From pgsql-performance-owner@postgresql.org Tue Dec 31 22:32:13 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7A00C475DDA for ; Tue, 31 Dec 2002 22:32:12 -0500 (EST) Received: from kaukau.mcs.vuw.ac.nz (kaukau.mcs.vuw.ac.nz [130.195.5.20]) by postgresql.org (Postfix) with ESMTP id 0D13F475B47 for ; Tue, 31 Dec 2002 22:32:10 -0500 (EST) Received: from devon.mcs.vuw.ac.nz (devon.mcs.vuw.ac.nz [130.195.5.109]) by kaukau.mcs.vuw.ac.nz (8.12.6/8.12.6) with ESMTP id h013WDC6008506 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT) for ; Wed, 1 Jan 2003 16:32:13 +1300 (NZDT) Received: from localhost (localhost [[UNIX: localhost]]) by devon.mcs.vuw.ac.nz (8.11.6/8.11.1) id h013WAc05325 for pgsql-performance@postgresql.org; Wed, 1 Jan 2003 16:32:10 +1300 (NZDT) Content-Type: text/plain; charset="us-ascii" From: Minghann Ho To: pgsql-performance@postgresql.org Subject: alter table TBL add constraint TBL_FK foreign key ... very slow Date: Wed, 1 Jan 2003 16:32:10 +1300 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200301011632.10433.Minghann.Ho@mcs.vuw.ac.nz> X-Scanned-By: MIMEDefang 2.24 (www . roaringpenguin . com / mimedefang) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/229 X-Sequence-Number: 645 Hi all, I've experienced very slow performance to add foreign key constraints using ALTER TABLE ADD CONSTRAINT FOREIGN KEY ... After using COPY ... FROM to load the base tables, I started to build the referential integrity between tables. I have 3 tables: T1 (6 million records), T2 (1.5 million records) and T3 (0.8 million records). One of the RI - foreign key (T1 -> T2) constraint took about 70 hrs to build. The other RI - foreign key (T1 -> T3) constraint took about 200 hrs and yet completed!! (compound foreign key) I tried to use small subset of the tables of T2 and T3 to do the testing. An estimation show that it need about 960 hrs to build the RI - foreign key constraints on table T1 -> T3 !!! I've read in the archives that some people suffered slow performance of this problem in Aug 2000, but there was no further information about the solution. Please anyone who has experience in this issues can give me some hint. Thanks Hans From pgsql-performance-owner@postgresql.org Tue Dec 31 22:38:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 650BB475DDA; Tue, 31 Dec 2002 22:38:06 -0500 (EST) Received: from kaukau.mcs.vuw.ac.nz (kaukau.mcs.vuw.ac.nz [130.195.5.20]) by postgresql.org (Postfix) with ESMTP id 6696D475B47; Tue, 31 Dec 2002 22:38:05 -0500 (EST) Received: from devon.mcs.vuw.ac.nz (devon.mcs.vuw.ac.nz [130.195.5.109]) by kaukau.mcs.vuw.ac.nz (8.12.6/8.12.6) with ESMTP id h013c8C6008672 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Wed, 1 Jan 2003 16:38:09 +1300 (NZDT) Received: from localhost (localhost [[UNIX: localhost]]) by devon.mcs.vuw.ac.nz (8.11.6/8.11.1) id h013c6R05361; Wed, 1 Jan 2003 16:38:06 +1300 (NZDT) Content-Type: text/plain; charset="us-ascii" From: Minghann Ho To: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org, pgsql-admin@postgresql.org Subject: alter table TBL add constraint TBL_FK foreign key ... very slow Date: Wed, 1 Jan 2003 16:38:06 +1300 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200301011638.06045.mho@mcs.vuw.ac.nz> X-Scanned-By: MIMEDefang 2.24 (www . roaringpenguin . com / mimedefang) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/230 X-Sequence-Number: 646 Hi all, I've experienced very slow performance to add foreign key constraints using ALTER TABLE ADD CONSTRAINT FOREIGN KEY ... After using COPY ... FROM to load the base tables, I started to build the referential integrity between tables. I have 3 tables: T1 (6 million records), T2 (1.5 million records) and T3 (0.8 million records). One of the RI - foreign key (T1 -> T2) constraint took about 70 hrs to build. The other RI - foreign key (T1 -> T3) constraint took about 200 hrs and yet completed!! (compound foreign key) I tried to use small subset of the tables of T2 and T3 to do the testing. An estimation show that it need about 960 hrs to build the RI - foreign key constraints on table T1 -> T3 !!! I've read in the archives that some people suffered slow performance of this problem in Aug 2000, but there was no further information about the solution. Please anyone who has experience in this issues can give me some hint. Thanks Hans From pgsql-performance-owner@postgresql.org Tue Dec 31 22:38:50 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 34A00475E24 for ; Tue, 31 Dec 2002 22:38:50 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id C0BBF475B47 for ; Tue, 31 Dec 2002 22:38:49 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 35D42D610; Tue, 31 Dec 2002 19:38:54 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 2B8395C02; Tue, 31 Dec 2002 19:38:54 -0800 (PST) Date: Tue, 31 Dec 2002 19:38:54 -0800 (PST) From: Stephan Szabo To: Minghann Ho Cc: Subject: Re: alter table TBL add constraint TBL_FK foreign key ... In-Reply-To: <200301011632.10433.Minghann.Ho@mcs.vuw.ac.nz> Message-ID: <20021231193351.U68640-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/231 X-Sequence-Number: 647 On Wed, 1 Jan 2003, Minghann Ho wrote: > I've experienced very slow performance to add foreign key constraints using > ALTER TABLE ADD CONSTRAINT FOREIGN KEY ... > > After using COPY ... FROM to load the base tables, I started to build the > referential integrity between tables. > I have 3 tables: T1 (6 million records), T2 (1.5 million records) and T3 (0.8 > million records). > One of the RI - foreign key (T1 -> T2) constraint took about 70 hrs to build. > The other RI - foreign key (T1 -> T3) constraint took about 200 hrs and yet > completed!! (compound foreign key) > > I tried to use small subset of the tables of T2 and T3 to do the testing. > An estimation show that it need about 960 hrs to build the RI - foreign key > constraints on table T1 -> T3 !!! It's running the constraint check for each row in the foreign key table. Rather than using a call to the function and a select for each row, it could probably be done in a single select with a not exists subselect, but that hasn't been done yet. There's also been talk about allowing some mechanism to allow the avoidance of the create time check, but I don't think any concensus was reached. From pgsql-performance-owner@postgresql.org Wed Jan 1 03:14:42 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7F5D5475A3F for ; Wed, 1 Jan 2003 03:14:39 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id C22204753A1 for ; Wed, 1 Jan 2003 03:14:37 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030101081438.BSNC26808.lakemtao03.cox.net@[192.168.1.1]> for ; Wed, 1 Jan 2003 03:14:38 -0500 Subject: Re: alter table TBL add constraint TBL_FK foreign key From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <200301011632.10433.Minghann.Ho@mcs.vuw.ac.nz> References: <200301011632.10433.Minghann.Ho@mcs.vuw.ac.nz> Content-Type: text/plain Organization: Message-Id: <1041408874.16580.39.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 01 Jan 2003 02:14:34 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/1 X-Sequence-Number: 648 On Tue, 2002-12-31 at 21:32, Minghann Ho wrote: > Hi all, > > I've experienced very slow performance to add foreign key constraints using > ALTER TABLE ADD CONSTRAINT FOREIGN KEY ... > > After using COPY ... FROM to load the base tables, I started to build the > referential integrity between tables. > I have 3 tables: T1 (6 million records), T2 (1.5 million records) and T3 (0.8 > million records). > One of the RI - foreign key (T1 -> T2) constraint took about 70 hrs to build. > The other RI - foreign key (T1 -> T3) constraint took about 200 hrs and yet > completed!! (compound foreign key) > > I tried to use small subset of the tables of T2 and T3 to do the testing. > An estimation show that it need about 960 hrs to build the RI - foreign key > constraints on table T1 -> T3 !!! > > I've read in the archives that some people suffered slow performance of this > problem in Aug 2000, but there was no further information about the solution. > > Please anyone who has experience in this issues can give me some hint. Silly question: Are T2 & T3 compound-key indexed on the relevant foreign key fields (in the exact order that they are mentioned in the ADD CONSTRAINT command)? Otherwise, for each record in T1, it is scanning T2 1.5M times (9E12 record reads!), with a similar formula for T1->T3. -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Jan 16 04:55:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 69664475E97 for ; Thu, 16 Jan 2003 04:55:36 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id A5999475D93 for ; Thu, 16 Jan 2003 04:55:35 -0500 (EST) Received: from klaster.net (pe26.krakow.cvx.ppp.tpnet.pl [213.76.40.26]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 512FB2B84B; Thu, 16 Jan 2003 10:52:22 +0100 (CET) Message-ID: <3E12BBEA.5020105@klaster.net> Date: Wed, 01 Jan 2003 10:59:06 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Roman Fail Cc: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/136 X-Sequence-Number: 783 Roman Fail wrote: > The same result columns and JOINS are performed all day with variations on the WHERE clause; Are there any where clauses which all of theses variation have? If yes - query can be reordered to contain explicit joins for these clauses and to let Postgres to find best solution for other joins. I know, it is not best solution, but sometimes I prefer finding best join order by myself. I create then several views returning the same values, but manualy ordered for specific where clauses. Tomasz Myrta From pgsql-performance-owner@postgresql.org Wed Jan 1 16:01:15 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 58094476065 for ; Wed, 1 Jan 2003 16:01:14 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 9D2AF475F2B for ; Wed, 1 Jan 2003 16:01:13 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h01L1Ed0008338; Wed, 1 Jan 2003 16:01:14 -0500 (EST) To: "Neil Conway" Cc: mt_pgsql@yahoo.com, pgsql-performance@postgresql.org Subject: Re: preliminary testing, two very slow situations... In-reply-to: <2973.24.112.166.30.1041375927.squirrel@mailbox.samurai.com> References: <20021231221435.26755.qmail@web14810.mail.yahoo.com> <2973.24.112.166.30.1041375927.squirrel@mailbox.samurai.com> Comments: In-reply-to "Neil Conway" message dated "Tue, 31 Dec 2002 18:05:27 -0500" Date: Wed, 01 Jan 2003 16:01:13 -0500 Message-ID: <8337.1041454873@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/2 X-Sequence-Number: 649 "Neil Conway" writes: > Michael Teter said: >> Now I'm trying to evaluate it as a possible >> replacement for MS SQL Server. > What version of PostgreSQL are you using? > [suggestions for tuning] The only reason I can think of for COPY to be as slow as Michael is describing is if it's checking foreign-key constraints (and even then it'd have to be using very inefficient plans for the check queries). So we should ask not only about the PG version, but also about the exact table declarations involved. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 2 09:57:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 715F54761C5 for ; Thu, 2 Jan 2003 09:57:16 -0500 (EST) Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by postgresql.org (Postfix) with ESMTP id ADF324760CE for ; Thu, 2 Jan 2003 09:57:15 -0500 (EST) Received: (from smtp@localhost) by ll.mit.edu (8.11.3/8.8.8) id h02EvFY20211 for ; Thu, 2 Jan 2003 09:57:15 -0500 (EST) Received: from sty.llan.ll.mit.edu( ), claiming to be "sty.llan" via SMTP by llpost, id smtpdAAAgEay9G; Thu Jan 2 09:56:57 2003 Date: Thu, 2 Jan 2003 10:57:27 -0500 From: george young To: pgsql-performance@postgresql.org Subject: Re: preliminary testing, two very slow situations... Message-Id: <20030102105727.4fa0bf7e.gry@ll.mit.edu> Reply-To: gry@ll.mit.edu Organization: MIT Lincoln Laboratory X-Mailer: Sylpheed version 0.8.5 (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 AMaViS new-20020517 X-Archive-Number: 200301/3 X-Sequence-Number: 650 On Tue, 31 Dec 2002 14:14:34 -0800 (PST) Michael Teter wrote: > I've used PostgreSQL in the past on a small project, > and I thought it was great. > > Now I'm trying to evaluate it as a possible > replacement for MS SQL Server. > > I have two issues: > > 1. I have a homegrown Java migration tool I wrote that > seems to work reasonably well, but I'm hoping to > understand how to improve its performance. > > 2. After migrating, I found pg_dump to be plenty > quick, but psql < (to completely reload the database) > to be very very slow during the COPY stage. I've found that "psql -f myfile mydb" is Much faster than "psql mydb Now for more detail. On problem 1., I have autocommit > off, and I'm doing PreparedStatement.addBatch() and > executeBatch(), and eventually, commit. > > I've been playing with the amount of rows I do before > executeBatch(), and I seem to do best with 20,000 to > 50,000 rows in a batch. Some background: this is > RedHat8.0 with all the latest RedHat patches, 1GB > RAMBUS RAM, 2GHz P4, 40GB 7200RPM HD. Watching > gkrellm and top, I see a good bit of CPU use by > postmaster duing the addBatch()es, but then when > executeBatch() comes, CPU goes almost totally idle, > and disk starts churning. Somehow it seems the disk > isn't being utilized to the fullest, but I'm just > guessing. > > I'm wondering if there's some postmaster tuning I > might do to improve this. > > Then on problem 2., a pg_dump of the database takes > about 3 minutes, and creates a file of 192MB in size. > Then I create testdb and do psql -e testdb > section. So far it's been running for 45 minutes, > mostly on one table (the biggest table, which has > 1,090,000 rows or so). During this time, CPU use is > very low, and there's no net or lo traffic. > > In contrast, using MSSQL's backup and restore > facilities, it takes about 15 second on a previous > generation box (with SCSI though) to backup, and 45 > seconds to a minute to restore. > > Suggestions? > > Thanks, > MT > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- I cannot think why the whole bed of the ocean is not one solid mass of oysters, so prolific they seem. Ah, I am wandering! Strange how the brain controls the brain! -- Sherlock Holmes in "The Dying Detective" -- I cannot think why the whole bed of the ocean is not one solid mass of oysters, so prolific they seem. Ah, I am wandering! Strange how the brain controls the brain! -- Sherlock Holmes in "The Dying Detective" From pgsql-performance-owner@postgresql.org Thu Jan 2 12:40:04 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5F71247607B for ; Thu, 2 Jan 2003 12:40:03 -0500 (EST) Received: from local.iboats.com (local.iboats.com [209.63.105.131]) by postgresql.org (Postfix) with SMTP id 9C687475FB0 for ; Thu, 2 Jan 2003 12:40:02 -0500 (EST) Received: (qmail 27751 invoked by uid 82); 2 Jan 2003 10:39:40 -0700 Received: from nw@codon.com by local.iboats.com by uid 81 with qmail-scanner-1.14 ( Clear:. Processed in 0.029668 secs); 02 Jan 2003 17:39:40 -0000 Received: from unknown (HELO WEASEL) (209.63.105.136) by 0 with SMTP; 2 Jan 2003 10:39:40 -0700 Message-ID: <008701c2b286$4c9c2ae0$88693fd1@WEASEL> From: "Steve Wolfe" To: Subject: Question on hardware & server capacity Date: Thu, 2 Jan 2003 10:42:05 -0700 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/4 X-Sequence-Number: 651 Well, our current database server is getting tremendously loaded, and right now there isn't a clear-cut choice as to an upgrade path - at least not within the commodity hardware market. The machine is a dual AthlonMP 2000, with 2 gigs of RAM. the loads on the machine are getting out of hand, and performance is noticeably slowed. 'top' shows the CPU's as being anywhere from 30% to 50% idle, with (on average) 5-10 postmasters in the "non-idle" state. 'vmstat' shows bi/bo pegged at zero (copious quantities of disk cache, fsync turned off), interrupts fluctuating between 200 and 1,000 per second (avg. is approx 400), context switches between 1300 and 4500 (avg. is approx 2300). I logged some queries, and found that in an average second, the machine forks off 10 new backends, and responds to 50 selects and 3 updates. My feelings are that the machine is being swamped by both the number of context switches and the I/O, most likely the memory bandwidth. I'm working on implementing some connection pooling to reduce the number of new backends forked off, but there's not much I can do about the sheer volume (or cost) of queries. Now, if quad-Hammers were here, I'd simply throw hardware at it. Unfortunately, they're not. So far, about the only commodity-level answer I can think of would be a dual P4 Xeon, with the 533 MHz bus, and dual-channel DDR memory. That would give each processor approximately double the memory bandwidth over what we're currently running. I'm fairly sure that would at least help lower the load, but I'm not sure by how much. If anyone has run testing under similar platforms, I'd love to hear of the performance difference. If this is going to chop the loads in half, I'll do it. If it's only going to improve it by 10% or so, I'm not going to waste the money. Steve From pgsql-performance-owner@postgresql.org Thu Jan 2 14:44:37 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 70F6E476C8E for ; Thu, 2 Jan 2003 14:44:34 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id AF3A4476C19 for ; Thu, 2 Jan 2003 14:42:02 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h02JfxMf019791 for ; Thu, 2 Jan 2003 11:42:00 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.30.55]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Thu, 2 Jan 2003 11:42:02 -0800 Date: Thu, 2 Jan 2003 11:42:02 -0800 Mime-Version: 1.0 (Apple Message framework v551) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: join over 12 tables takes 3 secs to plan From: Hilmar Lapp To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: <43D30901-1E8A-11D7-9244-000393B4BFF6@gmx.net> X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 02 Jan 2003 19:42:02.0605 (UTC) FILETIME=[05BFB1D0:01C2B297] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/5 X-Sequence-Number: 652 I have a query generated by an application (not mine, but there's nothing I can find that looks bad about the query itself) that takes an excessive amount of time to return even though there are almost no rows in the schema yet. 3 secs may not seem to be much, but the query is run by a web-application for a page you have to go through quite frequently, and it appears the query should be able to execute below 1 sec easily. I'm running Postgres 7.3.1 on Mac OSX. After having turned on several logging options, here is a pertinent excerpt from the log that also shows the query. It seems the query planner takes the whole time, not the actual execution. Does anyone have an idea what's going on here, and what I could do to alleviate the problem? (Just to mention, I've run the same with GEQO off and if anything it makes the timing worse.) 2003-01-02 11:22:59 LOG: query: SELECT TW.WORKITEMKEY, TW.PACKAGESYNOPSYS, TW.PACKAGEDESCRIPTION, TW.BUILD, TW.LASTEDIT, TOW.LASTNAME AS LOWNER, TOW.FIRSTNAME AS FOWNER, TOR.LASTNAME AS LORIGINATOR, TOR.FIRSTNAME AS FORIGINATOR, TRE.LASTNAME AS LRESPONSIBLE, TRE.FIRSTNAME AS FRESPONSIBLE, TPRJC.LABEL AS PROJCATLABEL, TPRJ.LABEL AS PROJLABEL, TCL.LABEL AS REQCLASS, TW.CATEGORYKEY AS REQCATEGORY, TW.PRIORITYKEY AS REQPRIORITY, TW.SEVERITYKEY AS REQSEVERITY, TST.LABEL AS STATELABEL, TW.STATE, TST.STATEFLAG, TREL.LABEL AS RELEASELABEL, TW.ENDDATE FROM TWORKITEM TW, TPERSON TOW, TPERSON TOR, TPERSON TRE, TPROJECT TPRJ, TPROJCAT TPRJC, TCATEGORY TCAT, TCLASS TCL, TPRIORITY TPRIO, TSEVERITY TSEV, TSTATE TST, TRELEASE TREL WHERE (TW.OWNER = TOW.PKEY) AND (TW.ORIGINATOR = TOR.PKEY) AND (TW.RESPONSIBLE = TRE.PKEY) AND (TW.PROJCATKEY = TPRJC.PKEY) AND (TPRJ.PKEY = TPRJC.PROJKEY) AND (TW.CLASSKEY = TCL.PKEY) AND (TW.CATEGORYKEY = TCAT.PKEY) AND (TW.PRIORITYKEY = TPRIO.PKEY) AND (TW.SEVERITYKEY = TSEV.PKEY) AND (TST.PKEY = TW.STATE) AND (TREL.PKEY = TW.RELSCHEDULEDKEY) 2003-01-02 11:23:02 LOG: PLANNER STATISTICS ! system usage stats: ! 2.730501 elapsed 1.400000 user 0.000000 system sec ! [3.580000 user 0.000000 sys total] ! 0/0 [0/0] filesystem blocks in/out ! 0/0 [0/0] page faults/reclaims, 0 [0] swaps ! 0 [0] signals rcvd, 0/0 [0/14] messages rcvd/sent ! 0/0 [24/0] voluntary/involuntary context switches ! buffer usage stats: ! Shared blocks: 0 read, 0 written, buffer hit rate = 0.00% ! Local blocks: 0 read, 0 written, buffer hit rate = 0.00% ! Direct blocks: 0 read, 0 written 2003-01-02 11:23:02 LOG: EXECUTOR STATISTICS ! system usage stats: ! 0.005024 elapsed 0.000000 user 0.000000 system sec ! [3.580000 user 0.000000 sys total] ! 0/0 [0/0] filesystem blocks in/out ! 0/0 [0/0] page faults/reclaims, 0 [0] swaps ! 0 [0] signals rcvd, 0/0 [0/14] messages rcvd/sent ! 0/0 [24/0] voluntary/involuntary context switches ! buffer usage stats: ! Shared blocks: 0 read, 0 written, buffer hit rate = 100.00% ! Local blocks: 0 read, 0 written, buffer hit rate = 0.00% ! Direct blocks: 0 read, 0 written 2003-01-02 11:23:02 LOG: duration: 2.740243 sec 2003-01-02 11:23:02 LOG: QUERY STATISTICS ! system usage stats: ! 0.006432 elapsed 0.000000 user 0.000000 system sec ! [3.580000 user 0.000000 sys total] ! 0/0 [0/0] filesystem blocks in/out ! 0/0 [0/0] page faults/reclaims, 0 [0] swaps ! 0 [0] signals rcvd, 0/0 [0/14] messages rcvd/sent ! 0/0 [24/0] voluntary/involuntary context switches ! buffer usage stats: ! Shared blocks: 0 read, 0 written, buffer hit rate = 100.00% ! Local blocks: 0 read, 0 written, buffer hit rate = 0.00% ! Direct blocks: 0 read, 0 written -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Jan 2 15:05:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F100C476B06 for ; Thu, 2 Jan 2003 15:05:53 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3CB0B4769FF for ; Thu, 2 Jan 2003 14:57:36 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h02JvY0U003256; Thu, 2 Jan 2003 14:57:35 -0500 (EST) To: "Steve Wolfe" Cc: pgsql-performance@postgresql.org Subject: Re: Question on hardware & server capacity In-reply-to: <008701c2b286$4c9c2ae0$88693fd1@WEASEL> References: <008701c2b286$4c9c2ae0$88693fd1@WEASEL> Comments: In-reply-to "Steve Wolfe" message dated "Thu, 02 Jan 2003 10:42:05 -0700" Date: Thu, 02 Jan 2003 14:57:34 -0500 Message-ID: <3255.1041537454@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/6 X-Sequence-Number: 653 "Steve Wolfe" writes: > I logged some queries, and found that in an average second, the machine > forks off 10 new backends, and responds to 50 selects and 3 updates. So an average backend only processes ~ 5 queries before exiting? > My feelings are that the machine is being swamped by both the number of > context switches and the I/O, most likely the memory bandwidth. I think you're getting killed by the lack of connection pooling. Launching a new backend is moderately expensive: there's not just the OS-level fork overhead, but significant cost to fill the catalog caches to useful levels, etc. 7.3 has reduced some of those startup costs a little, so if you're still on 7.2 then an update might help. But I'd strongly recommend getting connection re-use in place before you go off and buy hardware. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 2 15:34:34 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B3AB2476767 for ; Thu, 2 Jan 2003 15:34:32 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 232D7476DD1 for ; Thu, 2 Jan 2003 15:24:21 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h02KOK0U003560; Thu, 2 Jan 2003 15:24:20 -0500 (EST) To: Hilmar Lapp Cc: pgsql-performance@postgresql.org Subject: Re: join over 12 tables takes 3 secs to plan In-reply-to: <43D30901-1E8A-11D7-9244-000393B4BFF6@gmx.net> References: <43D30901-1E8A-11D7-9244-000393B4BFF6@gmx.net> Comments: In-reply-to Hilmar Lapp message dated "Thu, 02 Jan 2003 11:42:02 -0800" Date: Thu, 02 Jan 2003 15:24:20 -0500 Message-ID: <3559.1041539060@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/7 X-Sequence-Number: 654 Hilmar Lapp writes: > I have a query generated by an application (not mine, but there's > nothing I can find that looks bad about the query itself) that takes an > excessive amount of time to return even though there are almost no rows > in the schema yet. Read http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit-joins.html regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 2 15:48:32 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 52835476D4D for ; Thu, 2 Jan 2003 15:48:31 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 31341476E24 for ; Thu, 2 Jan 2003 15:41:23 -0500 (EST) Received: from samurai.com (localhost [127.0.0.1]) by bob.samurai.com (Postfix) with SMTP id 004F91D5C; Thu, 2 Jan 2003 15:41:24 -0500 (EST) Received: from cpe00d0096a6cd5.cpe.net.cable.rogers.com ([24.112.166.30]) (SquirrelMail authenticated user neilc) by mailbox.samurai.com with HTTP; Thu, 2 Jan 2003 15:41:24 -0500 (EST) Message-ID: <1309.24.112.166.30.1041540084.squirrel@mailbox.samurai.com> Date: Thu, 2 Jan 2003 15:41:24 -0500 (EST) Subject: Re: join over 12 tables takes 3 secs to plan From: "Neil Conway" To: In-Reply-To: <43D30901-1E8A-11D7-9244-000393B4BFF6@gmx.net> References: <43D30901-1E8A-11D7-9244-000393B4BFF6@gmx.net> X-Priority: 3 Importance: Normal Cc: X-Mailer: SquirrelMail (version 1.2.9) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/8 X-Sequence-Number: 655 Hilmar Lapp said: > I have a query generated by an application (not mine, but there's > nothing I can find that looks bad about the query itself) that takes an > excessive amount of time to return even though there are almost no rows > in the schema yet. Yes -- an exhaustive search to determine the correct join order for a multiple relation query is similar to solving the traveling salesman problem (only more difficult, due to the availability of different join algorithms, etc.). GEQO should be faster than the default optimizer for large queries involving large numbers of joins, but it's still going to take a fair bit of time. In other words, it's not a surprise that a 12-relation join takes a little while to plan. > I'm running Postgres 7.3.1 on Mac OSX. Tom recently checked in some optimizations for GEQO in CVS HEAD, so you could try using that (or at least testing it, so you have an idea of what 7.4 will perform like). You could also try using prepared queries. Finally, there are a bunch of GEQO tuning parameters that you might want to play with. They should allow you to reduce the planning time a bit, in exchange for possibly generating an inferior plan. Cheers, Neil From pgsql-performance-owner@postgresql.org Thu Jan 2 15:57:35 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6192476048 for ; Thu, 2 Jan 2003 15:57:32 -0500 (EST) Received: from local.iboats.com (local.iboats.com [209.63.105.131]) by postgresql.org (Postfix) with SMTP id 52746476419 for ; Thu, 2 Jan 2003 15:57:08 -0500 (EST) Received: (qmail 17032 invoked by uid 82); 2 Jan 2003 13:56:43 -0700 Received: from nw@codon.com by local.iboats.com by uid 81 with qmail-scanner-1.14 ( Clear:. Processed in 0.027759 secs); 02 Jan 2003 20:56:43 -0000 Received: from unknown (HELO WEASEL) (209.63.105.136) by 0 with SMTP; 2 Jan 2003 13:56:42 -0700 Message-ID: <006401c2b2a1$d322fec0$88693fd1@WEASEL> From: "Steve Wolfe" To: References: <008701c2b286$4c9c2ae0$88693fd1@WEASEL> <3255.1041537454@sss.pgh.pa.us> Subject: Re: Question on hardware & server capacity Date: Thu, 2 Jan 2003 13:59:19 -0700 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/9 X-Sequence-Number: 656 > So an average backend only processes ~ 5 queries before exiting? > > 7.3 has reduced some of those startup costs a little, so if you're still > on 7.2 then an update might help. But I'd strongly recommend getting > connection re-use in place before you go off and buy hardware. I've been fooling around with some connection pooling, and it hasn't make the sort of difference we're looking for. Going from 3 queries per back-end to 100 queries per backend made only about a 20% difference. While that's nothing to scoff at, we're looking for at least a 100% improvement. Either way, the connection pooling WILL be put in place, but I'm certainly not counting on it preventing the need for a hardware upgrade. steve From pgsql-performance-owner@postgresql.org Thu Jan 2 16:03:58 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8E32F476376 for ; Thu, 2 Jan 2003 16:03:57 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id A216B476264 for ; Thu, 2 Jan 2003 16:03:56 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h02L3pMf020143 for ; Thu, 2 Jan 2003 13:03:51 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.30.55]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Thu, 2 Jan 2003 13:03:54 -0800 Date: Thu, 2 Jan 2003 13:03:54 -0800 Subject: Re: join over 12 tables takes 3 secs to plan Content-Type: text/plain; delsp=yes; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: pgsql-performance@postgresql.org To: Tom Lane From: Hilmar Lapp In-Reply-To: <3559.1041539060@sss.pgh.pa.us> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 02 Jan 2003 21:03:54.0996 (UTC) FILETIME=[75C31340:01C2B2A2] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/10 X-Sequence-Number: 657 Thanks for the pointer Tom. The application that's generating those queries is open source, so I could even go in and hack the query generating code accordingly, but I doubt I can spare that time. Given the information in the document you pointed me at and Neil's email I assume there is no other immediate remedy. As an added note, appreciating that query optimization is a difficult problem, and I do think PostgreSQL is a great product. Having said that, I've written 16-table joins for Oracle and always found them to plan within a second or two, so that's why I thought there's nothing special about the query I posted ... I'm not saying this to be bashful about PostgreSQL, but rather to suggest that apparently there are ways to do it pretty fast. I'm only starting to use PostgreSQL and making experiences, so I'm asking for forgiveness what may occasionally seem to be ignorant ... -hilmar On Thursday, January 2, 2003, at 12:24 PM, Tom Lane wrote: > Hilmar Lapp writes: >> I have a query generated by an application (not mine, but there's >> nothing I can find that looks bad about the query itself) that takes >> an >> excessive amount of time to return even though there are almost no >> rows >> in the schema yet. > > Read > http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit- > joins.html > > regards, tom lane > > -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Jan 2 16:08:25 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0BAA847610A for ; Thu, 2 Jan 2003 16:08:25 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id E21484760AF for ; Thu, 2 Jan 2003 16:08:23 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h02L8MMf020161 for ; Thu, 2 Jan 2003 13:08:22 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.30.55]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Thu, 2 Jan 2003 13:08:25 -0800 Date: Thu, 2 Jan 2003 13:08:24 -0800 Subject: Re: join over 12 tables takes 3 secs to plan Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: To: "Neil Conway" From: Hilmar Lapp In-Reply-To: <1309.24.112.166.30.1041540084.squirrel@mailbox.samurai.com> Message-Id: <54E69E80-1E96-11D7-9244-000393B4BFF6@gmx.net> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 02 Jan 2003 21:08:25.0130 (UTC) FILETIME=[16C640A0:01C2B2A3] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/11 X-Sequence-Number: 658 On Thursday, January 2, 2003, at 12:41 PM, Neil Conway wrote: > > Finally, there are a bunch of GEQO tuning parameters that you might > want > to play with. They should allow you to reduce the planning time a bit, > in > exchange for possibly generating an inferior plan. > > Thanks for the tip. I have to admit that I have zero experience with tuning GAs. If anyone could provide a starter which parameters are best to start with? Or is it in the docs? -hilmar -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Jan 2 16:11:35 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BB138476048 for ; Thu, 2 Jan 2003 16:11:33 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 401AB475F5D for ; Thu, 2 Jan 2003 16:11:33 -0500 (EST) Received: from samurai.com (localhost [127.0.0.1]) by bob.samurai.com (Postfix) with SMTP id 75E3B1F2C; Thu, 2 Jan 2003 16:11:34 -0500 (EST) Received: from cpe00d0096a6cd5.cpe.net.cable.rogers.com ([24.112.166.30]) (SquirrelMail authenticated user neilc) by mailbox.samurai.com with HTTP; Thu, 2 Jan 2003 16:11:34 -0500 (EST) Message-ID: <1455.24.112.166.30.1041541894.squirrel@mailbox.samurai.com> Date: Thu, 2 Jan 2003 16:11:34 -0500 (EST) Subject: Re: join over 12 tables takes 3 secs to plan From: "Neil Conway" To: In-Reply-To: <54E69E80-1E96-11D7-9244-000393B4BFF6@gmx.net> References: <1309.24.112.166.30.1041540084.squirrel@mailbox.samurai.com> <54E69E80-1E96-11D7-9244-000393B4BFF6@gmx.net> X-Priority: 3 Importance: Normal Cc: X-Mailer: SquirrelMail (version 1.2.9) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/12 X-Sequence-Number: 659 Hilmar Lapp said: > Thanks for the tip. I have to admit that I have zero experience with > tuning GAs. If anyone could provide a starter which parameters are best > to start with? Or is it in the docs? http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/runtime-config.html lists the available options. I'd think that GEQO_EFFORT, GEQO_GENERATIONS, and GEQO_POOL_SIZE would be the parameters that would effect performance the most. Cheers, Neil From pgsql-performance-owner@postgresql.org Thu Jan 2 16:21:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0E292476D44 for ; Thu, 2 Jan 2003 16:21:55 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 95A34476CD8 for ; Thu, 2 Jan 2003 16:21:27 -0500 (EST) Received: from samurai.com (localhost [127.0.0.1]) by bob.samurai.com (Postfix) with SMTP id BEB511F2C; Thu, 2 Jan 2003 16:21:28 -0500 (EST) Received: from cpe00d0096a6cd5.cpe.net.cable.rogers.com ([24.112.166.30]) (SquirrelMail authenticated user neilc) by mailbox.samurai.com with HTTP; Thu, 2 Jan 2003 16:21:28 -0500 (EST) Message-ID: <1477.24.112.166.30.1041542488.squirrel@mailbox.samurai.com> Date: Thu, 2 Jan 2003 16:21:28 -0500 (EST) Subject: Re: join over 12 tables takes 3 secs to plan From: "Neil Conway" To: In-Reply-To: References: <3559.1041539060@sss.pgh.pa.us> X-Priority: 3 Importance: Normal Cc: , X-Mailer: SquirrelMail (version 1.2.9) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/13 X-Sequence-Number: 660 Hilmar Lapp said: > As an added note, appreciating that query optimization is a difficult > problem, and I do think PostgreSQL is a great product. Having said > that, I've written 16-table joins for Oracle and always found them to > plan within a second or two, so that's why I thought there's nothing > special about the query I posted ... I'm not saying this to be bashful > about PostgreSQL, but rather to suggest that apparently there are ways > to do it pretty fast. I'm sure there is room for improvement -- either by adding additional heuristics to the default optimizer, by improving GEQO, or by implementing another method for non-exhaustive search for large join queries (there are several ways to handle large join queries, only one of which uses a genetic algorithm: see "Query Optimization" (Ioannidis, 1996) for a good introductory survey). If you'd like to take a shot at improving it, let me know if I can be of any assistance :-) Cheers, Neil From pgsql-performance-owner@postgresql.org Thu Jan 2 16:29:40 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9B474475C8B for ; Thu, 2 Jan 2003 16:29:38 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id 0F47A474E53 for ; Thu, 2 Jan 2003 16:29:38 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h02LTaMf020318 for ; Thu, 2 Jan 2003 13:29:36 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.30.55]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Thu, 2 Jan 2003 13:29:39 -0800 Date: Thu, 2 Jan 2003 13:29:39 -0800 Subject: Re: join over 12 tables takes 3 secs to plan Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: , To: "Neil Conway" From: Hilmar Lapp In-Reply-To: <1477.24.112.166.30.1041542488.squirrel@mailbox.samurai.com> Message-Id: <4C57DC24-1E99-11D7-9244-000393B4BFF6@gmx.net> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 02 Jan 2003 21:29:39.0436 (UTC) FILETIME=[0E51EAC0:01C2B2A6] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/14 X-Sequence-Number: 661 On Thursday, January 2, 2003, at 01:21 PM, Neil Conway wrote: > If you'd like to take a shot at improving it, let me know if I can be > of > any assistance :-) > > Would be a very cool problem to work on once I enroll in a CS program :-) -hilmar -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Jan 2 16:42:10 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 34350475C8B for ; Thu, 2 Jan 2003 16:42:09 -0500 (EST) Received: from joeconway.com (unknown [63.210.180.150]) by postgresql.org (Postfix) with ESMTP id 85335474E53 for ; Thu, 2 Jan 2003 16:42:08 -0500 (EST) Received: from [192.168.5.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.2) with ESMTP-TLS id 1499578; Thu, 02 Jan 2003 14:15:41 -0800 Message-ID: <3E14B1C7.9040007@joeconway.com> Date: Thu, 02 Jan 2003 13:40:23 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2) Gecko/20021126 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Hilmar Lapp Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: join over 12 tables takes 3 secs to plan References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/15 X-Sequence-Number: 662 Hilmar Lapp wrote: > As an added note, appreciating that query optimization is a difficult > problem, and I do think PostgreSQL is a great product. Having said > that, I've written 16-table joins for Oracle and always found them to > plan within a second or two, so that's why I thought there's nothing > special about the query I posted ... I'm not saying this to be bashful > about PostgreSQL, but rather to suggest that apparently there are ways > to do it pretty fast. I could be wrong, but I believe Oracle uses its rule based optimizer by default, not its cost based optimizer. A rule based optimizer will be very quick all the time, but might not pick the best plan all the time, because it doesn't consider the statistics of the data. Any idea which one you were using in your Oracle experience? Joe From pgsql-performance-owner@postgresql.org Thu Jan 2 17:07:44 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CC87B475B99 for ; Thu, 2 Jan 2003 17:07:42 -0500 (EST) Received: from rh72.home.ee (unknown [194.204.44.121]) by postgresql.org (Postfix) with ESMTP id 5D037475B8E for ; Thu, 2 Jan 2003 17:07:41 -0500 (EST) Received: from rh72.home.ee (localhost.localdomain [127.0.0.1]) by rh72.home.ee (8.12.5/8.12.5) with ESMTP id h02M7aRX002831; Fri, 3 Jan 2003 03:07:37 +0500 Received: (from hannu@localhost) by rh72.home.ee (8.12.5/8.12.5/Submit) id h02M7Zrp002829; Fri, 3 Jan 2003 03:07:35 +0500 X-Authentication-Warning: rh72.home.ee: hannu set sender to hannu@tm.ee using -f Subject: Re: Question on hardware & server capacity From: Hannu Krosing To: Steve Wolfe Cc: pgsql-performance@postgresql.org In-Reply-To: <008701c2b286$4c9c2ae0$88693fd1@WEASEL> References: <008701c2b286$4c9c2ae0$88693fd1@WEASEL> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1041545254.2176.28.camel@rh72.home.ee> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 03 Jan 2003 03:07:34 +0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/16 X-Sequence-Number: 663 Steve Wolfe kirjutas N, 02.01.2003 kell 22:42: > Well, our current database server is getting tremendously loaded, and > right now there isn't a clear-cut choice as to an upgrade path - at least > not within the commodity hardware market. Have you optimized your queries to max ? Often one or two of the queries take most of resources and starve others. > The machine is a dual AthlonMP 2000, with 2 gigs of RAM. the loads on > the machine are getting out of hand, and performance is noticeably slowed. > 'top' shows the CPU's as being anywhere from 30% to 50% idle, with (on > average) 5-10 postmasters in the "non-idle" state. 'vmstat' shows bi/bo > pegged at zero (copious quantities of disk cache, fsync turned off), Could there be some unnecessary trashing between OS and PG caches ? How could this be detected ? > interrupts fluctuating between 200 and 1,000 per second (avg. is approx > 400), context switches between 1300 and 4500 (avg. is approx 2300). I > logged some queries, and found that in an average second, the machine > forks off 10 new backends, and responds to 50 selects and 3 updates. What are the average times for query responses ? Will running the same queries (the ones from the logs) serially run faster/slower/at the same speed ? Do you have some triggers on updates - I have occasionally found them to be real performance killers. Also - if memory bandwidth is the issue, you could tweak the parameters so that PG will prefer index scans more often - there are rumors that under heavy loads it is often better to use more index scans due to possible smaller memory/buffer use, even if they would be slower for only one or two backends. > My feelings are that the machine is being swamped by both the number of > context switches and the I/O, most likely the memory bandwidth. I'm > working on implementing some connection pooling to reduce the number of > new backends forked off, but there's not much I can do about the sheer > volume (or cost) of queries. You could try to replicate the updates (one master - multiple slaves) and distribute the selects. I guess this is what current postgreSQL state-of-the-art already lets you do with reasonable effort. > Now, if quad-Hammers were here, I'd simply throw hardware at it. > Unfortunately, they're not. Yes, it's BAD if your business grows faster than Moores law ;-p > So far, about the only commodity-level answer > I can think of would be a dual P4 Xeon, with the 533 MHz bus, and > dual-channel DDR memory. That would give each processor approximately > double the memory bandwidth over what we're currently running. > > I'm fairly sure that would at least help lower the load, but I'm not > sure by how much. If anyone has run testing under similar platforms, I'd > love to hear of the performance difference. How big is the dataset ? What kinds of queries ? I could perhaps run some quick tests on quad Xeon 1.40GHz , 2GB before this box goes to production sometime early next week. It is a RedHat AS2.1 box with rh-postgresql-7.2.3-1_as21. # hdparm -tT /dev/sda /dev/sda: Timing buffer-cache reads: 128 MB in 0.39 seconds =328.21 MB/sec Timing buffered disk reads: 64 MB in 1.97 seconds = 32.49 MB/sec > If this is going to chop the > loads in half, I'll do it. If it's only going to improve it by 10% or so, > I'm not going to waste the money. -- Hannu Krosing From pgsql-performance-owner@postgresql.org Thu Jan 2 17:51:20 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DFE26476D2E for ; Thu, 2 Jan 2003 17:51:18 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id 7DF8F47610A for ; Thu, 2 Jan 2003 17:49:01 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h02MmwMf020646 for ; Thu, 2 Jan 2003 14:48:59 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.30.55]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Thu, 2 Jan 2003 14:49:02 -0800 Date: Thu, 2 Jan 2003 14:49:01 -0800 Subject: Re: join over 12 tables takes 3 secs to plan Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: Tom Lane , pgsql-performance@postgresql.org To: Joe Conway From: Hilmar Lapp In-Reply-To: <3E14B1C7.9040007@joeconway.com> Message-Id: <630BD04E-1EA4-11D7-9B10-000393B4BFF6@gmx.net> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 02 Jan 2003 22:49:02.0448 (UTC) FILETIME=[254BDF00:01C2B2B1] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/17 X-Sequence-Number: 664 On Thursday, January 2, 2003, at 01:40 PM, Joe Conway wrote: > I could be wrong, but I believe Oracle uses its rule based optimizer > by default, not its cost based optimizer. They changed it from 9i on. The cost-based is now the default. The recent 16-table join example I was referring to was on the cost-based optimizer. They actually did an amazing good job on the CBO, at least in my experience. I caught it screwing up badly only once, only to realize that I had forgotten to compute the statistics ... It also allows for different plans depending on whether you want some rows fast and the total not necessarily as fast, or all rows as fast as possible. This also caught me off-guard initially when I wanted to peek into the first rows returned and had to wait almost as long as the entire query to return. (optimizing for all rows is the default) > A rule based optimizer will be very quick all the time, but might not > pick the best plan all the time, because it doesn't consider the > statistics of the data. True. In a situation with not that many rows though even a sub-optimal plan that takes 10x longer to execute than the possibly best (e.g., 1s vs 0.1s), but plans 10x faster (e.g. 0.3s vs 3s), might still return significantly sooner. Especially if some of the tables have been cached in memory already ... -hilmar -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Jan 2 19:01:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 17C15476C67 for ; Thu, 2 Jan 2003 19:01:16 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id 73E0C476C5B for ; Thu, 2 Jan 2003 19:01:15 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030103000118.QIVY2203.lakemtao02.cox.net@[192.168.1.1]> for ; Thu, 2 Jan 2003 19:01:18 -0500 Subject: Re: join over 12 tables takes 3 secs to plan From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <3E14B1C7.9040007@joeconway.com> References: <3E14B1C7.9040007@joeconway.com> Content-Type: text/plain Organization: Message-Id: <1041552070.16584.191.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 02 Jan 2003 18:01:10 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/18 X-Sequence-Number: 665 On Thu, 2003-01-02 at 15:40, Joe Conway wrote: > Hilmar Lapp wrote: > > As an added note, appreciating that query optimization is a difficult > > problem, and I do think PostgreSQL is a great product. Having said > > that, I've written 16-table joins for Oracle and always found them to > > plan within a second or two, so that's why I thought there's nothing > > special about the query I posted ... I'm not saying this to be bashful > > about PostgreSQL, but rather to suggest that apparently there are ways > > to do it pretty fast. > > I could be wrong, but I believe Oracle uses its rule based optimizer by > default, not its cost based optimizer. A rule based optimizer will be very > quick all the time, but might not pick the best plan all the time, because it > doesn't consider the statistics of the data. Any idea which one you were using > in your Oracle experience? Remember also that the commercial RDMBSs have had many engineers working for many years on these problems, whereas PostgreSQL hasn't... Could it be that PG isn't the proper tool for the job? Of course, at USD20K/cp, Oracle may be slightly out of budget. -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Jan 2 19:24:51 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 15C1F475EB9 for ; Thu, 2 Jan 2003 19:24:50 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id 7E421475B8E for ; Thu, 2 Jan 2003 19:24:49 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h030OmMf020987 for ; Thu, 2 Jan 2003 16:24:48 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.30.55]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Thu, 2 Jan 2003 16:24:52 -0800 Date: Thu, 2 Jan 2003 16:24:51 -0800 Subject: Re: join over 12 tables takes 3 secs to plan Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: PgSQL Performance ML To: Ron Johnson From: Hilmar Lapp In-Reply-To: <1041552070.16584.191.camel@haggis> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 03 Jan 2003 00:24:52.0601 (UTC) FILETIME=[88A79690:01C2B2BE] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/19 X-Sequence-Number: 666 On Thursday, January 2, 2003, at 04:01 PM, Ron Johnson wrote: > > Could it be that PG isn't the proper tool for the job? Of course, > at USD20K/cp, Oracle may be slightly out of budget. > > We are in fact an Oracle shop, but the application I tried to get running (http://trackplus.sourceforge.net/) I wanted to run on an OSS RDBMS so that I could easily move it onto my laptop etc (BTW apparently it was primarily developed on InterBase/Firebird). Anyway, I was able to cut the planning time for those queries in half by setting geqo_pool_size to 512. However, now it gets stuck for an excessive amount of time after the issue update page and I have no idea what's going on, and I'm not in the mood to track it down. So finally I'm giving up and I'm rolling it out on MySQL on which it is working fine, even though I don't like MySQL to say the least. -hilmar -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Jan 2 19:36:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4EBA7476CEE for ; Thu, 2 Jan 2003 19:36:11 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id A66D64766F6 for ; Thu, 2 Jan 2003 19:36:10 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id h030aAg19710; Thu, 2 Jan 2003 19:36:10 -0500 Message-ID: <3E14DAFC.3080409@clearmetrix.com> Date: Thu, 02 Jan 2003 19:36:12 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Hilmar Lapp Cc: Ron Johnson , PgSQL Performance ML Subject: Re: join over 12 tables takes 3 secs to plan References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/20 X-Sequence-Number: 667 Hilmar Lapp wrote: > We are in fact an Oracle shop, but the application I tried to get > running (http://trackplus.sourceforge.net/) I wanted to run on an OSS > RDBMS so that I could easily move it onto my laptop etc (BTW > apparently it was primarily developed on InterBase/Firebird). Anyway, > I was able to cut the planning time for those queries in half by > setting geqo_pool_size to 512. However, now it gets stuck for an > excessive amount of time after the issue update page and I have no > idea what's going on, and I'm not in the mood to track it down. So > finally I'm giving up and I'm rolling it out on MySQL on which it is > working fine, even though I don't like MySQL to say the least. > > -hilmar > Uhoh, did I just hear a gauntlet thrown down ... works well on MySQL but not on PostgreSQL. If I can find the time, perhaps I can take a look at the specific query(ies) and see what is missed in PostgreSQL that MySQL has gotten right. If only there were 48 hours in a day :-). Charlie -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com From pgsql-performance-owner@postgresql.org Fri Jan 3 12:10:21 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 51DC34763E7 for ; Fri, 3 Jan 2003 12:10:20 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id A4F0B4760E4 for ; Fri, 3 Jan 2003 12:10:19 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id h03H6449000834; Fri, 3 Jan 2003 10:06:40 -0700 (MST) Date: Fri, 3 Jan 2003 10:01:29 -0700 (MST) From: "scott.marlowe" To: Hilmar Lapp Cc: Ron Johnson , PgSQL Performance ML Subject: Re: join over 12 tables takes 3 secs to plan In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/21 X-Sequence-Number: 668 On Thu, 2 Jan 2003, Hilmar Lapp wrote: > > On Thursday, January 2, 2003, at 04:01 PM, Ron Johnson wrote: > > > > > Could it be that PG isn't the proper tool for the job? Of course, > > at USD20K/cp, Oracle may be slightly out of budget. > > > > > > We are in fact an Oracle shop, but the application I tried to get > running (http://trackplus.sourceforge.net/) I wanted to run on an OSS > RDBMS so that I could easily move it onto my laptop etc (BTW apparently > it was primarily developed on InterBase/Firebird). Anyway, I was able > to cut the planning time for those queries in half by setting > geqo_pool_size to 512. However, now it gets stuck for an excessive > amount of time after the issue update page and I have no idea what's > going on, and I'm not in the mood to track it down. So finally I'm > giving up and I'm rolling it out on MySQL on which it is working fine, > even though I don't like MySQL to say the least. Have you tried it on firebird for linux? It's an actively developed rdbms that's open source too. If this was developed for it, it might be a better fit to use that for now, and then learn postgresql under the less rigorous schedule of simply porting, not having to get a product out the door. Is an explicit join the answer here? i.e. will the number of rows we get from each table in a single query likely to never change? If so then you could just make an explicit join and be done with it. From pgsql-performance-owner@postgresql.org Fri Jan 3 12:12:37 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3EC3F4762E7 for ; Fri, 3 Jan 2003 12:12:36 -0500 (EST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.215.169]) by postgresql.org (Postfix) with SMTP id 7DAD64760E4 for ; Fri, 3 Jan 2003 12:12:35 -0500 (EST) Received: (qmail 51102 invoked from network); 3 Jan 2003 17:12:44 -0000 Received: from h00a0cc4084e5.ne.client2.attbi.com (threshar@24.128.215.169) by h00a0cc4084e5.ne.client2.attbi.com with SMTP; 3 Jan 2003 17:12:44 -0000 Date: Fri, 3 Jan 2003 12:12:44 -0500 (EST) From: Jeff X-X-Sender: threshar@torgo To: Hilmar Lapp Cc: "pgsql-performance@postgresql.org" Subject: Re: join over 12 tables takes 3 secs to plan In-Reply-To: <43D30901-1E8A-11D7-9244-000393B4BFF6@gmx.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/22 X-Sequence-Number: 669 On Thu, 2 Jan 2003, Hilmar Lapp wrote: > I have a query generated by an application (not mine, but there's > nothing I can find that looks bad about the query itself) that takes an > excessive amount of time to return even though there are almost no rows > in the schema yet. 3 secs may not seem to be much, but the query is run > by a web-application for a page you have to go through quite > frequently, and it appears the query should be able to execute below 1 > sec easily. I'm running Postgres 7.3.1 on Mac OSX. > Hmm.. This won't fix the fact the planner takes three seconds, but since it is a web application have you tried using PREPARE/EXECUTE so it only needs to be planned once? (Unless I am mistaken about what prepare/execute actually do) that way only the first visitor gets the hit.. ------------------------------------------------------------------------------ Jeff Trout http://www.jefftrout.com/ Ronald McDonald, with the help of cheese soup, controls America from a secret volkswagon hidden in the past ------------------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Fri Jan 3 12:31:28 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B4CE34764F1 for ; Fri, 3 Jan 2003 12:31:26 -0500 (EST) Received: from local.iboats.com (local.iboats.com [209.63.105.131]) by postgresql.org (Postfix) with SMTP id 72F00476DC2 for ; Fri, 3 Jan 2003 12:29:39 -0500 (EST) Received: (qmail 25122 invoked by uid 82); 3 Jan 2003 10:29:21 -0700 Received: from nw@codon.com by local.iboats.com by uid 81 with qmail-scanner-1.14 ( Clear:. Processed in 0.029907 secs); 03 Jan 2003 17:29:21 -0000 Received: from unknown (HELO WEASEL) (209.63.105.136) by 0 with SMTP; 3 Jan 2003 10:29:21 -0700 Message-ID: <012b01c2b34e$05e267e0$88693fd1@WEASEL> From: "Steve Wolfe" To: References: <008701c2b286$4c9c2ae0$88693fd1@WEASEL> <1041545254.2176.28.camel@rh72.home.ee> Subject: Re: Question on hardware & server capacity Date: Fri, 3 Jan 2003 10:31:54 -0700 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/23 X-Sequence-Number: 670 > Have you optimized your queries to max ? > > Often one or two of the queries take most of resources and starve > others. I did log a good number of queries and analyze them, and 69% of the queries issued are from one particular application, and they consume 78% of the total "cost". The developper is looking into optimizations, but it doesn't look like there's going to be any low-hanging fruit. It's simply a complicated and frequently-used app. > Could there be some unnecessary trashing between OS and PG caches ? > How could this be detected ? The machine generally has a minimum of a hundred megs free, unused memory, so I'm not terribly worried about memory thrashing. I've increased the various tuneable parameters (buffer blocks, sort mem, etc.) to the point where performance increases stopped, then I doubled them all for good measure. I've already decided that the next machine will have at least 4 gigs of RAM, just because RAM's cheap, and having too much is a Good Thing. > Do you have some triggers on updates - I have occasionally found them to > be real performance killers. There are a few triggers, but not many - and the number of updates is extremely low relative to the number of inserts. > Yes, it's BAD if your business grows faster than Moores law ;-p .. unfortunately, that's been the case. Each year we've done slightly more than double the traffic of the previous year - and at the same time, as we unify all of our various data sources, the new applications that we develop tend to make greater and greater demands on the database server. There is always the option of the "big iron", but your cost-per-transaction shoots through the roof. Paying a 10x premium can really hurt. : ) > How big is the dataset ? What kinds of queries ? our ~postgres/data/base is currently 3.4 gigs. > I could perhaps run some quick tests on quad Xeon 1.40GHz , 2GB before > this box goes to production sometime early next week. It is a RedHat > AS2.1 box with rh-postgresql-7.2.3-1_as21. I'd appreciate that! steve From pgsql-performance-owner@postgresql.org Fri Jan 3 13:14:58 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5FD06475CB1 for ; Fri, 3 Jan 2003 13:14:57 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 8F5684763D3 for ; Fri, 3 Jan 2003 13:14:56 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id h03IBDIk005142; Fri, 3 Jan 2003 11:11:13 -0700 (MST) Date: Fri, 3 Jan 2003 11:06:38 -0700 (MST) From: "scott.marlowe" To: Steve Wolfe Cc: Subject: Re: Question on hardware & server capacity In-Reply-To: <012b01c2b34e$05e267e0$88693fd1@WEASEL> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/24 X-Sequence-Number: 671 On Fri, 3 Jan 2003, Steve Wolfe wrote: > > Have you optimized your queries to max ? > > > > Often one or two of the queries take most of resources and starve > > others. > > I did log a good number of queries and analyze them, and 69% of the > queries issued are from one particular application, and they consume 78% > of the total "cost". The developper is looking into optimizations, but it > doesn't look like there's going to be any low-hanging fruit. It's simply > a complicated and frequently-used app. > > > Could there be some unnecessary trashing between OS and PG caches ? > > How could this be detected ? > > The machine generally has a minimum of a hundred megs free, unused > memory, so I'm not terribly worried about memory thrashing. I've > increased the various tuneable parameters (buffer blocks, sort mem, etc.) > to the point where performance increases stopped, then I doubled them all > for good measure. I've already decided that the next machine will have at > least 4 gigs of RAM, just because RAM's cheap, and having too much is a > Good Thing. Actually, free memory doesn't mean a whole lot. How much memory is being used as cache by the kernel? I've found that as long as the kernel is caching more data than postgresql, performance is better than when postgresql starts using more memory than the OS. for example, on my boxes at work, we have 1.5 gigs ram, and 256 megs are allocated to pgsql as shared buffer. The Linux kernel on those boxes has 100 megs free mem and 690 megs cached. The first time a heavy query runs there's a lag as the dataset is read into memory, but then subsequent queries fly. My experience has been that under Liunx (2.4.9 kernel RH7.2) the file system caching is better performance wise for very large amounts of data (500 Megs or more) than the postgresql shared buffers are. I.e. it would seem that when Postgresql has a large amount of shared memory to keep track of, it's quicker to just issue a request to the OS if the data is in the file cache than it is to look it up in postgresql's own shared memory buffers. The knee for me is somewhere between 32 megs and 512 megs memory to postgresql and twice that on average or a little more to the kernel file caches. > Yes, it's BAD if your business grows faster than Moores law ;-p > > .. unfortunately, that's been the case. Each year we've done slightly > more than double the traffic of the previous year - and at the same time, > as we unify all of our various data sources, the new applications that we > develop tend to make greater and greater demands on the database server. > There is always the option of the "big iron", but your > cost-per-transaction shoots through the roof. Paying a 10x premium can > really hurt. : ) Can you distribute your dataset across multiple machines? or is it the kinda thing that all needs to be in one big machine? Well, good luck with all this. From pgsql-performance-owner@postgresql.org Fri Jan 3 17:09:13 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 457234771A0 for ; Fri, 3 Jan 2003 17:09:11 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id A2122477199 for ; Fri, 3 Jan 2003 17:09:02 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h03M8xMf024500 for ; Fri, 3 Jan 2003 14:08:59 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.28.58]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Fri, 3 Jan 2003 14:09:02 -0800 Date: Fri, 3 Jan 2003 11:38:50 -0800 Subject: Re: join over 12 tables takes 3 secs to plan Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: "pgsql-performance@postgresql.org" To: Jeff From: Hilmar Lapp In-Reply-To: Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 03 Jan 2003 22:09:02.0333 (UTC) FILETIME=[B92122D0:01C2B374] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/27 X-Sequence-Number: 674 On Friday, January 3, 2003, at 09:12 AM, Jeff wrote: > Hmm.. This won't fix the fact the planner takes three seconds, but > since > it is a web application have you tried using PREPARE/EXECUTE so it only > needs to be planned once? Interesting point. I'd have to look into the source code whether the guy who wrote it actually uses JDBC PreparedStatements. I understand that PostgreSQL from 7.3 onwards supports prepared statements (cool!). Would the JDBC driver accompanying the dist. exploit that feature for its PreparedStatement implementation? -hilmar -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Fri Jan 3 15:47:24 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 72B5347630B for ; Fri, 3 Jan 2003 15:47:23 -0500 (EST) Received: from local.iboats.com (local.iboats.com [209.63.105.131]) by postgresql.org (Postfix) with SMTP id 93D1E475E88 for ; Fri, 3 Jan 2003 15:47:22 -0500 (EST) Received: (qmail 11791 invoked by uid 82); 3 Jan 2003 13:47:00 -0700 Received: from nw@codon.com by local.iboats.com by uid 81 with qmail-scanner-1.14 ( Clear:. Processed in 0.026228 secs); 03 Jan 2003 20:47:00 -0000 Received: from unknown (HELO WEASEL) (209.63.105.136) by 0 with SMTP; 3 Jan 2003 13:47:00 -0700 Message-ID: <006601c2b369$a2427ec0$88693fd1@WEASEL> From: "Steve Wolfe" To: References: Subject: Re: Question on hardware & server capacity Date: Fri, 3 Jan 2003 13:49:33 -0700 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/25 X-Sequence-Number: 672 > Actually, free memory doesn't mean a whole lot. How much memory is being > used as cache by the kernel? Generally, a gig or so. > Can you distribute your dataset across multiple machines? or is it the > kinda thing that all needs to be in one big machine? We're splitting the front-end across a number of machines, but all of the various datasets are sufficiently intertwined that they all have to be in the same database. I'm going to fiddle around with some of the available replication options and see if they're robust enough to put them into production. steve From pgsql-performance-owner@postgresql.org Fri Jan 3 17:09:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7E3AE47719D for ; Fri, 3 Jan 2003 17:09:09 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id A4DFB47719B for ; Fri, 3 Jan 2003 17:09:02 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h03M8xMh024500 for ; Fri, 3 Jan 2003 14:09:00 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.28.58]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Fri, 3 Jan 2003 14:09:02 -0800 Date: Fri, 3 Jan 2003 14:09:02 -0800 Subject: Re: join over 12 tables takes 3 secs to plan Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: Ron Johnson , PgSQL Performance ML To: "scott.marlowe" From: Hilmar Lapp In-Reply-To: Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 03 Jan 2003 22:09:02.0786 (UTC) FILETIME=[B9664220:01C2B374] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/26 X-Sequence-Number: 673 On Friday, January 3, 2003, at 09:01 AM, scott.marlowe wrote: > > Have you tried it on firebird for linux? It's an actively developed > rdbms > that's open source too. If this was developed for it, it might be a > better fit to use that for now, Probably it would. But honestly I'm not that keen to install the 3rd OSS database (in addition to Oracle, MySQL, PostgreSQL), and my sysadmins probably wouldn't be cheerfully jumping either ... > and then learn postgresql under the less > rigorous schedule of simply porting, not having to get a product out > the > door. Yes, so odd MySQL fit that bill for now ... > > Is an explicit join the answer here? i.e. will the number of rows we > get > from each table in a single query likely to never change? If so then > you > could just make an explicit join and be done with it. > Probably, even though the number of rows will change over time, but not by magnitudes. It's not an application of ours though, and since we're a bioinformatics shop, I'm not that eager to spend time hacking a project management system's query generation code. Thanks for all the thoughts and comments from you and others though, I appreciate that. -hilmar -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-jdbc-owner@postgresql.org Fri Jan 3 17:16:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 40F56477147; Fri, 3 Jan 2003 17:16:47 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id 9D830477142; Fri, 3 Jan 2003 17:16:44 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id h03MGig26985; Fri, 3 Jan 2003 17:16:44 -0500 Message-ID: <3E160BC0.3020900@clearmetrix.com> Date: Fri, 03 Jan 2003 17:16:32 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Hilmar Lapp Cc: Jeff , "pgsql-performance@postgresql.org" Subject: Re: [PERFORM] join over 12 tables takes 3 secs to plan References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/43 X-Sequence-Number: 5893 I have been asking (and learning) about this same thing on the PGSQL-JDBC mailing list. Apparently, there is a new driver for 7.3 that can store the plan on the server (aka, preparing it on the server) and re-use it. However, you need to set the PreparedStatement to do this for each statement. So, yes, you can retain the plan but it looks like you need to do some work to make it stick. [Also, you need to retain the PreparedStatement, it is not cached based based on the text of the statement, but associated with the PreparedStatement itself]. I think the functionality is starting to become real, but it looks like it is starting with some limitations that might restricts its use from be maximally realized until 7.4 (or beyond). Charlie Hilmar Lapp wrote: > > On Friday, January 3, 2003, at 09:12 AM, Jeff wrote: > >> Hmm.. This won't fix the fact the planner takes three seconds, but since >> it is a web application have you tried using PREPARE/EXECUTE so it only >> needs to be planned once? > > > Interesting point. I'd have to look into the source code whether the > guy who wrote it actually uses JDBC PreparedStatements. I understand > that PostgreSQL from 7.3 onwards supports prepared statements (cool!). > Would the JDBC driver accompanying the dist. exploit that feature for > its PreparedStatement implementation? > > -hilmar -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com From pgsql-performance-owner@postgresql.org Fri Jan 3 17:24:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 43B87477174 for ; Fri, 3 Jan 2003 17:24:10 -0500 (EST) Received: from ns1.gnf.org (ns1.gnf.org [63.196.132.67]) by postgresql.org (Postfix) with ESMTP id 34355477103 for ; Fri, 3 Jan 2003 17:22:48 -0500 (EST) Received: from EXCHCLUSTER01.lj.gnf.org (exch01.lj.gnf.org [172.25.10.19]) by ns1.gnf.org (8.12.3/8.12.3) with ESMTP id h03MMjMf024545 for ; Fri, 3 Jan 2003 14:22:45 -0800 (PST) (envelope-from hlapp@gmx.net) Received: from gmx.net ([172.25.28.58]) by EXCHCLUSTER01.lj.gnf.org with Microsoft SMTPSVC(5.0.2195.5329); Fri, 3 Jan 2003 14:22:48 -0800 Date: Fri, 3 Jan 2003 14:22:49 -0800 Subject: Re: join over 12 tables takes 3 secs to plan Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: Jeff , "pgsql-performance@postgresql.org" To: "Charles H. Woloszynski" From: Hilmar Lapp In-Reply-To: <3E160BC0.3020900@clearmetrix.com> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-OriginalArrivalTime: 03 Jan 2003 22:22:48.0864 (UTC) FILETIME=[A5C7C200:01C2B376] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/29 X-Sequence-Number: 676 On Friday, January 3, 2003, at 02:16 PM, Charles H. Woloszynski wrote: > Also, you need to retain the PreparedStatement, it is not cached based > based on the text of the > statement, but associated with the PreparedStatement itself I think that's normal. I don't recall the JDBC spec saying that you have a chance the server will remember that you created a PreparedStatement for the same query text before. You have to cache the PreparedStatement object in your app, not the query string. BTW that's the same for perl/DBI. At least for Oracle. -hilmar -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Sat Jan 4 08:33:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 32003475C15 for ; Sat, 4 Jan 2003 08:33:16 -0500 (EST) Received: from albert.auore.net (80-24-20-197.uc.nombres.ttd.es [80.24.20.197]) by postgresql.org (Postfix) with SMTP id C0D0147590C for ; Sat, 4 Jan 2003 08:33:13 -0500 (EST) Received: (qmail 1772 invoked by uid 1000); 4 Jan 2003 13:31:51 -0000 From: Albert Cervera Areny Subject: Fwd: Stock update like application Date: Sat, 4 Jan 2003 14:31:51 +0100 User-Agent: KMail/1.5 To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200301041431.51423.albertca@jazzfree.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/30 X-Sequence-Number: 677 Hi! I'm developing a small application which I'd like to be as fast as possible. The program simply receives an order by modem and has to give an answer with the products my enterprise will be able to send them. The number of products could be as much as 300-400 and I don't want to make my clients put I high time-out before the answer is sended. I do also need to use transactions as I start calculating before the whole order has been received and if an error occurs everything has to be rolled back. Under this circumstances which way do you think it would be faster? - Make a sequence for each product (we're talking about 20000 available products so I think it is very big but it might give a really fast answer). - Using standard SQL queries: SELECT the product, and if there are enough units UPDATE to decrease the number of available ones. (This one I suppose it's not very fast as two queries need to be processed for each product). - Using a CURSOR or something like this which I'm not used to but I've seen in the examples. Should I have the queries saved in the database to encrease performance? I hope I explained well enough :-) Thanks in advance! From pgsql-performance-owner@postgresql.org Sun Jan 5 21:25:06 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6F205476BDA for ; Sun, 5 Jan 2003 21:25:05 -0500 (EST) Received: from pineapple.ji.justsystem.co.jp (pineapple.ji.justsystem.co.jp [210.169.202.64]) by postgresql.org (Postfix) with ESMTP id C9EFF476BD6 for ; Sun, 5 Jan 2003 21:25:04 -0500 (EST) Received: from vrs01.b1.justsystem.co.jp ([10.4.1.51]) by pineapple.ji.justsystem.co.jp with smtp (Exim 3.33 #1) id 18VMxF-0001mX-00 for pgsql-performance@postgresql.org; Mon, 06 Jan 2003 11:25:29 +0900 Received: from justsystem.co.jp ([10.4.1.38]) by vrs01.b1.justsystem.co.jp (NAVGW 2.5.1.19) with SMTP id M2003010611250713463 for ; Mon, 06 Jan 2003 11:25:07 +0900 Received: (qmail 10823 invoked from network); 6 Jan 2003 11:25:07 +0900 Received: from bat.b1.justsystem.co.jp (10.4.1.37) by owl.b1.justsystem.co.jp with SMTP; 6 Jan 2003 11:25:07 +0900 Received: from yutaka_inada by bat.b1.justsystem.co.jp (8.8.8/3.6W) id LAA26427; Mon, 6 Jan 2003 11:21:46 +0900 (JST) From: yutaka_inada@justsystem.co.jp MIME-Version: 1.0 Date: Mon, 6 Jan 2003 11:27:17 +0900 Subject: Re: executing pgsql on Xeon-dual machine To: Tom Lane Cc: pgsql-performance@postgresql.org Message-ID: Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit In-Reply-To: <25730.1041014158@sss.pgh.pa.us> References: <25730.1041014158@sss.pgh.pa.us> X-Mailer: JsvMail 4.0 (Shuriken Pro2) X-Priority: 3 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/31 X-Sequence-Number: 678 Thank you, Tom, Tom Lane $B!'(B > > If you set fsync off, how do the pgbench results change? I'll try it. --- Yutaka Inada [Justsystem Corporation] From pgsql-performance-owner@postgresql.org Mon Jan 6 05:59:40 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AC4D447606A for ; Mon, 6 Jan 2003 05:59:38 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 17A43475C98 for ; Mon, 6 Jan 2003 05:59:38 -0500 (EST) Received: from klaster.net (pa236.krakow.cvx.ppp.tpnet.pl [213.76.36.236]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 51AD12B21C for ; Mon, 6 Jan 2003 11:58:10 +0100 (CET) Message-ID: <3E196277.5020904@klaster.net> Date: Mon, 06 Jan 2003 12:03:19 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: PgSQL Performance ML Subject: views vs pl/pgsql Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/32 X-Sequence-Number: 679 Hi 1. I have plpgsql function having only one query returning 1 value. This query joins some tables. I read, that plpgsql function saves execution plan for all queries inside one database connection. 2. Instead of this I can create a view returning one row. How does postgres work with views? When the plan is being created? What happens to views which don't have explicit joins? What happens if I create index on tables after creating a view? Which one is better and when? Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Mon Jan 6 14:12:14 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 63EA6476E32 for ; Mon, 6 Jan 2003 14:12:13 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 2F225476DD1 for ; Mon, 6 Jan 2003 14:12:12 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2305182; Mon, 06 Jan 2003 11:12:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Steve Wolfe" , Subject: Re: Question on hardware & server capacity Date: Mon, 6 Jan 2003 11:14:50 -0800 X-Mailer: KMail [version 1.4] References: <006601c2b369$a2427ec0$88693fd1@WEASEL> In-Reply-To: <006601c2b369$a2427ec0$88693fd1@WEASEL> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301061114.50830.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/33 X-Sequence-Number: 680 Steve, > We're splitting the front-end across a number of machines, but all of > the various datasets are sufficiently intertwined that they all have to be > in the same database. I'm going to fiddle around with some of the > available replication options and see if they're robust enough to put them > into production. 2 other suggestions: 1. Both PostgreSQL Inc. and Command Prompt Inc. have some sort of pay-for H= A=20 solution for Postgres. Paying them may end up being cheaper than=20 improvising this yourself. 2. Zapatec Inc. has acheived impressive performance gains by putting the=20 database on a high-speed, HA gigabit NAS server and having a few "client=20 servers" handle incoming queries. You may want to experiment along thes= e=20 lines. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-general-owner@postgresql.org Mon Jan 6 22:33:04 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 50044477289; Mon, 6 Jan 2003 22:33:03 -0500 (EST) Received: from voyager.corporate.connx.com (unknown [209.20.248.131]) by postgresql.org (Postfix) with ESMTP id 7C4354769E7; Mon, 6 Jan 2003 22:32:48 -0500 (EST) content-class: urn:content-classes:message Subject: Re: PostgreSQL and memory usage MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Mon, 6 Jan 2003 19:32:52 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [GENERAL] PostgreSQL and memory usage Thread-Index: AcK1/R1mXBhJY5VgR9mCHWb6ZWRYOQAACaqw From: "Dann Corbit" To: "Tom Lane" Cc: , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/207 X-Sequence-Number: 35328 > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 > Sent: Monday, January 06, 2003 7:30 PM > To: Dann Corbit > Cc: pgsql-hackers@postgresql.org; pgsql-general@postgresql.org > Subject: Re: [GENERAL] PostgreSQL and memory usage=20 >=20 >=20 > "Dann Corbit" writes: > > I have a machine with 4 CPU's and 2 gigabytes of physical=20 > ram. I would=20 > > like to get PostgreSQL to use as much memory as possible. I can't=20 > > seem to get PostgreSQL to use more than 100 megabytes or so. >=20 > You should not assume that more is necessarily better. >=20 > In many practical situations, it's better to leave the=20 > majority of RAM free for kernel disk caching. In any case, I would like to know what knobs and dials are available to turn and what each of them means. In at least one instance, the whole database should fit into memory. I would think that would be faster than any sort of kernel disk caching. From pgsql-performance-owner@postgresql.org Tue Jan 7 06:56:35 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2D7B94768CC for ; Tue, 7 Jan 2003 06:56:34 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 8778B476745 for ; Tue, 7 Jan 2003 06:56:33 -0500 (EST) Received: from klaster.net (pe241.krakow.cvx.ppp.tpnet.pl [213.76.40.241]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 7DDA02B21C; Tue, 7 Jan 2003 12:54:53 +0100 (CET) Message-ID: <3E1AC14C.7010104@klaster.net> Date: Tue, 07 Jan 2003 13:00:12 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Achilleus Mantzios Cc: pgsql-performance@postgresql.org Subject: Re: [SQL] 7.3.1 index use / performance References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/35 X-Sequence-Number: 682 Achilleus Mantzios wrote: > it has indexes: > Indexes: noonf_date btree (report_date), > noonf_logno btree (log_no), > noonf_rotation btree (rotation text_ops), > noonf_vcode btree (v_code), > noonf_voyageno btree (voyage_no) > > > ------------------------------------------------------------------------------------------------------------------- > Index Scan using noonf_date on noon (cost=0.00..4.46 rows=1 width=39) > (actual time=0.27..52.89 rows=259 loops=1) > Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= > '2003-01-07'::date)) > Filter: ((v_code = '4500'::character varying) AND (rotation = 'NOON > '::character varying)) > Total runtime: 53.98 msec > (4 rows) Maybe it is not an answer to your question, but why don't you help Postgres by yourself? For this kind of queries it's better to drop index on report_date - your report period is one year and answer to this condition is 10% records (I suppose) It would be better to change 2 indexes on v_code and rotation into one index based on both fields. What kind of queries do you have? How many records returns each "where" condition? Use indexes on fields, on which condition result in smallest amount of rows. Regards, Tomasz Myrta From pgsql-general-owner@postgresql.org Tue Jan 7 10:27:47 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CC93C475A3F; Tue, 7 Jan 2003 10:27:46 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 3213247628F; Tue, 7 Jan 2003 10:27:45 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 6D5C5D605; Tue, 7 Jan 2003 07:27:49 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 6316E5C04; Tue, 7 Jan 2003 07:27:49 -0800 (PST) Date: Tue, 7 Jan 2003 07:27:49 -0800 (PST) From: Stephan Szabo To: Achilleus Mantzios Cc: , , Subject: Re: [PERFORM] 7.3.1 index use / performance In-Reply-To: Message-ID: <20030107072146.L61341-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/232 X-Sequence-Number: 35353 On Tue, 7 Jan 2003, Achilleus Mantzios wrote: > i am just in the stage of having migrated my test system to 7.3.1 > and i am experiencing some performance problems. > > i have a table "noon" > Table "public.noon" > Column | Type | Modifiers > ------------------------+------------------------+----------- > v_code | character varying(4) | > log_no | bigint | > report_date | date | > report_time | time without time zone | > voyage_no | integer | > charterer | character varying(12) | > port | character varying(24) | > duration | character varying(4) | > rotation | character varying(9) | > ...... > > with a total of 278 columns. > > it has indexes: > Indexes: noonf_date btree (report_date), > noonf_logno btree (log_no), > noonf_rotation btree (rotation text_ops), > noonf_vcode btree (v_code), > noonf_voyageno btree (voyage_no) > > On the test 7.3.1 system (a FreeBSD 4.7-RELEASE-p2, Celeron 1.2GHz > 400Mb, with 168Mb for pgsql), > i get: > dynacom=# EXPLAIN ANALYZE select > FUELCONSUMPTION,rpm,Steam_Hours,voyage_activity,ldin from noon where > v_code='4500' and rotation='NOON ' and report_date between > '2002-01-07' and '2003-01-07'; > QUERY PLAN > > ------------------------------------------------------------------------------------------------------------------- > Index Scan using noonf_date on noon (cost=0.00..4.46 rows=1 width=39) > (actual time=0.27..52.89 rows=259 loops=1) > Index Scan using noonf_vcode on noon (cost=0.00..3122.88 rows=1 > width=39) (actual time=0.16..13.92 rows=259 loops=1) What do the statistics for the three columns actually look like and what are the real distributions and counts like? Given an estimated cost of around 4 for the first scan, my guess would be that it's not expecting alot of rows between 2002-01-07 and 2003-01-07 which would make that a reasonable plan. From pgsql-general-owner@postgresql.org Tue Jan 7 06:31:32 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2A00E475ADE; Tue, 7 Jan 2003 06:31:31 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 098B04758C9; Tue, 7 Jan 2003 06:31:30 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h07FdvXR008171; Tue, 7 Jan 2003 13:39:57 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h07FdvVA008167; Tue, 7 Jan 2003 13:39:57 -0200 Date: Tue, 7 Jan 2003 13:39:57 -0200 (GMT+2) From: Achilleus Mantzios To: pgsql-performance@postgresql.org, , Subject: 7.3.1 index use / performance Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/219 X-Sequence-Number: 35340 Hi, i am just in the stage of having migrated my test system to 7.3.1 and i am experiencing some performance problems. i have a table "noon" Table "public.noon" Column | Type | Modifiers ------------------------+------------------------+----------- v_code | character varying(4) | log_no | bigint | report_date | date | report_time | time without time zone | voyage_no | integer | charterer | character varying(12) | port | character varying(24) | duration | character varying(4) | rotation | character varying(9) | ...... with a total of 278 columns. it has indexes: Indexes: noonf_date btree (report_date), noonf_logno btree (log_no), noonf_rotation btree (rotation text_ops), noonf_vcode btree (v_code), noonf_voyageno btree (voyage_no) On the test 7.3.1 system (a FreeBSD 4.7-RELEASE-p2, Celeron 1.2GHz 400Mb, with 168Mb for pgsql), i get: dynacom=# EXPLAIN ANALYZE select FUELCONSUMPTION,rpm,Steam_Hours,voyage_activity,ldin from noon where v_code='4500' and rotation='NOON ' and report_date between '2002-01-07' and '2003-01-07'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Index Scan using noonf_date on noon (cost=0.00..4.46 rows=1 width=39) (actual time=0.27..52.89 rows=259 loops=1) Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) Filter: ((v_code = '4500'::character varying) AND (rotation = 'NOON '::character varying)) Total runtime: 53.98 msec (4 rows) after i drop the noonf_date index i actually get better performance cause the backend uses now the more appropriate index noonf_vcode : dynacom=# EXPLAIN ANALYZE select FUELCONSUMPTION,rpm,Steam_Hours,voyage_activity,ldin from noon where v_code='4500' and rotation='NOON ' and report_date between '2002-01-07' and '2003-01-07'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Index Scan using noonf_vcode on noon (cost=0.00..3122.88 rows=1 width=39) (actual time=0.16..13.92 rows=259 loops=1) Index Cond: (v_code = '4500'::character varying) Filter: ((rotation = 'NOON '::character varying) AND (report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) Total runtime: 14.98 msec (4 rows) On the pgsql 7.2.3 development system (a RH linux 2.4.7, PIII 1 GHz, 1Mb, with 168M for pgsql), i always get the right index use: dynacom=# EXPLAIN ANALYZE select FUELCONSUMPTION,rpm,Steam_Hours,voyage_activity,ldin from noon where v_code='4500' and rotation='NOON ' and report_date between '2002-01-07' and '2003-01-07'; NOTICE: QUERY PLAN: Index Scan using noonf_vcode on noon (cost=0.00..3046.38 rows=39 width=39) (actual time=0.09..8.55 rows=259 loops=1) Total runtime: 8.86 msec EXPLAIN Is something i am missing?? Is this reasonable behaviour?? P.S. Yes i have vaccumed analyzed both systems before the queries were issued. ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-general-owner@postgresql.org Tue Jan 7 07:13:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D7CB647699E; Tue, 7 Jan 2003 07:13:01 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id A525647698B; Tue, 7 Jan 2003 07:12:58 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h07GLJXR008348; Tue, 7 Jan 2003 14:21:19 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h07GLJth008344; Tue, 7 Jan 2003 14:21:19 -0200 Date: Tue, 7 Jan 2003 14:21:19 -0200 (GMT+2) From: Achilleus Mantzios To: Tomasz Myrta Cc: pgsql-performance@postgresql.org, , Subject: Re: [SQL] 7.3.1 index use / performance In-Reply-To: <3E1AC14C.7010104@klaster.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/222 X-Sequence-Number: 35343 On Tue, 7 Jan 2003, Tomasz Myrta wrote: > Maybe it is not an answer to your question, but why don't you help > Postgres by yourself? Thanx, i dont think that the issue here is to help postgresql by myself. I can always stick to 7.2.3, or use indexes that 7.3.1 will acknowledge, like noonf_vcode_date on noon (v_code,report_date). (unfortunately when i create the above noonf_vcode_date index, it is only used until the next vacuum analyze, hackers is this an issue too???), but these options are not interesting from a postgresql perspective :) > For this kind of queries it's better to drop index on report_date - your > report period is one year and answer to this condition is 10% records (I > suppose) I cannot drop the index on the report_date since a lot of other queries need it. > It would be better to change 2 indexes on v_code and rotation into one > index based on both fields. > What kind of queries do you have? How many records returns each "where" > condition? Use indexes on fields, on which condition result in smallest > amount of rows. > > Regards, > Tomasz Myrta > ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-general-owner@postgresql.org Tue Jan 7 11:30:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A20C247614E; Tue, 7 Jan 2003 11:30:16 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 23CE24771B4; Tue, 7 Jan 2003 11:29:48 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h07GTm0U013844; Tue, 7 Jan 2003 11:29:48 -0500 (EST) To: Achilleus Mantzios Cc: Stephan Szabo , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-reply-to: References: Comments: In-reply-to Achilleus Mantzios message dated "Tue, 07 Jan 2003 18:27:32 -0200" Date: Tue, 07 Jan 2003 11:29:48 -0500 Message-ID: <13843.1041956988@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/237 X-Sequence-Number: 35358 Achilleus Mantzios writes: > About the stats on these 3 columns i get: Does 7.2 generate the same stats? (minus the schemaname of course) Also, I would like to see the results of these queries on both versions, so that we can see what the planner thinks the index selectivity is: EXPLAIN ANALYZE select * from noon where v_code='4500'; EXPLAIN ANALYZE select * from noon where report_date between '2002-01-07' and '2003-01-07'; regards, tom lane From pgsql-general-owner@postgresql.org Tue Jan 7 12:04:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4697E476313; Tue, 7 Jan 2003 12:04:51 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 9FD204762C0; Tue, 7 Jan 2003 12:04:50 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id h07H0uB2008056; Tue, 7 Jan 2003 10:01:00 -0700 (MST) Date: Tue, 7 Jan 2003 09:55:30 -0700 (MST) From: "scott.marlowe" To: Dann Corbit Cc: Tom Lane , , Subject: Re: PostgreSQL and memory usage In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/239 X-Sequence-Number: 35360 Hi Dann, I took hackers out of the list as this isn't really a hacking issue, but I added in performance as this definitely applies there. There are generally two areas of a database server you have to reconfigure to use that extra memory. The first is the kernel's shared memory settings. On a linux box that has sysconf installed this is quite easy. If it isn't installed, install it, as it's much easier to manipulate your kernel's settings using sysctl than it is with editing rc.local. First, get root. Then, use 'sysctl -a|grep shm' to get a list of all the shared memory settings handled by sysctl. On a default redhat install, we'll get something like this: kernel.shmmni = 4096 kernel.shmall = 2097152 kernel.shmmax = 33554432 On my bigger box, it's been setup to have this: kernel.shmmni = 4096 kernel.shmall = 32000000 kernel.shmmax = 256000000 To make changes that stick around, edit the /etc/sysctl.conf file to have lines that look kinda like those above. To make the changes to the /etc/sysctl.conf file take effect, use 'sysctl -p'. Next, as the postgres user, edit $PGDATA/postgresql.conf and increase the number of shared buffers. On most postgresql installations this number is multiplied by 8k to get the amount of ram being allocated, since postgresql allocates share buffers in blocks the same size as what it uses on the dataset. To allocate 256 Megs of buffers (that's what I use, seems like a nice large chunk, but doesn't starve my other processes or system file cache) set it to 32768. Be careful how big you make your sort size. I haven't seen a great increase in speed on anything over 8 or 16 megs, while memory usage can skyrocket under heavy parallel load with lots of sorts, since sort memory is PER SORT maximum. Then do the old pg_ctl reload and you should be cooking with gas. From pgsql-general-owner@postgresql.org Tue Jan 7 12:09:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9234C476745; Tue, 7 Jan 2003 12:09:53 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 852AD475ED4; Tue, 7 Jan 2003 12:09:50 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h07H9L0U014257; Tue, 7 Jan 2003 12:09:21 -0500 (EST) To: "scott.marlowe" Cc: Dann Corbit , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: PostgreSQL and memory usage In-reply-to: References: Comments: In-reply-to "scott.marlowe" message dated "Tue, 07 Jan 2003 09:55:30 -0700" Date: Tue, 07 Jan 2003 12:09:21 -0500 Message-ID: <14256.1041959361@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/240 X-Sequence-Number: 35361 "scott.marlowe" writes: > Then do the old pg_ctl reload and you should be cooking with gas. One correction: altering the number of shared buffers requires an actual postmaster restart. regards, tom lane From pgsql-general-owner@postgresql.org Tue Jan 7 12:44:16 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2CC43475D99; Tue, 7 Jan 2003 12:44:15 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6F3484759BD; Tue, 7 Jan 2003 12:44:14 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h07HiG0U014599; Tue, 7 Jan 2003 12:44:16 -0500 (EST) To: Achilleus Mantzios Cc: Stephan Szabo , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-reply-to: References: Comments: In-reply-to Achilleus Mantzios message dated "Tue, 07 Jan 2003 19:05:22 -0200" Date: Tue, 07 Jan 2003 12:44:16 -0500 Message-ID: <14598.1041961456@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/242 X-Sequence-Number: 35363 Achilleus Mantzios writes: >> Also, I would like to see the results of these queries on both versions, >> so that we can see what the planner thinks the index selectivity is: >> > [ data supplied ] There is something really, really bizarre going on there. You have dynacom=# EXPLAIN ANALYZE select * from noon where report_date between '2002-01-07' and '2003-01-07'; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------- Index Scan using noonf_date on noon (cost=0.00..15919.50 rows=11139 width=1974) (actual time=2.05..13746.17 rows=7690 loops=1) Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) Total runtime: 13775.48 msec (3 rows) and from your earlier message dynacom=# EXPLAIN ANALYZE select FUELCONSUMPTION,rpm,Steam_Hours,voyage_activity,ldin from noon where v_code='4500' and rotation='NOON ' and report_date between '2002-01-07' and '2003-01-07'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Index Scan using noonf_date on noon (cost=0.00..4.46 rows=1 width=39) (actual time=0.27..52.89 rows=259 loops=1) Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) Filter: ((v_code = '4500'::character varying) AND (rotation = 'NOON'::character varying)) Total runtime: 53.98 msec (4 rows) There is no way that adding the filter condition should have reduced the estimated runtime for this plan --- reducing the estimated number of output rows, yes, but not the runtime. And in fact I can't duplicate that when I try it here. I did this on 7.3.1: regression=# create table noon (v_code character varying(4) , regression(# report_date date , regression(# rotation character varying(9)); CREATE TABLE regression=# create index noonf_date on noon(report_date); CREATE INDEX regression=# EXPLAIN select * from noon where report_date between regression-# '2002-01-07' and '2003-01-07'; QUERY PLAN --------------------------------------------------------------------------------------------- Index Scan using noonf_date on noon (cost=0.00..17.08 rows=5 width=25) Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) (2 rows) regression=# explain select * from noon where regression-# v_code='4500' and rotation='NOON ' and report_date between regression-# '2002-01-07' and '2003-01-07'; QUERY PLAN -------------------------------------------------------------------------------- ------------------ Index Scan using noonf_date on noon (cost=0.00..17.11 rows=1 width=25) Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) Filter: ((v_code = '4500'::character varying) AND (rotation = 'NOON '::character varying)) (3 rows) Note that the cost went up, not down. I am wondering about a compiler bug, or some other peculiarity on your platform. Can anyone else using FreeBSD try the above experiment and see if they get different results from mine on 7.3.* (or CVS tip)? regards, tom lane From pgsql-general-owner@postgresql.org Tue Jan 7 13:22:24 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BCAC7477275; Tue, 7 Jan 2003 13:22:23 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 63B9C476745; Tue, 7 Jan 2003 13:22:20 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h07IMF0U015502; Tue, 7 Jan 2003 13:22:16 -0500 (EST) To: Achilleus Mantzios Cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: 7.3.1 function problem: ERROR: cache lookup failed for type 0 In-reply-to: References: Comments: In-reply-to Achilleus Mantzios message dated "Tue, 07 Jan 2003 19:55:33 -0200" Date: Tue, 07 Jan 2003 13:22:15 -0500 Message-ID: <15501.1041963735@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/245 X-Sequence-Number: 35366 Achilleus Mantzios writes: > Hi i had written a C function to easily convert an int4 to its > equivalent 1x1 int4[] array. Does your function know about filling in the elemtype field that was recently added to struct ArrayType? regards, tom lane From pgsql-general-owner@postgresql.org Tue Jan 7 13:41:40 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 494F1475ED4; Tue, 7 Jan 2003 13:41:40 -0500 (EST) Received: from joeconway.com (unknown [63.210.180.150]) by postgresql.org (Postfix) with ESMTP id 79DB7477369; Tue, 7 Jan 2003 13:41:03 -0500 (EST) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.2) with ESMTP-TLS id 1554268; Tue, 07 Jan 2003 11:14:44 -0800 Message-ID: <3E1B1ED7.7060704@joeconway.com> Date: Tue, 07 Jan 2003 10:39:19 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Achilleus Mantzios Cc: Tom Lane , pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: 7.3.1 function problem: ERROR: cache lookup failed References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/249 X-Sequence-Number: 35370 Achilleus Mantzios wrote: > On Tue, 7 Jan 2003, Tom Lane wrote: >>Does your function know about filling in the elemtype field that was >>recently added to struct ArrayType? > > She has no clue :) > > Any pointers would be great. See construct_array() in src/backend/utils/adt/arrayfuncs.c. HTH, Joe From pgsql-general-owner@postgresql.org Tue Jan 7 13:40:05 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 48977475D99; Tue, 7 Jan 2003 13:40:01 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 84FBA475AD7; Tue, 7 Jan 2003 13:40:00 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h07Idv0U019586; Tue, 7 Jan 2003 13:39:57 -0500 (EST) To: Achilleus Mantzios Cc: Stephan Szabo , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-reply-to: References: Comments: In-reply-to Achilleus Mantzios message dated "Tue, 07 Jan 2003 20:38:17 -0200" Date: Tue, 07 Jan 2003 13:39:57 -0500 Message-ID: <19585.1041964797@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/248 X-Sequence-Number: 35369 Achilleus Mantzios writes: > My case persists: > After clean install of the database, and after vacuum analyze, > i get Um ... is it persisting? That looks like it's correctly picked the vcode index this time. Strange behavior though. By "clean install" do you mean you rebuilt Postgres, or just did dropdb/createdb/reload data? regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jan 7 13:45:45 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 566DC47739D; Tue, 7 Jan 2003 13:45:41 -0500 (EST) Received: from jester.senspire.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id 9F44F477275; Tue, 7 Jan 2003 13:45:26 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h07IjE39039903; Tue, 7 Jan 2003 13:45:15 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: [SQL] 7.3.1 index use / performance From: Rod Taylor To: Tom Lane Cc: Achilleus Mantzios , Stephan Szabo , Pgsql Performance , pgsql-general@postgresql.org, pgsql-sql@postgresql.org In-Reply-To: <14598.1041961456@sss.pgh.pa.us> References: <14598.1041961456@sss.pgh.pa.us> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-GwJlq1zAooSOa7CkghQM" Organization: Message-Id: <1041965114.39376.39.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 07 Jan 2003 13:45:14 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/47 X-Sequence-Number: 694 --=-GwJlq1zAooSOa7CkghQM Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > I am wondering about a compiler bug, or some other peculiarity on your > platform. Can anyone else using FreeBSD try the above experiment and > see if they get different results from mine on 7.3.* (or CVS tip)? On FreeBSD 4.7 I received the exact same results as Tom using the statements shown by Tom. --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-GwJlq1zAooSOa7CkghQM 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 (FreeBSD) iD8DBQA+GyA66DETLow6vwwRAmgbAJoCIJc0hYgyczkGSd8Stdlg64UebgCeNmSg LdAAH0L9w+S1nMDrb+fMrQY= =bljF -----END PGP SIGNATURE----- --=-GwJlq1zAooSOa7CkghQM-- From pgsql-general-owner@postgresql.org Tue Jan 7 14:26:16 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 18BC74762A4 for ; Tue, 7 Jan 2003 14:26:14 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id C764647607B for ; Tue, 7 Jan 2003 14:26:11 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h07JQ80U019890; Tue, 7 Jan 2003 14:26:08 -0500 (EST) To: Rod Taylor Cc: Achilleus Mantzios , Stephan Szabo , Pgsql Performance , pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-reply-to: <1041965114.39376.39.camel@jester> References: <14598.1041961456@sss.pgh.pa.us> <1041965114.39376.39.camel@jester> Comments: In-reply-to Rod Taylor message dated "07 Jan 2003 13:45:14 -0500" Date: Tue, 07 Jan 2003 14:26:08 -0500 Message-ID: <19889.1041967568@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/252 X-Sequence-Number: 35373 Rod Taylor writes: >> I am wondering about a compiler bug, or some other peculiarity on your >> platform. Can anyone else using FreeBSD try the above experiment and >> see if they get different results from mine on 7.3.* (or CVS tip)? > On FreeBSD 4.7 I received the exact same results as Tom using the > statements shown by Tom. On looking at the code, I do see part of a possible mechanism for this behavior: cost_index calculates the estimated cost for qual-clause evaluation like this: /* * Estimate CPU costs per tuple. * * Normally the indexquals will be removed from the list of restriction * clauses that we have to evaluate as qpquals, so we should subtract * their costs from baserestrictcost. XXX For a lossy index, not all * the quals will be removed and so we really shouldn't subtract their * costs; but detecting that seems more expensive than it's worth. * Also, if we are doing a join then some of the indexquals are join * clauses and shouldn't be subtracted. Rather than work out exactly * how much to subtract, we don't subtract anything. */ cpu_per_tuple = cpu_tuple_cost + baserel->baserestrictcost; if (!is_injoin) cpu_per_tuple -= cost_qual_eval(indexQuals); In theory, indexQuals will always be a subset of the qual list on which baserestrictcost was computed, so we should always end up with a cpu_per_tuple value at least as large as cpu_tuple_cost. I am wondering if somehow in Achilleus's situation, cost_qual_eval() is producing a silly result leading to negative cpu_per_tuple. I don't see how that could happen though --- nor why it would happen on his machine and not other people's. regards, tom lane From pgsql-general-owner@postgresql.org Tue Jan 7 15:03:50 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 60054475E14 for ; Tue, 7 Jan 2003 15:03:48 -0500 (EST) Received: from mail.digicamp.com (ns1.digicamp.com [216.38.142.76]) by postgresql.org (Postfix) with SMTP id 8D4D2475A71 for ; Tue, 7 Jan 2003 15:03:47 -0500 (EST) Received: (qmail 3842 invoked from network); 7 Jan 2003 19:46:22 -0000 Received: from localhost (HELO digicamp.com) (127.0.0.1) by localhost with SMTP; 7 Jan 2003 19:46:22 -0000 Received: from 168.103.211.137 (SquirrelMail authenticated user fred@digicamp.com) by mail.digicamp.com with HTTP; Tue, 7 Jan 2003 11:46:22 -0800 (PST) Message-ID: <36045.168.103.211.137.1041968782.squirrel@mail.digicamp.com> Date: Tue, 7 Jan 2003 11:46:22 -0800 (PST) Subject: Re: [PERFORM] PostgreSQL and memory usage From: "Fred Moyer" To: X-XheaderVersion: 1.1 X-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5 In-Reply-To: References: X-Priority: 3 Importance: Normal Cc: , , , Reply-To: fred@digicamp.com X-Mailer: SquirrelMail (version 1.2.10) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/253 X-Sequence-Number: 35374 To put this usage of shared buffers in perspective would you mind kindly let us know your total amount of system ram? Without hearing what percentage of memory used as shared buffers (assuming is the primary application being using here) I have always taken the 'more is better' approach with shared buffers but would like to know what in terms of percentages other people are using. I have been using 50% of system ram (2 out of 4 gigs) for shared buffers (and corresponding shmmax values) and it has been working great. I haven't tweaked the kernel yet to get more than 2 gigs shmmax so I can't speak for a setup using over 50%. I've been using between 256 and 512 megs sort memory which sounds like a little much from what I'm hearing here. Thanks Fred > > Hi Dann, I took hackers out of the list as this isn't really a hacking > issue, but I added in performance as this definitely applies there. > > There are generally two areas of a database server you have to > reconfigure to use that extra memory. The first is the kernel's shared > memory settings. > > On a linux box that has sysconf installed this is quite easy. If it > isn't installed, install it, as it's much easier to manipulate your > kernel's settings using sysctl than it is with editing rc.local. > > First, get root. Then, use 'sysctl -a|grep shm' to get a list of all > the shared memory settings handled by sysctl. > > On a default redhat install, we'll get something like this: > > kernel.shmmni = 4096 > kernel.shmall = 2097152 > kernel.shmmax = 33554432 > > On my bigger box, it's been setup to have this: > > kernel.shmmni = 4096 > kernel.shmall = 32000000 > kernel.shmmax = 256000000 > > To make changes that stick around, edit the /etc/sysctl.conf file to > have lines that look kinda like those above. To make the changes to > the /etc/sysctl.conf file take effect, use 'sysctl -p'. > > Next, as the postgres user, edit $PGDATA/postgresql.conf and increase > the number of shared buffers. On most postgresql installations this > number is multiplied by 8k to get the amount of ram being allocated, > since > postgresql allocates share buffers in blocks the same size as what it > uses on the dataset. To allocate 256 Megs of buffers (that's what I > use, seems like a nice large chunk, but doesn't starve my other > processes or system file cache) set it to 32768. > > Be careful how big you make your sort size. I haven't seen a great > increase in speed on anything over 8 or 16 megs, while memory usage can > skyrocket under heavy parallel load with lots of sorts, since sort > memory is PER SORT maximum. > > Then do the old pg_ctl reload and you should be cooking with gas. > > > ---------------------------(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-general-owner@postgresql.org Tue Jan 7 11:19:15 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 03212477060; Tue, 7 Jan 2003 11:19:13 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id D443447676D; Tue, 7 Jan 2003 11:19:06 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h07KRXXR009290; Tue, 7 Jan 2003 18:27:33 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h07KRW5Z009286; Tue, 7 Jan 2003 18:27:33 -0200 Date: Tue, 7 Jan 2003 18:27:32 -0200 (GMT+2) From: Achilleus Mantzios To: Stephan Szabo Cc: pgsql-performance@postgresql.org, , Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-Reply-To: <20030107072146.L61341-100000@megazone23.bigpanda.com> Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="333001285-560812375-1041971252=:8183" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/236 X-Sequence-Number: 35357 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --333001285-560812375-1041971252=:8183 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 7 Jan 2003, Stephan Szabo wrote: > > On Tue, 7 Jan 2003, Achilleus Mantzios wrote: > > > i am just in the stage of having migrated my test system to 7.3.1 > > and i am experiencing some performance problems. > > > > i have a table "noon" > > Table "public.noon" > > Column | Type | Modifiers > > ------------------------+------------------------+----------- > > v_code | character varying(4) | > > log_no | bigint | > > report_date | date | > > report_time | time without time zone | > > voyage_no | integer | > > charterer | character varying(12) | > > port | character varying(24) | > > duration | character varying(4) | > > rotation | character varying(9) | > > ...... > > > > with a total of 278 columns. > > > > it has indexes: > > Indexes: noonf_date btree (report_date), > > noonf_logno btree (log_no), > > noonf_rotation btree (rotation text_ops), > > noonf_vcode btree (v_code), > > noonf_voyageno btree (voyage_no) > > > > On the test 7.3.1 system (a FreeBSD 4.7-RELEASE-p2, Celeron 1.2GHz > > 400Mb, with 168Mb for pgsql), > > i get: > > dynacom=# EXPLAIN ANALYZE select > > FUELCONSUMPTION,rpm,Steam_Hours,voyage_activity,ldin from noon where > > v_code='4500' and rotation='NOON ' and report_date between > > '2002-01-07' and '2003-01-07'; > > QUERY PLAN > > > > > ------------------------------------------------------------------------------------------------------------------- > > Index Scan using noonf_date on noon (cost=0.00..4.46 rows=1 width=39) > > (actual time=0.27..52.89 rows=259 loops=1) > > > > Index Scan using noonf_vcode on noon (cost=0.00..3122.88 rows=1 > > width=39) (actual time=0.16..13.92 rows=259 loops=1) > > > What do the statistics for the three columns actually look like and what > are the real distributions and counts like? The two databases (test 7.3.1 and development 7.2.3) are identical (loaded from the same pg_dump). About the stats on these 3 columns i get: (see also attachment 1 to avoid identation/wraparound problems) schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-----------+-------------+-----------+-----------+------------+-----------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+------------- public | noon | v_code | 0 | 8 | 109 | {4630,4650,4690,4670,4520,4610,4550,4560,4620,4770} | {0.0283333,0.028,0.0256667,0.0243333,0.024,0.0236667,0.0233333,0.0233333,0.0226667,0.0226667} | {2070,3210,4330,4480,4570,4680,4751,4820,4870,4940,6020} | -0.249905 public | noon | report_date | 0 | 4 | 3408 | {2001-11-14,1998-10-18,2000-04-03,2000-07-04,2000-12-20,2000-12-31,2001-01-12,2001-10-08,2001-12-25,1996-01-23} | {0.002,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00166667,0.00133333} | {"0001-12-11 BC",1994-09-27,1996-03-26,1997-07-29,1998-08-26,1999-03-29,1999-11-30,2000-09-25,2001-05-25,2002-01-17,2002-12-31} | -0.812295 public | noon | rotation | 0 | 13 | 6 | {"NOON ","PORT LOG ","ARRIVAL ",DEPARTURE,"SEA ","NEXT PORT"} | {0.460333,0.268667,0.139,0.119667,0.007,0.00533333} | | 0.119698 (3 rows) About distributions, i have: dynacom=# SELECT rotation,count(*) from noon group by rotation; rotation | count -----------+------- | 2 000000000 | 65 ARRIVAL | 1 ARRIVAL | 15471 DEPARTURE | 15030 NEXT PORT | 462 NOON | 50874 PORT LOG | 25688 SEA | 1202 (9 rows) dynacom=# SELECT v_code,count(*) from noon group by v_code; v_code | count --------+------- 0004 | 1 1030 | 1 2070 | 170 2080 | 718 2110 | 558 2220 | 351 2830 | 1373 2840 | 543 2860 | 407 2910 | 418 3010 | 352 3020 | 520 3060 | 61 3130 | 117 3140 | 1 3150 | 752 3160 | 811 3170 | 818 3180 | 1064 3190 | 640 3200 | 998 3210 | 1512 3220 | 595 3230 | 374 3240 | 514 3250 | 13 3260 | 132 3270 | 614 4010 | 413 4020 | 330 4040 | 728 4050 | 778 4060 | 476 4070 | 534 4310 | 759 4320 | 424 4330 | 549 4360 | 366 4370 | 334 4380 | 519 4410 | 839 4420 | 183 4421 | 590 4430 | 859 4450 | 205 4470 | 861 4480 | 766 4490 | 169 4500 | 792 4510 | 2116 4520 | 2954 4530 | 2142 4531 | 217 4540 | 2273 4550 | 2765 4560 | 2609 4570 | 2512 4580 | 1530 4590 | 1987 4600 | 308 4610 | 2726 4620 | 2698 4630 | 2813 4640 | 1733 4650 | 2655 4660 | 2139 4661 | 65 4670 | 2607 4680 | 1729 4690 | 2587 4700 | 2101 4710 | 1830 4720 | 1321 4730 | 1258 4740 | 1506 4750 | 1391 4751 | 640 4760 | 1517 4770 | 2286 4780 | 1353 4790 | 1209 4800 | 2414 4810 | 770 4820 | 1115 4830 | 1587 4840 | 983 4841 | 707 4850 | 1297 4860 | 375 4870 | 1440 4880 | 456 4881 | 742 4890 | 210 4891 | 45 4900 | 2 4910 | 1245 4920 | 414 4930 | 1130 4940 | 1268 4950 | 949 4960 | 836 4970 | 1008 4980 | 1239 5510 | 477 5520 | 380 5530 | 448 5540 | 470 5550 | 352 5560 | 148 5570 | 213 5580 | 109 5590 | 55 6010 | 246 6020 | 185 9180 | 1 (Not all the above vessels are active or belong to me:) ) The distribution on the report_date has no probabilistic significance since each report_date usually corresponds to one row. So, dynacom=# SELECT count(*) from noon; count -------- 108795 (1 row) dynacom=# Now for the specific query the counts have as follows: dynacom=# select count(*) from noon where v_code='4500'; count ------- 792 (1 row) dynacom=# select count(*) from noon where rotation='NOON '; count ------- 50874 (1 row) dynacom=# select count(*) from noon where report_date between '2002-01-07' and '2003-01-07'; count ------- 7690 (1 row) dynacom=# > Given an estimated cost of around 4 for the first scan, my guess would be > that it's not expecting alot of rows between 2002-01-07 and 2003-01-07 > which would make that a reasonable plan. > As we see the rows returned for v_code='4500' (792) are much fewer than the rows returned for the dates between '2002-01-07' and '2003-01-07' (7690). Is there a way to provide you with more information? And i must note that the two databases were worked on after a fresh createdb on both systems (and as i told they are identical). But, for some reason the 7.2.3 *always* finds the best index to use :) > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr --333001285-560812375-1041971252=:8183 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=query_stats Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=query_stats IHNjaGVtYW5hbWUgfCB0YWJsZW5hbWUgfCAgIGF0dG5hbWUgICB8IG51bGxf ZnJhYyB8IGF2Z193aWR0aCB8IG5fZGlzdGluY3QgfCAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vc3RfY29tbW9u X3ZhbHMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIG1vc3RfY29tbW9uX2ZyZXFzICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpc3Rv Z3JhbV9ib3VuZHMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICB8IGNvcnJlbGF0aW9uIA0KLS0tLS0t LS0tLS0tKy0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0r LS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLQ0KIHB1YmxpYyAgICAg fCBub29uICAgICAgfCB2X2NvZGUgICAgICB8ICAgICAgICAgMCB8ICAgICAg ICAgOCB8ICAgICAgICAxMDkgfCB7NDYzMCw0NjUwLDQ2OTAsNDY3MCw0NTIw LDQ2MTAsNDU1MCw0NTYwLDQ2MjAsNDc3MH0gICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCB7 MC4wMjgzMzMzLDAuMDI4LDAuMDI1NjY2NywwLjAyNDMzMzMsMC4wMjQsMC4w MjM2NjY3LDAuMDIzMzMzMywwLjAyMzMzMzMsMC4wMjI2NjY3LDAuMDIyNjY2 N30gICAgICAgICAgICAgIHwgezIwNzAsMzIxMCw0MzMwLDQ0ODAsNDU3MCw0 NjgwLDQ3NTEsNDgyMCw0ODcwLDQ5NDAsNjAyMH0gICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICB8ICAgLTAuMjQ5OTA1DQogcHVibGljICAgICB8IG5vb24g ICAgICB8IHJlcG9ydF9kYXRlIHwgICAgICAgICAwIHwgICAgICAgICA0IHwg ICAgICAgMzQwOCB8IHsyMDAxLTExLTE0LDE5OTgtMTAtMTgsMjAwMC0wNC0w MywyMDAwLTA3LTA0LDIwMDAtMTItMjAsMjAwMC0xMi0zMSwyMDAxLTAxLTEy LDIwMDEtMTAtMDgsMjAwMS0xMi0yNSwxOTk2LTAxLTIzfSB8IHswLjAwMiww LjAwMTY2NjY3LDAuMDAxNjY2NjcsMC4wMDE2NjY2NywwLjAwMTY2NjY3LDAu MDAxNjY2NjcsMC4wMDE2NjY2NywwLjAwMTY2NjY3LDAuMDAxNjY2NjcsMC4w MDEzMzMzM30gfCB7IjAwMDEtMTItMTEgQkMiLDE5OTQtMDktMjcsMTk5Ni0w My0yNiwxOTk3LTA3LTI5LDE5OTgtMDgtMjYsMTk5OS0wMy0yOSwxOTk5LTEx LTMwLDIwMDAtMDktMjUsMjAwMS0wNS0yNSwyMDAyLTAxLTE3LDIwMDItMTIt MzF9IHwgICAtMC44MTIyOTUNCiBwdWJsaWMgICAgIHwgbm9vbiAgICAgIHwg cm90YXRpb24gICAgfCAgICAgICAgIDAgfCAgICAgICAgMTMgfCAgICAgICAg ICA2IHwgeyJOT09OICAgICAiLCJQT1JUIExPRyAiLCJBUlJJVkFMICAiLERF UEFSVFVSRSwiU0VBICAgICAgIiwiTkVYVCBQT1JUIn0gICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgezAuNDYwMzMzLDAuMjY4 NjY3LDAuMTM5LDAuMTE5NjY3LDAuMDA3LDAuMDA1MzMzMzN9ICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAg ICAwLjExOTY5OA0KKDMgcm93cykNCg0K --333001285-560812375-1041971252=:8183-- From pgsql-general-owner@postgresql.org Tue Jan 7 15:30:25 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 908E14772EA; Tue, 7 Jan 2003 15:30:24 -0500 (EST) Received: from hoemail2.firewall.lucent.com (hoemail2.lucent.com [192.11.226.163]) by postgresql.org (Postfix) with ESMTP id 2F75C47727F; Tue, 7 Jan 2003 15:29:56 -0500 (EST) Received: from nj7460exch002h.wins.lucent.com (h135-17-42-35.lucent.com [135.17.42.35]) by hoemail2.firewall.lucent.com (Switch-2.2.2/Switch-2.2.0) with ESMTP id h07KTtl17570; Tue, 7 Jan 2003 15:29:55 -0500 (EST) Received: by nj7460exch002h.ho.lucent.com with Internet Mail Service (5.5.2653.19) id ; Tue, 7 Jan 2003 15:29:55 -0500 Message-ID: From: "Claiborne, Aldemaco Earl (Al)" To: "'Tom Lane'" Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: path Date: Tue, 7 Jan 2003 15:29:54 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/256 X-Sequence-Number: 35377 Hi all, How is this path created without the (.profile)? $ echo $PATH /usr/local/bin:/usr/bin:/bin:/cygdrive/c/amtagent:/cygdrive/c/informix/bin:/cygd rive/c/winnt:/cygdrive/c/winnt/system:winnt/system32:/cygdrive/c/Windows:/cygdri ve/c/Windows/command:C:jdk1.2.2/bin How can I add this path to the above path? ~/cygwin/usr/bin/gcc-3.2.1 From pgsql-general-owner@postgresql.org Tue Jan 7 11:56:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CD5C2476501; Tue, 7 Jan 2003 11:56:53 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 6159B4762C5; Tue, 7 Jan 2003 11:56:52 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h07L5NXR009492; Tue, 7 Jan 2003 19:05:23 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h07L5Mh4009488; Tue, 7 Jan 2003 19:05:22 -0200 Date: Tue, 7 Jan 2003 19:05:22 -0200 (GMT+2) From: Achilleus Mantzios To: Tom Lane Cc: Stephan Szabo , , , Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-Reply-To: <13843.1041956988@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="333001285-1824804068-1041973522=:9324" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/238 X-Sequence-Number: 35359 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --333001285-1824804068-1041973522=:9324 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 7 Jan 2003, Tom Lane wrote: > Achilleus Mantzios writes: > > About the stats on these 3 columns i get: > > Does 7.2 generate the same stats? (minus the schemaname of course) Not absolutely but close: (See attachment) > > Also, I would like to see the results of these queries on both versions, > so that we can see what the planner thinks the index selectivity is: > > EXPLAIN ANALYZE select * from noon where > v_code='4500'; > > EXPLAIN ANALYZE select * from noon where > report_date between '2002-01-07' and '2003-01-07'; > On 7.3.1 (On a FreeBSD) ======================= dynacom=# EXPLAIN ANALYZE select * from noon where v_code='4500'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------- Index Scan using noonf_vcode on noon (cost=0.00..3066.64 rows=829 width=1974) (actual time=2.02..1421.14 rows=792 loops=1) Index Cond: (v_code = '4500'::character varying) Total runtime: 1424.82 msec (3 rows) dynacom=# EXPLAIN ANALYZE select * from noon where report_date between '2002-01-07' and '2003-01-07'; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------- Index Scan using noonf_date on noon (cost=0.00..15919.50 rows=11139 width=1974) (actual time=2.05..13746.17 rows=7690 loops=1) Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) Total runtime: 13775.48 msec (3 rows) On 7.2.3 (Linux) ================== dynacom=# EXPLAIN ANALYZE select * from noon where v_code='4500'; NOTICE: QUERY PLAN: Index Scan using noonf_vcode on noon (cost=0.00..3043.45 rows=827 width=1974) (actual time=19.59..927.06 rows=792 loops=1) Total runtime: 928.86 msec dynacom=# EXPLAIN ANALYZE select * from noon where report_date between '2002-01-07' and '2003-01-07'; NOTICE: QUERY PLAN: Index Scan using noonf_date on noon (cost=0.00..16426.45 rows=11958 width=1974) (actual time=29.64..8854.05 rows=7690 loops=1) Total runtime: 8861.90 msec EXPLAIN > regards, tom lane > ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr --333001285-1824804068-1041973522=:9324 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="querystats_on_7.2.3" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="querystats_on_7.2.3" IHRhYmxlbmFtZSB8ICAgYXR0bmFtZSAgIHwgbnVsbF9mcmFjIHwgYXZnX3dp ZHRoIHwgbl9kaXN0aW5jdCB8ICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgbW9zdF9jb21tb25fdmFscyAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vc3Rf Y29tbW9uX2ZyZXFzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIGhpc3RvZ3JhbV9ib3VuZHMgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICB8IGNvcnJlbGF0aW9uIA0KLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0t LSstLS0tLS0tLS0tLSstLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0rLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLQ0KIG5v b24gICAgICB8IHZfY29kZSAgICAgIHwgICAgICAgICAwIHwgICAgICAgICA4 IHwgICAgICAgIDEwOSB8IHs0NTUwLDQ2MzAsNDY1MCw0ODAwLDQ1MjAsNDc3 MCw0NjkwLDQ2MjAsNDYxMCw0NTYwfSAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IHswLjAy NzMzMzMsMC4wMjYzMzMzLDAuMDI2LDAuMDI1NjY2NywwLjAyNTMzMzMsMC4w MjUzMzMzLDAuMDI0NjY2NywwLjAyMjY2NjcsMC4wMjIzMzMzLDAuMDIyfSAg ICAgICAgIHwgezEwMzAsMzIxMCw0MzYwLDQ1MDAsNDU3MCw0NjcwLDQ3NDAs NDgyMCw0ODcwLDQ5NDAsNjAyMH0gICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICB8ICAgLTAuMjYwMzc3DQogbm9vbiAgICAgIHwgcmVwb3J0X2RhdGUgfCAg ICAgICAgIDAgfCAgICAgICAgIDQgfCAgICAgICAzNDAyIHwgezE5OTktMDEt MjIsMjAwMC0xMi0yNiwxOTk4LTA5LTI5LDE5OTgtMTAtMTEsMTk5OS0wMi0y NCwxOTk5LTA1LTE5LDE5OTktMDktMDgsMTk5OS0wOS0xMywyMDAwLTAxLTE5 LDIwMDAtMDItMDN9IHwgezAuMDAyLDAuMDAyLDAuMDAxNjY2NjcsMC4wMDE2 NjY2NywwLjAwMTY2NjY3LDAuMDAxNjY2NjcsMC4wMDE2NjY2NywwLjAwMTY2 NjY3LDAuMDAxNjY2NjcsMC4wMDE2NjY2N30gfCB7IjAwMDEtMTEtMDcgQkMi LDE5OTQtMTAtMjIsMTk5Ni0wNC0wNSwxOTk3LTA2LTE5LDE5OTgtMDctMzEs MTk5OS0wNC0wMSwxOTk5LTEyLTE1LDIwMDAtMDktMjksMjAwMS0wNS0zMSwy MDAyLTAyLTA2LDIwMDMtMDEtMDJ9IHwgICAtMC44MjE2MjcNCiBub29uICAg ICAgfCByb3RhdGlvbiAgICB8ICAgICAgICAgMCB8ICAgICAgICAxMyB8ICAg ICAgICAgIDYgfCB7Ik5PT04gICAgICIsIlBPUlQgTE9HICIsIkFSUklWQUwg ICIsREVQQVJUVVJFLCJTRUEgICAgICAiLCJORVhUIFBPUlQifSAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCB7MC40NzgsMC4y NTM2NjcsMC4xMzgzMzMsMC4xMjE2NjcsMC4wMDYsMC4wMDIzMzMzM30gICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAg ICAwLjE0NzgyMg0KKDMgcm93cykNCg0K --333001285-1824804068-1041973522=:9324-- From pgsql-general-owner@postgresql.org Tue Jan 7 12:47:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B82384772C2; Tue, 7 Jan 2003 12:46:58 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 943224772B4; Tue, 7 Jan 2003 12:46:57 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h07LtXXR009677; Tue, 7 Jan 2003 19:55:33 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h07LtXeB009673; Tue, 7 Jan 2003 19:55:33 -0200 Date: Tue, 7 Jan 2003 19:55:33 -0200 (GMT+2) From: Achilleus Mantzios To: pgsql-general@postgresql.org, Subject: 7.3.1 function problem: ERROR: cache lookup failed for type 0 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/243 X-Sequence-Number: 35364 Hi i had written a C function to easily convert an int4 to its equivalent 1x1 int4[] array. It worked fine under 7.1,7.2. Now under 7.3.1 i get the following message whenever i try to: dynacom=# select itoar(3126); ERROR: cache lookup failed for type 0 Surprisingly though when i do something like : dynacom=# select defid from machdefs where itoar(3126) ~ parents and level(parents) = 1 order by description,partno; defid ------- 3137 3127 3130 3129 3133 3136 3135 3128 3131 3132 3134 3138 (12 rows) it works fine, but then again when i try to EXPLAIN the above (successful) statement i also get: dynacom=# EXPLAIN select defid from machdefs where itoar(3126) ~ parents and level(parents) = 1 order by description,partno; ERROR: cache lookup failed for type 0 Any clues of what could be wrong?? The definition of the function is: CREATE FUNCTION "itoar" (integer) RETURNS integer[] AS '$libdir/itoar', 'itoar' LANGUAGE 'c' WITH ( iscachable,isstrict ); I also tried without the iscachable option with no luck (since it seems to complain about *type* 0) ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-general-owner@postgresql.org Tue Jan 7 13:24:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 25849477292; Tue, 7 Jan 2003 13:24:29 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 92F764771F7; Tue, 7 Jan 2003 13:24:26 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h07MWuXR009828; Tue, 7 Jan 2003 20:32:57 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h07MWulT009824; Tue, 7 Jan 2003 20:32:56 -0200 Date: Tue, 7 Jan 2003 20:32:56 -0200 (GMT+2) From: Achilleus Mantzios To: Tom Lane Cc: pgsql-general@postgresql.org, Subject: Re: 7.3.1 function problem: ERROR: cache lookup failed In-Reply-To: <15501.1041963735@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/246 X-Sequence-Number: 35367 On Tue, 7 Jan 2003, Tom Lane wrote: > Achilleus Mantzios writes: > > Hi i had written a C function to easily convert an int4 to its > > equivalent 1x1 int4[] array. > > Does your function know about filling in the elemtype field that was > recently added to struct ArrayType? She has no clue :) Any pointers would be great. Thanx Tom. > > regards, tom lane > ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-general-owner@postgresql.org Tue Jan 7 13:29:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6486E47612D; Tue, 7 Jan 2003 13:29:51 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 46DA4475ED4; Tue, 7 Jan 2003 13:29:50 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h07McIXR009854; Tue, 7 Jan 2003 20:38:18 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h07McH2k009850; Tue, 7 Jan 2003 20:38:17 -0200 Date: Tue, 7 Jan 2003 20:38:17 -0200 (GMT+2) From: Achilleus Mantzios To: Tom Lane Cc: Stephan Szabo , , , Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-Reply-To: <14598.1041961456@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/247 X-Sequence-Number: 35368 On Tue, 7 Jan 2003, Tom Lane wrote: > There is no way that adding the filter condition should have reduced the > estimated runtime for this plan --- reducing the estimated number of > output rows, yes, but not the runtime. And in fact I can't duplicate My case persists: After clean install of the database, and after vacuum analyze, i get dynacom=# EXPLAIN ANALYZE select FUELCONSUMPTION,rpm,Steam_Hours,voyage_activity,ldin from noon where report_date between '2002-01-07' and '2003-01-07'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------- Index Scan using noonf_date on noon (cost=0.00..16458.54 rows=10774 width=39) (actual time=0.13..205.86 rows=7690 loops=1) Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) Total runtime: 233.22 msec dynacom=# EXPLAIN ANALYZE select FUELCONSUMPTION,rpm,Steam_Hours,voyage_activity,ldin from noon where report_date between '2002-01-07' and '2003-01-07' and v_code='4500'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------ Index Scan using noonf_vcode on noon (cost=0.00..3092.52 rows=83 width=39) (actual time=0.15..15.08 rows=373 loops=1) Index Cond: (v_code = '4500'::character varying) Filter: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) Total runtime: 16.56 msec (4 rows) I thought PostgreSQL in some sense (hub.org) used FreeBSD, is there any 4.7 FreeBSD server with pgsql 7.3.1 you could use? ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-general-owner@postgresql.org Tue Jan 7 13:43:18 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1FBD4476879; Tue, 7 Jan 2003 13:43:17 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 657DE4773B4; Tue, 7 Jan 2003 13:43:07 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h07MpZXR009941; Tue, 7 Jan 2003 20:51:35 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h07MpZxh009937; Tue, 7 Jan 2003 20:51:35 -0200 Date: Tue, 7 Jan 2003 20:51:35 -0200 (GMT+2) From: Achilleus Mantzios To: Tom Lane Cc: Stephan Szabo , , , Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-Reply-To: <19585.1041964797@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/250 X-Sequence-Number: 35371 On Tue, 7 Jan 2003, Tom Lane wrote: > Achilleus Mantzios writes: > > My case persists: > > After clean install of the database, and after vacuum analyze, > > i get > > Um ... is it persisting? That looks like it's correctly picked the > vcode index this time. Strange behavior though. By "clean install" > do you mean you rebuilt Postgres, or just did dropdb/createdb/reload > data? Just dropdb/createdb/reload. > > regards, tom lane > ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-general-owner@postgresql.org Tue Jan 7 18:24:26 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1219D4773C9; Tue, 7 Jan 2003 18:24:26 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 1480F4772D1; Tue, 7 Jan 2003 18:23:51 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id h07NLafC008174; Tue, 7 Jan 2003 16:21:36 -0700 (MST) Date: Tue, 7 Jan 2003 16:16:09 -0700 (MST) From: "scott.marlowe" To: Fred Moyer Cc: , , , Subject: Re: [PERFORM] PostgreSQL and memory usage In-Reply-To: <36045.168.103.211.137.1041968782.squirrel@mail.digicamp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/264 X-Sequence-Number: 35385 Oh yeah, sorry. My box has 1.5 gig ram, but it is an application server that runs things other than just postgresql. It also runs: Apache Real Server OpenLDAP Squid Samba with all those services fired up and running, as well as postgresql with 256 Megs of shared buffer, I have about 900 megs of cache and 100 megs free ram. Since a lot of data is flying off the hard drives at any given time, favoring one service (database) over the others makes little sense for me, and I've found that there was little or no performance gain from 256 Megs ram over say 128 meg or 64 meg. We run about 50 databases averaging about 25megs each or so (backed up, it's about 50 to 75 Megs on the machine's hard drives) so there's no way for ALL the data to fit into memory. On Tue, 7 Jan 2003, Fred Moyer wrote: > To put this usage of shared buffers in perspective would you mind kindly > let us know your total amount of system ram? Without hearing what > percentage of memory used as shared buffers (assuming is the primary > application being using here) > > I have always taken the 'more is better' approach with shared buffers but > would like to know what in terms of percentages other people are using. I > have been using 50% of system ram (2 out of 4 gigs) for shared buffers > (and corresponding shmmax values) and it has been working great. I > haven't tweaked the kernel yet to get more than 2 gigs shmmax so I can't > speak for a setup using over 50%. I've been using between 256 and 512 > megs sort memory which sounds like a little much from what I'm hearing > here. From pgsql-performance-owner@postgresql.org Wed Jan 8 08:27:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1AD78475F34 for ; Wed, 8 Jan 2003 08:27:08 -0500 (EST) Received: from benhur.intern.control.de (unknown [217.89.112.10]) by postgresql.org (Postfix) with ESMTP id C1AA0475CED for ; Wed, 8 Jan 2003 08:27:06 -0500 (EST) Received: from devserver (devserver.intern.control.de [192.168.100.5]) by benhur.intern.control.de (8.12.6/8.12.6/Benhur 8.12.6) with ESMTP id h08DQGVO019858 for ; Wed, 8 Jan 2003 14:26:17 +0100 Content-Type: text/plain; charset="us-ascii" From: Boris Klug Organization: control IT GmbH To: pgsql-performance@postgresql.org Subject: Unions and where optimisation Date: Wed, 8 Jan 2003 14:25:48 +0100 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301081425.48597.boris.klug@control.de> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/52 X-Sequence-Number: 699 Hello! I am quite new in the PostgreSQL performance business, done a few years Ora= cle=20 stuff before. My ist question is the following: We have three table, lets name them rk150, 151 and rk152. They all have a= =20 timestamp and a order number in common but than different data after this.= =20 Now I need the data from all tables in one view for a given order number, s= o=20 I created a view create view orderevents as select ts, aufnr from rk150 union select ts, aufnr from rk151 union select ts, aufnr from rk152; When I does a "select * from orderevents where aufnr=3D'1234'" it takes ove= r 14=20 seconds! The problem is now that PostgreSQL first does the union with all the three= =20 tables and after this sorts out the right rows: Subquery Scan a (cost=3D54699.06..56622.18 rows=3D38462 width=3D20) -> Unique (cost=3D54699.06..56622.18 rows=3D38462 width=3D20) -> Sort (cost=3D54699.06..54699.06 rows=3D384624 width=3D20) -> Append (cost=3D0.00..10689.24 rows=3D384624 width=3D20) -> Subquery Scan *SELECT* 1 (cost=3D0.00..8862.52 rows=3D314852 width=3D20) -> Seq Scan on rk150=20 (cost=3D0.00..8862.52 rows=3D314852 width=3D20) -> Subquery Scan *SELECT* 2=20=20 (cost=3D0.00..1208.58 rows=3D45858 width=3D20) -> Seq Scan on rk151=20=20 (cost=3D0.00..1208.58 rows=3D45858 width=3D20) -> Subquery Scan *SELECT* 3=20 (cost=3D0.00..618.14 rows=3D23914 width=3D20) -> Seq Scan on rk152=20=20 (cost=3D0.00..618.14 rows=3D23914 width=3D20) A better thing would it (Oracle does this and I think I have seen it on=20 PostgreSQL before), that the where-clause is moved inside every select so w= e=20 have something like this (written by hand): select * from ( select zeit, aufnr from rk150 where aufnr=3D'13153811' union select zeit, aufnr from rk151 where aufnr=3D'13153811' union select zeit, aufnr from rk152 where aufnr=3D'13153811') as A; This takes less than 1 second because the nr of rows that have to be joined= =20 are only 45 (optimizer expects 4), not > 300.000: Subquery Scan a (cost=3D45.97..46.19 rows=3D4 width=3D20) -> Unique (cost=3D45.97..46.19 rows=3D4 width=3D20) -> Sort (cost=3D45.97..45.97 rows=3D45 width=3D20) -> Append (cost=3D0.00..44.74 rows=3D45 width=3D20) -> Subquery Scan *SELECT* 1=20 (cost=3D0.00..32.22 rows=3D31 width=3D20) -> Index Scan using rk150_uidx_aufnr on rk150=20= =20 (cost=3D0.00..32.22 rows=3D31 width=3D20) -> Subquery Scan *SELECT* 2=20 (cost=3D0.00..7.67 rows=3D9 width=3D20) -> Index Scan using rk151_uidx_aufnr on rk151=20= =20 (cost=3D0.00..7.67 rows=3D9 width=3D20) -> Subquery Scan *SELECT* 3=20=20 (cost=3D0.00..4.85 rows=3D5 width=3D20) -> Index Scan using rk152_uidx_aufnr on rk152=20 (cost=3D0.00..4.85 rows=3D5 width=3D20) My question now: Is the optimizer able to move the where clause into unions= ?=20 If so, how I can get him to do it? Thank you for the help in advance! --=20 Dipl. Inform. Boris Klug, control IT GmbH, Germany From pgsql-performance-owner@postgresql.org Wed Jan 8 09:28:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D980E475AAC for ; Wed, 8 Jan 2003 09:28:27 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 3966E4758F1 for ; Wed, 8 Jan 2003 09:28:27 -0500 (EST) Received: from klaster.net (pa168.krakow.cvx.ppp.tpnet.pl [213.76.36.168]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 618902B21C; Wed, 8 Jan 2003 15:26:34 +0100 (CET) Message-ID: <3E1C366B.5080406@klaster.net> Date: Wed, 08 Jan 2003 15:32:11 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Hannu Krosing Cc: Boris Klug , "pgsql-performance@postgresql.org" Subject: Re: Unions and where optimisation References: <200301081425.48597.boris.klug@control.de> <1042041735.3237.1.camel@huli> In-Reply-To: <200301081425.48597.boris.klug@control.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/55 X-Sequence-Number: 702 Hannu Krosing wrote: > > try making the orderevents view like this: > > create view orderevents as > select rk.aufnr, sub.ts > from rk150 rk, > ( select ts from rk150 where aufnr = rk.aufr > union > select ts from rk151 where aufnr = rk.aufr > union > select ts from rk152 where aufnr = rk.aufr > ) as sub > ; > > this could/should force your desired behavior. > Hannu, does it work? Few months ago I lost some time trying to create this kind of query and I always got error, that subselect doesn't knows anything about upper (outer?) table. In this query you should get error: "relation rk does not exist". What version of postgres do you have? Tomasz Myrta From pgsql-performance-owner@postgresql.org Wed Jan 8 09:37:09 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EA2B3476F6B for ; Wed, 8 Jan 2003 09:37:08 -0500 (EST) Received: from benhur.intern.control.de (unknown [217.89.112.10]) by postgresql.org (Postfix) with ESMTP id C0B12476F67 for ; Wed, 8 Jan 2003 09:37:07 -0500 (EST) Received: from devserver (devserver.intern.control.de [192.168.100.5]) by benhur.intern.control.de (8.12.6/8.12.6/Benhur 8.12.6) with ESMTP id h08Eb2VO024564; Wed, 8 Jan 2003 15:37:02 +0100 Content-Type: text/plain; charset="iso-8859-1" From: Boris Klug Organization: control IT GmbH To: Tomasz Myrta , Hannu Krosing Subject: Re: Unions and where optimisation Date: Wed, 8 Jan 2003 15:36:33 +0100 User-Agent: KMail/1.4.3 Cc: "pgsql-performance@postgresql.org" References: <200301081425.48597.boris.klug@control.de> <1042041735.3237.1.camel@huli> <3E1C366B.5080406@klaster.net> In-Reply-To: <3E1C366B.5080406@klaster.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301081536.33211.boris.klug@control.de> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/57 X-Sequence-Number: 704 Hello! > Hannu, does it work? > Few months ago I lost some time trying to create this kind of query and > I always got error, that subselect doesn't knows anything about upper > (outer?) table. It does not work on my PostgreSQL 7.2.x Get the same error like you: "relation rk does not exist" Also the disadvantage of this solution is that the speed up is bound to=20 queries for the ordernr. If a statement has a where clause e.g. for a=20 timestamp, the view is still slow. Does PostgreSQL not know how to move where clause inside each select in a= =20 union? --=20 Dipl. Inform. Boris Klug, control IT GmbH, Germany From pgsql-performance-owner@postgresql.org Wed Jan 8 09:36:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 97E2F475FCE for ; Wed, 8 Jan 2003 09:36:55 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id EBA84475EB2 for ; Wed, 8 Jan 2003 09:36:54 -0500 (EST) Received: from klaster.net (ph110.krakow.cvx.ppp.tpnet.pl [217.99.208.110]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 13E2C2B21C; Wed, 8 Jan 2003 15:35:06 +0100 (CET) Message-ID: <3E1C386B.5050400@klaster.net> Date: Wed, 08 Jan 2003 15:40:43 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Boris Klug Cc: pgsql-performance@postgresql.org Subject: Re: Unions and where optimisation References: <200301081425.48597.boris.klug@control.de> In-Reply-To: <200301081425.48597.boris.klug@control.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/56 X-Sequence-Number: 703 Boris Klug wrote: > create view orderevents as > select ts, aufnr from rk150 > union > select ts, aufnr from rk151 > union > select ts, aufnr from rk152; I lost some time and I didn't find valid solution for this kind of query :-( I solved it (nice to hear about better solution) using table inheritance. create table rk_master( fields... fields... ); create table rk150 () inherits rk_master; create table rk151 () inherits rk_master; create table rk152 () inherits rk_master; now you can just create simple view: select ts, aufnr from rk_master; Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Wed Jan 8 10:47:41 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 70FEE475D70 for ; Wed, 8 Jan 2003 10:47:40 -0500 (EST) Received: from mail.gmx.net (mail.gmx.net [213.165.65.60]) by postgresql.org (Postfix) with SMTP id 5ED75475CED for ; Wed, 8 Jan 2003 10:47:39 -0500 (EST) Received: (qmail 30675 invoked by uid 0); 8 Jan 2003 15:47:43 -0000 Received: from chello062178186201.1.15.tuwien.teleweb.at (HELO beeblebrox) (62.178.186.201) by mail.gmx.net (mp006-rz3) with SMTP; 8 Jan 2003 15:47:43 -0000 Message-ID: <013001c2b72d$658ee4b0$3201a8c0@beeblebrox> From: "Michael Paesold" To: "Boris Klug" , "Tomasz Myrta" , "Hannu Krosing" Cc: References: <200301081425.48597.boris.klug@control.de> <1042041735.3237.1.camel@huli> <3E1C366B.5080406@klaster.net> <200301081536.33211.boris.klug@control.de> Subject: Re: Unions and where optimisation Date: Wed, 8 Jan 2003 16:48:27 +0100 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/60 X-Sequence-Number: 707 Boris Klug wrote: > > Hannu, does it work? > > Few months ago I lost some time trying to create this kind of query and > > I always got error, that subselect doesn't knows anything about upper > > (outer?) table. > > It does not work on my PostgreSQL 7.2.x > > Get the same error like you: "relation rk does not exist" > > Also the disadvantage of this solution is that the speed up is bound to > queries for the ordernr. If a statement has a where clause e.g. for a > timestamp, the view is still slow. > > Does PostgreSQL not know how to move where clause inside each select in a > union? Hi Boris, As far as I know, this has first been "fixed" in 7.3. I think it was Tom who improved the optimizer to push the where clause into the selects of a union view. I've done a test... create view test as select updated, invoice_id from invoice union all select updated, invoice_id from inv2 union all select updated, invoice_id from inv3; ... and it seems to work (postgresql 7.3 here): billing=# explain select * from test where invoice_id = 111000; QUERY PLAN ---------------------------------------------------------------------------- ---------------- Subquery Scan test (cost=0.00..413.24 rows=114 width=12) -> Append (cost=0.00..413.24 rows=114 width=12) -> Subquery Scan "*SELECT* 1" (cost=0.00..6.00 rows=1 width=12) -> Index Scan using pk_invoice on invoice (cost=0.00..6.00 rows=1 width=12) Index Cond: (invoice_id = 111000) -> Subquery Scan "*SELECT* 2" (cost=0.00..203.62 rows=57 width=12) -> Index Scan using idx_inv2 on inv2 (cost=0.00..203.62 rows=57 width=12) Index Cond: (invoice_id = 111000) -> Subquery Scan "*SELECT* 3" (cost=0.00..203.62 rows=57 width=12) -> Index Scan using idx_inv3 on inv3 (cost=0.00..203.62 rows=57 width=12) Index Cond: (invoice_id = 111000) (11 rows) I hope this is helps. Can you upgrade to 7.3.1? I really think the upgrade is worth the effort. Best Regards, Michael Paesold From pgsql-performance-owner@postgresql.org Wed Jan 8 09:08:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B1D334763CD for ; Wed, 8 Jan 2003 09:08:37 -0500 (EST) Received: from localhost.localdomain (sein.itera.ee [194.126.109.126]) by postgresql.org (Postfix) with ESMTP id A3B254762AA for ; Wed, 8 Jan 2003 09:08:36 -0500 (EST) Received: (from hannu@localhost) by localhost.localdomain (8.11.6/8.11.6) id h08G2G103290; Wed, 8 Jan 2003 16:02:16 GMT X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: Unions and where optimisation From: Hannu Krosing To: Boris Klug Cc: "pgsql-performance@postgresql.org" In-Reply-To: <200301081425.48597.boris.klug@control.de> References: <200301081425.48597.boris.klug@control.de> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1042041735.3237.1.camel@huli> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 08 Jan 2003 16:02:15 +0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/54 X-Sequence-Number: 701 On Wed, 2003-01-08 at 13:25, Boris Klug wrote: > Hello! > > I am quite new in the PostgreSQL performance business, done a few years Oracle > stuff before. My ist question is the following: > > We have three table, lets name them rk150, 151 and rk152. They all have a > timestamp and a order number in common but than different data after this. > Now I need the data from all tables in one view for a given order number, so > I created a view > > create view orderevents as > select ts, aufnr from rk150 > union > select ts, aufnr from rk151 > union > select ts, aufnr from rk152; try making the orderevents view like this: create view orderevents as select rk.aufnr, sub.ts from rk150 rk, ( select ts from rk150 where aufnr = rk.aufr union select ts from rk151 where aufnr = rk.aufr union select ts from rk152 where aufnr = rk.aufr ) as sub ; this could/should force your desired behavior. > My question now: Is the optimizer able to move the where clause into unions? > If so, how I can get him to do it? > > Thank you for the help in advance! -- Hannu Krosing From pgsql-performance-owner@postgresql.org Wed Jan 8 11:14:56 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D2ED2476F4C for ; Wed, 8 Jan 2003 11:14:54 -0500 (EST) Received: from benhur.intern.control.de (unknown [217.89.112.10]) by postgresql.org (Postfix) with ESMTP id 2D19F4763D8 for ; Wed, 8 Jan 2003 11:14:15 -0500 (EST) Received: from devserver (devserver.intern.control.de [192.168.100.5]) by benhur.intern.control.de (8.12.6/8.12.6/Benhur 8.12.6) with ESMTP id h08GDVVO030991; Wed, 8 Jan 2003 17:13:32 +0100 Content-Type: text/plain; charset="iso-8859-1" From: Boris Klug Organization: control IT GmbH To: "Michael Paesold" , "Tomasz Myrta" , "Hannu Krosing" Subject: Re: Unions and where optimisation Date: Wed, 8 Jan 2003 17:13:00 +0100 User-Agent: KMail/1.4.3 Cc: References: <200301081425.48597.boris.klug@control.de> <200301081536.33211.boris.klug@control.de> <013001c2b72d$658ee4b0$3201a8c0@beeblebrox> In-Reply-To: <013001c2b72d$658ee4b0$3201a8c0@beeblebrox> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301081713.00786.boris.klug@control.de> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/61 X-Sequence-Number: 708 Hello! > As far as I know, this has first been "fixed" in 7.3. I think it was Tom > who improved the optimizer to push the where clause into the selects of a > union view. I've done a test... Yes, I installed 7.3 and it works fine there. I think we will upgrade to 7.= 3.1=20 our development system soon. Thank you! --=20 Dipl. Inform. Boris Klug, control IT GmbH, Germany From pgsql-performance-owner@postgresql.org Wed Jan 8 09:56:00 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EE4C4476F5F for ; Wed, 8 Jan 2003 09:55:59 -0500 (EST) Received: from localhost.localdomain (sein.itera.ee [194.126.109.126]) by postgresql.org (Postfix) with ESMTP id DCBAC476F55 for ; Wed, 8 Jan 2003 09:55:58 -0500 (EST) Received: (from hannu@localhost) by localhost.localdomain (8.11.6/8.11.6) id h08GnKU03357; Wed, 8 Jan 2003 16:49:20 GMT X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: Unions and where optimisation From: Hannu Krosing To: Tomasz Myrta Cc: Boris Klug , "pgsql-performance@postgresql.org" In-Reply-To: <3E1C366B.5080406@klaster.net> References: <200301081425.48597.boris.klug@control.de> <1042041735.3237.1.camel@huli> <3E1C366B.5080406@klaster.net> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1042044560.3237.7.camel@huli> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 08 Jan 2003 16:49:20 +0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/58 X-Sequence-Number: 705 On Wed, 2003-01-08 at 14:32, Tomasz Myrta wrote: > Hannu Krosing wrote: > > > > > try making the orderevents view like this: > > > > create view orderevents as > > select rk.aufnr, sub.ts > > from rk150 rk, > > ( select ts from rk150 where aufnr = rk.aufr > > union > > select ts from rk151 where aufnr = rk.aufr > > union > > select ts from rk152 where aufnr = rk.aufr > > ) as sub > > ; > > > > this could/should force your desired behavior. > > > > Hannu, does it work? Nope! Sorry. SQL spec clearly states that subqueries in FROM clause must not see each other ;( It would work in WITH part of the query, which will hopefully be implemented in some future PG version, perhaps even 7.4 as WITH is the prerequisite for implementing SQL99 recursive queries, and RedHat has shown an strongish interest in implementing these. > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Hannu Krosing From pgsql-performance-owner@postgresql.org Wed Jan 8 10:32:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 63B47476EAC for ; Wed, 8 Jan 2003 10:32:37 -0500 (EST) Received: from com.ith.tur.cu (com.ith.tur.cu [212.44.111.34]) by postgresql.org (Postfix) with ESMTP id 8CBDF476DC8 for ; Wed, 8 Jan 2003 10:32:31 -0500 (EST) Received: from nsoft by com.ith.tur.cu with SMTP (MDaemon.PRO.v6.0.7.R) for ; Wed, 08 Jan 2003 09:18:31 -0500 Message-ID: <000901c2b739$ed6df360$8a24a8c0@nsoft> Reply-To: "enediel" From: "enediel" To: "postgresql" Subject: postgresql in cluster of servers Date: Wed, 8 Jan 2003 09:18:09 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Return-Path: enediel@com.ith.tur.cu X-MDaemon-Deliver-To: pgsql-performance@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/59 X-Sequence-Number: 706 Hello to all list members: I'm looking for information about using postgresql in a cluster of servers where all real servers share a unique databases location outside them. The question could be one of the follows? ?Is the prostgresql prepared to synchronize simultaneous accesses to oneself database among processes that run in different PC's? or ?Was the postgresql database designed to allow simultaneous acceses of processes that run in different PC's allowing for own design the sincronizationof all the processes? Thanks in advance for the attention Enediel Linux user 300141 Happy who can penetrate the secret causes of the things �Use Linux! From pgsql-general-owner@postgresql.org Wed Jan 8 12:33:22 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 282894765C1; Wed, 8 Jan 2003 12:33:21 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 7DE6D476360; Wed, 8 Jan 2003 12:32:28 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h08HWX0U004829; Wed, 8 Jan 2003 12:32:33 -0500 (EST) To: pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-reply-to: References: Comments: In-reply-to Achilleus Mantzios message dated "Tue, 07 Jan 2003 20:38:17 -0200" Date: Wed, 08 Jan 2003 12:32:33 -0500 Message-ID: <4828.1042047153@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/297 X-Sequence-Number: 35418 Just to close off the thread, here is the end-result of investigating Achilleus Mantzios' problem. ------- Forwarded Message Date: Wed, 08 Jan 2003 11:54:36 -0500 From: Tom Lane To: Achilleus Mantzios Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance I believe I see what's going on. You have a number of silly outlier values in the report_date column --- quite a few instances of '10007-06-09' for example. Depending on whether ANALYZE's random sample happens to include one of these, the histogram generated by ANALYZE might look like this (it took about half a dozen tries with ANALYZE to get this result): dynacom=# analyze noon; ANALYZE dynacom=# select histogram_bounds from pg_stats where attname = 'report_date'; histogram_bounds ----------------------------------------------------------------------------------------------------------------------------- {1969-06-26,1994-09-24,1996-04-05,1997-07-21,1998-08-27,1999-03-13,1999-11-11,2000-08-18,2001-04-18,2002-01-04,10007-06-09} (1 row) in which case we get this: dynacom=# EXPLAIN select * from noon where dynacom-# report_date between '2002-01-07' and '2003-01-07'; QUERY PLAN --------------------------------------------------------------------------------------------- Index Scan using noonf_date on noon (cost=0.00..4.08 rows=1 width=1975) Index Cond: ((report_date >= '2002-01-07'::date) AND (report_date <= '2003-01-07'::date)) (2 rows) Seeing this histogram, the planner assumes that one-tenth of the table is uniformly distributed between 2002-01-04 and 10007-06-09, which leads it to the conclusion that the range between 2002-01-07 and 2003-01-07 probably contains only about one row, which causes it to prefer a scan on report_date rather than on v_code. The reason the problem comes and goes is that any given ANALYZE run might or might not happen across one of the outliers. When it doesn't, you get a histogram that leads to reasonably accurate estimates. There are a couple of things you could do about this. One is to increase the statistics target for report_date (see ALTER TABLE SET STATISTICS) so that a finer-grained histogram is generated for the report_date column. The other thing, which is more work but probably the best answer in the long run, is to fix the outliers, which I imagine must be incorrect entries. You could perhaps put a constraint on report_date to prevent bogus entries from sneaking in in future. It looks like increasing the stats target would be worth doing also, if you make many queries using ranges of report_date. regards, tom lane ------- End of Forwarded Message From pgsql-general-owner@postgresql.org Wed Jan 8 08:45:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DF4BC47685E; Wed, 8 Jan 2003 08:45:13 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id AC2154767AA; Wed, 8 Jan 2003 08:45:12 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h08HrvXR014444; Wed, 8 Jan 2003 15:53:57 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h08Hrs5Q014440; Wed, 8 Jan 2003 15:53:54 -0200 Date: Wed, 8 Jan 2003 15:53:54 -0200 (GMT+2) From: Achilleus Mantzios To: Tom Lane Cc: Rod Taylor , Stephan Szabo , Pgsql Performance , , Subject: Re: [SQL] [PERFORM] 7.3.1 index use / performance In-Reply-To: <19889.1041967568@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/287 X-Sequence-Number: 35408 On Tue, 7 Jan 2003, Tom Lane wrote: > Rod Taylor writes: > >> I am wondering about a compiler bug, or some other peculiarity on your > >> platform. Can anyone else using FreeBSD try the above experiment and > >> see if they get different results from mine on 7.3.* (or CVS tip)? > > > On FreeBSD 4.7 I received the exact same results as Tom using the > > statements shown by Tom. > > On looking at the code, I do see part of a possible mechanism for this > behavior: cost_index calculates the estimated cost for qual-clause > evaluation like this: > This bizarre index decreased cost (when adding conditions) behaviour maybe was due to some vacuums. (i cant remember how many reloads and vacuums i did to the database in the period petween the two emails). However my linux machine with the same pgsql 7.3.1, with a full clean installation also gives the same symptoms: Choosing the slow index, and after some (random) vacuums choosing the right index, and then after some vacuums chooses the bad index again. > > regards, tom lane > ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-performance-owner@postgresql.org Wed Jan 8 14:05:48 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3579D475FFE for ; Wed, 8 Jan 2003 14:05:48 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 034634764E4 for ; Wed, 8 Jan 2003 14:05:26 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2307618; Wed, 08 Jan 2003 11:05:29 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "enediel" , "postgresql" Subject: Re: postgresql in cluster of servers Date: Wed, 8 Jan 2003 11:08:13 -0800 X-Mailer: KMail [version 1.4] References: <000901c2b739$ed6df360$8a24a8c0@nsoft> In-Reply-To: <000901c2b739$ed6df360$8a24a8c0@nsoft> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301081108.13422.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/63 X-Sequence-Number: 710 Enediel, > ?Was the postgresql database designed to allow simultaneous acceses of > processes that run in different PC's allowing for own design the > sincronizationof all the processes? No, unless I'm really out of the loop.=20 However, I believe that some/all of the commercial companies who offer=20 PostgreSQL-based solutions offer extensions/versions of Postgres that do=20 this. I suggest that you contact: PostgreSQL Inc. Command Prompt Inc. Red Hat (Red Hat Database) --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Jan 8 16:14:53 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CDEEF475E3E for ; Wed, 8 Jan 2003 16:14:52 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id 44225475D1C for ; Wed, 8 Jan 2003 16:14:52 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030108211451.MNMM2203.lakemtao02.cox.net@[192.168.1.1]> for ; Wed, 8 Jan 2003 16:14:51 -0500 Subject: Re: postgresql in cluster of servers From: Ron Johnson To: postgresql In-Reply-To: <000901c2b739$ed6df360$8a24a8c0@nsoft> References: <000901c2b739$ed6df360$8a24a8c0@nsoft> Content-Type: text/plain Organization: Message-Id: <1042060491.7864.162.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 08 Jan 2003 15:14:52 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/64 X-Sequence-Number: 711 On Wed, 2003-01-08 at 11:18, enediel wrote: > Hello to all list members: > > I'm looking for information about using postgresql in a cluster of servers > where all real servers share a unique databases location outside them. > > The question could be one of the follows? > > ?Is the prostgresql prepared to synchronize simultaneous accesses to oneself > database among processes that run in different PC's? > > or > > ?Was the postgresql database designed to allow simultaneous acceses of > processes that run in different PC's allowing for own design the > sincronizationof all the processes? To clarify: do you mean (1) multiple copies of *the*same*database* sitting on many machines, and all of them synchronizing themselves? OR (2) multiple application server machines all hitting a single database sitting on a single database server machine? -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Wed Jan 8 18:38:56 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0234F475E31 for ; Wed, 8 Jan 2003 18:38:55 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 5D2D0475D3B for ; Wed, 8 Jan 2003 18:38:54 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030108233856.ZRTS26808.lakemtao03.cox.net@[192.168.1.1]> for ; Wed, 8 Jan 2003 18:38:56 -0500 Subject: Re: Fw: postgresql in cluster of servers From: Ron Johnson To: postgresql In-Reply-To: <018901c2b781$5576d2f0$8a24a8c0@nsoft> References: <018901c2b781$5576d2f0$8a24a8c0@nsoft> Content-Type: text/plain; charset=ISO-8859-1 Organization: Message-Id: <1042069134.7864.205.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 08 Jan 2003 17:38:54 -0600 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/66 X-Sequence-Number: 713 On Wed, 2003-01-08 at 19:49, enediel wrote: > Thanks for all answers: > Ron Johnson, I mean the second option thet you wrote: > > (2) multiple application server machines all hitting a single database > sitting on a single database server machine? Ok, great. To the PG server, the app servers are db clients, just like any other client. Multi-user access, arranged so that users don't step over each other, is integrated deeply into the server. Thus, PostgreSQL meets this qualification... > Happy who can penetrate the secret causes of the things > �Use Linux! > ----- Original Message ----- > From: "Ron Johnson" > To: "postgresql" > Sent: Wednesday, January 08, 2003 1:14 PM > Subject: Re: [PERFORM] postgresql in cluster of servers > > > > On Wed, 2003-01-08 at 11:18, enediel wrote: > > > Hello to all list members: > > > > > > I'm looking for information about using postgresql in a cluster of > servers > > > where all real servers share a unique databases location outside them. > > > > > > The question could be one of the follows? > > > > > > ?Is the prostgresql prepared to synchronize simultaneous accesses to > oneself > > > database among processes that run in different PC's? > > > > > > or > > > > > > ?Was the postgresql database designed to allow simultaneous acceses of > > > processes that run in different PC's allowing for own design the > > > sincronizationof all the processes? > > > > To clarify: do you mean > > > > (1) multiple copies of *the*same*database* sitting on many machines, > > and all of them synchronizing themselves? > > > > OR > > > > (2) multiple application server machines all hitting a single database > > sitting on a single database server machine? -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Wed Jan 8 17:47:44 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7CD0A475D3B for ; Wed, 8 Jan 2003 17:47:42 -0500 (EST) Received: from com.ith.tur.cu (com.ith.tur.cu [212.44.111.34]) by postgresql.org (Postfix) with ESMTP id 4C431475D1C for ; Wed, 8 Jan 2003 17:47:38 -0500 (EST) Received: from nsoft by com.ith.tur.cu with SMTP (MDaemon.PRO.v6.0.7.R) for ; Wed, 08 Jan 2003 17:49:38 -0500 Message-ID: <018901c2b781$5576d2f0$8a24a8c0@nsoft> Reply-To: "enediel" From: "enediel" To: "postgresql" Subject: Fw: postgresql in cluster of servers Date: Wed, 8 Jan 2003 17:49:21 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Return-Path: enediel@com.ith.tur.cu X-MDaemon-Deliver-To: pgsql-performance@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/65 X-Sequence-Number: 712 Thanks for all answers: Ron Johnson, I mean the second option thet you wrote: (2) multiple application server machines all hitting a single database sitting on a single database server machine? Greetings Enediel Linux user 300141 Happy who can penetrate the secret causes of the things �Use Linux! ----- Original Message ----- From: "Ron Johnson" To: "postgresql" Sent: Wednesday, January 08, 2003 1:14 PM Subject: Re: [PERFORM] postgresql in cluster of servers > On Wed, 2003-01-08 at 11:18, enediel wrote: > > Hello to all list members: > > > > I'm looking for information about using postgresql in a cluster of servers > > where all real servers share a unique databases location outside them. > > > > The question could be one of the follows? > > > > ?Is the prostgresql prepared to synchronize simultaneous accesses to oneself > > database among processes that run in different PC's? > > > > or > > > > ?Was the postgresql database designed to allow simultaneous acceses of > > processes that run in different PC's allowing for own design the > > sincronizationof all the processes? > > To clarify: do you mean > > (1) multiple copies of *the*same*database* sitting on many machines, > and all of them synchronizing themselves? > > OR > > (2) multiple application server machines all hitting a single database > sitting on a single database server machine? > > -- > +------------------------------------------------------------+ > | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | > | Jefferson, LA USA http://members.cox.net/ron.l.johnson | > | | > | "Basically, I got on the plane with a bomb. Basically, I | > | tried to ignite it. Basically, yeah, I intended to damage | > | the plane." | > | RICHARD REID, who tried to blow up American Airlines | > | Flight 63 | > +------------------------------------------------------------+ > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > From pgsql-performance-owner@postgresql.org Thu Jan 9 12:20:36 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1626D475FEB for ; Thu, 9 Jan 2003 12:20:35 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id C9FF8475FC6 for ; Thu, 9 Jan 2003 12:20:31 -0500 (EST) Received: (qmail 16695 invoked from network); 9 Jan 2003 19:00:58 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 9 Jan 2003 19:00:58 -0000 Message-ID: <3E1DA1B9.E19B6C02@t1.unisoftbg.com> Date: Thu, 09 Jan 2003 17:22:17 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: enediel Cc: postgresql Subject: Re: Fw: postgresql in cluster of servers References: <018901c2b781$5576d2f0$8a24a8c0@nsoft> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/67 X-Sequence-Number: 714 Hi, I think if we speak about single db server you will nead to ask the app. server provider about clustering. I am working with jboss and it is supporting clustering. regards, ivan. enediel wrote: > Thanks for all answers: > Ron Johnson, I mean the second option thet you wrote: > > (2) multiple application server machines all hitting a single database > sitting on a single database server machine? > > Greetings > Enediel > Linux user 300141 > > Happy who can penetrate the secret causes of the things > �Use Linux! > ----- Original Message ----- > From: "Ron Johnson" > To: "postgresql" > Sent: Wednesday, January 08, 2003 1:14 PM > Subject: Re: [PERFORM] postgresql in cluster of servers > > > On Wed, 2003-01-08 at 11:18, enediel wrote: > > > Hello to all list members: > > > > > > I'm looking for information about using postgresql in a cluster of > servers > > > where all real servers share a unique databases location outside them. > > > > > > The question could be one of the follows? > > > > > > ?Is the prostgresql prepared to synchronize simultaneous accesses to > oneself > > > database among processes that run in different PC's? > > > > > > or > > > > > > ?Was the postgresql database designed to allow simultaneous acceses of > > > processes that run in different PC's allowing for own design the > > > sincronizationof all the processes? > > > > To clarify: do you mean > > > > (1) multiple copies of *the*same*database* sitting on many machines, > > and all of them synchronizing themselves? > > > > OR > > > > (2) multiple application server machines all hitting a single database > > sitting on a single database server machine? > > > > -- > > +------------------------------------------------------------+ > > | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | > > | Jefferson, LA USA http://members.cox.net/ron.l.johnson | > > | | > > | "Basically, I got on the plane with a bomb. Basically, I | > > | tried to ignite it. Basically, yeah, I intended to damage | > > | the plane." | > > | RICHARD REID, who tried to blow up American Airlines | > > | Flight 63 | > > +------------------------------------------------------------+ > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) From pgsql-performance-owner@postgresql.org Thu Jan 9 15:27:45 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4648B475DA7 for ; Thu, 9 Jan 2003 15:27:44 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id A93B1475CB4 for ; Thu, 9 Jan 2003 15:27:43 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id h09KOsgS004117; Thu, 9 Jan 2003 13:24:57 -0700 (MST) Date: Thu, 9 Jan 2003 13:18:36 -0700 (MST) From: "scott.marlowe" To: enediel Cc: postgresql Subject: Re: Fw: Fw: postgresql in cluster of servers In-Reply-To: <006f01c2b81f$89508e10$8a24a8c0@nsoft> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/69 X-Sequence-Number: 716 On Thu, 9 Jan 2003, enediel wrote: > No, pginfo, suposse this example > > Web server or cluster web server, it's unimportant > | > Postgresql cluster server containing{ > ... > Real server 1 running postgresql processes > Real server 2 running postgresql processes > .... > } > | > File server machine that contains all pg_databases > > Notice that the real servers don't have in their hard disk any database, > they could have a link to the hard disk in the File server machine. Postgresql cannot currently work this way. It uses shared memory on a single image OS to maintain the database coherently. when you cluster Postgresql across multiple machines, currently you have to have two seperate and independant instances which are synchronized by an external process of some sort. since I/O is usually the single limiting factor, your suggested system would likely be no faster than a single box with decent memory and CPUs in it. From pgsql-performance-owner@postgresql.org Thu Jan 9 12:40:15 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A1D36476115 for ; Thu, 9 Jan 2003 12:40:14 -0500 (EST) Received: from com.ith.tur.cu (com.ith.tur.cu [212.44.111.34]) by postgresql.org (Postfix) with ESMTP id 1020D476085 for ; Thu, 9 Jan 2003 12:40:11 -0500 (EST) Received: from nsoft by com.ith.tur.cu with SMTP (MDaemon.PRO.v6.0.7.R) for ; Thu, 09 Jan 2003 12:42:01 -0500 Message-ID: <006f01c2b81f$89508e10$8a24a8c0@nsoft> Reply-To: "enediel" From: "enediel" To: "postgresql" Subject: Fw: Fw: postgresql in cluster of servers Date: Thu, 9 Jan 2003 12:41:44 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Return-Path: enediel@com.ith.tur.cu X-MDaemon-Deliver-To: pgsql-performance@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/68 X-Sequence-Number: 715 No, pginfo, suposse this example Web server or cluster web server, it's unimportant | Postgresql cluster server containing{ ... Real server 1 running postgresql processes Real server 2 running postgresql processes .... } | File server machine that contains all pg_databases Notice that the real servers don't have in their hard disk any database, they could have a link to the hard disk in the File server machine. The syncronization between postgresql processes that are running on different machines and using the same database is my question. Thanks for the answer Greetings Enediel Linux user 300141 Happy who can penetrate the secret causes of the things �Use Linux! ----- Original Message ----- From: "pginfo" To: "enediel" Sent: Thursday, January 09, 2003 8:21 AM Subject: Re: Fw: [PERFORM] postgresql in cluster of servers > Hi, > > I think if we speak about single db server you will nead to ask > the app. server provider about clustering. > > I am working with jboss and it is supporting clustering. > > > regards, > ivan. > > enediel wrote: > > > Thanks for all answers: > > Ron Johnson, I mean the second option thet you wrote: > > > > (2) multiple application server machines all hitting a single database > > sitting on a single database server machine? > > > > Greetings > > Enediel > > Linux user 300141 > > > > Happy who can penetrate the secret causes of the things > > �Use Linux! > > ----- Original Message ----- > > From: "Ron Johnson" > > To: "postgresql" > > Sent: Wednesday, January 08, 2003 1:14 PM > > Subject: Re: [PERFORM] postgresql in cluster of servers > > > > > On Wed, 2003-01-08 at 11:18, enediel wrote: > > > > Hello to all list members: > > > > > > > > I'm looking for information about using postgresql in a cluster of > > servers > > > > where all real servers share a unique databases location outside them. > > > > > > > > The question could be one of the follows? > > > > > > > > ?Is the prostgresql prepared to synchronize simultaneous accesses to > > oneself > > > > database among processes that run in different PC's? > > > > > > > > or > > > > > > > > ?Was the postgresql database designed to allow simultaneous acceses of > > > > processes that run in different PC's allowing for own design the > > > > sincronizationof all the processes? > > > > > > To clarify: do you mean > > > > > > (1) multiple copies of *the*same*database* sitting on many machines, > > > and all of them synchronizing themselves? > > > > > > OR > > > > > > (2) multiple application server machines all hitting a single database > > > sitting on a single database server machine? > > > > > > -- > > > +------------------------------------------------------------+ > > > | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | > > > | Jefferson, LA USA http://members.cox.net/ron.l.johnson | > > > | | > > > | "Basically, I got on the plane with a bomb. Basically, I | > > > | tried to ignite it. Basically, yeah, I intended to damage | > > > | the plane." | > > > | RICHARD REID, who tried to blow up American Airlines | > > > | Flight 63 | > > > +------------------------------------------------------------+ > > > > > > > > > ---------------------------(end of broadcast)--------------------------- > > > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > From pgsql-performance-owner@postgresql.org Thu Jan 9 16:33:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4D0E4475E18 for ; Thu, 9 Jan 2003 16:33:38 -0500 (EST) Received: from com.ith.tur.cu (com.ith.tur.cu [212.44.111.34]) by postgresql.org (Postfix) with ESMTP id 1C40E475CB4 for ; Thu, 9 Jan 2003 16:33:35 -0500 (EST) Received: from nsoft by com.ith.tur.cu with SMTP (MDaemon.PRO.v6.0.7.R) for ; Thu, 09 Jan 2003 16:35:14 -0500 Message-ID: <00d701c2b840$1dbedaa0$8a24a8c0@nsoft> Reply-To: "enediel" From: "enediel" To: "postgresql" Subject: Fw: Fw: Fw: postgresql in cluster of servers Date: Thu, 9 Jan 2003 16:35:01 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Return-Path: enediel@com.ith.tur.cu X-MDaemon-Deliver-To: pgsql-performance@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/70 X-Sequence-Number: 717 Thanks for the answer scott.marlowe I'm agree with you about the limit of the I/O operations with this configuration. I'm just looking for a fault tolerance configuration in the databases server, considering a very large databases, and a lot of users accesing to them. I'll accept with pleasure any suggestions about this topic. Greetings Enediel Linux user 300141 Happy who can penetrate the secret causes of the things �Use Linux! From pgsql-performance-owner@postgresql.org Sat Jan 11 13:53:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C4DEB475E84 for ; Sat, 11 Jan 2003 13:53:50 -0500 (EST) Received: from pd2mo3so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by postgresql.org (Postfix) with ESMTP id 357AB475BA0 for ; Sat, 11 Jan 2003 13:53:50 -0500 (EST) Received: from pd5mr4so.prod.shaw.ca (pd5mr4so-qfe3.prod.shaw.ca [10.0.141.168]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0H8K00LQRCHQP9@l-daemon> for pgsql-performance@postgresql.org; Sat, 11 Jan 2003 11:53:50 -0700 (MST) Received: from pn2ml5so.prod.shaw.ca (pn2ml5so-qfe0.prod.shaw.ca [10.0.121.149]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0H8K0065MCHQ78@l-daemon> for pgsql-performance@postgresql.org; Sat, 11 Jan 2003 11:53:50 -0700 (MST) Received: from kimiko (h24-78-132-76.vc.shawcable.net [24.78.132.76]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with SMTP id <0H8K006JTCHPEX@l-daemon> for pgsql-performance@postgresql.org; Sat, 11 Jan 2003 11:53:50 -0700 (MST) Date: Sat, 11 Jan 2003 10:51:44 -0800 From: Vernon Wu Subject: "IN" or "=" and "OR" To: pgsql-performance@postgresql.org Reply-To: vernonw@gatewaytech.com Message-id: MIME-version: 1.0 X-Mailer: Opera 6.05 build 1140 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT X-Priority: 3 (Normal) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/71 X-Sequence-Number: 718 Which query statement is better in terms of preformance ? select ... from table1 where field1 in ('a', 'b', 'c') select ... from table1 where field1='a' or field1='b' or field1='c' Thanks. From pgsql-performance-owner@postgresql.org Sat Jan 11 20:03:28 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B22AE475B47 for ; Sat, 11 Jan 2003 20:03:26 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 15D5D47592C for ; Sat, 11 Jan 2003 20:03:26 -0500 (EST) Received: from DU150.N224.ResNet.QueensU.CA (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 1FDED1D5D; Sat, 11 Jan 2003 20:03:28 -0500 (EST) Subject: Re: join over 12 tables takes 3 secs to plan From: Neil Conway To: "Charles H. Woloszynski" Cc: Hilmar Lapp , Jeff , "pgsql-performance@postgresql.org" In-Reply-To: <3E160BC0.3020900@clearmetrix.com> References: <3E160BC0.3020900@clearmetrix.com> Content-Type: text/plain Organization: Message-Id: <1042333405.386.49.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 11 Jan 2003 20:03:25 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/72 X-Sequence-Number: 719 On Fri, 2003-01-03 at 17:16, Charles H. Woloszynski wrote: > I think the functionality is starting to become real, but it looks like > it is starting with some limitations that might restricts its use from > be maximally realized until 7.4 (or beyond). Specifically, which limitations in this feature would you like to see corrected? Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-performance-owner@postgresql.org Sat Jan 11 23:10:53 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A155447627F for ; Sat, 11 Jan 2003 23:10:52 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id EEBE14761E9 for ; Sat, 11 Jan 2003 23:10:51 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0C4As5u025122; Sat, 11 Jan 2003 23:10:54 -0500 (EST) To: vernonw@gatewaytech.com Cc: pgsql-performance@postgresql.org Subject: Re: "IN" or "=" and "OR" In-reply-to: References: Comments: In-reply-to Vernon Wu message dated "Sat, 11 Jan 2003 10:51:44 -0800" Date: Sat, 11 Jan 2003 23:10:53 -0500 Message-ID: <25121.1042344653@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/73 X-Sequence-Number: 720 Vernon Wu writes: > Which query statement is better in terms of preformance ? > select ... from table1 where field1 in ('a', 'b', 'c') > select ... from table1 where field1='a' or field1='b' or field1='c' There is no difference, other than the microseconds the parser spends transforming form 1 into form 2 ... regards, tom lane From pgsql-performance-owner@postgresql.org Sun Jan 12 10:52:25 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 19846475E26 for ; Sun, 12 Jan 2003 10:52:23 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id F0633475D00 for ; Sun, 12 Jan 2003 10:52:22 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id h0CFqOM26295; Sun, 12 Jan 2003 10:52:24 -0500 Message-ID: <3E218F2B.8030107@clearmetrix.com> Date: Sun, 12 Jan 2003 10:52:11 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Neil Conway Cc: Hilmar Lapp , Jeff , "pgsql-performance@postgresql.org" Subject: Re: join over 12 tables takes 3 secs to plan References: <3E160BC0.3020900@clearmetrix.com> <1042333405.386.49.camel@tokyo> In-Reply-To: <1042333405.386.49.camel@tokyo> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/74 X-Sequence-Number: 721 Neil: I think that general use of this feature should be enabled using the URL, not with an API call. We use a JDBC connection pool and it will help tremendously to have the pool set to user server-side preparing without having to downcast the connection to a PG connection (which I think is an issue because of the facade in our connection pool code). The second item is that of compatibility. If the new code cannot handle all statements (eg. something with a semi in it) and disable the generation of a 'prepare' then we cannot count on the URL functionality. As I understand it, the programmer is required currently to enable/disable the server-side functionality by hand and only when the statement to be prepared is not composite (statement1; statement2; statement2). But in our real-world application space, we use a connection pool with a facade, so getting to the actual connection to enable this is problematic (and forces postgresql-specific coding into our framework where it is not particularly welcome). If we overcame this issue, we would then need to hand-manage the enable/disable to only be used when the statement is appropriately formulated (e.g., no semicolons in the statement). If we could get URL enabling and auto-detection of statements that won't work (and hence disable the enabled function for these functions), I think we have a solution that can be deployed into 'generic' app server environments with just configuration changes. That is, an operations person could enable this feature and monitor its impact on performance to see if/how it helps. That is a BIG win (at least to me) and a HUGE marketing item. I'd love to test MySQL with some joins over JDBC with PostgreSQL with some joins using prepared statements and be able to demonstrate the big improvement that this makes. As I understand it, the functions I am waiting for are targeted into 7.4 (but I'd love to see them early and do some testing of those for the community). Charlie Neil Conway wrote: >On Fri, 2003-01-03 at 17:16, Charles H. Woloszynski wrote: > > >>I think the functionality is starting to become real, but it looks like >>it is starting with some limitations that might restricts its use from >>be maximally realized until 7.4 (or beyond). >> >> > >Specifically, which limitations in this feature would you like to see >corrected? > >Cheers, > >Neil > > -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com From pgsql-jdbc-owner@postgresql.org Mon Jan 13 08:08:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 226E0476AF2 for ; Mon, 13 Jan 2003 08:08:16 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id 1880E476AA2 for ; Mon, 13 Jan 2003 08:08:15 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id h0DD8DM29519; Mon, 13 Jan 2003 08:08:13 -0500 Message-ID: <3E22BA32.3030905@clearmetrix.com> Date: Mon, 13 Jan 2003 08:08:02 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Neil Conway Subject: Re: [PERFORM] join over 12 tables takes 3 secs to plan References: <3E160BC0.3020900@clearmetrix.com> <1042333405.386.49.camel@tokyo> <3E218F2B.8030107@clearmetrix.com> <1042399760.362.26.camel@tokyo> In-Reply-To: <1042399760.362.26.camel@tokyo> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/144 X-Sequence-Number: 5994 Neil: Thanks for the feedback. I've attached my original text to this note and re-posted it back to pgsql-jdbc to make sure that they are aware of them. I look forward to this new and improved server-side preparation. Charlie Neil Conway wrote: >On Sun, 2003-01-12 at 10:52, Charles H. Woloszynski wrote: > > >>As I understand it, the functions I am waiting for are targeted into 7.4 >>(but I'd love to see them early and do some testing of those for the >>community). >> >> > >Ok -- those are pretty much all features on the JDBC side of things (not >the backend implementation of PREPARE/EXECUTE). I'm not sure how much of >that is planned for 7.4: if you haven't talked to the JDBC guys about >it, they may not be aware of your comments. > >Cheers, > >Neil > > Charles H. Woloszynski wrote: > Neil: > > I think that general use of this feature should be enabled using the > URL, not with an API call. We use a JDBC connection pool and it will > help tremendously to have the pool set to user server-side preparing > without having to downcast the connection to a PG connection (which I > think is an issue because of the facade in our connection pool code). > The second item is that of compatibility. If the new code cannot > handle all statements (eg. something with a semi in it) and disable > the generation of a 'prepare' then we cannot count on the URL > functionality. As I understand it, the programmer is required > currently to enable/disable the server-side functionality by hand and > only when the statement to be prepared is not composite (statement1; > statement2; statement2). > > But in our real-world application space, we use a connection pool with > a facade, so getting to the actual connection to enable this is > problematic (and forces postgresql-specific coding into our framework > where it is not particularly welcome). If we overcame this issue, we > would then need to hand-manage the enable/disable to only be used when > the statement is appropriately formulated (e.g., no semicolons in the > statement). > > If we could get URL enabling and auto-detection of statements that > won't work (and hence disable the enabled function for these > functions), I think we have a solution that can be deployed into > 'generic' app server environments with just configuration changes. > That is, an operations person could enable this feature and monitor > its impact on performance to see if/how it helps. That is a BIG win > (at least to me) and a HUGE marketing item. I'd love to test MySQL > with some joins over JDBC with PostgreSQL with some joins using > prepared statements and be able to demonstrate the big improvement > that this makes. > > As I understand it, the functions I am waiting for are targeted into > 7.4 (but I'd love to see them early and do some testing of those for > the community). -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com From pgsql-performance-owner@postgresql.org Mon Jan 13 13:38:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E83AC476C2C for ; Mon, 13 Jan 2003 13:38:51 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 5BB8C476B4D for ; Mon, 13 Jan 2003 13:38:51 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2312235 for pgsql-performance@postgresql.org; Mon, 13 Jan 2003 10:38:55 -0800 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Accessing ANALYZE stats Date: Mon, 13 Jan 2003 10:42:01 -0800 X-Mailer: KMail [version 1.4] MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301131042.01831.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/75 X-Sequence-Number: 722 Folks, Can someone give me a quick pointer on where the ANALYZE stats are kept in= =20 7.2.3? Thanks. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Jan 14 13:42:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EEF05475EE4 for ; Tue, 14 Jan 2003 13:42:52 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 5A4D9475E10 for ; Tue, 14 Jan 2003 13:42:52 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2313566; Tue, 14 Jan 2003 10:42:54 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tomasz Myrta , PgSQL Performance ML Subject: Re: complicated queries in pl/pgsql Date: Mon, 13 Jan 2003 10:44:50 -0800 X-Mailer: KMail [version 1.4] References: <3E23EC83.9060802@klaster.net> In-Reply-To: <3E23EC83.9060802@klaster.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301131044.50424.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/104 X-Sequence-Number: 751 Tomasz, > What happens to view planning - is it performed=20 > during view creation, or rather each time view is quered? Each time the view is executed. The only savings in running a view over a= =20 regular query is that the view will have taken care of some reference=20 expansion and JOIN explication during the CREATE process, but not planning.= =20=20 Also, views can actually be slower if the view is complex enough that any= =20 query-time parameters cannot be "pushed down" into the view. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Jan 13 13:47:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E5FFC477017 for ; Mon, 13 Jan 2003 13:47:06 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id B800C476F4C for ; Mon, 13 Jan 2003 13:46:10 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 94969D605; Mon, 13 Jan 2003 10:46:10 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 8A16C5C02; Mon, 13 Jan 2003 10:46:10 -0800 (PST) Date: Mon, 13 Jan 2003 10:46:10 -0800 (PST) From: Stephan Szabo To: Josh Berkus Cc: Subject: Re: Accessing ANALYZE stats In-Reply-To: <200301131042.01831.josh@agliodbs.com> Message-ID: <20030113104527.J58199-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/76 X-Sequence-Number: 723 On Mon, 13 Jan 2003, Josh Berkus wrote: > Can someone give me a quick pointer on where the ANALYZE stats are kept in > 7.2.3? Thanks. Should be in pg_stats I believe. From pgsql-performance-owner@postgresql.org Mon Jan 13 16:33:19 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D52D4476CD5 for ; Mon, 13 Jan 2003 16:33:16 -0500 (EST) Received: from o2.hostbaby.com (o2.hostbaby.com [208.187.29.121]) by postgresql.org (Postfix) with SMTP id 3165E476B4D for ; Mon, 13 Jan 2003 16:33:16 -0500 (EST) Received: (qmail 32631 invoked from network); 13 Jan 2003 21:33:19 -0000 Received: from unknown (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 13 Jan 2003 21:33:19 -0000 Received: from 216.80.95.13 (Hostbaby Webmail authenticated user typea@l-i-e.com) by www.l-i-e.com with HTTP; Mon, 13 Jan 2003 13:33:19 -0800 (PST) Message-ID: <49456.216.80.95.13.1042493599.squirrel@www.l-i-e.com> Date: Mon, 13 Jan 2003 13:33:19 -0800 (PST) Subject: Cursor rowcount From: To: X-Priority: 3 Importance: Normal X-Mailer: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/77 X-Sequence-Number: 724 Short Version: I've read the idocs and Notes and Googled a fair amount, honest. :-) What's the most efficient way of determining the number of rows in a cursor's result set if you really *DO* need that? (Or, rather, if your client specifically asked for features that require that.) Long Version: I'm not finding any way in the docs of asking a cursor how many rows total are in the result set, even if I do "move 1000000 in foo", knowing a priori that 1000000 is far more than could be returned. Oracle docs seem to have a SQL.%ROWCOUNT which gives the answer, provided one has moved beyond the last row... If I'm reading the Oracle docs right... Anyway. I could find nothing similar in PostgreSQL, even though it seems reasonable, even for a Portal, provided one is willing to do the "move X" for X sufficiently high -- And, in fact, psql outputs the precise number of rows when I do that in the psql monitor, so at some level PostgreSQL "knows" the answer I want, but I can't get that "MOVE XX" output into PHP, as far as I can tell. (Can I?) I suppose I could, in theory, use PHP to fire up psql, but that's not exactly going to be efficient, much less pleasant. :-) Using PHP, if it matters. I guess it does since maybe other APIs have some way to access that number I want -- psql sure seems to print it out when one goes over the edge. Given that the count(*) queries take just as long as the actual data-retrieval queries, and that some of my queries take too long as it is (like, a minute for a 4-term full text search)... I've written and am about to benchmark a binary search using a bunch of "move X" "fetch 1" "move backward 1" "move backward X" and then using Ye Olde Low/High guessing game algorithm to find the number of rows, but I'm hoping for something better from the optimization experts. Sorry this got a bit long, but I wanted to be clear about where I've been and gone, rather than leave you guessing. :-) Hope I didn't miss some obvious solution/documentation "out there"... From pgsql-performance-owner@postgresql.org Mon Jan 13 17:23:19 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AC8DA477192 for ; Mon, 13 Jan 2003 17:23:18 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 07E764770D4 for ; Mon, 13 Jan 2003 17:22:10 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0DMMA5u006430; Mon, 13 Jan 2003 17:22:10 -0500 (EST) To: typea@l-i-e.com Cc: pgsql-performance@postgresql.org Subject: Re: Cursor rowcount In-reply-to: <49456.216.80.95.13.1042493599.squirrel@www.l-i-e.com> References: <49456.216.80.95.13.1042493599.squirrel@www.l-i-e.com> Comments: In-reply-to message dated "Mon, 13 Jan 2003 13:33:19 -0800" Date: Mon, 13 Jan 2003 17:22:10 -0500 Message-ID: <6429.1042496530@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/78 X-Sequence-Number: 725 writes: > I'm not finding any way in the docs of asking a cursor how many rows total > are in the result set, even if I do "move 1000000 in foo", knowing a > priori that 1000000 is far more than could be returned. regression=# begin; BEGIN regression=# declare c cursor for select * from int8_tbl; DECLARE CURSOR regression=# move all in c; MOVE 5 <----------------------- regression=# end; COMMIT regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jan 14 17:30:53 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6EF86475D22 for ; Tue, 14 Jan 2003 17:30:52 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id CFE7E475B8F for ; Tue, 14 Jan 2003 17:30:51 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2313944; Tue, 14 Jan 2003 14:30:50 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Noah Silverman , Rod Taylor Subject: Re: Multiple databases Date: Mon, 13 Jan 2003 14:32:47 -0800 X-Mailer: KMail [version 1.4] Cc: Pgsql Performance References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301131432.47468.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/112 X-Sequence-Number: 759 Noah, > Can someone give me a good description of what the various directories=20 > and files actually are. I have RTFMed, but the descriptions there=20 > don't seem to match what I have on my machine. Within $PGDATA: /base is all database files unless you use WITH LOCATION /pg_clog is the Clog, which keeps a permanent count of transactions /pg_xlog is the transaction log (WAL) /global are a small number of relations, like pg_database or pg_user, which= =20 are available in all databases. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Jan 13 20:05:45 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D89D2475E9D for ; Mon, 13 Jan 2003 20:05:44 -0500 (EST) Received: from o2.hostbaby.com (o2.hostbaby.com [208.187.29.121]) by postgresql.org (Postfix) with SMTP id 0C11D475D3B for ; Mon, 13 Jan 2003 20:05:44 -0500 (EST) Received: (qmail 23419 invoked from network); 14 Jan 2003 01:05:50 -0000 Received: from unknown (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 14 Jan 2003 01:05:50 -0000 Received: from 216.80.95.13 (Hostbaby Webmail authenticated user typea@l-i-e.com) by www.l-i-e.com with HTTP; Mon, 13 Jan 2003 17:05:50 -0800 (PST) Message-ID: <50156.216.80.95.13.1042506350.squirrel@www.l-i-e.com> Date: Mon, 13 Jan 2003 17:05:50 -0800 (PST) Subject: Re: Cursor rowcount From: To: In-Reply-To: <6429.1042496530@sss.pgh.pa.us> References: <49456.216.80.95.13.1042493599.squirrel@www.l-i-e.com> <6429.1042496530@sss.pgh.pa.us> X-Priority: 3 Importance: Normal X-Mailer: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/79 X-Sequence-Number: 726 > writes: >> I'm not finding any way in the docs of asking a cursor how many rows >> total are in the result set, even if I do "move 1000000 in foo", >> knowing a priori that 1000000 is far more than could be returned. > > regression=# begin; > BEGIN > regression=# declare c cursor for select * from int8_tbl; > DECLARE CURSOR > regression=# move all in c; > MOVE 5 <----------------------- > regression=# end; > COMMIT > > regards, tom lane Yes, but as noted in my longer version, that number does not seem to "come through" the PHP API. I've tried calling just about every function I can in the PHP API in a test script, and none of them give me that number. At least, none that I can find... From pgsql-performance-owner@postgresql.org Mon Jan 13 23:20:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9726E4771E3 for ; Mon, 13 Jan 2003 23:20:56 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 2CFCF47722D for ; Mon, 13 Jan 2003 23:19:37 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0E4Je5u012896; Mon, 13 Jan 2003 23:19:41 -0500 (EST) To: typea@l-i-e.com Cc: pgsql-performance@postgresql.org Subject: Re: Cursor rowcount In-reply-to: <50156.216.80.95.13.1042506350.squirrel@www.l-i-e.com> References: <49456.216.80.95.13.1042493599.squirrel@www.l-i-e.com> <6429.1042496530@sss.pgh.pa.us> <50156.216.80.95.13.1042506350.squirrel@www.l-i-e.com> Comments: In-reply-to message dated "Mon, 13 Jan 2003 17:05:50 -0800" Date: Mon, 13 Jan 2003 23:19:40 -0500 Message-ID: <12895.1042517980@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/80 X-Sequence-Number: 727 writes: > Yes, but as noted in my longer version, that number does not seem to "come > through" the PHP API. Perhaps not, but you'd have to ask the PHP folk about it. This question surely doesn't belong on pgsql-performance ... regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jan 14 04:12:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C54B5475AE6 for ; Tue, 14 Jan 2003 04:12:36 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 0E65947580B for ; Tue, 14 Jan 2003 04:12:36 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030114091237.MGAF26808.lakemtao03.cox.net@[192.168.1.1]> for ; Tue, 14 Jan 2003 04:12:37 -0500 Subject: Re: Cursor rowcount From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <12895.1042517980@sss.pgh.pa.us> References: <49456.216.80.95.13.1042493599.squirrel@www.l-i-e.com> <6429.1042496530@sss.pgh.pa.us> <50156.216.80.95.13.1042506350.squirrel@www.l-i-e.com> <12895.1042517980@sss.pgh.pa.us> Content-Type: text/plain Organization: Message-Id: <1042535548.27702.31.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 14 Jan 2003 03:12:28 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/81 X-Sequence-Number: 728 On Mon, 2003-01-13 at 22:19, Tom Lane wrote: > writes: > > Yes, but as noted in my longer version, that number does not seem to "come > > through" the PHP API. > > Perhaps not, but you'd have to ask the PHP folk about it. This question > surely doesn't belong on pgsql-performance ... Wellllll, maybe it does, since the /performance/ of a SELECT COUNT(*) followed by a cursor certainly is lower than getting the count from a system variable. But still I agree, the PHP list seems more appropriate... -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Tue Jan 14 05:50:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 30F6C475EE2 for ; Tue, 14 Jan 2003 05:50:54 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 625A6475DBC for ; Tue, 14 Jan 2003 05:50:53 -0500 (EST) Received: from klaster.net (pc43.krakow.cvx.ppp.tpnet.pl [213.76.38.43]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 3A0062B267 for ; Tue, 14 Jan 2003 11:48:02 +0100 (CET) Message-ID: <3E23EC83.9060802@klaster.net> Date: Tue, 14 Jan 2003 11:54:59 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: PgSQL Performance ML Subject: complicated queries in pl/pgsql Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/82 X-Sequence-Number: 729 Hi Sometimes my pl/pgsql functions have pretty complicated queries inside - most of their execution time takes postgresql query planning. I was wondering if I should change these queries into views? Does it speed up function execution? Pl/pgsql saves execution plan for connection lifetime. What happens to view planning - is it performed during view creation, or rather each time view is quered? Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Tue Jan 14 10:00:07 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8035C47618A for ; Tue, 14 Jan 2003 10:00:05 -0500 (EST) Received: from web21103.mail.yahoo.com (web21103.mail.yahoo.com [216.136.227.105]) by postgresql.org (Postfix) with SMTP id C80EC4760D4 for ; Tue, 14 Jan 2003 10:00:04 -0500 (EST) Message-ID: <20030114150008.49425.qmail@web21103.mail.yahoo.com> Received: from [131.142.161.245] by web21103.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 07:00:08 PST Date: Tue, 14 Jan 2003 07:00:08 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Sun vs. Mac To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/83 X-Sequence-Number: 730 Hello, I'm having some serious performance issues with PostgreSQL on our newish SunFire 280R (1 900MHz ultrasparc III, 1 GB RAM). It's painfully slow. It took me almost a week of tuning to get it in the range of an old Mac G3 laptop. Now, a few days later, after tweaking every nearly every parameter (only noting decreased performance on some) in /etc/system and $PGDATA/postgresql.conf it's about as fast as I can make it, but still horribly slow. A few simple queries that take 1.5-7 minutes on the G3 take 1-1.5 minutes on the Sun. A bulk load of roughly 2.4 GB database dump takes ~1 hour on each machine. It took almost 2 hours on the Sun before I turned off fsync. We have plans to add another CPU, RAM and another disk, which should all help, but in its current state, I (and many others) would think that it should run circles around the G3. I'm thinking that I'm missing something big and obvious because this can't be right. Otherwise we might as well just get a bunch of ibooks to run our databases - they're a lot smaller and much more quiet. Can someone please point me in the right direction? Thanks, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 10:06:19 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BC1DF475E64 for ; Tue, 14 Jan 2003 10:06:17 -0500 (EST) Received: from new-smtp2.ihug.com.au (new-smtp2.ihug.com.au [203.109.250.28]) by postgresql.org (Postfix) with ESMTP id 1D69447580B for ; Tue, 14 Jan 2003 10:06:17 -0500 (EST) Received: from p96-tnt1.adl.ihug.com.au (postgresql.org) [203.173.248.96] by new-smtp2.ihug.com.au with esmtp (Exim 3.22 #1 (Debian)) id 18YSdv-0002Ef-00; Wed, 15 Jan 2003 02:06:20 +1100 Message-ID: <3E242826.8020306@postgresql.org> Date: Wed, 15 Jan 2003 01:39:26 +1030 From: Justin Clift User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: captainx0r@yahoo.com Cc: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac References: <20030114150008.49425.qmail@web21103.mail.yahoo.com> In-Reply-To: <20030114150008.49425.qmail@web21103.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/84 X-Sequence-Number: 731 Hi CaptainXOr, Which version of PostgreSQL, and which release of Solaris are you running? Regards and best wishes, Justin Clift CaptainX0r wrote: > Hello, > > I'm having some serious performance issues with PostgreSQL on > our newish SunFire 280R (1 900MHz ultrasparc III, 1 GB RAM). > It's painfully slow. It took me almost a week of tuning to get > it in the range of an old Mac G3 laptop. Now, a few days later, > after tweaking every nearly every parameter (only noting > decreased performance on some) in /etc/system and > $PGDATA/postgresql.conf it's about as fast as I can make it, but > still horribly slow. A few simple queries that take 1.5-7 > minutes on the G3 take 1-1.5 minutes on the Sun. A bulk load of > roughly 2.4 GB database dump takes ~1 hour on each machine. It > took almost 2 hours on the Sun before I turned off fsync. > > We have plans to add another CPU, RAM and another disk, which > should all help, but in its current state, I (and many others) > would think that it should run circles around the G3. I'm > thinking that I'm missing something big and obvious because this > can't be right. Otherwise we might as well just get a bunch of > ibooks to run our databases - they're a lot smaller and much > more quiet. > > Can someone please point me in the right direction? > > Thanks, > > -X > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi From pgsql-performance-owner@postgresql.org Tue Jan 14 10:18:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 40EA4476212 for ; Tue, 14 Jan 2003 10:18:55 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id AB8B547721B for ; Tue, 14 Jan 2003 10:10:50 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18YSiM-0002Kv-00 for ; Tue, 14 Jan 2003 10:10:54 -0500 Date: Tue, 14 Jan 2003 10:10:54 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac Message-ID: <20030114101054.B5335@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20030114150008.49425.qmail@web21103.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030114150008.49425.qmail@web21103.mail.yahoo.com>; from captainx0r@yahoo.com on Tue, Jan 14, 2003 at 07:00:08AM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/85 X-Sequence-Number: 732 On Tue, Jan 14, 2003 at 07:00:08AM -0800, CaptainX0r wrote: > Hello, > > I'm having some serious performance issues with PostgreSQL on > our newish SunFire 280R (1 900MHz ultrasparc III, 1 GB RAM). > It's painfully slow. It took me almost a week of tuning to get > it in the range of an old Mac G3 laptop. Now, a few days later, > after tweaking every nearly every parameter (only noting > decreased performance on some) in /etc/system and > $PGDATA/postgresql.conf it's about as fast as I can make it, but You should tell us about what version of Solaris you're running, what version of Postgres, and what options you have used. Did you split the WAL onto its own filesystem? You'll get a big win that way. Also, what fsync setting are you using (open_datasync is the fastest in my experience). Finally, the bottleneck on Solaris is both disk and process forking (fork() is notoriously slow on Solaris). Also, certain sort routines are abysmal. Replace the Solaris-provided qsort(). I have to say, however, that my experience indicates that Solaris is slower that the competition for Postgres. It still shouldn't be that bad. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Jan 14 10:43:44 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 016F74760CC for ; Tue, 14 Jan 2003 10:43:43 -0500 (EST) Received: from web21106.mail.yahoo.com (web21106.mail.yahoo.com [216.136.227.108]) by postgresql.org (Postfix) with SMTP id 2C1D4475FEC for ; Tue, 14 Jan 2003 10:18:19 -0500 (EST) Message-ID: <20030114151823.75801.qmail@web21106.mail.yahoo.com> Received: from [131.142.161.245] by web21106.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 07:18:23 PST Date: Tue, 14 Jan 2003 07:18:23 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: <3E242826.8020306@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/86 X-Sequence-Number: 733 Sorry - I meant to include that. I'm running PG 7.3.1 on Solaris 8. Thanks, -X --- Justin Clift wrote: > > Which version of PostgreSQL, and which release of Solaris are > you running? > > > > > I'm having some serious performance issues with PostgreSQL > on > > our newish SunFire 280R (1 900MHz ultrasparc III, 1 GB RAM). > > > It's painfully slow. It took me almost a week of tuning to > get > > it in the range of an old Mac G3 laptop. Now, a few days > later, > > after tweaking every nearly every parameter (only noting > > decreased performance on some) in /etc/system and > > $PGDATA/postgresql.conf it's about as fast as I can make it, > but > > still horribly slow. A few simple queries that take 1.5-7 > > minutes on the G3 take 1-1.5 minutes on the Sun. A bulk > load of > > roughly 2.4 GB database dump takes ~1 hour on each machine. > It > > took almost 2 hours on the Sun before I turned off fsync. > > > > We have plans to add another CPU, RAM and another disk, > which > > should all help, but in its current state, I (and many > others) > > would think that it should run circles around the G3. I'm > > thinking that I'm missing something big and obvious because > this > > can't be right. Otherwise we might as well just get a bunch > of > > ibooks to run our databases - they're a lot smaller and much > > more quiet. > > > > Can someone please point me in the right direction? > > > > Thanks, > > > > -X > > __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 10:47:03 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A88A94761B5 for ; Tue, 14 Jan 2003 10:47:02 -0500 (EST) Received: from web21103.mail.yahoo.com (web21103.mail.yahoo.com [216.136.227.105]) by postgresql.org (Postfix) with SMTP id 873C8475ADD for ; Tue, 14 Jan 2003 10:41:17 -0500 (EST) Message-ID: <20030114154121.53714.qmail@web21103.mail.yahoo.com> Received: from [131.142.161.245] by web21103.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 07:41:21 PST Date: Tue, 14 Jan 2003 07:41:21 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: <20030114101054.B5335@mail.libertyrms.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/87 X-Sequence-Number: 734 All, > You should tell us about what version of Solaris you're > running, what > version of Postgres, and what options you have used. You're right, sorry. PG 7.3.1 on Solaris 8. I've got the default recommended /etc/system but with shmmax cranked way up which seems to have helped. I don't have the system in front of me (and it's down, so I can't get to it), but from memory max_connections was increased to 64, shared_buffers up to 65536, sort_mem and vacuum_mem were doubled, and I think that's it. I changed every seemingly relevant one, and spent a lot of time on the *cost section trying various factors of n*10 on each, with no joy. > Did you split > the WAL onto its own filesystem? You'll get a big win that > way. I have not. What exactly do you by "own filesystem"? Another filesystem? I was planning on putting pg_xlog on the OS disk and moving $PGDATA off to a second disk. > Also, what fsync setting are you using (open_datasync is the > fastest in my experience). I've read that somewhere (maybe in the archives?) and I got no change with any of them. But now I'm thinking back - do I need fsync=true for that to have an affect? I'm not worried about the cons of having fsync=false at all - and I'm assuming that should be better than true and open_datasync. Or am I confusing things? > Also, certain sort routines are abysmal. Replace the > Solaris-provided qsort(). I've read about this as well - but haven't even gotten that far on the testing/configuring yet. > I have to say, however, that my experience indicates that > Solaris is > slower that the competition for Postgres. It still shouldn't > be that bad. I agree completely. Thanks for your input, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 11:09:32 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 29306476435 for ; Tue, 14 Jan 2003 11:09:31 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6B25F4762EE for ; Tue, 14 Jan 2003 11:04:48 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0EG4r5u016238; Tue, 14 Jan 2003 11:04:53 -0500 (EST) To: captainx0r@yahoo.com Cc: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac In-reply-to: <20030114154121.53714.qmail@web21103.mail.yahoo.com> References: <20030114154121.53714.qmail@web21103.mail.yahoo.com> Comments: In-reply-to CaptainX0r message dated "Tue, 14 Jan 2003 07:41:21 -0800" Date: Tue, 14 Jan 2003 11:04:52 -0500 Message-ID: <16237.1042560292@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/88 X-Sequence-Number: 735 CaptainX0r writes: > I've read that somewhere (maybe in the archives?) and I got no > change with any of them. But now I'm thinking back - do I need > fsync=true for that to have an affect? I'm not worried about > the cons of having fsync=false at all - and I'm assuming that > should be better than true and open_datasync. You are right that fsync_method is a no-op if you've got fsync turned off. Let me get this straight: the Sun is slower even with fsync off? That shoots down the first theory that I had, which was that the Sun's disk drives were actually honoring fsync while the laptop's drive does not. (See archives for more discussion of that, but briefly: IDE drives are commonly set up to claim write complete as soon as they've absorbed data into their onboard buffers. SCSI drives usually tell the truth about when they've completed a write.) Andrew Sullivan's nearby recommendation to replace qsort() is a good one, but PG 7.3 is already configured to do that by default. (Look in src/Makefile.global to confirm that qsort.o is mentioned in LIBOBJS.) I'd suggest starting with some elementary measurements, for example looking at I/O rates and CPU idle percentage while running the same task on both Solaris and G3. That would at least give us a clue whether I/O or CPU is the bottleneck. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jan 14 11:11:12 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B086A4767D9 for ; Tue, 14 Jan 2003 11:11:11 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 4761F47608D for ; Tue, 14 Jan 2003 11:08:47 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18YTcS-0003QL-00 for ; Tue, 14 Jan 2003 11:08:52 -0500 Date: Tue, 14 Jan 2003 11:08:52 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac Message-ID: <20030114110852.E5335@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20030114101054.B5335@mail.libertyrms.com> <20030114154121.53714.qmail@web21103.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030114154121.53714.qmail@web21103.mail.yahoo.com>; from captainx0r@yahoo.com on Tue, Jan 14, 2003 at 07:41:21AM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/89 X-Sequence-Number: 736 On Tue, Jan 14, 2003 at 07:41:21AM -0800, CaptainX0r wrote: > > You're right, sorry. PG 7.3.1 on Solaris 8. I've got the > default recommended /etc/system but with shmmax cranked way up Ok, I have no experience with 7.3.1 in a production setting - we're using 7.2. But here are some things. > which seems to have helped. I don't have the system in front of > me (and it's down, so I can't get to it), but from memory > max_connections was increased to 64, shared_buffers up to 65536, > sort_mem and vacuum_mem were doubled, and I think that's it. I > changed every seemingly relevant one, and spent a lot of time on You'll need to increase the number of available semaphores more than likely, if you add any connections. You do indeed need to fix shmmax, but if the postmaster starts, you're fine. I would worry slightly about sort_mem. I have managed to make Solaris boxes with _lots_ of memory start swapping by setting that too high (while experimenting). Look for problems in your I/O. > the *cost section trying various factors of n*10 on each, with > no joy. These are fine-tuning knobs. You have a different problem :) > > Did you split > > the WAL onto its own filesystem? You'll get a big win that > > way. > > I have not. What exactly do you by "own filesystem"? Another > filesystem? I was planning on putting pg_xlog on the OS disk > and moving $PGDATA off to a second disk. That's what you need. Without any doubt at all. The xlog on the same UFS filesystem (and disk) as the rest of $PGDATA is a nightmare. Interestingly, by the way, there is practically _no difference_ if you do this with an A5200 managed by Veritas. I have tried dozens of things. It never matters. The array is too fast. > > Also, what fsync setting are you using (open_datasync is the > > fastest in my experience). > > I've read that somewhere (maybe in the archives?) and I got no > change with any of them. But now I'm thinking back - do I need > fsync=true for that to have an affect? I'm not worried about > the cons of having fsync=false at all - and I'm assuming that > should be better than true and open_datasync. Or am I confusing > things? Yes, if you change the fsync method but have fsync turned off, it will make no difference. > > Also, certain sort routines are abysmal. Replace the > > Solaris-provided qsort(). > > I've read about this as well - but haven't even gotten that far > on the testing/configuring yet. If you're doing any sorting that is not by an index, forget about it. Change it now. It's something like a multiple of 40 slower. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Jan 14 11:20:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 726424760E2 for ; Tue, 14 Jan 2003 11:20:27 -0500 (EST) Received: from internet.csl.co.uk (internet.csl.co.uk [194.130.52.3]) by postgresql.org (Postfix) with ESMTP id 4DF084762C4 for ; Tue, 14 Jan 2003 11:18:56 -0500 (EST) Received: from euphrates.csl.co.uk (host-194-67.csl.co.uk [194.130.52.67]) by internet.csl.co.uk (8.12.6/8.12.6) with ESMTP id h0EGIvMi002242; Tue, 14 Jan 2003 16:18:57 GMT Received: from kelvin.csl.co.uk by euphrates.csl.co.uk (8.9.3/ConceptI 2.4) id QAA22033; Tue, 14 Jan 2003 16:18:59 GMT Received: by kelvin.csl.co.uk (8.11.6) id h0EGIvu04353; Tue, 14 Jan 2003 16:18:57 GMT From: Lee Kindness MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15908.14449.469992.977688@kelvin.csl.co.uk> Date: Tue, 14 Jan 2003 16:18:57 +0000 To: captainx0r@yahoo.com Cc: pgsql-performance@postgresql.org, Lee Kindness Subject: Sun vs. Mac In-Reply-To: <20030114150008.49425.qmail@web21103.mail.yahoo.com> References: <20030114150008.49425.qmail@web21103.mail.yahoo.com> X-Mailer: VM 7.00 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/90 X-Sequence-Number: 737 CaptainX0r writes: > I'm having some serious performance issues with PostgreSQL on > our newish SunFire 280R (1 900MHz ultrasparc III, 1 GB RAM). > It's painfully slow. What has PostgreSQL been compiled by? Personal past experience has shown the Sun Workshop C compiler to result in much better performance compared to GCC... L. From pgsql-performance-owner@postgresql.org Tue Jan 14 11:31:34 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DD85947640E for ; Tue, 14 Jan 2003 11:31:31 -0500 (EST) Received: from web21106.mail.yahoo.com (web21106.mail.yahoo.com [216.136.227.108]) by postgresql.org (Postfix) with SMTP id D708B47637C for ; Tue, 14 Jan 2003 11:29:52 -0500 (EST) Message-ID: <20030114162957.93069.qmail@web21106.mail.yahoo.com> Received: from [131.142.161.245] by web21106.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 08:29:57 PST Date: Tue, 14 Jan 2003 08:29:57 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: <15908.14449.469992.977688@kelvin.csl.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/91 X-Sequence-Number: 738 --- Lee Kindness wrote: > CaptainX0r writes: >> I'm having some serious performance issues with PostgreSQL on >> our newish SunFire 280R (1 900MHz ultrasparc III, 1 GB RAM). >> It's painfully slow. > > What has PostgreSQL been compiled by? Personal past experience > has > shown the Sun Workshop C compiler to result in much better > performance > compared to GCC... I used gcc - mostly because I have in the past, but also because I've read that it is "the one to use". Am I wrong on this one? I'm certainly willing to try the one from Sun Workshop. Thanks for the input, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 11:40:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7A8BD476B6F for ; Tue, 14 Jan 2003 11:40:53 -0500 (EST) Received: from web21107.mail.yahoo.com (web21107.mail.yahoo.com [216.136.227.109]) by postgresql.org (Postfix) with SMTP id 6B27347608D for ; Tue, 14 Jan 2003 11:38:20 -0500 (EST) Message-ID: <20030114163825.45392.qmail@web21107.mail.yahoo.com> Received: from [131.142.161.245] by web21107.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 08:38:25 PST Date: Tue, 14 Jan 2003 08:38:25 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: <20030114110852.E5335@mail.libertyrms.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/92 X-Sequence-Number: 739 > You'll need to increase the number of available semaphores > more than > likely, if you add any connections. You do indeed need to fix > shmmax, but if the postmaster starts, you're fine. Thanks, I'll take a closer look at this. > That's what you need. Without any doubt at all. The xlog on > the same UFS filesystem (and disk) as the rest of $PGDATA is a > nightmare. The disks are on order - but that can't be the only thing hold it up, can it? I've got to check out the IO, as you suggest. > > > Also, certain sort routines are abysmal. Replace the > > > Solaris-provided qsort(). > > > > I've read about this as well - but haven't even gotten that > > far on the testing/configuring yet. > > If you're doing any sorting that is not by an index, forget > about it. > Change it now. It's something like a multiple of 40 slower. I double checked, and this was one of the reasons I was glad to try 7.3 on Solaris - it's already got it built in. Thanks much for the input, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 11:58:51 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C47214764E6 for ; Tue, 14 Jan 2003 11:58:50 -0500 (EST) Received: from web21110.mail.yahoo.com (web21110.mail.yahoo.com [216.136.227.112]) by postgresql.org (Postfix) with SMTP id 3984D47656B for ; Tue, 14 Jan 2003 11:54:28 -0500 (EST) Message-ID: <20030114165433.63951.qmail@web21110.mail.yahoo.com> Received: from [131.142.161.245] by web21110.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 08:54:33 PST Date: Tue, 14 Jan 2003 08:54:33 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: <16237.1042560292@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/93 X-Sequence-Number: 740 All, > Let me get this straight: the Sun is slower even with fsync > off? That Correct. This really helped a lot, especially with the dump load, but I've clearly got some more work ahead of me. > Andrew Sullivan's nearby recommendation to replace qsort() is > a good > one, but PG 7.3 is already configured to do that by default. > (Look in > src/Makefile.global to confirm that qsort.o is mentioned in > LIBOBJS.) Thanks for confirming. I've got LIBOBJS = isinf.o qsort.o > I'd suggest starting with some elementary measurements, for > example looking at I/O rates and CPU idle percentage while > running the same task on both Solaris and G3. That would at > least give us a clue whether I/O or CPU is the bottleneck. Good thoughts - I'm working on it right now, though I'm not really sure how to check I/O rates.... Thanks much for the input, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 12:51:01 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6A5614767C1 for ; Tue, 14 Jan 2003 12:51:00 -0500 (EST) Received: from web21101.mail.yahoo.com (web21101.mail.yahoo.com [216.136.227.103]) by postgresql.org (Postfix) with SMTP id 4B8D84765D2 for ; Tue, 14 Jan 2003 12:49:59 -0500 (EST) Message-ID: <20030114175004.15074.qmail@web21101.mail.yahoo.com> Received: from [131.142.161.245] by web21101.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 09:50:04 PST Date: Tue, 14 Jan 2003 09:50:04 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: <16237.1042560292@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/95 X-Sequence-Number: 742 > I'd suggest starting with some elementary measurements, for > example looking at I/O rates and CPU idle percentage while > running the same task on both Solaris and G3. That would at > least give us a clue whether I/O or CPU is the bottleneck. Well, I've got the Sun box now, but I don't really have acces to the G3. FWIW, top shows postgres slowly taking up all the CPU - over the course of a minute or so it gradually ramps up to around 90%. Once the query is complete, however, top shows the CPU ramping down slowly, ~1-2% per second over the next 2 minutes which I find very strange. The CPU idle is 0% for the duration of the query, while the user state is around 100% for the same period. This kind of makes me think top is wrong (100% idle and 75% postgres?) iostat gives: (sorry for line wrap). # iostat -DcxnzP cpu us sy wt id 10 1 4 85 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 11.2 1.0 65.5 13.1 0.1 0.1 9.5 9.6 0 3 c1t0d0s0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 6.0 0 0 c1t0d0s1 7.3 0.1 502.3 0.5 0.0 0.0 0.0 2.3 0 1 c1t0d0s3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0 0 host:vold(pid313) This doesn't really tell me much, except I'm guessing that PG is CPU bound? -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 13:02:28 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CA79B4761AD for ; Tue, 14 Jan 2003 13:02:27 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 85FF4476B78 for ; Tue, 14 Jan 2003 12:58:42 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18YVKq-0005oX-00 for ; Tue, 14 Jan 2003 12:58:48 -0500 Date: Tue, 14 Jan 2003 12:58:48 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac Message-ID: <20030114125848.P5335@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <16237.1042560292@sss.pgh.pa.us> <20030114175004.15074.qmail@web21101.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030114175004.15074.qmail@web21101.mail.yahoo.com>; from captainx0r@yahoo.com on Tue, Jan 14, 2003 at 09:50:04AM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/96 X-Sequence-Number: 743 On Tue, Jan 14, 2003 at 09:50:04AM -0800, CaptainX0r wrote: > the G3. FWIW, top shows postgres slowly taking up all the CPU - Son't use top on Solaris 8. It's inaccurate, and it affects the results itself. Use prstat instead. > This doesn't really tell me much, except I'm guessing that PG is > CPU bound? It looks that way. I've had iostat show CPU-bound, however, when the problem actually turned out to be memory contention. I think you may want to have a poke with vmstat, and also have a look at the SE toolkit. A ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Jan 14 13:11:34 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 01D90476920 for ; Tue, 14 Jan 2003 13:11:33 -0500 (EST) Received: from web21109.mail.yahoo.com (web21109.mail.yahoo.com [216.136.227.111]) by postgresql.org (Postfix) with SMTP id 4A7DA4760AB for ; Tue, 14 Jan 2003 13:10:55 -0500 (EST) Message-ID: <20030114181054.25701.qmail@web21109.mail.yahoo.com> Received: from [131.142.161.245] by web21109.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 10:10:54 PST Date: Tue, 14 Jan 2003 10:10:54 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac - best Postgres platform? To: pgsql-performance@postgresql.org In-Reply-To: <1042572384.15544.84.camel@huli> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/97 X-Sequence-Number: 744 > could you post your $PGDATA/postgresql.conf for our viewing > pleasure ? max_connections = 64 shared_buffers = 65536 # 1/2 total RAM /8K sort_mem = 100000 # min 64, size in KB checkpoint_timeout = 300 # range 30-3600, in seconds fsync = false effective_cache_size = 65536 # typically 8KB each log_timestamp = true notice, warning, error stats_command_string = true stats_row_level = true stats_block_level = true LC_MESSAGES = 'C' LC_MONETARY = 'C' LC_NUMERIC = 'C' LC_TIME = 'C' I've stripped out the default lines (grep -v ^#) comments and blank lines. > Another CPU will probably not help with bulk loads or other > single-user stuff. > [snip] > > For single-user tasks you will probably be better off by > getting a gray box with Athlon 2600+ with 3 Gigs of memory and > IDE disks and running Linux or *BSD . Hannu brings up a good point - one that was debated before my attempts at making Solaris faster. If you were going to make a fast postgres server what would you use? Assuming you could afford a SunFire 280R (~$8k?), would that money be better spent on a (say) Dell server running (say) linux? We're doing light multiuser (I guess effectively single user) but at some point (years) this may grow considereably. I'm not particular to Macs, but I've got to say, that stock out the box, postgres loves it. That old G3 was faster than the Sun, and still is faster than my (years newer) linux laptop (on which I've done no performance tweaking). So maybe a dual G4 Xserver would scream? Any suggestions? It's still not too late for us to change our minds on this one. Thanks much, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 13:17:40 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C5B5E475EE4 for ; Tue, 14 Jan 2003 13:17:37 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3AA5147655A for ; Tue, 14 Jan 2003 13:15:55 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0EIFs5u017343; Tue, 14 Jan 2003 13:15:54 -0500 (EST) To: captainx0r@yahoo.com Cc: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac In-reply-to: <20030114175004.15074.qmail@web21101.mail.yahoo.com> References: <20030114175004.15074.qmail@web21101.mail.yahoo.com> Comments: In-reply-to CaptainX0r message dated "Tue, 14 Jan 2003 09:50:04 -0800" Date: Tue, 14 Jan 2003 13:15:54 -0500 Message-ID: <17342.1042568154@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/98 X-Sequence-Number: 745 CaptainX0r writes: > Well, I've got the Sun box now, but I don't really have acces to > the G3. FWIW, top shows postgres slowly taking up all the CPU - > over the course of a minute or so it gradually ramps up to > around 90%. Once the query is complete, however, top shows the > CPU ramping down slowly, ~1-2% per second over the next 2 > minutes which I find very strange. I believe top's percent-of-CPU numbers for individual processes are time averages over a minute or so, so the ramping effect is unsurprising. > This doesn't really tell me much, except I'm guessing that PG is > CPU bound? Yup, that seems pretty clear. Next step is to find out what the heck it's doing. My instinct would be to use gprof. Recompile with profiling enabled --- if you're using gcc, this should work cd postgres-distribution/src/backend make clean make PROFILE=-pg all make install-bin -- may need to stop postmaster before install Next run some sample queries (put them all into one session). After quitting the session, find gmon.out in the $PGDATA/base/nnn/ subdirectory corresponding to your database, and feed it to gprof. The results should show where the code hotspot is. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jan 14 13:28:45 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6F6C547686C for ; Tue, 14 Jan 2003 13:28:44 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 15D4B476383 for ; Tue, 14 Jan 2003 13:26:58 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id h0EIOmW4002653; Tue, 14 Jan 2003 11:24:48 -0700 (MST) Date: Tue, 14 Jan 2003 11:26:09 -0700 (MST) From: "scott.marlowe" To: CaptainX0r Cc: Subject: Re: Sun vs. Mac In-Reply-To: <20030114150008.49425.qmail@web21103.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/99 X-Sequence-Number: 746 On Tue, 14 Jan 2003, CaptainX0r wrote: > Hello, > > I'm having some serious performance issues with PostgreSQL on > our newish SunFire 280R (1 900MHz ultrasparc III, 1 GB RAM). > It's painfully slow. It took me almost a week of tuning to get > it in the range of an old Mac G3 laptop. Now, a few days later, > after tweaking every nearly every parameter (only noting > decreased performance on some) in /etc/system and > $PGDATA/postgresql.conf it's about as fast as I can make it, but > still horribly slow. A few simple queries that take 1.5-7 > minutes on the G3 take 1-1.5 minutes on the Sun. A bulk load of > roughly 2.4 GB database dump takes ~1 hour on each machine. It > took almost 2 hours on the Sun before I turned off fsync. Just for giggles, do you have a spare drive or something you can try loading debian or some other Sparc compatible linux distro and get some numbers? My experience has been that on the same basic hardware, Linux runs postgresql about twice as fast as Solaris, and no amount of tweaking seemed to ever get postgresql up to the same performance on Solaris. It's so bad a Sparc 20 with 256 Meg ram and a 50 MHz 32 bit CPU running linux was outrunning our Sun Ultra 1 with 512 Meg ram and a 150 MHz 64 bit CPU by about 50%. That was with the 2.0.x kernel for linux and Solaris 7 on the Ultra I believe. Could have been older on the Solaris version, as I wasn't the SA on that box. From pgsql-performance-owner@postgresql.org Tue Jan 14 13:29:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9B216475D64 for ; Tue, 14 Jan 2003 13:29:26 -0500 (EST) Received: from web21110.mail.yahoo.com (web21110.mail.yahoo.com [216.136.227.112]) by postgresql.org (Postfix) with SMTP id 3F41B476A37 for ; Tue, 14 Jan 2003 13:27:36 -0500 (EST) Message-ID: <20030114182736.85732.qmail@web21110.mail.yahoo.com> Received: from [131.142.161.245] by web21110.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 10:27:36 PST Date: Tue, 14 Jan 2003 10:27:36 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: <20030114125848.P5335@mail.libertyrms.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/100 X-Sequence-Number: 747 --- Andrew Sullivan wrote: > On Tue, Jan 14, 2003 at 09:50:04AM -0800, CaptainX0r wrote: > > the G3. FWIW, top shows postgres slowly taking up all the > CPU - > > Son't use top on Solaris 8. It's inaccurate, and it affects > the results itself. Use prstat instead. Thanks for the tip. Unfortunately it shows the same exact thing. > > This doesn't really tell me much, except I'm guessing that > PG is > > CPU bound? > > It looks that way. I've had iostat show CPU-bound, however, > when the problem actually turned out to be memory contention. > I think you may want to have a poke with vmstat, and also have > a look at the SE toolkit. I'll have a look at the SE toolkit - thanks. vmstat shows me this: # vmstat -s 0 swap ins 0 swap outs 0 pages swapped in 0 pages swapped out 125452 total address trans. faults taken 35245 page ins 60 page outs 194353 pages paged in 229 pages paged out 184621 total reclaims 184563 reclaims from free list 0 micro (hat) faults 125452 minor (as) faults 31764 major faults 10769 copy-on-write faults 80220 zero fill page faults 0 pages examined by the clock daemon 0 revolutions of the clock hand 170 pages freed by the clock daemon 601 forks 19 vforks 577 execs 370612 cpu context switches 1288431 device interrupts 148288 traps 1222653 system calls 294090 total name lookups (cache hits 48%) 43510 user cpu 4002 system cpu 480912 idle cpu 13805 wait cpu procs memory page disk faults cpu r b w swap free re mf pi po fr de sr s6 sd -- -- in sy cs us sy id 0 0 0 815496 538976 31 21 261 0 0 0 0 0 12 0 0 136 209 65 7 1 92 I've not much experience with this, it looks like there are considerably more page ins than outs as compared to our other solaris boxen but otherwise pretty normal. -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 13:32:04 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 58F04475F5A for ; Tue, 14 Jan 2003 13:32:03 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id F0E0F476E48 for ; Tue, 14 Jan 2003 13:30:46 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18YVpm-0006Vm-00 for ; Tue, 14 Jan 2003 13:30:46 -0500 Date: Tue, 14 Jan 2003 13:30:46 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac - best Postgres platform? Message-ID: <20030114133046.T5335@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <1042572384.15544.84.camel@huli> <20030114181054.25701.qmail@web21109.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030114181054.25701.qmail@web21109.mail.yahoo.com>; from captainx0r@yahoo.com on Tue, Jan 14, 2003 at 10:10:54AM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/101 X-Sequence-Number: 748 On Tue, Jan 14, 2003 at 10:10:54AM -0800, CaptainX0r wrote: > > could you post your $PGDATA/postgresql.conf for our viewing > > pleasure ? > > max_connections = 64 > shared_buffers = 65536 # 1/2 total RAM /8K > sort_mem = 100000 # min 64, size in KB ^^^^^^ There's your problem. Don't set that anywhere near that high. If you run 2 queries that require sorting, _each sort_ can use up to 100000 K. Which can chew up all your memory pretty fast. > effective_cache_size = 65536 # typically 8KB each What basis did you have to change this? Have you done work figuring out how big the kernel's disk cache is regularly on that system? > Hannu brings up a good point - one that was debated before my > attempts at making Solaris faster. If you were going to make a > fast postgres server what would you use? Assuming you could > afford a SunFire 280R (~$8k?), would that money be better spent > on a (say) Dell server running (say) linux? We're doing light I've been finding FreeBSD way faster than Linux. But yes. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Jan 14 13:39:14 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A785747612D for ; Tue, 14 Jan 2003 13:39:12 -0500 (EST) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id 2B7EC4760AB for ; Tue, 14 Jan 2003 13:39:12 -0500 (EST) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id E704D329D01 for ; Tue, 14 Jan 2003 09:56:08 -0800 (PST) X-Mailer: UserLand Frontier 9.1b1 (Macintosh OS) (mailServer v1.1..142) Mime-Version: 1.0 Message-Id: <17122703.1169581751@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <20030114181054.25701.qmail@web21109.mail.yahoo.com> Date: Tue, 14 Jan 2003 10:39:05 -0800 To: pgsql-performance@postgresql.org From: eric soroos Subject: Re: Sun vs. Mac - best Postgres platform? Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/102 X-Sequence-Number: 749 > > For single-user tasks you will probably be better off by > > getting a gray box with Athlon 2600+ with 3 Gigs of memory and > > > IDE disks and running Linux or *BSD . > > I'm not particular to > Macs, but I've got to say, that stock out the box, postgres > loves it. That old G3 was faster than the Sun, and still is > faster than my (years newer) linux laptop (on which I've done no > performance tweaking). So maybe a dual G4 Xserver would scream? > > Any suggestions? It's still not too late for us to change our > minds on this one. I can't recommend macs for either brute force speed or price/performance. My current flock of machines are mostly OSX g4 boxes (single 400s and dual 800), with a couple of linux boxen thrown in for good measure. The mac's biggest issues are: 1) Tweakability - you've got one file system, and it doesn't really do useful mount options like noatime. 2) There are bugs in mount and traversing symlinks that make it hard to move pg_xlog onto another file system and retain performance (in 10.1.5, I don't have test hardware with enough drives to test 10.2) 3) vm_stat gives vm status, iostat gives nothing. Looks like this is working on my 10.2 laptop, but it's annoyed me for a while on 10.1.5 4) SW raid is not that much of a help for speed. 5) Bus bandwidth is a good factor behind x86 linux boxen. (DDR ram isn't really taken advantage of in current designs) Having said that, I'm getting reasonable performance out of all the macs, in fact, I'm getting reasonably similar performance out of all of them desplite the 4x difference in processor power. And that's because they basically have the same low end disk system. I'm piecing together something that I hope will be faster out of a x86 box loaded with more drives in a sw raid mirroring setup. (tentative is 1x system+logs, mirror for pg_xlog, mirror for pg data) I'm planning on running some comparative benchmarks prior to going live, so I should be able to tell how much faster it is. eric From pgsql-performance-owner@postgresql.org Tue Jan 14 13:41:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 07B5D475F5A for ; Tue, 14 Jan 2003 13:41:07 -0500 (EST) Received: from web21102.mail.yahoo.com (web21102.mail.yahoo.com [216.136.227.104]) by postgresql.org (Postfix) with SMTP id 5A07D475F25 for ; Tue, 14 Jan 2003 13:41:06 -0500 (EST) Message-ID: <20030114184106.93556.qmail@web21102.mail.yahoo.com> Received: from [131.142.161.245] by web21102.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 10:41:06 PST Date: Tue, 14 Jan 2003 10:41:06 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/103 X-Sequence-Number: 750 Hi, > Just for giggles, do you have a spare drive or something you > can try > loading debian or some other Sparc compatible linux distro and > get some > numbers? My experience has been that on the same basic This was on the todo list, "just to see", but I'm not sure how much time we want to spend trying a myriad of options when concentrating on one should (maybe?) do the trick. > hardware, Linux runs postgresql about twice as fast as > Solaris, and no amount of tweaking seemed to ever get > postgresql up to the same performance on Solaris. It's > so bad a Sparc 20 with 256 Meg ram and a 50 MHz 32 bit CPU > running linux was outrunning our Sun Ultra 1 with 512 Meg ram > and a 150 MHz 64 bit CPU by about 50%. That was with the > 2.0.x kernel for linux and This is not encouraging..... We may be revisiting the linux option. Thanks much for the input, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 14:01:51 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C8CE0475D22 for ; Tue, 14 Jan 2003 14:01:49 -0500 (EST) Received: from web21104.mail.yahoo.com (web21104.mail.yahoo.com [216.136.227.106]) by postgresql.org (Postfix) with SMTP id 2AB1C475BA1 for ; Tue, 14 Jan 2003 14:01:49 -0500 (EST) Message-ID: <20030114190149.7293.qmail@web21104.mail.yahoo.com> Received: from [131.142.161.245] by web21104.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 11:01:49 PST Date: Tue, 14 Jan 2003 11:01:49 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac - best Postgres platform? To: pgsql-performance@postgresql.org In-Reply-To: <20030114133046.T5335@mail.libertyrms.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/105 X-Sequence-Number: 752 --- Andrew Sullivan wrote: > On Tue, Jan 14, 2003 at 10:10:54AM -0800, CaptainX0r wrote: > > > could you post your $PGDATA/postgresql.conf for our > viewing > > > pleasure ? > > > > max_connections = 64 > > shared_buffers = 65536 # 1/2 total RAM /8K > > sort_mem = 100000 # min 64, size in KB > ^^^^^^ > There's your problem. Don't set that anywhere near that high. > If you run 2 queries that require sorting, _each sort_ can use > up to > 100000 K. Which can chew up all your memory pretty fast. I changed back to the default 1024, and down to the minimum, 64 - no change. I think that was changed simultaneously with some other parameter (bad, I know) that actually had an affect. I guess I can remove it. > > effective_cache_size = 65536 # typically 8KB each > > What basis did you have to change this? Have you done work > figuring out how big the kernel's disk cache is regularly on > that system? I read somewhere that this should be set to half the system RAM size, 64k*8k=512m = 1/2 of the 1 Gig RAM. I guess this is way off since you're saying that it's disk cache. This agrees with the documentation. I can't really rely on the (precious little Solaris postgres) info I find on the net.... ;) Unfortunately, setting back to 1000 doesn't appear to help. > > Hannu brings up a good point - one that was debated before > > my attempts at making Solaris faster. If you were going to > make a > > fast postgres server what would you use? Assuming you could > > afford a SunFire 280R (~$8k?), would that money be better > > spent on a (say) Dell server running (say) linux? We're > > doing light > > I've been finding FreeBSD way faster than Linux. But yes. I like to hear this since I'm a big FreeBSD fan. So far I think I've understood this as: FreeBSD > Linux > OSX > Solaris. Thanks much for the input, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 14:18:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 637324764E0 for ; Tue, 14 Jan 2003 14:18:56 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 81A0A4764CE for ; Tue, 14 Jan 2003 14:18:53 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18YWaL-0007PS-00 for ; Tue, 14 Jan 2003 14:18:53 -0500 Date: Tue, 14 Jan 2003 14:18:53 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac - best Postgres platform? Message-ID: <20030114141853.V5335@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20030114133046.T5335@mail.libertyrms.com> <20030114190149.7293.qmail@web21104.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030114190149.7293.qmail@web21104.mail.yahoo.com>; from captainx0r@yahoo.com on Tue, Jan 14, 2003 at 11:01:49AM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/106 X-Sequence-Number: 753 On Tue, Jan 14, 2003 at 11:01:49AM -0800, CaptainX0r wrote: > I changed back to the default 1024, and down to the minimum, 64 > - no change. I think that was changed simultaneously with some > other parameter (bad, I know) that actually had an affect. I > guess I can remove it. Very bad to change two things at once. You think it's saving you time, but now . . . well, you already know what happens ;-) Anyway, you _still_ shouldn't have it that high. > > > effective_cache_size = 65536 # typically 8KB each > > I read somewhere that this should be set to half the system RAM > size, 64k*8k=512m = 1/2 of the 1 Gig RAM. I guess this is way > off since you're saying that it's disk cache. This agrees with > the documentation. I can't really rely on the (precious little > Solaris postgres) info I find on the net.... ;) I think you should rely on the Postgres documentation, which has way fewer errors than just about any other technical documentation I've ever seen. Yes, it's disk cache. I wouldn't set _anything_ to half the system RAM. It'd be real nice if your disk cache was half your RAM, but I'd be amazed if anyone's system were that efficient. It sounds like you need to follow Tom Lane's advice, though, and do some profiling. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Jan 14 12:33:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DBBD6475EE4 for ; Tue, 14 Jan 2003 12:33:07 -0500 (EST) Received: from localhost.localdomain (sein.itera.ee [194.126.109.126]) by postgresql.org (Postfix) with ESMTP id 2F4E1476315 for ; Tue, 14 Jan 2003 12:32:34 -0500 (EST) Received: (from hannu@localhost) by localhost.localdomain (8.11.6/8.11.6) id h0EJQPo15967; Tue, 14 Jan 2003 19:26:25 GMT X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: Sun vs. Mac From: Hannu Krosing To: captainx0r@yahoo.com Cc: "pgsql-performance@postgresql.org" In-Reply-To: <20030114150008.49425.qmail@web21103.mail.yahoo.com> References: <20030114150008.49425.qmail@web21103.mail.yahoo.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1042572384.15544.84.camel@huli> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 14 Jan 2003 19:26:24 +0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/94 X-Sequence-Number: 741 On Tue, 2003-01-14 at 15:00, CaptainX0r wrote: > Hello, > > I'm having some serious performance issues with PostgreSQL on > our newish SunFire 280R (1 900MHz ultrasparc III, 1 GB RAM). > It's painfully slow. It took me almost a week of tuning to get > it in the range of an old Mac G3 laptop. Now, a few days later, > after tweaking every nearly every parameter (only noting > decreased performance on some) in /etc/system and > $PGDATA/postgresql.conf could you post your $PGDATA/postgresql.conf for our viewing pleasure ? > it's about as fast as I can make it, but > still horribly slow. A few simple queries that take 1.5-7 > minutes on the G3 take 1-1.5 minutes on the Sun. A bulk load of > roughly 2.4 GB database dump takes ~1 hour on each machine. It > took almost 2 hours on the Sun before I turned off fsync. > > We have plans to add another CPU, RAM and another disk, which > should all help, Another CPU will probably not help with bulk loads or other single-user stuff. > but in its current state, I (and many others) > would think that it should run circles around the G3. I'm > thinking that I'm missing something big and obvious because this > can't be right. Otherwise we might as well just get a bunch of > ibooks to run our databases - they're a lot smaller and much > more quiet. For single-user tasks you will probably be better off by getting a gray box with Athlon 2600+ with 3 Gigs of memory and IDE disks and running Linux or *BSD . > Can someone please point me in the right direction? > > Thanks, > > -X > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Hannu Krosing From pgsql-performance-owner@postgresql.org Wed Jan 15 15:17:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AFFE74771CD for ; Wed, 15 Jan 2003 15:17:53 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 5045D476624 for ; Wed, 15 Jan 2003 14:30:29 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2315106; Wed, 15 Jan 2003 11:30:32 -0800 Content-Type: text/plain; charset="utf-8" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Roman Fail" , Subject: Re: 7.3.1 New install, large queries are slow Date: Tue, 14 Jan 2003 11:32:32 -0800 X-Mailer: KMail [version 1.4] References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301141132.32277.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/120 X-Sequence-Number: 767 Roman, First, if this is a dedicated PostgreSQL server, you should try increasing= =20 your shared_buffers to at least 512mb (65536) if not 1GB (double that) and= =20 adjust your shmmax and shmmall to match. Second, you will probably want to increase your sort_mem as well. How much= =20 depeneds on the number of concurrent queries you expect to be running and= =20 their relative complexity. Give me that information, and I'll offer you= =20 some suggestions. Part of your slow query=20 Your query problem is hopefully relatively easy. The following clause is 9= 5%=20 of your query time: > -> Index Scan using=20 batchdetail_ix_tranamount_idx on batchdetail d (cost=3D0.00..176768.18=20 rows=3D44010 width=3D293) (actual time=3D35.48..1104625.54 rows=3D370307 lo= ops=3D1)=20 >=20 See the actual time figures? This one clause is taking 1,104,590 msec!=20= =20=20 Now, why? Well, look at the cost estimate figures in contrast to the actual row count: estimate rows =3D 44,010 real rows 370,307 That's off by a factor of 9. This index scan is obviously very cumbersome= =20 and is slowing the query down. Probably it should be using a seq scan=20 instead ... my guess is, you haven't run ANALYZE in a while and the incorre= ct=20 row estimate is causing the parser to choose a very slow index scan. Try running ANALYZE on your database and re-running the query. Also try= =20 using REINDEX on batchdetail_ix_tranamount_idx . Second, this clause near the bottom: -> Seq Scan on purc1 p1 (cost=3D0.00..442= 59.70=20 rows=3D938770 width=3D19) (actual time=3D98.09..4187.32 rows=3D938770 loops= =3D5)=20 ... suggests that you could save an additional 4 seconds by figuring out a = way=20 for the criteria on purc1 to use a relevant index -- but only after you've= =20 solved the problem with batchdetail_ix_tranamount_idx. Finally, if you really want help, post the query. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Jan 14 14:39:13 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A9149475D01 for ; Tue, 14 Jan 2003 14:39:11 -0500 (EST) Received: from web21106.mail.yahoo.com (web21106.mail.yahoo.com [216.136.227.108]) by postgresql.org (Postfix) with SMTP id 5A8F24765D2 for ; Tue, 14 Jan 2003 14:38:28 -0500 (EST) Message-ID: <20030114193828.37133.qmail@web21106.mail.yahoo.com> Received: from [131.142.161.245] by web21106.mail.yahoo.com via HTTP; Tue, 14 Jan 2003 11:38:28 PST Date: Tue, 14 Jan 2003 11:38:28 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac To: pgsql-performance@postgresql.org In-Reply-To: <17342.1042568154@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/107 X-Sequence-Number: 754 > I believe top's percent-of-CPU numbers for individual > processes are time > averages over a minute or so, so the ramping effect is > unsurprising. Thanks - this makes much more sense. > > This doesn't really tell me much, except I'm guessing that > > PG is CPU bound? > > Yup, that seems pretty clear. Next step is to find out what > the heck > it's doing. My instinct would be to use gprof. Recompile > with > profiling enabled --- if you're using gcc, this should work > cd postgres-distribution/src/backend > make clean > make PROFILE=-pg all > make install-bin -- may need to stop postmaster > Next run some sample queries (put them all into one session). > After quitting the session, find gmon.out in the > $PGDATA/base/nnn/ subdirectory corresponding to your database, > and feed it to gprof. > The results should show where the code hotspot is. Well if that isn't a fancy bit of info.... Thanks! gprof says: Fatal ELF error: can't read ehdr (Request error: class file/memory mismatch) I'm guessing that's not what we're expecting... I'm using /usr/ccs/bin/gprof - maybe there's a better one? -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Tue Jan 14 14:44:12 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 83CC1475BA1 for ; Tue, 14 Jan 2003 14:44:11 -0500 (EST) Received: from pd6mo1so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by postgresql.org (Postfix) with ESMTP id 0DDF2475B8F for ; Tue, 14 Jan 2003 14:44:11 -0500 (EST) Received: from pd6mr1so.prod.shaw.ca (pd6mr1so-qfe3.prod.shaw.ca [10.0.141.216]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0H8P00FP3YTNCN@l-daemon> for pgsql-performance@postgresql.org; Tue, 14 Jan 2003 12:44:11 -0700 (MST) Received: from pn2ml5so.prod.shaw.ca (pn2ml5so-qfe0.prod.shaw.ca [10.0.121.149]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0H8P003NTYTN5S@l-daemon> for pgsql-performance@postgresql.org; Tue, 14 Jan 2003 12:44:11 -0700 (MST) Received: from kimiko (h24-78-132-76.vc.shawcable.net [24.78.132.76]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with SMTP id <0H8P0088WYTMNK@l-daemon> for pgsql-performance@postgresql.org; Tue, 14 Jan 2003 12:44:11 -0700 (MST) Date: Tue, 14 Jan 2003 11:42:07 -0800 From: Vernon Wu Subject: How good I can get To: pgsql-performance@postgresql.org Reply-To: vernonw@gatewaytech.com Message-id: <65TWVMK3ZVRRMF0DYTHF74KGKE08CA.3e24680f@kimiko> MIME-version: 1.0 X-Mailer: Opera 6.05 build 1140 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT X-Priority: 3 (Normal) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/108 X-Sequence-Number: 755 In my current project, among of over twenty main tables, three of them are the master tables and result are the multivalued detail tables. All of those table have the field name userid which is varchar data type. A selection statement, having a level of subquery, can involve up to twenty tables. After some query statement tuning and indexing (on all of the multivalued field of all the detail table), a query performance improves spectacularly. The following is the output of ?explain analyze? on a query involved ten tables. NOTICE: QUERY PLAN: Result (cost=0.00..23.42 rows=1 width=939) (actual time=28.00..28.00 rows=0 loops=1) . . . Total runtime: 31.00 msec I would like to find any performance improvement potentiality in terms of DB table design (indexing always can be done later). The first thing I know I can do is to change the join key, userid, to numeral. Since implementing the change requests some work on the system, I would like to know how significant performance improement it can bring. Almost all fields of those tables are a single digit character. I can guess that change them to number type also can improve the selection performance. My question again is how much it can get. The application is a web application. All data on a page is a string, or text type. All number type data has to be parsed from a string to the back-end, and converted into a string from the back end. So that change will have performance overhead on the application. Thanks for your input. Vernon From pgsql-performance-owner@postgresql.org Wed Jan 15 16:33:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5CBDF476D2E for ; Wed, 15 Jan 2003 16:21:18 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id D50AB476E7C for ; Wed, 15 Jan 2003 15:34:11 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2315206; Wed, 15 Jan 2003 12:34:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tomasz Myrta Subject: Re: complicated queries in pl/pgsql Date: Tue, 14 Jan 2003 12:36:15 -0800 X-Mailer: KMail [version 1.4] Cc: PgSQL Performance ML References: <3E23EC83.9060802@klaster.net> <200301131044.50424.josh@agliodbs.com> <3E25B29C.9040408@klaster.net> In-Reply-To: <3E25B29C.9040408@klaster.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301141236.15915.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/124 X-Sequence-Number: 771 Tomasz, > Thanks a lot. > I'm asking, because I use some queries which are easy to change into=20 > views. Most of their execution time takes planning, they use 5-10=20 > explicit table joins with not too many rows in these tables and returns= =20 > few values. You might want to investigate the new "prepared query" functionality in 7.3= .1. I haven't used it yet, so I can't help much. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Jan 14 15:51:16 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ED3684761D1 for ; Tue, 14 Jan 2003 15:51:15 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 717D5476009 for ; Tue, 14 Jan 2003 15:51:15 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id C70121479C for ; Tue, 14 Jan 2003 15:51:16 -0500 (EST) Date: Tue, 14 Jan 2003 15:51:16 -0500 Mime-Version: 1.0 (Apple Message framework v551) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: Multiple databases From: Noah Silverman To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/109 X-Sequence-Number: 756 Hi, A quick configuration question for everybody... When we create more than one database with psql, it appears as if everything is thrown into the same directory. I can understand having all the tables and indexes for a given database in the same directory, but multiple databases? Do we need to configure something differently, or is this just how postgres works? Thanks, -Noah From pgsql-performance-owner@postgresql.org Tue Jan 14 15:54:50 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BEE1D475D01 for ; Tue, 14 Jan 2003 15:54:48 -0500 (EST) Received: from jester.senspire.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id 109A8475B8F for ; Tue, 14 Jan 2003 15:54:48 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0EKsscb015604; Tue, 14 Jan 2003 15:54:54 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: Multiple databases From: Rod Taylor To: Noah Silverman Cc: Pgsql Performance In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-/ecQ6gKMtPf4fQYWobvE" Organization: Message-Id: <1042577693.14661.73.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 14 Jan 2003 15:54:54 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/110 X-Sequence-Number: 757 --=-/ecQ6gKMtPf4fQYWobvE Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > Do we need to configure something differently, or is this just how=20 > postgres works? Thats just how it works. Under 'base' there are a number of numbered directories which represent various databases. If you really want, take a look at the "WITH LOCATION" option for create database. Command: CREATE DATABASE Description: create a new database Syntax: CREATE DATABASE name [ [ WITH ] [ OWNER [=3D] dbowner ] [ LOCATION [=3D] 'dbpath' ] [ TEMPLATE [=3D] template ] [ ENCODING [=3D] encoding ] ] > Thanks, >=20 > -Noah >=20 >=20 > ---------------------------(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 --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-/ecQ6gKMtPf4fQYWobvE 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 (FreeBSD) iD8DBQA+JHkd6DETLow6vwwRAmVCAJ9+5oIg4NfRkk8RSO1NDmBPTg+WSgCfZYsJ YRb4yKYT1AG3BcWHXzcL0GQ= =B3+k -----END PGP SIGNATURE----- --=-/ecQ6gKMtPf4fQYWobvE-- From pgsql-performance-owner@postgresql.org Tue Jan 14 15:58:03 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 243FE475D01 for ; Tue, 14 Jan 2003 15:58:03 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id A8202475B8F for ; Tue, 14 Jan 2003 15:58:02 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 4036913F44; Tue, 14 Jan 2003 15:58:04 -0500 (EST) Date: Tue, 14 Jan 2003 15:58:03 -0500 Subject: Re: Multiple databases Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: Pgsql Performance To: Rod Taylor From: Noah Silverman In-Reply-To: <1042577693.14661.73.camel@jester> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/111 X-Sequence-Number: 758 Thanks, Can someone give me a good description of what the various directories and files actually are. I have RTFMed, but the descriptions there don't seem to match what I have on my machine. Thanks. On Tuesday, January 14, 2003, at 03:54 PM, Rod Taylor wrote: >> Do we need to configure something differently, or is this just how >> postgres works? > > Thats just how it works. Under 'base' there are a number of numbered > directories which represent various databases. > > If you really want, take a look at the "WITH LOCATION" option for > create > database. > > > Command: CREATE DATABASE > Description: create a new database > Syntax: > CREATE DATABASE name > [ [ WITH ] [ OWNER [=] dbowner ] > [ LOCATION [=] 'dbpath' ] > [ TEMPLATE [=] template ] > [ ENCODING [=] encoding ] ] > >> Thanks, >> >> -Noah >> >> >> ---------------------------(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 > -- > Rod Taylor > > PGP Key: http://www.rbt.ca/rbtpub.asc > From pgsql-performance-owner@postgresql.org Tue Jan 14 18:56:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 21DCC4764B3 for ; Tue, 14 Jan 2003 18:56:53 -0500 (EST) Received: from new-smtp2.ihug.com.au (new-smtp2.ihug.com.au [203.109.250.28]) by postgresql.org (Postfix) with ESMTP id 1777847611B for ; Tue, 14 Jan 2003 18:56:33 -0500 (EST) Received: from p96-tnt1.adl.ihug.com.au (postgresql.org) [203.173.248.96] by new-smtp2.ihug.com.au with esmtp (Exim 3.22 #1 (Debian)) id 18Yav4-0003Qi-00; Wed, 15 Jan 2003 10:56:34 +1100 Message-ID: <3E24A472.6040706@postgresql.org> Date: Wed, 15 Jan 2003 10:29:46 +1030 From: Justin Clift User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andrew Sullivan Cc: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac - best Postgres platform? References: <1042572384.15544.84.camel@huli> <20030114181054.25701.qmail@web21109.mail.yahoo.com> <20030114133046.T5335@mail.libertyrms.com> In-Reply-To: <20030114133046.T5335@mail.libertyrms.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/113 X-Sequence-Number: 760 Andrew Sullivan wrote: > I've been finding FreeBSD way faster than Linux. But yes. Out of curiosity, have you been trying FreeBSD 4.7x or the developer releases of 5.0? Apparently there are new kernel scheduling improvements in FreeBSD 5.0 that will help certain types of tasks and might boost our performance further. Would be interested in seeing if the profiling/optimisation options of GCC 3.2.x are useful as well. :-) Regards and best wishes, Justin Clift > A -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi From pgsql-performance-owner@postgresql.org Tue Jan 14 19:02:23 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 787624763F2 for ; Tue, 14 Jan 2003 19:02:21 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id E87CE475B8F for ; Tue, 14 Jan 2003 19:01:58 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18Yb0L-0004Yk-00 for ; Tue, 14 Jan 2003 19:02:01 -0500 Date: Tue, 14 Jan 2003 19:02:01 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac - best Postgres platform? Message-ID: <20030114190201.A17481@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <1042572384.15544.84.camel@huli> <20030114181054.25701.qmail@web21109.mail.yahoo.com> <20030114133046.T5335@mail.libertyrms.com> <3E24A472.6040706@postgresql.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3E24A472.6040706@postgresql.org>; from justin@postgresql.org on Wed, Jan 15, 2003 at 10:29:46AM +1030 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/114 X-Sequence-Number: 761 On Wed, Jan 15, 2003 at 10:29:46AM +1030, Justin Clift wrote: > Andrew Sullivan wrote: > > > I've been finding FreeBSD way faster than Linux. But yes. > > Out of curiosity, have you been trying FreeBSD 4.7x or the developer Just 4.7x. And mostly for little jobs for myself, so I can't speak about testing it in a production case. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Wed Jan 15 00:12:35 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5AA19475E75 for ; Wed, 15 Jan 2003 00:12:33 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 88A9C475E22 for ; Wed, 15 Jan 2003 00:12:32 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0F5Cb5u001984; Wed, 15 Jan 2003 00:12:37 -0500 (EST) To: captainx0r@yahoo.com Cc: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac In-reply-to: <20030114193828.37133.qmail@web21106.mail.yahoo.com> References: <20030114193828.37133.qmail@web21106.mail.yahoo.com> Comments: In-reply-to CaptainX0r message dated "Tue, 14 Jan 2003 11:38:28 -0800" Date: Wed, 15 Jan 2003 00:12:37 -0500 Message-ID: <1983.1042607557@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/115 X-Sequence-Number: 762 CaptainX0r writes: > gprof says: > Fatal ELF error: can't read ehdr (Request error: class > file/memory mismatch) Hm, that's a new one on me. Just to eliminate the obvious: you did read the gprof man page? It typically needs both the pathname of the postgres executable and that of the gmon.out file. If that's not it, I fear you need a gprof expert, which I ain't. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jan 15 13:13:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 243704773AB for ; Wed, 15 Jan 2003 13:13:14 -0500 (EST) Received: from web21110.mail.yahoo.com (web21110.mail.yahoo.com [216.136.227.112]) by postgresql.org (Postfix) with SMTP id 3B8F147757B for ; Wed, 15 Jan 2003 12:22:46 -0500 (EST) Message-ID: <20030115172250.54953.qmail@web21110.mail.yahoo.com> Received: from [140.247.91.110] by web21110.mail.yahoo.com via HTTP; Wed, 15 Jan 2003 09:22:50 PST Date: Wed, 15 Jan 2003 09:22:50 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac - gprof output To: pgsql-performance@postgresql.org In-Reply-To: <1983.1042607557@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/116 X-Sequence-Number: 763 All, > Hm, that's a new one on me. Just to eliminate the obvious: > you did read the gprof man page? It typically needs both the > pathname of the postgres executable and that of the gmon.out I read it, but apparently not very well. It appears that as long as gmon.out is in the current dir, all that's needed is the name of the executeable (with full path). The way it's formated I read it as all that's needed is the image-file. Anyways... There's a ton of output, so I'm picking what appear to be the highlights. granularity: each sample hit covers 4 byte(s) for 0.00% of 705.17 seconds called/total parents index %time self descendents called+self name index called/total children [1] 63.6 446.05 2.65 44386289+57463869 [1] 442.08 2.50 59491100+2566048020 [2] 2.91 0.00 23045572+366 _fini [23] 0.57 0.00 17763681 _rl_input_available [42] 0.11 0.15 478216+7 history_expand [54] 0.21 0.00 7 history_tokenize_internal [56] 0.10 0.00 1071137 tilde_expand [68] 0.07 0.00 397 rl_gather_tyi [70] 0.00 0.00 31 qsort [81] 0.00 0.00 17 rl_insert_close [82] ----------------------------------------------- [3] 32.3 0.65 227.47 rl_get_termcap [3] 226.13 1.34 22502064/44386289 [2] ----------------------------------------------- [4] 26.3 0.78 184.35 rl_stuff_char [4] 178.51 1.06 17763681/44386289 [2] 4.78 0.00 17763681/17763681 rl_clear_signals [18] ----------------------------------------------- [5] 15.8 111.61 0.00 rl_signal_handler [5] 0.00 0.00 1/44386289 [2] ----------------------------------------------- [6] 4.3 30.57 0.00 rl_sigwinch_handler [6] ----------------------------------------------- And: granularity: each sample hit covers 4 byte(s) for 0.00% of 705.17 seconds % cumulative self self total time seconds seconds calls ms/call ms/call name 15.8 111.61 111.61 rl_signal_handler [5] 4.3 142.18 30.57 rl_sigwinch_handler [6] 1.9 155.42 13.24 rl_set_sighandler [8] 1.9 168.52 13.10 rl_maybe_set_sighandler [9] 1.1 176.37 7.85 _rl_next_macro_key [11] 0.9 182.38 6.01 rl_read_key [12] 0.8 188.07 5.69 rl_backward_kill_line [13] 0.8 193.56 5.49 rl_unix_word_rubout [14] 0.8 198.91 5.35 _rl_pop_executing_macro [15] 0.7 203.73 4.82 _rl_fix_last_undo_of_type [17] 0.7 208.51 4.78 17763681 0.00 0.00 rl_clear_signals [18] 0.6 212.87 4.36 rl_modifying [19] 0.6 216.95 4.08 rl_begin_undo_group [20] 0.6 221.00 4.05 rl_tilde_expand [21] 0.4 223.98 2.98 region_kill_internal [22] 0.4 226.89 2.91 23045572 0.00 0.00 _fini [23] So. Any thoughts? This looks really useful in the hands of someone who knows what it all means. Looks like some signal handlers are using up most of the time. Good? Bad? Am I reading that first part correctly in that a good part of the time spent is external to Postgres? This report also seems to verify that qsort isn't a problem since it was the 81st index, with 31 calls (not much) and 0.00 self seconds. Thanks much, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Wed Jan 15 13:47:37 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 34E7E476662 for ; Wed, 15 Jan 2003 13:47:35 -0500 (EST) Received: from pos_pdc.posportal.com (unknown [12.158.169.100]) by postgresql.org (Postfix) with ESMTP id C4AAF4766E7 for ; Wed, 15 Jan 2003 13:00:05 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: 7.3.1 New install, large queries are slow Date: Wed, 15 Jan 2003 10:00:04 -0800 Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] 7.3.1 New install, large queries are slow Thread-Index: AcK8v+5ZAEtKuS2jTYa5+fDHnXwnag== From: "Roman Fail" To: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/117 X-Sequence-Number: 764 SSBhbSB0cnlpbmcgdG8gZ2V0IGEgUG9zdGdyZVNRTCBzZXJ2ZXIgaW50byBw cm9kdWN0aW9uIChtb3ZpbmcgZnJvbSBNU1NRTDJLKSBidXQgaGF2aW5nIHNv bWUgc2VyaW91cyBwZXJmb3JtYW5jZSBpc3N1ZXMuICBQb3N0Z3JlU1FMIGlz IG5ldyB0byBtZSwgYW5kIEknbSBvbmx5IGp1c3Qgbm93IGNvbWZvcnRhYmxl IHdpdGggTGludXguICBTbyBmYXIgSSd2ZSBzdWNjZXNmdWxseSBjb21waWxl ZCBwb3N0Z3JlcyBmcm9tIHNvdXJjZSBhbmQgbWlncmF0ZWQgYWxsIHRoZSBk YXRhIGZyb20gTVNTUUwuICBQb3N0Z3JlcyBpcyBwcmltYXJpbHkgYWNjZXNz ZWQgdXNpbmcgSkRCQy4gIA0KIA0KSSByZWFsbHkgd2FudCB0byB1c2UgUG9z dGdyZXMgZm9yIHByb2R1Y3Rpb24sIGJ1dCBpZiBJIGNhbid0IGdldCBiZXR0 ZXIgcmVzdWx0cyBvdXQgb2YgaXQgYnkgdGhlIGVuZCBvZiB0aGUgd2VlayB3 ZSBhcmUgZHJvcHBpbmcgaXQgZm9yZXZlciBhbmQgZ29pbmcgYmFjayB0byBN U1NRTCBkZXNwaXRlIHRoZSAkJCQuICBJJ20gYmFzaWNhbGx5IGF0IGEgcG9p bnQgd2hlcmUgSSd2ZSBnb3QgdG8gZmluZCBoZWxwIGZyb20gdGhlIGxpc3Qu ICBQbGVhc2UgaGVscCBtZSBtYWtlIHRoaXMgc2VydmVyIGZseSENCiANCkkg aGF2ZSBhIHF1ZXJ5IHRoYXQgZG9lcyBtYW55IGpvaW5zIChpbmNsdWRpbmcg dHdvIHZlcnkgYmlnIHRhYmxlcykgd2hpY2ggaXMgc2xvdyBvbiBQb3N0Z3Jl cy4gIE9uIFBHU1FMIHRoZSBxdWVyeSB0YWtlcyAxOSBtaW51dGVzLCBidXQg b25seSAzIHNlY29uZHMgb24gTVNTUUwuICBUaGUgdHdvIHNlcnZlcnMgaGF2 ZSB0aGUgc2FtZSBpbmRleGVzIGNyZWF0ZWQgKGluY2x1ZGluZyBwcmltYXJ5 IGtleSBpbmRleGVzKS4gIEkgZmluYWxseSBnYXZlIHVwIG9uIGNyZWF0aW5n IGFsbCB0aGUgZm9yZWlnbiBrZXlzIGluIFBvc3RncmVzIC0gYWZ0ZXIgMTIg aG91cnMgb2YgMTAwJSBDUFUuICBJdCdzIGhhcmQgZm9yIG1lIHRvIGJlbGll dmUgdGhhdCB0aGUgaGFyZHdhcmUgaXMgdGhlIGJvdHRsZW5lY2sgLSB0aGUg JDIwayBQb3N0Z3JlcyBzZXJ2ZXIgZmFyIG91dGNsYXNzZXMgdGhlIE1TU1FM IHNlcnZlciAoc2VlIGJlbG93IGZvciBzdGF0cykuICBXaGVuIEkgcmFuIEVY UExBSU4gQU5BTFlaRSBmb3IgdGhpcyBxdWVyeSB0aGUgQ1BVIGF2ZXJhZ2Vk IDUlLCBzYXIgLWIgc2hvd3MgYWJvdXQgNiwwMDAgYmxvY2sgcmVhZHMvc2Vj LCBhbmQgdm1zdGF0IGhhZCB6ZXJvIHN3YXBwaW5nLiAgRVhQTEFJTiByZXN1 bHRzIGFyZSBiZWxvdywgSSdtIG5vdCBzdXJlIGhvdyB0byBpbnRlcnByZXQg dGhlbS4NCiANClRoZSBkaXNrcyBhcmUgbm90IHJlYWRpbmcgYXQgbWF4IHNw ZWVkIGR1cmluZyB0aGUgcXVlcnkgLSB3aGVuIEkgcmFuIGEgVkFDVVVNIEFO QUxZWkUgKGFmdGVyIGRhdGEgbWlncmF0aW9uKSwgc2FyIC1iIHdhcyBjb25z aXN0ZW50bHkgMTAwLDAwMCBibG9jayByZWFkcy9zZWMuICBJdCBkb2VzIG5v dCBzZWVtIGxpa2UgdGhlIGhhcmR3YXJlIGlzIGhvbGRpbmcgYmFjayB0aGlu Z3MgaGVyZS4gIEkgcmVhZCBzb21ldGhpbmcgYWJvdXQgJ2ZzeW5jJyByZWNl bnRseSwgd291bGQgY2hhbmdpbmcgdGhhdCBzZXR0aW5nIGFwcGx5IGluIHRo aXMgY2FzZT8NCiANCkRBVEFCQVNFOg0KJ3RyYW5oZWFkZXInIHRhYmxlIGhh cyAyMDAwIHR1cGxlcywgUEsgaW5kZXgNCidiYXRjaGhlYWRlcicgdGFibGUg aGFzIDIuNiBtaWxsaW9uIHR1cGxlcywgNSBpbmRleGVzLCBGSyBjb25zdHJh aW50IHRvIHRyYW5oZWFkZXIgUEsNCidiYXRjaGRldGFpbCcgdGFibGUgaGFz IDIzIG1pbGxpb24gdHVwbGVzLCA2IGluZGV4ZXMsIEZLIGNvbnN0cmFpbnQg dG8gYmF0Y2hlYWRlciBQSw0KMTggdGFibGVzIHdpdGggPDEwMDAgdHVwbGVz LCBtb3N0IGFyZSBjaGlsZCB0YWJsZXMgb2YgYmF0Y2hkZXRhaWwNCkFsbCB0 YWJsZXMgaGF2ZSBhIFBLIGFuZCBhcmUgbm9ybWFsaXplZCANCkxhcmdlIG5p Z2h0bHkgSU5TRVJUcyAofjIwMDAwMCB0dXBsZXMpDQpDb21wbGV4IFNFTEVD VHMgYWxsIGRheSBsb25nDQpObyBVUERBVEVzIG9yIERFTEVURXMgZXZlciwg YXQgbGVhc3QgdW50aWwgSSBydW4gbG93IG9uIHN0b3JhZ2UhDQogDQpJJ3Zl IGxlYXJuZWQgYXMgbXVjaCBhcyBJIGNhbiBhYnNvcmIgZnJvbSB0aGUgb25s aW5lIGRvY3MgYW5kIGFyY2hpdmVzIGFib3V0IHBlcmZvcm1hbmNlIHR1bmlu Zy4gIEJhc2VkIG9uIG15IGxpbWl0ZWQgdW5kZXJzdGFuZGluZywgSSd2ZSBj aGFuZ2VkIHRoZSBmb2xsb3dpbmcgc2V0dGluZ3MuICBJIGFtIHRvdGFsbHkg b3BlbiB0byBhbnkgc3VnZ2VzdGlvbnMsIGluY2x1ZGluZyBzdGFydGluZyBv dmVyIHdpdGggUkFJRCwgZmlsZXN5c3RlbXMsIFBHU1FMLiAgSSB3b3VsZCBh bG1vc3QgY29uc2lkZXIgRnJlZUJTRCBpZiBpdCBoZWxwZWQgYSBsb3QsIGJ1 dCB0aGF0IHdvdWxkIGJlIGEgc3RyZXRjaCBnaXZlbiBteSB0aW1lIGludmVz dG1lbnQgaW4gTGludXguICBUaGlzIGlzIGEgYnJhbmQgbmV3IG1hY2hpbmUs IHNvIGJhZCBoYXJkd2FyZSBpcyBhIHBvc3NpYmlsaXR5IC0gYnV0IEknbSBu b3Qgc3VyZSBob3cgdG8gZ28gYWJvdXQgZGV0ZXJtaW5pbmcgdGhhdC4NCiAN CioqKiAvZXRjL3N5c2N0bC5jb25mDQprZXJuZWwuc2htbW5pID0gNDA5Ng0K a2VybmVsLnNobWFsbCA9IDMyMDAwMDAwDQprZXJuZWwuc2htbWF4ID0gNTEy MDAwMDAwICANCiANCioqKiAvdXNyL2xvY2FsL3Bnc3FsL2RhdGEvcG9zdGdy ZXNxbC5jb25mDQp0Y3BpcF9zb2NrZXQ9dHJ1ZQ0Kc2hhcmVkX2J1ZmZlcnMg PSAzMjc2OA0KbWF4X2ZzbV9yZWxhdGlvbnMgPSAxMDAwMA0KbWF4X2ZzbV9w YWdlcyA9IDIwMDAwMDANCnNvcnRfbWVtID0gODE5Mg0KIA0KUE9TVEdSRVNR TCBTWVNURU06DQpSZWQgSGF0IExpbnV4IDguMCwgUG9zdGdyZVNRTCA3LjMu MSAoZGVkaWNhdGVkLCBiZXNpZGVzIFNTSCBkYWVtb24pDQpEZWxsIFBFNjYw MCBEdWFsIFhlb24gTVAgMi4wR0h6LCAyTUIgTDMgY2FjaGUsSHlwZXJUaHJl YWRpbmcgZW5hYmxlZA0KNC4wIEdCIFBoeXNpY2FsIFJBTQ0KL2Rldi9zZGEx OiBleHQzIDEwMU1CIC9ib290IA0KL2Rldi9zZGEyOiBleHQzICAzNEdCIC8g ICAgICAoc2RhIGlzIDIgZGlzayBSQUlELTEpDQpub25lICAgICA6IHN3YXAg MS44R0INCi9kZXYvc2RiMTogZXh0MyAxMDRHQiAvdXNyL2xvY2FsL3Bnc3Fs L2RhdGEgKHNkYiBpcyA2IGRpc2sgUkFJRC0xMCkNCkFsbCA4IGRyaXZlcyBh cmUgMzZHQiwgMTVrIFJQTSwgVWx0cmExNjAgU0NTSQ0KUEVSQzMvREMgMTI4 TUIgUkFJRCBjb250cm9sbGVyDQogDQpNU1NRTCBTWVNURU06DQpEZWxsIFBF MTY1MCwgRHVhbCBQMyAxLjFHSHosIDEuNUdCIFJBTQ0KU2luZ2xlIDE4R0Is IDE1ayBSUE0gU0NTSSBkcml2ZSAobm8gUkFJRCkNCldpbmRvd3MgMjAwMCBT ZXJ2ZXIgU1AzLCBTUUwgU2VydmVyIDIwMDAgU1AyDQoNClRJQSwNClJvbWFu IEZhaWwNClNyLiBXZWIgQXBwbGljYXRpb24gRGV2ZWxvcGVyDQpQT1MgUG9y dGFsLCBJbmMuDQoNCkVYUExBSU4gQU5BTFlaRSBSRVNVTFRTOg0KTGltaXQg IChjb3N0PTM3MDUxOC4zMS4uMzcwNTE4LjMxIHJvd3M9MSB3aWR0aD01NDAp IChhY3R1YWwgdGltZT0xMTY4NzIyLjE4Li4xMTY4NzIyLjIwIHJvd3M9NSBs b29wcz0xKQ0KICAtPiAgU29ydCAgKGNvc3Q9MzcwNTE4LjMxLi4zNzA1MTgu MzEgcm93cz0xIHdpZHRoPTU0MCkgKGFjdHVhbCB0aW1lPTExNjg3MjIuMTgu LjExNjg3MjIuMTggcm93cz01IGxvb3BzPTEpDQogICAgICAgIFNvcnQgS2V5 OiBiLmJhdGNoZGF0ZQ0KICAgICAgICAtPiAgTmVzdGVkIExvb3AgIChjb3N0 PTMxNDE4MS4xNy4uMzcwNTE4LjMwIHJvd3M9MSB3aWR0aD01NDApIChhY3R1 YWwgdGltZT0xMTQ4MTkxLjEyLi4xMTY4NzIyLjA5IHJvd3M9NSBsb29wcz0x KQ0KICAgICAgICAgICAgICBKb2luIEZpbHRlcjogKCJpbm5lciIuYmF0Y2hk ZXRhaWxpZCA9ICJvdXRlciIuYmF0Y2hkZXRhaWxpZCkNCiAgICAgICAgICAg ICAgLT4gIE5lc3RlZCBMb29wICAoY29zdD0zMTQxODEuMTcuLjM3MDQ2MS43 OSByb3dzPTEgd2lkdGg9NTAyKSAoYWN0dWFsIHRpbWU9MTE0ODE2Ny41NS4u MTE2ODY3MS44MCByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAg ICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLmJhdGNoZGV0YWlsaWQgPSAib3V0 ZXIiLmJhdGNoZGV0YWlsaWQpDQogICAgICAgICAgICAgICAgICAgIC0+ICBO ZXN0ZWQgTG9vcCAgKGNvc3Q9MzE0MTgxLjE3Li4zNzA0MjkuMjkgcm93cz0x IHdpZHRoPTQ4NSkgKGFjdHVhbCB0aW1lPTExNDgxNjcuNDguLjExNjg2NzEu NDUgcm93cz01IGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAg IEpvaW4gRmlsdGVyOiAoImlubmVyIi5iYXRjaGRldGFpbGlkID0gIm91dGVy Ii5iYXRjaGRldGFpbGlkKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAt PiAgTmVzdGVkIExvb3AgIChjb3N0PTMxNDE4MS4xNy4uMzcwMzk2Ljc5IHJv d3M9MSB3aWR0aD00NzYpIChhY3R1YWwgdGltZT0xMTQ4MTY3LjQxLi4xMTY4 NjcxLjA4IHJvd3M9NSBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBKb2luIEZpbHRlcjogKCJpbm5lciIuYmF0Y2hkZXRhaWxp ZCA9ICJvdXRlciIuYmF0Y2hkZXRhaWxpZCkNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgLT4gIE5lc3RlZCBMb29wICAoY29zdD0zMTQxODEu MTcuLjMxNDQwMi40NyByb3dzPTEgd2lkdGg9NDU3KSAoYWN0dWFsIHRpbWU9 MTEzOTA5OS4zOS4uMTEzOTMyMC43OSByb3dzPTUgbG9vcHM9MSkNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6 ICgib3V0ZXIiLmNhcmR0eXBlaWQgPSAiaW5uZXIiLmNhcmR0eXBlaWQpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBNZXJn ZSBKb2luICAoY29zdD0zMTQxODEuMTcuLjMxNDQwMS4yNCByb3dzPTEgd2lk dGg9NDQzKSAoYWN0dWFsIHRpbWU9MTEzODkxMi4xMy4uMTEzOTEzMy4wMCBy b3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgTWVyZ2UgQ29uZDogKCJvdXRlciIuYmF0Y2hpZCA9 ICJpbm5lciIuYmF0Y2hpZCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgLT4gIFNvcnQgIChjb3N0PTEyNzQxOC41OS4u MTI3NDE4LjU5IHJvd3M9MyB3aWR0aD0xNTApIChhY3R1YWwgdGltZT05Njgx LjkxLi45NjgxLjkzIHJvd3M9MTcgbG9vcHM9MSkNCiAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU29ydCBLZXk6 IGIuYmF0Y2hpZA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAtPiAgSGFzaCBKb2luICAoY29zdD0xMjA3ODcu MzIuLjEyNzQxOC41NiByb3dzPTMgd2lkdGg9MTUwKSAoYWN0dWFsIHRpbWU9 NzcwOC4wNC4uOTY4MS44MyByb3dzPTE3IGxvb3BzPTEpDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IEhhc2ggQ29uZDogKCJvdXRlciIubWVyY2hhbnRpZCA9ICJpbm5lciIubWVy Y2hhbnRpZCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgLT4gIE1lcmdlIEpvaW4gIChjb3N0PTEy MDc4MS41OC4uMTI1OTk0LjgwIHJvd3M9MjgzNTk3IHdpZHRoPTcyKSAoYWN0 dWFsIHRpbWU9NzY1NS41Ny4uOTMyMC40OSByb3dzPTIxMzM4NyBsb29wcz0x KQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBNZXJnZSBDb25kOiAoIm91dGVyIi50cmFu aGVhZGVyaWQgPSAiaW5uZXIiLnRyYW5oZWFkZXJpZCkNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcgdHJhbmhlYWRlcl9peF90cmFu aGVhZGVyaWRfaWR4IG9uIHRyYW5oZWFkZXIgdCAgKGNvc3Q9MC4wMC4uMTIx LjE1IHJvd3M9MTkyMyB3aWR0aD0xNikgKGFjdHVhbCB0aW1lPTAuMTUuLjEw Ljg2IHJvd3M9MTkyMyBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBGaWx0ZXI6IChjbGllbnRpZCA9IDYpDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ ICBTb3J0ICAoY29zdD0xMjA3ODEuNTguLjEyMTU1Mi44OCByb3dzPTMwODUy MCB3aWR0aD01NikgKGFjdHVhbCB0aW1lPTc2MTEuNzUuLjgxNjIuODEgcm93 cz0zMjk0MzEgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU29y dCBLZXk6IGIudHJhbmhlYWRlcmlkDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IC0+ICBTZXEgU2NhbiBvbiBiYXRjaGhlYWRlciBiICAoY29zdD0wLjAwLi43 OTU4Ny4yMyByb3dzPTMwODUyMCB3aWR0aD01NikgKGFjdHVhbCB0aW1lPTAu OTAuLjQxODYuMzAgcm93cz0zMjk0MzEgbG9vcHM9MSkNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgRmlsdGVyOiAoYmF0Y2hkYXRlID4gJzIwMDIt MTItMTUgMDA6MDA6MDAnOjp0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUp DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIC0+ICBIYXNoICAoY29zdD01Ljc0Li41Ljc0IHJvd3M9 MSB3aWR0aD03OCkgKGFjdHVhbCB0aW1lPTMxLjM5Li4zMS4zOSByb3dzPTAg bG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNp bmcgbWVyY2hhbnRzX2l4X21lcmNoaWRfaWR4IG9uIG1lcmNoYW50cyBtICAo Y29zdD0wLjAwLi41Ljc0IHJvd3M9MSB3aWR0aD03OCkgKGFjdHVhbCB0aW1l PTMxLjM4Li4zMS4zOCByb3dzPTEgbG9vcHM9MSkNCiAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgSW5kZXggQ29uZDogKG1lcmNoaWQgPSAnNzAxMjUyMjY3Jzo6 Y2hhcmFjdGVyIHZhcnlpbmcpDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIC0+ICBTb3J0ICAoY29zdD0xODY3NjIuNTku LjE4Njg3Mi42MiByb3dzPTQ0MDEwIHdpZHRoPTI5MykgKGFjdHVhbCB0aW1l PTExMjc4MjguOTYuLjExMjg3MjUuMzkgcm93cz0zNjg2ODEgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgU29ydCBLZXk6IGQuYmF0Y2hpZA0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgSW5kZXggU2Nh biB1c2luZyBiYXRjaGRldGFpbF9peF90cmFuYW1vdW50X2lkeCBvbiBiYXRj aGRldGFpbCBkICAoY29zdD0wLjAwLi4xNzY3NjguMTggcm93cz00NDAxMCB3 aWR0aD0yOTMpIChhY3R1YWwgdGltZT0zNS40OC4uMTEwNDYyNS41NCByb3dz PTM3MDMwNyBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKHRy YW5hbW91bnQgPj0gNTAwLjApIEFORCAodHJhbmFtb3VudCA8PSA3MDAuMCkp DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBT ZXEgU2NhbiBvbiBjYXJkdHlwZSBjICAoY29zdD0wLjAwLi4xLjEwIHJvd3M9 MTAgd2lkdGg9MTQpIChhY3R1YWwgdGltZT0zNy40NC4uMzcuNDcgcm93cz0x MCBsb29wcz01KQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAt PiAgU2VxIFNjYW4gb24gcHVyYzEgcDEgIChjb3N0PTAuMDAuLjQ0MjU5Ljcw IHJvd3M9OTM4NzcwIHdpZHRoPTE5KSAoYWN0dWFsIHRpbWU9OTguMDkuLjQx ODcuMzIgcm93cz05Mzg3NzAgbG9vcHM9NSkNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIGRpcmVjdCBkciAgKGNvc3Q9MC4w MC4uMjAuMDAgcm93cz0xMDAwIHdpZHRoPTkpIChhY3R1YWwgdGltZT0wLjAw Li4wLjAwIHJvd3M9MCBsb29wcz01KQ0KICAgICAgICAgICAgICAgICAgICAt PiAgU2VxIFNjYW4gb24gY2FycmVudGFsIGNyICAoY29zdD0wLjAwLi4yMC4w MCByb3dzPTEwMDAgd2lkdGg9MTcpIChhY3R1YWwgdGltZT0wLjAwLi4wLjAw IHJvd3M9MCBsb29wcz01KQ0KICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4g b24gY2hlY2tzIGNrICAoY29zdD0wLjAwLi40MC42NyByb3dzPTEyNjcgd2lk dGg9MzgpIChhY3R1YWwgdGltZT0xLjAzLi43LjYzIHJvd3M9MTI2NyBsb29w cz01KQ0KVG90YWwgcnVudGltZTogMTE2ODg4MS4xMiBtc2VjDQo= From pgsql-performance-owner@postgresql.org Wed Jan 15 14:58:32 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CFBAF476672 for ; Wed, 15 Jan 2003 14:58:31 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 97AF6477391 for ; Wed, 15 Jan 2003 14:08:27 -0500 (EST) Received: from klaster.net (pc148.krakow.cvx.ppp.tpnet.pl [213.76.38.148]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id C7BCA2B2AE; Wed, 15 Jan 2003 20:05:15 +0100 (CET) Message-ID: <3E25B29C.9040408@klaster.net> Date: Wed, 15 Jan 2003 20:12:28 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: PgSQL Performance ML Subject: Re: complicated queries in pl/pgsql References: <3E23EC83.9060802@klaster.net> <200301131044.50424.josh@agliodbs.com> In-Reply-To: <3E23EC83.9060802@klaster.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/118 X-Sequence-Number: 765 Josh Berkus wrote: > Tomasz, > > > >What happens to view planning - is it performed > >during view creation, or rather each time view is quered? > > > Each time the view is executed. The only savings in running a view over a > regular query is that the view will have taken care of some reference > expansion and JOIN explication during the CREATE process, but not planning. > Also, views can actually be slower if the view is complex enough that any > query-time parameters cannot be "pushed down" into the view. Thanks a lot. I'm asking, because I use some queries which are easy to change into views. Most of their execution time takes planning, they use 5-10 explicit table joins with not too many rows in these tables and returns few values. Now I know, that queries inside pl/pgsql functions are better in these situations: - complex queries whith deep parameters - execution several times during conection lifetime. Can anyone add something? Tomasz Myrta From pgsql-performance-owner@postgresql.org Wed Jan 15 15:14:32 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8560B476171 for ; Wed, 15 Jan 2003 15:14:31 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id ACD80477031 for ; Wed, 15 Jan 2003 14:27:29 -0500 (EST) Received: from klaster.net (pe106.krakow.cvx.ppp.tpnet.pl [213.76.40.106]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id CF6E42B2AE; Wed, 15 Jan 2003 20:24:20 +0100 (CET) Message-ID: <3E25B716.4090401@klaster.net> Date: Wed, 15 Jan 2003 20:31:34 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Roman Fail Cc: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/119 X-Sequence-Number: 766 Roman Fail wrote: EXPLAIN ANALYZE RESULTS: Limit (cost=370518.31..370518.31 rows=1 width=540) (actual time=1168722.18..1168722.20 rows=5 loops=1) -> Sort (cost=370518.31..370518.31 rows=1 width=540) (actual time=1168722.18..1168722.18 rows=5 loops=1) Sort Key: b.batchdate -> Nested Loop (cost=314181.17..370518.30 rows=1 width=540) (actual time=1148191.12..1168722.09 rows=5 loops=1) Join Filter: ("inner".batchdetailid = "outer".batchdetailid) -> Nested Loop (cost=314181.17..370461.79 rows=1 width=502) (actual time=1148167.55..1168671.80 rows=5 loops=1) Join Filter: ("inner".batchdetailid = "outer".batchdetailid) -> Nested Loop (cost=314181.17..370429.29 rows=1 width=485) (actual time=1148167.48..1168671.45 rows=5 loops=1) Join Filter: ("inner".batchdetailid = "outer".batchdetailid) -> Nested Loop (cost=314181.17..370396.79 rows=1 width=476) (actual time=1148167.41..1168671.08 rows=5 loops=1) Join Filter: ("inner".batchdetailid = "outer".batchdetailid) -> Nested Loop (cost=314181.17..314402.47 rows=1 width=457) (actual time=1139099.39..1139320.79 rows=5 loops=1) Join Filter: ("outer".cardtypeid = "inner".cardtypeid) -> Merge Join (cost=314181.17..314401.24 rows=1 width=443) (actual time=1138912.13..1139133.00 rows=5 loops=1) Merge Cond: ("outer".batchid = "inner".batchid) -> Sort (cost=127418.59..127418.59 rows=3 width=150) (actual time=9681.91..9681.93 rows=17 loops=1) Sort Key: b.batchid -> Hash Join (cost=120787.32..127418.56 rows=3 width=150) (actual time=7708.04..9681.83 rows=17 loops=1) Hash Cond: ("outer".merchantid = "inner".merchantid) -> Merge Join (cost=120781.58..125994.80 rows=283597 width=72) (actual time=7655.57..9320.49 rows=213387 loops=1) Merge Cond: ("outer".tranheaderid = "inner".tranheaderid) -> Index Scan using tranheader_ix_tranheaderid_idx on tranheader t (cost=0.00..121.15 rows=1923 width=16) (actual time=0.15..10.86 rows=1923 loops=1) Filter: (clientid = 6) -> Sort (cost=120781.58..121552.88 rows=308520 width=56) (actual time=7611.75..8162.81 rows=329431 loops=1) Sort Key: b.tranheaderid -> Seq Scan on batchheader b (cost=0.00..79587.23 rows=308520 width=56) (actual time=0.90..4186.30 rows=329431 loops=1) Filter: (batchdate > '2002-12-15 00:00:00'::timestamp without time zone) -> Hash (cost=5.74..5.74 rows=1 width=78) (actual time=31.39..31.39 rows=0 loops=1) -> Index Scan using merchants_ix_merchid_idx on merchants m (cost=0.00..5.74 rows=1 width=78) (actual time=31.38..31.38 rows=1 loops=1) Index Cond: (merchid = '701252267'::character varying) -> Sort (cost=186762.59..186872.62 rows=44010 width=293) (actual time=1127828.96..1128725.39 rows=368681 loops=1) Sort Key: d.batchid -> Index Scan using batchdetail_ix_tranamount_idx on batchdetail d (cost=0.00..176768.18 rows=44010 width=293) (actual time=35.48..1104625.54 rows=370307 loops=1) Index Cond: ((tranamount >= 500.0) AND (tranamount <= 700.0)) -> Seq Scan on cardtype c (cost=0.00..1.10 rows=10 width=14) (actual time=37.44..37.47 rows=10 loops=5) -> Seq Scan on purc1 p1 (cost=0.00..44259.70 rows=938770 width=19) (actual time=98.09..4187.32 rows=938770 loops=5) -> Seq Scan on direct dr (cost=0.00..20.00 rows=1000 width=9) (actual time=0.00..0.00 rows=0 loops=5) -> Seq Scan on carrental cr (cost=0.00..20.00 rows=1000 width=17) (actual time=0.00..0.00 rows=0 loops=5) -> Seq Scan on checks ck (cost=0.00..40.67 rows=1267 width=38) (actual time=1.03..7.63 rows=1267 loops=5) Total runtime: 1168881.12 msec It looks like your execution time is not a hardware, but query problem. Query nearly doesn't use indexes at all. You said, that that you have normalized database, so you should have a lot of explicit joins, which work pretty well on Postgresql. Can you add some examples of your queries? If it is difficult for you, at least create one example, when you get "Join Filter" on "explain analyze". From your analyze result: Seq Scan on batchheader b (cost=0.00..79587.23 rows=308520 width=56) Can you write what condition and indexes does batchheader have? Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Wed Jan 15 15:37:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DB4E4477423 for ; Wed, 15 Jan 2003 15:37:16 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id C068A477240 for ; Wed, 15 Jan 2003 14:44:01 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id DE0EDD60D; Wed, 15 Jan 2003 11:44:01 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id D3D555C02; Wed, 15 Jan 2003 11:44:01 -0800 (PST) Date: Wed, 15 Jan 2003 11:44:01 -0800 (PST) From: Stephan Szabo To: Roman Fail Cc: Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> Message-ID: <20030115113159.F91182-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/121 X-Sequence-Number: 768 On Wed, 15 Jan 2003, Roman Fail wrote: > The disks are not reading at max speed during the query - when I ran a > VACUUM ANALYZE (after data migration), sar -b was consistently 100,000 > block reads/sec. It does not seem like the hardware is holding back > things here. I read something about 'fsync' recently, would changing > that setting apply in this case? You ran vacuum analyze, but some of the explain still looks suspiciously like it's using default statistics (dr and cr for example, unless they really do have 1000 rows). What are the actual query and table definitions for the query? From pgsql-performance-owner@postgresql.org Wed Jan 15 15:51:19 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1C5D3477494 for ; Wed, 15 Jan 2003 15:51:17 -0500 (EST) Received: from jester.senspire.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id D075D476C5B for ; Wed, 15 Jan 2003 14:53:01 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0FJrC57055306; Wed, 15 Jan 2003 14:53:12 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: 7.3.1 New install, large queries are slow From: Rod Taylor To: Roman Fail Cc: Pgsql Performance In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-TKYLVvCycETYl5CgONyR" Organization: Message-Id: <1042660391.61110.36.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 15 Jan 2003 14:53:11 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/122 X-Sequence-Number: 769 --=-TKYLVvCycETYl5CgONyR Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I didn't see the query itself in the message, but it looks to me like it's poorly formed. Could you send it?=20 By quick glance, either you're using a bunch of explicit joins that are poorly formed (you've made a bad choice in order) or those particular IDs are really popular. There are a number of sequential scans that possibly should be index scans. > EXPLAIN ANALYZE RESULTS: > Limit (cost=3D370518.31..370518.31 rows=3D1 width=3D540) (actual time=3D= 1168722.18..1168722.20 rows=3D5 loops=3D1) > -> Sort (cost=3D370518.31..370518.31 rows=3D1 width=3D540) (actual ti= me=3D1168722.18..1168722.18 rows=3D5 loops=3D1) > Sort Key: b.batchdate --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-TKYLVvCycETYl5CgONyR 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 (FreeBSD) iD8DBQA+Jbwm6DETLow6vwwRAvdWAJ9babghSXR90MBRe5c/J0iYvmEi5QCcD7WL 37Udyk8vi5YZ+LBBPM0vif4= =ZuPQ -----END PGP SIGNATURE----- --=-TKYLVvCycETYl5CgONyR-- From pgsql-performance-owner@postgresql.org Wed Jan 15 16:03:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 313C44770AD for ; Wed, 15 Jan 2003 16:03:35 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 0C1E2477070 for ; Wed, 15 Jan 2003 15:10:12 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18YtrY-0005zb-00 for ; Wed, 15 Jan 2003 15:10:12 -0500 Date: Wed, 15 Jan 2003 15:10:12 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030115151012.A21930@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com>; from rfail@posportal.com on Wed, Jan 15, 2003 at 10:00:04AM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/123 X-Sequence-Number: 770 On Wed, Jan 15, 2003 at 10:00:04AM -0800, Roman Fail wrote: > I have a query that does many joins (including two very big tables) > which is slow on Postgres. On PGSQL the query takes 19 minutes, There are three things I can think of right off the bat. First, the performance of foreign keys is flat-out awful in Postgres. I suggest avoiding them if you can. Second, ordering joins explicitly (with the JOIN keyword) constrains the planner, and may select bad plan. The explain analyse output was nice, but I didn't see the query, so I can't tell what the plan maybe ought to be. Third, I didn't see any suggestion that you'd moved the WAL onto its own disk. That will mostly help when you are under write load; I guess it's not a problem here, but it's worth keeping in mind. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Wed Jan 15 16:46:14 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8B843476609 for ; Wed, 15 Jan 2003 16:38:03 -0500 (EST) Received: from rh72.home.ee (unknown [194.204.44.121]) by postgresql.org (Postfix) with ESMTP id 24CD7475DD0 for ; Wed, 15 Jan 2003 15:43:10 -0500 (EST) Received: from rh72.home.ee (localhost.localdomain [127.0.0.1]) by rh72.home.ee (8.12.5/8.12.5) with ESMTP id h0FKh5Dv002012; Thu, 16 Jan 2003 01:43:06 +0500 Received: (from hannu@localhost) by rh72.home.ee (8.12.5/8.12.5/Submit) id h0FKh0cC002010; Thu, 16 Jan 2003 01:43:00 +0500 X-Authentication-Warning: rh72.home.ee: hannu set sender to hannu@tm.ee using -f Subject: Re: 7.3.1 New install, large queries are slow From: Hannu Krosing To: Roman Fail Cc: pgsql-performance@postgresql.org In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1042663379.1951.1.camel@rh72.home.ee> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 16 Jan 2003 01:42:59 +0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/125 X-Sequence-Number: 772 Roman Fail kirjutas K, 15.01.2003 kell 23:00: > I am trying to get a PostgreSQL server into production (moving from MSSQL2K) but having some serious performance issues. PostgreSQL is new to me, and I'm only just now comfortable with Linux. So far I've succesfully compiled postgres from source and migrated all the data from MSSQL. Postgres is primarily accessed using JDBC. > > I really want to use Postgres for production, but if I can't get better results out of it by the end of the week we are dropping it forever and going back to MSSQL despite the $$$. I'm basically at a point where I've got to find help from the list. Please help me make this server fly! > > I have a query that does many joins (including two very big tables) which is slow on Postgres. On PGSQL the query takes 19 minutes, but only 3 seconds on MSSQL. The two servers have the same indexes created (including primary key indexes). I finally gave up on creating all the foreign keys in Postgres - after 12 hours of 100% CPU. It's hard for me to believe that the hardware is the bottleneck - the $20k Postgres server far outclasses the MSSQL server (see below for stats). When I ran EXPLAIN ANALYZE for this query the CPU averaged 5%, sar -b shows about 6,000 block reads/sec, and vmstat had zero swapping. EXPLAIN results are below, I'm not sure how to interpret them. > Two questions: 1) Have you run analyze on this database (after loading the data ?) 2) could you also post the actual query - it would make interpreting the EXPLAIN ANALYZE RESULTS easier. -- Hannu Krosing From pgsql-performance-owner@postgresql.org Wed Jan 15 21:03:06 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0402347671F for ; Wed, 15 Jan 2003 19:08:00 -0500 (EST) Received: from pos_pdc.posportal.com (unknown [12.158.169.100]) by postgresql.org (Postfix) with ESMTP id 3C17C4770C0 for ; Wed, 15 Jan 2003 18:30:53 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Re: 7.3.1 New install, large queries are slow Date: Wed, 15 Jan 2003 15:30:55 -0800 Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] 7.3.1 New install, large queries are slow Thread-Index: AcK8zJAtURIYvO7lT4yitE5PKXLVXwAB6nQw From: "Roman Fail" To: , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/126 X-Sequence-Number: 773 VGhhbmtzIHRvIGV2ZXJ5b25lIGZvciB0aGUgcXVpY2sgcmVwbGllcyEgIEkn bSBzdXJlIHRoYXQgbXkgbGFjayBvZiBza2lsbCB3aXRoIFNRTCBxdWVyaWVz IGlzIHRoZSBtYWluIHByb2JsZW0uICBXaGF0J3Mgc3RyYW5nZSB0byBtZSBp cyBob3cgTVNTUUwgdGFrZXMgbXkgYmFkIHF1ZXJpZXMgYW5kIG1ha2VzIHRo ZW0gbG9vayBnb29kIGFueXdheS4gIEl0IG11c3QgaGF2ZSBhIHJlYWwgc21h cnQgcGxhbm5lci4NCiANClNldmVyYWwgY2hhbmdlczogIHNoYXJlZF9idWZm ZXJzID0gMTMxMDcyLCBzb3J0X21lbSA9IDMyNzY4LCBzaG1tYXggPSAyMDk3 MTUyMDAwLCBzaG1hbGwgPSAxMzEwNzIwMDAuICBJIGNvdWxkbid0IGZpbmQg YW55IGluZm8gb3V0IHRoZXJlIG9uIHRoZSByZWxhdGlvbnNoaXAgYmV0d2Vl biBzaG1tYXggYW5kIHNobWFsbCwgc28gSSBqdXN0IHByZXNlcnZlZCB0aGUg cmF0aW8gZnJvbSB0aGUgUmVkSGF0IGRlZmF1bHRzICgxOjE2KS4gIEFzIGZh ciBhcyBzb3J0X21lbSBnb2VzLCBJIGV4cGVjdCB0byBiZSBydW5uaW5nIG5v IG1vcmUgdGhhbiAzIGNvbmN1cnJlbnQgcXVlcmllcyBhbmQgdGhleSB3aWxs IGFsbCBiZSBqdXN0IGFzIGNvbXBsZXggYXMgdGhpcyBvbmUuICBEbyB5b3Ug dGhpbmsgc29ydF9tZW09MzI3NjggaXMgYSByZWFzb25hYmxlIHNpemU/ICBO b25lIG9mIHRoZXNlIGNoYW5nZXMgc2VlbWVkIHRvIGhlbHAgc3BlZWQgdXAg dGhpbmdzIGhvd2V2ZXIuDQogDQpSRUlOREVYIElOREVYIGJhdGNoZGV0YWls X2l4X3RyYW5hbW91bnRfaWR4OyAgICB3YXMgZXhlY3V0ZWQgc3VjY2Vzc2Z1 bGx5LCBhbHRob3VnaCBpdCB0b29rIDE1IG1pbnV0ZXMuDQpBTkFMWVpFIGV4 ZWN1dGVkIGluIDIgbWludXRlcywgZXZlbiB0aG91Z2ggSSBpbmNyZWFzZWQg ZGVmYXVsdF9zdGF0aXN0aWNzX3RhcmdldCA9IDMwLiAgU2hvdWxkIEkgaW5j cmVhc2UgaXQgZXZlbiBtb3JlPyAgSSBkb24ndCBtaW5kIHRoZSBleHRyYSBv dmVyaGVhZCBlYWNoIG5pZ2h0IGlmIGl0IHdpbGwgbWFrZSBteSBxdWVyaWVz IGZhc3Rlci4gIChJZGlvdCBjaGVjazogSSBkaWQgYWN0dWFsbHkgc3RvcCBh bmQgc3RhcnQgdGhlIHBvc3RtYXN0ZXIgYWZ0ZXIgY2hhbmdpbmcgYWxsIHRo ZXNlIHNldHRpbmdzKS4NCiANCkFuZHJldyBTdWxsaXZhbiB3cm90ZToNCj5G aXJzdCwgdGhlIHBlcmZvcm1hbmNlIG9mIGZvcmVpZ24ga2V5cyBpcyBmbGF0 LW91dCBhd2Z1bCBpbiBQb3N0Z3Jlcy4NCj5JIHN1Z2dlc3QgYXZvaWRpbmcg dGhlbSBpZiB5b3UgY2FuLg0KDQpJIGRvbid0IGhhdmUgYW55IHByb2JsZW0g Z2V0dGluZyByaWQgb2YgRktzLCBlc3BlY2lhbGx5IGlmIGl0IG1pZ2h0IGFj dHVhbGx5IGhlbHAgcGVyZm9ybWFuY2UuICBUaGUgbmlnaHRseSBkYXRhIGlt cG9ydCBpcyB3ZWxsLWRlZmluZWQgYW5kIHNob3VsZCBhbHdheXMgb2JzZXJ2 ZSByZWZlcmVudGlhbCBpbnRlZ3JpdHksIHNvIEkgZ3Vlc3MgdGhlIGRiIGRv ZXNuJ3QgcmVhbGx5IG5lZWQgdG8gZW5mb3JjZSBpdC4gIEluIE1TU1FMLCBh ZGRpbmcgRktzIHdhcyBzdXBwb3NlZCB0byBhY3R1YWxseSBiZW5lZml0IFNF TEVDVCBwZXJmb3JtYW5jZS4gIElzIGl0IHByZXR0eSBtdWNoIHVuaXZlcnNh bGx5IGFjY2VwdGVkIHRoYXQgSSBzaG91bGQgZHJvcCBhbGwgbXkgZm9yZWln biBrZXlzPw0KDQo+U2Vjb25kLCBvcmRlcmluZyBqb2lucyBleHBsaWNpdGx5 ICh3aXRoIHRoZSBKT0lOIGtleXdvcmQpIGNvbnN0cmFpbnMNCj50aGUgcGxh bm5lciwgYW5kIG1heSBzZWxlY3QgIGJhZCBwbGFuLiAgVGhlIGV4cGxhaW4g YW5hbHlzZSBvdXRwdXQNCj53YXMgbmljZSwgYnV0IEkgZGlkbid0IHNlZSB0 aGUgcXVlcnksIHNvIEkgY2FuJ3QgdGVsbCB3aGF0IHRoZSBwbGFuDQo+bWF5 YmUgb3VnaHQgdG8gYmUuDQoNCkkgdGhpbmsgdGhpcyBpcyB0aGUgbW9zdCBs aWtlbHkgcHJvYmxlbS4gIEkndmUgcmVhZCB0aHJvdWdoIENoYXB0ZXIgMTAg b2YgdGhlIDcuMyBkb2NzLCBidXQgSSBzdGlsbCBkb24ndCBmZWVsIGxpa2Ug SSBrbm93IHdoYXQgd291bGQgYmUgYSBnb29kIG9yZGVyLiAgSG93IGRvIHlv dSBsZWFybiB0aGlzIHN0dWZmIGFueXdheT8gIFRyaWFsIGFuZCBlcnJvcj8N Cg0KPlRoaXJkLCBJIGRpZG4ndCBzZWUgYW55IHN1Z2dlc3Rpb24gdGhhdCB5 b3UnZCBtb3ZlZCB0aGUgV0FMIG9udG8gaXRzDQo+b3duIGRpc2suICBUaGF0 IHdpbGwgbW9zdGx5IGhlbHAgd2hlbiB5b3UgYXJlIHVuZGVyIHdyaXRlIGxv YWQ7DQoNCkkgZG9uJ3QgdGhpbmsgSSdtIGdvaW5nIHRvIGJvdGhlciB3aXRo IG1vdmluZyB0aGUgV0FMLi4uLnRoZSB3cml0ZSBsb2FkIGR1cmluZyB0aGUg ZGF5IGlzIHZlcnksIHZlcnkgbGlnaHQgKHdoZW4gcXVlcmllcyBhcmUgcnVu KS4gICBEaXNrIEkvTyBpcyBjbGVhcmx5IG5vdCB0aGUgbGltaXRpbmcgZmFj dG9yICh5ZXQhKS4gIA0KIA0KU28gaGVyZSdzIHRoZSBxdWVyeSwgYW5kIGFu b3RoZXIgRVhQTEFJTiBBTkFMWVpFIHRvIGdvIHdpdGggaXQgKGV4ZWN1dGVk IGFmdGVyIGFsbCBzZXR0aW5nIGNoYW5nZXMpLiAgVGhlIHNhbWUgcmVzdWx0 IGNvbHVtbnMgYW5kIEpPSU5TIGFyZSBwZXJmb3JtZWQgYWxsIGRheSB3aXRo IHZhcmlhdGlvbnMgb24gdGhlIFdIRVJFIGNsYXVzZTsgb3RoZXIgcG9zc2li bGUgc2VhcmNoIGNvbHVtbnMgYXJlIHRoZSBvbmVzIHRoYXQgYXJlIGluZGV4 ZWQgKHNlZSBiZWxvdykuICBUaGUgNCB0YWJsZXMgdGhhdCB1c2UgTEVGVCBK T0lOIG9ubHkgc29tZXRpbWVzIGhhdmUgbWF0Y2hpbmcgcmVjb3JkcywgaGVu Y2UgdGhlIE9VVEVSIGpvaW4uDQogDQpFWFBMQUlOIEFOQUxZWkUNClNFTEVD VCBiLmJhdGNoZGF0ZSwgZC5iYXRjaGRldGFpbGlkLCB0LmJhbmtubywgZC50 cmFuZGF0ZSwgZC50cmFuYW1vdW50LCANCmQuc3VibWl0aW50ZXJjaGFuZ2Us IGQuYXV0aGFtb3VudCwgZC5hdXRobm8sIGQuY2FyZHR5cGVpZCwgZC5tY2Nj b2RlLCANCm0ubmFtZSBBUyBtZXJjaGFudG5hbWUsIGMuY2FyZHR5cGUsIG0u bWVyY2hpZCwgDQpwMS5sb2NhbHRheGFtb3VudCwgcDEucHJvZHVjdGlkZW50 aWZpZXIsIGRyLmF2c3Jlc3BvbnNlLCANCmNyLmNoZWNrb3V0ZGF0ZSwgY3Iu bm9zaG93aW5kaWNhdG9yLCBjay5jaGVja2luZ2FjY3RubywgDQpjay5hYmFy b3V0aW5nbm8sIGNrLmNoZWNrbm8gDQpGUk9NIHRyYW5oZWFkZXIgdCANCklO TkVSIEpPSU4gYmF0Y2hoZWFkZXIgYiBPTiB0LnRyYW5oZWFkZXJpZCA9IGIu dHJhbmhlYWRlcmlkIA0KSU5ORVIgSk9JTiBtZXJjaGFudHMgbSBPTiBtLm1l cmNoYW50aWQgPSBiLm1lcmNoYW50aWQgDQpJTk5FUiBKT0lOIGJhdGNoZGV0 YWlsIGQgT04gZC5iYXRjaGlkID0gYi5iYXRjaGlkIA0KSU5ORVIgSk9JTiBj YXJkdHlwZSBjIE9OIGQuY2FyZHR5cGVpZCA9IGMuY2FyZHR5cGVpZCANCkxF RlQgSk9JTiBwdXJjMSBwMSBPTiBwMS5iYXRjaGRldGFpbGlkID0gZC5iYXRj aGRldGFpbGlkIA0KTEVGVCBKT0lOIGRpcmVjdCBkciBPTiBkci5iYXRjaGRl dGFpbGlkID0gZC5iYXRjaGRldGFpbGlkIA0KTEVGVCBKT0lOIGNhcnJlbnRh bCBjciBPTiBjci5iYXRjaGRldGFpbGlkID0gZC5iYXRjaGRldGFpbGlkIA0K TEVGVCBKT0lOIGNoZWNrcyBjayBPTiBjay5iYXRjaGRldGFpbGlkID0gZC5i YXRjaGRldGFpbGlkIA0KV0hFUkUgdC5jbGllbnRpZCA9IDYgDQpBTkQgZC50 cmFuYW1vdW50IEJFVFdFRU4gNTAwLjAgQU5EIDcwMC4wIA0KQU5EIGIuYmF0 Y2hkYXRlID4gJzIwMDItMTItMTUnIA0KQU5EIG0ubWVyY2hpZCA9ICc3MDEy NTIyNjcnIA0KT1JERVIgQlkgYi5iYXRjaGRhdGUgREVTQyANCkxJTUlUIDUw DQoNCkxpbWl0ICAoY29zdD0xODI5OTcyLjM5Li4xODI5OTcyLjM5IHJvd3M9 MSB3aWR0aD0yODUpIChhY3R1YWwgdGltZT0xNTU2NDk3Ljc5Li4xNTU2NDk3 LjgwIHJvd3M9NSBsb29wcz0xKQ0KICAtPiAgU29ydCAgKGNvc3Q9MTgyOTk3 Mi4zOS4uMTgyOTk3Mi4zOSByb3dzPTEgd2lkdGg9Mjg1KSAoYWN0dWFsIHRp bWU9MTU1NjQ5Ny43OC4uMTU1NjQ5Ny43OSByb3dzPTUgbG9vcHM9MSkNCiAg ICAgICAgU29ydCBLZXk6IGIuYmF0Y2hkYXRlDQogICAgICAgIC0+ICBOZXN0 ZWQgTG9vcCAgKGNvc3Q9MTc3MTg3NC4zMi4uMTgyOTk3Mi4zOCByb3dzPTEg d2lkdGg9Mjg1KSAoYWN0dWFsIHRpbWU9MTUzODc4My4wMy4uMTU1NjQ4Ni42 NCByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6 ICgiaW5uZXIiLmJhdGNoZGV0YWlsaWQgPSAib3V0ZXIiLmJhdGNoZGV0YWls aWQpDQogICAgICAgICAgICAgIC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MTc3 MTg3NC4zMi4uMTgyOTkxNS44NyByb3dzPTEgd2lkdGg9MjQ3KSAoYWN0dWFs IHRpbWU9MTUzODc2MC42MC4uMTU1NjQzOS42NyByb3dzPTUgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLmJh dGNoZGV0YWlsaWQgPSAib3V0ZXIiLmJhdGNoZGV0YWlsaWQpDQogICAgICAg ICAgICAgICAgICAgIC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MTc3MTg3NC4z Mi4uMTgyOTkxNS44NiByb3dzPTEgd2lkdGg9MjMwKSAoYWN0dWFsIHRpbWU9 MTUzODc2MC41NS4uMTU1NjQzOS41MCByb3dzPTUgbG9vcHM9MSkNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLmJh dGNoZGV0YWlsaWQgPSAib3V0ZXIiLmJhdGNoZGV0YWlsaWQpDQogICAgICAg ICAgICAgICAgICAgICAgICAgIC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MTc3 MTg3NC4zMi4uMTgyOTkxNS44NSByb3dzPTEgd2lkdGg9MjIxKSAoYWN0dWFs IHRpbWU9MTUzODc2MC41MS4uMTU1NjQzOS4zMSByb3dzPTUgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6 ICgiaW5uZXIiLmJhdGNoZGV0YWlsaWQgPSAib3V0ZXIiLmJhdGNoZGV0YWls aWQpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBOZXN0 ZWQgTG9vcCAgKGNvc3Q9MTc3MTg3NC4zMi4uMTc3Mzg2My44MSByb3dzPTEg d2lkdGg9MjAyKSAoYWN0dWFsIHRpbWU9MTUyOTE1My44NC4uMTUyOTMyOS42 NSByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgib3V0ZXIiLmNhcmR0eXBlaWQg PSAiaW5uZXIiLmNhcmR0eXBlaWQpDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIC0+ICBNZXJnZSBKb2luICAoY29zdD0xNzcxODc0 LjMyLi4xNzczODYyLjU4IHJvd3M9MSB3aWR0aD0xODgpIChhY3R1YWwgdGlt ZT0xNTI5MTQyLjU1Li4xNTI5MzE3Ljk5IHJvd3M9NSBsb29wcz0xKQ0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNZXJn ZSBDb25kOiAoIm91dGVyIi5iYXRjaGlkID0gImlubmVyIi5iYXRjaGlkKQ0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAt PiAgU29ydCAgKGNvc3Q9MTE2MDU4LjQyLi4xMTYwNTguNDMgcm93cz0zIHdp ZHRoPTExOCkgKGFjdHVhbCB0aW1lPTE0MTg0LjExLi4xNDE4NC4xNCByb3dz PTE3IGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIFNvcnQgS2V5OiBiLmJhdGNoaWQNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg LT4gIEhhc2ggSm9pbiAgKGNvc3Q9MTA5MTQzLjQ0Li4xMTYwNTguMzkgcm93 cz0zIHdpZHRoPTExOCkgKGFjdHVhbCB0aW1lPTEyMzk4LjI5Li4xNDE4NC4w MyByb3dzPTE3IGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEhhc2ggQ29uZDogKCJv dXRlciIubWVyY2hhbnRpZCA9ICJpbm5lciIubWVyY2hhbnRpZCkNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgLT4gIE1lcmdlIEpvaW4gIChjb3N0PTEwOTEzNy44MS4uMTE0NTcy Ljk0IHJvd3M9Mjk1OTU3IHdpZHRoPTQwKSAoYWN0dWFsIHRpbWU9MTIzNTku NzUuLjEzODQ4LjY3IHJvd3M9MjEzMzg3IGxvb3BzPTEpDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIE1lcmdlIENvbmQ6ICgib3V0ZXIiLnRyYW5oZWFkZXJpZCA9ICJp bm5lciIudHJhbmhlYWRlcmlkKQ0KICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgSW5k ZXggU2NhbiB1c2luZyB0cmFuaGVhZGVyX2l4X3RyYW5oZWFkZXJpZF9pZHgg b24gdHJhbmhlYWRlciB0ICAoY29zdD0wLjAwLi4xMjEuMTUgcm93cz0xOTIz IHdpZHRoPTE2KSAoYWN0dWFsIHRpbWU9MC4xNy4uMTAuOTEgcm93cz0xOTIz IGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbHRlcjogKGNs aWVudGlkID0gNikNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNvcnQgIChjb3N0 PTEwOTEzNy44MS4uMTA5OTQyLjczIHJvd3M9MzIxOTY2IHdpZHRoPTI0KSAo YWN0dWFsIHRpbWU9MTIzMTcuODMuLjEyODQ4LjQzIHJvd3M9MzI5NDMxIGxv b3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNvcnQgS2V5OiBiLnRy YW5oZWFkZXJpZA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgU2VxIFNj YW4gb24gYmF0Y2hoZWFkZXIgYiAgKGNvc3Q9MC4wMC4uNzk2ODMuNDQgcm93 cz0zMjE5NjYgd2lkdGg9MjQpIChhY3R1YWwgdGltZT0yOS45My4uMTA0MjIu NzUgcm93cz0zMjk0MzEgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgRmlsdGVyOiAoYmF0Y2hkYXRlID4gJzIwMDItMTItMTUgMDA6 MDA6MDAnOjp0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIC0+ICBIYXNoICAoY29zdD01LjYzLi41LjYzIHJvd3M9MSB3aWR0aD03 OCkgKGFjdHVhbCB0aW1lPTIxLjA2Li4yMS4wNiByb3dzPTAgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcgbWVyY2hh bnRzX2l4X21lcmNoaWRfaWR4IG9uIG1lcmNoYW50cyBtICAoY29zdD0wLjAw Li41LjYzIHJvd3M9MSB3aWR0aD03OCkgKGFjdHVhbCB0aW1lPTIxLjA1Li4y MS4wNSByb3dzPTEgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg SW5kZXggQ29uZDogKG1lcmNoaWQgPSAnNzAxMjUyMjY3Jzo6Y2hhcmFjdGVy IHZhcnlpbmcpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIC0+ICBTb3J0ICAoY29zdD0xNjU1ODE1LjkwLi4xNjU2ODEw LjE1IHJvd3M9Mzk3Njk4IHdpZHRoPTcwKSAoYWN0dWFsIHRpbWU9MTUxMzg2 MC43My4uMTUxNDQ5Ny45MiByb3dzPTM2ODY4MSBsb29wcz0xKQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBT b3J0IEtleTogZC5iYXRjaGlkDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5n IGJhdGNoZGV0YWlsX2l4X3RyYW5hbW91bnRfaWR4IG9uIGJhdGNoZGV0YWls IGQgIChjb3N0PTAuMDAuLjE1OTc1MjIuMzggcm93cz0zOTc2OTggd2lkdGg9 NzApIChhY3R1YWwgdGltZT0xNC4wNS4uMTUwNTM5Ny4xNyByb3dzPTM3MDMw NyBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKHRyYW5hbW91 bnQgPj0gNTAwLjApIEFORCAodHJhbmFtb3VudCA8PSA3MDAuMCkpDQogICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2Nh biBvbiBjYXJkdHlwZSBjICAoY29zdD0wLjAwLi4xLjEwIHJvd3M9MTAgd2lk dGg9MTQpIChhY3R1YWwgdGltZT0yLjI1Li4yLjI4IHJvd3M9MTAgbG9vcHM9 NSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBT Y2FuIG9uIHB1cmMxIHAxICAoY29zdD0wLjAwLi40NDI4NS4zNSByb3dzPTk0 MTMzNSB3aWR0aD0xOSkgKGFjdHVhbCB0aW1lPTIuNDAuLjM4MTIuNDMgcm93 cz05Mzg3NzAgbG9vcHM9NSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAg LT4gIFNlcSBTY2FuIG9uIGRpcmVjdCBkciAgKGNvc3Q9MC4wMC4uMC4wMCBy b3dzPTEgd2lkdGg9OSkgKGFjdHVhbCB0aW1lPTAuMDAuLjAuMDAgcm93cz0w IGxvb3BzPTUpDQogICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBv biBjYXJyZW50YWwgY3IgIChjb3N0PTAuMDAuLjAuMDAgcm93cz0xIHdpZHRo PTE3KSAoYWN0dWFsIHRpbWU9MC4wMC4uMC4wMCByb3dzPTAgbG9vcHM9NSkN CiAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIGNoZWNrcyBjayAgKGNv c3Q9MC4wMC4uNDAuNjcgcm93cz0xMjY3IHdpZHRoPTM4KSAoYWN0dWFsIHRp bWU9MC41MC4uNy4wNSByb3dzPTEyNjcgbG9vcHM9NSkNClRvdGFsIHJ1bnRp bWU6IDE1NTY1NTMuNzYgbXNlYw0KDQogDQpUb21hc3ogTXlydGEgd3JvdGU6 DQo+U2VxIFNjYW4gb24gYmF0Y2hoZWFkZXIgYiAgKGNvc3Q9MC4wMC4uNzk1 ODcuMjMgcm93cz0zMDg1MjAgd2lkdGg9NTYpDQo+Q2FuIHlvdSB3cml0ZSB3 aGF0IGNvbmRpdGlvbiBhbmQgaW5kZXhlcyBkb2VzIGJhdGNoaGVhZGVyIGhh dmU/DQogDQpiYXRjaGhlYWRlciBoYXMgMi42IG1pbGxpb24gcmVjb3JkczoN CkNSRUFURSBUQUJMRSBwdWJsaWMuYmF0Y2hoZWFkZXIgKA0KICBiYXRjaGlk IGludDggREVGQVVMVCBuZXh0dmFsKCciYmF0Y2hoZWFkZXJfYmF0Y2hpZF9r ZXkiJzo6dGV4dCkgTk9UIE5VTEwsIA0KICBsaW5lIGludDQsIA0KICB0cmFu aGVhZGVyaWQgaW50NCwgDQogIG1lcmNoYW50aWQgaW50NCwgDQogIGJhdGNo ZGF0ZSB0aW1lc3RhbXAsIA0KICBtZXJjaHJlZiBjaGFyKDE2KSwgDQogIGNh cnJ5aW5kaWNhdG9yIGNoYXIoMSksIA0KICBhc3NvY25vIHZhcmNoYXIoNiks IA0KICBtZXJjaGJhbmtubyBjaGFyKDQpLCANCiAgZGViaXRjcmVkaXQgY2hh cigxKSwgDQogIGFjaHBvc3RkYXRlIHRpbWVzdGFtcCwgDQogIHRyYW5jb2Rl IGNoYXIoNCksIA0KICBuZXRkZXBvc2l0IG51bWVyaWMoMTgsIDQpLCANCiAg Q09OU1RSQUlOVCBiYXRjaGhlYWRlcl9peF9iYXRjaGlkX2lkeCBVTklRVUUg KGJhdGNoaWQpLCANCiAgQ09OU1RSQUlOVCBiYXRjaGhlYWRlcl9wa2V5IFBS SU1BUlkgS0VZIChiYXRjaGlkKSwgDQogIENPTlNUUkFJTlQgZmtfYmhfdGgg Rk9SRUlHTiBLRVkgKHRyYW5oZWFkZXJpZCkgUkVGRVJFTkNFUyB0cmFuaGVh ZGVyICh0cmFuaGVhZGVyaWQpIE9OIERFTEVURSBSRVNUUklDVCBPTiBVUERB VEUgTk8gQUNUSU9OIE5PVCBERUZFUlJBQkxFIElOSVRJQUxMWSBJTU1FRElB VEUNCikgV0lUSCBPSURTOw0KQ1JFQVRFIFVOSVFVRSBJTkRFWCBiYXRjaGhl YWRlcl9peF9iYXRjaGlkX2lkeCBPTiBiYXRjaGhlYWRlciBVU0lORyBidHJl ZSAoYmF0Y2hpZCk7DQpDUkVBVEUgSU5ERVggYmF0Y2hoZWFkZXJfaXhfYmF0 Y2hkYXRlX2lkeCBPTiBiYXRjaGhlYWRlciBVU0lORyBidHJlZSAoYmF0Y2hk YXRlKTsNCkNSRUFURSBJTkRFWCBiYXRjaGhlYWRlcl9peF9tZXJjaGFudGlk X2lkeCBPTiBiYXRjaGhlYWRlciBVU0lORyBidHJlZSAobWVyY2hhbnRpZCk7 DQpDUkVBVEUgSU5ERVggYmF0Y2hoZWFkZXJfaXhfbWVyY2hyZWZfaWR4IE9O IGJhdGNoaGVhZGVyIFVTSU5HIGJ0cmVlIChtZXJjaHJlZik7DQpDUkVBVEUg SU5ERVggYmF0Y2hoZWFkZXJfaXhfbmV0ZGVwb3NpdF9pZHggT04gYmF0Y2ho ZWFkZXIgVVNJTkcgYnRyZWUgKG5ldGRlcG9zaXQpOw0KDQpBbmQgaGVyZSdz IGJhdGNoZGV0YWlsIHRvbywganVzdCBmb3Iga2lja3MuICAyMyBtaWxsaW9u IHJlY29yZHMuDQpDUkVBVEUgVEFCTEUgcHVibGljLmJhdGNoZGV0YWlsICgN CiAgYmF0Y2hkZXRhaWxpZCBpbnQ4IERFRkFVTFQgbmV4dHZhbCgncHVibGlj LmJhdGNoZGV0YWlsX2JhdGNoZGV0YWlsaWRfc2VxJzo6dGV4dCkgTk9UIE5V TEwsIA0KICBsaW5lIGludDQsIA0KICBiYXRjaGlkIGludDQsIA0KICBtZXJj aG5vIHZhcmNoYXIoMTYpLCANCiAgYXNzb2NubyB2YXJjaGFyKDYpLCANCiAg cmVmbnVtYmVyIGNoYXIoMjMpLCANCiAgdHJhbmRhdGUgdGltZXN0YW1wLCAN CiAgdHJhbmFtb3VudCBudW1lcmljKDE4LCA0KSwgDQogIG5ldGRlcG9zaXQg bnVtZXJpYygxOCwgNCksIA0KICBjYXJkbm9jZmIgYnl0ZWEsIA0KICBiZXN0 aW50ZXJjaGFuZ2UgY2hhcigyKSwgDQogIHN1Ym1pdGludGVyY2hhbmdlIGNo YXIoMiksIA0KICBkb3duZ3JhZGVyMSBjaGFyKDQpLCANCiAgZG93bmdyYWRl cjIgY2hhcig0KSwgDQogIGRvd25ncmFkZXIzXzEgY2hhcigxKSwgDQogIGRv d25ncmFkZXIzXzIgY2hhcigxKSwgDQogIGRvd25ncmFkZXIzXzMgY2hhcigx KSwgDQogIGRvd25ncmFkZXIzXzQgY2hhcigxKSwgDQogIGRvd25ncmFkZXIz XzUgY2hhcigxKSwgDQogIGRvd25ncmFkZXIzXzYgY2hhcigxKSwgDQogIGRv d25ncmFkZXIzXzcgY2hhcigxKSwgDQogIG9ubGluZWVudHJ5IGNoYXIoMSks IA0KICBhY2hmbGFnIGNoYXIoMSksIA0KICBhdXRoc291cmNlIGNoYXIoMSks IA0KICBjYXJkaG9sZGVyaWRtZXRoIGNoYXIoMSksIA0KICBjYXRpbmRpY2F0 b3IgY2hhcigxKSwgDQogIHJlaW1iYXR0cmlidXRlIGNoYXIoMSksIA0KICBt b3RvaW5kaWNhdG9yIGNoYXIoMSksIA0KICBhdXRoY2hhcmluZCBjaGFyKDEp LCANCiAgYmFua25ldHJlZm5vIGNoYXIoOSksIA0KICBiYW5rbmV0YXV0aGRh dGUgY2hhcig2KSwgDQogIGRyYWZ0YWZsYWcgY2hhcigxKSwgDQogIGF1dGhj dXJyZW5jeWNvZGUgY2hhcigzKSwgDQogIGF1dGhhbW91bnQgbnVtZXJpYygx OCwgNCksIA0KICB2YWxpZGNvZGUgY2hhcig0KSwgDQogIGF1dGhyZXNwb25z ZWNvZGUgY2hhcigyKSwgDQogIGRlYml0bmV0d29ya2lkIGNoYXIoMyksIA0K ICBzd2l0Y2hzZXRpbmRpY2F0b3IgY2hhcigxKSwgDQogIHBvc2VudHJ5bW9k ZSBjaGFyKDIpLCANCiAgZGViaXRjcmVkaXQgY2hhcigxKSwgDQogIHJldmVy c2FsZmxhZyBjaGFyKDEpLCANCiAgbWVyY2hhbnRuYW1lIHZhcmNoYXIoMjUp LCANCiAgYXV0aG5vIGNoYXIoNiksIA0KICByZWplY3RyZWFzb24gY2hhcig0 KSwgDQogIGNhcmR0eXBlaWQgaW50NCwgDQogIGN1cnJlbmN5Y29kZSBjaGFy KDMpLCANCiAgb3JpZ3RyYW5hbW91bnQgbnVtZXJpYygxOCwgNCksIA0KICBm b3JlaWduY2FyZCBjaGFyKDEpLCANCiAgY2FycnlvdmVyIGNoYXIoMSksIA0K ICBleHRlbnNpb25yZWNvcmQgY2hhcigyKSwgDQogIG1jY2NvZGUgY2hhcig0 KSwgDQogIHRlcm1pbmFsaWQgY2hhcig4KSwgDQogIHN1Ym1pdGludGVyY2hh bmdlM2IgY2hhcigzKSwgDQogIHB1cmNoYXNlaWQgdmFyY2hhcigyNSksIA0K ICB0cmFuY29kZSBjaGFyKDQpLCANCiAgQ09OU1RSQUlOVCBiYXRjaGRldGFp bF9wa2V5IFBSSU1BUlkgS0VZIChiYXRjaGRldGFpbGlkKQ0KKSBXSVRIIE9J RFM7DQpDUkVBVEUgSU5ERVggYmF0Y2hkZXRhaWxfaXhfYXV0aG5vX2lkeCBP TiBiYXRjaGRldGFpbCBVU0lORyBidHJlZSAoYXV0aG5vKTsNCkNSRUFURSBJ TkRFWCBiYXRjaGRldGFpbF9peF9iYXRjaGRldGFpbGlkX2lkeCBPTiBiYXRj aGRldGFpbCBVU0lORyBidHJlZSAoYmF0Y2hkZXRhaWxpZCk7DQpDUkVBVEUg SU5ERVggYmF0Y2hkZXRhaWxfaXhfY2FyZG5vY2ZiX2lkeCBPTiBiYXRjaGRl dGFpbCBVU0lORyBidHJlZSAoY2FyZG5vY2ZiKTsNCkNSRUFURSBJTkRFWCBi YXRjaGRldGFpbF9peF9wb3NlbnRyeW1vZGVfaWR4IE9OIGJhdGNoZGV0YWls IFVTSU5HIGJ0cmVlIChwb3NlbnRyeW1vZGUpOw0KQ1JFQVRFIElOREVYIGJh dGNoZGV0YWlsX2l4X3N1Ym1pdGludGVyY2hhbmdlM2JfaWR4IE9OIGJhdGNo ZGV0YWlsIFVTSU5HIGJ0cmVlIChzdWJtaXRpbnRlcmNoYW5nZTNiKTsNCkNS RUFURSBJTkRFWCBiYXRjaGRldGFpbF9peF90cmFuYW1vdW50X2lkeCBPTiBi YXRjaGRldGFpbCBVU0lORyBidHJlZSAodHJhbmFtb3VudCk7DQogDQpSb21h biBGYWlsDQpTci4gV2ViIEFwcGxpY2F0aW9uIERldmVsb3Blcg0KUE9TIFBv cnRhbCwgSW5jLg0KU2FjcmFtZW50bywgQ0ENCiANCg0KIA0KDQogDQoNCg0K IA0KDQogDQo= From pgsql-performance-owner@postgresql.org Wed Jan 15 22:09:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 784C84765E2 for ; Wed, 15 Jan 2003 21:31:58 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id B1F054772A2 for ; Wed, 15 Jan 2003 21:05:21 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Wed, 15 Jan 2003 18:05:27 -0800 Date: Wed, 15 Jan 2003 18:05:27 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030116020527.GA28172@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BF9@pos_pdc.posportal.com> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/127 X-Sequence-Number: 774 Roman Fail wrote: > I am trying to get a PostgreSQL server into production (moving from > MSSQL2K) but having some serious performance issues. PostgreSQL is > new to me, and I'm only just now comfortable with Linux. So far > I've succesfully compiled postgres from source and migrated all the > data from MSSQL. Postgres is primarily accessed using JDBC. [...] > POSTGRESQL SYSTEM: > Red Hat Linux 8.0, PostgreSQL 7.3.1 (dedicated, besides SSH daemon) > Dell PE6600 Dual Xeon MP 2.0GHz, 2MB L3 cache,HyperThreading enabled > 4.0 GB Physical RAM > /dev/sda1: ext3 101MB /boot > /dev/sda2: ext3 34GB / (sda is 2 disk RAID-1) > none : swap 1.8GB > /dev/sdb1: ext3 104GB /usr/local/pgsql/data (sdb is 6 disk RAID-10) > All 8 drives are 36GB, 15k RPM, Ultra160 SCSI > PERC3/DC 128MB RAID controller Ext3, huh? Ext3 is a journalling filesystem that is capable of journalling data as well as metadata. But if you mount it such that it journals data, writes will be significantly slower. The default for ext3 is to do ordered writes: data is written before the associated metadata transaction commits, but the data itself isn't journalled. But because PostgreSQL synchronously writes the transaction log (using fsync() by default, if I'm not mistaken) and uses sync() during a savepoint, I would think that ordered writes at the filesystem level would probably buy you very little in the way of additional data integrity in the event of a crash. So if I'm right about that, then you might consider using the "data=writeback" option to ext3 on the /usr/local/pgsql/data filesystem. I'd recommend the default ("data=ordered") for everything else. That said, I doubt the above change will make the orders of magnitude difference you're looking for. But every little bit helps... You might also consider experimenting with different filesystems, but others here may be able to chime in with better information on that. People, please correct me if I'm wrong in my analysis of PostgreSQL on ext3 above. If the database on an ext3 filesystem mounted in writeback mode is subject to corruption upon a crash despite the efforts PostgreSQL makes to keep things sane, then writeback mode shouldn't be used! And clearly it shouldn't be used if it doesn't make a significant performance difference. -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Wed Jan 15 22:44:59 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 83AC8476226 for ; Wed, 15 Jan 2003 22:43:33 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 242C447667D for ; Wed, 15 Jan 2003 22:40:00 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 8E30FD60D; Wed, 15 Jan 2003 19:40:04 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 83EA95C02; Wed, 15 Jan 2003 19:40:04 -0800 (PST) Date: Wed, 15 Jan 2003 19:40:04 -0800 (PST) From: Stephan Szabo To: Roman Fail Cc: , Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> Message-ID: <20030115192815.T98147-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/128 X-Sequence-Number: 775 > So here's the query, and another EXPLAIN ANALYZE to go with it > (executed after all setting changes). The same result columns and > JOINS are performed all day with variations on the WHERE clause; other > possible search columns are the ones that are indexed (see below). > The 4 tables that use LEFT JOIN only sometimes have matching records, > hence the OUTER join. > > EXPLAIN ANALYZE > SELECT b.batchdate, d.batchdetailid, t.bankno, d.trandate, d.tranamount, > d.submitinterchange, d.authamount, d.authno, d.cardtypeid, d.mcccode, > m.name AS merchantname, c.cardtype, m.merchid, > p1.localtaxamount, p1.productidentifier, dr.avsresponse, > cr.checkoutdate, cr.noshowindicator, ck.checkingacctno, > ck.abaroutingno, ck.checkno > FROM tranheader t > INNER JOIN batchheader b ON t.tranheaderid = b.tranheaderid > INNER JOIN merchants m ON m.merchantid = b.merchantid > INNER JOIN batchdetail d ON d.batchid = b.batchid > INNER JOIN cardtype c ON d.cardtypeid = c.cardtypeid > LEFT JOIN purc1 p1 ON p1.batchdetailid = d.batchdetailid > LEFT JOIN direct dr ON dr.batchdetailid = d.batchdetailid > LEFT JOIN carrental cr ON cr.batchdetailid = d.batchdetailid > LEFT JOIN checks ck ON ck.batchdetailid = d.batchdetailid > WHERE t.clientid = 6 > AND d.tranamount BETWEEN 500.0 AND 700.0 > AND b.batchdate > '2002-12-15' > AND m.merchid = '701252267' > ORDER BY b.batchdate DESC > LIMIT 50 Well, you might get a little help by replace the from with something like: FROM transheader t, batchheader b, merchants m, cardtype c, batchdetail d LEFT JOIN purc1 p1 on p1.batchdetailid=d.batchdetailid LEFT JOIN direct dr ON dr.batchdetailid = d.batchdetailid LEFT JOIN carrental cr ON cr.batchdetailid = d.batchdetailid LEFT JOIN checks ck ON ck.batchdetailid = d.batchdetailid and adding AND t.tranheaderid=b.tranheaderid AND m.merchantid=b.merchantid AND d.batchid=b.batchid AND c.cardtypeid=d.cardtypeid to the WHERE conditions. That should at least allow it to do some small reordering of the joins. I don't think that alone is going to do much, since most of the time seems to be on the scan of d. What does vacuum verbose batchdetail give you (it'll give an idea of pages anyway) From pgsql-performance-owner@postgresql.org Wed Jan 15 22:46:23 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7DE64475BEC for ; Wed, 15 Jan 2003 22:46:21 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id B64CD47635A for ; Wed, 15 Jan 2003 22:46:11 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 31052D60D; Wed, 15 Jan 2003 19:46:16 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 26BE55C02; Wed, 15 Jan 2003 19:46:16 -0800 (PST) Date: Wed, 15 Jan 2003 19:46:16 -0800 (PST) From: Stephan Szabo To: Roman Fail Cc: , Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> Message-ID: <20030115194528.U98448-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/129 X-Sequence-Number: 776 On Wed, 15 Jan 2003, Roman Fail wrote: > Thanks to everyone for the quick replies! I'm sure that my lack of > skill with SQL queries is the main problem. What's strange to me is > how MSSQL takes my bad queries and makes them look good anyway. It > must have a real smart planner. As a followup, if you do set enable_indexscan=off; before running the explain analyze, what does that give you? From pgsql-performance-owner@postgresql.org Wed Jan 15 23:35:24 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 22181475E23 for ; Wed, 15 Jan 2003 23:35:22 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 880EF475DC0 for ; Wed, 15 Jan 2003 23:35:21 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0G4Z05u011548; Wed, 15 Jan 2003 23:35:00 -0500 (EST) To: "Roman Fail" Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> Comments: In-reply-to "Roman Fail" message dated "Wed, 15 Jan 2003 15:30:55 -0800" Date: Wed, 15 Jan 2003 23:35:00 -0500 Message-ID: <11547.1042691700@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/130 X-Sequence-Number: 777 "Roman Fail" writes: > Thanks to everyone for the quick replies! I'm sure that my lack of > skill with SQL queries is the main problem. What's strange to me is > how MSSQL takes my bad queries and makes them look good anyway. It > must have a real smart planner. I think more likely the issue is that your use of JOIN syntax is forcing Postgres into a bad plan. MSSQL probably doesn't assign any semantic significance to the use of "a JOIN b" syntax as opposed to "FROM a, b" syntax. Postgres does. Whether this is a bug or a feature depends on your point of view --- but there are folks out there who find it to be a life-saver. You can find some explanations at http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit-joins.html > Is it pretty much universally accepted that I should drop all my > foreign keys? No. They don't have any effect on SELECT performance in Postgres. They will impact update speed, but that's not your complaint (at the moment). Don't throw away data integrity protection until you know you need to. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jan 15 23:41:56 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2FC46476673 for ; Wed, 15 Jan 2003 23:41:53 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 550284766CB for ; Wed, 15 Jan 2003 23:41:04 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2315724; Wed, 15 Jan 2003 20:41:11 -0800 From: "Josh Berkus" Subject: Re: 7.3.1 New install, large queries are slow To: Tom Lane , "Roman Fail" Cc: josh@agliodbs.com, pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Wed, 15 Jan 2003 20:41:11 -0800 Message-ID: In-Reply-To: <11547.1042691700@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/131 X-Sequence-Number: 778 Tom, Roman, > I think more likely the issue is that your use of JOIN syntax is > forcing > Postgres into a bad plan. MSSQL probably doesn't assign any semantic > significance to the use of "a JOIN b" syntax as opposed to "FROM a, > b" > syntax. That's correct. MSSQL will reorder equijoins, even when explicitly declared. Hey, Roman, how many records in BatchDetail, anyway? Josh Berkus From pgsql-performance-owner@postgresql.org Wed Jan 15 23:48:43 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 229F5475C22 for ; Wed, 15 Jan 2003 23:48:40 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id 7E0B1475BEC for ; Wed, 15 Jan 2003 23:48:39 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Wed, 15 Jan 2003 20:48:47 -0800 Date: Wed, 15 Jan 2003 20:48:47 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030116044847.GA29781@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> <11547.1042691700@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: <11547.1042691700@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/132 X-Sequence-Number: 779 Tom Lane wrote: > "Roman Fail" writes: > > Thanks to everyone for the quick replies! I'm sure that my lack of > > skill with SQL queries is the main problem. What's strange to me is > > how MSSQL takes my bad queries and makes them look good anyway. It > > must have a real smart planner. > > I think more likely the issue is that your use of JOIN syntax is forcing > Postgres into a bad plan. MSSQL probably doesn't assign any semantic > significance to the use of "a JOIN b" syntax as opposed to "FROM a, b" > syntax. Postgres does. Whether this is a bug or a feature depends on > your point of view --- but there are folks out there who find it to be > a life-saver. Since it *does* depend on one's point of view, would it be possible to have control over this implemented in a session-defined variable (with the default in the GUC, of course)? I wouldn't be surprised if a lot of people get bitten by this. -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Thu Jan 16 00:07:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1336E475DC0 for ; Thu, 16 Jan 2003 00:07:48 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 607C8475C22 for ; Thu, 16 Jan 2003 00:07:47 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0G57q5u011771; Thu, 16 Jan 2003 00:07:52 -0500 (EST) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: <20030116044847.GA29781@filer> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> <11547.1042691700@sss.pgh.pa.us> <20030116044847.GA29781@filer> Comments: In-reply-to Kevin Brown message dated "Wed, 15 Jan 2003 20:48:47 -0800" Date: Thu, 16 Jan 2003 00:07:52 -0500 Message-ID: <11770.1042693672@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/133 X-Sequence-Number: 780 Kevin Brown writes: > Tom Lane wrote: >> ... Whether this is a bug or a feature depends on >> your point of view --- but there are folks out there who find it to be >> a life-saver. > Since it *does* depend on one's point of view, would it be possible to > have control over this implemented in a session-defined variable (with > the default in the GUC, of course)? I have no objection to doing that --- anyone care to contribute code to make it happen? (I think the trick would be to fold plain-JOIN jointree entries into FROM-list items in planner.c, somewhere near the code that hoists sub-SELECTs into the main join tree. But I haven't tried it, and have no time to in the near future.) regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 16 01:11:53 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AF5F947648B for ; Thu, 16 Jan 2003 01:11:50 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0C14F4764A7 for ; Thu, 16 Jan 2003 01:11:49 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0G6Bm5u012203; Thu, 16 Jan 2003 01:11:48 -0500 (EST) To: captainx0r@yahoo.com Cc: pgsql-performance@postgresql.org Subject: Re: Sun vs. Mac - gprof output In-reply-to: <20030115172250.54953.qmail@web21110.mail.yahoo.com> References: <20030115172250.54953.qmail@web21110.mail.yahoo.com> Comments: In-reply-to CaptainX0r message dated "Wed, 15 Jan 2003 09:22:50 -0800" Date: Thu, 16 Jan 2003 01:11:48 -0500 Message-ID: <12202.1042697508@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/134 X-Sequence-Number: 781 CaptainX0r writes: > % cumulative self self total > time seconds seconds calls ms/call ms/call name > 15.8 111.61 111.61 rl_signal_handler [5] > 4.3 142.18 30.57 rl_sigwinch_handler [6] > 1.9 155.42 13.24 rl_set_sighandler [8] > 1.9 168.52 13.10 rl_maybe_set_sighandler > [9] > 1.1 176.37 7.85 _rl_next_macro_key [11] > 0.9 182.38 6.01 rl_read_key [12] > 0.8 188.07 5.69 rl_backward_kill_line [13] All of these names correspond to internal routines in libreadline. It'd not be surprising for libreadline to suck a good deal of the runtime of psql ... but I don't believe the backend will call it at all. So, either this trace is erroneous, or you profiled the wrong process (client instead of backend), or there's something truly weird going on. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 16 04:03:51 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 375BB476128 for ; Thu, 16 Jan 2003 04:03:49 -0500 (EST) Received: from pos_pdc.posportal.com (unknown [12.158.169.100]) by postgresql.org (Postfix) with ESMTP id ABD77475D93 for ; Thu, 16 Jan 2003 04:03:47 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Re: 7.3.1 New install, large queries are slow Date: Thu, 16 Jan 2003 01:03:43 -0800 Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C02@pos_pdc.posportal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] 7.3.1 New install, large queries are slow Thread-Index: AcK9GX1//W2i8AeRQnaE5W1F2Gh0lAAGCuHA From: "Roman Fail" To: "Josh Berkus" , "Tom Lane" , Cc: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/135 X-Sequence-Number: 782 KioqKioqKioqKioqKioqKioqKioqKioNCj4gSm9zaCBCZXJrdXMgd3JvdGU6 DQo+IEhleSwgUm9tYW4sIGhvdyBtYW55IHJlY29yZHMgaW4gQmF0Y2hEZXRh aWwsIGFueXdheT8NCg0KMjMgbWlsbGlvbi4NCiANCioqKioqKioqKioqKioq KioqKioqKioqDQo+IFN0ZXBoYW4gU3phYm8gd3JvdGU6DQo+IFdoYXQgZG9l cyB2YWN1dW0gdmVyYm9zZSBiYXRjaGRldGFpbCBnaXZlIHlvdSAoaXQnbGwg Z2l2ZSBhbiBpZGVhIG9mIHBhZ2VzIGFueXdheSkNCg0KdHJhbnM9IyBWQUNV VU0gVkVSQk9TRSBiYXRjaGRldGFpbDsNCklORk86ICAtLVJlbGF0aW9uIHB1 YmxpYy5iYXRjaGRldGFpbC0tDQpJTkZPOiAgUGFnZXMgMTY2OTA0NzogQ2hh bmdlZCAwLCBFbXB0eSAwOyBUdXAgMjMzMTY2NzQ6IFZhYyAwLCBLZWVwIDAs IFVuVXNlZCAwLg0KICAgICAgICBUb3RhbCBDUFUgODUuMzZzLzkuMzh1IHNl YyBlbGFwc2VkIDI1My4zOCBzZWMuDQpJTkZPOiAgLS1SZWxhdGlvbiBwZ190 b2FzdC5wZ190b2FzdF84NjA0MjQ3LS0NCklORk86ICBQYWdlcyAwOiBDaGFu Z2VkIDAsIEVtcHR5IDA7IFR1cCAwOiBWYWMgMCwgS2VlcCAwLCBVblVzZWQg MC4NCiAgICAgICAgVG90YWwgQ1BVIDAuMDBzLzAuMDB1IHNlYyBlbGFwc2Vk IDAuMDAgc2VjLg0KVkFDVVVNDQp0cmFucz0jDQoNCioqKioqKioqKioqKioq KioqKioqKioqDQpBdCBTdGVwaGFuIFN6YWJvIGFuZCBUb20gTGFuZSdzIHN1 Z2dlc3Rpb24sIEkgcmVvcmdhbml6ZWQgdGhlIHF1ZXJ5IHNvIHRoZSBKT0lO IHN5bnRheCB3YXMgb25seSB1c2VkIGluIHRoZSBvdXRlciBqb2lucy4gIFRo aXMgZGlkIG5vdCBzZWVtIHRvIGhlbHAgYXQgYWxsLiAgT2Ygbm90ZTogZHVy aW5nIHRoaXMgcXVlcnkgJ3NhciAtYicgc2hvd2VkIGEgY29uc2lzdGVudCA2 MDAwIGJsb2NrcyByZWFkL3NlYywgQ1BVIHdhcyBhYm91dCAyJS4NCiANCkVY UExBSU4gQU5BTFlaRQ0KU0VMRUNUIGIuYmF0Y2hkYXRlLCBkLmJhdGNoZGV0 YWlsaWQsIHQuYmFua25vLCBkLnRyYW5kYXRlLCBkLnRyYW5hbW91bnQsDQpk LnN1Ym1pdGludGVyY2hhbmdlLCBkLmF1dGhhbW91bnQsIGQuYXV0aG5vLCBk LmNhcmR0eXBlaWQsIGQubWNjY29kZSwNCm0ubmFtZSBBUyBtZXJjaGFudG5h bWUsIGMuY2FyZHR5cGUsIG0ubWVyY2hpZCwNCnAxLmxvY2FsdGF4YW1vdW50 LCBwMS5wcm9kdWN0aWRlbnRpZmllciwgZHIuYXZzcmVzcG9uc2UsDQpjci5j aGVja291dGRhdGUsIGNyLm5vc2hvd2luZGljYXRvciwgY2suY2hlY2tpbmdh Y2N0bm8sDQpjay5hYmFyb3V0aW5nbm8sIGNrLmNoZWNrbm8NCkZST00gdHJh bmhlYWRlciB0LCBiYXRjaGhlYWRlciBiLCBtZXJjaGFudHMgbSwgY2FyZHR5 cGUgYywgYmF0Y2hkZXRhaWwgZA0KTEVGVCBKT0lOIHB1cmMxIHAxIG9uIHAx LmJhdGNoZGV0YWlsaWQ9ZC5iYXRjaGRldGFpbGlkDQpMRUZUIEpPSU4gZGly ZWN0IGRyIE9OIGRyLmJhdGNoZGV0YWlsaWQgPSBkLmJhdGNoZGV0YWlsaWQN CkxFRlQgSk9JTiBjYXJyZW50YWwgY3IgT04gY3IuYmF0Y2hkZXRhaWxpZCA9 IGQuYmF0Y2hkZXRhaWxpZA0KTEVGVCBKT0lOIGNoZWNrcyBjayBPTiBjay5i YXRjaGRldGFpbGlkID0gZC5iYXRjaGRldGFpbGlkDQpXSEVSRSB0LnRyYW5o ZWFkZXJpZD1iLnRyYW5oZWFkZXJpZA0KQU5EIG0ubWVyY2hhbnRpZD1iLm1l cmNoYW50aWQNCkFORCBkLmJhdGNoaWQ9Yi5iYXRjaGlkDQpBTkQgYy5jYXJk dHlwZWlkPWQuY2FyZHR5cGVpZA0KQU5EIHQuY2xpZW50aWQgPSA2DQpBTkQg ZC50cmFuYW1vdW50IEJFVFdFRU4gNTAwLjAgQU5EIDcwMC4wDQpBTkQgYi5i YXRjaGRhdGUgPiAnMjAwMi0xMi0xNScNCkFORCBtLm1lcmNoaWQgPSAnNzAx MjUyMjY3Jw0KT1JERVIgQlkgYi5iYXRjaGRhdGUgREVTQw0KTElNSVQgNTAN CkxpbWl0ICAoY29zdD0xNzg5MTA1LjIxLi4xNzg5MTA1LjIyIHJvd3M9MSB3 aWR0aD0yODUpIChhY3R1YWwgdGltZT0xMjIyMDI5LjU5Li4xMjIyMDI5LjYx IHJvd3M9NSBsb29wcz0xKQ0KICAtPiAgU29ydCAgKGNvc3Q9MTc4OTEwNS4y MS4uMTc4OTEwNS4yMiByb3dzPTEgd2lkdGg9Mjg1KSAoYWN0dWFsIHRpbWU9 MTIyMjAyOS41OC4uMTIyMjAyOS41OSByb3dzPTUgbG9vcHM9MSkNCiAgICAg ICAgU29ydCBLZXk6IGIuYmF0Y2hkYXRlDQogICAgICAgIC0+ICBOZXN0ZWQg TG9vcCAgKGNvc3Q9MTc4NzE3MS4yMi4uMTc4OTEwNS4yMCByb3dzPTEgd2lk dGg9Mjg1KSAoYWN0dWFsIHRpbWU9MTIyMTgxNS4xNC4uMTIyMjAxOS40NiBy b3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgi aW5uZXIiLnRyYW5oZWFkZXJpZCA9ICJvdXRlciIudHJhbmhlYWRlcmlkKQ0K ICAgICAgICAgICAgICAtPiAgTmVzdGVkIExvb3AgIChjb3N0PTE3ODcxNzEu MjIuLjE3ODkwMjYuMDIgcm93cz0xIHdpZHRoPTI2OSkgKGFjdHVhbCB0aW1l PTEyMjE4MDkuMzMuLjEyMjE5NzguNjIgcm93cz01IGxvb3BzPTEpDQogICAg ICAgICAgICAgICAgICAgIEpvaW4gRmlsdGVyOiAoImlubmVyIi5jYXJkdHlw ZWlkID0gIm91dGVyIi5jYXJkdHlwZWlkKQ0KICAgICAgICAgICAgICAgICAg ICAtPiAgTWVyZ2UgSm9pbiAgKGNvc3Q9MTc4NzE3MS4yMi4uMTc4OTAyNC43 OSByb3dzPTEgd2lkdGg9MjU1KSAoYWN0dWFsIHRpbWU9MTIyMTgwMi40Ny4u MTIyMTk3MS40OCByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgTWVyZ2UgQ29uZDogKCJvdXRlciIuYmF0Y2hpZCA9ICJpbm5l ciIuYmF0Y2hpZCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNv cnQgIChjb3N0PTQ3Ni4xNy4uNDc2LjE4IHJvd3M9NCB3aWR0aD0xMDIpIChh Y3R1YWwgdGltZT02NzguMDUuLjY3OC4wNyByb3dzPTE3IGxvb3BzPTEpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNvcnQgS2V5OiBiLmJh dGNoaWQNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIE5l c3RlZCBMb29wICAoY29zdD0wLjAwLi40NzYuMTQgcm93cz00IHdpZHRoPTEw MikgKGFjdHVhbCB0aW1lPTE2MS42Mi4uNjc3Ljk1IHJvd3M9MTcgbG9vcHM9 MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4g IEluZGV4IFNjYW4gdXNpbmcgbWVyY2hhbnRzX2l4X21lcmNoaWRfaWR4IG9u IG1lcmNoYW50cyBtICAoY29zdD0wLjAwLi41LjY1IHJvd3M9MSB3aWR0aD03 OCkgKGFjdHVhbCB0aW1lPTEzLjg3Li4xMy44OCByb3dzPTEgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg SW5kZXggQ29uZDogKG1lcmNoaWQgPSAnNzAxMjUyMjY3Jzo6Y2hhcmFjdGVy IHZhcnlpbmcpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nIGJhdGNoaGVhZGVyX2l4X21lcmNo YW50aWRfaWR4IG9uIGJhdGNoaGVhZGVyIGIgIChjb3N0PTAuMDAuLjQ3MC4z MCByb3dzPTE1IHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MTQ3LjcyLi42NjMu OTQgcm93cz0xNyBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoIm91dGVyIi5tZXJj aGFudGlkID0gYi5tZXJjaGFudGlkKQ0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6IChiYXRjaGRhdGUgPiAn MjAwMi0xMi0xNSAwMDowMDowMCc6OnRpbWVzdGFtcCB3aXRob3V0IHRpbWUg em9uZSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNvcnQgIChj b3N0PTE3ODY2OTUuMDUuLjE3ODc2MjEuODIgcm93cz0zNzA3MTAgd2lkdGg9 MTUzKSAoYWN0dWFsIHRpbWU9MTIyMDA4MC4zNC4uMTIyMDcyMi4xOSByb3dz PTM2ODY4MSBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICBTb3J0IEtleTogZC5iYXRjaGlkDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIC0+ICBNZXJnZSBKb2luICAoY29zdD0xNzA0MTkxLjI1 Li4xNzEzNjc0LjQ5IHJvd3M9MzcwNzEwIHdpZHRoPTE1MykgKGFjdHVhbCB0 aW1lPTEyMDAxODQuOTEuLjEyMTMzNTIuNzcgcm93cz0zNzAzMDcgbG9vcHM9 MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTWVy Z2UgQ29uZDogKCJvdXRlciIuYmF0Y2hkZXRhaWxpZCA9ICJpbm5lciIuYmF0 Y2hkZXRhaWxpZCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgLT4gIE1lcmdlIEpvaW4gIChjb3N0PTE3MDQwODUuMjguLjE3MTI2 NzguMzMgcm93cz0zNzA3MTAgd2lkdGg9MTE1KSAoYWN0dWFsIHRpbWU9MTE5 OTcwNS43MS4uMTIxMDMzNi4zNyByb3dzPTM3MDMwNyBsb29wcz0xKQ0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNZXJn ZSBDb25kOiAoIm91dGVyIi5iYXRjaGRldGFpbGlkID0gImlubmVyIi5iYXRj aGRldGFpbGlkKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAtPiAgTWVyZ2UgSm9pbiAgKGNvc3Q9MTcwNDA4NS4yNy4u MTcxMTc1MS41NCByb3dzPTM3MDcxMCB3aWR0aD05OCkgKGFjdHVhbCB0aW1l PTExOTk3MDUuNjUuLjEyMDgxMjIuNzMgcm93cz0zNzAzMDcgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgTWVyZ2UgQ29uZDogKCJvdXRlciIuYmF0Y2hkZXRhaWxpZCA9ICJp bm5lciIuYmF0Y2hkZXRhaWxpZCkNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIE1lcmdlIEpvaW4gIChj b3N0PTE3MDQwODUuMjYuLjE3MTA4MjQuNzUgcm93cz0zNzA3MTAgd2lkdGg9 ODkpIChhY3R1YWwgdGltZT0xMTk5NzA1LjU1Li4xMjA1OTc3Ljc2IHJvd3M9 MzcwMzA3IGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1lcmdlIENvbmQ6ICgib3V0 ZXIiLmJhdGNoZGV0YWlsaWQgPSAiaW5uZXIiLmJhdGNoZGV0YWlsaWQpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIC0+ICBTb3J0ICAoY29zdD0xNTQzMTE5LjAxLi4xNTQ0MDQ1 Ljc5IHJvd3M9MzcwNzEwIHdpZHRoPTcwKSAoYWN0dWFsIHRpbWU9MTE4MTE3 Mi43OS4uMTE4MTkwMi43NyByb3dzPTM3MDMwNyBsb29wcz0xKQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBTb3J0IEtleTogZC5iYXRjaGRldGFpbGlkDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nIGJhdGNoZGV0YWlsX2l4 X3RyYW5hbW91bnRfaWR4IG9uIGJhdGNoZGV0YWlsIGQgIChjb3N0PTAuMDAu LjE0ODkxMDMuNDYgcm93cz0zNzA3MTAgd2lkdGg9NzApIChhY3R1YWwgdGlt ZT0xNC40NS4uMTE3NjA3NC45MCByb3dzPTM3MDMwNyBsb29wcz0xKQ0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoKHRyYW5hbW91bnQg Pj0gNTAwLjApIEFORCAodHJhbmFtb3VudCA8PSA3MDAuMCkpDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIC0+ICBTb3J0ICAoY29zdD0xNjA5NjYuMjUuLjE2MzMxOS41OSByb3dz PTk0MTMzNSB3aWR0aD0xOSkgKGFjdHVhbCB0aW1lPTE4NTMyLjcwLi4yMDA3 NC4wOSByb3dzPTkzODc3MCBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBT b3J0IEtleTogcDEuYmF0Y2hkZXRhaWxpZA0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAt PiAgU2VxIFNjYW4gb24gcHVyYzEgcDEgIChjb3N0PTAuMDAuLjQ0Mjg1LjM1 IHJvd3M9OTQxMzM1IHdpZHRoPTE5KSAoYWN0dWFsIHRpbWU9OS40NC4uOTEx OS44MyByb3dzPTkzODc3MCBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgU29ydCAgKGNv c3Q9MC4wMS4uMC4wMiByb3dzPTEgd2lkdGg9OSkgKGFjdHVhbCB0aW1lPTAu MDguLjAuMDggcm93cz0wIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNvcnQgS2V5 OiBkci5iYXRjaGRldGFpbGlkDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBv biBkaXJlY3QgZHIgIChjb3N0PTAuMDAuLjAuMDAgcm93cz0xIHdpZHRoPTkp IChhY3R1YWwgdGltZT0wLjAxLi4wLjAxIHJvd3M9MCBsb29wcz0xKQ0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAg U29ydCAgKGNvc3Q9MC4wMS4uMC4wMiByb3dzPTEgd2lkdGg9MTcpIChhY3R1 YWwgdGltZT0wLjA0Li4wLjA0IHJvd3M9MCBsb29wcz0xKQ0KICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTb3J0 IEtleTogY3IuYmF0Y2hkZXRhaWxpZA0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24g Y2FycmVudGFsIGNyICAoY29zdD0wLjAwLi4wLjAwIHJvd3M9MSB3aWR0aD0x NykgKGFjdHVhbCB0aW1lPTAuMDAuLjAuMDAgcm93cz0wIGxvb3BzPTEpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTb3J0 ICAoY29zdD0xMDUuOTcuLjEwOS4xMyByb3dzPTEyNjcgd2lkdGg9MzgpIChh Y3R1YWwgdGltZT00NzkuMTcuLjQ4MC43NCByb3dzPTEyNjcgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg U29ydCBLZXk6IGNrLmJhdGNoZGV0YWlsaWQNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIGNo ZWNrcyBjayAgKGNvc3Q9MC4wMC4uNDAuNjcgcm93cz0xMjY3IHdpZHRoPTM4 KSAoYWN0dWFsIHRpbWU9NDQ3Ljg4Li40NzUuNjAgcm93cz0xMjY3IGxvb3Bz PTEpDQogICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBjYXJk dHlwZSBjICAoY29zdD0wLjAwLi4xLjEwIHJvd3M9MTAgd2lkdGg9MTQpIChh Y3R1YWwgdGltZT0xLjM3Li4xLjM5IHJvd3M9MTAgbG9vcHM9NSkNCiAgICAg ICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIHRyYW5oZWFkZXIgdCAgKGNvc3Q9 MC4wMC4uNTUuMTUgcm93cz0xOTIzIHdpZHRoPTE2KSAoYWN0dWFsIHRpbWU9 MC4wMS4uNS4xNCByb3dzPTE5MjMgbG9vcHM9NSkNCiAgICAgICAgICAgICAg ICAgICAgRmlsdGVyOiAoY2xpZW50aWQgPSA2KQ0KVG90YWwgcnVudGltZTog MTIyMjE1Ny4yOCBtc2VjDQoNCioqKioqKioqKioqKioqKioqKioqKioqDQpK dXN0IHRvIHNlZSB3aGF0IHdvdWxkIGhhcHBlbiwgSSBleGVjdXRlZDoNCiAg ICAgQUxURVIgVEFCTEUgYmF0Y2hkZXRhaWwgQUxURVIgQ09MVU1OIHRyYW5h bW91bnQgU0VUIFNUQVRJU1RJQ1MgMTAwMDsNCiAgICAgQU5BTFlaRTsNCkl0 IHNlZW1lZCB0byBodXJ0IHBlcmZvcm1hbmNlIGlmIGFueXRoaW5nLiAgQnV0 IHRoZSBFWFBMQUlOIGVzdGltYXRlIGZvciByb3dzIHdhcyBtdWNoIGNsb3Nl ciB0byB0aGUgcmVhbCB2YWx1ZSB0aGFuIGl0IHdhcyBwcmV2aW91c2x5Lg0K IA0KKioqKioqKioqKioqKioqKioqKioqKioNCkl0IHNlZW1zIHRvIG1lIHRo YXQgdGhlIGJpZywgYmlnIGlzb2xhdGVkIHByb2JsZW0gaXMgdGhlIGluZGV4 IHNjYW4gb24gYmF0Y2hkZXRhaWwudHJhbmFtb3VudC4gIER1cmluZyB0aGlz IHNtYWxsIHF1ZXJ5LCAnc2FyIC1iJyBzaG93ZWQgY29uc2lzdGVudCA5MCww MDAgYmxvY2sgcmVhZHMvc2VjLiAoY29udHJhc3Qgd2l0aCBvbmx5IDYsMDAw IHdpdGggbGFyZ2VyIHF1ZXJ5IGluZGV4IHNjYW4pLiAgJ3RvcCcgc2hvd3Mg dGhlIENQVSBpcyBhdCAyMCUgdXNlciwgMzAlIHN5c3RlbSB0aGUgd2hvbGUg dGltZSAoY29udHJhc3Qgd2l0aCAyJSB0b3RhbCBpbiBsYXJnZXIgcXVlcnkg YWJvdmUpLiAgVGhpcyByZXN1bHRzIGhlcmUgc3RpbGwgc2VlbSBwcmV0dHkg YmFkIChhbHRob3VnaCBub3QgYXMgYmFkIGFzIGFib3ZlKSwgYnV0IEkgc3Rp bGwgZG9uJ3Qga25vdyB3aGF0IGlzIHRoZSBib3R0bGVuZWNrLiAgQW5kIHRo ZSBzdHJhbmdlIHNhciBzdGF0cyBhcmUgY29uZnVzaW5nIG1lLg0KIA0KRVhQ TEFJTiBBTkFMWVpFIFNFTEVDVCAqIEZST00gYmF0Y2hkZXRhaWwgV0hFUkUg dHJhbmFtb3VudCBCRVRXRUVOIDMwMCBBTkQgNDk5Ow0KU2VxIFNjYW4gb24g YmF0Y2hkZXRhaWwgIChjb3N0PTAuMDAuLjIwMTg3OTcuMTEgcm93cz03ODMy OTEgd2lkdGg9NDQwKSAoYWN0dWFsIHRpbWU9NDUuNjYuLjI4MzkyNi41OCBy b3dzPTc4MzY4NyBsb29wcz0xKQ0KICBGaWx0ZXI6ICgodHJhbmFtb3VudCA+ PSAzMDA6Om51bWVyaWMpIEFORCAodHJhbmFtb3VudCA8PSA0OTk6Om51bWVy aWMpKQ0KVG90YWwgcnVudGltZTogMjg1MDMyLjQ3IG1zZWMNCg0KIA0KKioq KioqKioqKioqKioqKioqKioqKioNCj4gU3RlcGhhbiBTemFibyB3cm90ZToN Cj4gQXMgYSBmb2xsb3d1cCwgaWYgeW91IGRvIHNldCBlbmFibGVfaW5kZXhz Y2FuPW9mZjsNCj4gYmVmb3JlIHJ1bm5pbmcgdGhlIGV4cGxhaW4gYW5hbHl6 ZSwgd2hhdCBkb2VzIHRoYXQgZ2l2ZSB5b3U/DQoNCk5vdyB0aGlzIGlzIHZl cnkgaW50ZXJlc3Rpbmc6ICdzYXIgLWInIHNob3dzIGFib3V0IDk1LDAwMCBi bG9jayByZWFkcy9zZWM7IENQVSBpcyBhdCAyMCUgdXNlciAzMCUgc3lzdGVt LCB2bXN0YXQgc2hvd3Mgbm8gc3dhcHBpbmcsIHF1ZXJ5IHRha2VzIG9ubHkg NSBtaW51dGVzIHRvIGV4ZWN1dGUgKHdoaWNoIGlzIG9uZS1xdWFydGVyIG9m IHRoZSB0aW1lIFdJVEggdGhlIGluZGV4IHNjYW4hISEhKS4gIE9idmlvdXNs eSB0aGUgZXhlY3V0aW9uIHBsYW4gaXMgcHJldHR5IGRpZmZlcmVudCBvbiB0 aGlzIG9uZSAocXVlcnkgaXMgaWRlbnRpY2FsIHRoZSBsYXJnZXIgb25lIGFi b3ZlKS4NCiANCkVYUExBSU4gQU5BTFlaRQ0KU0VMRUNUIGIuYmF0Y2hkYXRl LCBkLmJhdGNoZGV0YWlsaWQsIHQuYmFua25vLCBkLnRyYW5kYXRlLCBkLnRy YW5hbW91bnQsDQpkLnN1Ym1pdGludGVyY2hhbmdlLCBkLmF1dGhhbW91bnQs IGQuYXV0aG5vLCBkLmNhcmR0eXBlaWQsIGQubWNjY29kZSwNCm0ubmFtZSBB UyBtZXJjaGFudG5hbWUsIGMuY2FyZHR5cGUsIG0ubWVyY2hpZCwNCnAxLmxv Y2FsdGF4YW1vdW50LCBwMS5wcm9kdWN0aWRlbnRpZmllciwgZHIuYXZzcmVz cG9uc2UsDQpjci5jaGVja291dGRhdGUsIGNyLm5vc2hvd2luZGljYXRvciwg Y2suY2hlY2tpbmdhY2N0bm8sDQpjay5hYmFyb3V0aW5nbm8sIGNrLmNoZWNr bm8NCkZST00gdHJhbmhlYWRlciB0LCBiYXRjaGhlYWRlciBiLCBtZXJjaGFu dHMgbSwgY2FyZHR5cGUgYywNCmJhdGNoZGV0YWlsIGQNCkxFRlQgSk9JTiBw dXJjMSBwMSBvbiBwMS5iYXRjaGRldGFpbGlkPWQuYmF0Y2hkZXRhaWxpZA0K TEVGVCBKT0lOIGRpcmVjdCBkciBPTiBkci5iYXRjaGRldGFpbGlkID0gZC5i YXRjaGRldGFpbGlkDQpMRUZUIEpPSU4gY2FycmVudGFsIGNyIE9OIGNyLmJh dGNoZGV0YWlsaWQgPSBkLmJhdGNoZGV0YWlsaWQNCkxFRlQgSk9JTiBjaGVj a3MgY2sgT04gY2suYmF0Y2hkZXRhaWxpZCA9IGQuYmF0Y2hkZXRhaWxpZA0K V0hFUkUgdC50cmFuaGVhZGVyaWQ9Yi50cmFuaGVhZGVyaWQNCkFORCBtLm1l cmNoYW50aWQ9Yi5tZXJjaGFudGlkDQpBTkQgZC5iYXRjaGlkPWIuYmF0Y2hp ZA0KQU5EIGMuY2FyZHR5cGVpZD1kLmNhcmR0eXBlaWQNCkFORCB0LmNsaWVu dGlkID0gNg0KQU5EIGQudHJhbmFtb3VudCBCRVRXRUVOIDUwMC4wIEFORCA3 MDAuMA0KQU5EIGIuYmF0Y2hkYXRlID4gJzIwMDItMTItMTUnDQpBTkQgbS5t ZXJjaGlkID0gJzcwMTI1MjI2NycNCk9SREVSIEJZIGIuYmF0Y2hkYXRlIERF U0MNCkxJTUlUIDUwDQpMaW1pdCAgKGNvc3Q9MjMyMTQ2MC41Ni4uMjMyMTQ2 MC41NyByb3dzPTEgd2lkdGg9Mjg1KSAoYWN0dWFsIHRpbWU9MzA4MTk0LjU3 Li4zMDgxOTQuNTkgcm93cz01IGxvb3BzPTEpDQogIC0+ICBTb3J0ICAoY29z dD0yMzIxNDYwLjU2Li4yMzIxNDYwLjU3IHJvd3M9MSB3aWR0aD0yODUpIChh Y3R1YWwgdGltZT0zMDgxOTQuNTcuLjMwODE5NC41OCByb3dzPTUgbG9vcHM9 MSkNCiAgICAgICAgU29ydCBLZXk6IGIuYmF0Y2hkYXRlDQogICAgICAgIC0+ ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MjMxOTUyNi41Ny4uMjMyMTQ2MC41NSBy b3dzPTEgd2lkdGg9Mjg1KSAoYWN0dWFsIHRpbWU9MzA3OTg4LjU2Li4zMDgx OTQuNDYgcm93cz01IGxvb3BzPTEpDQogICAgICAgICAgICAgIEpvaW4gRmls dGVyOiAoImlubmVyIi50cmFuaGVhZGVyaWQgPSAib3V0ZXIiLnRyYW5oZWFk ZXJpZCkNCiAgICAgICAgICAgICAgLT4gIE5lc3RlZCBMb29wICAoY29zdD0y MzE5NTI2LjU3Li4yMzIxMzgxLjM3IHJvd3M9MSB3aWR0aD0yNjkpIChhY3R1 YWwgdGltZT0zMDc5ODIuODAuLjMwODE1My4yMiByb3dzPTUgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLmNh cmR0eXBlaWQgPSAib3V0ZXIiLmNhcmR0eXBlaWQpDQogICAgICAgICAgICAg ICAgICAgIC0+ICBNZXJnZSBKb2luICAoY29zdD0yMzE5NTI2LjU3Li4yMzIx MzgwLjE0IHJvd3M9MSB3aWR0aD0yNTUpIChhY3R1YWwgdGltZT0zMDc5ODIu NjkuLjMwODE1Mi44MiByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAg ICAgICAgICAgICAgTWVyZ2UgQ29uZDogKCJvdXRlciIuYmF0Y2hpZCA9ICJp bm5lciIuYmF0Y2hpZCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgLT4g IFNvcnQgIChjb3N0PTIzMTYzODguNzAuLjIzMTczMTUuNDcgcm93cz0zNzA3 MTAgd2lkdGg9MTUzKSAoYWN0dWFsIHRpbWU9MzA1OTc2Ljc0Li4zMDY2MjIu ODggcm93cz0zNjg2ODEgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgU29ydCBLZXk6IGQuYmF0Y2hpZA0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAtPiAgTWVyZ2UgSm9pbiAgKGNvc3Q9MjIz Mzg4NC45MC4uMjI0MzM2OC4xNSByb3dzPTM3MDcxMCB3aWR0aD0xNTMpIChh Y3R1YWwgdGltZT0yODY0NTIuMTIuLjI5OTQ4NS40MyByb3dzPTM3MDMwNyBs b29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBNZXJnZSBDb25kOiAoIm91dGVyIi5iYXRjaGRldGFpbGlkID0gImlubmVy Ii5iYXRjaGRldGFpbGlkKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAtPiAgTWVyZ2UgSm9pbiAgKGNvc3Q9MjIzMzc3OC45My4u MjI0MjM3MS45OCByb3dzPTM3MDcxMCB3aWR0aD0xMTUpIChhY3R1YWwgdGlt ZT0yODY0MjguNzcuLjI5NjkzOS42NiByb3dzPTM3MDMwNyBsb29wcz0xKQ0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBN ZXJnZSBDb25kOiAoIm91dGVyIi5iYXRjaGRldGFpbGlkID0gImlubmVyIi5i YXRjaGRldGFpbGlkKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAtPiAgTWVyZ2UgSm9pbiAgKGNvc3Q9MjIzMzc3OC45 Mi4uMjI0MTQ0NS4xOSByb3dzPTM3MDcxMCB3aWR0aD05OCkgKGFjdHVhbCB0 aW1lPTI4NjQyOC43Mi4uMjk0NzUwLjAxIHJvd3M9MzcwMzA3IGxvb3BzPTEp DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIE1lcmdlIENvbmQ6ICgib3V0ZXIiLmJhdGNoZGV0YWlsaWQgPSAi aW5uZXIiLmJhdGNoZGV0YWlsaWQpDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBNZXJnZSBKb2luICAo Y29zdD0yMjMzNzc4LjkxLi4yMjQwNTE4LjQwIHJvd3M9MzcwNzEwIHdpZHRo PTg5KSAoYWN0dWFsIHRpbWU9Mjg2NDI4LjYwLi4yOTI2MDYuNTYgcm93cz0z NzAzMDcgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgTWVyZ2UgQ29uZDogKCJvdXRl ciIuYmF0Y2hkZXRhaWxpZCA9ICJpbm5lciIuYmF0Y2hkZXRhaWxpZCkNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgLT4gIFNvcnQgIChjb3N0PTIwNzI4MTIuNjYuLjIwNzM3Mzku NDQgcm93cz0zNzA3MTAgd2lkdGg9NzApIChhY3R1YWwgdGltZT0yNjk3Mzgu MzQuLjI3MDQ3MC44MyByb3dzPTM3MDMwNyBsb29wcz0xKQ0KICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBTb3J0IEtleTogZC5iYXRjaGRldGFpbGlkDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIC0+ICBTZXEgU2NhbiBvbiBiYXRjaGRldGFpbCBkICAoY29zdD0w LjAwLi4yMDE4Nzk3LjExIHJvd3M9MzcwNzEwIHdpZHRoPTcwKSAoYWN0dWFs IHRpbWU9NDEuNjYuLjI2NjU2OC44MyByb3dzPTM3MDMwNyBsb29wcz0xKQ0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6ICgodHJhbmFtb3VudCA+ PSA1MDAuMCkgQU5EICh0cmFuYW1vdW50IDw9IDcwMC4wKSkNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgLT4gIFNvcnQgIChjb3N0PTE2MDk2Ni4yNS4uMTYzMzE5LjU5IHJvd3M9 OTQxMzM1IHdpZHRoPTE5KSAoYWN0dWFsIHRpbWU9MTY2OTAuMjAuLjE4MjAy LjY1IHJvd3M9OTM4NzcwIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNv cnQgS2V5OiBwMS5iYXRjaGRldGFpbGlkDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ ICBTZXEgU2NhbiBvbiBwdXJjMSBwMSAgKGNvc3Q9MC4wMC4uNDQyODUuMzUg cm93cz05NDEzMzUgd2lkdGg9MTkpIChhY3R1YWwgdGltZT02Ljg4Li43Nzc5 LjMxIHJvd3M9OTM4NzcwIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTb3J0ICAoY29z dD0wLjAxLi4wLjAyIHJvd3M9MSB3aWR0aD05KSAoYWN0dWFsIHRpbWU9MC4x MC4uMC4xMCByb3dzPTAgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU29ydCBLZXk6 IGRyLmJhdGNoZGV0YWlsaWQNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9u IGRpcmVjdCBkciAgKGNvc3Q9MC4wMC4uMC4wMCByb3dzPTEgd2lkdGg9OSkg KGFjdHVhbCB0aW1lPTAuMDAuLjAuMDAgcm93cz0wIGxvb3BzPTEpDQogICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBT b3J0ICAoY29zdD0wLjAxLi4wLjAyIHJvd3M9MSB3aWR0aD0xNykgKGFjdHVh bCB0aW1lPTAuMDMuLjAuMDMgcm93cz0wIGxvb3BzPTEpDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNvcnQg S2V5OiBjci5iYXRjaGRldGFpbGlkDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBj YXJyZW50YWwgY3IgIChjb3N0PTAuMDAuLjAuMDAgcm93cz0xIHdpZHRoPTE3 KSAoYWN0dWFsIHRpbWU9MC4wMC4uMC4wMCByb3dzPTAgbG9vcHM9MSkNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNvcnQg IChjb3N0PTEwNS45Ny4uMTA5LjEzIHJvd3M9MTI2NyB3aWR0aD0zOCkgKGFj dHVhbCB0aW1lPTIzLjMyLi4yNC44OSByb3dzPTEyNjcgbG9vcHM9MSkNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU29y dCBLZXk6IGNrLmJhdGNoZGV0YWlsaWQNCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIGNoZWNr cyBjayAgKGNvc3Q9MC4wMC4uNDAuNjcgcm93cz0xMjY3IHdpZHRoPTM4KSAo YWN0dWFsIHRpbWU9Ni41MS4uMTkuNTkgcm93cz0xMjY3IGxvb3BzPTEpDQog ICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTb3J0ICAoY29zdD0zMTM3 Ljg3Li4zMTM3Ljg4IHJvd3M9NCB3aWR0aD0xMDIpIChhY3R1YWwgdGltZT05 NTQuMTguLjk1NC4yMCByb3dzPTE5IGxvb3BzPTEpDQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIFNvcnQgS2V5OiBiLmJhdGNoaWQNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIE5lc3RlZCBMb29wICAo Y29zdD0wLjAwLi4zMTM3Ljg0IHJvd3M9NCB3aWR0aD0xMDIpIChhY3R1YWwg dGltZT0yMzYuMjYuLjk1NC4wNCByb3dzPTE3IGxvb3BzPTEpDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBv biBtZXJjaGFudHMgbSAgKGNvc3Q9MC4wMC4uMjY2Ny4zNSByb3dzPTEgd2lk dGg9NzgpIChhY3R1YWwgdGltZT0yLjQ4Li4yMjcuNzEgcm93cz0xIGxvb3Bz PTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIEZpbHRlcjogKG1lcmNoaWQgPSAnNzAxMjUyMjY3Jzo6Y2hhcmFjdGVy IHZhcnlpbmcpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nIGJhdGNoaGVhZGVyX2l4X21lcmNo YW50aWRfaWR4IG9uIGJhdGNoaGVhZGVyIGIgIChjb3N0PTAuMDAuLjQ3MC4z MCByb3dzPTE1IHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9MjMzLjc1Li43MjYu MjIgcm93cz0xNyBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAoIm91dGVyIi5tZXJj aGFudGlkID0gYi5tZXJjaGFudGlkKQ0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6IChiYXRjaGRhdGUgPiAn MjAwMi0xMi0xNSAwMDowMDowMCc6OnRpbWVzdGFtcCB3aXRob3V0IHRpbWUg em9uZSkNCiAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIGNh cmR0eXBlIGMgIChjb3N0PTAuMDAuLjEuMTAgcm93cz0xMCB3aWR0aD0xNCkg KGFjdHVhbCB0aW1lPTAuMDIuLjAuMDQgcm93cz0xMCBsb29wcz01KQ0KICAg ICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gdHJhbmhlYWRlciB0ICAoY29z dD0wLjAwLi41NS4xNSByb3dzPTE5MjMgd2lkdGg9MTYpIChhY3R1YWwgdGlt ZT0wLjAxLi41LjIxIHJvd3M9MTkyMyBsb29wcz01KQ0KICAgICAgICAgICAg ICAgICAgICBGaWx0ZXI6IChjbGllbnRpZCA9IDYpDQpUb3RhbCBydW50aW1l OiAzMDgzMjMuNjAgbXNlYw0KDQoqKioqKioqKioqKioqKioqKioqKioqKg0K SSBob3BlIHdlIGNhbiBjb21lIHVwIHdpdGggc29tZXRoaW5nIHNvb24uLi4u Lml0IHNlZW1zIHRoaXMgaW5kZXggc2NhbiBpcyBhIGJpZyBwYXJ0IG9mIHRo ZSBwcm9ibGVtLiAgSSdtIHN0aWxsIHJlYWxseSBjdXJpb3VzIHdoeSB0aGUg ZGlzayByZWFkcyBhcmUgc28gZmV3IHdpdGggdGhlIGluZGV4IHNjYW4uICBM ZXQncyBob3BlIEkgY2FuIGdldCBpdCBuZWFyIHRoZSAzIHNlY29uZCB0aW1l IGZvciBNU1NRTCBieSBGcmlkYXkhDQogDQpSb21hbiBGYWlsDQogDQo= From pgsql-performance-owner@postgresql.org Thu Jan 16 05:40:23 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 80EB247621A for ; Thu, 16 Jan 2003 05:40:21 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id DF1DF47618E for ; Thu, 16 Jan 2003 05:40:20 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Thu, 16 Jan 2003 02:40:26 -0800 Date: Thu, 16 Jan 2003 02:40:25 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030116104025.GB29781@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> <11547.1042691700@sss.pgh.pa.us> <20030116044847.GA29781@filer> <11770.1042693672@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: <11770.1042693672@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/137 X-Sequence-Number: 784 Tom Lane wrote: > Kevin Brown writes: > > Tom Lane wrote: > >> ... Whether this is a bug or a feature depends on > >> your point of view --- but there are folks out there who find it to be > >> a life-saver. > > > Since it *does* depend on one's point of view, would it be possible to > > have control over this implemented in a session-defined variable (with > > the default in the GUC, of course)? > > I have no objection to doing that --- anyone care to contribute code to > make it happen? (I think the trick would be to fold plain-JOIN jointree > entries into FROM-list items in planner.c, somewhere near the code that > hoists sub-SELECTs into the main join tree. But I haven't tried it, and > have no time to in the near future.) I'm looking at the code now (the 7.2.3 code in particular, but I suspect for this purpose the code is likely to be very similar to the CVS tip), but it's all completely new to me and the developer documentation isn't very revealing of the internals. The optimizer code (I've been looking especially at make_jointree_rel() and make_fromexpr_rel()) looks a bit tricky...it'll take me some time to completely wrap my brain around it. Any pointers to revealing documentation would be quite helpful! -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Thu Jan 16 07:29:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BBFF14766ED for ; Thu, 16 Jan 2003 07:29:49 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id C06AE4766AB for ; Thu, 16 Jan 2003 07:29:46 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030116122948.ITVZ6744.lakemtao02.cox.net@[192.168.1.1]> for ; Thu, 16 Jan 2003 07:29:48 -0500 Subject: Re: 7.3.1 New install, large queries are slow From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C02@pos_pdc.posportal.com> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C02@pos_pdc.posportal.com> Content-Type: text/plain Organization: Message-Id: <1042720183.892.18.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 16 Jan 2003 06:29:43 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/139 X-Sequence-Number: 786 On Thu, 2003-01-16 at 03:03, Roman Fail wrote: > *********************** > > Josh Berkus wrote: > > Hey, Roman, how many records in BatchDetail, anyway? > > 23 million. What are the indexes on batchdetail? There's one on batchid and a seperate one on tranamount? If so, what about dropping them and create a single multi-segment index on "batchid, tranamount". (A constraint can then enforce uniqueness on batchid. > *********************** > > Stephan Szabo wrote: > > What does vacuum verbose batchdetail give you (it'll give an idea of pages anyway) > > trans=# VACUUM VERBOSE batchdetail; > INFO: --Relation public.batchdetail-- > INFO: Pages 1669047: Changed 0, Empty 0; Tup 23316674: Vac 0, Keep 0, UnUsed 0. > Total CPU 85.36s/9.38u sec elapsed 253.38 sec. > INFO: --Relation pg_toast.pg_toast_8604247-- > INFO: Pages 0: Changed 0, Empty 0; Tup 0: Vac 0, Keep 0, UnUsed 0. > Total CPU 0.00s/0.00u sec elapsed 0.00 sec. > VACUUM > trans=# > > *********************** > At Stephan Szabo and Tom Lane's suggestion, I reorganized the query > so the JOIN syntax was only used in the outer joins. This did not > seem to help at all. Of note: during this query 'sar -b' showed a > consistent 6000 blocks read/sec, CPU was about 2%. > > EXPLAIN ANALYZE > SELECT b.batchdate, d.batchdetailid, t.bankno, d.trandate, d.tranamount, > d.submitinterchange, d.authamount, d.authno, d.cardtypeid, d.mcccode, > m.name AS merchantname, c.cardtype, m.merchid, > p1.localtaxamount, p1.productidentifier, dr.avsresponse, > cr.checkoutdate, cr.noshowindicator, ck.checkingacctno, > ck.abaroutingno, ck.checkno > FROM tranheader t, batchheader b, merchants m, cardtype c, batchdetail d > LEFT JOIN purc1 p1 on p1.batchdetailid=d.batchdetailid > LEFT JOIN direct dr ON dr.batchdetailid = d.batchdetailid > LEFT JOIN carrental cr ON cr.batchdetailid = d.batchdetailid > LEFT JOIN checks ck ON ck.batchdetailid = d.batchdetailid > WHERE t.tranheaderid=b.tranheaderid > AND m.merchantid=b.merchantid > AND d.batchid=b.batchid > AND c.cardtypeid=d.cardtypeid > AND t.clientid = 6 > AND d.tranamount BETWEEN 500.0 AND 700.0 > AND b.batchdate > '2002-12-15' > AND m.merchid = '701252267' > ORDER BY b.batchdate DESC > LIMIT 50 > Limit (cost=1789105.21..1789105.22 rows=1 width=285) (actual time=1222029.59..1222029.61 rows=5 loops=1) > -> Sort (cost=1789105.21..1789105.22 rows=1 width=285) (actual time=1222029.58..1222029.59 rows=5 loops=1) > Sort Key: b.batchdate > -> Nested Loop (cost=1787171.22..1789105.20 rows=1 width=285) (actual time=1221815.14..1222019.46 rows=5 loops=1) > Join Filter: ("inner".tranheaderid = "outer".tranheaderid) > -> Nested Loop (cost=1787171.22..1789026.02 rows=1 width=269) (actual time=1221809.33..1221978.62 rows=5 loops=1) > Join Filter: ("inner".cardtypeid = "outer".cardtypeid) > -> Merge Join (cost=1787171.22..1789024.79 rows=1 width=255) (actual time=1221802.47..1221971.48 rows=5 loops=1) > Merge Cond: ("outer".batchid = "inner".batchid) > -> Sort (cost=476.17..476.18 rows=4 width=102) (actual time=678.05..678.07 rows=17 loops=1) > Sort Key: b.batchid > -> Nested Loop (cost=0.00..476.14 rows=4 width=102) (actual time=161.62..677.95 rows=17 loops=1) > -> Index Scan using merchants_ix_merchid_idx on merchants m (cost=0.00..5.65 rows=1 width=78) (actual time=13.87..13.88 rows=1 loops=1) > Index Cond: (merchid = '701252267'::character varying) > -> Index Scan using batchheader_ix_merchantid_idx on batchheader b (cost=0.00..470.30 rows=15 width=24) (actual time=147.72..663.94 rows=17 loops=1) > Index Cond: ("outer".merchantid = b.merchantid) > Filter: (batchdate > '2002-12-15 00:00:00'::timestamp without time zone) > -> Sort (cost=1786695.05..1787621.82 rows=370710 width=153) (actual time=1220080.34..1220722.19 rows=368681 loops=1) > Sort Key: d.batchid > -> Merge Join (cost=1704191.25..1713674.49 rows=370710 width=153) (actual time=1200184.91..1213352.77 rows=370307 loops=1) > Merge Cond: ("outer".batchdetailid = "inner".batchdetailid) > -> Merge Join (cost=1704085.28..1712678.33 rows=370710 width=115) (actual time=1199705.71..1210336.37 rows=370307 loops=1) > Merge Cond: ("outer".batchdetailid = "inner".batchdetailid) > -> Merge Join (cost=1704085.27..1711751.54 rows=370710 width=98) (actual time=1199705.65..1208122.73 rows=370307 loops=1) > Merge Cond: ("outer".batchdetailid = "inner".batchdetailid) > -> Merge Join (cost=1704085.26..1710824.75 rows=370710 width=89) (actual time=1199705.55..1205977.76 rows=370307 loops=1) > Merge Cond: ("outer".batchdetailid = "inner".batchdetailid) > -> Sort (cost=1543119.01..1544045.79 rows=370710 width=70) (actual time=1181172.79..1181902.77 rows=370307 loops=1) > Sort Key: d.batchdetailid > -> Index Scan using batchdetail_ix_tranamount_idx on batchdetail d (cost=0.00..1489103.46 rows=370710 width=70) (actual time=14.45..1176074.90 rows=370307 loops=1) > Index Cond: ((tranamount >= 500.0) AND (tranamount <= 700.0)) > -> Sort (cost=160966.25..163319.59 rows=941335 width=19) (actual time=18532.70..20074.09 rows=938770 loops=1) > Sort Key: p1.batchdetailid > -> Seq Scan on purc1 p1 (cost=0.00..44285.35 rows=941335 width=19) (actual time=9.44..9119.83 rows=938770 loops=1) > -> Sort (cost=0.01..0.02 rows=1 width=9) (actual time=0.08..0.08 rows=0 loops=1) > Sort Key: dr.batchdetailid > -> Seq Scan on direct dr (cost=0.00..0.00 rows=1 width=9) (actual time=0.01..0.01 rows=0 loops=1) > -> Sort (cost=0.01..0.02 rows=1 width=17) (actual time=0.04..0.04 rows=0 loops=1) > Sort Key: cr.batchdetailid > -> Seq Scan on carrental cr (cost=0.00..0.00 rows=1 width=17) (actual time=0.00..0.00 rows=0 loops=1) > -> Sort (cost=105.97..109.13 rows=1267 width=38) (actual time=479.17..480.74 rows=1267 loops=1) > Sort Key: ck.batchdetailid > -> Seq Scan on checks ck (cost=0.00..40.67 rows=1267 width=38) (actual time=447.88..475.60 rows=1267 loops=1) > -> Seq Scan on cardtype c (cost=0.00..1.10 rows=10 width=14) (actual time=1.37..1.39 rows=10 loops=5) > -> Seq Scan on tranheader t (cost=0.00..55.15 rows=1923 width=16) (actual time=0.01..5.14 rows=1923 loops=5) > Filter: (clientid = 6) > Total runtime: 1222157.28 msec > > *********************** > Just to see what would happen, I executed: > ALTER TABLE batchdetail ALTER COLUMN tranamount SET STATISTICS 1000; > ANALYZE; > It seemed to hurt performance if anything. But the EXPLAIN estimate > for rows was much closer to the real value than it was previously. > > *********************** > It seems to me that the big, big isolated problem is the index scan on > batchdetail.tranamount. During this small query, 'sar -b' showed > consistent 90,000 block reads/sec. (contrast with only 6,000 with > larger query index scan). 'top' shows the CPU is at 20% user, 30% > system the whole time (contrast with 2% total in larger query above). > This results here still seem pretty bad (although not as bad as > above), but I still don't know what is the bottleneck. And the > strange sar stats are confusing me. > > EXPLAIN ANALYZE SELECT * FROM batchdetail WHERE tranamount BETWEEN 300 AND 499; > Seq Scan on batchdetail (cost=0.00..2018797.11 rows=783291 width=440) (actual time=45.66..283926.58 rows=783687 loops=1) > Filter: ((tranamount >= 300::numeric) AND (tranamount <= 499::numeric)) > Total runtime: 285032.47 msec > > > *********************** > > Stephan Szabo wrote: > > As a followup, if you do set enable_indexscan=off; > > before running the explain analyze, what does that give you? > > Now this is very interesting: 'sar -b' shows about 95,000 block > reads/sec; CPU is at 20% user 30% system, vmstat shows no swapping, > query takes only 5 minutes to execute (which is one-quarter of the > time WITH the index scan!!!!). Obviously the execution plan is pretty > different on this one (query is identical the larger one above). > > EXPLAIN ANALYZE > SELECT b.batchdate, d.batchdetailid, t.bankno, d.trandate, d.tranamount, > d.submitinterchange, d.authamount, d.authno, d.cardtypeid, d.mcccode, > m.name AS merchantname, c.cardtype, m.merchid, > p1.localtaxamount, p1.productidentifier, dr.avsresponse, > cr.checkoutdate, cr.noshowindicator, ck.checkingacctno, > ck.abaroutingno, ck.checkno > FROM tranheader t, batchheader b, merchants m, cardtype c, > batchdetail d > LEFT JOIN purc1 p1 on p1.batchdetailid=d.batchdetailid > LEFT JOIN direct dr ON dr.batchdetailid = d.batchdetailid > LEFT JOIN carrental cr ON cr.batchdetailid = d.batchdetailid > LEFT JOIN checks ck ON ck.batchdetailid = d.batchdetailid > WHERE t.tranheaderid=b.tranheaderid > AND m.merchantid=b.merchantid > AND d.batchid=b.batchid > AND c.cardtypeid=d.cardtypeid > AND t.clientid = 6 > AND d.tranamount BETWEEN 500.0 AND 700.0 > AND b.batchdate > '2002-12-15' > AND m.merchid = '701252267' > ORDER BY b.batchdate DESC > LIMIT 50 > Limit (cost=2321460.56..2321460.57 rows=1 width=285) (actual time=308194.57..308194.59 rows=5 loops=1) > -> Sort (cost=2321460.56..2321460.57 rows=1 width=285) (actual time=308194.57..308194.58 rows=5 loops=1) > Sort Key: b.batchdate > -> Nested Loop (cost=2319526.57..2321460.55 rows=1 width=285) (actual time=307988.56..308194.46 rows=5 loops=1) > Join Filter: ("inner".tranheaderid = "outer".tranheaderid) > -> Nested Loop (cost=2319526.57..2321381.37 rows=1 width=269) (actual time=307982.80..308153.22 rows=5 loops=1) > Join Filter: ("inner".cardtypeid = "outer".cardtypeid) > -> Merge Join (cost=2319526.57..2321380.14 rows=1 width=255) (actual time=307982.69..308152.82 rows=5 loops=1) > Merge Cond: ("outer".batchid = "inner".batchid) > -> Sort (cost=2316388.70..2317315.47 rows=370710 width=153) (actual time=305976.74..306622.88 rows=368681 loops=1) > Sort Key: d.batchid > -> Merge Join (cost=2233884.90..2243368.15 rows=370710 width=153) (actual time=286452.12..299485.43 rows=370307 loops=1) > Merge Cond: ("outer".batchdetailid = "inner".batchdetailid) > -> Merge Join (cost=2233778.93..2242371.98 rows=370710 width=115) (actual time=286428.77..296939.66 rows=370307 loops=1) > Merge Cond: ("outer".batchdetailid = "inner".batchdetailid) > -> Merge Join (cost=2233778.92..2241445.19 rows=370710 width=98) (actual time=286428.72..294750.01 rows=370307 loops=1) > Merge Cond: ("outer".batchdetailid = "inner".batchdetailid) > -> Merge Join (cost=2233778.91..2240518.40 rows=370710 width=89) (actual time=286428.60..292606.56 rows=370307 loops=1) > Merge Cond: ("outer".batchdetailid = "inner".batchdetailid) > -> Sort (cost=2072812.66..2073739.44 rows=370710 width=70) (actual time=269738.34..270470.83 rows=370307 loops=1) > Sort Key: d.batchdetailid > -> Seq Scan on batchdetail d (cost=0.00..2018797.11 rows=370710 width=70) (actual time=41.66..266568.83 rows=370307 loops=1) > Filter: ((tranamount >= 500.0) AND (tranamount <= 700.0)) > -> Sort (cost=160966.25..163319.59 rows=941335 width=19) (actual time=16690.20..18202.65 rows=938770 loops=1) > Sort Key: p1.batchdetailid > -> Seq Scan on purc1 p1 (cost=0.00..44285.35 rows=941335 width=19) (actual time=6.88..7779.31 rows=938770 loops=1) > -> Sort (cost=0.01..0.02 rows=1 width=9) (actual time=0.10..0.10 rows=0 loops=1) > Sort Key: dr.batchdetailid > -> Seq Scan on direct dr (cost=0.00..0.00 rows=1 width=9) (actual time=0.00..0.00 rows=0 loops=1) > -> Sort (cost=0.01..0.02 rows=1 width=17) (actual time=0.03..0.03 rows=0 loops=1) > Sort Key: cr.batchdetailid > -> Seq Scan on carrental cr (cost=0.00..0.00 rows=1 width=17) (actual time=0.00..0.00 rows=0 loops=1) > -> Sort (cost=105.97..109.13 rows=1267 width=38) (actual time=23.32..24.89 rows=1267 loops=1) > Sort Key: ck.batchdetailid > -> Seq Scan on checks ck (cost=0.00..40.67 rows=1267 width=38) (actual time=6.51..19.59 rows=1267 loops=1) > -> Sort (cost=3137.87..3137.88 rows=4 width=102) (actual time=954.18..954.20 rows=19 loops=1) > Sort Key: b.batchid > -> Nested Loop (cost=0.00..3137.84 rows=4 width=102) (actual time=236.26..954.04 rows=17 loops=1) > -> Seq Scan on merchants m (cost=0.00..2667.35 rows=1 width=78) (actual time=2.48..227.71 rows=1 loops=1) > Filter: (merchid = '701252267'::character varying) > -> Index Scan using batchheader_ix_merchantid_idx on batchheader b (cost=0.00..470.30 rows=15 width=24) (actual time=233.75..726.22 rows=17 loops=1) > Index Cond: ("outer".merchantid = b.merchantid) > Filter: (batchdate > '2002-12-15 00:00:00'::timestamp without time zone) > -> Seq Scan on cardtype c (cost=0.00..1.10 rows=10 width=14) (actual time=0.02..0.04 rows=10 loops=5) > -> Seq Scan on tranheader t (cost=0.00..55.15 rows=1923 width=16) (actual time=0.01..5.21 rows=1923 loops=5) > Filter: (clientid = 6) > Total runtime: 308323.60 msec > > *********************** > I hope we can come up with something soon.....it seems this index > scan is a big part of the problem. I'm still really curious why the > disk reads are so few with the index scan. Let's hope I can get it > near the 3 second time for MSSQL by Friday! -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Jan 16 06:05:14 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 313494766DE for ; Thu, 16 Jan 2003 06:05:11 -0500 (EST) Received: from localhost.localdomain (sein.itera.ee [194.126.109.126]) by postgresql.org (Postfix) with ESMTP id E0997476A10 for ; Thu, 16 Jan 2003 06:03:22 -0500 (EST) Received: (from hannu@localhost) by localhost.localdomain (8.11.6/8.11.6) id h0GCsxq02689; Thu, 16 Jan 2003 12:54:59 GMT X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: 7.3.1 New install, large queries are slow From: Hannu Krosing To: Stephan Szabo Cc: Roman Fail , josh@agliodbs.com, "pgsql-performance@postgresql.org" In-Reply-To: <20030115192815.T98147-100000@megazone23.bigpanda.com> References: <20030115192815.T98147-100000@megazone23.bigpanda.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1042721698.2502.109.camel@huli> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 16 Jan 2003 12:54:58 +0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/138 X-Sequence-Number: 785 On Thu, 2003-01-16 at 03:40, Stephan Szabo wrote: > > So here's the query, and another EXPLAIN ANALYZE to go with it > > (executed after all setting changes). The same result columns and > > JOINS are performed all day with variations on the WHERE clause; other > > possible search columns are the ones that are indexed (see below). > > The 4 tables that use LEFT JOIN only sometimes have matching records, > > hence the OUTER join. > > > > EXPLAIN ANALYZE > > SELECT b.batchdate, d.batchdetailid, t.bankno, d.trandate, d.tranamount, > > d.submitinterchange, d.authamount, d.authno, d.cardtypeid, d.mcccode, > > m.name AS merchantname, c.cardtype, m.merchid, > > p1.localtaxamount, p1.productidentifier, dr.avsresponse, > > cr.checkoutdate, cr.noshowindicator, ck.checkingacctno, > > ck.abaroutingno, ck.checkno > > FROM tranheader t > > INNER JOIN batchheader b ON t.tranheaderid = b.tranheaderid > > INNER JOIN merchants m ON m.merchantid = b.merchantid > > INNER JOIN batchdetail d ON d.batchid = b.batchid > > INNER JOIN cardtype c ON d.cardtypeid = c.cardtypeid > > LEFT JOIN purc1 p1 ON p1.batchdetailid = d.batchdetailid > > LEFT JOIN direct dr ON dr.batchdetailid = d.batchdetailid > > LEFT JOIN carrental cr ON cr.batchdetailid = d.batchdetailid > > LEFT JOIN checks ck ON ck.batchdetailid = d.batchdetailid > > WHERE t.clientid = 6 > > AND d.tranamount BETWEEN 500.0 AND 700.0 How much of data in d has tranamount BETWEEN 500.0 AND 700.0 ? Do you have an index on d.tranamount ? > > AND b.batchdate > '2002-12-15' again - how much of b.batchdate > '2002-12-15' ? is there an index > > AND m.merchid = '701252267' ditto > > ORDER BY b.batchdate DESC > > LIMIT 50 these two together make me think that perhaps b.batchdate between '2003-12-12' and '2002-12-15' could be better at making the optimiser see that reverse index scan on b.batchdate would be the way to go. > Well, you might get a little help by replace the from with -- Hannu Krosing From pgsql-performance-owner@postgresql.org Thu Jan 16 08:17:37 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 53B644766F0 for ; Thu, 16 Jan 2003 08:17:35 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id CCB854766BC for ; Thu, 16 Jan 2003 08:17:34 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18Z9tq-0006BP-00 for ; Thu, 16 Jan 2003 08:17:38 -0500 Date: Thu, 16 Jan 2003 08:17:38 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030116081738.B22344@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com>; from rfail@posportal.com on Wed, Jan 15, 2003 at 03:30:55PM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/140 X-Sequence-Number: 787 On Wed, Jan 15, 2003 at 03:30:55PM -0800, Roman Fail wrote: > Thanks to everyone for the quick replies! I'm sure that my lack of skill with SQL queries is the main problem. What's strange to me is how MSSQL takes my bad queries and makes them look good anyway. It must have a real smart planner. > Andrew Sullivan wrote: > >First, the performance of foreign keys is flat-out awful in Postgres. > >I suggest avoiding them if you can. > > I don't have any problem getting rid of FKs, especially if it might > actually help performance. The nightly data import is well-defined Sorry, I think I sent this too quickly. FKs make no difference to SELECT performance, so if you're not doing updates and the like at the same time as the SELECTs, there's no advantage. So you should leave the FKs in place. > I think this is the most likely problem. I've read through Chapter > 10 of the 7.3 docs, but I still don't feel like I know what would > be a good order. How do you learn this stuff anyway? Trial and > error? Sorry, but yes. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Jan 16 08:45:03 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E716847621F for ; Thu, 16 Jan 2003 08:44:59 -0500 (EST) Received: from web21105.mail.yahoo.com (web21105.mail.yahoo.com [216.136.227.107]) by postgresql.org (Postfix) with SMTP id 574DC47621A for ; Thu, 16 Jan 2003 08:44:59 -0500 (EST) Message-ID: <20030116134502.36697.qmail@web21105.mail.yahoo.com> Received: from [140.247.91.110] by web21105.mail.yahoo.com via HTTP; Thu, 16 Jan 2003 05:45:02 PST Date: Thu, 16 Jan 2003 05:45:02 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: Re: Sun vs. Mac - gprof output To: pgsql-performance@postgresql.org In-Reply-To: <12202.1042697508@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/141 X-Sequence-Number: 788 > It'd not be surprising for libreadline to suck a good deal of the > runtime of psql ... but I don't believe the backend will call it at all. > So, either this trace is erroneous, or you profiled the wrong process > (client instead of backend), or there's something truly weird going on. You're right, I got the client, here's the backend: % cumulative self self total time seconds seconds calls ms/call ms/call name 23.4 125.31 125.31 internal_mcount [13] 21.2 239.07 113.76 79296415 0.00 0.00 ExecMakeFunctionResult [14] 7.8 280.68 41.61 98971658 0.00 0.00 AllocSetReset [23] 6.8 317.13 36.45 193735603 0.00 0.00 ExecEvalVar [18] 5.2 345.21 28.08 280731963 0.00 0.00 ExecEvalExpr [15] 2.7 359.93 14.72 38140599 0.00 0.00 nocachegetattr [35] 2.7 374.28 14.35 320207 0.04 0.04 _read [38] 2.2 385.97 11.69 78969393 0.00 0.00 ExecQual [34] 2.1 397.46 11.49 79296415 0.00 0.00 ExecEvalFuncArgs [42] 1.4 404.71 7.25 _mcount (6219) 1.3 411.73 7.02 11293115 0.00 0.00 heapgettup [31] 1.2 418.34 6.61 98975017 0.00 0.00 ExecClearTuple [43] 1.0 423.93 5.59 98971592 0.00 0.00 ExecStoreTuple [33] 0.9 428.87 4.94 197952332 0.00 0.00 MemoryContextSwitchTo [53] 0.9 433.53 4.66 7612547 0.00 0.00 heap_formtuple [39] 0.8 437.96 4.43 7609318 0.00 0.01 ExecScanHashBucket [17] 0.8 442.34 4.38 8 547.50 547.50 .rem [55] 0.8 446.64 4.30 79296261 0.00 0.00 ExecEvalOper [56] I'm not sure what to make of this. Thanks, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Thu Jan 16 08:54:44 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A6028476819 for ; Thu, 16 Jan 2003 08:54:37 -0500 (EST) Received: from web21106.mail.yahoo.com (web21106.mail.yahoo.com [216.136.227.108]) by postgresql.org (Postfix) with SMTP id 4E0A7476B85 for ; Thu, 16 Jan 2003 08:51:37 -0500 (EST) Message-ID: <20030116135140.32097.qmail@web21106.mail.yahoo.com> Received: from [140.247.91.110] by web21106.mail.yahoo.com via HTTP; Thu, 16 Jan 2003 05:51:40 PST Date: Thu, 16 Jan 2003 05:51:40 -0800 (PST) From: CaptainX0r Reply-To: captainx0r@yahoo.com Subject: schema/db design wrt performance To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/142 X-Sequence-Number: 789 All, I just noted in another thread that use of foreign keys in postgres significantly hinders performance. I'm wondering what other aspects we should take into consideration in the design of our database. We're coming from Sybase and trying to design a more encompassing, modular, generic database that won't take a serious performance hit under postgres. Thanks, -X __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Thu Jan 16 09:08:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6FE22476757 for ; Thu, 16 Jan 2003 09:08:25 -0500 (EST) Received: from mx5.claxson.com (unknown [200.32.96.144]) by postgresql.org (Postfix) with ESMTP id 8F721476BF9 for ; Thu, 16 Jan 2003 09:07:22 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: schema/db design wrt performance Date: Thu, 16 Jan 2003 11:07:25 -0300 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] schema/db design wrt performance Thread-Index: AcK9ZtfL0RIwYBa3QHSI7Zs7EHCr+QAAOQxg From: "Fernando Papa" To: , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/143 X-Sequence-Number: 790 I think FK on every database (oracle and MSSQL too) may hit performance, but only in DML (insert/update/delete). These are tradeoffs... referencial integrity vs. problems with batchload for example. My Oracle experience say when I need to do batchload, I disable constraints and then apply and work over exceptions. If you don't make referencial integrity on database maybe you need to do it on you application... and I think will be very painfull. -- Fernando O. Papa DBA =20 > -----Mensaje original----- > De: CaptainX0r [mailto:captainx0r@yahoo.com]=20 > Enviado el: jueves, 16 de enero de 2003 10:52 > Para: pgsql-performance@postgresql.org > Asunto: [PERFORM] schema/db design wrt performance >=20 >=20 > All, >=20 > I just noted in another thread that use of foreign keys in=20 > postgres significantly hinders performance. I'm wondering=20 > what other aspects we should take into consideration in the=20 > design of our database. We're coming from Sybase and trying=20 > to design a more encompassing, modular, generic database that=20 > won't take a serious performance hit under postgres. >=20 > Thanks, >=20 > -X >=20 > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.=20 http://mailplus.yahoo.com ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html From pgsql-performance-owner@postgresql.org Thu Jan 16 09:20:04 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 859F1475FD5 for ; Thu, 16 Jan 2003 09:20:02 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 07D23475CEE for ; Thu, 16 Jan 2003 09:20:02 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ZAsH-000797-00 for ; Thu, 16 Jan 2003 09:20:05 -0500 Date: Thu, 16 Jan 2003 09:20:05 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: schema/db design wrt performance Message-ID: <20030116092005.C22344@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20030116135140.32097.qmail@web21106.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030116135140.32097.qmail@web21106.mail.yahoo.com>; from captainx0r@yahoo.com on Thu, Jan 16, 2003 at 05:51:40AM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/144 X-Sequence-Number: 791 On Thu, Jan 16, 2003 at 05:51:40AM -0800, CaptainX0r wrote: > All, > > I just noted in another thread that use of foreign keys in postgres > significantly hinders performance. I'm wondering what other Since I think I'm the one responsible for this, I'd better say something clearer for the record. The foreign keys implementation in PostgreSQL essentially uses SELECT . . . FOR UPDATE to ensure that referenced data doesn't go away while a referencing datum is being inserted or altered. The problem with this is that frequently-referenced data are therefore effectively locked during the operation. Other writers will block on the locked data until the first writer finishes. So, for instance, consider two artificial-example tables: create table account (acct_id serial primary key); create table acct_activity (acct_id int references account(acct_id), trans_on timestamp, val numeric(12,2)); If a user has multiple connections and charges things to the same account in more than one connection at the same time, the transactions will have to be processed, effectively, in series: each one will have to wait for another to commit in order to complete. This is just a performance bottleneck. But it gets worse. Suppose the account table is like this: create table account (acct_id serial primary key, con_id int references contact(con_id)); create table contact (con_id serial primary key, name text, address1 text [. . .]); Now, if another transaction is busy trying to delete a contact at the same time the account table is being updated to reflect, say, a new contact, you run the risk of deadlock. The FK support in PostgreSQL is therefore mostly useful for low-volume applications. It can be made to work under heavier load if you use it very carefully and program your application for it. But I suggest avoiding it for heavy-duty use if you really can. > take into consideration in the design of our database. We're > coming from Sybase and trying to design a more encompassing, > modular, generic database that won't take a serious performance hit > under postgres. Avoid NOT IN. This is difficult, because the workaround in Postgres (NOT EXISTS) is frequently lousy on other systems. Apparently there is some fix for this contemplated for 7.4, but I've been really busy lately, so I haven't been following -hackers. Someone else can probably say something more useful about it. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Jan 16 09:23:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DFFDD475FD5 for ; Thu, 16 Jan 2003 09:23:27 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 31CCB475CEE for ; Thu, 16 Jan 2003 09:23:27 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0GENXfe033690; Thu, 16 Jan 2003 09:23:33 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: 7.3.1 New install, large queries are slow From: Rod Taylor To: Roman Fail Cc: PgSQL Performance ML In-Reply-To: <1042720183.892.18.camel@haggis> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C02@pos_pdc.posportal.com> <1042720183.892.18.camel@haggis> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-h6okXiXg4P76ZXXA2EZx" Organization: Message-Id: <1042727012.82534.50.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 16 Jan 2003 09:23:32 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/145 X-Sequence-Number: 792 --=-h6okXiXg4P76ZXXA2EZx Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2003-01-16 at 07:29, Ron Johnson wrote: > On Thu, 2003-01-16 at 03:03, Roman Fail wrote: > > *********************** > > > Josh Berkus wrote: > > > Hey, Roman, how many records in BatchDetail, anyway? > >=20 > > 23 million. >=20 > What are the indexes on batchdetail? >=20 > There's one on batchid and a seperate one on tranamount? >=20 > If so, what about dropping them and create a single multi-segment > index on "batchid, tranamount". (A constraint can then enforce > uniqueness on batchid. Thats a good step. Once done, CLUSTER by that index -- might buy 10 to 20% extra. --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-h6okXiXg4P76ZXXA2EZx 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 (FreeBSD) iD8DBQA+JsBj6DETLow6vwwRAgHAAJ9Uxj4BQ/tMQooJ0l7z0/PjV+EAhACfZT5U OR5Ig7+qxeprpC93ckBJX4s= =MKW8 -----END PGP SIGNATURE----- --=-h6okXiXg4P76ZXXA2EZx-- From pgsql-performance-owner@postgresql.org Thu Jan 16 09:35:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 70F6E476742 for ; Thu, 16 Jan 2003 09:35:28 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 2F5A1476809 for ; Thu, 16 Jan 2003 09:34:35 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030116143439.KAGI8666.lakemtao03.cox.net@[192.168.1.1]> for ; Thu, 16 Jan 2003 09:34:39 -0500 Subject: Re: schema/db design wrt performance From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <20030116092005.C22344@mail.libertyrms.com> References: <20030116135140.32097.qmail@web21106.mail.yahoo.com> <20030116092005.C22344@mail.libertyrms.com> Content-Type: text/plain Organization: Message-Id: <1042727678.892.31.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 16 Jan 2003 08:34:38 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/146 X-Sequence-Number: 793 On Thu, 2003-01-16 at 08:20, Andrew Sullivan wrote: > On Thu, Jan 16, 2003 at 05:51:40AM -0800, CaptainX0r wrote: > > All, > > > > I just noted in another thread that use of foreign keys in postgres > > significantly hinders performance. I'm wondering what other > > Since I think I'm the one responsible for this, I'd better say > something clearer for the record. > > The foreign keys implementation in PostgreSQL essentially uses SELECT > . . . FOR UPDATE to ensure that referenced data doesn't go away while a > referencing datum is being inserted or altered. > > The problem with this is that frequently-referenced data are > therefore effectively locked during the operation. Other writers > will block on the locked data until the first writer finishes. > > So, for instance, consider two artificial-example tables: > > create table account (acct_id serial primary key); > > create table acct_activity (acct_id int references > account(acct_id), trans_on timestamp, val numeric(12,2)); > > If a user has multiple connections and charges things to the same > account in more than one connection at the same time, the > transactions will have to be processed, effectively, in series: each > one will have to wait for another to commit in order to complete. This is true even though the default transaction mode is READ COMMITTED? -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Jan 16 10:13:43 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9CD794761AF for ; Thu, 16 Jan 2003 10:13:41 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id ABC7D475CEE for ; Thu, 16 Jan 2003 10:13:40 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0GFDc5u014737; Thu, 16 Jan 2003 10:13:38 -0500 (EST) To: "Roman Fail" Cc: "Josh Berkus" , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C02@pos_pdc.posportal.com> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C02@pos_pdc.posportal.com> Comments: In-reply-to "Roman Fail" message dated "Thu, 16 Jan 2003 01:03:43 -0800" Date: Thu, 16 Jan 2003 10:13:37 -0500 Message-ID: <14736.1042730017@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/147 X-Sequence-Number: 794 "Roman Fail" writes: > SELECT ... > FROM tranheader t, batchheader b, merchants m, cardtype c, (batchdetail d > LEFT JOIN purc1 p1 on p1.batchdetailid=d.batchdetailid > LEFT JOIN direct dr ON dr.batchdetailid = d.batchdetailid > LEFT JOIN carrental cr ON cr.batchdetailid = d.batchdetailid > LEFT JOIN checks ck ON ck.batchdetailid = d.batchdetailid) > WHERE t.tranheaderid=b.tranheaderid > AND m.merchantid=b.merchantid > AND d.batchid=b.batchid > AND c.cardtypeid=d.cardtypeid > AND t.clientid = 6 > AND d.tranamount BETWEEN 500.0 AND 700.0 > AND b.batchdate > '2002-12-15' > AND m.merchid = '701252267' No no no ... this is even worse than before. Your big tables are batchdetail (d) and purc1 (p1). What you've got to do is arrange the computation so that those are trimmed to just the interesting records as soon as possible. The constraint on d.tranamount helps, but after that you proceed to join d to p1 *first*, before any of the other constraints can be applied. That's a huge join that you then proceed to throw away most of, as shown by the row counts in the EXPLAIN output. Note the parentheses I added above to show how the system interprets your FROM clause. Since dr,cr,ck are contributing nothing to elimination of records, you really want them joined last, not first. What would probably work better is SELECT ... FROM (SELECT ... FROM tranheader t, batchheader b, merchants m, cardtype c, batchdetail d WHERE t.tranheaderid=b.tranheaderid AND m.merchantid=b.merchantid AND d.batchid=b.batchid AND c.cardtypeid=d.cardtypeid AND t.clientid = 6 AND d.tranamount BETWEEN 500.0 AND 700.0 AND b.batchdate > '2002-12-15' AND m.merchid = '701252267') ss LEFT JOIN purc1 p1 on p1.batchdetailid=ss.batchdetailid LEFT JOIN direct dr ON dr.batchdetailid = ss.batchdetailid LEFT JOIN carrental cr ON cr.batchdetailid = ss.batchdetailid LEFT JOIN checks ck ON ck.batchdetailid = ss.batchdetailid which lets the system get the useful restrictions applied before it has to finish expanding out the star query. Since cardtype isn't contributing any restrictions, you might think about moving it into the LEFT JOIN series too (although I think the planner will choose to join it last in the subselect, anyway). regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 16 10:39:33 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7C66E4766BC for ; Thu, 16 Jan 2003 10:39:30 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 421144766BA for ; Thu, 16 Jan 2003 10:39:29 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ZC7B-0008Vq-00 for ; Thu, 16 Jan 2003 10:39:33 -0500 Date: Thu, 16 Jan 2003 10:39:33 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: schema/db design wrt performance Message-ID: <20030116103933.B32288@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <20030116135140.32097.qmail@web21106.mail.yahoo.com> <20030116092005.C22344@mail.libertyrms.com> <1042727678.892.31.camel@haggis> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1042727678.892.31.camel@haggis>; from ron.l.johnson@cox.net on Thu, Jan 16, 2003 at 08:34:38AM -0600 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/148 X-Sequence-Number: 795 On Thu, Jan 16, 2003 at 08:34:38AM -0600, Ron Johnson wrote: > On Thu, 2003-01-16 at 08:20, Andrew Sullivan wrote: > > If a user has multiple connections and charges things to the same > > account in more than one connection at the same time, the > > transactions will have to be processed, effectively, in series: each > > one will have to wait for another to commit in order to complete. > > This is true even though the default transaction mode is > READ COMMITTED? Yes. Remember, _both_ of these are doing SELECT. . .FOR UPDATE. Which means they both try to lock the corresponding record. But they can't _both_ lock the same record; that's what the lock prevents. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Jan 16 10:46:31 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BFE3B47682B for ; Thu, 16 Jan 2003 10:46:30 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A15A1476758 for ; Thu, 16 Jan 2003 10:46:18 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0GFkN5u015060; Thu, 16 Jan 2003 10:46:23 -0500 (EST) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: <20030116104025.GB29781@filer> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> <11547.1042691700@sss.pgh.pa.us> <20030116044847.GA29781@filer> <11770.1042693672@sss.pgh.pa.us> <20030116104025.GB29781@filer> Comments: In-reply-to Kevin Brown message dated "Thu, 16 Jan 2003 02:40:25 -0800" Date: Thu, 16 Jan 2003 10:46:22 -0500 Message-ID: <15059.1042731982@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/149 X-Sequence-Number: 796 Kevin Brown writes: > I'm looking at the code now (the 7.2.3 code in particular, but I > suspect for this purpose the code is likely to be very similar to the > CVS tip), but it's all completely new to me and the developer > documentation isn't very revealing of the internals. The optimizer > code (I've been looking especially at make_jointree_rel() and > make_fromexpr_rel()) looks a bit tricky...it'll take me some time to > completely wrap my brain around it. Any pointers to revealing > documentation would be quite helpful! src/backend/optimizer/README is a good place to start. I'd recommend working with CVS tip; there is little point in doing any nontrivial development in the 7.2 branch. You'd have to port it forward anyway. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 16 10:50:05 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2DDE4475CEE for ; Thu, 16 Jan 2003 10:50:03 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 5503C4767C0 for ; Thu, 16 Jan 2003 10:50:00 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030116155005.KTXQ8666.lakemtao03.cox.net@[192.168.1.1]> for ; Thu, 16 Jan 2003 10:50:05 -0500 Subject: Re: schema/db design wrt performance From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <20030116103933.B32288@mail.libertyrms.com> References: <20030116135140.32097.qmail@web21106.mail.yahoo.com> <20030116092005.C22344@mail.libertyrms.com> <1042727678.892.31.camel@haggis> <20030116103933.B32288@mail.libertyrms.com> Content-Type: text/plain Organization: Message-Id: <1042732204.892.35.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 16 Jan 2003 09:50:04 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/150 X-Sequence-Number: 797 On Thu, 2003-01-16 at 09:39, Andrew Sullivan wrote: > On Thu, Jan 16, 2003 at 08:34:38AM -0600, Ron Johnson wrote: > > On Thu, 2003-01-16 at 08:20, Andrew Sullivan wrote: > > > > If a user has multiple connections and charges things to the same > > > account in more than one connection at the same time, the > > > transactions will have to be processed, effectively, in series: each > > > one will have to wait for another to commit in order to complete. > > > > This is true even though the default transaction mode is > > READ COMMITTED? > > Yes. Remember, _both_ of these are doing SELECT. . .FOR UPDATE. > Which means they both try to lock the corresponding record. But they > can't _both_ lock the same record; that's what the lock prevents. Could BEFORE INSERT|UPDATE|DELETE triggers perform the same functionality while touching only the desired records, thus decreasing conflict? -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Jan 16 10:53:16 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DB7B34766BA for ; Thu, 16 Jan 2003 10:53:14 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id 35E77476632 for ; Thu, 16 Jan 2003 10:53:14 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id h0GFrCM02459; Thu, 16 Jan 2003 10:53:12 -0500 Message-ID: <3E26D564.1060209@clearmetrix.com> Date: Thu, 16 Jan 2003 10:53:08 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Roman Fail , josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> <11547.1042691700@sss.pgh.pa.us> In-Reply-To: <11547.1042691700@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/151 X-Sequence-Number: 798 I was surprised to hear that JOIN syntax constrained the planner. We have a policy of using JOIN syntax to describe the table relationships and where clauses to describe the selection process for our queries. It was our understanding that the JOIN syntax was introduced to support this approach, but not to contrain the planner. Is there any way to sell the planner to consider JOIN syntax as equivalent to WHERE clauses and to not use them to force the planner down a specific path? Can we get that added as an option (and then made available to use JDBC folks as a URL parameter). It would make my team very happy :-). I think that making this an option will help all those migrating to Postgres who did not expect that JOINs forced the planner down specific plans. Is it possible/reasonable to add? Charlie Tom Lane wrote: >"Roman Fail" writes: > > >>Thanks to everyone for the quick replies! I'm sure that my lack of >>skill with SQL queries is the main problem. What's strange to me is >>how MSSQL takes my bad queries and makes them look good anyway. It >>must have a real smart planner. >> >> > >I think more likely the issue is that your use of JOIN syntax is forcing >Postgres into a bad plan. MSSQL probably doesn't assign any semantic >significance to the use of "a JOIN b" syntax as opposed to "FROM a, b" >syntax. Postgres does. Whether this is a bug or a feature depends on >your point of view --- but there are folks out there who find it to be >a life-saver. You can find some explanations at >http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit-joins.html > > > >>Is it pretty much universally accepted that I should drop all my >>foreign keys? >> >> > >No. They don't have any effect on SELECT performance in Postgres. >They will impact update speed, but that's not your complaint (at the >moment). Don't throw away data integrity protection until you know >you need to. > > regards, tom lane > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com From pgsql-performance-owner@postgresql.org Thu Jan 16 11:04:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 25C9847675C for ; Thu, 16 Jan 2003 11:04:36 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 82518476D75 for ; Thu, 16 Jan 2003 11:02:35 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 24504D606; Thu, 16 Jan 2003 08:02:40 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 1A04C5C02; Thu, 16 Jan 2003 08:02:40 -0800 (PST) Date: Thu, 16 Jan 2003 08:02:40 -0800 (PST) From: Stephan Szabo To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: schema/db design wrt performance In-Reply-To: <1042732204.892.35.camel@haggis> Message-ID: <20030116080132.A4962-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/152 X-Sequence-Number: 799 On 16 Jan 2003, Ron Johnson wrote: > On Thu, 2003-01-16 at 09:39, Andrew Sullivan wrote: > > On Thu, Jan 16, 2003 at 08:34:38AM -0600, Ron Johnson wrote: > > > On Thu, 2003-01-16 at 08:20, Andrew Sullivan wrote: > > > > > > If a user has multiple connections and charges things to the same > > > > account in more than one connection at the same time, the > > > > transactions will have to be processed, effectively, in series: each > > > > one will have to wait for another to commit in order to complete. > > > > > > This is true even though the default transaction mode is > > > READ COMMITTED? > > > > Yes. Remember, _both_ of these are doing SELECT. . .FOR UPDATE. > > Which means they both try to lock the corresponding record. But they > > can't _both_ lock the same record; that's what the lock prevents. > > Could BEFORE INSERT|UPDATE|DELETE triggers perform the same > functionality while touching only the desired records, thus > decreasing conflict? It does limit it to the corresponding records, but if you say insert a row pointing at customer 1, and in another transaction insert a row pointing at customer 1, the second waits on the first. From pgsql-performance-owner@postgresql.org Thu Jan 16 11:06:26 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 30B9D476809 for ; Thu, 16 Jan 2003 11:06:25 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 3D5A24766ED for ; Thu, 16 Jan 2003 11:05:17 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ZCWA-0000Z2-00 for ; Thu, 16 Jan 2003 11:05:22 -0500 Date: Thu, 16 Jan 2003 11:05:22 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: schema/db design wrt performance Message-ID: <20030116110522.F32288@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <20030116135140.32097.qmail@web21106.mail.yahoo.com> <20030116092005.C22344@mail.libertyrms.com> <1042727678.892.31.camel@haggis> <20030116103933.B32288@mail.libertyrms.com> <1042732204.892.35.camel@haggis> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1042732204.892.35.camel@haggis>; from ron.l.johnson@cox.net on Thu, Jan 16, 2003 at 09:50:04AM -0600 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/153 X-Sequence-Number: 800 On Thu, Jan 16, 2003 at 09:50:04AM -0600, Ron Johnson wrote: > > Could BEFORE INSERT|UPDATE|DELETE triggers perform the same > functionality while touching only the desired records, thus > decreasing conflict? You can make the constraint DEFERRABLE INITIALY DEFERRED. It helps somewhat. But the potential for deadlock, and the backing up, will still happen to some degree. It's a well-known flaw in the FK system. I beleive the FK implementation was mostly intended as a proof of concept. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Jan 16 11:19:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 32AB14766BA for ; Thu, 16 Jan 2003 11:19:48 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 1E463476A4A for ; Thu, 16 Jan 2003 11:18:52 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h0GGIZi16755; Thu, 16 Jan 2003 11:18:35 -0500 (EST) From: Bruce Momjian Message-Id: <200301161618.h0GGIZi16755@candle.pha.pa.us> Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <3E26D564.1060209@clearmetrix.com> To: "Charles H. Woloszynski" Date: Thu, 16 Jan 2003 11:18:35 -0500 (EST) Cc: Tom Lane , Roman Fail , josh@agliodbs.com, pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/154 X-Sequence-Number: 801 Is this a TODO item? --------------------------------------------------------------------------- Charles H. Woloszynski wrote: > I was surprised to hear that JOIN syntax constrained the planner. We > have a policy of using JOIN syntax to describe the table relationships > and where clauses to describe the selection process for our queries. It > was our understanding that the JOIN syntax was introduced to support > this approach, but not to contrain the planner. > > Is there any way to sell the planner to consider JOIN syntax as > equivalent to WHERE clauses and to not use them to force the planner > down a specific path? Can we get that added as an option (and then made > available to use JDBC folks as a URL parameter). It would make my team > very happy :-). > > > I think that making this an option will help all those migrating to > Postgres who did not expect that JOINs forced the planner down specific > plans. Is it possible/reasonable to add? > > Charlie > > > Tom Lane wrote: > > >"Roman Fail" writes: > > > > > >>Thanks to everyone for the quick replies! I'm sure that my lack of > >>skill with SQL queries is the main problem. What's strange to me is > >>how MSSQL takes my bad queries and makes them look good anyway. It > >>must have a real smart planner. > >> > >> > > > >I think more likely the issue is that your use of JOIN syntax is forcing > >Postgres into a bad plan. MSSQL probably doesn't assign any semantic > >significance to the use of "a JOIN b" syntax as opposed to "FROM a, b" > >syntax. Postgres does. Whether this is a bug or a feature depends on > >your point of view --- but there are folks out there who find it to be > >a life-saver. You can find some explanations at > >http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit-joins.html > > > > > > > >>Is it pretty much universally accepted that I should drop all my > >>foreign keys? > >> > >> > > > >No. They don't have any effect on SELECT performance in Postgres. > >They will impact update speed, but that's not your complaint (at the > >moment). Don't throw away data integrity protection until you know > >you need to. > > > > regards, tom lane > > > >---------------------------(end of broadcast)--------------------------- > >TIP 4: Don't 'kill -9' the postmaster > > > > > > -- > > > Charles H. Woloszynski > > ClearMetrix, Inc. > 115 Research Drive > Bethlehem, PA 18015 > > tel: 610-419-2210 x400 > fax: 240-371-3256 > web: www.clearmetrix.com > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Thu Jan 16 11:27:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4D63E47687A for ; Thu, 16 Jan 2003 11:27:47 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id D65DA476CC6 for ; Thu, 16 Jan 2003 11:25:32 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030116162538.LDCY8666.lakemtao03.cox.net@[192.168.1.1]> for ; Thu, 16 Jan 2003 11:25:38 -0500 Subject: Re: schema/db design wrt performance From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <20030116080132.A4962-100000@megazone23.bigpanda.com> References: <20030116080132.A4962-100000@megazone23.bigpanda.com> Content-Type: text/plain Organization: Message-Id: <1042734336.892.42.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 16 Jan 2003 10:25:36 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/155 X-Sequence-Number: 802 On Thu, 2003-01-16 at 10:02, Stephan Szabo wrote: > On 16 Jan 2003, Ron Johnson wrote: > > > On Thu, 2003-01-16 at 09:39, Andrew Sullivan wrote: > > > On Thu, Jan 16, 2003 at 08:34:38AM -0600, Ron Johnson wrote: > > > > On Thu, 2003-01-16 at 08:20, Andrew Sullivan wrote: > > > > > > > > If a user has multiple connections and charges things to the same > > > > > account in more than one connection at the same time, the > > > > > transactions will have to be processed, effectively, in series: each > > > > > one will have to wait for another to commit in order to complete. > > > > > > > > This is true even though the default transaction mode is > > > > READ COMMITTED? > > > > > > Yes. Remember, _both_ of these are doing SELECT. . .FOR UPDATE. > > > Which means they both try to lock the corresponding record. But they > > > can't _both_ lock the same record; that's what the lock prevents. > > > > Could BEFORE INSERT|UPDATE|DELETE triggers perform the same > > functionality while touching only the desired records, thus > > decreasing conflict? > > It does limit it to the corresponding records, but if you > say insert a row pointing at customer 1, and in another transaction > insert a row pointing at customer 1, the second waits on the first. 2 points: 1. Don't you *want* TXN2 to wait on TXN1? 2. In an OLTP environment (heck, in *any* environment), the goal is to minimize txn length, so TXN2 shouldn't be waiting on TXN1 for more than a fraction of a second anyway. Am I missing something? -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Jan 16 11:38:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 72BBF476227 for ; Thu, 16 Jan 2003 11:38:38 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 6FCA9476306 for ; Thu, 16 Jan 2003 11:38:03 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 46E81D606; Thu, 16 Jan 2003 08:38:08 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 3CA3A5C02; Thu, 16 Jan 2003 08:38:08 -0800 (PST) Date: Thu, 16 Jan 2003 08:38:08 -0800 (PST) From: Stephan Szabo To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: schema/db design wrt performance In-Reply-To: <1042734336.892.42.camel@haggis> Message-ID: <20030116083403.X4962-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/156 X-Sequence-Number: 803 On 16 Jan 2003, Ron Johnson wrote: > On Thu, 2003-01-16 at 10:02, Stephan Szabo wrote: > > On 16 Jan 2003, Ron Johnson wrote: > > > > > On Thu, 2003-01-16 at 09:39, Andrew Sullivan wrote: > > > > On Thu, Jan 16, 2003 at 08:34:38AM -0600, Ron Johnson wrote: > > > > > On Thu, 2003-01-16 at 08:20, Andrew Sullivan wrote: > > > > > > > > > > If a user has multiple connections and charges things to the same > > > > > > account in more than one connection at the same time, the > > > > > > transactions will have to be processed, effectively, in series: each > > > > > > one will have to wait for another to commit in order to complete. > > > > > > > > > > This is true even though the default transaction mode is > > > > > READ COMMITTED? > > > > > > > > Yes. Remember, _both_ of these are doing SELECT. . .FOR UPDATE. > > > > Which means they both try to lock the corresponding record. But they > > > > can't _both_ lock the same record; that's what the lock prevents. > > > > > > Could BEFORE INSERT|UPDATE|DELETE triggers perform the same > > > functionality while touching only the desired records, thus > > > decreasing conflict? > > > > It does limit it to the corresponding records, but if you > > say insert a row pointing at customer 1, and in another transaction > > insert a row pointing at customer 1, the second waits on the first. > > 2 points: > > 1. Don't you *want* TXN2 to wait on TXN1? Not really. Maybe I was unclear though. Given create table pktable(a int primary key); create table fktable(a int references pktable); insert into pktable values (1); The blocking would occur on: T1: begin; T2: begin; T1: insert into fktable values (1); T2: insert into fktable values (1); This doesn't need to block. The reason for the lock is to prevent someone from updating or deleting the row out of pktable, but it also prevents this kind of thing. This becomes an issue if you say have tables that store mappings and a table that has an fk to that. You'll be inserting lots of rows with say customertype=7 which points into a table with types and they'll block. Worse, if you say do inserts with different customertypes in different orders in two transactions you can deadlock yourself. From pgsql-performance-owner@postgresql.org Thu Jan 16 11:46:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 92867475EF9 for ; Thu, 16 Jan 2003 11:46:13 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 229C8475BD7 for ; Thu, 16 Jan 2003 11:46:13 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ZD9m-0001ne-00 for ; Thu, 16 Jan 2003 11:46:18 -0500 Date: Thu, 16 Jan 2003 11:46:18 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: schema/db design wrt performance Message-ID: <20030116114618.G32288@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <20030116080132.A4962-100000@megazone23.bigpanda.com> <1042734336.892.42.camel@haggis> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1042734336.892.42.camel@haggis>; from ron.l.johnson@cox.net on Thu, Jan 16, 2003 at 10:25:36AM -0600 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/157 X-Sequence-Number: 804 On Thu, Jan 16, 2003 at 10:25:36AM -0600, Ron Johnson wrote: > > 2 points: > > 1. Don't you *want* TXN2 to wait on TXN1? Not really. You really just want a tag which prevents TXN2 from committing when its reference data might go away. So what you want is a lock which says "don't delete, no matter what", until TXN2 commits. Then TXN1 could fail or not, depending on what it's trying to do. The problem is that there isn't a lock of the right strength to do that. > 2. In an OLTP environment (heck, in *any* environment), the goal > is to minimize txn length, so TXN2 shouldn't be waiting on > TXN1 for more than a fraction of a second anyway. Right. But it's possible to have multiple REFERENCES constraints to the same table; that's why I picked an account table, for instance, because you might have a large number of different kinds of things that the same account can do. So while you're correct that one wants to minimize txn length, it's also true that, when the effects are followed across a large system, you can easily start tripping over the FKs. The real problem, then, only shows up on a busy system with a table which gets referenced a lot. I should note, by the way, that the tremendous performance improvements available in 7.2.x have reduced the problem considerably from 7.1.x, at least in my experience. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Jan 16 12:03:05 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6C7F476585 for ; Thu, 16 Jan 2003 12:03:02 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 6E1B3476306 for ; Thu, 16 Jan 2003 12:02:33 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 6FA5BD606; Thu, 16 Jan 2003 09:02:38 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 6554C5C02; Thu, 16 Jan 2003 09:02:38 -0800 (PST) Date: Thu, 16 Jan 2003 09:02:38 -0800 (PST) From: Stephan Szabo To: Roman Fail Cc: Josh Berkus , Tom Lane , Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C02@pos_pdc.posportal.com> Message-ID: <20030116085358.E5729-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/158 X-Sequence-Number: 805 On Thu, 16 Jan 2003, Roman Fail wrote: > *********************** Hmm, I wonder if maybe we're going about things backwards in this case. Does the original database have something like EXPLAIN that'll show what it's doing? Perhaps that'll give an idea. > > What does vacuum verbose batchdetail give you (it'll give an idea of pages anyway) > > trans=# VACUUM VERBOSE batchdetail; > INFO: --Relation public.batchdetail-- > INFO: Pages 1669047: Changed 0, Empty 0; Tup 23316674: Vac 0, Keep 0, UnUsed 0. So about 12 gigabytes of data, then? > It seems to me that the big, big isolated problem is the index scan on > batchdetail.tranamount. During this small query, 'sar -b' showed > consistent 90,000 block reads/sec. (contrast with only 6,000 with > larger query index scan). 'top' shows the CPU is at 20% user, 30% > system the whole time (contrast with 2% total in larger query above). Note that in this case below, you've gotten a sequence scan not an index scan. (similar to setting enable_indexscan=off performance) > This results here still seem pretty bad (although not as bad as > above), but I still don't know what is the bottleneck. And the > strange sar stats are confusing me. > > EXPLAIN ANALYZE SELECT * FROM batchdetail WHERE tranamount BETWEEN 300 AND 499; > Seq Scan on batchdetail (cost=0.00..2018797.11 rows=783291 width=440) (actual time=45.66..283926.58 rows=783687 loops=1) > Filter: ((tranamount >= 300::numeric) AND (tranamount <= 499::numeric)) > Total runtime: 285032.47 msec I'd assume that tranamount values are fairly randomly distributed throughout the table, right? It takes about 5 minutes for the system to read the entire table and more for the index scan, so you're probably reading most of the table randomly and the index as well. What values on batchdetail do you use in query where clauses regularly? It's possible that occasional clusters would help if this was the main field you filtered on. The cluster itself is time consuming, but it might help make the index scans actually read fewer pages. From pgsql-performance-owner@postgresql.org Thu Jan 16 12:16:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 782E1475F6A for ; Thu, 16 Jan 2003 12:16:26 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id ACEBB475BD7 for ; Thu, 16 Jan 2003 12:16:25 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2316163; Thu, 16 Jan 2003 09:16:33 -0800 From: "Josh Berkus" Subject: Re: 7.3.1 New install, large queries are slow To: Tom Lane , "Roman Fail" Cc: "Josh Berkus" , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Thu, 16 Jan 2003 09:16:33 -0800 Message-ID: In-Reply-To: <14736.1042730017@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/159 X-Sequence-Number: 806 Roman, Tom: > No no no ... this is even worse than before. Your big tables are > batchdetail (d) and purc1 (p1). What you've got to do is arrange the > computation so that those are trimmed to just the interesting records > as > soon as possible. When joining disproportionally large tables, I've also had some success with the following method: SELECT b.batchdate, d.batchdetailid, t.bankno, d.trandate, d.tranamount, d.submitinterchange, d.authamount, d.authno, d.cardtypeid, d.mcccode, m.name AS merchantname, c.cardtype, m.merchid, p1.localtaxamount, p1.productidentifier, dr.avsresponse, cr.checkoutdate, cr.noshowindicator, ck.checkingacctno, ck.abaroutingno, ck.checkno FROM tranheader t JOIN batchheader b ON (t.tranheaderid = b.tranheaderid AND b.batchdate > '2002-12-15') JOIN merchants m ON (m.merchantid = b.merchantid AND mmerchid = '701252267') JOIN batchdetail d ON (d.batchid = b.batchid AND d.tranamount BETWEEN 500 and 700) JOIN cardtype c ON d.cardtypeid = c.cardtypeid LEFT JOIN purc1 p1 ON p1.batchdetailid = d.batchdetailid LEFT JOIN direct dr ON dr.batchdetailid = d.batchdetailid LEFT JOIN carrental cr ON cr.batchdetailid = d.batchdetailid LEFT JOIN checks ck ON ck.batchdetailid = d.batchdetailid WHERE t.clientid = 6 AND d.tranamount BETWEEN 500.0 AND 700.0 AND b.batchdate > '2002-12-15' AND m.merchid = '701252267' ORDER BY b.batchdate DESC LIMIT 50 This could be re-arranged some, but I think you get the idea ... I've been able, in some queries, to get the planner to use a better and faster join strategy by repeating my WHERE conditions in the JOIN criteria. -Josh From pgsql-performance-owner@postgresql.org Thu Jan 16 12:25:56 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E7119476615 for ; Thu, 16 Jan 2003 12:25:53 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id CCEE4476122 for ; Thu, 16 Jan 2003 12:24:47 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030116172454.LRLW8666.lakemtao03.cox.net@[192.168.1.1]> for ; Thu, 16 Jan 2003 12:24:54 -0500 Subject: Re: schema/db design wrt performance From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <20030116083403.X4962-100000@megazone23.bigpanda.com> References: <20030116083403.X4962-100000@megazone23.bigpanda.com> Content-Type: text/plain Organization: Message-Id: <1042737892.889.56.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 16 Jan 2003 11:24:52 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/160 X-Sequence-Number: 807 On Thu, 2003-01-16 at 10:38, Stephan Szabo wrote: > On 16 Jan 2003, Ron Johnson wrote: > > > On Thu, 2003-01-16 at 10:02, Stephan Szabo wrote: > > > On 16 Jan 2003, Ron Johnson wrote: > > > > > > > On Thu, 2003-01-16 at 09:39, Andrew Sullivan wrote: > > > > > On Thu, Jan 16, 2003 at 08:34:38AM -0600, Ron Johnson wrote: > > > > > > On Thu, 2003-01-16 at 08:20, Andrew Sullivan wrote: > > > > > > > > > > > > If a user has multiple connections and charges things to the same > > > > > > > account in more than one connection at the same time, the > > > > > > > transactions will have to be processed, effectively, in series: each > > > > > > > one will have to wait for another to commit in order to complete. > > > > > > > > > > > > This is true even though the default transaction mode is > > > > > > READ COMMITTED? > > > > > > > > > > Yes. Remember, _both_ of these are doing SELECT. . .FOR UPDATE. > > > > > Which means they both try to lock the corresponding record. But they > > > > > can't _both_ lock the same record; that's what the lock prevents. > > > > > > > > Could BEFORE INSERT|UPDATE|DELETE triggers perform the same > > > > functionality while touching only the desired records, thus > > > > decreasing conflict? > > > > > > It does limit it to the corresponding records, but if you > > > say insert a row pointing at customer 1, and in another transaction > > > insert a row pointing at customer 1, the second waits on the first. > > > > 2 points: > > > > 1. Don't you *want* TXN2 to wait on TXN1? > > Not really. Maybe I was unclear though. > > Given > create table pktable(a int primary key); > create table fktable(a int references pktable); > insert into pktable values (1); > > The blocking would occur on: > T1: begin; > T2: begin; > T1: insert into fktable values (1); > T2: insert into fktable values (1); > > This doesn't need to block. The reason for > the lock is to prevent someone from updating > or deleting the row out of pktable, but it > also prevents this kind of thing. This becomes > an issue if you say have tables that store mappings > and a table that has an fk to that. You'll > be inserting lots of rows with say > customertype=7 which points into a table with > types and they'll block. Worse, if you say > do inserts with different customertypes in > different orders in two transactions you > can deadlock yourself. So Postgres will think it's possible that I could modify the reference table that "customertype=7" refers to? If so, bummer. The commercial RDBMS that I use (Rdb/VMS) allows one to specify that certain tables are only for read access. For example: SET TRANSACTION READ WRITE RESERVING T_MASTER, T_DETAIL FOR SHARED WRITE, T_MAPPING1, T_MAPPING2, T_MAPPING3 FOR SHARED READ; Thus, only minimal locking is taken out on T_MAPPING1, T_MAPPING2 & T_MAPPING3, but if I try to "UPDATE T_MAPPING1" or reference any other table, even in a SELECT statement, then the statement will fail. Rdb also alows for exclusive write locks: SET TRANSACTION READ WRITE RESERVING T_MASTER, T_DETAIL FOR SHARED WRITE, T_MAPPING1, T_MAPPING2, T_MAPPING3 FOR SHARED READ, T_FOOBAR FOR EXCLUSIVE WRITE; Thus, even though there is concurrent access to the other tables, a table lock on T_FOOBAR is taken out. This cuts IO usage in 1/2, but obviously must be used with great discretion. -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Jan 16 12:28:23 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 851F54761DD for ; Thu, 16 Jan 2003 12:28:21 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id CCEF147619E for ; Thu, 16 Jan 2003 12:28:20 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2316193; Thu, 16 Jan 2003 09:28:28 -0800 From: "Josh Berkus" Subject: Re: 7.3.1 New install, large queries are slow To: "Roman Fail" , "Josh Berkus" , "Tom Lane" , Cc: X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Thu, 16 Jan 2003 09:28:28 -0800 Message-ID: In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C02@pos_pdc.posportal.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/161 X-Sequence-Number: 808 Roman, > > Hey, Roman, how many records in BatchDetail, anyway? > > 23 million. And MSSQL is returning results in 3 seconds? I find that a bit hard to believe, unless this query is called repeatedly and that's the figure for the last call, where the records are being cached. I'll have to look at your hardware descriptions again. > It seems to me that the big, big isolated problem is the index scan > on batchdetail.tranamount. Nope. This was a misimpression caused by batchdetail waiting for a bunch of other processes to complete. Sometimes the parallelizing gives me a wrong impression of what's holding up the query. Sorry if I confused you. > I hope we can come up with something soon.....it seems this index > scan is a big part of the problem. I'm still really curious why the > disk reads are so few with the index scan. Let's hope I can get it > near the 3 second time for MSSQL by Friday! Um, Roman, keep in mind this is a mailing list. I'm sure that everyone here is happy to give you the tools to figure out how to fix things, but only in a DIY fashion, and not on your schedule. If you have a deadline, you'd better hire some paid query/database tuning help. DB Tuning experts .... whether on MSSQL or Postgres ... run about $250/hour last I checked. -Josh Berkus From pgsql-performance-owner@postgresql.org Thu Jan 16 12:30:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D80B4476547 for ; Thu, 16 Jan 2003 12:30:08 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id BF3784764AB for ; Thu, 16 Jan 2003 12:30:07 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0GHU95u016506; Thu, 16 Jan 2003 12:30:09 -0500 (EST) To: "Josh Berkus" Cc: "Roman Fail" , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: References: Comments: In-reply-to "Josh Berkus" message dated "Thu, 16 Jan 2003 09:16:33 -0800" Date: Thu, 16 Jan 2003 12:30:09 -0500 Message-ID: <16505.1042738209@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/162 X-Sequence-Number: 809 "Josh Berkus" writes: > This could be re-arranged some, but I think you get the idea ... I've > been able, in some queries, to get the planner to use a better and > faster join strategy by repeating my WHERE conditions in the JOIN > criteria. Hm. It shouldn't be necessary to do that --- the planner should be able to push down the WHERE conditions to the right place without that help. The list of explicit JOINs as you have here is a good way to proceed *if* you write the JOINs in an appropriate order for implementation. I believe the problem with Roman's original query was that he listed the JOINs in a bad order. Unfortunately I didn't keep a copy of that message, and the list archives seem to be a day or more behind... but at least for these WHERE conditions, it looks like the best bet would to join m to b (I'm assuming m.merchid is unique), then to t, then to d, then add on the others. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 16 12:47:00 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6C11747619E for ; Thu, 16 Jan 2003 12:46:57 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id EE9CA47610B for ; Thu, 16 Jan 2003 12:46:56 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 614AAD606; Thu, 16 Jan 2003 09:47:02 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 5704B5C02; Thu, 16 Jan 2003 09:47:02 -0800 (PST) Date: Thu, 16 Jan 2003 09:47:02 -0800 (PST) From: Stephan Szabo To: Josh Berkus Cc: Roman Fail , Tom Lane , Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: Message-ID: <20030116094210.L6318-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/163 X-Sequence-Number: 810 On Thu, 16 Jan 2003, Josh Berkus wrote: > Roman, > > > > Hey, Roman, how many records in BatchDetail, anyway? > > > > 23 million. > > And MSSQL is returning results in 3 seconds? I find that a bit hard > to believe, unless this query is called repeatedly and that's the > figure for the last call, where the records are being cached. I'll > have to look at your hardware descriptions again. > > > It seems to me that the big, big isolated problem is the index scan > > on batchdetail.tranamount. > > Nope. This was a misimpression caused by batchdetail waiting for a > bunch of other processes to complete. Sometimes the parallelizing > gives me a wrong impression of what's holding up the query. Sorry if I > confused you. I'm still not sure that it isn't a big part given that the time went down by a factor of about 4 when index scans were disabled and a sequence scan was done and that a sequence scan over the table with no other tables joined looked to take about 5 minutes itself and the difference between that seqscan and the big query was only about 20 seconds when enable_indexscan was off unless I'm misreading those results. From pgsql-performance-owner@postgresql.org Thu Jan 16 12:52:51 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 116804760CE for ; Thu, 16 Jan 2003 12:52:50 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 61A734767DA for ; Thu, 16 Jan 2003 12:52:39 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2316240; Thu, 16 Jan 2003 09:52:47 -0800 From: "Josh Berkus" Subject: Re: 7.3.1 New install, large queries are slow To: Tom Lane , "Josh Berkus" Cc: "Roman Fail" , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Thu, 16 Jan 2003 09:52:47 -0800 Message-ID: In-Reply-To: <16505.1042738209@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/164 X-Sequence-Number: 811 Tom, > The list of explicit JOINs as you have here is a good way to proceed > *if* you write the JOINs in an appropriate order for implementation. > I believe the problem with Roman's original query was that he listed > the JOINs in a bad order. Unfortunately I didn't keep a copy of that > message, and the list archives seem to be a day or more behind... > but at least for these WHERE conditions, it looks like the best bet > would to join m to b (I'm assuming m.merchid is unique), then to t, > then to d, then add on the others. I realize that I've contributed nothing other than bug reports to the parser design. But shouldn't Postgres, given a free hand, figure out the above automatically? I'd be embarassed if MS could one-up us in parser planning anywhere, theirs sucks on sub-selects .... -Josh Berkus From pgsql-performance-owner@postgresql.org Thu Jan 16 13:40:44 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D72554753A1 for ; Thu, 16 Jan 2003 13:40:41 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B139A476547 for ; Thu, 16 Jan 2003 13:40:36 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0GIeW5u026147; Thu, 16 Jan 2003 13:40:33 -0500 (EST) To: "Josh Berkus" Cc: "Roman Fail" , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: References: Comments: In-reply-to "Josh Berkus" message dated "Thu, 16 Jan 2003 09:52:47 -0800" Date: Thu, 16 Jan 2003 13:40:32 -0500 Message-ID: <26146.1042742432@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/165 X-Sequence-Number: 812 "Josh Berkus" writes: >> but at least for these WHERE conditions, it looks like the best bet >> would to join m to b (I'm assuming m.merchid is unique), then to t, >> then to d, then add on the others. > I realize that I've contributed nothing other than bug reports to the > parser design. But shouldn't Postgres, given a free hand, figure out > the above automatically? I believe it will. So far I've not seen an EXPLAIN from a query that was structured to give it a free hand. As noted elsewhere, the fact that we allow JOIN syntax to constrain the planner is a real pain if you are accustomed to databases that don't do that. On the other hand, it's a real lifesaver for people who need to pare the planning time for dozen-way joins; it was only a day or two back in this same mailing list that we last had a discussion about that end of the problem. So even though it started out as an implementation shortcut rather than an intended feature, I'm loathe to just disable the behavior entirely. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 16 13:51:28 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 682AD476C13 for ; Thu, 16 Jan 2003 13:43:44 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 52AB1476D69 for ; Thu, 16 Jan 2003 13:43:02 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 2918AD606; Thu, 16 Jan 2003 10:43:02 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 1AC8B5C02; Thu, 16 Jan 2003 10:43:02 -0800 (PST) Date: Thu, 16 Jan 2003 10:43:02 -0800 (PST) From: Stephan Szabo To: Roman Fail Cc: , Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4BFD@pos_pdc.posportal.com> Message-ID: <20030116103622.K6828-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/166 X-Sequence-Number: 813 On Wed, 15 Jan 2003, Roman Fail wrote: I just had new thoughts. If you make an index on batchdetail(batchid) does that help? I realized that it was doing a merge join to join d and the (t,b,m) combination when it was expecting 3 rows out of the latter, and batchid is presumably fairly selective on the batchdetail table, right? I'd have expected a nested loop over the id column, but it doesn't appear you have an index on it in batchdetail. Then I realized that batchheader.batchid and batchdetail.batchid don't even have the same type, and that's probably something else you'd need to fix. > batchheader has 2.6 million records: > CREATE TABLE public.batchheader ( > batchid int8 DEFAULT nextval('"batchheader_batchid_key"'::text) NOT NULL, > And here's batchdetail too, just for kicks. 23 million records. > CREATE TABLE public.batchdetail ( > batchid int4, From pgsql-performance-owner@postgresql.org Thu Jan 16 14:51:34 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3DBAF4768F9 for ; Thu, 16 Jan 2003 14:50:46 -0500 (EST) Received: from pos_pdc.posportal.com (unknown [12.158.169.100]) by postgresql.org (Postfix) with ESMTP id 4C51B4771B6 for ; Thu, 16 Jan 2003 14:22:22 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Re: 7.3.1 New install, large queries are slow Date: Thu, 16 Jan 2003 11:22:03 -0800 Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C06@pos_pdc.posportal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] 7.3.1 New install, large queries are slow Thread-Index: AcK9hK1eAKq/LDlWSFqachkkBnyCAAABkDvh From: "Roman Fail" To: "Josh Berkus" , "Tom Lane" , Cc: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/167 X-Sequence-Number: 814 PiBKb3NoIEJlcmt1cyB3cm90ZToNCj4gQW5kIE1TU1FMIGlzIHJldHVybmlu ZyByZXN1bHRzIGluIDMgc2Vjb25kcz8gICAgSSBmaW5kIHRoYXQgYSBiaXQg aGFyZA0KPiB0byBiZWxpZXZlLCB1bmxlc3MgdGhpcyBxdWVyeSBpcyBjYWxs ZWQgcmVwZWF0ZWRseSBhbmQgdGhhdCdzIHRoZQ0KPiBmaWd1cmUgZm9yIHRo ZSBsYXN0IGNhbGwsIHdoZXJlIHRoZSByZWNvcmRzIGFyZSBiZWluZyBjYWNo ZWQuICAgSSdsbA0KPiBoYXZlIHRvIGxvb2sgYXQgeW91ciBoYXJkd2FyZSBk ZXNjcmlwdGlvbnMgYWdhaW4uDQoNCkhhcmR3YXJlLXdpc2UsIHRoZSBQb3N0 Z3JlcyBzZXJ2ZXIgaXMgYSBob3Qgcm9kIGFuZCBNU1NRTCBpcyBhIGJhc2lj IHZhbmlsbGEgc2VydmVyLiAgSSBjaGFuZ2VkIGFsbCB0aGUgV0hFUkUgY2xh dXNlcyB0byByYWRpY2FsbHkgZGlmZmVyZW50IHZhbHVlcyBhbmQgY291bGRu J3QgZ2V0IGl0IHRvIHRha2UgbW9yZSB0aGFuIDUgc2Vjb25kcyBvbiBNU1NR TC4gIE1vc3Qgb2YgaXQncyBjb3N0IHNhdmluZ3Mgc2VlbXMgdG8gY29tZSBm cm9tIHNvbWUga2luZCBvZiAiVGFibGUgU3Bvb2wvTGF6eSBTcG9vbCIgaW4g aXQncyBleGVjdXRpb24gcGxhbiwgd2hpY2ggbG9va3MgdG8gbWUgbGlrZSBp dCBvbmx5IGV4aXN0cyBmb3IgdGhlIGxpZmUgb2YgdGhlIHF1ZXJ5LiAgWW91 IGNhbiByZWFkIG1vcmUgYWJvdXQgdGhpcyBhdDoNCmh0dHA6Ly9tc2RuLm1p Y3Jvc29mdC5jb20vbGlicmFyeS9kZWZhdWx0LmFzcD91cmw9L2xpYnJhcnkv ZW4tdXMvb3B0aW1zcWwvb2RwX3R1bl8xXzFtN2cuYXNwDQpodHRwOi8vbXNk bi5taWNyb3NvZnQuY29tL2xpYnJhcnkvZGVmYXVsdC5hc3A/dXJsPS9saWJy YXJ5L2VuLXVzL29wdGltc3FsL29kcF90dW5fMV83cmpnLmFzcA0KTWF5YmUg dGhlcmUgYXJlIHNvbWUgZ29vZCBpZGVhcyBoZXJlIGZvciBQb3N0Z3Jlcy4g IFVuZm9ydHVuYXRlbHksIHRoZSBNU1NRTCBFeGVjdXRpb24gUGxhbiBpcyBk aXNwbGF5ZWQgZ3JhcGhpY2FsbHksIGFuZCBJIGNhbid0IGZpZ3VyZSBvdXQg YSB3YXkgdG8gZ2V0IGl0IHRvIHRleHQgd2l0aG91dCB0eXBpbmcgaXQgYWxs LiAgSSBjb3VsZCBkbyBzb21lIHNjcmVlbiBzaG90cyBpZiB5b3UgcmVhbGx5 IHdhbnQgdG8gc2VlIGl0Lg0KIA0KPiBTdGVwaGFuIFN6YWJvIHdyb3RlOg0K PiBJJ2QgYXNzdW1lIHRoYXQgdHJhbmFtb3VudCB2YWx1ZXMgYXJlIGZhaXJs eSByYW5kb21seSBkaXN0cmlidXRlZA0KPiB0aHJvdWdob3V0IHRoZSB0YWJs ZSwgcmlnaHQ/ICBJdCB0YWtlcyBhYm91dCA1IG1pbnV0ZXMgZm9yIHRoZQ0K PiBzeXN0ZW0gdG8gcmVhZCB0aGUgZW50aXJlIHRhYmxlIGFuZCBtb3JlIGZv ciB0aGUgaW5kZXggc2Nhbiwgc28NCj4geW91J3JlIHByb2JhYmx5IHJlYWRp bmcgbW9zdCBvZiB0aGUgdGFibGUgcmFuZG9tbHkgYW5kIHRoZSBpbmRleA0K PiBhcyB3ZWxsLg0KPiBXaGF0IHZhbHVlcyBvbiBiYXRjaGRldGFpbCBkbyB5 b3UgdXNlIGluIHF1ZXJ5IHdoZXJlIGNsYXVzZXMgcmVndWxhcmx5PyANCiAN ClllcywgdHJhbmFtb3VudCB2YWx1ZXMgYXJlIHJhbmRvbWx5IGRpc3RyaWJ1 dGVkLiAgSSBkb24ndCB1bmRlcnN0YW5kIHdoeSBhbiBpbmRleCBzY2FuIHdv dWxkIGJlICJyYW5kb20iLCBpc24ndCB0aGUgd2hvbGUgcG9pbnQgb2YgYW4g aW5kZXggdG8gaGF2ZSBhbiBvcmRlcmVkIHJlZmVyZW5jZSBpbnRvIHRoZSBk YXRhPyAgYmF0Y2hkZXRhaWwgaGFzIDUgY29sdW1ucyB0aGF0IGNhbiBiZSBp biB0aGUgV0hFUkUgY2xhdXNlLCBhbGwgb2Ygd2hpY2ggYXJlIGluZGV4ZWQu ICBOb25lIGlzIG1vcmUgbGlrZWx5IHRoYW4gdGhlIG90aGVyIHRvIGJlIHNl YXJjaGVkLCBzbyBhIGNsdXN0ZXJlZCBpbmRleCBkb2Vzbid0IG1ha2UgbXVj aCBzZW5zZSB0byBtZS4gIFRoZSB3aG9sZSB0aGluZyBuZWVkcyB0byBiZSBm YXN0Lg0KIA0KPj4gTm9wZS4gIFRoaXMgd2FzIGEgbWlzaW1wcmVzc2lvbiBj YXVzZWQgYnkgYmF0Y2hkZXRhaWwgd2FpdGluZyBmb3IgYQ0KPj4gYnVuY2gg b2Ygb3RoZXIgcHJvY2Vzc2VzIHRvIGNvbXBsZXRlLiAgU29tZXRpbWVzIHRo ZSBwYXJhbGxlbGl6aW5nDQo+PiBnaXZlcyBtZSBhIHdyb25nIGltcHJlc3Np b24gb2Ygd2hhdCdzIGhvbGRpbmcgdXAgdGhlIHF1ZXJ5LiAgU29ycnkgaWYg SQ0KPj4gY29uZnVzZWQgeW91Lg0KPg0KPkknbSBzdGlsbCBub3Qgc3VyZSB0 aGF0IGl0IGlzbid0IGEgYmlnIHBhcnQgZ2l2ZW4gdGhhdCB0aGUgdGltZSB3 ZW50IGRvd24NCj5ieSBhIGZhY3RvciBvZiBhYm91dCA0IHdoZW4gaW5kZXgg c2NhbnMgd2VyZSBkaXNhYmxlZCBhbmQgYSBzZXF1ZW5jZSBzY2FuDQo+d2Fz IGRvbmUgYW5kIHRoYXQgYSBzZXF1ZW5jZSBzY2FuIG92ZXIgdGhlIHRhYmxl IHdpdGggbm8gb3RoZXIgdGFibGVzDQo+am9pbmVkIGxvb2tlZCB0byB0YWtl IGFib3V0IDUgbWludXRlcyBpdHNlbGYgYW5kIHRoZSBkaWZmZXJlbmNlIGJl dHdlZW4NCj50aGF0IHNlcXNjYW4gYW5kIHRoZSBiaWcgcXVlcnkgd2FzIG9u bHkgYWJvdXQgMjAgc2Vjb25kcyB3aGVuDQo+ZW5hYmxlX2luZGV4c2NhbiB3 YXMgb2ZmIHVubGVzcyBJJ20gbWlzcmVhZGluZyB0aG9zZSByZXN1bHRzLg0K DQpZb3UgYXJlIG5vdCBtaXNyZWFkaW5nIHRoZSByZXN1bHRzLiAgVGhlcmUg d2FzIGEgaHVnZSBkaWZmZXJlbmNlLiAgTm9ib2R5IGhhcyBldmVyIG1hZGUg bm90ZSBvZiBpdCwgYnV0IHRoaXMgc3RpbGwgc2VlbXMgdmVyeSBvZGQgdG8g bWU6DQoqKiogJ3NhciAtYicgZHVyaW5nIHRoZSBxdWVyeQ0Kd2l0aCBpbmRl eCBzY2FuOiA2LDAwMCBibG9jayByZWFkcy9zZWMNCndpdGggc2VxIHNjYW46 IDk1LDAwMCBibG9jayByZWFkcy9zZWMNCiANCiANClRvbSwgaGVyZSBpcyB0 aGUgRVhQTEFJTiBmb3IgeW91ciBzdWdnZXN0ZWQgdmVyc2lvbiBvZiB0aGUg cXVlcnkgd2l0aCBlbmFibGVfaW5kZXhzY2FuPW9uLiAgSSBwZXJmb3JtZWQg dGhlIHNhbWUgcXVlcnkgd2l0aCBlbmFibGVfaW5kZXhzY2FuPW9mZiBhbmQg dG90YWwgcnVudGltZSB3YXMgKm11Y2gqIGJldHRlcjogMjk2MTc0LjYwIG1z ZWMuICBCeSB0aGUgd2F5LCB0aGFuayB5b3UgZm9yIHlvdXIgZGV0YWlsZWQg ZGVzY3JpcHRpb24gb2YgaG93IHRoZSBKT0lOIG9yZGVyIGFmZmVjdHMgdGhl IG91dGNvbWUgLSBJIHVuZGVyc3RhbmQgbXVjaCBiZXR0ZXIgbm93Lg0KRVhQ TEFJTiBBTkFMWVpFDQpTRUxFQ1Qgc3MuYmF0Y2hkYXRlLCBzcy5iYXRjaGRl dGFpbGlkLCBzcy5iYW5rbm8sIHNzLnRyYW5kYXRlLCBzcy50cmFuYW1vdW50 LA0Kc3Muc3VibWl0aW50ZXJjaGFuZ2UsIHNzLmF1dGhhbW91bnQsIHNzLmF1 dGhubywgc3MuY2FyZHR5cGVpZCwgc3MubWNjY29kZSwNCnNzLm5hbWUgQVMg bWVyY2hhbnRuYW1lLCBzcy5jYXJkdHlwZSwgc3MubWVyY2hpZCwNCnAxLmxv Y2FsdGF4YW1vdW50LCBwMS5wcm9kdWN0aWRlbnRpZmllciwgZHIuYXZzcmVz cG9uc2UsDQpjci5jaGVja291dGRhdGUsIGNyLm5vc2hvd2luZGljYXRvciwg Y2suY2hlY2tpbmdhY2N0bm8sDQpjay5hYmFyb3V0aW5nbm8sIGNrLmNoZWNr bm8NCkZST00NCiAgKFNFTEVDVCBiLmJhdGNoZGF0ZSwgZC5iYXRjaGRldGFp bGlkLCB0LmJhbmtubywgZC50cmFuZGF0ZSwgZC50cmFuYW1vdW50LA0KICAg ICAgIGQuc3VibWl0aW50ZXJjaGFuZ2UsIGQuYXV0aGFtb3VudCwgZC5hdXRo bm8sIGQuY2FyZHR5cGVpZCwgZC5tY2Njb2RlLA0KICAgICAgIG0ubmFtZSwg Yy5jYXJkdHlwZSwgbS5tZXJjaGlkDQogICBGUk9NIHRyYW5oZWFkZXIgdCwg YmF0Y2hoZWFkZXIgYiwgbWVyY2hhbnRzIG0sIGNhcmR0eXBlIGMsIGJhdGNo ZGV0YWlsIGQNCiAgIFdIRVJFIHQudHJhbmhlYWRlcmlkPWIudHJhbmhlYWRl cmlkDQogICBBTkQgbS5tZXJjaGFudGlkPWIubWVyY2hhbnRpZA0KICAgQU5E IGQuYmF0Y2hpZD1iLmJhdGNoaWQNCiAgIEFORCBjLmNhcmR0eXBlaWQ9ZC5j YXJkdHlwZWlkDQogICBBTkQgdC5jbGllbnRpZCA9IDYNCiAgIEFORCBkLnRy YW5hbW91bnQgQkVUV0VFTiA1MDAuMCBBTkQgNzAwLjANCiAgIEFORCBiLmJh dGNoZGF0ZSA+ICcyMDAyLTEyLTE1Jw0KICAgQU5EIG0ubWVyY2hpZCA9ICc3 MDEyNTIyNjcnKSBzcw0KICBMRUZUIEpPSU4gcHVyYzEgcDEgb24gcDEuYmF0 Y2hkZXRhaWxpZD1zcy5iYXRjaGRldGFpbGlkDQogIExFRlQgSk9JTiBkaXJl Y3QgZHIgT04gZHIuYmF0Y2hkZXRhaWxpZCA9IHNzLmJhdGNoZGV0YWlsaWQN CiAgTEVGVCBKT0lOIGNhcnJlbnRhbCBjciBPTiBjci5iYXRjaGRldGFpbGlk ID0gc3MuYmF0Y2hkZXRhaWxpZA0KICBMRUZUIEpPSU4gY2hlY2tzIGNrIE9O IGNrLmJhdGNoZGV0YWlsaWQgPSBzcy5iYXRjaGRldGFpbGlkDQpPUkRFUiBC WSBzcy5iYXRjaGRhdGUgREVTQw0KTElNSVQgNTANCkxpbWl0ICAoY29zdD0x NjAxNjM3Ljc1Li4xNjAxNjM3Ljc1IHJvd3M9MSB3aWR0aD0yODUpIChhY3R1 YWwgdGltZT0xMjIxNjA2LjQxLi4xMjIxNjA2LjQyIHJvd3M9NSBsb29wcz0x KQ0KICAtPiAgU29ydCAgKGNvc3Q9MTYwMTYzNy43NS4uMTYwMTYzNy43NSBy b3dzPTEgd2lkdGg9Mjg1KSAoYWN0dWFsIHRpbWU9MTIyMTYwNi40MC4uMTIy MTYwNi40MSByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgU29ydCBLZXk6IGIu YmF0Y2hkYXRlDQogICAgICAgIC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MTU0 MzU5NS4xOC4uMTYwMTYzNy43NCByb3dzPTEgd2lkdGg9Mjg1KSAoYWN0dWFs IHRpbWU9MTIwNDgxNS4wMi4uMTIyMTYwNi4yNyByb3dzPTUgbG9vcHM9MSkN CiAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLmJhdGNoZGV0 YWlsaWQgPSAib3V0ZXIiLmJhdGNoZGV0YWlsaWQpDQogICAgICAgICAgICAg IC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MTU0MzU5NS4xOC4uMTYwMTU4MS4y MyByb3dzPTEgd2lkdGg9MjQ3KSAoYWN0dWFsIHRpbWU9MTIwNDc5Mi4zOC4u MTIyMTU2MC40MiByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAg ICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLmJhdGNoZGV0YWlsaWQgPSAib3V0 ZXIiLmJhdGNoZGV0YWlsaWQpDQogICAgICAgICAgICAgICAgICAgIC0+ICBO ZXN0ZWQgTG9vcCAgKGNvc3Q9MTU0MzU5NS4xOC4uMTYwMTU4MS4yMiByb3dz PTEgd2lkdGg9MjMwKSAoYWN0dWFsIHRpbWU9MTIwNDc5Mi4zNS4uMTIyMTU2 MC4yNyByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLmJhdGNoZGV0YWlsaWQgPSAib3V0 ZXIiLmJhdGNoZGV0YWlsaWQpDQogICAgICAgICAgICAgICAgICAgICAgICAg IC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MTU0MzU5NS4xOC4uMTYwMTU4MS4y MSByb3dzPTEgd2lkdGg9MjIxKSAoYWN0dWFsIHRpbWU9MTIwNDc5Mi4zMS4u MTIyMTU2MC4wOSByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLmJhdGNoZGV0 YWlsaWQgPSAib3V0ZXIiLmJhdGNoZGV0YWlsaWQpDQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MTU0 MzU5NS4xOC4uMTU0NTUyOS4xNyByb3dzPTEgd2lkdGg9MjAyKSAoYWN0dWFs IHRpbWU9MTE5NTM3Ni40OC4uMTE5NTU3OC44NiByb3dzPTUgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSm9pbiBG aWx0ZXI6ICgiaW5uZXIiLnRyYW5oZWFkZXJpZCA9ICJvdXRlciIudHJhbmhl YWRlcmlkKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAtPiAgTmVzdGVkIExvb3AgIChjb3N0PTE1NDM1OTUuMTguLjE1NDU0NDku OTggcm93cz0xIHdpZHRoPTE4NikgKGFjdHVhbCB0aW1lPTExOTUzNzAuNzIu LjExOTU1MzYuNTMgcm93cz01IGxvb3BzPTEpDQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIEpvaW4gRmlsdGVyOiAoImlu bmVyIi5jYXJkdHlwZWlkID0gIm91dGVyIi5jYXJkdHlwZWlkKQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgTWVy Z2UgSm9pbiAgKGNvc3Q9MTU0MzU5NS4xOC4uMTU0NTQ0OC43NiByb3dzPTEg d2lkdGg9MTcyKSAoYWN0dWFsIHRpbWU9MTE5NTMxMS44OC4uMTE5NTQ3Ny4z MiByb3dzPTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgTWVyZ2UgQ29uZDogKCJvdXRlciIu YmF0Y2hpZCA9ICJpbm5lciIuYmF0Y2hpZCkNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNvcnQgIChj b3N0PTQ3Ni4xNy4uNDc2LjE4IHJvd3M9NCB3aWR0aD0xMDIpIChhY3R1YWwg dGltZT0zMC41Ny4uMzAuNTkgcm93cz0xNyBsb29wcz0xKQ0KICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBTb3J0IEtleTogYi5iYXRjaGlkDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBOZXN0ZWQg TG9vcCAgKGNvc3Q9MC4wMC4uNDc2LjE0IHJvd3M9NCB3aWR0aD0xMDIpIChh Y3R1YWwgdGltZT0yNS4yMS4uMzAuNDcgcm93cz0xNyBsb29wcz0xKQ0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyBtZXJjaGFudHNf aXhfbWVyY2hpZF9pZHggb24gbWVyY2hhbnRzIG0gIChjb3N0PTAuMDAuLjUu NjUgcm93cz0xIHdpZHRoPTc4KSAoYWN0dWFsIHRpbWU9MjMuODEuLjIzLjgy IHJvd3M9MSBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRl eCBDb25kOiAobWVyY2hpZCA9ICc3MDEyNTIyNjcnOjpjaGFyYWN0ZXIgdmFy eWluZykNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcg YmF0Y2hoZWFkZXJfaXhfbWVyY2hhbnRpZF9pZHggb24gYmF0Y2hoZWFkZXIg YiAgKGNvc3Q9MC4wMC4uNDcwLjMwIHJvd3M9MTUgd2lkdGg9MjQpIChhY3R1 YWwgdGltZT0xLjM4Li42LjU1IHJvd3M9MTcgbG9vcHM9MSkNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCJvdXRlciIubWVyY2hhbnRp ZCA9IGIubWVyY2hhbnRpZCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRmls dGVyOiAoYmF0Y2hkYXRlID4gJzIwMDItMTItMTUgMDA6MDA6MDAnOjp0aW1l c3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTb3J0ICAoY29z dD0xNTQzMTE5LjAxLi4xNTQ0MDQ1Ljc5IHJvd3M9MzcwNzEwIHdpZHRoPTcw KSAoYWN0dWFsIHRpbWU9MTE5NDI2MC41MS4uMTE5NDg5Mi43OSByb3dzPTM2 ODY4MSBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBTb3J0IEtleTogZC5iYXRjaGlk DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nIGJhdGNoZGV0YWls X2l4X3RyYW5hbW91bnRfaWR4IG9uIGJhdGNoZGV0YWlsIGQgIChjb3N0PTAu MDAuLjE0ODkxMDMuNDYgcm93cz0zNzA3MTAgd2lkdGg9NzApIChhY3R1YWwg dGltZT01LjI2Li4xMTg2MDUxLjQ0IHJvd3M9MzcwMzA3IGxvb3BzPTEpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6ICgodHJhbmFtb3VudCA+PSA1 MDAuMCkgQU5EICh0cmFuYW1vdW50IDw9IDcwMC4wKSkNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2Fu IG9uIGNhcmR0eXBlIGMgIChjb3N0PTAuMDAuLjEuMTAgcm93cz0xMCB3aWR0 aD0xNCkgKGFjdHVhbCB0aW1lPTExLjc3Li4xMS43OSByb3dzPTEwIGxvb3Bz PTUpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ ICBTZXEgU2NhbiBvbiB0cmFuaGVhZGVyIHQgIChjb3N0PTAuMDAuLjU1LjE1 IHJvd3M9MTkyMyB3aWR0aD0xNikgKGFjdHVhbCB0aW1lPTAuMDIuLjUuNDYg cm93cz0xOTIzIGxvb3BzPTUpDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIEZpbHRlcjogKGNsaWVudGlkID0gNikNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9u IHB1cmMxIHAxICAoY29zdD0wLjAwLi40NDI4NS4zNSByb3dzPTk0MTMzNSB3 aWR0aD0xOSkgKGFjdHVhbCB0aW1lPTEwLjc5Li4zNzYzLjU2IHJvd3M9OTM4 NzcwIGxvb3BzPTUpDQogICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBT ZXEgU2NhbiBvbiBkaXJlY3QgZHIgIChjb3N0PTAuMDAuLjAuMDAgcm93cz0x IHdpZHRoPTkpIChhY3R1YWwgdGltZT0wLjAwLi4wLjAwIHJvd3M9MCBsb29w cz01KQ0KICAgICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gY2Fy cmVudGFsIGNyICAoY29zdD0wLjAwLi4wLjAwIHJvd3M9MSB3aWR0aD0xNykg KGFjdHVhbCB0aW1lPTAuMDAuLjAuMDAgcm93cz0wIGxvb3BzPTUpDQogICAg ICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBjaGVja3MgY2sgIChjb3N0PTAu MDAuLjQwLjY3IHJvd3M9MTI2NyB3aWR0aD0zOCkgKGFjdHVhbCB0aW1lPTAu NzcuLjcuMTUgcm93cz0xMjY3IGxvb3BzPTUpDQpUb3RhbCBydW50aW1lOiAx MjIxNjQ1LjUyIG1zZWMNCg0KIA0KPiBUb21hc3ogTXlydGEgd3JvdGU6DQo+ IEFyZSB0aGVyZSBhbnkgd2hlcmUgY2xhdXNlcyB3aGljaCBhbGwgb2YgdGhl c2VzIHZhcmlhdGlvbiBoYXZlPw0KDQpZZXMuLi4uLldIRVJFIGNsaWVudGlk ID0gPyB3aWxsIGFwcGVhciBpbiBldmVyeSBxdWVyeS4gIFRoZSBvdGhlcnMg YXJlIHByZXNlbnQgYmFzZWQgb24gdXNlciBpbnB1dC4NCg0KIA0KPiBSb24g Sm9obnNvbiB3cm90ZToNCj4gV2hhdCBhcmUgdGhlIGluZGV4ZXMgb24gYmF0 Y2hkZXRhaWw/DQo+IFRoZXJlJ3Mgb25lIG9uIGJhdGNoaWQgYW5kIGEgc2Vw ZXJhdGUgb25lIG9uIHRyYW5hbW91bnQ/DQo+IElmIHNvLCB3aGF0IGFib3V0 IGRyb3BwaW5nIHRoZW0gYW5kIGNyZWF0ZSBhIHNpbmdsZSBtdWx0aS1zZWdt ZW50DQo+IGluZGV4IG9uICJiYXRjaGlkLCB0cmFuYW1vdW50Ii4gIChBIGNv bnN0cmFpbnQgY2FuIHRoZW4gZW5mb3JjZQ0KPiB1bmlxdWVuZXNzIG9uIGJh dGNoaWQuDQogDQpUaGVyZSBpcyBubyBpbmRleCBvbiBiYXRjaGlkLCBJIHRo aW5rIGl0IGlzIGEgZ29vZCBpZGVhIHRvIGNyZWF0ZSBvbmUuICBTdGVwaGFu IGFsc28gc3VnZ2VzdGVkIHRoaXMuICBBZnRlciBJIHRyeSB0aGUgc2luZ2xl IGJhdGNoaWQgaW5kZXgsIEkgbWlnaHQgdHJ5IHRvIG11bHRpLXNlZ21lbnQg aW5kZXggaWRlYSBhcyB3ZWxsLiAgIEknbGwgcG9zdCByZXN1bHRzIGxhdGVy IHRvZGF5Lg0KIA0KPiBTdGVwaGFuIFN6YWJvIHdyb3RlOg0KPiBUaGVuIEkg cmVhbGl6ZWQgdGhhdCBiYXRjaGhlYWRlci5iYXRjaGlkIGFuZA0KPiBiYXRj aGRldGFpbC5iYXRjaGlkIGRvbid0IGV2ZW4gaGF2ZSB0aGUgc2FtZQ0KPiB0 eXBlLCBhbmQgdGhhdCdzIHByb2JhYmx5IHNvbWV0aGluZyBlbHNlIHlvdSdk DQo+IG5lZWQgdG8gZml4Lg0KDQpZZXMsIHRoYXQncyBhIG1pc3Rha2Ugb24g bXkgcGFydC4uLi5iYXRjaGRldGFpbChiYXRjaGlkKSBzaG91bGQgYmUgYW4g aW50OC4gIEl0IGxvb2tzIHRvIG1lIGxpa2UgY29udmVydGluZyB0aGlzIGRh dGF0eXBlIGNhbid0IGJlIGRvbmUgd2l0aCBhIHNpbmdsZSBBTFRFUiBUQUJM RSBBTFRFUiBDT0xVTU4gc3RhdGVtZW50Li4uLi5zbyBJIGd1ZXNzIEknbGwg d29yayBhcm91bmQgaXQgd2l0aCBhbiBBREQsIFVQREFURSwgRFJPUCwgYW5k IFJFTkFNRS4NCiANCj4gSm9zaCBCZXJrdXMgd3JvdGU6DQo+IFVtLCBSb21h biwga2VlcCBpbiBtaW5kIHRoaXMgaXMgYSBtYWlsaW5nIGxpc3QuICAgSSdt IHN1cmUgdGhhdA0KPiBldmVyeW9uZSBoZXJlIGlzIGhhcHB5IHRvIGdpdmUg eW91IHRoZSB0b29scyB0byBmaWd1cmUgb3V0IGhvdyB0byBmaXgNCj4gdGhp bmdzLCBidXQgb25seSBpbiBhIERJWSBmYXNoaW9uLCBhbmQgbm90IG9uIHlv dXIgc2NoZWR1bGUuIA0KDQpJIGhhdGUgYmVpbmcgZGVmZW5zaXZlLCBidXQg SSBkb24ndCByZW1lbWJlciBzYXlpbmcgdGhhdCBJIGV4cGVjdCBhbnlvbmUg dG8gZml4IG15IHByb2JsZW1zIGZvciBtZSBvbiBteSBzY2hlZHVsZS4gICpJ KiBob3BlIHRoYXQgKkkqIGNhbiBnZXQgdGhpcyBkb25lIGJ5IEZyaWRheSwg YmVjYXVzZSBvdGhlcndpc2UgbXkgYm9zcyBpcyBnb2luZyB0byB0ZWxsIG1l IHRvIGR1bXAgUG9zdGdyZXMgYW5kIGluc3RhbGwgTVNTUUwgb24gdGhlIHNl cnZlci4gIEkgb25seSBtZW50aW9uIHRoaXMgZmFjdCBiZWNhdXNlIGl0J3Mg YSBibG93IGFnYWluc3QgUG9zdGdyZVNRTCdzIHJlcHV0YXRpb24gaWYgSSBo YXZlIHRvIGdpdmUgdXAuICBUaGVyZSBpcyBubyBwcmVzc3VyZSBvbiB5b3Us IGFuZCBJIGFwb2xvZ2l6ZSBpZiBzb21ldGhpbmcgSSBzYWlkIHNvdW5kZWQg bGlrZSB3aGluaW5nLg0KIA0KSSBhbSBWRVJZIGdyYXRlZnVsIGZvciB0aGUg dGltZSB0aGF0IGFsbCBvZiB5b3UgaGF2ZSBnaXZlbiB0byB0aGlzIHByb2Js ZW0uDQogDQpSb21hbiBGYWlsDQpTci4gV2ViIEFwcGxpY2F0aW9uIFByb2dy YW1tZXINClBPUyBQb3J0YWwsIEluYy4NCiANCg== From pgsql-performance-owner@postgresql.org Thu Jan 16 14:54:09 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B7ADC476DDC for ; Thu, 16 Jan 2003 14:54:05 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id BA168476386 for ; Thu, 16 Jan 2003 14:36:05 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D5D9AD606; Thu, 16 Jan 2003 11:35:55 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id CB8385C02; Thu, 16 Jan 2003 11:35:55 -0800 (PST) Date: Thu, 16 Jan 2003 11:35:55 -0800 (PST) From: Stephan Szabo To: Roman Fail Cc: Josh Berkus , Tom Lane , Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C06@pos_pdc.posportal.com> Message-ID: <20030116112424.S7433-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/168 X-Sequence-Number: 815 On Thu, 16 Jan 2003, Roman Fail wrote: > > Stephan Szabo wrote: > > I'd assume that tranamount values are fairly randomly distributed > > throughout the table, right? It takes about 5 minutes for the > > system to read the entire table and more for the index scan, so > > you're probably reading most of the table randomly and the index > > as well. > > What values on batchdetail do you use in query where clauses regularly? > Yes, tranamount values are randomly distributed. I don't understand > why an index scan would be "random", isn't the whole point of an index > to have an ordered reference into the data? batchdetail has 5 columns > that can be in the WHERE clause, all of which are indexed. None is > more likely than the other to be searched, so a clustered index > doesn't make much sense to me. The whole thing needs to be fast. Yeah, in that case a clustered index doesn't help. Indexes give you an ordered way to find the rows that meet a condition, but say you had three rows in your table in this order (note that this is an amazing oversimplification): (1,'a') (2,'b') (0,'c') And you want to scan the index from values with the first number between 0 and 2. It reads the third row, then the first, then the second (to get the letter associated). Between those reads, it's got to seek back and forth through the heap file and the order in which it hits them is pretty random seeming (to the kernel). > > Ron Johnson wrote: > > What are the indexes on batchdetail? > > There's one on batchid and a seperate one on tranamount? > > If so, what about dropping them and create a single multi-segment > > index on "batchid, tranamount". (A constraint can then enforce > > uniqueness on batchid. > There is no index on batchid, I think it is a good idea to create > one. Stephan also suggested this. After I try the single batchid > index, I might try to multi-segment index idea as well. I'll post > results later today. I think we may all have misread the index list to include an index on batchid. Also you have two indexes on batchdetailid right now (primary key also creates one) which added to the confusion. > > Stephan Szabo wrote: > > Then I realized that batchheader.batchid and > > batchdetail.batchid don't even have the same > > type, and that's probably something else you'd > > need to fix. > > Yes, that's a mistake on my part....batchdetail(batchid) should be an > int8. It looks to me like converting this datatype can't be done with > a single ALTER TABLE ALTER COLUMN statement.....so I guess I'll work > around it with an ADD, UPDATE, DROP, and RENAME. Don't forget to do a vacuum full in there as well. From pgsql-performance-owner@postgresql.org Thu Jan 16 14:57:44 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6A6204768A5 for ; Thu, 16 Jan 2003 14:56:51 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 18DAC4769AF for ; Thu, 16 Jan 2003 14:46:43 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0GJkX5u026713; Thu, 16 Jan 2003 14:46:34 -0500 (EST) To: "Roman Fail" Cc: "Josh Berkus" , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C06@pos_pdc.posportal.com> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C06@pos_pdc.posportal.com> Comments: In-reply-to "Roman Fail" message dated "Thu, 16 Jan 2003 11:22:03 -0800" Date: Thu, 16 Jan 2003 14:46:33 -0500 Message-ID: <26712.1042746393@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/169 X-Sequence-Number: 816 "Roman Fail" writes: > -> Merge Join (cost=1543595.18..1545448.76 rows=1 width=172) (actual time=1195311.88..1195477.32 rows=5 loops=1) > Merge Cond: ("outer".batchid = "inner".batchid) > -> Sort (cost=476.17..476.18 rows=4 width=102) (actual time=30.57..30.59 rows=17 loops=1) > Sort Key: b.batchid > -> Nested Loop (cost=0.00..476.14 rows=4 width=102) (actual time=25.21..30.47 rows=17 loops=1) > -> Index Scan using merchants_ix_merchid_idx on merchants m (cost=0.00..5.65 rows=1 width=78) (actual time=23.81..23.82 rows=1 loops=1) > Index Cond: (merchid = '701252267'::character varying) > -> Index Scan using batchheader_ix_merchantid_idx on batchheader b (cost=0.00..470.30 rows=15 width=24) (actual time=1.38..6.55 rows=17 loops=1) > Index Cond: ("outer".merchantid = b.merchantid) > Filter: (batchdate > '2002-12-15 00:00:00'::timestamp without time zone) > -> Sort (cost=1543119.01..1544045.79 rows=370710 width=70) (actual time=1194260.51..1194892.79 rows=368681 loops=1) > Sort Key: d.batchid > -> Index Scan using batchdetail_ix_tranamount_idx on batchdetail d (cost=0.00..1489103.46 rows=370710 width=70) (actual time=5.26..1186051.44 rows=370307 loops=1) > Index Cond: ((tranamount >= 500.0) AND (tranamount <= 700.0)) The expensive part of this is clearly the sort and merge of the rows extracted from batchdetail. The index on tranamount is not helping you at all, because the condition (between 500 and 700) isn't very selective --- it picks up 370000 rows --- and since those rows are totally randomly scattered in the table, you do a ton of random seeking. It's actually faster to scan the table linearly --- that's why enable_indexscan=off was faster. However, I'm wondering why the thing picked this plan, when it knew it would get only a few rows out of the m/b join (estimate 4, actual 17, not too bad). I would have expected it to use an inner indexscan on d.batchid. Either you've not got an index on d.batchid, or there's a datatype mismatch that prevents the index from being used. What are the datatypes of d.batchid and b.batchid, exactly? If they're not the same, either make them the same or add an explicit coercion to the query, like WHERE d.batchid = b.batchid::typeof_d_batchid regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 16 16:25:15 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 467D8476D5C for ; Thu, 16 Jan 2003 16:12:33 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 3CC7B476299 for ; Thu, 16 Jan 2003 15:51:51 -0500 (EST) Received: by serwer.skawsoft.com.pl (Postfix, from userid 1000) id 517F22B26E; Thu, 16 Jan 2003 21:48:26 +0100 (CET) Date: Thu, 16 Jan 2003 21:48:26 +0100 To: Tom Lane Cc: Roman Fail , Josh Berkus , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030116204826.GA26576@serwer> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C06@pos_pdc.posportal.com> <26712.1042746393@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26712.1042746393@sss.pgh.pa.us> User-Agent: Mutt/1.3.28i From: jasiek@klaster.net X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/170 X-Sequence-Number: 817 Tom said: > datatype mismatch that prevents the index from being used. What are the > datatypes of d.batchid and b.batchid, exactly? If they're not the same, > either make them the same or add an explicit coercion to the query, like > WHERE d.batchid = b.batchid::typeof_d_batchid > It can be source of problem. I found in one of Roman's mail, that batchid is declared as int8 in master table and as int4 in detail table. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Fri Jan 17 00:54:41 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 299CD476543 for ; Fri, 17 Jan 2003 00:54:36 -0500 (EST) Received: from pos_pdc.posportal.com (unknown [12.158.169.100]) by postgresql.org (Postfix) with ESMTP id 301D947651E for ; Fri, 17 Jan 2003 00:54:34 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Re: 7.3.1 New install, large queries are slow Date: Thu, 16 Jan 2003 21:54:39 -0800 Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C09@pos_pdc.posportal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] 7.3.1 New install, large queries are slow Thread-Index: AcK9l/wPnT5XK39ZSQKMu5my8Z07QgAKAnUG From: "Roman Fail" To: "Tom Lane" Cc: "Josh Berkus" , , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/171 X-Sequence-Number: 818 VG9tIGFuZCBUb21hc3o6DQpJIGhhdmUgdG8gY2hhbmdlIHRoZSBkYXRhdHlw ZSBvZiBiYXRjaGRldGFpbC5iYXRjaGlkIGZyb20gaW50NCB0byBpbnQ4LiAg QWZ0ZXIgb3ZlciA0IGhvdXJzLCB0aGUgVVBEQVRFIHRyYW5zZmVyIGZyb20g dGhlIG9sZCBjb2x1bW4gdG8gbmV3IGhhcyBub3QgeWV0IGNvbXBsZXRlZC4g IEFmdGVyIHRoYXQgSSBzdGlsbCBoYXZlIHRvIGJ1aWxkIGEgbmV3IGluZGV4 IGFuZCBydW4gVkFDVVVNIEZVTEwuICBXaGVuIHRoYXQgaXMgYWxsIGRvbmUg SSdsbCByZS1ydW4gdGhlIHZhcmlvdXMgcXVlcmllcywgaW5jbHVkaW5nIGEg c3BlY2lmaWMgc21hbGwgb25lIHRoYXQgSm9zaCByZXF1ZXN0ZWQuICANCiAN CkNoYWQgVGhvbXBzb24gc3VnZ2VzdGVkIHRoYXQgSSBhZGQgc2luZ2xlIHF1 b3RlcyBhcm91bmQgdGhlIGxpdGVyYWxzIGluIHRoZSBXSEVSRSBjbGF1c2Us IHdoaWNoIHNvdW5kZWQgbGlrZSBhIGdyZWF0IGlkZWEgYmFzZWQgb24gaGlz IGV4cGVyaWVuY2UuICBVbmZvcnR1bmF0ZWx5LCBpdCBkaWQgbm90IG1ha2Ug dGhlIHF1ZXJ5IGFueSBmYXN0ZXIuICBCdXQgcmVhZCBvbiENCiANCkZvciBr aWNrcywgSSB0cmllZCB0aGlzIHNpbXBsZSBxdWVyeSwgd2hpY2ggc2hvdWxk IGhhcHBlbiBpbiBhbiBpbnN0YW50LiAgSXQgaXMgdGhlIGZpcnN0IHJvdyBp biB0aGUgdGFibGUuDQpFWFBMQUlOIEFOQUxZWkUgc2VsZWN0IGJhdGNoZGV0 YWlsaWQgZnJvbSBiYXRjaGRldGFpbCB3aGVyZSBiYXRjaGRldGFpbGlkID0g MjczMjE7DQogU2VxIFNjYW4gb24gYmF0Y2hkZXRhaWwgIChjb3N0PTAuMDAu LjE5NjA0ODUuNDMgcm93cz0xIHdpZHRoPTgpIChhY3R1YWwgdGltZT0xNy41 OC4uMjY0MzAzLjc2IHJvd3M9MSBsb29wcz0xKQ0KICAgRmlsdGVyOiAoYmF0 Y2hkZXRhaWxpZCA9IDI3MzIxKQ0KIFRvdGFsIHJ1bnRpbWU6IDI2NDMwMy44 NyBtc2VjDQpEb2VzIGl0IG1ha2Ugc2Vuc2UgdG8gZG8gYSBzZXF1ZW5jZSBz Y2FuIHdoZW4gdGhlIHByaW1hcnkga2V5IGluZGV4IGlzIGF2YWlsYWJsZT8g IEV2ZW4gc28sIGl0J3Mgc3RpbGwgYSBwcmV0dHkgaG9ycmlibGUgdGltZSBn aXZlbiB0aGUgaGFyZHdhcmUuDQogDQpIT1dFVkVSLi4uLi5sb29rIGF0IHRo aXM6DQpFWFBMQUlOIEFOQUxZWkUgc2VsZWN0IGJhdGNoZGV0YWlsaWQgZnJv bSBiYXRjaGRldGFpbCB3aGVyZSBiYXRjaGRldGFpbGlkID0gMjczMjE6OmJp Z2ludDsNCiBJbmRleCBTY2FuIHVzaW5nIGJhdGNoZGV0YWlsX3BrZXkgb24g YmF0Y2hkZXRhaWwgIChjb3N0PTAuMDAuLjQuMTMgcm93cz0xIHdpZHRoPTgp IChhY3R1YWwgdGltZT0wLjAzLi4wLjAzIHJvd3M9MSBsb29wcz0xKQ0KICAg SW5kZXggQ29uZDogKGJhdGNoZGV0YWlsaWQgPSAyNzMyMTo6YmlnaW50KQ0K IFRvdGFsIHJ1bnRpbWU6IDAuMDcgbXNlYw0KIA0KSXQgc29ydCBvZiBmZWVs cyBsaWtlIGEgbWFnaWMgbW9tZW50LiAgSSB3ZW50IGJhY2sgYW5kIGxvb2tl ZCB0aHJvdWdoIGEgbG90IG9mIHRoZSBKT0lOIGNvbHVtbnMgYW5kIGZvdW5k IHRoYXQgSSB3YXMgbWl4aW5nIGludDQgd2l0aCBpbnQ4IGluIGEgbG90IG9m IHRoZW0uICBBbGwgb2YgdGhlc2UgdGFibGVzIChleGNlcHQgYmF0Y2hkZXRh aWwpIHdlcmUgbWlncmF0ZWQgdXNpbmcgcGdBZG1pbklJJ3MgbWlncmF0aW9u IHdpemFyZCwgc28gSSBkaWRuJ3QgcmVhbGx5IGdpdmUgYSBoYXJkIGxvb2sg YXQgYWxsIHRoZSBkYXRhIHR5cGVzIG1hdGNoaW5nIHVwIHNpbmNlIGl0IGhh cyBhIG5pY2UgZGF0YSBtYXAgKEkgdXNlZCB0aGUgZGVmYXVsdHMgZXhjZXB0 IGZvciB0aGUgbW9uZXkgdHlwZSkuICANCiANCk5vdyBJIHRoaW5rIEknbSBq dXN0IGdvaW5nIHRvIGRyb3AgdGhlIGVudGlyZSBkYXRhYmFzZSBhbmQgcmVs b2FkIHRoZSBkYXRhIGZyb20gc2NyYXRjaCwgbWFraW5nIHN1cmUgdGhhdCB0 aGUgZGF0YSB0eXBlcyBhcmUgbWFwcGVkIGV4YWN0bHkgcmlnaHQuICBDb3Jy ZWN0IG1lIGlmIEknbSB3cm9uZywgYnV0IGludDQgb25seSByYW5nZXMgZnJv bSBuZWdhdGl2ZSAyIGJpbGxpb24gdG8gcG9zaXRpdmUgMiBiaWxsaW9uLiAg QWxsIHRoZSBwcmltYXJ5IGtleXMgZm9yIG15IHRhYmxlcyB3b3VsZCBmaXQg aW4gdGhpcyByYW5nZSB3aXRoIHRoZSBleGNlcHRpb24gb2YgYmF0Y2hkZXRh aWwsIHdoaWNoIGNvdWxkIGNvbmNlaXZhYmx5IGdyb3cgYmV5b25kIDIgYmls bGlvbiBzb21lZGF5IChhbHRob3VnaCBJJ2QgYmUgYXJjaGl2aW5nIGEgbG90 IG9mIGl0IHdoZW4gaXQgZ290IHRoYXQgYmlnKS4gIE1heWJlIEkganVzdCBz aG91bGRuJ3Qgd29ycnkgYWJvdXQgaXQgZm9yIG5vdyBhbmQgbWFrZSBldmVy eXRoaW5nIGludDQgZm9yIHNpbXBsaWNpdHkuDQogDQpJIGRvdWJ0IEkgd2ls bCBhY2NvbXBsaXNoIGFsbCB0aGlzIG9uIEZyaWRheSwgYnV0IEknbGwgZ2l2 ZSBhIGZ1bGwgcmVwb3J0IG9uY2UgSSBnZXQgaXQgYWxsIHJlbG9hZGVkLiAN CiANCj4gU3RlcGhhbiBTemFibyB3cm90ZToNCj4gQWxzbyB5b3UgaGF2ZSB0 d28gaW5kZXhlcyBvbiBiYXRjaGRldGFpbGlkIHJpZ2h0IG5vdyAocHJpbWFy eSBrZXkNCj4gYWxzbyBjcmVhdGVzIG9uZSkgd2hpY2ggYWRkZWQgdG8gdGhl IGNvbmZ1c2lvbi4NCg0KVGhlIDcuMy4xIGRvY3MgZm9yIENSRUFURSBUQUJM RSBkb24ndCBtZW50aW9uIGFueXRoaW5nIGFib3V0IGF1dG9tYXRpYyBpbmRl eCBjcmVhdGlvbiBmb3IgYSBQUklNQVJZIEtFWS4gIEkgZGlkbid0IHNlZSBh bnkgUEsgaW5kZXhlcyB2aWEgcGdBZG1pbklJLCBzbyBJIHJlYWQgdGhpcyBs aW5lIGZyb20gdGhlIGRvY3MgYW5kIGRlY2lkZWQgdG8gY3JlYXRlIHRoZW0g c2VwYXJhdGVseS4NCiAgICAiVGVjaG5pY2FsbHksIFBSSU1BUlkgS0VZIGlz IG1lcmVseSBhIGNvbWJpbmF0aW9uIG9mIFVOSVFVRSBhbmQgTk9UIE5VTEwi DQpIb3dldmVyLCB0aGlzIHF1ZXJ5IHByb3ZlcyB5b3UgYXJlIHJpZ2h0Og0K dHJhbnM9IyBzZWxlY3QgcmVsbmFtZSwgcmVscGFnZXMsIGluZGlzdW5pcXVl LCBpbmRpc3ByaW1hcnkgZnJvbSBwZ19jbGFzcywgcGdfaW5kZXgNCnRyYW5z LSMgd2hlcmUgaW5kZXhyZWxpZCBpbiAoMzcxMjY3MzksIDg2MDQyNTcpIGFu ZCBwZ19jbGFzcy5vaWQgPSBwZ19pbmRleC5pbmRleHJlbGlkOw0KIHJlbG5h bWUgICAgICAgICAgICAgICAgICAgICAgICAgIHwgcmVscGFnZXMgfCBpbmRp c3VuaXF1ZSB8IGluZGlzcHJpbWFyeQ0KLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0rLS0tLS0t LS0tLS0tLS0NCiBiYXRjaGRldGFpbF9wa2V5ICAgICAgICAgICAgICAgICB8 ICAgMTIxODUwIHwgdCAgICAgICAgICAgfCB0DQogYmF0Y2hkZXRhaWxfaXhf YmF0Y2hkZXRhaWxpZF9pZHggfCAgICA2MzkzNCB8IGYgICAgICAgICAgIHwg Zg0KIA0KQWxsIG90aGVyIGNvbHVtbnMgaW4gdGhlIHR3byB0YWJsZXMgYXJl IGlkZW50aWNhbCBmb3IgdGhlc2UgdHdvIGluZGV4ZXMuICBTbyBub3cgSSd2 ZSBnb25lIHRocm91Z2ggYW5kIGRlbGV0ZWQgYWxsIG9mIHRoZXNlIGR1cGxp Y2F0ZSBpbmRleGVzIEkgY3JlYXRlZCAoYW5kIHRoZW4gYSBWQUNVVU0gRlVM TCkuICBQZXJoYXBzIGFuIGV4dHJhIHNlbnRlbmNlIGluIHRoZSBkb2NzIG1p Z2h0IHByZXZlbnQgc29tZW9uZSBlbHNlIGZyb20gbWFraW5nIHRoZSBzYW1l IG1pc3Rha2UgYXMgST8NCiANCioqKiBDdXJyZW50IHBvc3RncmVzcWwuY29u ZiBzZXR0aW5nczoNCnRjcGlwX3NvY2tldD10cnVlDQpzaGFyZWRfYnVmZmVy cyA9IDEzMTA3Mg0KbWF4X2ZzbV9yZWxhdGlvbnMgPSAxMDAwMA0KbWF4X2Zz bV9wYWdlcyA9IDIwMDAwMDANCnNvcnRfbWVtID0gMzI3NjgNCmRlZmF1bHRf c3RhdGlzdGljc190YXJnZXQgPSAzMA0KDQpUaGFua3MgYWdhaW4gZm9yIGFs bCB5b3VyIGhlbHAhDQogDQpSb21hbiBGYWlsDQpTci4gV2ViIEFwcGxpY2F0 aW9uIERldmVsb3Blcg0KUE9TIFBvcnRhbCwgSW5jLg0KIA0K From pgsql-performance-owner@postgresql.org Fri Jan 17 01:06:22 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D8135475BC3 for ; Fri, 17 Jan 2003 01:06:17 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 28AC647592C for ; Fri, 17 Jan 2003 01:06:17 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0H66A5u004982; Fri, 17 Jan 2003 01:06:10 -0500 (EST) To: "Roman Fail" Cc: "Josh Berkus" , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C09@pos_pdc.posportal.com> References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C09@pos_pdc.posportal.com> Comments: In-reply-to "Roman Fail" message dated "Thu, 16 Jan 2003 21:54:39 -0800" Date: Fri, 17 Jan 2003 01:06:10 -0500 Message-ID: <4981.1042783570@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/172 X-Sequence-Number: 819 "Roman Fail" writes: > shared_buffers = 131072 Yipes! Try about a tenth that much. Or less. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 17 02:00:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6122475C5F for ; Fri, 17 Jan 2003 02:00:49 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 4CBB4475BC3 for ; Fri, 17 Jan 2003 02:00:49 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 11B2DD602; Thu, 16 Jan 2003 23:00:49 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 076C75C03; Thu, 16 Jan 2003 23:00:48 -0800 (PST) Date: Thu, 16 Jan 2003 23:00:48 -0800 (PST) From: Stephan Szabo To: Roman Fail Cc: Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C09@pos_pdc.posportal.com> Message-ID: <20030116225602.G17408-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/173 X-Sequence-Number: 820 On Thu, 16 Jan 2003, Roman Fail wrote: > > Stephan Szabo wrote: > > Also you have two indexes on batchdetailid right now (primary key > > also creates one) which added to the confusion. > > The 7.3.1 docs for CREATE TABLE don't mention anything about automatic > index creation for a PRIMARY KEY. I didn't see any PK indexes via > pgAdminII, so I read this line from the docs and decided to create > them separately. > "Technically, PRIMARY KEY is merely a combination of UNIQUE and NOT NULL" Right, but the implementation of UNIQUE constraints in postgresql right now is through a unique index. That's not necessarily a guarantee for the future, but for right now you can rely on it. From pgsql-performance-owner@postgresql.org Fri Jan 17 06:47:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D9EB6475E18 for ; Fri, 17 Jan 2003 06:47:54 -0500 (EST) Received: from mail.sarkor.com (unknown [81.95.224.36]) by postgresql.org (Postfix) with SMTP id 5BC2F475EC9 for ; Fri, 17 Jan 2003 06:47:52 -0500 (EST) Received: (qmail 10337 invoked by uid 507); 17 Jan 2003 11:47:51 -0000 Received: from thor@sarkor.com by mail.sarkor.com by uid 504 with qmail-scanner-1.14 (clamscan: 0.51. Clear:. Processed in 0.440657 secs); 17 Jan 2003 11:47:51 -0000 Received: from unknown (HELO timur) (81.95.224.66) by mail.sarkor.com with SMTP; 17 Jan 2003 11:47:50 -0000 Date: Fri, 17 Jan 2003 16:48:00 +0500 From: Timur Irmatov X-Mailer: The Bat! (v1.61) Reply-To: Timur Irmatov X-Priority: 3 (Normal) Message-ID: <10597430257.20030117164800@sarkor.com> To: pgsql-performance@postgresql.org Subject: index usage MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/174 X-Sequence-Number: 821 Hi, everyone! I have a simple query which takes almost 3 seconds to complete, but disabling sequence scans leads to a new plan using index. This second plan takes less than 1 millisecond to run. So, I'd like to hear any comments and suggestions. Details. CREATE TABLE MediumStats ( year SMALLINT NOT NULL, month SMALLINT NOT NULL, day SMALLINT NOT NULL, hour SMALLINT NOT NULL, --- and then goes few data fields figureId INTEGER NOT NULL, typeId INTEGER NOT NULL PRIMARY KEY (figureId, typeId, year, month, day, hour) ); CREATE FUNCTION indexHelper (INT2, INT2, INT2, INT2) RETURNS CHARACTER(10) AS ' return sprintf("%d%02d%02d%02d", @_); ' LANGUAGE 'plperl' WITH (isCachable); CREATE INDEX timeIndex ON MediumStats (indexHelper(year,month,day,hour)); and that is the query: SELECT * FROM MediumStats WHERE indexHelper(year,month,day,hour) < '2002121500' LIMIT 1; First, original plan: Limit (cost=0.00..0.09 rows=1 width=22) (actual time=2969.30..2969.30 rows=0 loops=1) -> Seq Scan on mediumstats (cost=0.00..1332.33 rows=15185 width=22) (actual time=2969.29..2969.29 rows=0 loops=1) Total runtime: 2969.39 msec Second plan, seq scans disabled: Limit (cost=0.00..0.19 rows=1 width=6) (actual time=0.43..0.43 rows=0 loops=1) -> Index Scan using timeindex on mediumstats (cost=0.00..2898.96 rows=15185 width=6) (actual time=0.42..0.42 rows=0 loops=1) Total runtime: 0.54 msec Table MediumStats currently has 45000 rows, all rows belong to this month. From pgsql-performance-owner@postgresql.org Fri Jan 17 08:29:37 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5138C4760B7 for ; Fri, 17 Jan 2003 08:29:36 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id 9F009476078 for ; Fri, 17 Jan 2003 08:29:35 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id h0HDTNM10103; Fri, 17 Jan 2003 08:29:23 -0500 Message-ID: <3E280535.1090909@clearmetrix.com> Date: Fri, 17 Jan 2003 08:29:25 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruce Momjian Cc: Tom Lane , Roman Fail , josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow References: <200301161618.h0GGIZi16755@candle.pha.pa.us> In-Reply-To: <200301161618.h0GGIZi16755@candle.pha.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/175 X-Sequence-Number: 822 I'd love to see this as a TODO item, but I am hardly one to add to the list... Charlie Bruce Momjian wrote: >Is this a TODO item? > >--------------------------------------------------------------------------- > >Charles H. Woloszynski wrote: > > >>I was surprised to hear that JOIN syntax constrained the planner. We >>have a policy of using JOIN syntax to describe the table relationships >>and where clauses to describe the selection process for our queries. It >>was our understanding that the JOIN syntax was introduced to support >>this approach, but not to contrain the planner. >> >>Is there any way to sell the planner to consider JOIN syntax as >>equivalent to WHERE clauses and to not use them to force the planner >>down a specific path? Can we get that added as an option (and then made >>available to use JDBC folks as a URL parameter). It would make my team >>very happy :-). >> >> >>I think that making this an option will help all those migrating to >>Postgres who did not expect that JOINs forced the planner down specific >>plans. Is it possible/reasonable to add? >> >>Charlie >> >> >>Tom Lane wrote: >> >> >> >>>"Roman Fail" writes: >>> >>> >>> >>> >>>>Thanks to everyone for the quick replies! I'm sure that my lack of >>>>skill with SQL queries is the main problem. What's strange to me is >>>>how MSSQL takes my bad queries and makes them look good anyway. It >>>>must have a real smart planner. >>>> >>>> >>>> >>>> >>>I think more likely the issue is that your use of JOIN syntax is forcing >>>Postgres into a bad plan. MSSQL probably doesn't assign any semantic >>>significance to the use of "a JOIN b" syntax as opposed to "FROM a, b" >>>syntax. Postgres does. Whether this is a bug or a feature depends on >>>your point of view --- but there are folks out there who find it to be >>>a life-saver. You can find some explanations at >>>http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit-joins.html >>> >>> >>> >>> >>> >>>>Is it pretty much universally accepted that I should drop all my >>>>foreign keys? >>>> >>>> >>>> >>>> >>>No. They don't have any effect on SELECT performance in Postgres. >>>They will impact update speed, but that's not your complaint (at the >>>moment). Don't throw away data integrity protection until you know >>>you need to. >>> >>> regards, tom lane >>> >>>---------------------------(end of broadcast)--------------------------- >>>TIP 4: Don't 'kill -9' the postmaster >>> >>> >>> >>> >>-- >> >> >>Charles H. Woloszynski >> >>ClearMetrix, Inc. >>115 Research Drive >>Bethlehem, PA 18015 >> >>tel: 610-419-2210 x400 >>fax: 240-371-3256 >>web: www.clearmetrix.com >> >> >> >> >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >> >> >> > > > -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com From pgsql-performance-owner@postgresql.org Fri Jan 17 09:01:22 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1BE14771F5 for ; Fri, 17 Jan 2003 09:01:20 -0500 (EST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.215.169]) by postgresql.org (Postfix) with SMTP id 7FC02477272 for ; Fri, 17 Jan 2003 09:00:12 -0500 (EST) Received: (qmail 55163 invoked from network); 17 Jan 2003 14:00:19 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 17 Jan 2003 14:00:19 -0000 Date: Fri, 17 Jan 2003 09:00:19 -0500 (EST) From: Jeff To: Roman Fail Cc: Tom Lane , Josh Berkus , "sszabo@megazone23.bigpanda.com" , "pgsql-performance@postgresql.org" Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C09@pos_pdc.posportal.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/176 X-Sequence-Number: 823 On Thu, 16 Jan 2003, Roman Fail wrote: > > HOWEVER.....look at this: > EXPLAIN ANALYZE select batchdetailid from batchdetail where batchdetailid = 27321::bigint; > Index Scan using batchdetail_pkey on batchdetail (cost=0.00..4.13 rows=1 width=8) (actual time=0.03..0.03 rows=1 loops=1) > Index Cond: (batchdetailid = 27321::bigint) > Total runtime: 0.07 msec > We had this happen to us - we had a serial8 column (int8) and our query was straight forward where id = 12345; which ran craptacularly. After much head banging and cursing I had tried where id = '12345' and it magically worked. I think the parser is interpreting a "number" to be an int4 instead of int8. (instead of quotes you can also cast via 12345::int8 like you did) Perhaps this should go on the TODO - when one side is an int8 and the other is a literal number assume the number to be int8 instead of int4? ------------------------------------------------------------------------------ Jeff Trout http://www.jefftrout.com/ Ronald McDonald, with the help of cheese soup, controls America from a secret volkswagon hidden in the past ------------------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Fri Jan 17 09:49:12 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7EECE4763AE for ; Fri, 17 Jan 2003 09:49:11 -0500 (EST) Received: from pos_pdc.posportal.com (unknown [12.158.169.100]) by postgresql.org (Postfix) with ESMTP id 6DF6147721D for ; Fri, 17 Jan 2003 09:48:29 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Implicit casting and JOIN syntax constraints Date: Fri, 17 Jan 2003 06:48:28 -0800 Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] 7.3.1 New install, large queries are slow Thread-Index: AcK+MMt5Ej1+jTmlTVq88jlphHkjhwABVroz From: "Roman Fail" To: "Jeff" Cc: "Tom Lane" , "Josh Berkus" , , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/177 X-Sequence-Number: 824 Pj4gSE9XRVZFUi4uLi4ubG9vayBhdCB0aGlzOg0KPj4gRVhQTEFJTiBBTkFM WVpFIHNlbGVjdCBiYXRjaGRldGFpbGlkIGZyb20gYmF0Y2hkZXRhaWwgd2hl cmUgYmF0Y2hkZXRhaWxpZCA9IDI3MzIxOjpiaWdpbnQ7DQo+PiAgSW5kZXgg U2NhbiB1c2luZyBiYXRjaGRldGFpbF9wa2V5IG9uIGJhdGNoZGV0YWlsICAo Y29zdD0wLjAwLi40LjEzIHJvd3M9MSB3aWR0aD04KSAoYWN0dWFsIHRpbWU9 MC4wMy4uMC4wMyByb3dzPTEgbG9vcHM9MSkNCj4+ICAgIEluZGV4IENvbmQ6 IChiYXRjaGRldGFpbGlkID0gMjczMjE6OmJpZ2ludCkNCj4+ICBUb3RhbCBy dW50aW1lOiAwLjA3IG1zZWMNCg0KPiBKZWZmIFRyb3V0IHdyb3RlOg0KPiBX ZSBoYWQgdGhpcyBoYXBwZW4gdG8gdXMgLSB3ZSBoYWQgYSBzZXJpYWw4IGNv bHVtbiAoaW50OCkgYW5kIG91ciBxdWVyeQ0KPiB3YXMgc3RyYWlnaHQgZm9y d2FyZCB3aGVyZSBpZCA9IDEyMzQ1OyB3aGljaCByYW4gY3JhcHRhY3VsYXJs eS4gIEFmdGVyDQo+IG11Y2ggaGVhZCBiYW5naW5nIGFuZCBjdXJzaW5nIEkg aGFkIHRyaWVkIHdoZXJlIGlkID0gJzEyMzQ1JyBhbmQgaXQNCj4gbWFnaWNh bGx5IHdvcmtlZC4gSSB0aGluayB0aGUgcGFyc2VyIGlzIGludGVycHJldGlu ZyBhICJudW1iZXIiIHRvIGJlIGFuDQo+IGludDQgaW5zdGVhZCBvZiBpbnQ4 LiAgKGluc3RlYWQgb2YgcXVvdGVzIHlvdSBjYW4gYWxzbyBjYXN0IHZpYQ0K PiAxMjM0NTo6aW50OCBsaWtlIHlvdSBkaWQpDQoNCj4gUGVyaGFwcyB0aGlz IHNob3VsZCBnbyBvbiB0aGUgVE9ETyAtIHdoZW4gb25lIHNpZGUgaXMgYW4g aW50OCBhbmQgdGhlDQo+IG90aGVyIGlzIGEgbGl0ZXJhbCBudW1iZXIgYXNz dW1lIHRoZSBudW1iZXIgdG8gYmUgaW50OCBpbnN0ZWFkIG9mIGludDQ/DQoN Ckl0IHNlZW1zIHRvIG1lIHRoYXQgdGhpcyBzaG91bGQgYWJzb2x1dGVseSBn byBvbiB0aGUgVE9ETyBsaXN0LiAgV2h5IGRvZXMgdGhlIHBsYW5uZXIgcmVx dWlyZSBhbiBleHBsaWNpdCBjYXN0IHdoZW4gdGhlIGltcGxpY2l0IGNhc3Qg aXMgc28gb2J2aW91cz8gIERvZXMgT3JhY2xlIGRvIHRoaXM/ICBJIGNhbiBh c3N1cmUgeW91IHRoYXQgTVNTUUwgZG9lcyBub3QuICANCiANCklmIGdldHRp bmcgbW9yZSBwZW9wbGUgdG8gbWlncmF0ZSB0byBQb3N0Z3JlU1FMIGlzIGEg bWFqb3IgZ29hbCB0aGVzZSBkYXlzLCBpdCdzIGdvdCB0byBiZSByZWxhdGl2 ZWx5IGVhc3kuICBJIHRoaW5rIHRoYXQgYWxtb3N0IGV2ZXJ5b25lIGNvbWlu ZyBmcm9tIGEgTVNTUUwgb3IgQWNjZXNzIGJhY2tncm91bmQgaXMgZ29pbmcg dG8gaGF2ZSBiaWcgcHJvYmxlbXMgd2l0aCB0aGlzLiAgQW5kIHRoZSBvdGhl ciBpc3N1ZSBvZiB0aGUgSk9JTiBzeW50YXggY29uc3RyYWluaW5nIHRoZSBw bGFubmVyIC0geW91J3ZlIGdvdCB0byBiZSBhYmxlIHRvIHR1cm4gdGhhdCBv ZmYgdG9vLiAgSSd2ZSBiZWVuIHdyaXRpbmcgU1FMIHF1ZXJpZXMgZm9yIDEw IHllYXJzIGluIEZveFBybywgQWNjZXNzLCBTUUwgU2VydmVyLCBNeVNRTCwg YW5kIFN5YmFzZS4gIEkgaGF2ZSBuZXZlciBjb21lIGFjcm9zcyB0aGlzIHZl cnkgY29uZnVzaW5nICJmZWF0dXJlIiB1bnRpbCBub3cuICANCiANCkhvdyBk byB3ZSBnbyBhYm91dCB2b3RpbmcgYW4gaXNzdWUgb250byB0aGUgVE9ETyBs aXN0PyAgVGhlc2UgdHdvIGdldCBteSB2b3RlIGZvciBzdXJlIQ0KIA0KUm9t YW4NCg== From pgsql-performance-owner@postgresql.org Fri Jan 17 09:57:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E2D814762EB for ; Fri, 17 Jan 2003 09:57:01 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 50161476199 for ; Fri, 17 Jan 2003 09:57:01 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0HEv45u011752; Fri, 17 Jan 2003 09:57:04 -0500 (EST) To: Timur Irmatov Cc: pgsql-performance@postgresql.org Subject: Re: index usage In-reply-to: <10597430257.20030117164800@sarkor.com> References: <10597430257.20030117164800@sarkor.com> Comments: In-reply-to Timur Irmatov message dated "Fri, 17 Jan 2003 16:48:00 +0500" Date: Fri, 17 Jan 2003 09:57:04 -0500 Message-ID: <11751.1042815424@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/178 X-Sequence-Number: 825 Timur Irmatov writes: > Limit (cost=0.00..0.19 rows=1 width=6) (actual time=0.43..0.43 rows=0 loops=1) > -> Index Scan using timeindex on mediumstats (cost=0.00..2898.96 rows=15185 width=6) (actual time=0.42..0.42 rows=0 loops=1) The planner has absolutely no clue about the behavior of your function, and so its estimate of the number of rows matched is way off, leading to a poor estimate of the cost of an indexscan. There is not much to be done about this in the current system (though I've speculated about the possibility of computing statistics for functional indexes). Just out of curiosity, why don't you lose all this year/month/day stuff and use a timestamp column? Less space, more functionality. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 17 10:09:30 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 957E04773B2 for ; Fri, 17 Jan 2003 10:09:28 -0500 (EST) Received: from mail.sarkor.com (unknown [81.95.224.36]) by postgresql.org (Postfix) with SMTP id 46FDA4772E0 for ; Fri, 17 Jan 2003 10:08:04 -0500 (EST) Received: (qmail 30518 invoked by uid 507); 17 Jan 2003 15:08:04 -0000 Received: from thor@sarkor.com by mail.sarkor.com by uid 504 with qmail-scanner-1.14 (clamscan: 0.51. Clear:. Processed in 0.814302 secs); 17 Jan 2003 15:08:04 -0000 Received: from unknown (HELO timur) (81.95.224.66) by mail.sarkor.com with SMTP; 17 Jan 2003 15:08:03 -0000 Date: Fri, 17 Jan 2003 20:08:14 +0500 From: Timur Irmatov X-Mailer: The Bat! (v1.61) Reply-To: Timur Irmatov X-Priority: 3 (Normal) Message-ID: <87109443711.20030117200814@sarkor.com> To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: index usage In-Reply-To: <11751.1042815424@sss.pgh.pa.us> References: <10597430257.20030117164800@sarkor.com> <11751.1042815424@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/179 X-Sequence-Number: 826 TL> Timur Irmatov writes: >> Limit (cost=0.00..0.19 rows=1 width=6) (actual time=0.43..0.43 rows=0 loops=1) >> -> Index Scan using timeindex on mediumstats (cost=0.00..2898.96 rows=15185 width=6) (actual time=0.42..0.42 rows=0 loops=1) TL> The planner has absolutely no clue about the behavior of your function, TL> and so its estimate of the number of rows matched is way off, leading to TL> a poor estimate of the cost of an indexscan. There is not much to be TL> done about this in the current system (though I've speculated about the TL> possibility of computing statistics for functional indexes). you're absolutely right. thanks. TL> Just out of curiosity, why don't you lose all this year/month/day stuff TL> and use a timestamp column? Less space, more functionality. :-) Well, I've a seen a lot of people on pgsql-general mailing list with problems with dates, timestamps, and I was just scared of using PostreSQL date and time types and functions.. May be, I should just try it myself before doing it other way... From pgsql-performance-owner@postgresql.org Fri Jan 17 10:11:31 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3FCD64772A6 for ; Fri, 17 Jan 2003 10:11:30 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D6555477264 for ; Fri, 17 Jan 2003 10:11:19 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0HFBH5u011881; Fri, 17 Jan 2003 10:11:19 -0500 (EST) To: Jeff Cc: Roman Fail , Josh Berkus , "sszabo@megazone23.bigpanda.com" , "pgsql-performance@postgresql.org" Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: References: Comments: In-reply-to Jeff message dated "Fri, 17 Jan 2003 09:00:19 -0500" Date: Fri, 17 Jan 2003 10:11:17 -0500 Message-ID: <11880.1042816277@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/180 X-Sequence-Number: 827 Jeff writes: > Perhaps this should go on the TODO - when one side is an int8 and the > other is a literal number assume the number to be int8 instead of int4? It's been on TODO for so long that it's buried near the bottom. * Allow SELECT * FROM tab WHERE int2col = 4 to use int2col index, int8, float4, numeric/decimal too [optimizer] This behavior interacts with enough other stuff that we can't just change it willy-nilly. See many past discussions in the pghackers archives if you want details. A recent example of a promising-looking fix crashing and burning is http://fts.postgresql.org/db/mw/msg.html?mid=1357121 regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 17 10:16:45 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B9614476813 for ; Fri, 17 Jan 2003 10:16:44 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id CEB5D477361 for ; Fri, 17 Jan 2003 10:15:29 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ZYDW-0006FL-00 for ; Fri, 17 Jan 2003 10:15:34 -0500 Date: Fri, 17 Jan 2003 10:15:34 -0500 From: Andrew Sullivan To: "pgsql-performance@postgresql.org" Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030117101534.A23422@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , "pgsql-performance@postgresql.org" References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C09@pos_pdc.posportal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from threshar@torgo.978.org on Fri, Jan 17, 2003 at 09:00:19AM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/181 X-Sequence-Number: 828 On Fri, Jan 17, 2003 at 09:00:19AM -0500, Jeff wrote: > Perhaps this should go on the TODO - when one side is an int8 and the > other is a literal number assume the number to be int8 instead of int4? Actually, this is a broader problem having to do with type coercion. There are a couple of TODO items which refer to this, it looks to me, but in any case there has been _plenty_ of discussion on -general and -hackers about what's wrong here. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Jan 17 10:33:42 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8FC86475EBF for ; Fri, 17 Jan 2003 10:33:37 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 66243475E91 for ; Fri, 17 Jan 2003 10:33:36 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ZYV3-0006Ug-00 for ; Fri, 17 Jan 2003 10:33:41 -0500 Date: Fri, 17 Jan 2003 10:33:41 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: index usage Message-ID: <20030117103341.E23422@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <10597430257.20030117164800@sarkor.com> <11751.1042815424@sss.pgh.pa.us> <87109443711.20030117200814@sarkor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <87109443711.20030117200814@sarkor.com>; from thor@sarkor.com on Fri, Jan 17, 2003 at 08:08:14PM +0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/182 X-Sequence-Number: 829 On Fri, Jan 17, 2003 at 08:08:14PM +0500, Timur Irmatov wrote: > Well, I've a seen a lot of people on pgsql-general mailing list with > problems with dates, timestamps, and I was just scared of using > PostreSQL date and time types and functions.. What problems? The only problems I know of with datetime stuff are on those machines with the utterly silly glibc hobbling, and even that has been worked around in recent releases. I think the date and time handling in PostgreSQL beats most systems. It just works, and handles all the time-zone conversions for you and everything. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Jan 17 10:41:10 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 387C7475F39 for ; Fri, 17 Jan 2003 10:41:06 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id A1522475EBF for ; Fri, 17 Jan 2003 10:41:05 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ZYcI-0006cl-00 for ; Fri, 17 Jan 2003 10:41:10 -0500 Date: Fri, 17 Jan 2003 10:41:10 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Implicit casting and JOIN syntax constraints Message-ID: <20030117104110.G23422@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com>; from rfail@posportal.com on Fri, Jan 17, 2003 at 06:48:28AM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/183 X-Sequence-Number: 830 On Fri, Jan 17, 2003 at 06:48:28AM -0800, Roman Fail wrote: > It seems to me that this should absolutely go on the TODO list. > Why does the planner require an explicit cast when the implicit > cast is so obvious? Does Oracle do this? I can assure you that > MSSQL does not. The reason it happens is because of the flexible datatype system in PostgreSQL. Because it's easy to add a datatype, you pay in other ways. The problem is coming up with a nice, clean set of rules for coercion. See the link that Tom Lane posted, and the thousands of other discussions around this in the archives. Yes, it's a pain. Everyone knows that. A complete solution is what's missing. > too. I've been writing SQL queries for 10 years in FoxPro, Access, > SQL Server, MySQL, and Sybase. I have never come across this very > confusing "feature" until now. Well, there are differences between every system. Indeed, the "SQL" of MySQL is so far from anything resembling the standard that one could argue it doesn't comply at all. You're right that it means a steep learning curve for some things, and the problems can be frustrating. But that doesn't mean you want to throw the baby out with the bathwater. The ability to give the planner hints through the JOIN syntax is, frankly, a real help when you're faced with certain kinds of performance problems. Some systems don't give you a knob to tune there at all. Is it different from other systems? Sure. Is that automatically a reason to pitch the feature? No. (Further discussion of this probably belongs on -general, if anywhere, by the way.) A ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Jan 17 12:14:36 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 37D2C475EAE for ; Fri, 17 Jan 2003 12:08:52 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 36CA4475E60 for ; Fri, 17 Jan 2003 12:08:51 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2317350; Fri, 17 Jan 2003 09:08:54 -0800 From: "Josh Berkus" Subject: Re: 7.3.1 New install, large queries are slow To: Tom Lane , "Roman Fail" Cc: sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Fri, 17 Jan 2003 09:08:54 -0800 Message-ID: In-Reply-To: <4981.1042783570@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/184 X-Sequence-Number: 831 Tom, > > shared_buffers = 131072 > > Yipes! Try about a tenth that much. Or less. Why? He has 4GB RAM on the machine. -Josh Berkus From pgsql-performance-owner@postgresql.org Fri Jan 17 12:33:56 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 506F84764FA for ; Fri, 17 Jan 2003 12:33:52 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 2544547743A for ; Fri, 17 Jan 2003 12:28:30 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 465BD1557D; Fri, 17 Jan 2003 12:28:35 -0500 (EST) Date: Fri, 17 Jan 2003 12:28:35 -0500 Subject: Strange Join question Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: Noah Silverman To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: <1B62AFA4-2A41-11D7-8B2D-000393AA8F3C@allresearch.com> X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/185 X-Sequence-Number: 832 Hi, I have a challenging (for me) SQL question: Two tables (Note: these are fictitious, the real tables actually make sense, so no need to re-design our table structure) Table 1 id | name | count ------------------------ 1 | foo | 10 1 | foo | 20 2 | bar | 100 Table 2 id | f1 | f2 | t1ref ----------------------- 1 | 10 | 20 | 1 2 | 50 | 40 | 2 The question: I want to do the following select: select table2.f1, table1.name from table1,table2 where table1.id = table 2.id and table2.id = 2; The problem is that I really only need the name from table2 returned once. With this query, I get two records back. Clearly this is because of the join that I am doing. Is there a different way to perform this join, so that I only get back ONE record from table1 that matches? Thanks, -Noah From pgsql-performance-owner@postgresql.org Fri Jan 17 12:37:13 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 690044772A6 for ; Fri, 17 Jan 2003 12:37:09 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A026F4773F7 for ; Fri, 17 Jan 2003 12:33:18 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0HHXB5u013110; Fri, 17 Jan 2003 12:33:11 -0500 (EST) To: "Josh Berkus" Cc: "Roman Fail" , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: References: Comments: In-reply-to "Josh Berkus" message dated "Fri, 17 Jan 2003 09:08:54 -0800" Date: Fri, 17 Jan 2003 12:33:11 -0500 Message-ID: <13109.1042824791@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/186 X-Sequence-Number: 833 "Josh Berkus" writes: >>> shared_buffers = 131072 >> >> Yipes! Try about a tenth that much. Or less. > Why? He has 4GB RAM on the machine. I think a gig of shared buffers is overkill no matter what. One reason not to crank up shared_buffers "just because you can" is that there are operations (such as CHECKPOINT) that have to scan through all the buffers, linearly. I don't *think* any of these are in performance-critical paths, but nonetheless you're wasting CPU. I trust the kernel to manage a huge number of buffers efficiently more than I trust Postgres. There's another issue, which is somewhat platform-dependent; I'm not sure if it applies to whatever OS Roman is using. But if you have a machine where SysV shared memory is not locked into RAM, then a huge shared buffer arena creates the probability that some of it will be touched seldom enough that the kernel will decide to swap it out. When that happens, you *really* pay through the nose --- a page that you might have been able to get from kernel cache without incurring I/O will now certainly cost you I/O to touch. It's even worse if the buffer contained a dirty page at the time it was swapped out --- now that page is going to require being read back in and written out again, a net cost of three I/Os where there should have been one. Bottom line is that shared_buffers should be kept small enough that the space all looks like a hot spot to the kernel's memory allocation manager. In short, I believe in keeping shared_buffers relatively small --- one to ten thousand seems like the right ballpark --- and leaving the kernel to allocate the rest of RAM as kernel disk cache. I have been thinking recently about proposing that we change the factory default shared_buffers to 1000, which if this line of reasoning is correct would eliminate the need for average installations to tune it. The reason the default is 64 is that on some older Unixen, the default SHMMAX is only one meg --- but it's been a long time since our default shared memory request was less than a meg anyway, because of bloat in other components of shared memory. It's probably time to change the default to something more reasonable from a performance standpoint, and put some burden on users of older Unixen to either reduce the setting or fix their SHMMAX parameter. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 17 12:51:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0A110476987; Fri, 17 Jan 2003 12:51:04 -0500 (EST) Received: from fddlnint05.fds.com (fddlnint05.fds.com [208.15.91.52]) by postgresql.org (Postfix) with ESMTP id 3B6D4477416; Fri, 17 Jan 2003 12:43:01 -0500 (EST) Subject: Re: Strange Join question To: "Noah Silverman Cc: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org X-Mailer: Lotus Notes Release 5.0.4 June 8, 2000 Message-ID: From: "Patrick Hatcher" Date: Fri, 17 Jan 2003 09:38:42 -0800 X-MIMETrack: Serialize by Router on FDDLNINT05/FSG/SVR/FDD(Release 5.0.4 |June 8, 2000) at 01/17/2003 12:40:07 PM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/187 X-Sequence-Number: 834 Can you do select table2.f1, table1.name from table1,table2 where table1.id = table 2.id and table2.id = 2 GROUP BY table2.f1, table1.name; Patrick Hatcher Macys.Com Legacy Integration Developer 415-422-1610 office HatcherPT - AIM Noah Silverman To: pgsql-performance@postgresql.org Sent by: cc: pgsql-performance-owner@post Subject: [PERFORM] Strange Join question gresql.org 01/17/2003 09:28 AM Hi, I have a challenging (for me) SQL question: Two tables (Note: these are fictitious, the real tables actually make sense, so no need to re-design our table structure) Table 1 id | name | count ------------------------ 1 | foo | 10 1 | foo | 20 2 | bar | 100 Table 2 id | f1 | f2 | t1ref ----------------------- 1 | 10 | 20 | 1 2 | 50 | 40 | 2 The question: I want to do the following select: select table2.f1, table1.name from table1,table2 where table1.id = table 2.id and table2.id = 2; The problem is that I really only need the name from table2 returned once. With this query, I get two records back. Clearly this is because of the join that I am doing. Is there a different way to perform this join, so that I only get back ONE record from table1 that matches? Thanks, -Noah ---------------------------(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 Fri Jan 17 12:56:13 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 04144477478 for ; Fri, 17 Jan 2003 12:56:06 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 91EA9477425 for ; Fri, 17 Jan 2003 12:52:38 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h0HHqLR27486; Fri, 17 Jan 2003 12:52:21 -0500 (EST) From: Bruce Momjian Message-Id: <200301171752.h0HHqLR27486@candle.pha.pa.us> Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <13109.1042824791@sss.pgh.pa.us> To: Tom Lane Date: Fri, 17 Jan 2003 12:52:21 -0500 (EST) Cc: Josh Berkus , Roman Fail , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/188 X-Sequence-Number: 835 Tom Lane wrote: > "Josh Berkus" writes: > >>> shared_buffers = 131072 > >> > >> Yipes! Try about a tenth that much. Or less. > > > Why? He has 4GB RAM on the machine. > > I think a gig of shared buffers is overkill no matter what. > > One reason not to crank up shared_buffers "just because you can" is that > there are operations (such as CHECKPOINT) that have to scan through all > the buffers, linearly. I don't *think* any of these are in > performance-critical paths, but nonetheless you're wasting CPU. I trust > the kernel to manage a huge number of buffers efficiently more than I > trust Postgres. > > There's another issue, which is somewhat platform-dependent; I'm not > sure if it applies to whatever OS Roman is using. But if you have a > machine where SysV shared memory is not locked into RAM, then a huge > shared buffer arena creates the probability that some of it will be > touched seldom enough that the kernel will decide to swap it out. When > that happens, you *really* pay through the nose --- a page that you > might have been able to get from kernel cache without incurring I/O will > now certainly cost you I/O to touch. It's even worse if the buffer > contained a dirty page at the time it was swapped out --- now that page > is going to require being read back in and written out again, a net cost > of three I/Os where there should have been one. Bottom line is that > shared_buffers should be kept small enough that the space all looks like > a hot spot to the kernel's memory allocation manager. Just as a data point, I believe other database systems recommend very large shared memory areas if a lot of data is being accessed. I seem to remember Informix doing that. -- 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 Fri Jan 17 13:03:30 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5A0754763AE for ; Fri, 17 Jan 2003 13:03:25 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id B65164773A6 for ; Fri, 17 Jan 2003 12:59:39 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ZamJ-0000pY-00 for ; Fri, 17 Jan 2003 12:59:39 -0500 Date: Fri, 17 Jan 2003 12:59:39 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030117125939.J23422@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <13109.1042824791@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <13109.1042824791@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Fri, Jan 17, 2003 at 12:33:11PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/189 X-Sequence-Number: 836 On Fri, Jan 17, 2003 at 12:33:11PM -0500, Tom Lane wrote: > One reason not to crank up shared_buffers "just because you can" is that > there are operations (such as CHECKPOINT) that have to scan through all > the buffers, linearly. I don't *think* any of these are in > performance-critical paths, but nonetheless you're wasting CPU. I trust > the kernel to manage a huge number of buffers efficiently more than I > trust Postgres. For what it's worth, we have exactly that experience on our Sun E4500s. I had machines with 12 gig I was testing on, and I increased the buffers to 2 Gig, because truss was showing us some sluggishness in the system was tripping on the system call to get a page. It was satisifed right away by the kernel's cache, but the system call was still the most expensive part of the operation. After we'd increased the shared buffers, however, performance _degraded_ considerably. It now spent all its time instead managing the huge shared buffer, and the cost of that was much worse than the cost of the system call. So it is extremely dependent on the efficiency of PostgreSQL's use of shared memory as compared to the efficiency of the system call. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Jan 17 13:04:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 452F9476726 for ; Fri, 17 Jan 2003 13:03:58 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 16E93477395 for ; Fri, 17 Jan 2003 13:01:19 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0HI195u013373; Fri, 17 Jan 2003 13:01:09 -0500 (EST) To: Bruce Momjian Cc: Josh Berkus , Roman Fail , sszabo@megazone23.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: <200301171752.h0HHqLR27486@candle.pha.pa.us> References: <200301171752.h0HHqLR27486@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Fri, 17 Jan 2003 12:52:21 -0500" Date: Fri, 17 Jan 2003 13:01:09 -0500 Message-ID: <13372.1042826469@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/190 X-Sequence-Number: 837 Bruce Momjian writes: > Just as a data point, I believe other database systems recommend very > large shared memory areas if a lot of data is being accessed. I seem to > remember Informix doing that. Yeah, but isn't that theory a hangover from pre-Unix operating systems? In all modern Unixen, you can expect the kernel to make use of any spare RAM for disk buffer cache --- and that behavior makes it pointless for Postgres to try to do large amounts of its own buffering. Having a page in our own buffer instead of kernel buffer saves a context swap to access the page, but it doesn't save I/O, so the benefit is a lot less than you might think. I think there's seriously diminishing returns in pushing shared_buffers beyond a few thousand, and once you get to the point where it distorts the kernel's ability to manage memory for processes, you're really shooting yourself in the foot. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 17 14:04:06 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4B1BA476939 for ; Fri, 17 Jan 2003 13:41:54 -0500 (EST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.215.169]) by postgresql.org (Postfix) with SMTP id 0B4884773E0 for ; Fri, 17 Jan 2003 13:39:38 -0500 (EST) Received: (qmail 56672 invoked from network); 17 Jan 2003 18:39:42 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 17 Jan 2003 18:39:42 -0000 Date: Fri, 17 Jan 2003 13:39:41 -0500 (EST) From: Jeff To: Tom Lane Cc: Bruce Momjian , Josh Berkus , Roman Fail , "sszabo@megazone23.bigpanda.com" , "pgsql-performance@postgresql.org" Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <13372.1042826469@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/191 X-Sequence-Number: 838 On Fri, 17 Jan 2003, Tom Lane wrote: > > Yeah, but isn't that theory a hangover from pre-Unix operating systems? > In all modern Unixen, you can expect the kernel to make use of any spare > RAM for disk buffer cache --- and that behavior makes it pointless for > Postgres to try to do large amounts of its own buffering. > Informix, oracle, etc all do raw device access bypassing the kernels buffering, etc. So they need heaping gobules of memory to do the same thing the kernel does.. but since they know the exact patterns of data and how things will be done they can fine tune their buffer caches to get much better performance than the kernel (15-20% in informix's case) since the kernel needs to be a "works good generally" probably the desire to crank that up stems from using those other db's I know I used to do that with pgsql. (Ahh, I crank that setting up through the roof on informix, I'll do the same with pg) perhaps a FAQ entry or comment in the shipped config about it? I think if people realize it isn't quite the same as what it does in oracle/informix/etc then they'll be less inclined to cranking it. ------------------------------------------------------------------------------ Jeff Trout http://www.jefftrout.com/ Ronald McDonald, with the help of cheese soup, controls America from a secret volkswagon hidden in the past ------------------------------------------------------------------------------- From pgsql-general-owner@postgresql.org Fri Jan 17 14:39:13 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 925F1475957 for ; Fri, 17 Jan 2003 14:39:07 -0500 (EST) Received: from polaris.pinpointresearch.com (66-7-238-176.cust.telepacific.net [66.7.238.176]) by postgresql.org (Postfix) with ESMTP id BC051477378 for ; Fri, 17 Jan 2003 14:37:30 -0500 (EST) Received: from there (66-7-238-179.cust.telepacific.net [66.7.238.179]) by polaris.pinpointresearch.com (Postfix) with SMTP id 1CFCB103E5 for ; Fri, 17 Jan 2003 11:37:26 -0800 (PST) Content-Type: text/plain; charset="iso-8859-15" From: Steve Crawford Organization: Pinpoint Research To: pgsql-general@postgresql.org Subject: Terrible performance on wide selects Date: Fri, 17 Jan 2003 11:37:26 -0800 X-Mailer: KMail [version 1.3.1] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <20030117193726.1CFCB103E5@polaris.pinpointresearch.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/659 X-Sequence-Number: 35780 I have a table which is rather wide (~800 columns) and consists of a few columns of identifying data (run time, channel and such) and up to several hundred columns of collected data (no, normalization does not suggest putting collected data in another table - collected item 1 always corresponds to collected item 1 but is completely different than item 3). My test table is very short (62 rows) but in production would grow by several thousand rows per day. Unfortunately if my test data is correct, performance on wide selects is so bad that it will render the system unusable. Here's the test. I have created two versions of the table - one stores the collected data in an array of text and the other stores the data in individual columns, no joins, no indexes. Times are averages of many runs - the times varied very little and the data is small enough that I'm sure it was served from RAM. Postgres CPU utilization observed on the longer runs was 98-99%. Changing the output format didn't seem to change things significantly. Times for selecting all the columns in the table: select * from columnversion; 8,000 ms select * from arrayversion; 110 ms select * from arraytocolumnview (data in the array version but converted to columns in the view) 10,000 ms Times to select a single column in a table: select runstarttime from columversion; 32 ms select runstarttime from arrayversion; 6 ms So the question is, does it seem reasonable that a query on fundamentally identical data should take 70-90 times as long when displayed as individual columns vs. when output as a raw array and, more imporantly, what can I do to get acceptable performance on this query? Cheers, Steve From pgsql-general-owner@postgresql.org Fri Jan 17 18:18:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A5F8C4773E2 for ; Fri, 17 Jan 2003 18:18:05 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 92DB2476A5B for ; Fri, 17 Jan 2003 18:12:24 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0HN6q5u019507; Fri, 17 Jan 2003 18:06:54 -0500 (EST) To: Steve Crawford Cc: pgsql-general@postgresql.org Subject: Re: Terrible performance on wide selects In-reply-to: <20030117193726.1CFCB103E5@polaris.pinpointresearch.com> References: <20030117193726.1CFCB103E5@polaris.pinpointresearch.com> Comments: In-reply-to Steve Crawford message dated "Fri, 17 Jan 2003 11:37:26 -0800" Date: Fri, 17 Jan 2003 18:06:52 -0500 Message-ID: <19506.1042844812@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/671 X-Sequence-Number: 35792 Steve Crawford writes: > So the question is, does it seem reasonable that a query on fundamentally > identical data should take 70-90 times as long when displayed as individual > columns vs. when output as a raw array and, more imporantly, what can I do to > get acceptable performance on this query? There are undoubtedly some places that are O(N^2) in the number of targetlist items. Feel free to do some profiling to identify them. It probably won't be real hard to fix 'em once identified. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 17 23:51:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E50A0476324 for ; Fri, 17 Jan 2003 23:51:10 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 9F91C47680A for ; Fri, 17 Jan 2003 23:50:10 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0I4nV5u021624; Fri, 17 Jan 2003 23:49:34 -0500 (EST) To: Jeff Cc: Bruce Momjian , Josh Berkus , Roman Fail , "sszabo@megazone23.bigpanda.com" , "pgsql-performance@postgresql.org" Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: References: Comments: In-reply-to Jeff message dated "Fri, 17 Jan 2003 13:39:41 -0500" Date: Fri, 17 Jan 2003 23:49:31 -0500 Message-ID: <21623.1042865371@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/192 X-Sequence-Number: 839 Jeff writes: > On Fri, 17 Jan 2003, Tom Lane wrote: >> Yeah, but isn't that theory a hangover from pre-Unix operating systems? > Informix, oracle, etc all do raw device access bypassing the kernels > buffering, etc. So they need heaping gobules of memory to do the same > thing the kernel does.. D'oh, I believe Jeff's put his finger on it. You need lotsa RAM if you are trying to bypass the OS. But Postgres would like to work with the OS, not bypass it. > but since they know the exact patterns of data and > how things will be done they can fine tune their buffer caches to get much > better performance than the kernel (15-20% in informix's case) since the > kernel needs to be a "works good generally" They go to all that work for 15-20% ??? Remind me not to follow that primrose path. I can think of lots of places where we can buy 20% for less work than implementing (and maintaining) our own raw-device access layer. > perhaps a FAQ entry or comment in the shipped config about it? > I think if people realize it isn't quite the same as what it does in > oracle/informix/etc then they'll be less inclined to cranking it. Good thought. But we do need to set the default to something a tad more realistic-for-2003 than 64 buffers ... regards, tom lane From pgsql-performance-owner@postgresql.org Sat Jan 18 00:38:28 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BC22D475AD7 for ; Sat, 18 Jan 2003 00:29:47 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 072814758E1 for ; Sat, 18 Jan 2003 00:29:47 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030118052952.GMJC8666.lakemtao03.cox.net@[192.168.1.1]> for ; Sat, 18 Jan 2003 00:29:52 -0500 Subject: x86-64 and PostgreSQL From: Ron Johnson To: PgSQL Performance ML Content-Type: text/plain Organization: Message-Id: <1042867764.889.181.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 17 Jan 2003 23:29:25 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/193 X-Sequence-Number: 840 Hi, Will there be any advantages to running Pg on a 64-bit CPU rather than 32-bit? The recent discussions in the "7.3.1 New install, large queries are slow" thread make me think not, since Pg says that the OS can manage buffers better: Yeah, but isn't that theory a hangover from pre-Unix operating systems? In all modern Unixen, you can expect the kernel to make use of any spare RAM for disk buffer cache --- and that behavior makes it pointless for Postgres to try to do large amounts of its own buffering. Having a page in our own buffer instead of kernel buffer saves a context swap to access the page, but it doesn't save I/O, so the benefit is a lot less than you might think. I think there's seriously diminishing returns in pushing shared_buffers beyond a few thousand, and once you get to the point where it distorts the kernel's ability to manage memory for processes, you're really shooting yourself in the foot. Also, would int8 then become a more "natural" default integer, rather than the int4 that all of us millions of i386, PPC & Sparc users use? Thanks, Ron -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sat Jan 18 02:07:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 252114763C3 for ; Sat, 18 Jan 2003 01:44:38 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 5859C47636B for ; Sat, 18 Jan 2003 01:44:37 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0I6iZ5u022329; Sat, 18 Jan 2003 01:44:36 -0500 (EST) To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: x86-64 and PostgreSQL In-reply-to: <1042867764.889.181.camel@haggis> References: <1042867764.889.181.camel@haggis> Comments: In-reply-to Ron Johnson message dated "17 Jan 2003 23:29:25 -0600" Date: Sat, 18 Jan 2003 01:44:35 -0500 Message-ID: <22328.1042872275@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/195 X-Sequence-Number: 842 Ron Johnson writes: > Will there be any advantages to running Pg on a 64-bit CPU rather > than 32-bit? Not so's you'd notice. PG is designed to be cross-platform, and at the moment that means 32-bit-centric. There's been occasional talk of improving the performance of float8 and int8 types on 64-bit machines, but so far it's only idle talk; and in any case I think that performance improvements for those two datatypes wouldn't have much effect for average applications. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Jan 18 02:07:30 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1A0C6475AD7 for ; Sat, 18 Jan 2003 01:55:09 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id 824EA474E53 for ; Sat, 18 Jan 2003 01:55:08 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030118065508.GYLM6744.lakemtao02.cox.net@[192.168.1.1]> for ; Sat, 18 Jan 2003 01:55:08 -0500 Subject: Re: x86-64 and PostgreSQL From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <22328.1042872275@sss.pgh.pa.us> References: <1042867764.889.181.camel@haggis> <22328.1042872275@sss.pgh.pa.us> Content-Type: text/plain Organization: Message-Id: <1042872864.7792.43.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 18 Jan 2003 00:55:04 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/194 X-Sequence-Number: 841 On Sat, 2003-01-18 at 00:44, Tom Lane wrote: > Ron Johnson writes: > > Will there be any advantages to running Pg on a 64-bit CPU rather > > than 32-bit? > > Not so's you'd notice. PG is designed to be cross-platform, and at > the moment that means 32-bit-centric. There's been occasional talk > of improving the performance of float8 and int8 types on 64-bit > machines, but so far it's only idle talk; and in any case I think > that performance improvements for those two datatypes wouldn't have > much effect for average applications. That's kinda what I expected. The ability to /relatively/ inexpensively get a box chock full of RAM couldn't hurt, though... Putting a 12GB database on a box with 8GB RAM has to make it run pretty fast. (As long as you aren't joining mismatched types!!!) -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sat Jan 18 02:39:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ABCCF474E53 for ; Sat, 18 Jan 2003 02:39:49 -0500 (EST) Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) by postgresql.org (Postfix) with ESMTP id 9663E475AD7 for ; Sat, 18 Jan 2003 02:39:48 -0500 (EST) Received: from localhost (db@localhost) by zigo.dhs.org (8.11.6/8.11.6) with ESMTP id h0I7d8S02797; Sat, 18 Jan 2003 08:39:09 +0100 Date: Sat, 18 Jan 2003 08:39:08 +0100 (CET) From: =?ISO-8859-1?Q?Dennis_Bj=F6rklund?= To: Roman Fail Cc: Josh Berkus , , Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C09@pos_pdc.posportal.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/196 X-Sequence-Number: 843 On Thu, 16 Jan 2003, Roman Fail wrote: > It sort of feels like a magic moment. I went back and looked through a > lot of the JOIN columns and found that I was mixing int4 with int8 in a > lot of them. There is note about it in the docs: http://www.postgresql.org/idocs/index.php?datatype.html#DATATYPE-INT I don't know if this is in a faq anywhere, but it should be. I myself have helped a number of persons with this. Every once in a while there come someone in to the #postgresql irc channel with the exact same problem. Usually they leave the channel very happy, when their queries take less then a second instead of minutes. -- /Dennis From pgsql-performance-owner@postgresql.org Sat Jan 18 14:55:18 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8B380475CE5 for ; Sat, 18 Jan 2003 11:26:21 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 7EF2D475E26 for ; Sat, 18 Jan 2003 11:24:21 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18Zvli-0006Hg-00 for ; Sat, 18 Jan 2003 11:24:26 -0500 Date: Sat, 18 Jan 2003 11:24:26 -0500 From: Andrew Sullivan To: "pgsql-performance@postgresql.org" Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030118112426.A23790@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , "pgsql-performance@postgresql.org" References: <21623.1042865371@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <21623.1042865371@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Fri, Jan 17, 2003 at 11:49:31PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/198 X-Sequence-Number: 845 On Fri, Jan 17, 2003 at 11:49:31PM -0500, Tom Lane wrote: > Jeff writes: > > Informix, oracle, etc all do raw device access bypassing the kernels > > buffering, etc. So they need heaping gobules of memory to do the same > > thing the kernel does.. > > D'oh, I believe Jeff's put his finger on it. You need lotsa RAM if you > are trying to bypass the OS. But Postgres would like to work with the > OS, not bypass it. One of the interesting things I have been playing with on Solaris recently is the various no-buffer settings you can give to the kernel for filesystems. The idea is that you don't have the kernel do the buffering, and you set your database's shared memory setting _reeeeal_ high. As nearly as I can tell, there is again no benefit with PostgreSQL. I'd also be amazed if this approach is a win for other systems. But a lot of DBAs seem to believe that they know better than their computers which tables are "really" accessed frequently. I think they must be smarter than I am: I'd rather trust a system that was designed to track these things and change the tuning on the fly, myself. (To be fair, there are some cases where you have an infrequently-accessed table which nevertheless is required to be fast for some reason or other, so you might want to force it to stay in memory.) A ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Sat Jan 18 14:54:58 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0480B475ED1 for ; Sat, 18 Jan 2003 11:39:31 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 71918475AD7 for ; Sat, 18 Jan 2003 11:39:30 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18Zw0N-0006ZM-00 for ; Sat, 18 Jan 2003 11:39:35 -0500 Date: Sat, 18 Jan 2003 11:39:35 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: x86-64 and PostgreSQL Message-ID: <20030118113935.C23790@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <1042867764.889.181.camel@haggis> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1042867764.889.181.camel@haggis>; from ron.l.johnson@cox.net on Fri, Jan 17, 2003 at 11:29:25PM -0600 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/197 X-Sequence-Number: 844 On Fri, Jan 17, 2003 at 11:29:25PM -0600, Ron Johnson wrote: > Hi, > > Will there be any advantages to running Pg on a 64-bit CPU rather > than 32-bit? In my experience, not really. We use SPARCs under Solaris 7 and, now, 8. We haven't found any terribly obvious advantages with the system compiled as a 64 bit app, but we _did_ find problems with the 64 bit libraries combined with gcc. As a result of that and pressures to get working on some other things, we stopped testing Postgres as a 64 bit app on Solaris. We haven't done any work on Solaris 8 with it, and that system is a little more mature in the 64-bit-support department, so when I have a chance do to more investigation, I will. > Also, would int8 then become a more "natural" default integer, rather > than the int4 that all of us millions of i386, PPC & Sparc users use? I think the problem with int8s in a lot of cases has more to do with typer coercion. So at least in systems < 7.4, I'm not sure you'll see a big win, unless you make sure to cast everything correctly. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Mon Jan 20 01:29:43 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9049C475D22 for ; Mon, 20 Jan 2003 01:29:42 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 38D45475B8F for ; Mon, 20 Jan 2003 01:29:40 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0K6Tcs30556 for ; Mon, 20 Jan 2003 11:59:38 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0K6TcU30551 for ; Mon, 20 Jan 2003 11:59:38 +0530 From: "Shridhar Daithankar" To: PgSQL Performance ML Date: Mon, 20 Jan 2003 11:59:59 +0530 MIME-Version: 1.0 Subject: Re: x86-64 and PostgreSQL Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E2BE4BF.28150.D33005A@localhost> In-reply-to: <20030118113935.C23790@mail.libertyrms.com> References: <1042867764.889.181.camel@haggis>; from ron.l.johnson@cox.net on Fri, Jan 17, 2003 at 11:29:25PM -0600 X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/199 X-Sequence-Number: 846 On 18 Jan 2003 at 11:39, Andrew Sullivan wrote: > On Fri, Jan 17, 2003 at 11:29:25PM -0600, Ron Johnson wrote: > > Hi, > > > > Will there be any advantages to running Pg on a 64-bit CPU rather > > than 32-bit? > > In my experience, not really. We use SPARCs under Solaris 7 and, > now, 8. We haven't found any terribly obvious advantages with the > system compiled as a 64 bit app, but we _did_ find problems with the > 64 bit libraries combined with gcc. As a result of that and > pressures to get working on some other things, we stopped testing > Postgres as a 64 bit app on Solaris. We haven't done any work on > Solaris 8 with it, and that system is a little more mature in the > 64-bit-support department, so when I have a chance do to more > investigation, I will. I remember reading in one of the HP guides regarding 64 bit that 64 bit is a tool provided for applications. In general no app. should be 64 bit unless required. In fact they advice that fastest performance one can get is by running 32 bit app. on 64 bit machine because registers are wide and can be filled in is less number of fetches. Sounds reasonable to me. Bye Shridhar -- Tip of the Day: Never fry bacon in the nude. [Correction: always fry bacon in the nude; you'll learn not to burn it] From pgsql-performance-owner@postgresql.org Mon Jan 20 01:34:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A339F475AE6 for ; Mon, 20 Jan 2003 01:34:27 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id CD0ED475AA1 for ; Mon, 20 Jan 2003 01:34:25 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0K6YOG31276 for ; Mon, 20 Jan 2003 12:04:24 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0K6YOU31271 for ; Mon, 20 Jan 2003 12:04:24 +0530 From: "Shridhar Daithankar" To: pgsql-performance@postgresql.org Date: Mon, 20 Jan 2003 12:04:45 +0530 MIME-Version: 1.0 Subject: Re: 7.3.1 New install, large queries are slow Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E2BE5DD.30158.D375D9A@localhost> References: In-reply-to: <13109.1042824791@sss.pgh.pa.us> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/200 X-Sequence-Number: 847 On 17 Jan 2003 at 12:33, Tom Lane wrote: > "Josh Berkus" writes: > >>> shared_buffers = 131072 > >> > >> Yipes! Try about a tenth that much. Or less. > > > Why? He has 4GB RAM on the machine. > > I think a gig of shared buffers is overkill no matter what. > > One reason not to crank up shared_buffers "just because you can" is that > there are operations (such as CHECKPOINT) that have to scan through all > the buffers, linearly. I don't *think* any of these are in > performance-critical paths, but nonetheless you're wasting CPU. I trust Assuming that one knows what he/she is doing, would it help in such cases i.e. the linear search thing, to bump up page size to day 16K/32K? and that is also the only way to make postgresql use more than couple of gigs of RAM, isn't it? Bye Shridhar -- Arithmetic: An obscure art no longer practiced in the world's developed countries. From pgsql-performance-owner@postgresql.org Mon Jan 20 02:14:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DC8F9475AE6 for ; Mon, 20 Jan 2003 02:14:52 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 4AE12475AA1 for ; Mon, 20 Jan 2003 02:14:52 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0K7Ei5u027221; Mon, 20 Jan 2003 02:14:44 -0500 (EST) To: shridhar_daithankar@persistent.co.in Cc: pgsql-performance@postgresql.org Subject: Re: 7.3.1 New install, large queries are slow In-reply-to: <3E2BE5DD.30158.D375D9A@localhost> References: <3E2BE5DD.30158.D375D9A@localhost> Comments: In-reply-to "Shridhar Daithankar" message dated "Mon, 20 Jan 2003 12:04:45 +0530" Date: Mon, 20 Jan 2003 02:14:43 -0500 Message-ID: <27220.1043046883@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/201 X-Sequence-Number: 848 "Shridhar Daithankar" writes: > On 17 Jan 2003 at 12:33, Tom Lane wrote: >> One reason not to crank up shared_buffers "just because you can" is that >> there are operations (such as CHECKPOINT) that have to scan through all >> the buffers, linearly. I don't *think* any of these are in >> performance-critical paths, but nonetheless you're wasting CPU. I trust > Assuming that one knows what he/she is doing, would it help in such cases i.e. > the linear search thing, to bump up page size to day 16K/32K? You mean increase page size and decrease the number of buffers proportionately? It'd save on buffer-management overhead, but I wouldn't assume there'd be an overall performance gain. The system would have to do more I/O per page read or written; which might be a wash for sequential scans, but I bet it would hurt for random access. > and that is also the only way to make postgresql use more than couple of gigs > of RAM, isn't it? It seems quite unrelated. The size of our shared memory segment is limited by INT_MAX --- chopping it up differently won't change that. In any case, I think worrying because you can't push shared buffers above two gigs is completely wrongheaded, for the reasons already discussed in this thread. The notion that Postgres can't use more than two gig because its shared memory is limited to that is *definitely* wrongheaded. We can exploit however much memory your kernel can manage for kernel disk cache. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Jan 20 02:44:10 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DB8B7475D22 for ; Mon, 20 Jan 2003 02:44:08 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 0CC2D475AE6 for ; Mon, 20 Jan 2003 02:44:07 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0K7i6v06628 for ; Mon, 20 Jan 2003 13:14:06 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0K7i6J06623 for ; Mon, 20 Jan 2003 13:14:06 +0530 From: "Shridhar Daithankar" To: pgsql-performance@postgresql.org Date: Mon, 20 Jan 2003 13:14:27 +0530 MIME-Version: 1.0 Subject: Re: 7.3.1 New install, large queries are slow Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E2BF633.14532.D772D99@localhost> References: <3E2BE5DD.30158.D375D9A@localhost> In-reply-to: <27220.1043046883@sss.pgh.pa.us> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/202 X-Sequence-Number: 849 On 20 Jan 2003 at 2:14, Tom Lane wrote: > "Shridhar Daithankar" writes: > > Assuming that one knows what he/she is doing, would it help in such cases i.e. > > the linear search thing, to bump up page size to day 16K/32K? > > You mean increase page size and decrease the number of buffers > proportionately? It'd save on buffer-management overhead, but > I wouldn't assume there'd be an overall performance gain. The > system would have to do more I/O per page read or written; which > might be a wash for sequential scans, but I bet it would hurt for > random access. Right. But it has its own applications. If I am saving huge data blocks like say gene stuff, I might be better off living with a relatively bigger page fragmentation. > > and that is also the only way to make postgresql use more than couple of gigs > > of RAM, isn't it? > > It seems quite unrelated. The size of our shared memory segment is > limited by INT_MAX --- chopping it up differently won't change that. Well, if my page size is doubled, I can get double amount of shared buffers. That was the logic nothing else. > In any case, I think worrying because you can't push shared buffers > above two gigs is completely wrongheaded, for the reasons already > discussed in this thread. The notion that Postgres can't use more > than two gig because its shared memory is limited to that is > *definitely* wrongheaded. We can exploit however much memory your > kernel can manage for kernel disk cache. Well, I agree completely. However there are folks and situation which demands things because they can be done. This is just to check out the absolute limit what it can manage. Bye Shridhar -- Bagdikian's Observation: Trying to be a first-rate reporter on the average American newspaper is like trying to play Bach's "St. Matthew Passion" on a ukelele. From pgsql-performance-owner@postgresql.org Mon Jan 20 04:41:32 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3C77D476538 for ; Mon, 20 Jan 2003 04:41:31 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 6A1B947646C for ; Mon, 20 Jan 2003 04:41:24 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030120094126.LQFD8666.lakemtao03.cox.net@[192.168.1.1]> for ; Mon, 20 Jan 2003 04:41:26 -0500 Subject: Very large caches (was Re: 7.3.1 New install, large queries are slow) From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <27220.1043046883@sss.pgh.pa.us> References: <3E2BE5DD.30158.D375D9A@localhost> <27220.1043046883@sss.pgh.pa.us> Content-Type: text/plain Organization: Message-Id: <1043055681.15592.156.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 20 Jan 2003 03:41:21 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/203 X-Sequence-Number: 850 On Mon, 2003-01-20 at 01:14, Tom Lane wrote: > "Shridhar Daithankar" writes: > > On 17 Jan 2003 at 12:33, Tom Lane wrote: [snip] > > and that is also the only way to make postgresql use more than couple of gigs > > of RAM, isn't it? > > It seems quite unrelated. The size of our shared memory segment is > limited by INT_MAX --- chopping it up differently won't change that. > > In any case, I think worrying because you can't push shared buffers > above two gigs is completely wrongheaded, for the reasons already > discussed in this thread. The notion that Postgres can't use more > than two gig because its shared memory is limited to that is > *definitely* wrongheaded. We can exploit however much memory your > kernel can manage for kernel disk cache. http://www.redhat.com/services/techsupport/production/GSS_caveat.html "RAM Limitations on IA32 Red Hat Linux releases based on the 2.4 kernel -- including Red Hat Linux 7.1, 7.2, 7.3 and Red Hat Linux Advanced Server 2.1 -- support a maximum of 16GB of RAM." So if I have some honking "big" Compaq Xeon SMP server w/ 16GB RAM, and top(1) shows that there is 8GB of buffers, then Pg will be happy as a pig in the mud? -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 20 04:52:19 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6B582475E14 for ; Mon, 20 Jan 2003 04:52:18 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 83970475D22 for ; Mon, 20 Jan 2003 04:52:17 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030120095219.LTFL8666.lakemtao03.cox.net@[192.168.1.1]> for ; Mon, 20 Jan 2003 04:52:19 -0500 Subject: Re: x86-64 and PostgreSQL From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <3E2BE4BF.28150.D33005A@localhost> References: <1042867764.889.181.camel@haggis> ; from ron.l.johnson@cox.net on Fri, Jan 17, 2003 at 11:29:25PM -0600 <3E2BE4BF.28150.D33005A@localhost> Content-Type: text/plain Organization: Message-Id: <1043056334.15592.167.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 20 Jan 2003 03:52:15 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/204 X-Sequence-Number: 851 On Mon, 2003-01-20 at 00:29, Shridhar Daithankar wrote: > On 18 Jan 2003 at 11:39, Andrew Sullivan wrote: > > On Fri, Jan 17, 2003 at 11:29:25PM -0600, Ron Johnson wrote: > > > Hi, > > > > > > Will there be any advantages to running Pg on a 64-bit CPU rather > > > than 32-bit? > > > > In my experience, not really. We use SPARCs under Solaris 7 and, > > now, 8. We haven't found any terribly obvious advantages with the > > system compiled as a 64 bit app, but we _did_ find problems with the > > 64 bit libraries combined with gcc. As a result of that and > > pressures to get working on some other things, we stopped testing > > Postgres as a 64 bit app on Solaris. We haven't done any work on > > Solaris 8 with it, and that system is a little more mature in the > > 64-bit-support department, so when I have a chance do to more > > investigation, I will. > > I remember reading in one of the HP guides regarding 64 bit that 64 bit is a > tool provided for applications. In general no app. should be 64 bit unless > required. In fact they advice that fastest performance one can get is by > running 32 bit app. on 64 bit machine because registers are wide and can be > filled in is less number of fetches. > > Sounds reasonable to me. Dou you, the programmer or SysAdmin, always know when 64 bits is needed? Take, for simple example, a memcpy() of 1024 bytes. Most CPUs don't have direct core-core copy instruction. (The RISC philosophy, after all, is load-and-store.) A 32-bit executable would need 1024/32 = 32 pairs of load-store operations, while a 64-bit executable would only need 16. Yes, L1 & L2 caching would help some, but not if you are moving huge amounts of data... -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 20 04:59:23 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2878B475D22 for ; Mon, 20 Jan 2003 04:59:22 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 4B878475CED for ; Mon, 20 Jan 2003 04:59:20 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0K9xLJ27009 for ; Mon, 20 Jan 2003 15:29:21 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0K9xKn27004 for ; Mon, 20 Jan 2003 15:29:20 +0530 From: "Shridhar Daithankar" To: PgSQL Performance ML Date: Mon, 20 Jan 2003 15:29:42 +0530 MIME-Version: 1.0 Subject: Re: x86-64 and PostgreSQL Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E2C15E6.9191.DF2FEFC@localhost> References: <3E2BE4BF.28150.D33005A@localhost> In-reply-to: <1043056334.15592.167.camel@haggis> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/205 X-Sequence-Number: 852 On 20 Jan 2003 at 3:52, Ron Johnson wrote: > On Mon, 2003-01-20 at 00:29, Shridhar Daithankar wrote: > > I remember reading in one of the HP guides regarding 64 bit that 64 bit is a > > tool provided for applications. In general no app. should be 64 bit unless > > required. In fact they advice that fastest performance one can get is by > > running 32 bit app. on 64 bit machine because registers are wide and can be > > filled in is less number of fetches. > > > > Sounds reasonable to me. > > Dou you, the programmer or SysAdmin, always know when 64 bits is > needed? > > Take, for simple example, a memcpy() of 1024 bytes. Most CPUs don't > have direct core-core copy instruction. (The RISC philosophy, after > all, is load-and-store.) A 32-bit executable would need 1024/32 = 32 > pairs of load-store operations, while a 64-bit executable would only > need 16. Yes, L1 & L2 caching would help some, but not if you are > moving huge amounts of data... Well, that wasn't intended application aera of that remark. I was more on the line of, I have 16GB data of double precision which I need to shuffle thr. once in a while, should I use 32 bit or 64 bit? Something like that.. bit more macroscopic. I work on an application which is 32 bit on HP-UX 64 bit. It handles more than 15GB of data at some sites pretty gracefully..No need to move to 64 bit as yet.. Bye Shridhar -- Kramer's Law: You can never tell which way the train went by looking at the tracks. From pgsql-performance-owner@postgresql.org Mon Jan 20 07:06:13 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7F6BF475CED for ; Mon, 20 Jan 2003 07:06:11 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id BDBDA475CE7 for ; Mon, 20 Jan 2003 07:06:10 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030120120613.NETK8666.lakemtao03.cox.net@[192.168.1.1]> for ; Mon, 20 Jan 2003 07:06:13 -0500 Subject: Re: x86-64 and PostgreSQL From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <3E2C15E6.9191.DF2FEFC@localhost> References: <3E2BE4BF.28150.D33005A@localhost> <3E2C15E6.9191.DF2FEFC@localhost> Content-Type: text/plain Organization: Message-Id: <1043064363.15592.187.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 20 Jan 2003 06:06:04 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/206 X-Sequence-Number: 853 On Mon, 2003-01-20 at 03:59, Shridhar Daithankar wrote: > On 20 Jan 2003 at 3:52, Ron Johnson wrote: > > > On Mon, 2003-01-20 at 00:29, Shridhar Daithankar wrote: > > > I remember reading in one of the HP guides regarding 64 bit that 64 bit is a > > > tool provided for applications. In general no app. should be 64 bit unless > > > required. In fact they advice that fastest performance one can get is by > > > running 32 bit app. on 64 bit machine because registers are wide and can be > > > filled in is less number of fetches. > > > > > > Sounds reasonable to me. > > > > Dou you, the programmer or SysAdmin, always know when 64 bits is > > needed? > > > > Take, for simple example, a memcpy() of 1024 bytes. Most CPUs don't > > have direct core-core copy instruction. (The RISC philosophy, after > > all, is load-and-store.) A 32-bit executable would need 1024/32 = 32 > > pairs of load-store operations, while a 64-bit executable would only > > need 16. Yes, L1 & L2 caching would help some, but not if you are > > moving huge amounts of data... > > Well, that wasn't intended application aera of that remark. I was more on the > line of, I have 16GB data of double precision which I need to shuffle thr. once > in a while, should I use 32 bit or 64 bit? > > Something like that.. bit more macroscopic. > > I work on an application which is 32 bit on HP-UX 64 bit. It handles more than > 15GB of data at some sites pretty gracefully..No need to move to 64 bit as > yet.. Maybe you wouldn't get a speed boost on HP-UX, but I bet you would on x86-64. Why? 64 bit programs get to use the new registers that AMD created just for 64 bit mode. Thus, the compiler should, hopefully, be able to generate more efficient code. Also, since (at least on the gcc-3.2 compiler) a "long" and "int" are still 32 bits (64 bit scalars are of type "long long"), existing programs (that all use "long" and "int") will still only fill up 1/2 of each register (attaining the speed that HP alleges), but, as I mentioned above, would be able to use the extra registers if recompiled into native 64-bit apps... $ cat test.c #include #include int main (int argc, char **argv) { printf("%d %d %d\n", sizeof(long), sizeof(int), sizeof(long long)); }; $ gcc-3.2 test.c && ./a.out 4 4 8 -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Basically, I got on the plane with a bomb. Basically, I | | tried to ignite it. Basically, yeah, I intended to damage | | the plane." | | RICHARD REID, who tried to blow up American Airlines | | Flight 63 | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 20 07:11:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D5653475CED for ; Mon, 20 Jan 2003 07:11:38 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 23E74475CE7 for ; Mon, 20 Jan 2003 07:11:36 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0KCBbs13104 for ; Mon, 20 Jan 2003 17:41:37 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0KCBbw13099 for ; Mon, 20 Jan 2003 17:41:37 +0530 From: "Shridhar Daithankar" To: PgSQL Performance ML Date: Mon, 20 Jan 2003 17:41:59 +0530 MIME-Version: 1.0 Subject: Re: x86-64 and PostgreSQL Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E2C34E7.25952.E6C1A58@localhost> References: <3E2C15E6.9191.DF2FEFC@localhost> In-reply-to: <1043064363.15592.187.camel@haggis> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/207 X-Sequence-Number: 854 On 20 Jan 2003 at 6:06, Ron Johnson wrote: > On Mon, 2003-01-20 at 03:59, Shridhar Daithankar wrote: > > On 20 Jan 2003 at 3:52, Ron Johnson wrote: > > I work on an application which is 32 bit on HP-UX 64 bit. It handles more than > > 15GB of data at some sites pretty gracefully..No need to move to 64 bit as > > yet.. > > Maybe you wouldn't get a speed boost on HP-UX, but I bet you would on > x86-64. Why? 64 bit programs get to use the new registers that AMD > created just for 64 bit mode. Thus, the compiler should, hopefully, > be able to generate more efficient code. Well, that is not the issue exactly. The app. is commercial with oracle under it and it si going nowhere but oracle/HP-UX for its remaining lifecycle.. I was just quoting it as an example. > Also, since (at least on the gcc-3.2 compiler) a "long" and "int" are > still 32 bits (64 bit scalars are of type "long long"), existing > programs (that all use "long" and "int") will still only fill up 1/2 > of each register (attaining the speed that HP alleges), but, as I > mentioned above, would be able to use the extra registers if recompiled > into native 64-bit apps... I am not too sure, but most 64bit migration guides talk of ILP paradigm that is integer/long/pointer with later two going to 8 bits. If gcc puts long at 4 bytes on a 64 bit platform, it is wrong. Bye Shridhar -- Painting, n.: The art of protecting flat surfaces from the weather, and exposing them to the critic. -- Ambrose Bierce From pgsql-performance-owner@postgresql.org Mon Jan 20 10:16:47 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 63276476075 for ; Mon, 20 Jan 2003 10:16:45 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 710E1476021 for ; Mon, 20 Jan 2003 10:16:44 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0KFGl5u002996; Mon, 20 Jan 2003 10:16:47 -0500 (EST) To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: Very large caches (was Re: 7.3.1 New install, large queries are slow) In-reply-to: <1043055681.15592.156.camel@haggis> References: <3E2BE5DD.30158.D375D9A@localhost> <27220.1043046883@sss.pgh.pa.us> <1043055681.15592.156.camel@haggis> Comments: In-reply-to Ron Johnson message dated "20 Jan 2003 03:41:21 -0600" Date: Mon, 20 Jan 2003 10:16:47 -0500 Message-ID: <2995.1043075807@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/208 X-Sequence-Number: 855 Ron Johnson writes: > So if I have some honking "big" Compaq Xeon SMP server w/ 16GB RAM, > and top(1) shows that there is 8GB of buffers, then Pg will be happy > as a pig in the mud? Sounds good to me ... regards, tom lane From pgsql-performance-owner@postgresql.org Mon Jan 20 16:40:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E29F7476B7A for ; Mon, 20 Jan 2003 16:40:44 -0500 (EST) Received: from pos_pdc.posportal.com (unknown [12.158.169.100]) by postgresql.org (Postfix) with ESMTP id DDEAE476CDE for ; Mon, 20 Jan 2003 16:32:41 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Re: 7.3.1 New install, large queries are slow Date: Mon, 20 Jan 2003 13:32:42 -0800 Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0F@pos_pdc.posportal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] 7.3.1 New install, large queries are slow Thread-Index: AcK+xLE/Sv/ROSiNRa6IWzg15iBHMgB61ut7 From: "Roman Fail" To: =?utf-8?Q?Dennis_Bj=C3=B6rklund?= Cc: "Josh Berkus" , "Stephan Szabo" , , "Tom Lane" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/209 X-Sequence-Number: 856 Pj4gSXQgc29ydCBvZiBmZWVscyBsaWtlIGEgbWFnaWMgbW9tZW50LiAgSSB3 ZW50IGJhY2sgYW5kIGxvb2tlZCB0aHJvdWdoIGENCj4+IGxvdCBvZiB0aGUg Sk9JTiBjb2x1bW5zIGFuZCBmb3VuZCB0aGF0IEkgd2FzIG1peGluZyBpbnQ0 IHdpdGggaW50OCBpbiBhDQo+PiBsb3Qgb2YgdGhlbS4NCg0KPlRoZXJlIGlz IG5vdGUgYWJvdXQgaXQgaW4gdGhlIGRvY3M6DQo+aHR0cDovL3d3dy5wb3N0 Z3Jlc3FsLm9yZy9pZG9jcy9pbmRleC5waHA/ZGF0YXR5cGUuaHRtbCNEQVRB VFlQRS1JTlQNCj4NCj5JIGRvbid0IGtub3cgaWYgdGhpcyBpcyBpbiBhIGZh cSBhbnl3aGVyZSwgYnV0IGl0IHNob3VsZCBiZS4gSSBteXNlbGYgaGF2ZQ0K PmhlbHBlZCBhIG51bWJlciBvZiBwZXJzb25zIHdpdGggdGhpcy4gRXZlcnkg b25jZSBpbiBhIHdoaWxlIHRoZXJlIGNvbWUNCj5zb21lb25lIGluIHRvIHRo ZSAjcG9zdGdyZXNxbCBpcmMgY2hhbm5lbCB3aXRoIHRoZSBleGFjdCBzYW1l IHByb2JsZW0uIA0KPlVzdWFsbHkgdGhleSBsZWF2ZSB0aGUgY2hhbm5lbCB2 ZXJ5IGhhcHB5LCB3aGVuIHRoZWlyIHF1ZXJpZXMgdGFrZSBsZXNzDQo+dGhl biBhIHNlY29uZCBpbnN0ZWFkIG9mIG1pbnV0ZXMuDQo+DQo+LS0NCj4vRGVu bmlzDQoNCkknbSByZWFsbHkgc3VycHJpc2VkIHRoYXQgdGhpcyBpc3N1ZSBk b2Vzbid0IHBvcCB1cCBhbGwgdGhlIHRpbWUuICBBcyB0aGUgY29tbXVuaXR5 IGdyb3dzLCBJIHRoaW5rIGl0IHdpbGwgc3RhcnQgdG8uICBJIGNhbWUgdmVy eSwgdmVyeSBjbG9zZSB0byBkcm9wcGluZyBQb3N0Z3JlU1FMIGVudGlyZWx5 IGJlY2F1c2Ugb2YgaXQuICBIb3BlZnVsbHkgdGhlIFRPRE8gaXNzdWUgb24g aW1wbGljaXQgdHlwZSBjYXN0aW5nIHdpbGwgbW92ZSBjbG9zZXIgdG8gdGhl IHRvcCBvZiB0aGUgaGFja2VycyBsaXN0LiAgQnV0IEknbSBqdXN0IGEgYmVn Z2FyIHNvIEkgd29uJ3QgcHJldGVuZCB0byBiZSBhIGNob29zZXIuDQogDQpC YWNrIHRvIG15IG9yaWdpbmFsIHByb2JsZW1zOiAgSSByZS1jcmVhdGVkIGV2 ZXJ5dGhpbmcgZnJvbSBzY3JhdGNoIGFuZCBtYWRlIHN1cmUgdGhlcmUgYXJl IG5vIGludDgncyBpbiBteSBlbnRpcmUgZGF0YWJhc2UuICAgSSBmb3VuZCBh IGZldyBtb3JlIHBsYWNlcyB0aGF0IEkgY291bGQgY3JlYXRlIHVzZWZ1bCBp bmRleGVzIGFzIHdlbGwuICBJIGRpZG4ndCBnZXQgdG8gdGVzdCBpdCBvdmVy IHRoZSB3ZWVrZW5kLCBidXQgdG9kYXkgSSBwbGF5ZWQgd2l0aCBpdCBmb3Ig c2V2ZXJhbCBob3VycyBhbmQgY291bGQgbm90IGdldCB0aGUgcXVlcmllcyB0 byBwZXJmb3JtIG11Y2ggYmV0dGVyIHRoYW4gbGFzdCB3ZWVrLiAgSSB3YXMg YWJvdXQgcmVhZHkgdG8gZ2l2ZSB1cCwgdGhyb3cgUG9zdGdyZXMgaW4gdGhl IGp1bmsgcGlsZSwgYW5kIGdldCBvdXQgdGhlIE1TU1FMIENELiAgDQogDQpM dWNraWx5LCBhbiB1bnJlbGF0ZWQgcG9zdCBvbiBvbmUgb2YgdGhlIGxpc3Rz IG1lbnRpb25lZCBzb21ldGhpbmcgYWJvdXQgQU5BTFlaRSwgYW5kIEkgcmVh bGl6ZWQgdGhhdCBJIGhhZCBmb3Jnb3R0ZW4gdG8gcnVuIGl0IGFmdGVyIGFs bCB0aGUgbmV3IGRhdGEgd2FzIGltcG9ydGVkIChhbHRob3VnaCBJIGRpZCBy ZW1lbWJlciBhIFZBQ1VVTSBGVUxMKS4gIEFmdGVyIHJ1bm5pbmcgQU5BTFla RSwgSSBzdGFydGVkIGdldHRpbmcgYW1hemluZyByZXN1bHRzLi4uLi5saWtl IGEgcXVlcnkgdGhhdCB0b29rIDIwIG1pbnV0ZXMgbGFzdCB3ZWVrIHdhcyB0 YWtpbmcgb25seSA2IG1pbGxpc2Vjb25kcyBub3cuICBUaGF0IGtpY2tzIHRo ZSBNU1NRTCBzZXJ2ZXIncyBhc3MgYWxsIG92ZXIgdGhlIG1hcCAoYXMgSSBo YWQgb3JpZ2luYWxseSBleHBlY3RlZCBpdCB3b3VsZCEhISkuDQogDQpTbyB0 aGluZ3MgYXJlIHdvcmtpbmcgcHJldHR5IGdvb2Qgbm93Li4uLmFuZCBpdCBs b29rcyBsaWtlIHRoZSB3aG9sZSBwcm9ibGVtIHdhcyB0aGUgZGF0YSB0eXBl IG1pc21hdGNoIGlzc3VlLiAgSSBoYXRlIHRvIHBvaW50IGZpbmdlcnMsIGJ1 dCB0aGUgcGdBZG1pbklJIE1pZ3JhdGlvbiBXaXphcmQgZm9yY2VzIGFsbCB5 b3VyIHByaW1hcnkga2V5cyB0byBiZSBpbnQ4IGV2ZW4gaWYgeW91IHNldCB0 aGUgVHlwZSBNYXAgdG8gaW50NC4gIFRoZSBzZWNvbmQgdGltZSB0aHJvdWdo IEkgcmVjb2duaXplZCB0aGlzIGFuZCBkaWQgYSBwZ19kdW1wIHNvIEkgY291 bGQgc3dpdGNoIGV2ZXJ5dGhpbmcgdG8gaW50NC4gIE5vdyBJJ20gZ29pbmcg dG8gd3JpdGUgc29tZSBtaW5vciBtb2RzIGluIG15IEphdmEgcHJvZ3JhbXMg Zm9yIFBHU1FMLXN5bnRheCBjb21wYXRpYmlsaXR5LCBhbmQgd2lsbCBob3Bl ZnVsbHkgaGF2ZSB0aGUgUG9zdGdyZVNRTCBzZXJ2ZXIgaW4gcHJvZHVjdGlv biBzaG9ydGx5LiAgDQogDQpUSEFOSyBZT1UgdG8gZXZlcnlvbmUgb24gcGdz cWwtcGVyZm9ybWFuY2UgZm9yIGFsbCB5b3VyIGhlbHAuICBZb3UgYXJlIHRo ZSByZWFzb24gdGhhdCBJJ2xsIGJlIGEgbG9uZyB0ZXJtIG1lbWJlciBvZiB0 aGUgUG9zdGdyZXMgY29tbXVuaXR5LiAgSSBob3BlIHRoYXQgSSBjYW4gYXNz aXN0IHNvbWVvbmUgZWxzZSBvdXQgaW4gdGhlIGZ1dHVyZS4gIA0KIA0KUm9t YW4gRmFpbA0KU3IuIFdlYiBBcHBsaWNhdGlvbiBEZXZlbG9wZXINClBPUyBQ b3J0YWwsIEluYy4NCiANCiANCg== From pgsql-performance-owner@postgresql.org Mon Jan 20 17:15:20 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2AC854764B8 for ; Mon, 20 Jan 2003 17:15:19 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id B0F324765CB for ; Mon, 20 Jan 2003 17:14:41 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2320112; Mon, 20 Jan 2003 14:14:46 -0800 From: "Josh Berkus" Subject: Re: 7.3.1 New install, large queries are slow To: "Roman Fail" Cc: X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Mon, 20 Jan 2003 14:14:46 -0800 Message-ID: In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0F@pos_pdc.posportal.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/210 X-Sequence-Number: 857 Roman, > I'm really surprised that this issue doesn't pop up all the time. As > the community grows, I think it will start to. Actually, in the general sense of intelligent casting, the issue *does* come up all the time. Unfortunately, this is one of those issues that requires both an inspired solution and program-wide overhaul work to fix. In fact, in the FTP achives you can find an alternate version of Postgres (7.1 I think) where someone tried to fix the "stupid casting" issue and succeeded in making Postgres crash and burn instead. > Luckily, an unrelated post on one of the lists mentioned something > about ANALYZE, and I realized that I had forgotten to run it after > all the new data was imported (although I did remember a VACUUM > FULL). After running ANALYZE, I started getting amazing > results.....like a query that took 20 minutes last week was taking > only 6 milliseconds now. That kicks the MSSQL server's ass all over > the map (as I had originally expected it would!!!). That's great! > So things are working pretty good now....and it looks like the whole > problem was the data type mismatch issue. I hate to point fingers, > but the pgAdminII Migration Wizard forces all your primary keys to be > int8 even if you set the Type Map to int4. So? Send Dave Page (address at pgadmin.postgresql.org) a quick note documenting the problem. I'm sure he'll patch it, or at least fix it for PGAdmin III. > THANK YOU to everyone on pgsql-performance for all your help. You > are the reason that I'll be a long term member of the Postgres > community. I hope that I can assist someone else out in the future. You're welcome! If you can get your boss to authorize it, the Advocacy page (advocacy.postgresql.org) could use some more business testimonials. -Josh Berkus From pgsql-performance-owner@postgresql.org Mon Jan 20 17:33:50 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 373FE4764EB for ; Mon, 20 Jan 2003 17:33:49 -0500 (EST) Received: from pos_pdc.posportal.com (unknown [12.158.169.100]) by postgresql.org (Postfix) with ESMTP id BA6E54768AC for ; Mon, 20 Jan 2003 17:33:23 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Re: 7.3.1 New install, large queries are slow Date: Mon, 20 Jan 2003 14:33:25 -0800 Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C11@pos_pdc.posportal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] 7.3.1 New install, large queries are slow Thread-Index: AcLAzrojSfxhtVV6SFKZ2/vr+e/ZegAAziiJ From: "Roman Fail" To: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/211 X-Sequence-Number: 858 PiBKb2NoZW0gdmFuIERpZXRlbiB3cm90ZToNCj4gSnVzdCBvdXQgb2YgY3Vy aW9zaXR5IGFuZCBmb3IgYXJjaGl2aW5nIHB1cnBvc2VzLCBjb3VsZCB5b3Ug cG9zdCB0aGUgbmV3DQo+IEVYUExBSU4gQU5BTFlaRSBvdXRwdXQgdG8gdGhl IGxpc3Q/DQoNClRvIHJlaXRlcmF0ZSwgdGhlIGJhdGNoZGV0YWlsIHRhYmxl IGlzIDI0IG1pbGxpb24gcm93cywgYmF0Y2hoZWFkZXIgaXMgMi43IG1pbGxp b24sIGFuZCBwdXJjMSBpcyAxIG1pbGxpb24uICBUaGUgcmVzdCBhcmUgMjAw MCByb3dzIG9yIGxlc3MuICBJIHRoaW5rIGhhdmluZyB0aGUgNi1kaXNrIFJB SUQtMTAgZGV2b3RlZCB0byAvdXNyL2xvY2FsL3Bnc3FsL2RhdGEgaGVscHMg b3V0IGEgbGl0dGxlIGhlcmUuICAgSSBkaWQgdHJ5IGNoYW5naW5nIHRoZSBX SEVSRSBjbGF1c2VzIHRvIHJhZGljYWxseSBkaWZmZXJlbnQgdmFsdWVzIGFu ZCBpdCB3YXMgc3RpbGwganVzdCBhcyBmYXN0LiAgVGhpcyBpcyB0aGUgb3Jp Z2luYWwgcXVlcnkgSSB3YXMgd29ya2luZyB3aXRoIChwbHVzIHN1Z2dlc3Rl ZCBtb2RpZmljYXRpb25zIGZyb20gdGhlIGxpc3QpOg0KDQpFWFBMQUlOIEFO QUxZWkUNClNFTEVDVCBzcy5iYXRjaGRhdGUsIHNzLmJhdGNoZGV0YWlsaWQs IHNzLmJhbmtubywgc3MudHJhbmRhdGUsIHNzLnRyYW5hbW91bnQsDQpzcy5z dWJtaXRpbnRlcmNoYW5nZSwgc3MuYXV0aGFtb3VudCwgc3MuYXV0aG5vLCBz cy5jYXJkdHlwZWlkLCBzcy5tY2Njb2RlLA0Kc3MubmFtZSBBUyBtZXJjaGFu dG5hbWUsIHNzLmNhcmR0eXBlLCBzcy5tZXJjaGlkLA0KcDEubG9jYWx0YXhh bW91bnQsIHAxLnByb2R1Y3RpZGVudGlmaWVyLCBkci5hdnNyZXNwb25zZSwN CmNyLmNoZWNrb3V0ZGF0ZSwgY3Iubm9zaG93aW5kaWNhdG9yLCBjay5jaGVj a2luZ2FjY3RubywNCmNrLmFiYXJvdXRpbmdubywgY2suY2hlY2tubw0KRlJP TQ0KICAoU0VMRUNUIGIuYmF0Y2hkYXRlLCBkLmJhdGNoZGV0YWlsaWQsIHQu YmFua25vLCBkLnRyYW5kYXRlLCBkLnRyYW5hbW91bnQsDQogICAgICAgZC5z dWJtaXRpbnRlcmNoYW5nZSwgZC5hdXRoYW1vdW50LCBkLmF1dGhubywgZC5j YXJkdHlwZWlkLCBkLm1jY2NvZGUsDQogICAgICAgbS5uYW1lLCBjLmNhcmR0 eXBlLCBtLm1lcmNoaWQNCiAgIEZST00gdHJhbmhlYWRlciB0LCBiYXRjaGhl YWRlciBiLCBtZXJjaGFudHMgbSwgY2FyZHR5cGUgYywgYmF0Y2hkZXRhaWwg ZA0KICAgV0hFUkUgdC50cmFuaGVhZGVyaWQ9Yi50cmFuaGVhZGVyaWQNCiAg IEFORCBtLm1lcmNoYW50aWQ9Yi5tZXJjaGFudGlkDQogICBBTkQgZC5iYXRj aGlkPWIuYmF0Y2hpZA0KICAgQU5EIGMuY2FyZHR5cGVpZD1kLmNhcmR0eXBl aWQNCiAgIEFORCB0LmNsaWVudGlkID0gNg0KICAgQU5EIGQudHJhbmFtb3Vu dCBCRVRXRUVOIDUwMC4wIEFORCA3MDAuMA0KICAgQU5EIGIuYmF0Y2hkYXRl ID4gJzIwMDItMTItMTUnDQogICBBTkQgbS5tZXJjaGlkID0gJzcwMTI1MjI2 NycpIHNzDQogIExFRlQgSk9JTiBwdXJjMSBwMSBvbiBwMS5iYXRjaGRldGFp bGlkPXNzLmJhdGNoZGV0YWlsaWQNCiAgTEVGVCBKT0lOIGRpcmVjdCBkciBP TiBkci5iYXRjaGRldGFpbGlkID0gc3MuYmF0Y2hkZXRhaWxpZA0KICBMRUZU IEpPSU4gY2FycmVudGFsIGNyIE9OIGNyLmJhdGNoZGV0YWlsaWQgPSBzcy5i YXRjaGRldGFpbGlkDQogIExFRlQgSk9JTiBjaGVja3MgY2sgT04gY2suYmF0 Y2hkZXRhaWxpZCA9IHNzLmJhdGNoZGV0YWlsaWQNCk9SREVSIEJZIHNzLmJh dGNoZGF0ZSBERVNDDQpMSU1JVCA1MA0KDQpMaW1pdCAgKGNvc3Q9MTM1MS45 My4uMTM1MS45MyByb3dzPTEgd2lkdGg9MjYxKSAoYWN0dWFsIHRpbWU9NS4z NC4uNS4zNiByb3dzPTggbG9vcHM9MSkNCiAgLT4gIFNvcnQgIChjb3N0PTEz NTEuOTMuLjEzNTEuOTMgcm93cz0xIHdpZHRoPTI2MSkgKGFjdHVhbCB0aW1l PTUuMzMuLjUuMzQgcm93cz04IGxvb3BzPTEpDQogICAgICAgIFNvcnQgS2V5 OiBiLmJhdGNoZGF0ZQ0KICAgICAgICAtPiAgTmVzdGVkIExvb3AgIChjb3N0 PTAuMDEuLjEzNTEuOTIgcm93cz0xIHdpZHRoPTI2MSkgKGFjdHVhbCB0aW1l PTEuNjEuLjUuMjQgcm93cz04IGxvb3BzPTEpDQogICAgICAgICAgICAgIC0+ ICBIYXNoIEpvaW4gIChjb3N0PTAuMDEuLjEzNDYuOTkgcm93cz0xIHdpZHRo PTIyMykgKGFjdHVhbCB0aW1lPTEuNTguLjUuMDYgcm93cz04IGxvb3BzPTEp DQogICAgICAgICAgICAgICAgICAgIEhhc2ggQ29uZDogKCJvdXRlciIuYmF0 Y2hkZXRhaWxpZCA9ICJpbm5lciIuYmF0Y2hkZXRhaWxpZCkNCiAgICAgICAg ICAgICAgICAgICAgLT4gIEhhc2ggSm9pbiAgKGNvc3Q9MC4wMC4uMTM0Ni45 OCByb3dzPTEgd2lkdGg9MjEwKSAoYWN0dWFsIHRpbWU9MS4yMS4uNC41OCBy b3dzPTggbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgSGFz aCBDb25kOiAoIm91dGVyIi5iYXRjaGRldGFpbGlkID0gImlubmVyIi5iYXRj aGRldGFpbGlkKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgTmVz dGVkIExvb3AgIChjb3N0PTAuMDAuLjEzNDYuOTcgcm93cz0xIHdpZHRoPTIw MSkgKGFjdHVhbCB0aW1lPTAuODIuLjQuMDUgcm93cz04IGxvb3BzPTEpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBOZXN0ZWQgTG9v cCAgKGNvc3Q9MC4wMC4uMTM0My44NCByb3dzPTEgd2lkdGg9MTgyKSAoYWN0 dWFsIHRpbWU9MC43OC4uMy44MiByb3dzPTggbG9vcHM9MSkNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgi aW5uZXIiLmNhcmR0eXBlaWQgPSAib3V0ZXIiLmNhcmR0eXBlaWQpDQogICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBOZXN0ZWQg TG9vcCAgKGNvc3Q9MC4wMC4uMTM0Mi42MiByb3dzPTEgd2lkdGg9MTcyKSAo YWN0dWFsIHRpbWU9MC43NC4uMy4zNSByb3dzPTggbG9vcHM9MSkNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIE5l c3RlZCBMb29wICAoY29zdD0wLjAwLi41MzkuMzIgcm93cz00IHdpZHRoPTEw NikgKGFjdHVhbCB0aW1lPTAuMTcuLjEuNjEgcm93cz0yNiBsb29wcz0xKQ0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAtPiAgTmVzdGVkIExvb3AgIChjb3N0PTAuMDAuLjUxNS40OCByb3dz PTUgd2lkdGg9OTQpIChhY3R1YWwgdGltZT0wLjEzLi4xLjAxIHJvd3M9MjYg bG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcgbWVy Y2hhbnRzX2l4X21lcmNoaWRfaWR4IG9uIG1lcmNoYW50cyBtICAoY29zdD0w LjAwLi41LjY1IHJvd3M9MSB3aWR0aD03OCkgKGFjdHVhbCB0aW1lPTAuMDcu LjAuMDggcm93cz0xIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEluZGV4 IENvbmQ6IChtZXJjaGlkID0gJzcwMTI1MjI2Nyc6OmNoYXJhY3RlciB2YXJ5 aW5nKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyBiYXRjaGhl YWRlcl9peF9tZXJjaGFudGlkX2lkeCBvbiBiYXRjaGhlYWRlciBiICAoY29z dD0wLjAwLi41MDguNTYgcm93cz0yMCB3aWR0aD0xNikgKGFjdHVhbCB0aW1l PTAuMDQuLjAuODEgcm93cz0yNiBsb29wcz0xKQ0KICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBJbmRleCBDb25kOiAoIm91dGVyIi5tZXJjaGFudGlkID0gYi5tZXJjaGFu dGlkKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBGaWx0ZXI6IChiYXRjaGRhdGUgPiAn MjAwMi0xMi0xNSc6OmRhdGUpDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5n IHRyYW5oZWFkZXJfcGtleSBvbiB0cmFuaGVhZGVyIHQgIChjb3N0PTAuMDAu LjUuMDggcm93cz0xIHdpZHRoPTEyKSAoYWN0dWFsIHRpbWU9MC4wMS4uMC4w MSByb3dzPTEgbG9vcHM9MjYpDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6ICh0 LnRyYW5oZWFkZXJpZCA9ICJvdXRlciIudHJhbmhlYWRlcmlkKQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICBGaWx0ZXI6IChjbGllbnRpZCA9IDYpDQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVz aW5nIGJhdGNoZGV0YWlsX2l4X2JhdGNoaWRfaWR4IG9uIGJhdGNoZGV0YWls IGQgIChjb3N0PTAuMDAuLjE4Ni44MSByb3dzPTIgd2lkdGg9NjYpIChhY3R1 YWwgdGltZT0wLjA1Li4wLjA2IHJvd3M9MCBsb29wcz0yNikNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5k ZXggQ29uZDogKGQuYmF0Y2hpZCA9ICJvdXRlciIuYmF0Y2hpZCkNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg RmlsdGVyOiAoKHRyYW5hbW91bnQgPj0gNTAwLjApIEFORCAodHJhbmFtb3Vu dCA8PSA3MDAuMCkpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIC0+ICBTZXEgU2NhbiBvbiBjYXJkdHlwZSBjICAoY29zdD0wLjAw Li4xLjEwIHJvd3M9MTAgd2lkdGg9MTApIChhY3R1YWwgdGltZT0wLjAwLi4w LjAzIHJvd3M9MTAgbG9vcHM9OCkNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcgcHVyYzFfaXhfYmF0Y2hk ZXRhaWxpZF9pZHggb24gcHVyYzEgcDEgIChjb3N0PTAuMDAuLjMuMTIgcm93 cz0xIHdpZHRoPTE5KSAoYWN0dWFsIHRpbWU9MC4wMS4uMC4wMSByb3dzPTAg bG9vcHM9OCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgSW5kZXggQ29uZDogKHAxLmJhdGNoZGV0YWlsaWQgPSAib3V0ZXIiLmJh dGNoZGV0YWlsaWQpDQogICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBI YXNoICAoY29zdD0wLjAwLi4wLjAwIHJvd3M9MSB3aWR0aD05KSAoYWN0dWFs IHRpbWU9MC4wMC4uMC4wMCByb3dzPTAgbG9vcHM9MSkNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIGRpcmVjdCBk ciAgKGNvc3Q9MC4wMC4uMC4wMCByb3dzPTEgd2lkdGg9OSkgKGFjdHVhbCB0 aW1lPTAuMDAuLjAuMDAgcm93cz0wIGxvb3BzPTEpDQogICAgICAgICAgICAg ICAgICAgIC0+ICBIYXNoICAoY29zdD0wLjAwLi4wLjAwIHJvd3M9MSB3aWR0 aD0xMykgKGFjdHVhbCB0aW1lPTAuMDEuLjAuMDEgcm93cz0wIGxvb3BzPTEp DQogICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBj YXJyZW50YWwgY3IgIChjb3N0PTAuMDAuLjAuMDAgcm93cz0xIHdpZHRoPTEz KSAoYWN0dWFsIHRpbWU9MC4wMC4uMC4wMCByb3dzPTAgbG9vcHM9MSkNCiAg ICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcgY2hlY2tzX2l4X2Jh dGNoZGV0YWlsaWRfaWR4IG9uIGNoZWNrcyBjayAgKGNvc3Q9MC4wMC4uNC45 MiByb3dzPTEgd2lkdGg9MzgpIChhY3R1YWwgdGltZT0wLjAxLi4wLjAxIHJv d3M9MCBsb29wcz04KQ0KICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25k OiAoY2suYmF0Y2hkZXRhaWxpZCA9ICJvdXRlciIuYmF0Y2hkZXRhaWxpZCkN ClRvdGFsIHJ1bnRpbWU6IDUuODkgbXNlYw0KDQoNCg== From pgsql-performance-owner@postgresql.org Mon Jan 20 18:39:47 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 38D9F4763A4 for ; Mon, 20 Jan 2003 18:39:46 -0500 (EST) Received: from water.oasis.net.au (water.oasis.net.au [210.8.139.2]) by postgresql.org (Postfix) with ESMTP id BBB33476198 for ; Mon, 20 Jan 2003 18:39:44 -0500 (EST) Received: from oasis.net.au (guardian [210.8.139.5]) by water.oasis.net.au (8.9.3/100.1) with ESMTP id KAA21377 for ; Tue, 21 Jan 2003 10:26:38 +1000 X-Authentication-Warning: water.oasis.net.au: Host guardian [210.8.139.5] claimed to be oasis.net.au Message-ID: <3E2C88DD.6090808@oasis.net.au> Date: Tue, 21 Jan 2003 09:40:13 +1000 From: Rudi Starcevic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: subscribe Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/212 X-Sequence-Number: 859 subscribe From pgsql-performance-owner@postgresql.org Tue Jan 21 03:21:14 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 45A04475DB3 for ; Tue, 21 Jan 2003 03:21:12 -0500 (EST) Received: from ore.jhcloos.com (ore.jhcloos.com [64.240.156.239]) by postgresql.org (Postfix) with ESMTP id 9B2A3475BEC for ; Tue, 21 Jan 2003 03:21:11 -0500 (EST) Received: from lugabout.jhcloos.org (ppp505.tc-1.buf-ch.ny.localnet.com [207.251.222.251]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "lugabout.jhcloos.org", Issuer "ca.jhcloos.com" (verified OK)) by ore.jhcloos.com (Postfix) with ESMTP id 3C8301C36B; Tue, 21 Jan 2003 02:21:11 -0600 (CST) Received: from lugabout.jhcloos.org (localhost [127.0.0.1]) by lugabout.jhcloos.org (Postfix on SuSE Linux 7.3 (i386)) with ESMTP id B8FBA3F16; Tue, 21 Jan 2003 08:21:03 +0000 (GMT) To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: x86-64 and PostgreSQL References: <3E2BE4BF.28150.D33005A@localhost> <3E2C15E6.9191.DF2FEFC@localhost> <1043064363.15592.187.camel@haggis> From: "James H. Cloos Jr." In-Reply-To: <1043064363.15592.187.camel@haggis> Date: 21 Jan 2003 03:21:03 -0500 Message-ID: Lines: 14 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/213 X-Sequence-Number: 860 >>>>> "Ron" == Ron Johnson writes: Ron> Also, since (at least on the gcc-3.2 compiler) a "long" and "int" Ron> are still 32 bits (64 bit scalars are of type "long long"), According to the draft x86-64 psABI�, which is to become the System V psABI for the x86-64 architecture, sizeof(long) == 8. This does seem necessary as most code tends to presume that an unsigned long can hold a pointer.... -JimC � http://www.x86-64.org/abi.pdf From pgsql-performance-owner@postgresql.org Tue Jan 21 16:21:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6FEA5475CE7 for ; Tue, 21 Jan 2003 16:21:00 -0500 (EST) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by postgresql.org (Postfix) with ESMTP id F09DF475425 for ; Tue, 21 Jan 2003 16:20:53 -0500 (EST) Received: (from mail@localhost) by martin.sysdetect.com (8.11.3/8.11.3) id h0LLKtH20808 for ; Tue, 21 Jan 2003 21:20:55 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdm26056; Tue Jan 21 21:20:49 2003 Received: from winwood.sysdetect.com (seth@localhost) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id h0LLKn820463 for ; Tue, 21 Jan 2003 16:20:49 -0500 Message-Id: <200301212120.h0LLKn820463@winwood.sysdetect.com> To: pgsql-performance@postgresql.org From: "Seth Robertson" Subject: Postgres 7.3.1 poor insert/update/search performance esp WRT Oracle MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <20460.1043184020.0@winwood.sysdetect.com> Date: Tue, 21 Jan 2003 16:20:49 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/214 X-Sequence-Number: 861 ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20460.1043184020.1@winwood.sysdetect.com> Content-Description: text I'm trying to get converted over to Postgres from Oracle (Postgres is billions of times more straightforward and pragmatically clean than Oracle), but I'm having some severe performance problems on what naively appears to be a very straightforward dead-simple test. The test is comprised of two parts: a write part which attempts to accumulate (sum) numbers by distinct keys, and a read part which searches for keys in the database (some of which will be present, some of which will not). In a more realistic scenario, both will be happening all of the time, but we can start off easy. However, performance is terrible: around 39 write transactions/second and 69 searches/second. Oracle, by comparison, writes at 314 and reads at 395--practically an order of magnitude better performance. Both are using the same hardware (obviously not at the same time) which is a dual-processor AMD 2000+ with 3GB memory and both oracle and postgres loaded on a 105GB ``MD'' striped (no redundancy) 2 SCSI disks running ext3 fs (no special flags) with Linux 2.4.18-10smp. I actually have seven different schemes for performing the writes using Postgres: ---------------------------------------------------------------------- "normal" C libpq 39 t/s "normal" Perl DBI 39 t/s "DBI Prepared Statement" Perl DBI 39 t/s "Batching" Perl DBI 45 t/s "arrays" Perl DBI 26 t/s "server-side function" Perl DBI 39 t/s "server-side trigger" Perl DBI 39 t/s "normal" Perl DBI read 69 t/s "normal" Perl DBI for Oracle 314 t/s "normal" Perl DBI read for Oracle 395 t/s ---------------------------------------------------------------------- Only batching had a statistically significant improvement, and it wasn't that major. I couldn't use true Postgres prepared statements since you cannot determine the success/failure of the statements yet. I was planning on using arrays as well, but the additional 33% performance impact is not amusing (though I suppose it is only an additional 3% if you consider the 87% performance drop of Postgres from Oracle). I'll include all methods in the attached file, but since there was no significant difference, I'll concentrate on the basic one: Example table: ---------------------------------------------------------------------- CREATE TABLE test ( val BIGINT PRIMARY KEY, # "vals" may be between 0 and 2^32-1 accum INTEGER ); ---------------------------------------------------------------------- Basic algorithm for writes ---------------------------------------------------------------------- while (<>) { chomp; @A = split; if (dosql($dbh, "UPDATE test SET accum = accum + $A[1] WHERE val = '$A[0]';",0) eq "0E0") { dosql($dbh, "INSERT INTO test VALUES ( $A[0], $A[1] );"); } } ---------------------------------------------------------------------- Basic algorithm for reads ---------------------------------------------------------------------- while (<>) { chomp; @A = split; $sth = querysql($dbh,"SELECT accum FROM test WHERE val = $A[0];"); $hit++ if ($sth && ($row = $sth->fetchrow_arrayref)); $tot++; } ---------------------------------------------------------------------- What could be simpler. In my randomly generated write data, I usually have about 18K inserts and 82K updates. In my randomly generated read data, I have 100K keys which will be found and 100K keys which will not be found. The postgresql.conf file is default (my sysadmin nuked all of my changes when he upgraded to 7.3.1--grr) and there are some shared memory configs: kernel.sem = 250 32000 100 128, kernel.shmmax = 2147483648, kernel.shmmni = 100, kernel.shmmax = 134217728 The WAL is not seperated (but see below). A "vacuum analyze" is performed between the write phase and the read phase. However, for your analysis pleasure, here are the results of a full verbose analyze and some explain results (both before and after). /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ seth=> explain update test set accum = accum + 53 where val = '5'; QUERY PLAN ----------------------------------------------------- Seq Scan on test (cost=0.00..0.00 rows=1 width=18) Filter: (val = 5::bigint) (2 rows) seth=> explain insert into test values (5, 53); QUERY PLAN ------------------------------------------ Result (cost=0.00..0.01 rows=1 width=0) (1 row) seth=> vacuum full verbose analyze test; INFO: --Relation public.test-- INFO: Pages 541: Changed 2, reaped 540, Empty 0, New 0; Tup 18153: Vac 81847, Keep/VTL 0/0, UnUsed 0, MinLen 40, MaxLen 40; Re-using: Free/Avail. Space 3294932/3294932; EndEmpty/Avail. Pages 0/541. CPU 0.00s/0.03u sec elapsed 0.02 sec. INFO: Index test_pkey: Pages 355; Tuples 18153: Deleted 81847. CPU 0.03s/0.34u sec elapsed 0.65 sec. INFO: Rel test: Pages: 541 --> 99; Tuple(s) moved: 18123. CPU 1.01s/0.31u sec elapsed 9.65 sec. INFO: Index test_pkey: Pages 355; Tuples 18153: Deleted 18123. CPU 0.02s/0.06u sec elapsed 0.19 sec. INFO: Analyzing public.test VACUUM seth=> explain select accum from test where val = 5; QUERY PLAN ---------------------------------------------------------------------- Index Scan using test_pkey on test (cost=0.00..5.99 rows=1 width=4) Index Cond: (val = 5) (2 rows) seth=> explain update test set accum = accum + 53 where val = '5'; QUERY PLAN ----------------------------------------------------------------------- Index Scan using test_pkey on test (cost=0.00..5.99 rows=1 width=18) Index Cond: (val = 5::bigint) (2 rows) seth=> explain insert into test values (5, 53); QUERY PLAN ------------------------------------------ Result (cost=0.00..0.01 rows=1 width=0) (1 row) /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ I certainly understand that using an index scan might well speed things up WRT the update policy, but considering the search performance is post-analyze (pre-analyze it is even more deadly slow), I am dubious that doing it during the updates will get me within striking distance of Oracle since read performance has got to be better than write performance, right?. This is also why I am dubious that moving the WAL to another filesystem or futzing with the fsync policy will do anything. I will include below a compressed tarball of the programs I used (and the corresponding RUNME script) in case you wish to play along at home. I don't claim they are pretty, BTW :-) -Seth Robertson ------- =_aaaaaaaaaa0 Content-Type: application/tar; name="perftest.tar.gz" Content-ID: <20460.1043184020.2@winwood.sysdetect.com> Content-Transfer-Encoding: base64 H4sIALO4LT4AA+09a3vaxtL9Wv2KCSYFbDAX2/H7GNsNwYrjpwQ7gJv0TV1X oAXUgkR08eWkPr/9zOyuQOJinNR2knYnMUir3ZnZmdXszGhXjJjb9Znn5797 OCgUNgvbW1v4XShsbz+j72Jxs8TPJXxX2H5W3NjY2Cxt4fVisbSx+R1sPSBP Ywg833ABvvOY37+tnskuHoOdx4ZRqP/Gab2lN1sPQaNQLNymfyyK6L9A+i9t bBS+g8JDMDMN/3L9rzzJty077/W1FW0F9CtjOBowGLlOzzWG4DvgBjYYgwHQ IPGwkoaCghzTsPa7d++gqtebxw3tuFGp1vTzV8ev9b08tv4j77hGZ8A0djVy XB8i17WTSuvV3vpOkr7DE9Fm5Hh+z2UesbQTRcMLRIP66euf9WrruNHcK/Lh o50039TOq8f1OhY3W42j+uFeIteHrhtYZmLR1UvHNpmLlw9nLubMdh8ZGSNY XCNEgr2bV8c2hmyPYwE6DTzm7nUdh5+MDM/baxtLGgsCk9bGZZv0MMEgCxIa 9vKkdtqcxoTk8kjluezLgloSS15+Pw/7FVOxxjp9Bw6ZzVzDZ5CcKAJcwzad IVj2KPDhgnV8x/U0wpTrYfULZvvro0GsxT7k/eEof7Vu2VDal8dO4Gva1d7v OGbcWO3UagpKvwsGEpIDy+5B8ooPSzqUVCEdbWcGIy+T0NIdw5/QK8OtnCE3 eKvn7WAwyMBfvGsDy2aQMyZMe8xwO30hkckHJJpoSjg3nsVvI8tGpfn5YGSS xIZoYRwTCwGN7iAh2wBUB4iOWmEto214LKGNvA/I1ezQhVxXcI/Xx+1P0IQ7 7pAwCIIJzbeGTFRsXxMx3snpgTwRyTxUxAxK1bW6ForPcuyE0KgZDEfz0Y3F Y3T8wBhoptXtwkS18aso2j4zzHmUXSznzEObYRkDwzYG1/9h0W71mD/R3qKO STXdSsLA2c+dUFgs+A4kLoxOEAzDyuXP5edvDRsIPKp58OIIjTQbGS4zAWcw nw2R+mRMpX9hXhYsH0yHeXaKvpHva78vRgn2Wd43KBEIzS5cMz/z6OMylws7 0ra+0kF6HxprG36HpP8F5MtJ/4NFa7iuce19AcFywvct2MVo71nAd5AsVkBO c55lMugGdkew+yhy9vvB1z1z/S3BorxwbPuu1euRo/XYEs3lJOlvTrZLrEI1 P7Daow/3J9GqMxxZA0IgY6KE1ulA7rgEuaN84Ll5y+4MApPlRz1CCzknNBOd 8cE6NhiMPuBHx70e+Xe1Mx3YjXjJK9B0XPc6C33DNTuOifM+xSDfopKOeUx3 q45QlqNB4EFybsQCz0M9rWN8SGIKXfa7yRYbcTnMhF6fN/gR3Vi0syjv3S2e 6knM9VzYo9D3nI7/x/mfMNB5gBzDkvxPcevZ9nT+Z3trW+V/HgNk/ocmhi1K AeG/wGMY5vvOyN/ZafpmWdOG1+nkqYcjLQN7kOBHO5As7MD7nNUzzmC3aw3Y /vr6+q92oqz1eFsvnepZRgpj6L/AtBgIBGXN6mKMvlJpHP6M920howF8xD+A UeD108+pPJvIJTJlLLzRRG3Edm5lNKpHnHiMmfz6CI2GD4kTNB/IMqOoBugi UEzTd7GQ8wPAmyDru83WwVF9n4rw/hqOIrjCKj1m9w3kRFwBTp9fevJfyP/2 q7mWzEdpN+mS5YnmkppHt5IoKWs3Ght4jPMuy5NUqFFga5BXjgR4r0X/OL0u sA9AQuCCEeIBWH25t+r5pmWXecENfnLU0TrU/IkzYnb6ZTbZzWS07z9q3wNc Gq4Niaph244v7Eiyiwp8whnG6za78vHgZoz4OVkCjyT2Ukhr4Hgs/ZL3HP9f 9lHfpEZRbX9PKHLCxxDdV5412QNvNLA6LM1rZin0THMxhI3XiplMFoqZsmwp 5Mobh0UDA+P0wB4wz5ODwciEMkBJal7QnqgtMkx8l4br8/NyWBAMs8mO7WeT A2b3/D5HgnpIy/M98SValqnmrrzCT9bW4n0kfIiff63Cxjas4bgz08gNtudI BDXs4ERjVJv0/6Vv+zGM7f/EWbl3GmT/n21uLrL/m4WN4pT93yiWVP7/UWBF +q+wS7bFWe/va7EidKeny8hVi5UluM+d67L1fkLTVkzWpVv/1XGzVa+81iER ppPRnOO9bbJ20MMbp1CW5w76cemTw45j27BqtvtZNM6oklUsxjtnaRV+w58c uswLBj6s4jfdbtTMpntNGlVOVdzAXW5jumnsHXPdbOKph3YwK6jJ2k/SLjd/ J2/YFeukOUWqwGezkzeCFrq7fuBRzQw8wbqHDZ381NevK/WD8+OfJlPbNMGq EwxMIFtM2AP0jX9/6qV24KmXfmpmJDNZQUcSmUMzk51XKEyN0XZcPx1OokCS wN4YvmMhps7QbAXon0daYCH54LyAC8FlfuDaaWyX4dMViXNoWHaaDgy31wk1 gMcX78+EEnhJO+i+LxU2/++sHJZgZyYlESUiR/XTWm1cb5WejdAM7DP7Ip04 0F+cHiYiOsHLUoGOs5coJPiVcDTxvlENUcqxn7zBm9ps15weMh4Oxywnevtn hChiysRFSjP5peV3+ihKT0ieKoXq7pAvIl3wo+M6DoSduYPg5A2I1vDUhOOf SOtxfEKTbZyu/yzPwfuicnAHxFjrkzE3W5VGS78Ldlnzkym8rhzod0BP1T4Z d+Vt5aiFgc853o0nx/XmXQiFVT+d2Gnr1d00TDU/Q8tNvaXXf76LKnjFpfjR NhtoMe6A8EB/WTmttZZi5PZFOoRdvHe9NFoAtJbWf5jTpWN077jbmpkYxOAc 6W6UztGUmKaLd2p6XJLBG3kw4O0EobEhpxNhJ0Y+b4MzUafvcnIpwEBjjbuR vF7E3o3ImROlnh12GM2rZJCsejZxenJQaeniiRBKEoxOR2Dg32skj7ev9IYO Fxii78HToJzIEpEs70DIKU0zfKai+YIQY4RTjDuNi1k4wvHXaMFRvXUs+Pi5 UjvVm5B+GmSRfoYoEjFOd+wu30aTqH4fmQlCH1R83nCzjzO1hW4zKZaqsCvL TxcyX5WHquAhYdr/lxnie6WxbP3PZnHa/98sbBaV//8YsPKEZ7HDHNBU+qfm 2L0yLzl4cYRWVGSCmpVDfTYTZJ7hR7hwJczkyjK+eIU+6KIs4+tX6OMSw2ZZ RhntPfqI1PM6fTY09sTXuJw/0+RHk6fH0VN+zB+kncEuN+M0wMc5KuzH0+MT mmKbaO2i3d3ZqTp21+oFLksn2gFPivbQ9iZs59zq2Y7LzmmSliVG4ONHG2fD C1kisl/nHWc4Mnwqc9mHwMJW2EsMggS14xGlj730ryETWUhxT/Yvcy1Fx0KK njjm0pPHXGrymEtLHodSojMuGzqYiCZyRodcMNHcHKmUJ/og/dz0bJoxRUIO T7IJyU5SMvtR8pe6ScgM2cwFRBBpzxmNVqKCua3FhXhrWkAWa00Fc1uLC/HW jhB1DIEsm4tjfC2OxvevYyjwfG5zXo5NVyJtw4EfQ0CFczGIC1MowvskLgcs nC8HfiEjFJoUwRDewLl9ir1Yx0+jRq2dk95OYv0PB2OjBDoXXO1ZmOUkXiZQ Z+EjVHDoV53h0PJhbx+KWWgYlsd013VcKihgAEuuTrTgLeUh6RBuYDL4kLOd HXRA0Z8jExPvjBjLNyLApK7k9tsM47lzlMaf5KfEq0dG/E2YCoSkH4woU8db yxrpD78tc/p+jPl8P5Z/y5RDfJY9B98CDy79YxZ+zMjW0lHe3Z84wzwTLfyz 5xWZMPWlx8o7h9zn9mWmIJ2svC+eoUoq7wtnGZ4nLuiFqUwx8RdrURAtimeh 0MsRN5BnqOdKMRQhaSlx4DCP5yxI8LRSKJc7CdcNdcLMMiUNQGZinG6Y3uBZ ceGlJnkq5cNvJw39pNIQwhfPB9Mvjg5RdFmSn36oNzJQacIyFSVLMR0li1LM i4mJh4FziS3SXxLHdrL0NzQY5Sahv9Orp9inpV0jfcV6l+KaTOG9Wlik+Ril hREFRIcEYGSRWTIexHQhR8PfFUCk42Khy7j370tnoQDo8CFkIChOCyL1sZgV N9ZGdvMmNV8k7L57/7Wpfanh7XBrT0ZXnJuWF04oY2ueOJCeHzBu+BProu7E vmsr9wLaChwNR3wl8AWD5psaEHuGbdIidXokJIWSLI+fCYEQUZJi72R3YPS8 8AGRFj54arYO9EYDEohvn+qhszg9u5KbxidXMRe4F+Vx0hhPxvOC6aSTPGUc ecQ5TeLJLrbY343LaD0RK8HT25kIk7WAvirryieI1Dn4YfxcjWtGPv8Lc868 f7s7ME1dPsW8mSsUYvg2dmiskERu7lXRDWZ0Fqn5Q8Dc60fRtOf3I6rGsxkf 4A4KRynPKvx+FSy5uZOCF4xg7NzYgfiMAfyFBuxnjFeQav3X5rvi+R+5jOme aSzJ/2wVNp5NP//dKpZU/ucx4FvN/4jUzj8/l6MyNSpT85VmasY+0S3BonST Jk4auWWJpl7Tqy2Kb7LjaO9l4/h1JEQ7buAcDi9+oUo89IktpbsV7eoE13w0 3OlxLstauI4NT8ZeT5dh3IMF55wPl3VFR+R6P6qa28cwCuRRUdgg8ndVUKSC IhUUqaBIBUUKvhmIx3+RTfH3SGPZ/o/iTPy3uYHVVfz3CDAb/61M3vHAnbNg wPc6AR8YHro5Q+MKzaF4+UY5PE3SHgbyi7hRCU/QgaT5jy+yv9orlJNXu1Qf v2k1PdnPFfQ9WZe5YLNLSQIMH7oWmrEs9GhnlTEYXIPXt7p8b5nvkC3HFmLH WEDbC4hXyZ6w2XyLwf4e7TKo5eljrYTMRmehpFgiNt6PUFpd3ShlQpMpN1bE qiZr76O7F2p8vVnmLGyyAgcOzRzOpU1ycwJ7vL9eOH0Y1HX+xCKsa5hmOhmu rR3vBCEyaY/elvIRkgbsovudbJfRAX9ei/qgoSHn9ZOvPtL3zdgJ5dM/xz/Z CUGUJjM9dwTQHc5Eu7+F0lkrCk+AxzK1rGjGZ8CQipgb5AmsoUzIrZ64D5In LJT8fOnRrWAZTNt///Ht/1ZxY3r/3+bGttr/8Sgwx/5r30gKcP4SsH94SlBl AlUm8KvLBGqRVRFiI5BcETG1HkImDBZm7sQiiEn2Lra2hxYvlOV+oHEGTy6R IqQ//LA0kyfcv5VJ1J7gWGGc1ZNRMzo5fctfW5PHviOPY67hLJrcpHmkyd9Z LRGiR24gz7GSzV1PU0GeTjMy0lcJRJVA/FRFqwSiSiCqBOK/HOLxn3gxzn3T WBr/Fbam139slDZU/PcY8K2u/1D7fxavGVH7f1QseYdYUryGbWeOVr+GkPIL LrW/75X28YX2apmIivJUlKeiPBXlKfjyMBP/PcAWgCXx3+azjen4b7Ok3v/2 OPAtxn//8AhOhWUqLPtaw7KxL/dZK/DFAny1/F7FVSquUnGViqu+grhqxv9/ gCWAS5//bE77/1uFbfX+t0cBtf5PBQcqOFDBwTe1DFCtAlSrAFUccz+KVnGM imP+AXGMgs+DePyHg+ABaCz5/Z+N7e3p+K+0vaF+/+1R4KBxfAKtyouaXChT rTSrlQOMK6oNnVbPRC6lNe6DiVenwknj6HWl8Qv8pP+S1aTLJt+mquHNP4VX vNRlMXJx/c4U3p/NoXEe/qbpYjLjKjFKC/l/eVrnP8Mh2vJf+Jx5c+yYyl0q Q0NvnTbqzbCAXjubOtCrNXo9rUUcVWpHWPbyuEEvswVL8BUpLJXhhY5Il74/ VjaN+s5EoAxHLxHTaf0AWq/0umQIkJZea+qL3oELaWqblUgzWBnbH70sR5vX D1JQq9QPTzEshdRowCWQQq9gkSi5MtALnlbXLVVD8bUaR4eh+O4mjrr+dn1W IlS6WCj814mWyEViyE4IzEpH4lkooHCYyk5NdRtH6wsddT9mIpSMHMt8Tqex oVeqr6Bx/BbCVwyfNI6r+sGpfPNxTJJI9edK9fT0NVTqldov/68DRQ/5VW1l WgnJj83qK/115Wbdu/bM8y4z0L9gaC0tM93S37UmSqGflSduSSkykpvUPrdM EdEtxCcVE2lyNRycD80t8WLniOzQ9yhTomqaVTYcnaMpGY5gwVAR0RofMOKQ IJeDKm3NB79v+ISDAmqgTfGeMTDcayB/r4cesj1pg8OF9B1WPmqSivnYmdQh aFSOcPDo76o6d48glQqbyFdmtxkfHTQcA5bCwTBuLsfQDE3J1CeQfBoS6xsX kpxAkkplo92YRzwmprd9h7/92+NvNQg8uOwzG7w+gyHOojBCC04XLP/HRVzv QuEzWDbAZj0Ri34e4w02ZMM2Ds1L7EGnb9g9ZqK6GbHsOoMB78ikBaGmH508 579bvLOHDNnOZUw74yqUaKEqncB1mS3OI/VCC6C/lYXIIB7NNwSTIR0O2smI njIBjdDgiWEvcC8xAmNkdPuvaKt58stn/D/6ReV79jGW+H/o7s38/uPmtnr/ y6PAlA91i98XuixLHL8v3SEFnwTx+9/vBw/wA1BL3/9bnHn/U6n0TN3/jwHf 4vo/KpfO779vc5fsuHoQ+O9+EPhtvwgk3udwSN9MsuG37rMaZ3Fu/2WTmRe5 kTz/COw/Zx48QvjkMZK6if9sEkaPlXrzrd4Y41YbudSDOvWgTj2oUw/qFChQ oECBAgUKFChQoECBAgUKFChQoECBAgUKFChQoECBAgUKFChQoECBAgUKFChQ 8EjwP+/zYX4AyAAA ------- =_aaaaaaaaaa0-- From pgsql-performance-owner@postgresql.org Tue Jan 21 16:46:18 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3E8E3475BD7 for ; Tue, 21 Jan 2003 16:46:16 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id C57F1475425 for ; Tue, 21 Jan 2003 16:46:15 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 1FAA2D605; Tue, 21 Jan 2003 13:46:17 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 114DB5C04; Tue, 21 Jan 2003 13:46:17 -0800 (PST) Date: Tue, 21 Jan 2003 13:46:17 -0800 (PST) From: Stephan Szabo To: Seth Robertson Cc: Subject: Re: Postgres 7.3.1 poor insert/update/search performance In-Reply-To: <200301212120.h0LLKn820463@winwood.sysdetect.com> Message-ID: <20030121134242.Q84028-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/215 X-Sequence-Number: 862 On Tue, 21 Jan 2003, Seth Robertson wrote: > The postgresql.conf file is default (my sysadmin nuked all of my > changes when he upgraded to 7.3.1--grr) and there are some shared > memory configs: kernel.sem = 250 32000 100 128, kernel.shmmax = > 2147483648, kernel.shmmni = 100, kernel.shmmax = 134217728 The > WAL is not seperated (but see below). You almost certainly want to raise shared_buffers from the default (64?) to say 1k-10k. I'm not sure how much that'll help but it should help some. > A "vacuum analyze" is performed between the write phase and the read > phase. However, for your analysis pleasure, here are the results > of a full verbose analyze and some explain results (both before and after). BTW: what does explain analyze (rather than plain explain) show? From pgsql-performance-owner@postgresql.org Tue Jan 21 17:09:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5D38E4762DE for ; Tue, 21 Jan 2003 17:09:51 -0500 (EST) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by postgresql.org (Postfix) with ESMTP id 25952475CE7 for ; Tue, 21 Jan 2003 17:07:25 -0500 (EST) Received: (from mail@localhost) by martin.sysdetect.com (8.11.3/8.11.3) id h0LM7IR12412; Tue, 21 Jan 2003 22:07:18 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdx15237; Tue Jan 21 22:07:15 2003 Received: from winwood.sysdetect.com (seth@localhost) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id h0LM7Dt21080; Tue, 21 Jan 2003 17:07:13 -0500 Message-Id: <200301212207.h0LM7Dt21080@winwood.sysdetect.com> To: pgsql-performance@postgresql.org Cc: Stephan Szabo From: Seth Robertson Subject: Re: Postgres 7.3.1 poor insert/update/search performance In-reply-to: <20030121134242.Q84028-100000@megazone23.bigpanda.com> References: <200301212120.h0LLKn820463> <20030121134242.Q84028-100000@megazone23.bigpanda.com> Comments: In reply to a message from "Stephan Szabo " dated "Tue, 21 Jan 2003 13:46:17 -0800." Date: Tue, 21 Jan 2003 17:07:13 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/216 X-Sequence-Number: 863 In message <20030121134242.Q84028-100000@megazone23.bigpanda.com>, Stephan Szabo writes: On Tue, 21 Jan 2003, Seth Robertson wrote: > The postgresql.conf file is default (my sysadmin nuked all of my > changes when he upgraded to 7.3.1--grr) and there are some shared > memory configs: kernel.sem = 250 32000 100 128, kernel.shmmax = > 2147483648, kernel.shmmni = 100, kernel.shmmax = 134217728 The > WAL is not seperated (but see below). You almost certainly want to raise shared_buffers from the default (64?) to say 1k-10k. I'm not sure how much that'll help but it should help some. I'll try that and report back later, but I was under the (false?) impression that it was primarily important when you had multiple database connections using the same table. > A "vacuum analyze" is performed between the write phase and the > read phase. However, for your analysis pleasure, here are the > results of a full verbose analyze and some explain results (both > before and after). BTW: what does explain analyze (rather than plain explain) show? /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ seth=> explain analyze select accum from test where val = 5; QUERY PLAN ---------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..0.00 rows=1 width=4) (actual time=94.55..94.55 rows=0 loops=1) Filter: (val = 5) Total runtime: 99.20 msec (3 rows) seth=> explain analyze update test set accum = accum + 53 where val = '5'; QUERY PLAN ----------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..0.00 rows=1 width=18) (actual time=31.95..31.95 rows=0 loops=1) Filter: (val = 5::bigint) Total runtime: 32.04 msec (3 rows) seth=> explain analyze insert into test values (5, 53); QUERY PLAN ---------------------------------------------------------------------------------- Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.01..0.01 rows=1 loops=1) Total runtime: 7.50 msec (2 rows) seth=> vacuum full verbose analyze test seth-> ; INFO: --Relation public.test-- INFO: Pages 541: Changed 1, reaped 539, Empty 0, New 0; Tup 18071: Vac 81930, Keep/VTL 0/0, UnUsed 0, MinLen 40, MaxLen 40; Re-using: Free/Avail. Space 3298208/3298176; EndEmpty/Avail. Pages 0/540. CPU 0.03s/0.00u sec elapsed 0.02 sec. INFO: Index test_pkey: Pages 355; Tuples 18071: Deleted 81930. CPU 0.04s/0.41u sec elapsed 1.96 sec. INFO: Rel test: Pages: 541 --> 98; Tuple(s) moved: 18046. CPU 0.95s/0.42u sec elapsed 12.74 sec. INFO: Index test_pkey: Pages 355; Tuples 18071: Deleted 18046. CPU 0.02s/0.05u sec elapsed 0.31 sec. INFO: Analyzing public.test VACUUM seth=> explain analyze select accum from test where val = 5; QUERY PLAN ----------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..323.89 rows=1 width=4) (actual time=0.13..14.20 rows=1 loops=1) Filter: (val = 5) Total runtime: 14.26 msec (3 rows) seth=> explain analyze select accum from test where val = 2147483648; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Index Scan using test_pkey on test (cost=0.00..5.99 rows=1 width=4) (actual time=0.11..0.11 rows=0 loops=1) Index Cond: (val = 2147483648::bigint) Total runtime: 0.16 msec (3 rows) seth=> explain analyze update test set accum = accum + 53 where val = '5'; QUERY PLAN --------------------------------------------------------------------------------------------------------------- Index Scan using test_pkey on test (cost=0.00..5.99 rows=1 width=18) (actual time=0.24..0.24 rows=1 loops=1) Index Cond: (val = 5::bigint) Total runtime: 0.39 msec (3 rows) seth=> explain analyze insert into test values (6, 53); QUERY PLAN ---------------------------------------------------------------------------------- Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.01..0.01 rows=1 loops=1) Total runtime: 0.08 msec (2 rows) seth=> explain analyze insert into test values (2147483647, 53); QUERY PLAN ---------------------------------------------------------------------------------- Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.01..0.01 rows=1 loops=1) Total runtime: 0.33 msec (2 rows) /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ -Seth Robertson From pgsql-performance-owner@postgresql.org Tue Jan 21 17:33:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8BC6D4767CB for ; Tue, 21 Jan 2003 17:33:36 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 90559476B91 for ; Tue, 21 Jan 2003 17:31:34 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0LMVZ5u013166; Tue, 21 Jan 2003 17:31:35 -0500 (EST) To: Seth Robertson Cc: pgsql-performance@postgresql.org, Stephan Szabo Subject: Re: Postgres 7.3.1 poor insert/update/search performance In-reply-to: <200301212207.h0LM7Dt21080@winwood.sysdetect.com> References: <200301212120.h0LLKn820463> <20030121134242.Q84028-100000@megazone23.bigpanda.com> <200301212207.h0LM7Dt21080@winwood.sysdetect.com> Comments: In-reply-to Seth Robertson message dated "Tue, 21 Jan 2003 17:07:13 -0500" Date: Tue, 21 Jan 2003 17:31:35 -0500 Message-ID: <13165.1043188295@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/217 X-Sequence-Number: 864 Seth Robertson writes: > I'll try that and report back later, but I was under the (false?) > impression that it was primarily important when you had multiple > database connections using the same table. Definitely false. shared_buffers needs to be 1000 or so for production-grade performance. There are varying schools of thought about whether it's useful to raise it even higher, but in any case 64 is just a toy-installation setting. > seth=> explain analyze select accum from test where val = 5; > QUERY PLAN > ----------------------------------------------------------------------------------------------- > Seq Scan on test (cost=0.00..323.89 rows=1 width=4) (actual time=0.13..14.20 rows=1 loops=1) > Filter: (val = 5) > Total runtime: 14.26 msec > (3 rows) > seth=> explain analyze update test set accum = accum + 53 where val = '5'; > QUERY PLAN > --------------------------------------------------------------------------------------------------------------- > Index Scan using test_pkey on test (cost=0.00..5.99 rows=1 width=18) (actual time=0.24..0.24 rows=1 loops=1) > Index Cond: (val = 5::bigint) > Total runtime: 0.39 msec > (3 rows) The quotes are important when you are dealing with BIGINT indexes. You won't get an indexscan if the constant looks like int4 rather than int8. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jan 21 20:44:47 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A6FC4475EF9 for ; Tue, 21 Jan 2003 20:44:45 -0500 (EST) Received: from homer.berkhirt.com (unknown [207.88.49.100]) by postgresql.org (Postfix) with ESMTP id 9A03C475F85 for ; Tue, 21 Jan 2003 20:44:44 -0500 (EST) Received: from mobygames.com (fwbhirt.independence.net [204.144.177.199]) (authenticated bits=0) by homer.berkhirt.com (8.12.6/8.12.6) with ESMTP id h0M1iVI0029060 (version=TLSv1/SSLv3 cipher=DES-CBC3-SHA bits=168 verify=NO); Tue, 21 Jan 2003 19:44:33 -0600 Date: Tue, 21 Jan 2003 18:44:57 -0700 Subject: Re: Postgres 7.3.1 poor insert/update/search performance Content-Type: text/plain; delsp=yes; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: bhirt@mobygames.com To: pgsql-performance@postgresql.org From: Brian Hirt In-Reply-To: <13165.1043188295@sss.pgh.pa.us> Message-Id: <1CE2D1AE-2DAB-11D7-BE6C-000393D9FD00@mobygames.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/218 X-Sequence-Number: 865 Tom and others: There has been a lot of talk about shared memory size recently, along with many conflicting statements from various people. Earlier threads said that setting the shared buffer to a high values (like 512MB on a 2GB dedicated DB server) is not a good idea. A couple of reasons were mentioned. a) potential inefficiencies with the kernel and VM system b) modern kernels aggressive caching with all free memory and c) the shared memory stealing from memory the kernel would use to cache, etc. So my question is: if the kernel is caching all this data, what's the benefit of setting this to 1000 or higher? Why wouldn't i just set it to 0 if I believe my kernel is doing a good job. From all the discussion on this topic, it's still not clear to me how to calculate what value this should be set at and why. I've read these documents and others and have yet to find explanations and recommendations that i can use. http://www.postgresql.org/docs/momjian/hw_performance.pdf http://www.postgresql.org/idocs/index.php?runtime-config.html http://www.postgresql.org/idocs/index.php?kernel-resources.html http://www.postgresql.org/idocs/index.php?performance-tips.html http://www.ca.postgresql.org/docs/momjian/hw_performance/node6.html http://www.ca.postgresql.org/docs/momjian/hw_performance/node5.html http://www.ca.postgresql.org/docs/faq-english.html#3.6 This is such a common topic, it would be nice to see a more definitive and comprehensive section in the docs for tuning. Google searches for "shared_buffers site:www.postgresql.org" and "tuning site:www.postgresql.org" come up with little info. FYI: I've been running our database which is mostly read only with 1500 buffers. On a whole, we see very little IO. postgresql performs many many million queries a day, many simple, many complex. Though the database is relatively small, around 3GB. --brian On Tuesday, January 21, 2003, at 03:31 PM, Tom Lane wrote: > Seth Robertson writes: >> I'll try that and report back later, but I was under the (false?) >> impression that it was primarily important when you had multiple >> database connections using the same table. > > Definitely false. shared_buffers needs to be 1000 or so for > production-grade performance. There are varying schools of thought > about whether it's useful to raise it even higher, but in any case > 64 is just a toy-installation setting. > >> seth=> explain analyze select accum from test where val = 5; >> QUERY PLAN >> ---------------------------------------------------------------------- >> ------------------------- >> Seq Scan on test (cost=0.00..323.89 rows=1 width=4) (actual >> time=0.13..14.20 rows=1 loops=1) >> Filter: (val = 5) >> Total runtime: 14.26 msec >> (3 rows) > >> seth=> explain analyze update test set accum = accum + 53 where val = >> '5'; >> QUERY PLAN >> ---------------------------------------------------------------------- >> ----------------------------------------- >> Index Scan using test_pkey on test (cost=0.00..5.99 rows=1 >> width=18) (actual time=0.24..0.24 rows=1 loops=1) >> Index Cond: (val = 5::bigint) >> Total runtime: 0.39 msec >> (3 rows) > > The quotes are important when you are dealing with BIGINT indexes. > You won't get an indexscan if the constant looks like int4 rather than > int8. > > regards, tom lane > > ---------------------------(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 Jan 21 21:50:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 211F047627A for ; Tue, 21 Jan 2003 21:50:37 -0500 (EST) Received: from web80302.mail.yahoo.com (web80302.mail.yahoo.com [66.218.79.18]) by postgresql.org (Postfix) with SMTP id 74195476256 for ; Tue, 21 Jan 2003 21:50:35 -0500 (EST) Message-ID: <20030122025039.18791.qmail@web80302.mail.yahoo.com> Received: from [203.87.150.116] by web80302.mail.yahoo.com via HTTP; Tue, 21 Jan 2003 18:50:39 PST Date: Tue, 21 Jan 2003 18:50:39 -0800 (PST) From: Ludwig Lim Subject: Performance between triggers/functions written in C and PL/PGSQL To: PostgreSQL Mailing List MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/219 X-Sequence-Number: 866 Hi: Has anyone done performance comparison between triggers/functions in C vs. PL/PGSQL? What are the drawbacks of functions written using C? ludwig. __________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com From pgsql-performance-owner@postgresql.org Wed Jan 22 02:19:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7213C475FBF for ; Wed, 22 Jan 2003 02:19:51 -0500 (EST) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by postgresql.org (Postfix) with ESMTP id A1CE347592C for ; Wed, 22 Jan 2003 02:19:50 -0500 (EST) Received: (from mail@localhost) by martin.sysdetect.com (8.11.3/8.11.3) id h0M7JnB04192; Wed, 22 Jan 2003 07:19:49 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdBs5148; Wed Jan 22 07:19:45 2003 Received: from winwood.sysdetect.com (seth@localhost) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id h0M7JjA04509; Wed, 22 Jan 2003 02:19:45 -0500 Message-Id: <200301220719.h0M7JjA04509@winwood.sysdetect.com> From: Seth Robertson Cc: pgsql-performance@postgresql.org, Stephan Szabo Subject: Re: Postgres 7.3.1 poor insert/update/search performance In-reply-to: <13165.1043188295@sss.pgh.pa.us> References: <200301212120.h0LLKn820463> <20030121134242.Q84028-100000@megazone23.bigpanda.com> <200301212207.h0LM7Dt21080@winwood.sysdetect.com> <13165.1043188295@sss.pgh.pa.us> Comments: In reply to a message from "Tom Lane " dated "Tue, 21 Jan 2003 17:31:35 -0500." Date: Wed, 22 Jan 2003 02:19:45 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/220 X-Sequence-Number: 867 In message <13165.1043188295@sss.pgh.pa.us>, Tom Lane writes: Seth Robertson writes: > I'll try that and report back later, but I was under the (false?) > impression that it was primarily important when you had multiple > database connections using the same table. Definitely false. shared_buffers needs to be 1000 or so for production-grade performance. There are varying schools of thought about whether it's useful to raise it even higher, but in any case 64 is just a toy-installation setting. Increasing the setting to 4096 improved write performance by 20%. Increasing the setting to 8192 had no additional effect. I could try a few more probes if anyone cared. The quotes are important when you are dealing with BIGINT indexes. You won't get an indexscan if the constant looks like int4 rather than int8. You are not kidding!!!! Changing this increased the search performance to 2083 transactions/second. This is 30 times faster than before, and 5 times faster than Oracle! Go Tom Lane!!! Unfortunately, the update accidentally already used the quoting, so this top did not directly help the write case. However, it did inspire me to check some other suggestions I have read since obviously performance was to be had. ---------------------------------------------------------------------- Oracle read performance: 395 Original read performance: 69 shared_buffer = 4096 118 + quoted where (WHERE val = '5') 2083 ---------------------------------------------------------------------- ---------------------------------------------------------------------- Oracle write performance: 314 Original write performance: 39 shared_buffer = 4096: 47 + Occassional (@ 10K & 60K vectors) vacuum analyze in bg: 121 + Periodic (every 10K vectors) vacuum analyze in background: 124 + wal_buffers = 24: 125 + wal_method = fdatasync 127 + wal_method = open_sync 248 + wal_method = open_datasync Not Supported + fsync=false: 793 ---------------------------------------------------------------------- Just to round out my report, using the fastest safe combination I was able to find (open_sync *is* safe, isn't it?), I reran all 7 performance tests to see if there was any different using the different access methods: ---------------------------------------------------------------------- "normal" C libpq 256 t/s "normal" Perl DBI 251 t/s "DBI Prepared Statement" Perl DBI 254 t/s "Batching" Perl DBI 1149 t/s "arrays" Perl DBI 43 t/s "server-side function" Perl DBI 84 t/s "server-side trigger" Perl DBI 84 t/s "normal" Perl DBI read 1960 t/s "normal" Perl DBI for Oracle 314 t/s "normal" Perl DBI read for Oracle 395 t/s ---------------------------------------------------------------------- With a batching update of 1149 transactions per second (2900% improvement), I am willing to call it a day unless anyone else has any brilliant ideas. However, it looks like my hope to use arrays is doomed though, I'm not sure I can handle the performance penalty. -Seth Robertson From pgsql-general-owner@postgresql.org Wed Jan 22 05:30:35 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EE7CF475DC5 for ; Wed, 22 Jan 2003 05:30:32 -0500 (EST) Received: from biomax.de (unknown [212.6.137.236]) by postgresql.org (Postfix) with ESMTP id A82A2475BC3 for ; Wed, 22 Jan 2003 05:30:31 -0500 (EST) Received: from biomax.de (guffert.biomax.de [192.168.3.166]) by biomax.de (8.8.8/8.8.8) with ESMTP id LAA32055 for ; Wed, 22 Jan 2003 11:30:32 +0100 Message-ID: <3E2E72C8.2080703@biomax.de> Date: Wed, 22 Jan 2003 11:30:32 +0100 From: Chantal Ackermann User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: optimizing query Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/854 X-Sequence-Number: 35975 hello all, I am getting the following output from EXPLAIN, concerning a query with joins. The merge uses index scans but takes too long, in my opinion. The query is in fact only a part (subquery) of another one, but it is the bottle neck. As I am quite ignorant in optimizing queries, and I have no idea where to find documentation on the net on how to learn optimizing my queries, I am posting this here in hope someone will give me either tips how to optimize, or where to find some tutorial that could help me get along on my own. dropping the "DISTINCT" has some effect, but I can't really do without. Thank you Chantal +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ relate=# explain SELECT DISTINCT gene.gene_name, gene_occurrences_puid.puid FROM disease, gene, disease_occurrences_puid, gene_occurrences_puid WHERE disease_occurrences_puid.puid=gene_occurrences_puid.puid AND disease.disease_id=disease_occurrences_puid.disease_id AND gene.gene_id=gene_occurrences_puid.gene_id; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ Unique (cost=426503.59..436839.47 rows=137812 width=41) -> Sort (cost=426503.59..429948.88 rows=1378118 width=41) Sort Key: gene.gene_name, gene_occurrences_puid.puid -> Hash Join (cost=67813.96..162375.07 rows=1378118 width=41) Hash Cond: ("outer".disease_id = "inner".disease_id) -> Merge Join (cost=63671.50..98237.36 rows=1378118 width=37) Merge Cond: ("outer".puid = "inner".puid) -> Index Scan using disease_occpd_puid_i on disease_occurrences_puid (cost=0.00..14538.05 rows=471915 width=8) -> Sort (cost=63671.50..64519.87 rows=339347 width=29) Sort Key: gene_occurrences_puid.puid -> Merge Join (cost=0.00..22828.18 rows=339347 width=29) Merge Cond: ("outer".gene_id = "inner".gene_id) -> Index Scan using gene_pkey on gene (cost=0.00..7668.59 rows=218085 width=21) -> Index Scan using gene_id_puid_uni on gene_occurrences_puid (cost=0.00..9525.57 rows=339347 width=8) -> Hash (cost=3167.97..3167.97 rows=164597 width=4) -> Seq Scan on disease (cost=0.00..3167.97 rows=164597 width=4) (16 rows) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From pgsql-performance-owner@postgresql.org Wed Jan 22 07:05:23 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 44707475CA9 for ; Wed, 22 Jan 2003 07:05:22 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id ADA1B475BC3 for ; Wed, 22 Jan 2003 07:05:21 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18bJdE-00029x-00 for ; Wed, 22 Jan 2003 07:05:24 -0500 Date: Wed, 22 Jan 2003 07:05:24 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Postgres 7.3.1 poor insert/update/search performance Message-ID: <20030122070524.F27014@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <13165.1043188295@sss.pgh.pa.us> <1CE2D1AE-2DAB-11D7-BE6C-000393D9FD00@mobygames.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1CE2D1AE-2DAB-11D7-BE6C-000393D9FD00@mobygames.com>; from bhirt@mobygames.com on Tue, Jan 21, 2003 at 06:44:57PM -0700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/221 X-Sequence-Number: 868 On Tue, Jan 21, 2003 at 06:44:57PM -0700, Brian Hirt wrote: > > So my question is: if the kernel is caching all this data, what's the > benefit of setting this to 1000 or higher? Why wouldn't i just set it > to 0 if I believe my kernel is doing a good job. If Postgres tries to fetch a bit of data which is in its own shared buffer, it does not even need to make a system call in order to fetch it. The data fetch is extremely fast. The problem is that managing that shared memory comes at some cost. If the data is not in a shared buffer, then Postgres makes exactly the same call, no matter what, to the OS kernel, asking for the data from disk. It might happen, however, that the kernel will have the data in its disk cache, however. The total cost of the operation, therefore, is much lower in case the data is in the kernel's disk cache than in the case where it is actually on the disk. It is nevertheless still higher (atomically speaking) than fetching the data from Postgres's own shared buffer. So the question is this: where is the "sweet spot" where it costs little enough for Postgres to manage the shared buffer that the reduced cost of a system call is worth it. (As you point out, this caclulation is complicated by the potential to waste memory by caching the data twice -- once in the shared buffer and once in the disk cache. Some systems, like Solaris, allow you to turn off the disk cache, so the problem may not be one you face.) The trouble is that there is no agreement on the answer to that question, and precious little evidence which seems to settle the question. The only way to determine the best setting, then, is to use your system with more-or-less simulated production loads, and see where the best setting lies. You have to do this over time, because sometimes inefficiencies turn up only after running for a while. In an experiment we tried, we used a 2G shared buffer on a 12G machine. It looked brilliantly fast at first, but 48 hours later was _crawling_; that indicates a problem with shared-buffer management on the part of Postgres, I guess, but it was hard to say more than that. We ultimately settled on a value somewhere less than 1 G as appropriate for our use. But if I had to justify the number I picked (as opposed to one a few hundred higher or lower), I'd have a tough time. > From all the discussion on this topic, it's still not clear to me how > to calculate what value this should be set at and why. I've read these > documents and others and have yet to find explanations and > recommendations that i can use. I'm afraid what I'm saying is that it's a bit of a black art. The pg_autotune project is an attempt to help make this a little more scientific. It relies on pgbench, which has its own problems, however. Hope that's helpful, but I fear it doesn't give you the answer you'd like. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Wed Jan 22 11:21:14 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A665E476F7C for ; Wed, 22 Jan 2003 11:21:13 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 673424759AF for ; Wed, 22 Jan 2003 11:09:56 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0MG9x5u019953; Wed, 22 Jan 2003 11:09:59 -0500 (EST) To: Brian Hirt Cc: pgsql-performance@postgresql.org Subject: Re: Postgres 7.3.1 poor insert/update/search performance In-reply-to: <1CE2D1AE-2DAB-11D7-BE6C-000393D9FD00@mobygames.com> References: <1CE2D1AE-2DAB-11D7-BE6C-000393D9FD00@mobygames.com> Comments: In-reply-to Brian Hirt message dated "Tue, 21 Jan 2003 18:44:57 -0700" Date: Wed, 22 Jan 2003 11:09:58 -0500 Message-ID: <19952.1043251798@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/222 X-Sequence-Number: 869 Brian Hirt writes: > So my question is: if the kernel is caching all this data, what's the > benefit of setting this to 1000 or higher? Why wouldn't i just set it > to 0 if I believe my kernel is doing a good job. Well, setting it to 0 won't work ;-). There's some minimum number of buffers needed for PG to work at all; depending on complexity of your queries and number of active backends it's probably around 25-100. (You'll get "out of buffers" failures if too few.) But more to the point, when shared_buffers is too small you'll waste CPU cycles on unnecessary data transfers between kernel and user memory. It seems to be pretty well established that 64 is too small for most applications. I'm not sure how much is enough, but I suspect that a few thousand is plenty to get past the knee of the performance curve in most scenarios. regards, tom lane From pgsql-general-owner@postgresql.org Wed Jan 22 11:33:07 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3473A476EF0; Wed, 22 Jan 2003 11:33:04 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id D6850476F21; Wed, 22 Jan 2003 11:20:10 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 94101D611; Wed, 22 Jan 2003 08:20:15 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 89BC25C03; Wed, 22 Jan 2003 08:20:15 -0800 (PST) Date: Wed, 22 Jan 2003 08:20:15 -0800 (PST) From: Stephan Szabo To: Chantal Ackermann Cc: , Subject: Re: optimizing query In-Reply-To: <3E2E72C8.2080703@biomax.de> Message-ID: <20030122081422.Y96911-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/862 X-Sequence-Number: 35983 (Replying to general and performance in a hope to move this to performance after a couple of replies). On Wed, 22 Jan 2003, Chantal Ackermann wrote: > I am getting the following output from EXPLAIN, concerning a query with > joins. The merge uses index scans but takes too long, in my opinion. The > query is in fact only a part (subquery) of another one, but it is the > bottle neck. > > As I am quite ignorant in optimizing queries, and I have no idea where > to find documentation on the net on how to learn optimizing my queries, > I am posting this here in hope someone will give me either tips how to > optimize, or where to find some tutorial that could help me get along on > my own. > > dropping the "DISTINCT" has some effect, but I can't really do without. The first thing is, have you done ANALYZE recently to make sure that the statistics are correct and what does EXPLAIN ANALYZE give you (that will run the query and give the estimate and actual). Also, if you haven't vacuumed recently, you may want to vacuum full. How many rows are there on gene, disease and both occurrances tables? I'd wonder if perhaps using explicit sql join syntax (which postgres uses to constrain order) to join disease and disease_occurrences_puid before joining it to the other two would be better or worse in practice. From pgsql-performance-owner@postgresql.org Wed Jan 22 13:15:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 68BB4476391 for ; Wed, 22 Jan 2003 13:15:07 -0500 (EST) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by postgresql.org (Postfix) with ESMTP id D5F28476E57 for ; Wed, 22 Jan 2003 12:45:21 -0500 (EST) Received: (from mail@localhost) by martin.sysdetect.com (8.11.3/8.11.3) id h0MHjPJ23547 for ; Wed, 22 Jan 2003 17:45:25 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdZ15586; Wed Jan 22 17:45:24 2003 Received: from winwood.sysdetect.com (seth@localhost) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id h0MHjOs14488 for ; Wed, 22 Jan 2003 12:45:24 -0500 Message-Id: <200301221745.h0MHjOs14488@winwood.sysdetect.com> From: Seth Robertson To: pgsql-performance@postgresql.org Subject: Re: Postgres 7.3.1 poor insert/update/search performance References: <200301212120.h0LLKn820463> <20030121134242.Q84028-100000@megazone23.bigpanda.com> <200301212207.h0LM7Dt21080@winwood.sysdetect.com> <13165.1043188295@sss.pgh.pa.us> Comments: In reply to a message from "Seth Robertson " dated "Wed, 22 Jan 2003 02:19:45 -0500." Date: Wed, 22 Jan 2003 12:45:24 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/224 X-Sequence-Number: 871 Seth Robertson writes: However, it looks like my hope to use arrays is doomed though, I'm not sure I can handle the performance penalty. Just in case I get the person who implemented arrays annoyed or worried, I did not properly modify the "array" test and was vacuum'ing the wrong table every 10000 vectors during the test. I realized that this morning and the new array results are listed below. I also experimented with batching read operations, and I was surprised to find that this helps a great deal as well. ---------------------------------------------------------------------- "normal" C libpq 256 t/s "normal" Perl DBI 251 t/s "DBI Prepared Statement" Perl DBI 254 t/s "Batching" Perl DBI 1149 t/s "arrays" Perl DBI 250 t/s (*) "arrays with batching" Perl DBI 1020 t/s (*) "server-side function" Perl DBI 84 t/s "server-side trigger" Perl DBI 84 t/s "normal" Perl DBI read 1960 t/s "batched" Perl DBI read 3076 t/s (*) "array" Perl DBI read 1754 t/s (*) "batched array" Perl DBI read 2702 t/s (*) "normal" Perl DBI for Oracle 314 t/s "normal" Perl DBI read for Oracle 395 t/s ---------------------------------------------------------------------- (*) New/updated from this morning This brings array code to within 11% of the performance of batched non-arrays, and close enough to be an option. I may well be doing something wrong with the server-side functions, but I don't see anything quite so obviously wrong. -Seth Robertson From pgsql-performance-owner@postgresql.org Wed Jan 22 13:56:46 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3F211476EF0 for ; Wed, 22 Jan 2003 13:56:46 -0500 (EST) Received: from fddlnint05.fds.com (fddlnint05.fds.com [208.15.91.52]) by postgresql.org (Postfix) with ESMTP id 38810476F09 for ; Wed, 22 Jan 2003 13:30:42 -0500 (EST) Subject: Slow query on OS X box To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 Message-ID: From: "Patrick Hatcher" Date: Wed, 22 Jan 2003 10:26:17 -0800 X-MIMETrack: Serialize by Router on FDDLNINT05/FSG/SVR/FDD(Release 5.0.4 |June 8, 2000) at 01/22/2003 01:27:40 PM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/225 X-Sequence-Number: 872 I have a table that contains over 13 million rows. This query takes an extremely long time to return. I've vacuum full, analyzed, and re-indexed the table. Still the results are the same. Any ideas? TIA Patrick mdc_oz=# explain analyze select wizard from search_log where wizard ='Keyword' and sdate between '2002-12-01' and '2003-01-15'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------- Seq Scan on search_log (cost=0.00..609015.34 rows=3305729 width=10) (actual time=99833.83..162951.25 rows=3280573 loops=1) Filter: ((wizard = 'Keyword'::character varying) AND (sdate > = '2002-12-01'::date) AND (sdate <= '2003-01-15'::date)) Total runtime: 174713.25 msec (3 rows) My box I'm running PG on: Dual 500 Mac OS X 1g ram Pg 7.3.0 Conf settings max_connections = 200 shared_buffers = 15200 #max_fsm_relations = 100 # min 10, fsm is free space map, ~40 bytes #max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes #max_locks_per_transaction = 64 # min 10 #wal_buffers = 8 # min 4, typically 8KB each CREATE TABLE public.search_log ( wizard varchar(50) NOT NULL, sub_wizard varchar(50), timestamp varchar(75), department int4, gender varchar(25), occasion varchar(50), age varchar(25), product_type varchar(2000), price_range varchar(1000), brand varchar(2000), keyword varchar(1000), result_count int4, html_count int4, fragrance_type varchar(50), frag_type varchar(50), frag_gender char(1), trip_length varchar(25), carry_on varchar(25), suiter varchar(25), expandable varchar(25), wheels varchar(25), style varchar(1000), heel_type varchar(25), option varchar(50), metal varchar(255), gem varchar(255), bra_size varchar(25), feature1 varchar(50), feature2 varchar(50), feature3 varchar(50), sdate date, stimestamp timestamptz, file_name text ) WITH OIDS; CREATE INDEX date_idx ON search_log USING btree (sdate); CREATE INDEX slog_wizard_idx ON search_log USING btree (wizard); From pgsql-performance-owner@postgresql.org Wed Jan 22 14:22:16 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 34F7B477031 for ; Wed, 22 Jan 2003 14:22:14 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 725094770AD for ; Wed, 22 Jan 2003 13:55:02 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2322107; Wed, 22 Jan 2003 10:55:00 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Ludwig Lim , PostgreSQL Mailing List Subject: Re: Performance between triggers/functions written in C and PL/PGSQL Date: Wed, 22 Jan 2003 10:57:29 -0800 X-Mailer: KMail [version 1.4] References: <20030122025039.18791.qmail@web80302.mail.yahoo.com> In-Reply-To: <20030122025039.18791.qmail@web80302.mail.yahoo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301221057.29207.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/226 X-Sequence-Number: 873 Ludwig, > Has anyone done performance comparison between > triggers/functions in C vs. PL/PGSQL? On simple ON UPDATE triggers that update an archive table, but are called m= any=20 times per minute, about 20:1 in favor of C triggers. Partly that depends o= n=20 whether you load the C function as an external file or compile it into the= =20 database. The latter is, of course, faster by far less flexible. Partly this is because C is fast, being a lower-level language. Partly thi= s=20 is because the PL/pgSQL parser is in *desperate* need of an overhaul, as it= =20 was written in a hurry and has since suffered incremental development. > What are the drawbacks of functions written using > C? Writing C is harder. Gotta manage your own memory. Plus a badly written C= =20 function can easily crash Postgres, whereas that's much harder to do with= =20 PL/pgSQL. Usually I just write the original Trigger in PL/pgSQL, test & debug for dat= a=20 errors, and then farm it out to a crack C programmer to convert to C. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Jan 22 15:27:42 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E9457476F70 for ; Wed, 22 Jan 2003 15:27:38 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 31C9A47678E for ; Wed, 22 Jan 2003 15:02:16 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0MK25YJ059162; Wed, 22 Jan 2003 15:02:05 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: Slow query on OS X box From: Rod Taylor To: Patrick Hatcher Cc: Postgresql Performance In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-3K4M2hH3Gjt/xjJBmSiX" Organization: Message-Id: <1043265724.83856.147.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 22 Jan 2003 15:02:05 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/227 X-Sequence-Number: 874 --=-3K4M2hH3Gjt/xjJBmSiX Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-01-22 at 13:26, Patrick Hatcher wrote: > I have a table that contains over 13 million rows. This query takes an > extremely long time to return. I've vacuum full, analyzed, and re-indexed > the table. Still the results are the same. Any ideas? Yeah, you're pulling out 3.2 million rows from (possibly) a wide table bytewise. Do all of those fields actually have data? Thats always going to take a while -- and I find it hard to believe you're actually doing something with all of those rows that runs regularly. If every one of those rows was maxed out (ignoring the text field at the end) you could have ~ 15GB of data to pull out. Without knowing the type of data actually in the table, I'm going to bet it's a harddrive limitation. The index on 'wizard' is next to useless as at least 1/4 of the data in the table is under the same key. You might try a partial index on 'wizard' (skip the value 'Keyword'). It won't help this query, but it'll help ones looking for values other than 'Keyword'. Anyway, you might try a CURSOR. Fetch rows out 5000 at a time, do some work with them, then grab some more. This -- more or less -- will allow you to process the rows received while awaiting the remaining lines to be processed by the database. Depending on what you're doing with them it'll give a chance for the diskdrive to catch up. If the kernels smart it'll read ahead of the scan. This doesn't remove read time, but hides it while you're transferring the data out (from the db to your client) or processing it. > mdc_oz=3D# explain analyze select wizard from search_log where wizard > =3D'Keyword' and sdate between '2002-12-01' and '2003-01-15'; > QUERY PLAN > -------------------------------------------------------------------------= ---------------------------------------------------- > Seq Scan on search_log (cost=3D0.00..609015.34 rows=3D3305729 width=3D1= 0) > (actual time=3D99833.83..162951.25 rows=3D3280573 loops=3D1) > Filter: ((wizard =3D 'Keyword'::character varying) AND (sdate > > =3D '2002-12-01'::date) AND (sdate <=3D '2003-01-15'::date)) > Total runtime: 174713.25 msec > (3 rows) --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-3K4M2hH3Gjt/xjJBmSiX 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 (FreeBSD) iD8DBQA+Lvi76DETLow6vwwRAk3jAJ4gFieqU+UzgBQppmLx9Hhbp0A1nwCggud0 bS/lcI4nTc8OHQpTVQ+YB60= =pSvF -----END PGP SIGNATURE----- --=-3K4M2hH3Gjt/xjJBmSiX-- From pgsql-performance-owner@postgresql.org Wed Jan 22 16:10:25 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AE9A4476FF4 for ; Wed, 22 Jan 2003 16:10:23 -0500 (EST) Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) by postgresql.org (Postfix) with ESMTP id 5BDAA476FFA for ; Wed, 22 Jan 2003 15:35:27 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao01.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030122203528.CDZB16369.lakemtao01.cox.net@[192.168.1.1]> for ; Wed, 22 Jan 2003 15:35:28 -0500 Subject: Re: Slow query on OS X box From: Ron Johnson To: PgSQL Performance ML In-Reply-To: References: Content-Type: text/plain Organization: Message-Id: <1043267721.22135.141.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 22 Jan 2003 14:35:22 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/228 X-Sequence-Number: 875 What about creating a multi-segment index on wizard/sdate? On a side note: that record is ~8KB long, which is kinda big. You could split those column into a seperate table (or tables), so that when you want to query, say, gender, department & trip_length, you won't have to read in *so*much* extra data, slowing the query down. Also, these column sizes seem kind excessive, and allow for bad data to seep in to the table: timestamp varchar(75), age varchar(25), metal varchar(255), gem varchar(255), bra_size varchar(25), On Wed, 2003-01-22 at 12:26, Patrick Hatcher wrote: > I have a table that contains over 13 million rows. This query takes an > extremely long time to return. I've vacuum full, analyzed, and re-indexed > the table. Still the results are the same. Any ideas? > TIA > Patrick > > mdc_oz=# explain analyze select wizard from search_log where wizard > ='Keyword' and sdate between '2002-12-01' and '2003-01-15'; > QUERY PLAN > ----------------------------------------------------------------------------- > Seq Scan on search_log (cost=0.00..609015.34 rows=3305729 width=10) > (actual time=99833.83..162951.25 rows=3280573 loops=1) > Filter: ((wizard = 'Keyword'::character varying) AND (sdate > > = '2002-12-01'::date) AND (sdate <= '2003-01-15'::date)) > Total runtime: 174713.25 msec > (3 rows) > > My box I'm running PG on: > Dual 500 Mac OS X > 1g ram > Pg 7.3.0 > > Conf settings > max_connections = 200 > shared_buffers = 15200 > #max_fsm_relations = 100 # min 10, fsm is free space map, ~40 bytes > #max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes > #max_locks_per_transaction = 64 # min 10 > #wal_buffers = 8 # min 4, typically 8KB each > > > > > CREATE TABLE public.search_log ( > wizard varchar(50) NOT NULL, > sub_wizard varchar(50), > timestamp varchar(75), > department int4, > gender varchar(25), > occasion varchar(50), > age varchar(25), > product_type varchar(2000), > price_range varchar(1000), > brand varchar(2000), > keyword varchar(1000), > result_count int4, > html_count int4, > fragrance_type varchar(50), > frag_type varchar(50), > frag_gender char(1), > trip_length varchar(25), > carry_on varchar(25), > suiter varchar(25), > expandable varchar(25), > wheels varchar(25), > style varchar(1000), > heel_type varchar(25), > option varchar(50), > metal varchar(255), > gem varchar(255), > bra_size varchar(25), > feature1 varchar(50), > feature2 varchar(50), > feature3 varchar(50), > sdate date, > stimestamp timestamptz, > file_name text > ) WITH OIDS; > > CREATE INDEX date_idx ON search_log USING btree (sdate); > CREATE INDEX slog_wizard_idx ON search_log USING btree (wizard); > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "My advice to you is to get married: If you find a good wife, | | you will be happy; if not, you will become a philosopher." | | Socrates | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Wed Jan 22 16:25:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1B8C5475D64 for ; Wed, 22 Jan 2003 16:25:53 -0500 (EST) Received: from fddlnint05.fds.com (fddlnint05.fds.com [208.15.91.52]) by postgresql.org (Postfix) with ESMTP id D80604766F8 for ; Wed, 22 Jan 2003 15:54:11 -0500 (EST) Subject: Re: Slow query on OS X box To: "Rod Taylor Cc: Postgresql Performance X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 Message-ID: From: "Patrick Hatcher" Date: Wed, 22 Jan 2003 12:49:49 -0800 X-MIMETrack: Serialize by Router on FDDLNINT05/FSG/SVR/FDD(Release 5.0.4 |June 8, 2000) at 01/22/2003 03:51:11 PM MIME-Version: 1.0 Content-type: multipart/mixed; Boundary="0__=88256CB6006EA4498f9e8a93df938690918c88256CB6006EA449" Content-Disposition: inline X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/229 X-Sequence-Number: 876 --0__=88256CB6006EA4498f9e8a93df938690918c88256CB6006EA449 Content-type: text/plain; charset=us-ascii Sorry I'm being really dense today. I didn't even notice the 3.2 million row being returned. :( To answer your question, no, all fields would not have data. The data we receive is from a Web log file. It's parsed and then uploaded to this table. I guess the bigger issue is that when trying to do aggregates, grouping by the wizard field, it takes just as long. Ex: mdc_oz=# explain analyze select wizard,count(wizard) from search_log where sdate between '2002-12-01' and '2003-01-15' group by wizard; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1083300.43..1112411.55 rows=388148 width=10) (actual time=229503.85..302617.75 rows=14 loops=1) -> Group (cost=1083300.43..1102707.84 rows=3881482 width=10) (actual time=229503.60..286014.83 rows=3717161 loops=1) -> Sort (cost=1083300.43..1093004.14 rows=3881482 width=10) (actual time=229503.57..248415.81 rows=3717161 loops=1) Sort Key: wizard -> Seq Scan on search_log (cost=0.00..575217.57 rows=3881482 width=10) (actual time=91235.76..157559.58 rows=3717161 loops=1) Filter: ((sdate >= '2002-12-01'::date) AND (sdate <= '2003-01-15'::date)) Total runtime: 302712.48 msec (7 rows) Thanks again for the help Patrick Hatcher Rod Taylor To: Patrick Hatcher cc: Postgresql Performance 01/22/2003 Subject: Re: [PERFORM] Slow query on OS X box 12:02 PM On Wed, 2003-01-22 at 13:26, Patrick Hatcher wrote: > I have a table that contains over 13 million rows. This query takes an > extremely long time to return. I've vacuum full, analyzed, and re-indexed > the table. Still the results are the same. Any ideas? Yeah, you're pulling out 3.2 million rows from (possibly) a wide table bytewise. Do all of those fields actually have data? Thats always going to take a while -- and I find it hard to believe you're actually doing something with all of those rows that runs regularly. If every one of those rows was maxed out (ignoring the text field at the end) you could have ~ 15GB of data to pull out. Without knowing the type of data actually in the table, I'm going to bet it's a harddrive limitation. The index on 'wizard' is next to useless as at least 1/4 of the data in the table is under the same key. You might try a partial index on 'wizard' (skip the value 'Keyword'). It won't help this query, but it'll help ones looking for values other than 'Keyword'. Anyway, you might try a CURSOR. Fetch rows out 5000 at a time, do some work with them, then grab some more. This -- more or less -- will allow you to process the rows received while awaiting the remaining lines to be processed by the database. Depending on what you're doing with them it'll give a chance for the diskdrive to catch up. If the kernels smart it'll read ahead of the scan. This doesn't remove read time, but hides it while you're transferring the data out (from the db to your client) or processing it. > mdc_oz=# explain analyze select wizard from search_log where wizard > ='Keyword' and sdate between '2002-12-01' and '2003-01-15'; > QUERY PLAN > ----------------------------------------------------------------------------------------------------------------------------- > Seq Scan on search_log (cost=0.00..609015.34 rows=3305729 width=10) > (actual time=99833.83..162951.25 rows=3280573 loops=1) > Filter: ((wizard = 'Keyword'::character varying) AND (sdate > > = '2002-12-01'::date) AND (sdate <= '2003-01-15'::date)) > Total runtime: 174713.25 msec > (3 rows) -- Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc (See attached file: signature.asc) --0__=88256CB6006EA4498f9e8a93df938690918c88256CB6006EA449 Content-type: application/octet-stream; name="signature.asc" Content-Disposition: attachment; filename="signature.asc" Content-transfer-encoding: base64 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0NClZlcnNpb246IEdudVBH IHYxLjIuMSAoRnJlZUJTRCkNCg0KaUQ4REJRQStMdmk3NkRFVExvdzZ2d3dS QWszakFKNGdGaWVxVStVemdCUXBwbUx4OUhoYnAwQTFud0NnZ3VkMA0KYlMv bGNJNG5UYzhPSFFwVFZRK1lCNjA9DQo9cFN2Rg0KLS0tLS1FTkQgUEdQIFNJ R05BVFVSRS0tLS0tDQo= --0__=88256CB6006EA4498f9e8a93df938690918c88256CB6006EA449-- From pgsql-performance-owner@postgresql.org Wed Jan 22 16:25:59 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 327284761E9 for ; Wed, 22 Jan 2003 16:25:53 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 1C63F476581 for ; Wed, 22 Jan 2003 15:54:30 -0500 (EST) Received: from klaster.net (ph159.krakow.cvx.ppp.tpnet.pl [217.99.208.159]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 461922B864; Wed, 22 Jan 2003 21:50:09 +0100 (CET) Message-ID: <3E2F060E.9000509@klaster.net> Date: Wed, 22 Jan 2003 21:58:54 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Patrick Hatcher Cc: pgsql-performance@postgresql.org Subject: Re: Slow query on OS X box References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/230 X-Sequence-Number: 877 Patrick Hatcher wrote: >I have a table that contains over 13 million rows. This query takes an >extremely long time to return. I've vacuum full, analyzed, and re-indexed >the table. Still the results are the same. Any ideas? >TIA >Patrick > >mdc_oz=# explain analyze select wizard from search_log where wizard >='Keyword' and sdate between '2002-12-01' and '2003-01-15'; > QUERY PLAN >----------------------------------------------------------------------------------------------------------------------------- > Seq Scan on search_log (cost=0.00..609015.34 rows=3305729 width=10) >(actual time=99833.83..162951.25 rows=3280573 loops=1) > Filter: ((wizard = 'Keyword'::character varying) AND (sdate > >= '2002-12-01'::date) AND (sdate <= '2003-01-15'::date)) > Total runtime: 174713.25 msec >(3 rows) > >My box I'm running PG on: >Dual 500 Mac OS X >1g ram >Pg 7.3.0 > >Conf settings >max_connections = 200 >shared_buffers = 15200 >#max_fsm_relations = 100 # min 10, fsm is free space map, ~40 bytes >#max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes >#max_locks_per_transaction = 64 # min 10 >#wal_buffers = 8 # min 4, typically 8KB each > > > > >CREATE TABLE public.search_log ( > wizard varchar(50) NOT NULL, > sub_wizard varchar(50), > timestamp varchar(75), > department int4, > gender varchar(25), > occasion varchar(50), > age varchar(25), > product_type varchar(2000), > price_range varchar(1000), > brand varchar(2000), > keyword varchar(1000), > result_count int4, > html_count int4, > fragrance_type varchar(50), > frag_type varchar(50), > frag_gender char(1), > trip_length varchar(25), > carry_on varchar(25), > suiter varchar(25), > expandable varchar(25), > wheels varchar(25), > style varchar(1000), > heel_type varchar(25), > option varchar(50), > metal varchar(255), > gem varchar(255), > bra_size varchar(25), > feature1 varchar(50), > feature2 varchar(50), > feature3 varchar(50), > sdate date, > stimestamp timestamptz, > file_name text >) WITH OIDS; > >CREATE INDEX date_idx ON search_log USING btree (sdate); >CREATE INDEX slog_wizard_idx ON search_log USING btree (wizard); Did you try to change theses 2 indexes into 1? CREATE INDEX date_wizard_idx on search_log USING btree(wizard,sdate) How selective are these fields: - if you ask about wizard="Keyword", the answer is 0.1% or 5% or 50% of rows? - if you ask about sdate >= '2002-12-01'::date) AND (sdate <= '2003-01-15'::date) what is the answer? Consider creating table "wizards", and changing field "wizard" in table "search_log" into integer field "wizardid". Searching by integer is faster than by varchar. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Wed Jan 22 17:27:51 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EF88D476FAE for ; Wed, 22 Jan 2003 17:27:49 -0500 (EST) Received: from johnlaptop.darkcore.net (link.clearoption.com [205.200.121.81]) by postgresql.org (Postfix) with ESMTP id E262B47711C for ; Wed, 22 Jan 2003 16:44:41 -0500 (EST) Received: by johnlaptop.darkcore.net (Postfix, from userid 501) id 51237F1EB4; Wed, 22 Jan 2003 16:44:42 -0500 (EST) Subject: Query plan and Inheritance. Weird behavior From: John Lange To: pgsql-performance@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8-3mdk Date: 22 Jan 2003 15:44:42 -0600 Message-Id: <1043271882.11373.158.camel@johnlaptop.darkcore.net> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/231 X-Sequence-Number: 878 I have a database that makes fairly extensive use of table Inheritance. Structure is one parent table and 5 child tables as follows: tbl_objects (parent table) -> tbl_viewers -> tbl_documents -> tbl_icons -> tbl_massemails -> tbl_formats I have two questions: First, if I create an index on the parent table will queries to the child tables use that index? Secondly, I tried to use explain to find out but I got very strange results. It appears to read all the child tables even when you specify only the parent table. In this case this appears to make the select do 6 queries instead of only 1. Obviously a huge performance hit. And none of them uses the index though the table only has 420 rows at the moment so that might be why its just doing a scan (though IMHO 'explain' should explain that it isn't using the available index and why). I can't say that I'm reading these results properly but here they are: "EXPLAIN select * from tbl_objects where id = 1;" Gives: NOTICE: QUERY PLAN: Result (cost=0.00..27.25 rows=6 width=138) -> Append (cost=0.00..27.25 rows=6 width=138) -> Seq Scan on tbl_objects (cost=0.00..12.24 rows=1 width=73) -> Seq Scan on tbl_viewers tbl_objects (cost=0.00..1.07 rows=1 width=83) -> Seq Scan on tbl_documents tbl_objects (cost=0.00..11.56 rows=1 width=78) -> Seq Scan on tbl_massemails tbl_objects (cost=0.00..0.00 rows=1 width=138) -> Seq Scan on tbl_formats tbl_objects (cost=0.00..1.12 rows=1 width=80) -> Seq Scan on tbl_icons tbl_objects (cost=0.00..1.25 rows=1 width=89) Can anyone tell me if these results are making any sense and why postgres is doing 6 reads when I only need one? John Lange From pgsql-performance-owner@postgresql.org Wed Jan 22 17:39:18 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9A513477335 for ; Wed, 22 Jan 2003 17:39:17 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D79A1476F02 for ; Wed, 22 Jan 2003 17:04:03 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0MM3u5u024610; Wed, 22 Jan 2003 17:03:56 -0500 (EST) To: "Patrick Hatcher" Cc: pgsql-performance@postgresql.org Subject: Re: Slow query on OS X box In-reply-to: References: Comments: In-reply-to "Patrick Hatcher" message dated "Wed, 22 Jan 2003 10:26:17 -0800" Date: Wed, 22 Jan 2003 17:03:55 -0500 Message-ID: <24609.1043273035@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/232 X-Sequence-Number: 879 "Patrick Hatcher" writes: > I have a table that contains over 13 million rows. This query takes an > extremely long time to return. I've vacuum full, analyzed, and re-indexed > the table. Still the results are the same. Any ideas? > mdc_oz=# explain analyze select wizard from search_log where wizard > ='Keyword' and sdate between '2002-12-01' and '2003-01-15'; > QUERY PLAN > ----------------------------------------------------------------------------------------------------------------------------- > Seq Scan on search_log (cost=0.00..609015.34 rows=3305729 width=10) > (actual time=99833.83..162951.25 rows=3280573 loops=1) > Filter: ((wizard = 'Keyword'::character varying) AND (sdate > > = '2002-12-01'::date) AND (sdate <= '2003-01-15'::date)) > Total runtime: 174713.25 msec > (3 rows) This query is selecting 3280573 rows out of your 13 million. I'd say the machine is doing the best it can. Returning 19000 rows per second is not all that shabby. Perhaps you should rethink what you're doing. Do you actually need to return 3 million rows to the client? regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jan 22 18:41:44 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 16E5E47635D for ; Wed, 22 Jan 2003 18:41:43 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 216C7476A0E for ; Wed, 22 Jan 2003 17:54:33 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0MMsKYJ059528; Wed, 22 Jan 2003 17:54:21 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: Slow query on OS X box From: Rod Taylor To: Patrick Hatcher Cc: Postgresql Performance In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-Ddx8v7ZEOD45HkgRKSwg" Organization: Message-Id: <1043276059.83856.180.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 22 Jan 2003 17:54:20 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/233 X-Sequence-Number: 880 --=-Ddx8v7ZEOD45HkgRKSwg Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Yup, since you still need to pull everything off the disk (the slowest part), which is quite a bit of data. You're simply dealing with a lot of data for a single query -- not much you can do. Is this a dedicated -- one client doing big selects like this? Knock your shared_buffers down to about 2000, bump your sort mem up to around 32MB (128MB or so if it's a dedicated box with a vast majority of queries like the below). Okay, need to do something about the rest of the data. 13million * 2k is a big number. Do you have a set of columns that are rarely used? If so, toss them into a separate table and link via a unique identifier (int4). It'll cost extra when you do hit them, but pulling out a few of the large ones information wise would buy quite a bit. Now, wizard. For that particular query it would be best if entries were made for all the values of wizard into a lookup table, and change search_log.wizard into a reference to that entry in the lookup. Index the lookup table well (one in the wizard primary key -- int4, and a unique index on the 'wizard' varchar). Group by the number, join to the lookup table for the name. Any other values with highly repetitive data? Might want to consider doing the same for them. In search_log, index the numeric representation of 'wizard' (key from lookup table), but don't bother indexing numbers that occur regularly. Look up how to create a partial index. Ie. The value 'Keyword' could be skipped as it occurs once in four tuples -- too often for an index to be useful. On Wed, 2003-01-22 at 15:49, Patrick Hatcher wrote: > Sorry I'm being really dense today. I didn't even notice the 3.2 million > row being returned. :( >=20 > To answer your question, no, all fields would not have data. The data we > receive is from a Web log file. It's parsed and then uploaded to this > table. >=20 > I guess the bigger issue is that when trying to do aggregates, grouping by > the wizard field, it takes just as long. >=20 > Ex: > mdc_oz=3D# explain analyze select wizard,count(wizard) from search_log wh= ere > sdate > between '2002-12-01' and '2003-01-15' group by wizard; > QUERY > PLAN > -------------------------------------------------------------------------= ---------------------------------------------------------------------- > Aggregate (cost=3D1083300.43..1112411.55 rows=3D388148 width=3D10) (act= ual > time=3D229503.85..302617.75 rows=3D14 loops=3D1) > -> Group (cost=3D1083300.43..1102707.84 rows=3D3881482 width=3D10) (= actual > time=3D229503.60..286014.83 rows=3D3717161 loops=3D1) > -> Sort (cost=3D1083300.43..1093004.14 rows=3D3881482 width=3D= 10) > (actual time=3D229503.57..248415.81 rows=3D3717161 loops=3D1) > Sort Key: wizard > -> Seq Scan on search_log (cost=3D0.00..575217.57 > rows=3D3881482 width=3D10) (actual time=3D91235.76..157559.58 rows=3D3717= 161 > loops=3D1) > Filter: ((sdate >=3D '2002-12-01'::date) AND (sdate > <=3D '2003-01-15'::date)) > Total runtime: 302712.48 msec > (7 rows) > On Wed, 2003-01-22 at 13:26, Patrick Hatcher wrote: > > I have a table that contains over 13 million rows. This query takes an > > extremely long time to return. I've vacuum full, analyzed, and > re-indexed > > the table. Still the results are the same. Any ideas? > > mdc_oz=3D# explain analyze select wizard from search_log where wizard > > =3D'Keyword' and sdate between '2002-12-01' and '2003-01-15'; > > QUERY PLAN > > > -------------------------------------------------------------------------= ---------------------------------------------------- >=20 > > Seq Scan on search_log (cost=3D0.00..609015.34 rows=3D3305729 width= =3D10) > > (actual time=3D99833.83..162951.25 rows=3D3280573 loops=3D1) > > Filter: ((wizard =3D 'Keyword'::character varying) AND (sdate > > > =3D '2002-12-01'::date) AND (sdate <=3D '2003-01-15'::date)) > > Total runtime: 174713.25 msec > > (3 rows) > -- > Rod Taylor >=20 > PGP Key: http://www.rbt.ca/rbtpub.asc > (See attached file: signature.asc) >=20 >=20 > ______________________________________________________________________ >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-Ddx8v7ZEOD45HkgRKSwg 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 (FreeBSD) iD8DBQA+LyEa6DETLow6vwwRAozBAJ0UfoOxkmyVKfFX/mk5EQWGhzx9WgCdGPOl BFCJvs11Hd2cujy6g5jrfBg= =ZU4w -----END PGP SIGNATURE----- --=-Ddx8v7ZEOD45HkgRKSwg-- From pgsql-hackers-owner@postgresql.org Wed Jan 22 18:45:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D38D4476FA6; Wed, 22 Jan 2003 18:45:51 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3FC3E4770F2; Wed, 22 Jan 2003 18:01:51 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0MN1r5u025072; Wed, 22 Jan 2003 18:01:53 -0500 (EST) To: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org Subject: Proposal: relaxing link between explicit JOINs and execution order Date: Wed, 22 Jan 2003 18:01:53 -0500 Message-ID: <25071.1043276513@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/849 X-Sequence-Number: 34459 There's been some recent discussion about the fact that Postgres treats explicit JOIN syntax as constraining the actual join plan, cf http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit-joins.html This behavior was originally in there simply because of lack of time to consider alternatives. I now realize that it wouldn't be hard to get the planner to do better --- basically, preprocess_jointree just has to be willing to fold JoinExpr-under-JoinExpr into a FromExpr when the joins are inner joins. But in the meantime, some folks have found the present behavior to be a feature rather than a bug, since it lets them control planning time on many-table queries. If we are going to change it, I think we need some way to accommodate both camps. What I've been toying with is inventing a GUC variable or two. I am thinking of defining a variable that sets the maximum size of a FromExpr that preprocess_jointree is allowed to create by folding JoinExprs. If this were set to 2, the behavior would be the same as before: no collapsing of JoinExprs can occur. If it were set to a large number, inner JOIN syntax would never affect the planner at all. In practice it'd be smart to leave it at some value less than GEQO_THRESHOLD, so that folding a large number of JOINs wouldn't leave you with a query that takes a long time to plan or produces unpredictable plans. There is already a need for a GUC variable to control the existing behavior of preprocess_jointree: right now, it arbitrarily uses GEQO_THRESHOLD/2 as the limit for the size of a FromExpr that can be made by collapsing FromExprs together. This ought to be a separately settable parameter, I think. Comments? In particular, can anyone think of pithy names for these variables? The best I'd been able to come up with is MAX_JOIN_COLLAPSE and MAX_FROM_COLLAPSE, but neither of these exactly sing... regards, tom lane From pgsql-hackers-owner@postgresql.org Wed Jan 22 18:51:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A1726476FF9; Wed, 22 Jan 2003 18:51:37 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A5D6D477161; Wed, 22 Jan 2003 18:14:31 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0MNEU5u025183; Wed, 22 Jan 2003 18:14:32 -0500 (EST) To: Steve Crawford Cc: pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org Subject: Re: Terrible performance on wide selects In-reply-to: <20030122224814.ECF47103E6@polaris.pinpointresearch.com> References: <20030117193726.1CFCB103E5@polaris.pinpointresearch.com> <20030122212901.EDF00103E6@polaris.pinpointresearch.com> <24808.1043274411@sss.pgh.pa.us> <20030122224814.ECF47103E6@polaris.pinpointresearch.com> Comments: In-reply-to Steve Crawford message dated "Wed, 22 Jan 2003 14:48:15 -0800" Date: Wed, 22 Jan 2003 18:14:30 -0500 Message-ID: <25182.1043277270@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/850 X-Sequence-Number: 34460 Steve Crawford sent me some profiling results for queries involving wide tuples (hundreds of columns). > Done, results attached. nocachegetattr seems to be the likely suspect. Yipes, you can say that again. % cumulative self self total time seconds seconds calls ms/call ms/call name 93.38 26.81 26.81 885688 0.03 0.03 nocachegetattr 0.00 0.00 1/885688 heapgettup [159] 0.00 0.00 1/885688 CatalogCacheComputeTupleHashValue [248] 0.00 0.00 5/885688 SearchCatCache [22] 13.40 0.00 442840/885688 ExecEvalVar [20] 13.40 0.00 442841/885688 printtup [12] [11] 93.4 26.81 0.00 885688 nocachegetattr [11] Half of the calls are coming from printtup(), which seems relatively easy to fix. /* * send the attributes of this tuple */ for (i = 0; i < natts; ++i) { ... origattr = heap_getattr(tuple, i + 1, typeinfo, &isnull); ... } The trouble here is that in the presence of variable-width fields, heap_getattr requires a linear scan over the tuple --- and so the total time spent in it is O(N^2) in the number of fields. What we could do is reinstitute heap_deformtuple() as the inverse of heap_formtuple() --- but make it extract Datums for all the columns in a single pass over the tuple. This would reduce the time in printtup() from O(N^2) to O(N), which would pretty much wipe out that part of the problem. The other half of the calls are coming from ExecEvalVar, which is a harder problem to solve, since those calls are scattered all over the place. It's harder to see how to get them to share work. Any ideas out there? regards, tom lane From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:26:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C3BCD476792; Wed, 22 Jan 2003 19:26:01 -0500 (EST) Received: from voyager.corporate.connx.com (unknown [209.20.248.131]) by postgresql.org (Postfix) with ESMTP id 9F4264764FF; Wed, 22 Jan 2003 18:56:52 -0500 (EST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Terrible performance on wide selects X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Date: Wed, 22 Jan 2003 15:56:55 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [HACKERS] Terrible performance on wide selects Thread-Index: AcLCcUCKv2Dzdt+2S5KSGmsm2QIFGQAADl6w From: "Dann Corbit" To: "Tom Lane" , "Steve Crawford" Cc: , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/851 X-Sequence-Number: 34461 > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 > Sent: Wednesday, January 22, 2003 3:15 PM > To: Steve Crawford > Cc: pgsql-performance@postgreSQL.org; pgsql-hackers@postgreSQL.org > Subject: Re: [HACKERS] Terrible performance on wide selects=20 >=20 >=20 > Steve Crawford sent me some profiling results for queries=20 > involving wide tuples (hundreds of columns). >=20 > > Done, results attached. nocachegetattr seems to be the=20 > likely suspect. >=20 > Yipes, you can say that again. >=20 > % cumulative self self total=20=20=20=20=20=20=20= =20=20=20=20 > time seconds seconds calls ms/call ms/call name=20=20=20=20 > 93.38 26.81 26.81 885688 0.03 0.03 nocachegetattr >=20 > 0.00 0.00 1/885688 heapgettup [159] > 0.00 0.00 1/885688=20=20=20=20=20=20 > CatalogCacheComputeTupleHashValue [248] > 0.00 0.00 5/885688 SearchCatCache [22] > 13.40 0.00 442840/885688 ExecEvalVar [20] > 13.40 0.00 442841/885688 printtup [12] > [11] 93.4 26.81 0.00 885688 nocachegetattr [11] >=20 >=20 > Half of the calls are coming from printtup(), which seems=20 > relatively easy to fix. >=20 > /* > * send the attributes of this tuple > */ > for (i =3D 0; i < natts; ++i) > { > ... > origattr =3D heap_getattr(tuple, i + 1, typeinfo,=20 > &isnull); > ... > } >=20 > The trouble here is that in the presence of variable-width=20 > fields, heap_getattr requires a linear scan over the tuple=20 > --- and so the total time spent in it is O(N^2) in the number=20 > of fields. >=20 > What we could do is reinstitute heap_deformtuple() as the inverse of > heap_formtuple() --- but make it extract Datums for all the=20 > columns in a single pass over the tuple. This would reduce=20 > the time in printtup() from O(N^2) to O(N), which would=20 > pretty much wipe out that part of the problem. >=20 > The other half of the calls are coming from ExecEvalVar,=20 > which is a harder problem to solve, since those calls are=20 > scattered all over the place. It's harder to see how to get=20 > them to share work. Any ideas out there? Is it possible that the needed information could be retrieved by querying the system metadata to collect the column information? Once the required tuple attributes are described, it could form a binding list that allocates a buffer of sufficient size with pointers to the required column start points. Maybe I don't really understand the problem, but it seems simple enough to do it once for the whole query. If this is utter stupidity, please disregard and have a hearty laugh at my expense. ;-) From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:27:14 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2E220476F8B; Wed, 22 Jan 2003 19:27:14 -0500 (EST) Received: from perrin.int.nxad.com (internal.ext.nxad.com [66.250.180.251]) by postgresql.org (Postfix) with ESMTP id BC38947707B; Wed, 22 Jan 2003 18:59:47 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id A685E2105F; Wed, 22 Jan 2003 15:59:31 -0800 (PST) Date: Wed, 22 Jan 2003 15:59:31 -0800 From: Sean Chittenden To: Tom Lane Cc: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org Subject: Re: [PERFORM] Proposal: relaxing link between explicit JOINs and execution order Message-ID: <20030122235931.GE12075@perrin.int.nxad.com> References: <25071.1043276513@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25071.1043276513@sss.pgh.pa.us> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 6CEB 1B06 BFD3 70F6 95BE 7E4D 8E85 2E0A 5F5B 3ECB X-Web-Homepage: http://sean.chittenden.org/ X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/852 X-Sequence-Number: 34462 > There's been some recent discussion about the fact that Postgres > treats explicit JOIN syntax as constraining the actual join plan, cf > http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit-joins.html > > This behavior was originally in there simply because of lack of time > to consider alternatives. I now realize that it wouldn't be hard to > get the planner to do better --- basically, preprocess_jointree just > has to be willing to fold JoinExpr-under-JoinExpr into a FromExpr > when the joins are inner joins. > > But in the meantime, some folks have found the present behavior to be > a feature rather than a bug, since it lets them control planning time > on many-table queries. If we are going to change it, I think we need > some way to accommodate both camps. [snip] > Comments? In particular, can anyone think of pithy names for these > variables? The best I'd been able to come up with is > MAX_JOIN_COLLAPSE and MAX_FROM_COLLAPSE, but neither of these > exactly sing... How about something that's runtime tunable via a SET/SHOW config var? There are some queries that I have that I haven't spent any time tuning and would love to have the planner spend its CPU thinking about it instead of mine. Setting it to 2 by default, then on my tuned queries, setting to something obscenely high so the planner won't muck with what I know is fastest (or so I think at least). I know this is a can of worms, but what about piggy backing on an Oracle notation and having an inline way of setting this inside of a comment? SELECT /* +planner:collapse_tables=12 */ .... ? ^^^^^^^ ^^^^^^^^^^^^^^^ ^^^ system variable value ::shrug:: In brainstorm mode. Anyway, a few names: auto_order_join auto_order_join_max auto_reorder_table_limit auto_collapse_join auto_collapse_num_join auto_join_threshold When I'm thinking about what this variable will do for me as a DBA, I think it will make the plan more intelligent by reordering the joins. My $0.02. -sc -- Sean Chittenden From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:28:13 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3F186476FBA; Wed, 22 Jan 2003 19:28:12 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3125947610E; Wed, 22 Jan 2003 19:04:03 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0N0435u025522; Wed, 22 Jan 2003 19:04:03 -0500 (EST) To: "Dann Corbit" Cc: "Steve Crawford" , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org Subject: Re: Terrible performance on wide selects In-reply-to: References: Comments: In-reply-to "Dann Corbit" message dated "Wed, 22 Jan 2003 15:56:55 -0800" Date: Wed, 22 Jan 2003 19:04:02 -0500 Message-ID: <25521.1043280242@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/853 X-Sequence-Number: 34463 "Dann Corbit" writes: > Maybe I don't really understand the problem, but it seems simple enough > to do it once for the whole query. We already do cache column offsets when they are fixed. The code that's the problem executes when there's a variable-width column in the table --- which means that all columns to its right are not at fixed offsets, and have to be scanned for separately in each tuple, AFAICS. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jan 22 19:30:34 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2696E477117; Wed, 22 Jan 2003 19:30:30 -0500 (EST) Received: from fddlnint05.fds.com (fddlnint05.fds.com [208.15.91.52]) by postgresql.org (Postfix) with ESMTP id 829BE47630A; Wed, 22 Jan 2003 19:10:11 -0500 (EST) Subject: Re: Slow query on OS X box To: "Rod Taylor Cc: Postgresql Performance , pgsql-performance-owner@postgresql.org X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 Message-ID: From: "Patrick Hatcher" Date: Wed, 22 Jan 2003 16:05:39 -0800 X-MIMETrack: Serialize by Router on FDDLNINT05/FSG/SVR/FDD(Release 5.0.4 |June 8, 2000) at 01/22/2003 07:07:12 PM MIME-Version: 1.0 Content-type: multipart/mixed; Boundary="0__=88256CB7000066218f9e8a93df938690918c88256CB700006621" Content-Disposition: inline X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/241 X-Sequence-Number: 888 --0__=88256CB7000066218f9e8a93df938690918c88256CB700006621 Content-type: text/plain; charset=us-ascii Thanks everyone. I'll give your suggestions a try and report back. Patrick Hatcher Macys.Com Legacy Integration Developer 415-422-1610 office HatcherPT - AIM Rod Taylor Sent by: To: Patrick Hatcher pgsql-performance-owner@post cc: Postgresql Performance gresql.org Subject: Re: [PERFORM] Slow query on OS X box 01/22/2003 02:54 PM Yup, since you still need to pull everything off the disk (the slowest part), which is quite a bit of data. You're simply dealing with a lot of data for a single query -- not much you can do. Is this a dedicated -- one client doing big selects like this? Knock your shared_buffers down to about 2000, bump your sort mem up to around 32MB (128MB or so if it's a dedicated box with a vast majority of queries like the below). Okay, need to do something about the rest of the data. 13million * 2k is a big number. Do you have a set of columns that are rarely used? If so, toss them into a separate table and link via a unique identifier (int4). It'll cost extra when you do hit them, but pulling out a few of the large ones information wise would buy quite a bit. Now, wizard. For that particular query it would be best if entries were made for all the values of wizard into a lookup table, and change search_log.wizard into a reference to that entry in the lookup. Index the lookup table well (one in the wizard primary key -- int4, and a unique index on the 'wizard' varchar). Group by the number, join to the lookup table for the name. Any other values with highly repetitive data? Might want to consider doing the same for them. In search_log, index the numeric representation of 'wizard' (key from lookup table), but don't bother indexing numbers that occur regularly. Look up how to create a partial index. Ie. The value 'Keyword' could be skipped as it occurs once in four tuples -- too often for an index to be useful. On Wed, 2003-01-22 at 15:49, Patrick Hatcher wrote: > Sorry I'm being really dense today. I didn't even notice the 3.2 million > row being returned. :( > > To answer your question, no, all fields would not have data. The data we > receive is from a Web log file. It's parsed and then uploaded to this > table. > > I guess the bigger issue is that when trying to do aggregates, grouping by > the wizard field, it takes just as long. > > Ex: > mdc_oz=# explain analyze select wizard,count(wizard) from search_log where > sdate > between '2002-12-01' and '2003-01-15' group by wizard; > QUERY > PLAN > ----------------------------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=1083300.43..1112411.55 rows=388148 width=10) (actual > time=229503.85..302617.75 rows=14 loops=1) > -> Group (cost=1083300.43..1102707.84 rows=3881482 width=10) (actual > time=229503.60..286014.83 rows=3717161 loops=1) > -> Sort (cost=1083300.43..1093004.14 rows=3881482 width=10) > (actual time=229503.57..248415.81 rows=3717161 loops=1) > Sort Key: wizard > -> Seq Scan on search_log (cost=0.00..575217.57 > rows=3881482 width=10) (actual time=91235.76..157559.58 rows=3717161 > loops=1) > Filter: ((sdate >= '2002-12-01'::date) AND (sdate > <= '2003-01-15'::date)) > Total runtime: 302712.48 msec > (7 rows) > On Wed, 2003-01-22 at 13:26, Patrick Hatcher wrote: > > I have a table that contains over 13 million rows. This query takes an > > extremely long time to return. I've vacuum full, analyzed, and > re-indexed > > the table. Still the results are the same. Any ideas? > > mdc_oz=# explain analyze select wizard from search_log where wizard > > ='Keyword' and sdate between '2002-12-01' and '2003-01-15'; > > QUERY PLAN > > > ----------------------------------------------------------------------------------------------------------------------------- > > > Seq Scan on search_log (cost=0.00..609015.34 rows=3305729 width=10) > > (actual time=99833.83..162951.25 rows=3280573 loops=1) > > Filter: ((wizard = 'Keyword'::character varying) AND (sdate > > > = '2002-12-01'::date) AND (sdate <= '2003-01-15'::date)) > > Total runtime: 174713.25 msec > > (3 rows) > -- > Rod Taylor > > PGP Key: http://www.rbt.ca/rbtpub.asc > (See attached file: signature.asc) > > > ______________________________________________________________________ > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc (See attached file: signature.asc) --0__=88256CB7000066218f9e8a93df938690918c88256CB700006621 Content-type: application/octet-stream; name="signature.asc" Content-Disposition: attachment; filename="signature.asc" Content-transfer-encoding: base64 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0NClZlcnNpb246IEdudVBH IHYxLjIuMSAoRnJlZUJTRCkNCg0KaUQ4REJRQStMeUVhNkRFVExvdzZ2d3dS QW96QkFKMFVmb094a215VktmRlgvbWs1RVFXR2h6eDlXZ0NkR1BPbA0KQkZD SnZzMTFIZDJjdWp5Nmc1anJmQmc9DQo9WlU0dw0KLS0tLS1FTkQgUEdQIFNJ R05BVFVSRS0tLS0tDQo= --0__=88256CB7000066218f9e8a93df938690918c88256CB700006621-- From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:28:24 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CA74F47610E; Wed, 22 Jan 2003 19:28:23 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3174F476932; Wed, 22 Jan 2003 19:06:11 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0N06C5u025542; Wed, 22 Jan 2003 19:06:12 -0500 (EST) To: Sean Chittenden Cc: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org Subject: Re: [PERFORM] Proposal: relaxing link between explicit JOINs and execution order In-reply-to: <20030122235931.GE12075@perrin.int.nxad.com> References: <25071.1043276513@sss.pgh.pa.us> <20030122235931.GE12075@perrin.int.nxad.com> Comments: In-reply-to Sean Chittenden message dated "Wed, 22 Jan 2003 15:59:31 -0800" Date: Wed, 22 Jan 2003 19:06:12 -0500 Message-ID: <25541.1043280372@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/854 X-Sequence-Number: 34464 Sean Chittenden writes: > How about something that's runtime tunable via a SET/SHOW config var? Er, that's what I was talking about. > I know this is a can of worms, but what about piggy backing on an > Oracle notation and having an inline way of setting this inside of a > comment? I don't want to go there ... regards, tom lane From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:28:31 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AF5574763AE; Wed, 22 Jan 2003 19:28:26 -0500 (EST) Received: from voyager.corporate.connx.com (unknown [209.20.248.131]) by postgresql.org (Postfix) with ESMTP id 30BCC476225; Wed, 22 Jan 2003 19:06:24 -0500 (EST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Terrible performance on wide selects X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Date: Wed, 22 Jan 2003 16:06:26 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [HACKERS] Terrible performance on wide selects Thread-Index: AcLCcvHqCIiFc580TV+dnOY8b5QwgQAABbnw From: "Dann Corbit" To: "Tom Lane" Cc: "Steve Crawford" , , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/855 X-Sequence-Number: 34465 > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 > Sent: Wednesday, January 22, 2003 4:04 PM > To: Dann Corbit > Cc: Steve Crawford; pgsql-performance@postgreSQL.org;=20 > pgsql-hackers@postgreSQL.org > Subject: Re: [HACKERS] Terrible performance on wide selects=20 >=20 >=20 > "Dann Corbit" writes: > > Maybe I don't really understand the problem, but it seems simple=20 > > enough to do it once for the whole query. >=20 > We already do cache column offsets when they are fixed. The=20 > code that's the problem executes when there's a=20 > variable-width column in the table > --- which means that all columns to its right are not at=20 > fixed offsets, and have to be scanned for separately in each=20 > tuple, AFAICS. Why not waste a bit of memory and make the row buffer the maximum possible length? E.g. for varchar(2000) allocate 2000 characters + size element and point to the start of that thing. If we have 64K rows, even at that it is a pittance. If someone designs 10,000 row tables, then it will allocate an annoyingly large block of memory, but bad designs are always going to cause a fuss. From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:35:36 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0FD50476E52; Wed, 22 Jan 2003 19:35:30 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id D5F5F476026; Wed, 22 Jan 2003 19:17:09 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2322649; Wed, 22 Jan 2003 16:17:16 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane , pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org Subject: Re: [PERFORM] Proposal: relaxing link between explicit JOINs and execution order Date: Wed, 22 Jan 2003 16:17:41 -0800 X-Mailer: KMail [version 1.4] References: <25071.1043276513@sss.pgh.pa.us> In-Reply-To: <25071.1043276513@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301221617.41680.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/856 X-Sequence-Number: 34466 Tom, I am very strongly in favor of this idea. I would personally prefer it if= =20 the Join collapsing parmeter could be set at query time through a SET=20 statement, but will of course defer to the difficulty level in doing so. > Comments? In particular, can anyone think of pithy names for these > variables? The best I'd been able to come up with is MAX_JOIN_COLLAPSE > and MAX_FROM_COLLAPSE, but neither of these exactly sing... How about: EXPLICIT_JOIN_MINIMUM and FROM_COLLAPSE_LIMIT Just to make the two params not sound so identical? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:35:50 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 43A17477178; Wed, 22 Jan 2003 19:35:49 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 71418476680; Wed, 22 Jan 2003 19:18:07 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0N0I75u025623; Wed, 22 Jan 2003 19:18:07 -0500 (EST) To: "Dann Corbit" Cc: "Steve Crawford" , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org Subject: Re: Terrible performance on wide selects In-reply-to: References: Comments: In-reply-to "Dann Corbit" message dated "Wed, 22 Jan 2003 16:06:26 -0800" Date: Wed, 22 Jan 2003 19:18:07 -0500 Message-ID: <25622.1043281087@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/857 X-Sequence-Number: 34467 "Dann Corbit" writes: > Why not waste a bit of memory and make the row buffer the maximum > possible length? > E.g. for varchar(2000) allocate 2000 characters + size element and point > to the start of that thing. Surely you're not proposing that we store data on disk that way. The real issue here is avoiding overhead while extracting columns out of a stored tuple. We could perhaps use a different, less space-efficient format for temporary tuples in memory than we do on disk, but I don't think that will help a lot. The nature of O(N^2) bottlenecks is you have to kill them all --- for example, if we fix printtup and don't do anything with ExecEvalVar, we can't do more than double the speed of Steve's example, so it'll still be slow. So we must have a solution for the case where we are disassembling a stored tuple, anyway. I have been sitting here toying with a related idea, which is to use the heap_deformtuple code I suggested before to form an array of pointers to Datums in a specific tuple (we could probably use the TupleTableSlot mechanisms to manage the memory for these). Then subsequent accesses to individual columns would just need an array-index operation, not a nocachegetattr call. The trick with that would be that if only a few columns are needed out of a row, it might be a net loss to compute the Datum values for all columns. How could we avoid slowing that case down while making the wide-tuple case faster? regards, tom lane From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:37:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4BDCA4771FE; Wed, 22 Jan 2003 19:37:28 -0500 (EST) Received: from voyager.corporate.connx.com (unknown [209.20.248.131]) by postgresql.org (Postfix) with ESMTP id 11828476DC3; Wed, 22 Jan 2003 19:21:16 -0500 (EST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Terrible performance on wide selects X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Date: Wed, 22 Jan 2003 16:21:18 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [HACKERS] Terrible performance on wide selects Thread-Index: AcLCdOk7m8zPEW2kS6KRnU56l4FJ/AAACQgA From: "Dann Corbit" To: "Tom Lane" Cc: "Steve Crawford" , , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/858 X-Sequence-Number: 34468 > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 > Sent: Wednesday, January 22, 2003 4:18 PM > To: Dann Corbit > Cc: Steve Crawford; pgsql-performance@postgreSQL.org;=20 > pgsql-hackers@postgreSQL.org > Subject: Re: [HACKERS] Terrible performance on wide selects=20 >=20 >=20 > "Dann Corbit" writes: > > Why not waste a bit of memory and make the row buffer the maximum=20 > > possible length? E.g. for varchar(2000) allocate 2000 characters +=20 > > size element and point to the start of that thing. >=20 > Surely you're not proposing that we store data on disk that way. >=20 > The real issue here is avoiding overhead while extracting=20 > columns out of a stored tuple. We could perhaps use a=20 > different, less space-efficient format for temporary tuples=20 > in memory than we do on disk, but I don't think that will=20 > help a lot. The nature of O(N^2) bottlenecks is you have to=20 > kill them all --- for example, if we fix printtup and don't=20 > do anything with ExecEvalVar, we can't do more than double=20 > the speed of Steve's example, so it'll still be slow. So we=20 > must have a solution for the case where we are disassembling=20 > a stored tuple, anyway. >=20 > I have been sitting here toying with a related idea, which is=20 > to use the heap_deformtuple code I suggested before to form=20 > an array of pointers to Datums in a specific tuple (we could=20 > probably use the TupleTableSlot mechanisms to manage the=20 > memory for these). Then subsequent accesses to individual=20 > columns would just need an array-index operation, not a=20 > nocachegetattr call. The trick with that would be that if=20 > only a few columns are needed out of a row, it might be a net=20 > loss to compute the Datum values for all columns. How could=20 > we avoid slowing that case down while making the wide-tuple=20 > case faster? For the disk case, why not have the start of the record contain an array of offsets to the start of the data for each column? It would only be necessary to have a list for variable fields. So (for instance) if you have 12 variable fields, you would store 12 integers at the start of the record. From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:38:10 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1882476E89; Wed, 22 Jan 2003 19:38:08 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id E3970476F45; Wed, 22 Jan 2003 19:21:43 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0N0LO5u025651; Wed, 22 Jan 2003 19:21:24 -0500 (EST) To: josh@agliodbs.com Cc: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org Subject: Re: [PERFORM] Proposal: relaxing link between explicit JOINs and execution order In-reply-to: <200301221617.41680.josh@agliodbs.com> References: <25071.1043276513@sss.pgh.pa.us> <200301221617.41680.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 22 Jan 2003 16:17:41 -0800" Date: Wed, 22 Jan 2003 19:21:24 -0500 Message-ID: <25650.1043281284@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/859 X-Sequence-Number: 34469 Josh Berkus writes: > I am very strongly in favor of this idea. I would personally prefer it if > the Join collapsing parmeter could be set at query time through a SET > statement, but will of course defer to the difficulty level in doing so. I guess I failed to make it clear that that's what I meant. GUC variables are those things that you can set via SET, or in the postgresql.conf file, etc. These values would be just as manipulable as, say, ENABLE_SEQSCAN. > How about: > EXPLICIT_JOIN_MINIMUM > and > FROM_COLLAPSE_LIMIT > Just to make the two params not sound so identical? Hmm. The two parameters would have closely related functions, so I'd sort of think that the names *should* be pretty similar. regards, tom lane From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:38:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0F135477253; Wed, 22 Jan 2003 19:38:28 -0500 (EST) Received: from voyager.corporate.connx.com (unknown [209.20.248.131]) by postgresql.org (Postfix) with ESMTP id 0D9A9476EAB; Wed, 22 Jan 2003 19:22:49 -0500 (EST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Terrible performance on wide selects X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Date: Wed, 22 Jan 2003 16:22:51 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [HACKERS] Terrible performance on wide selects Thread-Index: AcLCdOk7m8zPEW2kS6KRnU56l4FJ/AAACQgAAAAXHfA= From: "Dann Corbit" To: "Dann Corbit" , "Tom Lane" Cc: "Steve Crawford" , , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/860 X-Sequence-Number: 34470 [snip] > So (for instance) if you have 12 variable fields, you would=20 > store 12 integers at the start of the record. Additionally, you could implicitly size the integers from the properties of the column. A varchar(255) would only need an unsigned char to store the offset, but a varchar(80000) would require an unsigned int. From pgsql-hackers-owner@postgresql.org Wed Jan 22 19:49:21 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 92EAE476FB1; Wed, 22 Jan 2003 19:49:19 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id EF2054770BE; Wed, 22 Jan 2003 19:30:05 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0N0U45u025726; Wed, 22 Jan 2003 19:30:04 -0500 (EST) To: "Dann Corbit" Cc: "Steve Crawford" , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org Subject: Re: Terrible performance on wide selects In-reply-to: References: Comments: In-reply-to "Dann Corbit" message dated "Wed, 22 Jan 2003 16:21:18 -0800" Date: Wed, 22 Jan 2003 19:30:04 -0500 Message-ID: <25725.1043281804@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/861 X-Sequence-Number: 34471 "Dann Corbit" writes: > For the disk case, why not have the start of the record contain an array > of offsets to the start of the data for each column? It would only be > necessary to have a list for variable fields. No, you'd need an entry for *every* column (or at least, every one to the right of the first variable-width column or NULL). That's a lot of overhead, especially in comparison to datatypes like bool or int4 ... regards, tom lane From pgsql-hackers-owner@postgresql.org Wed Jan 22 20:14:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 35404475D99; Wed, 22 Jan 2003 20:14:47 -0500 (EST) Received: from voyager.corporate.connx.com (unknown [209.20.248.131]) by postgresql.org (Postfix) with ESMTP id AFBB64772C7; Wed, 22 Jan 2003 19:39:54 -0500 (EST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Terrible performance on wide selects X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Date: Wed, 22 Jan 2003 16:39:57 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [HACKERS] Terrible performance on wide selects Thread-Index: AcLCdOk7m8zPEW2kS6KRnU56l4FJ/AAACQgAAACuH1A= From: "Dann Corbit" To: "Dann Corbit" , "Tom Lane" Cc: "Steve Crawford" , , X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/862 X-Sequence-Number: 34472 [snip] > For the disk case, why not have the start of the record=20 > contain an array of offsets to the start of the data for each=20 > column? It would only be necessary to have a list for=20 > variable fields. >=20 > So (for instance) if you have 12 variable fields, you would=20 > store 12 integers at the start of the record. You have to store this information anyway (for variable length objects). By storing it at the front of the record you would lose nothing (except the logical coupling of an object with its length). But I would think that it would not consume any additional storage. From pgsql-performance-owner@postgresql.org Wed Jan 22 20:29:40 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0E14D47620C for ; Wed, 22 Jan 2003 20:29:40 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id CAB6A4768BF for ; Wed, 22 Jan 2003 19:59:10 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id B3591D616; Wed, 22 Jan 2003 16:59:13 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id A90665C03; Wed, 22 Jan 2003 16:59:13 -0800 (PST) Date: Wed, 22 Jan 2003 16:59:13 -0800 (PST) From: Stephan Szabo To: John Lange Cc: Subject: Re: Query plan and Inheritance. Weird behavior In-Reply-To: <1043271882.11373.158.camel@johnlaptop.darkcore.net> Message-ID: <20030122165418.Q4204-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/249 X-Sequence-Number: 896 On 22 Jan 2003, John Lange wrote: > I have a database that makes fairly extensive use of table Inheritance. > > Structure is one parent table and 5 child tables as follows: > > tbl_objects (parent table) > -> tbl_viewers > -> tbl_documents > -> tbl_icons > -> tbl_massemails > -> tbl_formats > > I have two questions: > > First, if I create an index on the parent table will queries to the > child tables use that index? AFAIK no since indices aren't inherited. > Secondly, I tried to use explain to find out but I got very strange > results. It appears to read all the child tables even when you specify > only the parent table. In this case this appears to make the select do 6 > queries instead of only 1. Obviously a huge performance hit. And none of > them uses the index though the table only has 420 rows at the moment so > that might be why its just doing a scan (though IMHO 'explain' should > explain that it isn't using the available index and why). It seems reasonable to me since given the # of rows and the estimated row width the table is probably only like 5 or 6 pages. Reading the index is unlikely to make life much better given an index read, seek in heap file, read heap file page. > I can't say that I'm reading these results properly but here they are: > > "EXPLAIN select * from tbl_objects where id = 1;" This gets any rows in tbl_objects that have id=1 and any rows in any subtables that have id=1. Is that the intended effect? From pgsql-performance-owner@postgresql.org Wed Jan 22 21:11:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 41AA8475D99 for ; Wed, 22 Jan 2003 21:11:56 -0500 (EST) Received: from johnlaptop.darkcore.net (h24-82-231-93.wp.shawcable.net [24.82.231.93]) by postgresql.org (Postfix) with ESMTP id EE3A3475AE4 for ; Wed, 22 Jan 2003 21:11:54 -0500 (EST) Received: by johnlaptop.darkcore.net (Postfix, from userid 501) id 1DA89F1EB4; Wed, 22 Jan 2003 21:11:57 -0500 (EST) Subject: Re: Query plan and Inheritance. Weird behavior From: John Lange To: Stephan Szabo Cc: pgsql-performance@postgresql.org In-Reply-To: <20030122165418.Q4204-100000@megazone23.bigpanda.com> References: <20030122165418.Q4204-100000@megazone23.bigpanda.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8-3mdk Date: 22 Jan 2003 20:11:56 -0600 Message-Id: <1043287916.2142.76.camel@johnlaptop.darkcore.net> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/250 X-Sequence-Number: 897 > This gets any rows in tbl_objects that have id=1 and any rows in any > subtables that have id=1. Is that the intended effect? It is the intended result, but not the expected implementation. Doing more investigation I think I figured out why Postgres does what it does. Creating child tables by inheriting from another table doesn't really do what I consider to be 'true' inheritance, at least not in the way I expected as a programmer. Postgres seems to create "child" tables by first fully duplicating the parent table and then adding the new columns to it. It then links the tables internally some how so that a query on a parent table also queries the child tables. IHO this seems like inheritance by 'brute force' and a parent table that has many children will cause a significant performance hit. When I say "as a programmer" what I mean is I had expected it to be done entirely the opposite way. In other words, child tables would simply be linked internally to the parent table and a new table created which only contains the new columns. In this way the parent table would not need to know, nor would it care about child tables in any way (just like inheritance in most programming languages). If done this way a select on a parent table would only require the retrieval of a single row and a select on a child table would only require the retrieval of two rows (one in the child table and one in the parent table). I don't pretend to know the intricacies of Postgres performance but this is the way I'm interpreting the data from the explains. At this time, now that I (think I) understand how the inheritance is implemented I'm considering abandoning it in Postgres and solving the issue entirely pragmatically. I hoping someone on the list will tell me where I'm going wrong here or what wrong assumptions I'm making. John Lange On Wed, 2003-01-22 at 18:59, Stephan Szabo wrote: > > On 22 Jan 2003, John Lange wrote: > > > I have a database that makes fairly extensive use of table Inheritance. > > > > Structure is one parent table and 5 child tables as follows: > > > > tbl_objects (parent table) > > -> tbl_viewers > > -> tbl_documents > > -> tbl_icons > > -> tbl_massemails > > -> tbl_formats > > > > I have two questions: > > > > First, if I create an index on the parent table will queries to the > > child tables use that index? > > AFAIK no since indices aren't inherited. > > > Secondly, I tried to use explain to find out but I got very strange > > results. It appears to read all the child tables even when you specify > > only the parent table. In this case this appears to make the select do 6 > > queries instead of only 1. Obviously a huge performance hit. And none of > > them uses the index though the table only has 420 rows at the moment so > > that might be why its just doing a scan (though IMHO 'explain' should > > explain that it isn't using the available index and why). > > It seems reasonable to me since given the # of rows and the estimated > row width the table is probably only like 5 or 6 pages. Reading the index > is unlikely to make life much better given an index read, seek in heap > file, read heap file page. > > > I can't say that I'm reading these results properly but here they are: > > > > "EXPLAIN select * from tbl_objects where id = 1;" > > This gets any rows in tbl_objects that have id=1 and any rows in any > subtables that have id=1. Is that the intended effect? > > From pgsql-performance-owner@postgresql.org Wed Jan 22 21:27:22 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4E757475D99 for ; Wed, 22 Jan 2003 21:27:21 -0500 (EST) Received: from spirit.aldeiadigital.com.br (iplus-fac-137.xdsl-fixo.ctbcnetsuper.com.br [200.225.213.137]) by postgresql.org (Postfix) with ESMTP id BE14C475AE4 for ; Wed, 22 Jan 2003 21:27:18 -0500 (EST) Received: from aldeiadigital.com.br (localhost.localdomain [127.0.0.1]) by spirit.aldeiadigital.com.br (8.11.6/8.11.6) with SMTP id h0N2Qil03476 for ; Thu, 23 Jan 2003 00:26:44 -0200 Received: from 200.225.202.15 (SquirrelMail authenticated user alepaes) by webmail.ad2.com.br with HTTP; Thu, 23 Jan 2003 00:26:44 -0200 (BRST) Message-ID: <10635.200.225.202.15.1043288804.squirrel@webmail.ad2.com.br> Date: Thu, 23 Jan 2003 00:26:44 -0200 (BRST) Subject: Same query, same performance From: "alexandre :: aldeia digital" To: X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal X-Mailer: SquirrelMail (version 1.2.7) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/251 X-Sequence-Number: 898 Hi all, First, sorry for the long mail... I have a system with 7 Million of records in 600 tables. My actual production machine is: P4 1.6G, 3 IDE 7200, 1GB PC133 My new machine production is: Dual Xeon 2.0G HT, 1GB DDR266 ECC 3 SCSI with HW Raid 5 The postgresql.conf is the SAME in both systems and I test with no other connections, only my local test. shared_buffers = 80000 effective_cache_size = 60000 random_page_cost = 2.5 cpu_tuple_cost = 0.001 cpu_index_tuple_cost = 0.0001 cpu_operator_cost = 0.00025 My question is: If I execute the same query executed a lot of times, the duration is praticaly the same in both systems ? 1) ! 1.185424 elapsed 1.090000 user 0.100000 system sec 2) ! 1.184415 elapsed 1.070000 user 0.120000 system sec 3) ! 1.185209 elapsed 1.100000 user 0.080000 system sec If the disks is not read directly, the system must find the rows in RAM. If it find in RAM, why so diffrents machines have the times of execution and why the times does not down ??? The variations of query show bellow have the times pratically equals and my system send thousands os this querys with a thousands of 1.18 seconds... :( Very thank�s Alexandre Query: [postgres@host1 data]$ psql -c "explain SELECT T2.fi15emp05, T2.fi15flagcf, T2.fi15codcf, T1.Fn06Emp07, T1.Fn06TipTit, T1.Fn06TitBan, T1.Fn06Conta1, T1.Fn06NumTit, T1.Fn06Desdob, T1.Fn05CodPre, T1.Fn06eCli1, T1.Fn06tCli1, T1.Fn06cCli1, T2.fi15nome FROM (FN06T T1 LEFT JOIN FI15T T2 ON T2.fi15emp05 = T1.Fn06eCli1 AND T2.fi15flagcf = T1.Fn06tCli1 AND T2.fi15codcf = T1.Fn06cCli1) WHERE ( T1.Fn06Emp07 = '1' AND T1.Fn06TipTit = 'R' ) AND ( T1.Fn06TitBan = '002021001525 ' ) ORDER BY T1.Fn06Emp07, T1.Fn06TipTit, T1.Fn06NumTit, T1.Fn06Desdob, T1.Fn05CodPre, T1.Fn06eCli1, T1.Fn06tCli1, T1.Fn06cCli1" Pro13Z QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=25875.53..25875.53 rows=15 width=155) Sort Key: t1.fn06emp07, t1.fn06tiptit, t1.fn06numtit, t1.fn06desdob, t1.fn05codpre, t1.fn06ecli1, t1.fn06tcli1, t1.fn06ccli1 -> Nested Loop (cost=0.00..25875.50 rows=15 width=155) -> Seq Scan on fn06t t1 (cost=0.00..25808.30 rows=15 width=95) Filter: ((fn06emp07 = 1::smallint) AND (fn06tiptit = 'R'::bpchar) AND (fn06titban = '002021001525 '::bpchar)) -> Index Scan using fi15t_pkey on fi15t t2 (cost=0.00..4.33 rows=1 width=60) Index Cond: ((t2.fi15emp05 = "outer".fn06ecli1) AND (t2.fi15flagcf = "outer".fn06tcli1) AND (t2.fi15codcf = "outer".fn06ccli1)) (7 rows) *** AND FROM LOG when a execute the query: 2003-01-23 00:09:49 [3372] LOG: duration: 1.285900 sec 2003-01-23 00:09:49 [3372] LOG: QUERY STATISTICS ! system usage stats: ! 1.286001 elapsed 1.240000 user 0.040000 system sec ! [1.250000 user 0.040000 sys total] ! 0/0 [0/0] filesystem blocks in/out ! 50526/130 [50693/372] page faults/reclaims, 0 [0] swaps ! 0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent ! 0/0 [0/0] voluntary/involuntary context switches ! buffer usage stats: ! Shared blocks: 0 read, 0 written, buffer hit rate = 100.00% ! Local blocks: 0 read, 0 written, buffer hit rate = 0.00% ! Direct blocks: 0 read, 0 written From pgsql-performance-owner@postgresql.org Wed Jan 22 21:45:16 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6D0E04760DF for ; Wed, 22 Jan 2003 21:45:15 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id A513A4760B7 for ; Wed, 22 Jan 2003 21:45:14 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 88368D616; Wed, 22 Jan 2003 18:45:18 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 7DEF35C03; Wed, 22 Jan 2003 18:45:18 -0800 (PST) Date: Wed, 22 Jan 2003 18:45:18 -0800 (PST) From: Stephan Szabo To: John Lange Cc: Subject: Re: Query plan and Inheritance. Weird behavior In-Reply-To: <1043287916.2142.76.camel@johnlaptop.darkcore.net> Message-ID: <20030122183939.I5182-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/252 X-Sequence-Number: 899 On 22 Jan 2003, John Lange wrote: > Creating child tables by inheriting from another table doesn't really do > what I consider to be 'true' inheritance, at least not in the way I > expected as a programmer. > > Postgres seems to create "child" tables by first fully duplicating the > parent table and then adding the new columns to it. It then links the > tables internally some how so that a query on a parent table also > queries the child tables. That pretty much sums up my understanding of it. [snip] > In this way the parent table would not need to know, nor would it care > about child tables in any way (just like inheritance in most programming > languages). If done this way a select on a parent table would only > require the retrieval of a single row and a select on a child table > would only require the retrieval of two rows (one in the child table and > one in the parent table). As opposed to needing one row from a select on a child table and effectively a union all when selecting from the parent. There are up and down sides of both implementations, and I haven't played with it enough to speak meaningfully on it. > I don't pretend to know the intricacies of Postgres performance but this > is the way I'm interpreting the data from the explains. As a side note, for a better understanding of timings, explain analyze is much better than plain explain which only gives the plan and estimates. From pgsql-performance-owner@postgresql.org Thu Jan 23 01:08:20 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1EDCE476501 for ; Thu, 23 Jan 2003 01:08:17 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 2E26C476393 for ; Thu, 23 Jan 2003 01:07:50 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0N67l5u023642; Thu, 23 Jan 2003 01:07:47 -0500 (EST) To: Stephan Szabo Cc: John Lange , pgsql-performance@postgresql.org Subject: Re: Query plan and Inheritance. Weird behavior In-reply-to: <20030122183939.I5182-100000@megazone23.bigpanda.com> References: <20030122183939.I5182-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Wed, 22 Jan 2003 18:45:18 -0800" Date: Thu, 23 Jan 2003 01:07:47 -0500 Message-ID: <23641.1043302067@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/253 X-Sequence-Number: 900 > On 22 Jan 2003, John Lange wrote: >> In this way the parent table would not need to know, nor would it care >> about child tables in any way (just like inheritance in most programming >> languages). If done this way a select on a parent table would only >> require the retrieval of a single row and a select on a child table >> would only require the retrieval of two rows (one in the child table and >> one in the parent table). No, it'd require the retrieval of N rows: you're failing to think about multiple levels of inheritance or multi-parent inheritance, both of which are supported reasonably effectively by the current model. My guess is that this scheme would crash and burn just on locking considerations. (When you want to update a child row, what locks do you have to get in what order? With pieces of the row scattered through many tables, it'd be pretty messy.) You may care to look in the pghackers archives for prior discussions. The variant scheme that's sounded most interesting to me so far is to store *all* rows of an inheritance hierarchy in a single physical table. This'd require giving up multiple inheritance, but few people seem to use that, and the other benefits (like being able to enforce uniqueness constraints over the whole hierarchy with just a standard unique index) seem worth it. No one's stepped up to bat to do the legwork on the idea yet, though. One bit that looks pretty tricky is ALTER TABLE ADD COLUMN. regards, tom lane From pgsql-general-owner@postgresql.org Thu Jan 23 17:24:22 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8F1A4476FB1 for ; Thu, 23 Jan 2003 03:21:30 -0500 (EST) Received: from mail.sarkor.com (unknown [81.95.224.36]) by postgresql.org (Postfix) with SMTP id 5BBE94769B2 for ; Thu, 23 Jan 2003 03:14:24 -0500 (EST) Received: (qmail 8423 invoked by uid 507); 23 Jan 2003 08:14:20 -0000 Received: from thor@sarkor.com by mail.sarkor.com by uid 504 with qmail-scanner-1.14 (clamscan: 0.51. Clear:. Processed in 0.685745 secs); 23 Jan 2003 08:14:20 -0000 Received: from unknown (HELO timur) (81.95.224.66) by mail.sarkor.com with SMTP; 23 Jan 2003 08:14:19 -0000 Date: Thu, 23 Jan 2003 13:14:25 +0500 From: Timur Irmatov X-Mailer: The Bat! (v1.61) Reply-To: Timur Irmatov X-Priority: 3 (Normal) Message-ID: <746750156.20030123131425@sarkor.com> To: pgsql-performance@postgresql.org Cc: pgsql-general@postgresql.org Subject: types & index usage MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/967 X-Sequence-Number: 36088 Hi! I have a table with year, month, day and hour fields (all SMALLINT type). Selecting one row from it takes about 40 msecs, and I am trying now to use DATE type instead of first three fields. Now select time decreased to less than millisecond, but I found that i must use this form: hour=10::smallint instead of simple hour=10, because in the latter case PostgreSQL does sequential scan. I've heard something about type coercion issues, so I just want to say that it is very funny to see such sort of things... From pgsql-performance-owner@postgresql.org Thu Jan 23 03:23:55 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E71A5476837 for ; Thu, 23 Jan 2003 03:23:53 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 32F45476653 for ; Thu, 23 Jan 2003 03:15:39 -0500 (EST) Received: from klaster.net (pa158.krakow.cvx.ppp.tpnet.pl [213.76.36.158]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 5CFE22B87B for ; Thu, 23 Jan 2003 09:11:13 +0100 (CET) Message-ID: <3E2FA5B9.1030105@klaster.net> Date: Thu, 23 Jan 2003 09:20:09 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.2b) Gecko/20021016 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Same query, same performance References: <10635.200.225.202.15.1043288804.squirrel@webmail.ad2.com.br> In-Reply-To: <10635.200.225.202.15.1043288804.squirrel@webmail.ad2.com.br> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/255 X-Sequence-Number: 902 alexandre :: aldeia digital wrote: >Hi all, > >First, sorry for the long mail... > >I have a system with 7 Million of records in 600 tables. >My actual production machine is: P4 1.6G, 3 IDE 7200, 1GB PC133 >My new machine production is: Dual Xeon 2.0G HT, 1GB DDR266 ECC >3 SCSI with HW Raid 5 > >The postgresql.conf is the SAME in both systems and I test >with no other connections, only my local test. > >shared_buffers = 80000 >effective_cache_size = 60000 >random_page_cost = 2.5 >cpu_tuple_cost = 0.001 >cpu_index_tuple_cost = 0.0001 >cpu_operator_cost = 0.00025 > >My question is: > >If I execute the same query executed a lot of times, the >duration is praticaly the same in both systems ? > >1) ! 1.185424 elapsed 1.090000 user 0.100000 system sec >2) ! 1.184415 elapsed 1.070000 user 0.120000 system sec >3) ! 1.185209 elapsed 1.100000 user 0.080000 system sec > >If the disks is not read directly, the system must find >the rows in RAM. If it find in RAM, why so diffrents machines >have the times of execution and why the times does not down ??? Here is your problem: -> Seq Scan on fn06t t1 (cost=0.00..25808.30 rows=15 width=95) Filter: ((fn06emp07 = 1::smallint) AND (fn06tiptit = 'R'::bpchar) AND (fn06titban = '002021001525 '::bpchar)) Problably system has to read from disk whole table fn06t each time, beacuse it doesn't use index scan. Do you have any indexes on table fn06t? How selective are conditions above How big is this table? Can you use indexes on multiple fields on this table - it should help, because conditions above return only 15 rows? Regards, Tomasz Myrta From pgsql-general-owner@postgresql.org Thu Jan 23 04:16:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8CBA44762B0; Thu, 23 Jan 2003 04:16:16 -0500 (EST) Received: from biomax.de (unknown [212.6.137.236]) by postgresql.org (Postfix) with ESMTP id 76DEF475ADE; Thu, 23 Jan 2003 04:16:04 -0500 (EST) Received: from biomax.de (guffert.biomax.de [192.168.3.166]) by biomax.de (8.8.8/8.8.8) with ESMTP id KAA04877; Thu, 23 Jan 2003 10:16:01 +0100 Message-ID: <3E2FB2D1.9020904@biomax.de> Date: Thu, 23 Jan 2003 10:16:01 +0100 From: Chantal Ackermann User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stephan Szabo Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: optimizing query References: <20030122081422.Y96911-100000@megazone23.bigpanda.com> In-Reply-To: <20030122081422.Y96911-100000@megazone23.bigpanda.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/911 X-Sequence-Number: 36032 hi Stephan, thank you for your reply. I ran vacuum analyze before calling explain. As this is a newly built database where no rows have been deleted, yet, I thought vacuum full would have no effect. In fact, BEFORE running vacuum full, the cost of the query is estimates by explain analyze as 33 secs, and AFTER running it, the cost is estimate to be 43 secs??? (Hey, I want at least the 10 secs back ;-) ) I have just installed this database on a "bigger" (see the system info further down) machine, and I expected the queries would run _really_ fast. especially, as there is a lot more data to be inserted in the occurrences tables. This is the row count of the tables and the output of explain analyze before and after running vacuum full (after that, I listed some system and postgresql information): relate=# select count(*) from gene; count -------- 218085 (1 row) relate=# select count(*) from disease; count -------- 164597 (1 row) relate=# select count(*) from disease_occurrences_puid; count -------- 471915 (1 row) relate=# select count(*) from gene_occurrences_puid; count -------- 339347 (1 row) relate=# explain analyze SELECT DISTINCT gene.gene_name, gene_occurrences_puid.puid FROM gene, disease_occurrences_puid, gene_occurrences_puid WHERE disease_occurrences_puid.puid=gene_occurrences_puid.puid AND gene.gene_id=gene_occurrences_puid.gene_id; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Unique (cost=342175.89..352511.77 rows=137812 width=33) (actual time=32112.66..33139.23 rows=219435 loops=1) -> Sort (cost=342175.89..345621.18 rows=1378118 width=33) (actual time=32112.65..32616.14 rows=695158 loops=1) Sort Key: gene.gene_name, gene_occurrences_puid.puid -> Merge Join (cost=63671.50..98237.36 rows=1378118 width=33) (actual time=10061.83..17940.02 rows=695158 loops=1) Merge Cond: ("outer".puid = "inner".puid) -> Index Scan using disease_occpd_puid_i on disease_occurrences_puid (cost=0.00..14538.05 rows=471915 width=4) (actual time=0.03..3917.99 rows=471915 loops=1) -> Sort (cost=63671.50..64519.87 rows=339347 width=29) (actual time=10061.69..10973.64 rows=815068 loops=1) Sort Key: gene_occurrences_puid.puid -> Merge Join (cost=0.00..22828.18 rows=339347 width=29) (actual time=0.21..3760.59 rows=339347 loops=1) Merge Cond: ("outer".gene_id = "inner".gene_id) -> Index Scan using gene_pkey on gene (cost=0.00..7668.59 rows=218085 width=21) (actual time=0.02..955.19 rows=218073 loops=1) -> Index Scan using gene_id_puid_uni on gene_occurrences_puid (cost=0.00..9525.57 rows=339347 width=8) (actual time=0.02..1523.81 rows=339347 loops=1) Total runtime: 33244.81 msec (13 rows) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AFTER relate=# vacuum full verbose analyze; relate=# explain analyze SELECT DISTINCT gene.gene_name, gene_occurrences_puid.puid FROM gene, disease_occurrences_puid, gene_occurrences_puid WHERE disease_occurrences_puid.puid=gene_occurrences_puid.puid AND gene.gene_id=gene_occurrences_puid.gene_id; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Unique (cost=359069.64..369948.41 rows=145050 width=33) (actual time=42195.60..43229.04 rows=219435 loops=1) -> Sort (cost=359069.64..362695.90 rows=1450503 width=33) (actual time=42195.59..42694.70 rows=695158 loops=1) Sort Key: gene.gene_name, gene_occurrences_puid.puid -> Merge Join (cost=63732.51..99264.24 rows=1450503 width=33) (actual time=13172.40..27973.79 rows=695158 loops=1) Merge Cond: ("outer".puid = "inner".puid) -> Index Scan using disease_occpd_puid_i on disease_occurrences_puid (cost=0.00..14543.06 rows=471915 width=4) (actual time=36.50..10916.29 rows=471915 loops=1) -> Sort (cost=63732.51..64580.88 rows=339347 width=29) (actual time=13126.56..14048.38 rows=815068 loops=1) Sort Key: gene_occurrences_puid.puid -> Merge Join (cost=0.00..22889.19 rows=339347 width=29) (actual time=58.00..6775.55 rows=339347 loops=1) Merge Cond: ("outer".gene_id = "inner".gene_id) -> Index Scan using gene_pkey on gene (cost=0.00..7739.91 rows=218085 width=21) (actual time=29.00..3416.01 rows=218073 loops=1) -> Index Scan using gene_id_puid_uni on gene_occurrences_puid (cost=0.00..9525.57 rows=339347 width=8) (actual time=28.69..1936.83 rows=339347 loops=1) Total runtime: 43338.94 msec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Postgres Version: 7.3.1 CPU: 1666.767 MHz RAM: 2070492 kB shmmax/shmall: 1048576000 postgresql.conf: shared_buffers: 121600 max_connections: 64 max_fsm_relations = 200 max_fsm_pages = 40000 effective_cache_size = 8000 ******************************************************************** Thank you again for your interest and help! Chantal Stephan Szabo wrote: > (Replying to general and performance in a hope to move this > to performance after a couple of replies). > > On Wed, 22 Jan 2003, Chantal Ackermann wrote: > > >>I am getting the following output from EXPLAIN, concerning a query with >>joins. The merge uses index scans but takes too long, in my opinion. The >>query is in fact only a part (subquery) of another one, but it is the >>bottle neck. >> >>As I am quite ignorant in optimizing queries, and I have no idea where >>to find documentation on the net on how to learn optimizing my queries, >>I am posting this here in hope someone will give me either tips how to >>optimize, or where to find some tutorial that could help me get along on >>my own. >> >>dropping the "DISTINCT" has some effect, but I can't really do without. > > > The first thing is, have you done ANALYZE recently to make sure that the > statistics are correct and what does EXPLAIN ANALYZE give you (that will > run the query and give the estimate and actual). Also, if you haven't > vacuumed recently, you may want to vacuum full. > > How many rows are there on gene, disease and both occurrances tables? > I'd wonder if perhaps using explicit sql join syntax (which postgres uses > to constrain order) to join disease and disease_occurrences_puid before > joining it to the other two would be better or worse in practice. > > From pgsql-hackers-owner@postgresql.org Thu Jan 23 05:12:36 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3C26F476279; Thu, 23 Jan 2003 05:12:34 -0500 (EST) Received: from localhost.localdomain (unknown [194.204.44.121]) by postgresql.org (Postfix) with ESMTP id 9192D475AE4; Thu, 23 Jan 2003 05:12:19 -0500 (EST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h0NABSHf002506; Thu, 23 Jan 2003 12:11:28 +0200 Received: (from hannu@localhost) by localhost.localdomain (8.12.5/8.12.5/Submit) id h0NAB87w002504; Thu, 23 Jan 2003 12:11:08 +0200 X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: Terrible performance on wide selects From: Hannu Krosing To: Tom Lane Cc: Dann Corbit , Steve Crawford , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org In-Reply-To: <25622.1043281087@sss.pgh.pa.us> References: <25622.1043281087@sss.pgh.pa.us> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1043316668.2348.15.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 23 Jan 2003 12:11:08 +0200 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/871 X-Sequence-Number: 34481 Tom Lane kirjutas N, 23.01.2003 kell 02:18: > "Dann Corbit" writes: > > Why not waste a bit of memory and make the row buffer the maximum > > possible length? > > E.g. for varchar(2000) allocate 2000 characters + size element and point > > to the start of that thing. > > Surely you're not proposing that we store data on disk that way. > > The real issue here is avoiding overhead while extracting columns out of > a stored tuple. We could perhaps use a different, less space-efficient > format for temporary tuples in memory than we do on disk, but I don't > think that will help a lot. The nature of O(N^2) bottlenecks is you > have to kill them all --- for example, if we fix printtup and don't do > anything with ExecEvalVar, we can't do more than double the speed of > Steve's example, so it'll still be slow. So we must have a solution for > the case where we are disassembling a stored tuple, anyway. > > I have been sitting here toying with a related idea, which is to use the > heap_deformtuple code I suggested before to form an array of pointers to > Datums in a specific tuple (we could probably use the TupleTableSlot > mechanisms to manage the memory for these). Then subsequent accesses to > individual columns would just need an array-index operation, not a > nocachegetattr call. The trick with that would be that if only a few > columns are needed out of a row, it might be a net loss to compute the > Datum values for all columns. How could we avoid slowing that case down > while making the wide-tuple case faster? make the pointer array incrementally for O(N) performance: i.e. for tuple with 100 cols, allocate an array of 100 pointers, plus keep count of how many are actually valid, so the first call to get col[5] will fill first 5 positions in the array save said nr 5 and then access tuple[ptrarray[5]] next call to get col[75] will start form col[5] and fill up to col[75] next call to col[76] will start form col[75] and fill up to col[76] next call to col[60] will just get tuple[ptrarray[60]] the above description assumes 1-based non-C arrays ;) -- Hannu Krosing From pgsql-hackers-owner@postgresql.org Thu Jan 23 05:29:09 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AB3B247628E; Thu, 23 Jan 2003 05:29:06 -0500 (EST) Received: from localhost.localdomain (unknown [194.204.44.121]) by postgresql.org (Postfix) with ESMTP id 4CD92475AE4; Thu, 23 Jan 2003 05:29:05 -0500 (EST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h0NASNHf002570; Thu, 23 Jan 2003 12:28:24 +0200 Received: (from hannu@localhost) by localhost.localdomain (8.12.5/8.12.5/Submit) id h0NASLSs002568; Thu, 23 Jan 2003 12:28:21 +0200 X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: [PERFORM] Terrible performance on wide selects From: Hannu Krosing To: Dann Corbit Cc: Tom Lane , Steve Crawford , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1043317701.2348.32.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 23 Jan 2003 12:28:21 +0200 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/872 X-Sequence-Number: 34482 Dann Corbit kirjutas N, 23.01.2003 kell 02:39: > [snip] > > For the disk case, why not have the start of the record > > contain an array of offsets to the start of the data for each > > column? It would only be necessary to have a list for > > variable fields. > > > > So (for instance) if you have 12 variable fields, you would > > store 12 integers at the start of the record. > > You have to store this information anyway (for variable length objects). > By storing it at the front of the record you would lose nothing (except > the logical coupling of an object with its length). But I would think > that it would not consume any additional storage. I don't think it will win much either (except for possible cache locality with really huge page sizes), as the problem is _not_ scanning over big strings finding their end marker, but instead is chasing long chains of pointers. There could be some merit in the idea of storing in the beginning of tuple all pointers starting with first varlen field (16 bit int should be enough) so people can minimize the overhead by moving fixlen fields to the beginning. once we have this setup, we no longer need the varlen fields /stored/ together with field data. this adds complexity of converting form (len,data) to ptr,...,data) when constructing the tuple as tuple (int,int,int,varchar,varchar) which is currently stored as (intdata1, intdata2, intdata3, (len4, vardata4), (len5,vardata5)) should be rewritten on storage to (ptr4,ptr5),(intdata1, intdata2, intdata3, vardata4,vardata5) but it seems to solve the O(N) problem quite nicely (and forces no storage growth for tuples with fixlen fields in the beginning of tuple) and we must also account for NULL fields in calculations . -- Hannu Krosing From pgsql-hackers-owner@postgresql.org Thu Jan 23 05:33:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1FA9A4768F7; Thu, 23 Jan 2003 05:32:59 -0500 (EST) Received: from localhost.localdomain (unknown [194.204.44.121]) by postgresql.org (Postfix) with ESMTP id 1BF9F476A0F; Thu, 23 Jan 2003 05:30:55 -0500 (EST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h0NAUsHf002610; Thu, 23 Jan 2003 12:30:55 +0200 Received: (from hannu@localhost) by localhost.localdomain (8.12.5/8.12.5/Submit) id h0NAUmw0002608; Thu, 23 Jan 2003 12:30:48 +0200 X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: Terrible performance on wide selects From: Hannu Krosing To: Tom Lane Cc: Dann Corbit , Steve Crawford , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org In-Reply-To: <25521.1043280242@sss.pgh.pa.us> References: <25521.1043280242@sss.pgh.pa.us> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1043317847.2347.35.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 23 Jan 2003 12:30:48 +0200 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/873 X-Sequence-Number: 34483 Tom Lane kirjutas N, 23.01.2003 kell 02:04: > "Dann Corbit" writes: > > Maybe I don't really understand the problem, but it seems simple enough > > to do it once for the whole query. > > We already do cache column offsets when they are fixed. The code that's > the problem executes when there's a variable-width column in the table > --- which means that all columns to its right are not at fixed offsets, > and have to be scanned for separately in each tuple, AFAICS. Not only varlen columns, but also NULL columns forbid knowing the offsets beforehand. -- Hannu Krosing From pgsql-hackers-owner@postgresql.org Thu Jan 23 05:44:28 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CF19A476DC6; Thu, 23 Jan 2003 05:44:24 -0500 (EST) Received: from localhost.localdomain (unknown [194.204.44.121]) by postgresql.org (Postfix) with ESMTP id 1CF06476E42; Thu, 23 Jan 2003 05:41:52 -0500 (EST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h0NAfpHf002670; Thu, 23 Jan 2003 12:41:52 +0200 Received: (from hannu@localhost) by localhost.localdomain (8.12.5/8.12.5/Submit) id h0NAfmZ1002668; Thu, 23 Jan 2003 12:41:48 +0200 X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: Terrible performance on wide selects From: Hannu Krosing To: Tom Lane Cc: Dann Corbit , Steve Crawford , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org In-Reply-To: <1043316668.2348.15.camel@localhost.localdomain> References: <25622.1043281087@sss.pgh.pa.us> <1043316668.2348.15.camel@localhost.localdomain> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1043318508.2347.39.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 23 Jan 2003 12:41:48 +0200 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/874 X-Sequence-Number: 34484 Hannu Krosing kirjutas N, 23.01.2003 kell 12:11: > make the pointer array incrementally for O(N) performance: > > i.e. for tuple with 100 cols, allocate an array of 100 pointers, plus > keep count of how many are actually valid, Additionally, this should also make repeted determining of NULL fields faster - just put a NULL-pointer in and voila - no more bit-shifting and AND-ing to find out if the field is null. One has to watch the NULL bitmap on fist pass anyway. > so the first call to get col[5] will fill first 5 positions in the array > save said nr 5 and then access tuple[ptrarray[5]] > > next call to get col[75] will start form col[5] and fill up to col[75] > > next call to col[76] will start form col[75] and fill up to col[76] > > next call to col[60] will just get tuple[ptrarray[60]] > > the above description assumes 1-based non-C arrays ;) -- Hannu Krosing From pgsql-hackers-owner@postgresql.org Thu Jan 23 05:56:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 82BD7476EF4; Thu, 23 Jan 2003 05:56:09 -0500 (EST) Received: from dcave.digsys.bg (dcave.digsys.bg [192.92.129.5]) by postgresql.org (Postfix) with ESMTP id 4AAA14765DD; Thu, 23 Jan 2003 05:49:56 -0500 (EST) Received: from dcave.digsys.bg (daniel@localhost.digsys.bg [127.0.0.1]) by dcave.digsys.bg (8.11.6/8.10.1) with ESMTP id h0NAi8Y21333; Thu, 23 Jan 2003 12:44:12 +0200 (EET) Message-Id: <200301231044.h0NAi8Y21333@dcave.digsys.bg> X-Mailer: exmh version 2.1.0 09/18/1999 To: Hannu Krosing Cc: Tom Lane , Dann Corbit , Steve Crawford , pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Terrible performance on wide selects In-reply-to: Your message of "23 Jan 2003 12:30:48 +0200." <1043317847.2347.35.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 23 Jan 2003 12:44:04 +0200 From: Daniel Kalchev X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/875 X-Sequence-Number: 34485 >>>Hannu Krosing said: > Tom Lane kirjutas N, 23.01.2003 kell 02:04: > > We already do cache column offsets when they are fixed. The code that's > > the problem executes when there's a variable-width column in the table > > --- which means that all columns to its right are not at fixed offsets, > > and have to be scanned for separately in each tuple, AFAICS. > > Not only varlen columns, but also NULL columns forbid knowing the > offsets beforehand. Does this mean, that constructing tables where fixed length fields are 'before' variable lenght fields and 'possibly null' fields might increase performance? Daniel From pgsql-hackers-owner@postgresql.org Thu Jan 23 09:42:05 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 265904769B2 for ; Thu, 23 Jan 2003 09:42:01 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id C58794768C4 for ; Thu, 23 Jan 2003 09:41:36 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0NEfP5u025662; Thu, 23 Jan 2003 09:41:25 -0500 (EST) To: Hannu Krosing Cc: Dann Corbit , Steve Crawford , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org Subject: Re: Terrible performance on wide selects In-reply-to: <1043318508.2347.39.camel@localhost.localdomain> References: <25622.1043281087@sss.pgh.pa.us> <1043316668.2348.15.camel@localhost.localdomain> <1043318508.2347.39.camel@localhost.localdomain> Comments: In-reply-to Hannu Krosing message dated "23 Jan 2003 12:41:48 +0200" Date: Thu, 23 Jan 2003 09:41:25 -0500 Message-ID: <25661.1043332885@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/881 X-Sequence-Number: 34491 Hannu Krosing writes: >> i.e. for tuple with 100 cols, allocate an array of 100 pointers, plus >> keep count of how many are actually valid, > Additionally, this should also make repeted determining of NULL fields > faster - just put a NULL-pointer in and voila - no more bit-shifting and > AND-ing to find out if the field is null. Right, the output of the operation would be a pair of arrays: Datum values and is-null flags. (NULL pointers don't work for pass-by-value datatypes.) I like the idea of keeping track of a last-known-column position and incrementally extending that as needed. I think the way to manage this is to add the overhead data (the output arrays and last-column state) to TupleTableSlots. Then we'd have a routine similar to heap_getattr except that it takes a TupleTableSlot and makes use of the extra state data. The infrastructure to manage the state data is already in place: for example, ExecStoreTuple would reset the last-known-column to 0, ExecSetSlotDescriptor would be responsible for allocating the output arrays using the natts value from the provided tupdesc, etc. This wouldn't help for accesses that are not in the context of a slot, but certainly all the ones from ExecEvalVar are. The executor always works with tuples stored in slots, so I think we could fix all the high-traffic cases this way. regards, tom lane From pgsql-hackers-owner@postgresql.org Thu Jan 23 09:47:42 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 178A1476910 for ; Thu, 23 Jan 2003 09:47:41 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id DE3FF476A55 for ; Thu, 23 Jan 2003 09:46:52 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0NEko5u025702; Thu, 23 Jan 2003 09:46:51 -0500 (EST) To: Hannu Krosing Cc: Dann Corbit , Steve Crawford , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org Subject: Re: [PERFORM] Terrible performance on wide selects In-reply-to: <1043317701.2348.32.camel@localhost.localdomain> References: <1043317701.2348.32.camel@localhost.localdomain> Comments: In-reply-to Hannu Krosing message dated "23 Jan 2003 12:28:21 +0200" Date: Thu, 23 Jan 2003 09:46:50 -0500 Message-ID: <25701.1043333210@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/882 X-Sequence-Number: 34492 Hannu Krosing writes: > as tuple (int,int,int,varchar,varchar) > which is currently stored as > (intdata1, intdata2, intdata3, (len4, vardata4), (len5,vardata5)) > should be rewritten on storage to > (ptr4,ptr5),(intdata1, intdata2, intdata3, vardata4,vardata5) I do not see that this buys anything at all. heap_getattr still has to make essentially the same calculation as before to determine column locations, namely adding up column widths. All you've done is move the data that it has to fetch to make the calculation. If anything, this will be slower not faster, because now heap_getattr has to keep track of two positions not one --- not just the next column offset, but also the index of the next "ptr" to use. In the existing method it only needs the column offset, because that's exactly where it can pick up the next length from. But the really serious objection is that the datatype functions that access the data would now also need to be passed two pointers, since after all they would like to know the length too. That breaks APIs far and wide :-( regards, tom lane From pgsql-hackers-owner@postgresql.org Thu Jan 23 09:52:48 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 22295475FB0 for ; Thu, 23 Jan 2003 09:52:46 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 2669A476FAE for ; Thu, 23 Jan 2003 09:50:24 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0NEo25u025739; Thu, 23 Jan 2003 09:50:03 -0500 (EST) To: Daniel Kalchev Cc: Hannu Krosing , Dann Corbit , Steve Crawford , pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Terrible performance on wide selects In-reply-to: <200301231044.h0NAi8Y21333@dcave.digsys.bg> References: <200301231044.h0NAi8Y21333@dcave.digsys.bg> Comments: In-reply-to Daniel Kalchev message dated "Thu, 23 Jan 2003 12:44:04 +0200" Date: Thu, 23 Jan 2003 09:50:02 -0500 Message-ID: <25738.1043333402@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/883 X-Sequence-Number: 34493 Daniel Kalchev writes: > Does this mean, that constructing tables where fixed length fields are > 'before' variable lenght fields and 'possibly null' fields might increase > performance? There'd have to be no nulls, period, to get any useful performance difference --- but yes, in theory putting fixed-length columns before variable-length ones is a win. I wouldn't bother going out to rearrange your schemas though ... at least not before you do some tests to prove that it's worthwhile. regards, tom lane From pgsql-general-owner@postgresql.org Thu Jan 23 10:09:22 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4ADCA476F9A; Thu, 23 Jan 2003 10:09:20 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 8FE98476F74; Thu, 23 Jan 2003 10:05:24 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A4E17D61B; Thu, 23 Jan 2003 07:05:28 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 9895D5C03; Thu, 23 Jan 2003 07:05:28 -0800 (PST) Date: Thu, 23 Jan 2003 07:05:28 -0800 (PST) From: Stephan Szabo To: Chantal Ackermann Cc: , Subject: Re: optimizing query In-Reply-To: <3E2FB2D1.9020904@biomax.de> Message-ID: <20030123070120.Y11731-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/924 X-Sequence-Number: 36045 On Thu, 23 Jan 2003, Chantal Ackermann wrote: > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > Postgres Version: 7.3.1 > CPU: 1666.767 MHz > RAM: 2070492 kB > shmmax/shmall: 1048576000 > > postgresql.conf: > shared_buffers: 121600 > max_connections: 64 > max_fsm_relations = 200 > max_fsm_pages = 40000 > effective_cache_size = 8000 > > ******************************************************************** Hmm, how about how many pages are in the various tables, (do a vacuum verbose for the various tables and what is sort_mem set to? It's picking the index scan to get the tables in sorted order, but I wonder if that's really the best plan given it's getting a large portion of the tables. Hmm, what does it do if you set enable_indexscan=off; ? From pgsql-general-owner@postgresql.org Thu Jan 23 10:39:45 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 41E5F475A9E; Thu, 23 Jan 2003 10:39:43 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 9737A476FAE; Thu, 23 Jan 2003 10:26:22 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0NFQJ5u025977; Thu, 23 Jan 2003 10:26:19 -0500 (EST) To: Chantal Ackermann Cc: Stephan Szabo , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] optimizing query In-reply-to: <3E2FB2D1.9020904@biomax.de> References: <20030122081422.Y96911-100000@megazone23.bigpanda.com> <3E2FB2D1.9020904@biomax.de> Comments: In-reply-to Chantal Ackermann message dated "Thu, 23 Jan 2003 10:16:01 +0100" Date: Thu, 23 Jan 2003 10:26:19 -0500 Message-ID: <25976.1043335579@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/927 X-Sequence-Number: 36048 Chantal Ackermann writes: > Unique (cost=359069.64..369948.41 rows=145050 width=33) (actual > time=42195.60..43229.04 rows=219435 loops=1) > -> Sort (cost=359069.64..362695.90 rows=1450503 width=33) (actual > time=42195.59..42694.70 rows=695158 loops=1) > Sort Key: gene.gene_name, gene_occurrences_puid.puid > -> Merge Join (cost=63732.51..99264.24 rows=1450503 > width=33) (actual time=13172.40..27973.79 rows=695158 loops=1) > Merge Cond: ("outer".puid = "inner".puid) > -> Index Scan using disease_occpd_puid_i on > disease_occurrences_puid (cost=0.00..14543.06 rows=471915 width=4) > (actual time=36.50..10916.29 rows=471915 loops=1) > -> Sort (cost=63732.51..64580.88 rows=339347 width=29) > (actual time=13126.56..14048.38 rows=815068 loops=1) > Sort Key: gene_occurrences_puid.puid > -> Merge Join (cost=0.00..22889.19 rows=339347 > width=29) (actual time=58.00..6775.55 rows=339347 loops=1) > Merge Cond: ("outer".gene_id = "inner".gene_id) > -> Index Scan using gene_pkey on gene > (cost=0.00..7739.91 rows=218085 width=21) (actual time=29.00..3416.01 > rows=218073 > loops=1) > -> Index Scan using gene_id_puid_uni on > gene_occurrences_puid (cost=0.00..9525.57 rows=339347 width=8) (actual > time=28.69..1936.83 rows=339347 loops=1) > Total runtime: 43338.94 msec Seems like most of the time is going into the sort steps. > postgresql.conf: > shared_buffers: 121600 > max_connections: 64 > max_fsm_relations = 200 > max_fsm_pages = 40000 > effective_cache_size = 8000 Try increasing sort_mem. Also, I'd back off on shared_buffers if I were you. There's no evidence that values above a few thousand buy anything. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jan 23 10:47:16 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AA0F14771D9 for ; Thu, 23 Jan 2003 10:47:14 -0500 (EST) Received: from johnlaptop.darkcore.net (link.clearoption.com [205.200.121.81]) by postgresql.org (Postfix) with ESMTP id B3ADD4770B7 for ; Thu, 23 Jan 2003 10:36:17 -0500 (EST) Received: by johnlaptop.darkcore.net (Postfix, from userid 501) id 0E755F1EB4; Thu, 23 Jan 2003 10:36:11 -0500 (EST) Subject: Re: Query plan and Inheritance. Weird behavior From: John Lange To: Tom Lane Cc: pgsql-performance@postgresql.org In-Reply-To: <23641.1043302067@sss.pgh.pa.us> References: <20030122183939.I5182-100000@megazone23.bigpanda.com> <23641.1043302067@sss.pgh.pa.us> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8-3mdk Date: 23 Jan 2003 09:36:11 -0600 Message-Id: <1043336171.2048.35.camel@johnlaptop.darkcore.net> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/267 X-Sequence-Number: 914 On Thu, 2003-01-23 at 00:07, Tom Lane wrote: > > On 22 Jan 2003, John Lange wrote: > >> In this way the parent table would not need to know, nor would it care > >> about child tables in any way (just like inheritance in most programming > >> languages). If done this way a select on a parent table would only > >> require the retrieval of a single row and a select on a child table > >> would only require the retrieval of two rows (one in the child table and > >> one in the parent table). > > No, it'd require the retrieval of N rows: you're failing to think about > multiple levels of inheritance or multi-parent inheritance, both of > which are supported reasonably effectively by the current model. Lets not be too nit-picky here. In the case of multiple layers of inheritance you are still only selecting two rows (at a time), one child, one parent. However if the parent also has a parent, then the process repeats, once for every layer. This is entirely reasonable and efficient compared to the current model where a select on a parent table requires the same select to be executed on EVERY child table. If it's a large expensive JOIN of some kind then this is verging on un-workable. > My guess is that this scheme would crash and burn just on locking > considerations. (When you want to update a child row, what locks do you > have to get in what order? With pieces of the row scattered through > many tables, it'd be pretty messy.) You lock the parent on down to the last child. I'm not a database developer but that seems fairly straight forward? The choice between the schema I've suggested and the way it is currently implemented is a trade off between more efficient selects vs. more efficient updates. If you are selecting on the parent table more than updating then my idea is vastly more efficient. If you INSERT a lot then the current way is marginally better. With apologies to the developers, I don't feel the current implementation is really usable for the simple fact that expensive operations performed on the parent table causes them to be repeated for every child table. And, as an added penalty, indexes on parent tables are NOT inherited to the children so the child operations can be even more expensive. This solution is not that large and I've already got 6 child tables. It just so happens that I do a LOT of selects on the parent so I'm going to have to make a decision on where to go from here. Solving this programmatically is not really that hard but I've gone a ways down this path now so I'm not anxious to redo the entire database schema since we do have customers already using this. > You may care to look in the pghackers archives for prior discussions. I will, thanks. > The variant scheme that's sounded most interesting to me so far is to > store *all* rows of an inheritance hierarchy in a single physical table. Unless I'm not understanding I don't think that works. In my case for example, a single parent has 4-5 children so the only columns they have in common are the ones in the parent. Combining them all into a single table means a big de-normalized table (loads of empty columns). If you are going to go this route then you might as well just do it. It doesn't need to be implemented on the DBMS. Regards, John Lange > This'd require giving up multiple inheritance, but few people seem to > use that, and the other benefits (like being able to enforce uniqueness > constraints over the whole hierarchy with just a standard unique index) > seem worth it. No one's stepped up to bat to do the legwork on the idea > yet, though. One bit that looks pretty tricky is ALTER TABLE ADD > COLUMN. > > regards, tom lane From pgsql-hackers-owner@postgresql.org Thu Jan 23 11:18:34 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4B3454768C4; Thu, 23 Jan 2003 11:18:33 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id 1A5AD477219; Thu, 23 Jan 2003 10:53:50 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id A2B85BF4C; Thu, 23 Jan 2003 15:53:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id D14B48736; Fri, 24 Jan 2003 00:50:27 +0900 (JST) Date: Fri, 24 Jan 2003 00:50:27 +0900 (JST) From: Curt Sampson To: Daniel Kalchev Cc: Hannu Krosing , Tom Lane , Dann Corbit , Steve Crawford , pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Terrible performance on wide selects In-Reply-To: <200301231044.h0NAi8Y21333@dcave.digsys.bg> Message-ID: References: <200301231044.h0NAi8Y21333@dcave.digsys.bg> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/892 X-Sequence-Number: 34502 On Thu, 23 Jan 2003, Daniel Kalchev wrote: > Does this mean, that constructing tables where fixed length fields are > 'before' variable lenght fields and 'possibly null' fields might increase > performance? This, I believe, is why DB2 always puts (in physical storage) all of the fixed-length fields before the variable-length fields. cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-general-owner@postgresql.org Thu Jan 23 11:17:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EDE4A476FC7; Thu, 23 Jan 2003 11:17:50 -0500 (EST) Received: from biomax.de (unknown [212.6.137.236]) by postgresql.org (Postfix) with ESMTP id 45FD74770A3; Thu, 23 Jan 2003 10:53:09 -0500 (EST) Received: from biomax.de (guffert.biomax.de [192.168.3.166]) by biomax.de (8.8.8/8.8.8) with ESMTP id QAA18901; Thu, 23 Jan 2003 16:52:51 +0100 Message-ID: <3E300FD3.3030100@biomax.de> Date: Thu, 23 Jan 2003 16:52:51 +0100 From: Chantal Ackermann User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane , Stephan Szabo Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] optimizing query References: <20030122081422.Y96911-100000@megazone23.bigpanda.com> <3E2FB2D1.9020904@biomax.de> <25976.1043335579@sss.pgh.pa.us> In-Reply-To: <25976.1043335579@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/928 X-Sequence-Number: 36049 hi Stephan, hi Tom, sort_mem was at its default: 1024. I increased it, and the query takes even longer (~ 36 secs). I tried two different values: 4096 and 8192, this last time I reduced the shared_buffers to 25600 (--> ~ 37 secs). Another point is: after a vacuum, the cost would slightly increase. would it help to cluster the index? but as I am using several indexes I find it difficult to decide on which index to cluster. (I paste the output from vacuum full verbose analyze) Thanks! Chantal ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INFO: --Relation public.disease_occurrences_puid-- INFO: Pages 2079: Changed 0, reaped 0, Empty 0, New 0; Tup 471915: Vac 0, Keep/VTL 0/0, UnUsed 0, MinLen 32, MaxLen 32; Re-using: Free/Avail. Space 648/648; EndEmpty/Avail. Pages 0/1. CPU 0.02s/0.05u sec elapsed 0.07 sec. INFO: Index disease_occpd_puid_i: Pages 1036; Tuples 471915. CPU 0.00s/0.03u sec elapsed 0.03 sec. INFO: Index disease_id_puid_uni: Pages 1297; Tuples 471915. CPU 0.03s/0.05u sec elapsed 0.23 sec. INFO: Rel disease_occurrences_puid: Pages: 2079 --> 2079; Tuple(s) moved: 0. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: Analyzing public.disease_occurrences_puid INFO: --Relation public.gene_occurrences_puid-- INFO: Pages 1495: Changed 0, reaped 0, Empty 0, New 0; Tup 339347: Vac 0, Keep/VTL 0/0, UnUsed 0, MinLen 32, MaxLen 32; Re-using: Free/Avail. Space 648/648; EndEmpty/Avail. Pages 0/1. CPU 0.01s/0.04u sec elapsed 0.05 sec. INFO: Index gene_occpd_puid_i: Pages 746; Tuples 339347. CPU 0.01s/0.02u sec elapsed 0.03 sec. INFO: Index gene_id_puid_uni: Pages 934; Tuples 339347. CPU 0.00s/0.02u sec elapsed 0.02 sec. INFO: Rel gene_occurrences_puid: Pages: 1495 --> 1495; Tuple(s) moved: 0. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: Analyzing public.gene_occurrences_puid INFO: --Relation public.disease-- INFO: Pages 1522: Changed 0, reaped 0, Empty 0, New 0; Tup 164597: Vac 0, Keep/VTL 0/0, UnUsed 0, MinLen 44, MaxLen 232; Re-using: Free/Avail. Space 56920/38388; EndEmpty/Avail. Pages 0/603. CPU 0.00s/0.04u sec elapsed 0.04 sec. INFO: Index disease_name_i: Pages 1076; Tuples 164597. CPU 0.05s/0.02u sec elapsed 0.18 sec. INFO: Index disease_pkey: Pages 364; Tuples 164597. CPU 0.00s/0.00u sec elapsed 0.03 sec. INFO: Index disease_uni: Pages 1168; Tuples 164597. CPU 0.08s/0.04u sec elapsed 0.22 sec. INFO: Rel disease: Pages: 1522 --> 1521; Tuple(s) moved: 75. CPU 0.00s/0.03u sec elapsed 0.04 sec. INFO: Index disease_name_i: Pages 1077; Tuples 164597: Deleted 75. CPU 0.00s/0.03u sec elapsed 0.03 sec. INFO: Index disease_pkey: Pages 364; Tuples 164597: Deleted 75. CPU 0.01s/0.02u sec elapsed 0.02 sec. INFO: Index disease_uni: Pages 1168; Tuples 164597: Deleted 75. CPU 0.00s/0.03u sec elapsed 0.03 sec. INFO: --Relation pg_toast.pg_toast_7114632-- INFO: Pages 0: Changed 0, reaped 0, Empty 0, New 0; Tup 0: Vac 0, Keep/VTL 0/0, UnUsed 0, MinLen 0, MaxLen 0; Re-using: Free/Avail. Space 0/0; EndEmpty/Avail. Pages 0/0. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: Index pg_toast_7114632_index: Pages 1; Tuples 0. CPU 0.00s/0.00u sec elapsed 0.01 sec. INFO: Analyzing public.disease INFO: --Relation public.gene-- INFO: Pages 1566: Changed 0, reaped 0, Empty 0, New 0; Tup 218085: Vac 0, Keep/VTL 0/0, UnUsed 0, MinLen 44, MaxLen 348; Re-using: Free/Avail. Space 48692/25408; EndEmpty/Avail. Pages 0/365. CPU 0.01s/0.04u sec elapsed 0.04 sec. INFO: Index gene_pkey: Pages 481; Tuples 218085. CPU 0.00s/0.01u sec elapsed 0.01 sec. INFO: Index gene_uni: Pages 1038; Tuples 218085. CPU 0.04s/0.01u sec elapsed 0.19 sec. INFO: Index gene_name_uni: Pages 917; Tuples 218085. CPU 0.06s/0.00u sec elapsed 0.15 sec. INFO: Rel gene: Pages: 1566 --> 1564; Tuple(s) moved: 230. CPU 0.01s/0.06u sec elapsed 0.11 sec. INFO: Index gene_pkey: Pages 482; Tuples 218085: Deleted 230. CPU 0.00s/0.03u sec elapsed 0.02 sec. INFO: Index gene_uni: Pages 1041; Tuples 218085: Deleted 230. CPU 0.00s/0.04u sec elapsed 0.03 sec. INFO: Index gene_name_uni: Pages 918; Tuples 218085: Deleted 230. CPU 0.00s/0.04u sec elapsed 0.03 sec. INFO: --Relation pg_toast.pg_toast_7114653-- INFO: Pages 0: Changed 0, reaped 0, Empty 0, New 0; Tup 0: Vac 0, Keep/VTL 0/0, UnUsed 0, MinLen 0, MaxLen 0; Re-using: Free/Avail. Space 0/0; EndEmpty/Avail. Pages 0/0. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: Index pg_toast_7114653_index: Pages 1; Tuples 0. CPU 0.00s/0.00u sec elapsed 0.01 sec. INFO: Analyzing public.gene ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From pgsql-performance-owner@postgresql.org Thu Jan 23 12:15:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1CA7247718F for ; Thu, 23 Jan 2003 12:15:48 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 5F1234770F1 for ; Thu, 23 Jan 2003 11:59:58 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2323224; Thu, 23 Jan 2003 09:00:02 -0800 From: "Josh Berkus" Subject: Re: Same query, same performance To: "alexandre :: aldeia digital" , X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Thu, 23 Jan 2003 09:00:02 -0800 Message-ID: In-Reply-To: <10635.200.225.202.15.1043288804.squirrel@webmail.ad2.com.br> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/270 X-Sequence-Number: 917 Alexandre, > I have a system with 7 Million of records in 600 tables. > My actual production machine is: P4 1.6G, 3 IDE 7200, 1GB PC133 > My new machine production is: Dual Xeon 2.0G HT, 1GB DDR266 ECC > 3 SCSI with HW Raid 5 Well, first of all, those two systems are almost equivalent as far as Postgres is concerned for simple queries. The extra processor power will only help you with very complex queries. 3-disk RAID 5 is no faster ... and sometimes slower ... than IDE for database purposes. The only real boost to the Xeon is the faster RAM ... which may not help you if your drive array is the bottleneck. > > The postgresql.conf is the SAME in both systems and I test > with no other connections, only my local test. > > shared_buffers = 80000 > effective_cache_size = 60000 > random_page_cost = 2.5 > cpu_tuple_cost = 0.001 > cpu_index_tuple_cost = 0.0001 > cpu_operator_cost = 0.00025 Not that it affects the query below, but what about SORT_MEM? > If I execute the same query executed a lot of times, the > duration is praticaly the same in both systems ? > > 1) ! 1.185424 elapsed 1.090000 user 0.100000 system sec > 2) ! 1.184415 elapsed 1.070000 user 0.120000 system sec > 3) ! 1.185209 elapsed 1.100000 user 0.080000 system sec > > If the disks is not read directly, the system must find > the rows in RAM. If it find in RAM, why so diffrents machines > have the times of execution and why the times does not down ??? I'm pretty sure that PostgreSQL always checks on disk, even when the same query is run repeatedly. Tom? > [postgres@host1 data]$ psql -c "explain SELECT T2.fi15emp05, > T2.fi15flagcf, T2.fi15codcf, T1.Fn06Emp07, T1.Fn06TipTit, > T1.Fn06TitBan, > T1.Fn06Conta1, T1.Fn06NumTit, T1.Fn06Desdob, T1.Fn05CodPre, > T1.Fn06eCli1, > T1.Fn06tCli1, T1.Fn06cCli1, T2.fi15nome FROM (FN06T T1 LEFT JOIN > FI15T > T2 ON T2.fi15emp05 = T1.Fn06eCli1 AND T2.fi15flagcf = T1.Fn06tCli1 > AND > T2.fi15codcf = T1.Fn06cCli1) WHERE ( T1.Fn06Emp07 = '1' AND > T1.Fn06TipTit = 'R' ) AND ( T1.Fn06TitBan = '002021001525 > > ' ) ORDER BY T1.Fn06Emp07, T1.Fn06TipTit, T1.Fn06NumTit, > T1.Fn06Desdob, > T1.Fn05CodPre, T1.Fn06eCli1, T1.Fn06tCli1, T1.Fn06cCli1" Pro13Z Actually, from your stats, Postgres is doing a pretty good job. 1.18 seconds to return 15 rows from a 7 million row table searching on not Indexed columns? I don't think you have anything to complain about. If you want less-than-1 second respose time: Add some indexes and keep the tables VACUUMed so the indexes work. Particularly, add a multi-column index on ( T1.Fn06Emp07, T1.Fn06TipTit, T1.Fn06TitBan ) If you want single-digit-msec response: Get a better disk set for Postgres: I recommend dual-channel RAID 1 (n addition to indexing). -Josh Berkus From pgsql-hackers-owner@postgresql.org Thu Jan 23 12:58:41 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B67F7475F32; Thu, 23 Jan 2003 12:58:38 -0500 (EST) Received: from localhost.localdomain (unknown [194.204.44.121]) by postgresql.org (Postfix) with ESMTP id 43EA247651B; Thu, 23 Jan 2003 12:42:35 -0500 (EST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h0NHgULV001458; Thu, 23 Jan 2003 19:42:31 +0200 Received: (from hannu@localhost) by localhost.localdomain (8.12.5/8.12.5/Submit) id h0NHgQli001456; Thu, 23 Jan 2003 19:42:26 +0200 X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: Terrible performance on wide selects From: Hannu Krosing To: Dann Corbit Cc: Tom Lane , Steve Crawford , pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1043343746.1368.6.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 23 Jan 2003 19:42:26 +0200 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/895 X-Sequence-Number: 34505 Dann Corbit kirjutas N, 23.01.2003 kell 02:22: > [snip] > > So (for instance) if you have 12 variable fields, you would > > store 12 integers at the start of the record. > > Additionally, you could implicitly size the integers from the properties > of the column. A varchar(255) would only need an unsigned char to store > the offset, but a varchar(80000) would require an unsigned int. I guess that the pointer could always be 16-bit, as the offset inside a tuple will never be more (other issues constrain max page size to 32K) varchar(80000) will use TOAST (another file) anyway, but this will be hidden inside the field storage in the page) > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- Hannu Krosing From pgsql-performance-owner@postgresql.org Thu Jan 23 17:27:00 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A53C7476768 for ; Thu, 23 Jan 2003 16:26:54 -0500 (EST) Received: from spirit.aldeiadigital.com.br (iplus-fac-137.xdsl-fixo.ctbcnetsuper.com.br [200.225.213.137]) by postgresql.org (Postfix) with ESMTP id 1C86F476860 for ; Thu, 23 Jan 2003 14:50:27 -0500 (EST) Received: from aldeiadigital.com.br (localhost.localdomain [127.0.0.1]) by spirit.aldeiadigital.com.br (8.11.6/8.11.6) with SMTP id h0NJnbl21150 for ; Thu, 23 Jan 2003 17:49:37 -0200 Received: from 200.225.202.15 (SquirrelMail authenticated user alepaes) by webmail.ad2.com.br with HTTP; Thu, 23 Jan 2003 17:49:37 -0200 (BRST) Message-ID: <10840.200.225.202.15.1043351377.squirrel@webmail.ad2.com.br> Date: Thu, 23 Jan 2003 17:49:37 -0200 (BRST) Subject: Re: Same query, same performance From: "alexandre :: aldeia digital" To: In-Reply-To: <3E2FA5B9.1030105@klaster.net> References: <10635.200.225.202.15.1043288804.squirrel@webmail.ad2.com.br> <3E2FA5B9.1030105@klaster.net> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal X-Mailer: SquirrelMail (version 1.2.7) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/272 X-Sequence-Number: 919 Tomasz, >>1) ! 1.185424 elapsed 1.090000 user 0.100000 system sec >>2) ! 1.184415 elapsed 1.070000 user 0.120000 system sec >>3) ! 1.185209 elapsed 1.100000 user 0.080000 system sec >> >>If the disks is not read directly, the system must find >>the rows in RAM. If it find in RAM, why so diffrents machines >>have the times of execution and why the times does not down ??? > > Here is your problem: > -> Seq Scan on fn06t t1 (cost=0.00..25808.30 rows=15 width=95) > Filter: ((fn06emp07 = 1::smallint) AND (fn06tiptit = > 'R'::bpchar) AND (fn06titban = '002021001525 > '::bpchar)) Really! I do not attemp that fn06t does not have an index with fn06titban ... :) Now, tehe time of the querys are < 0.02 sec on P4 and <0.05 on Xeon. Very Thank�s Alexandre, From pgsql-performance-owner@postgresql.org Thu Jan 23 18:03:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E9B83479F13 for ; Thu, 23 Jan 2003 17:26:00 -0500 (EST) Received: from spirit.aldeiadigital.com.br (iplus-fac-137.xdsl-fixo.ctbcnetsuper.com.br [200.225.213.137]) by postgresql.org (Postfix) with ESMTP id 74685477146 for ; Thu, 23 Jan 2003 15:31:40 -0500 (EST) Received: from aldeiadigital.com.br (localhost.localdomain [127.0.0.1]) by spirit.aldeiadigital.com.br (8.11.6/8.11.6) with SMTP id h0NKV3l21659 for ; Thu, 23 Jan 2003 18:31:03 -0200 Received: from 200.225.202.15 (SquirrelMail authenticated user alepaes) by webmail.ad2.com.br with HTTP; Thu, 23 Jan 2003 18:31:03 -0200 (BRST) Message-ID: <10520.200.225.202.15.1043353863.squirrel@webmail.ad2.com.br> Date: Thu, 23 Jan 2003 18:31:03 -0200 (BRST) Subject: Re: Same query, same performance From: "alexandre :: aldeia digital" To: In-Reply-To: References: <10635.200.225.202.15.1043288804.squirrel@webmail.ad2.com.br> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal X-Mailer: SquirrelMail (version 1.2.7) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/273 X-Sequence-Number: 920 Josh, > Alexandre, > >> I have a system with 7 Million of records in 600 tables. >> My actual production machine is: P4 1.6G, 3 IDE 7200, 1GB PC133 >> My new machine production is: Dual Xeon 2.0G HT, 1GB DDR266 ECC >> 3 SCSI with HW Raid 5 > > Well, first of all, those two systems are almost equivalent as far as > Postgres is concerned for simple queries. The extra processor power > will only help you with very complex queries. 3-disk RAID 5 is no > faster ... and sometimes slower ... than IDE for database purposes. > The only real boost to the Xeon is the faster RAM ... which may not > help you if your drive array is the bottleneck. Today, I will add more one HD and I will make an RAID 10 ... In next week i will report my tests to the list... > >> >> The postgresql.conf is the SAME in both systems and I test >> with no other connections, only my local test. >> >> shared_buffers = 80000 >> effective_cache_size = 60000 >> random_page_cost = 2.5 >> cpu_tuple_cost = 0.001 >> cpu_index_tuple_cost = 0.0001 >> cpu_operator_cost = 0.00025 > > Not that it affects the query below, but what about SORT_MEM? Sort_mem = 32000 > Actually, from your stats, Postgres is doing a pretty good job. 1.18 > seconds to return 15 rows from a 7 million row table searching on not > Indexed columns? I don't think you have anything to complain about. The table have 300000 tuples, the entire database have 7 million. Tomazs answer the question: a missing index on fn06t ... But the query time difference of the systems continue. I will change the discs and tell to list after... Thank�s Josh, Alexandre From pgsql-performance-owner@postgresql.org Fri Jan 24 00:22:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2A9CA477373 for ; Fri, 24 Jan 2003 00:22:25 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id BA69B47717F for ; Thu, 23 Jan 2003 22:32:41 -0500 (EST) Received: from [10.0.1.133] (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 60AC73BFF4 for ; Thu, 23 Jan 2003 22:32:45 -0500 (EST) Date: Thu, 23 Jan 2003 22:32:58 -0500 From: Noah Silverman To: pgsql-performance@postgresql.org Subject: Crash Recovery Message-ID: <2147483647.1043361178@[10.0.1.133]> X-Mailer: Mulberry/3.0.0 (Mac OS X Demo) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/274 X-Sequence-Number: 921 To preface my question, we are still in the process of evaluating postgres to determine if we want to switch our production environment over. I'm curious about where I can find documentation about crash recovery in postgres. In mysql, there is a nice table recovery utility (myisamchk). is there something similar in postgres? What do we do if a table or database becomes corrupted? (I'm aware of backup techniques, but it isn't feasible for some of our larger tables. We're already running on raid 5, but can't do much more) Thanks, -N From pgsql-performance-owner@postgresql.org Fri Jan 24 00:37:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 86DB7477438 for ; Fri, 24 Jan 2003 00:37:53 -0500 (EST) Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id 6C2E84771E9 for ; Thu, 23 Jan 2003 23:16:09 -0500 (EST) Received: from antares.intervideo.com [206.112.112.139] by torque.intervideoinc.com with ESMTP (SMTPD32-5.05) id A286AF302A6; Thu, 23 Jan 2003 20:35:18 -0800 Date: Thu, 23 Jan 2003 20:16:09 -0800 (PST) From: Ron Mayer X-X-Sender: ron@localhost.localdomain To: pgsql-performance@postgresql.org Cc: Ron Mayer Subject: Does "correlation" mislead the optimizer on large tables? In-Reply-To: <10520.200.225.202.15.1043353863.squirrel@webmail.ad2.com.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/275 X-Sequence-Number: 922 Short summary: On a large tables, I think the "correlation" pg_stats field as calculated by "vacuum analyze" or "analyze" can mislead the optimizer. By forcing index scans on some queries shown below, some queries in my database speed up from 197 seconds to under 30 seconds. I'd like feedback on whether or not having a smarter "analyze" function (which I think I could write as a separate utility) would help me situations like this. Longer: In particular, if I have a large table t with columns 'a','b','c', etc, and I cluster the table as follows: create table t_ordered as select * from t order by a,b; vacuum analyze t_ordered; Column "b" will (correctly) get a very low "correlation" in the pg_stats table -- but I think the optimizer would do better assuming a high correlation because similar 'b' values are still grouped closely on the same disk pages. Below is a real-world example of this issue. The table "fact" is a large one (reltuples = 1e8, relpages = 1082385) and contains about 1 years worth of data. The data was loaded sequentialy (ordered by dat,tim). logs=# \d fact; Table "fact" Column | Type | Modifiers --------+------------------------+----------- dat | date | tim | time without time zone | ip_id | integer | bid_id | integer | req_id | integer | ref_id | integer | uag_id | integer | Indexes: i_fact_2__bid_id, i_fact_2__dat, i_fact_2__tim, i_fact_2__ip_id, i_fact_2__ref_id, i_fact_2__req_id With a table this large, each day's worth of data contains about 3000 pages; or conversely, each page contains only about a 30 second range of values for "tim". As shown in the queries below, the optimizer wanted to do a sequential scan when looking at a 10 minute part of the day. However also as shown, forcing an index scan did much better. I'm guessing this happened because the optimizer saw the horrible correlation, and decided it would have to read an enormous number of pages if it did an index scan. =========================================== logs=# select tablename,attname,n_distinct,correlation from pg_stats where tablename='fact'; tablename | attname | n_distinct | correlation -----------+---------+------------+------------- fact | dat | 365 | 1 fact | tim | 80989 | -0.00281447 fact | ip_id | 44996 | 0.660689 fact | bid_id | 742850 | 0.969026 fact | req_id | 2778 | 0.67896 fact | ref_id | 595 | 0.258023 fact | uag_id | 633 | 0.234216 (7 rows) logs=# explain analyze select * from fact where tim<'00:10:00'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Seq Scan on fact (cost=0.00..1949838.40 rows=526340 width=32) (actual time=0.39..197447.50 rows=402929 loops=1) Filter: (tim < '00:10:00'::time without time zone) Total runtime: 197810.01 msec (3 rows) logs=# explain analyze select * from fact where tim<'00:10:00'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Seq Scan on fact (cost=0.00..1949838.40 rows=526340 width=32) (actual time=15.25..156705.76 rows=402929 loops=1) Filter: (tim < '00:10:00'::time without time zone) Total runtime: 157089.15 msec (3 rows) logs=# set enable_seqscan = off; SET logs=# explain analyze select * from fact where tim<'00:10:00'; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------- Index Scan using i__fact__tim on fact (cost=0.00..2110978.39 rows=526340 width=32) (actual time=104.41..23307.84 rows=402929 loops=1) Index Cond: (tim < '00:10:00'::time without time zone) Total runtime: 23660.95 msec (3 rows) logs=# explain analyze select * from fact where tim<'00:10:00'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- Index Scan using i__fact__tim on fact (cost=0.00..2110978.39 rows=526340 width=32) (actual time=0.03..1477.35 rows=402929 loops=1) Index Cond: (tim < '00:10:00'::time without time zone) Total runtime: 1827.94 msec (3 rows) logs=# ******************************************************************************* ******************************************************************************* So two questions: a) Am I on to something.... or is something else the reason why the optimizer chose the much slower sequential scan? b) If I did write an "analyze" that tried to set "correlation" values that took into account such local grouping of data, would anyone be interested? Ron From pgsql-performance-owner@postgresql.org Fri Jan 24 02:08:59 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2488847609C for ; Fri, 24 Jan 2003 02:08:57 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0967647669A for ; Fri, 24 Jan 2003 01:29:37 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0O6Ta5u010920; Fri, 24 Jan 2003 01:29:36 -0500 (EST) To: Noah Silverman Cc: pgsql-performance@postgresql.org Subject: Re: Crash Recovery In-reply-to: <2147483647.1043361178@[10.0.1.133]> References: <2147483647.1043361178@[10.0.1.133]> Comments: In-reply-to Noah Silverman message dated "Thu, 23 Jan 2003 22:32:58 -0500" Date: Fri, 24 Jan 2003 01:29:35 -0500 Message-ID: <10919.1043389775@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/276 X-Sequence-Number: 923 Noah Silverman writes: > I'm curious about where I can find documentation about crash recovery in > postgres. In mysql, there is a nice table recovery utility (myisamchk). > is there something similar in postgres? There are no automated recovery tools for Postgres, because there are no known failure modes that are systematic enough to allow automatic recovery. We prefer to fix such bugs rather than patch around them. There are some last-ditch tools for reconstructing indexes (REINDEX) and for throwing away the WAL log (pg_resetxlog) but I have not seen any recent cases where I would have felt that blind invocation of either would be a good move. > What do we do if a table or > database becomes corrupted? (I'm aware of backup techniques, but it isn't > feasible for some of our larger tables. Reconsider that. If your data center burns down tonight, what is your fallback? Ultimately, you *must* have a backup copy, or you're just not taking the possibility of failure seriously. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 02:35:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 691804769C8 for ; Fri, 24 Jan 2003 02:35:50 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 75741477248 for ; Fri, 24 Jan 2003 01:48:20 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0O6mJ5u011026; Fri, 24 Jan 2003 01:48:19 -0500 (EST) To: Ron Mayer Cc: pgsql-performance@postgresql.org Subject: Re: Does "correlation" mislead the optimizer on large tables? In-reply-to: References: Comments: In-reply-to Ron Mayer message dated "Thu, 23 Jan 2003 20:16:09 -0800" Date: Fri, 24 Jan 2003 01:48:19 -0500 Message-ID: <11025.1043390899@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/277 X-Sequence-Number: 924 Ron Mayer writes: > On a large tables, I think the "correlation" pg_stats field as calculated > by "vacuum analyze" or "analyze" can mislead the optimizer. If you look in the pghackers archives, you will find some discussion about changing the equation that cost_index() uses to estimate the impact of correlation on indexscan cost. The existing equation is ad-hoc and surely wrong, but so far no one's proposed a replacement that can be justified any better. If you've got such a replacement then we're all ears... > In particular, if I have a large table t with columns 'a','b','c', etc, > and I cluster the table as follows: > create table t_ordered as select * from t order by a,b; > vacuum analyze t_ordered; > Column "b" will (correctly) get a very low "correlation" in > the pg_stats table -- but I think the optimizer would do better > assuming a high correlation because similar 'b' values are still > grouped closely on the same disk pages. How would that be? They'll be separated by the stride of 'a'. It seems likely to me that a one-dimensional correlation statistic may be inadequate, but I haven't seen any proposals for better stats. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 08:22:20 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 96020475EDF for ; Fri, 24 Jan 2003 08:22:16 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 0A338475D87 for ; Fri, 24 Jan 2003 08:22:16 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18c3ml-0007Dz-00 for ; Fri, 24 Jan 2003 08:22:19 -0500 Date: Fri, 24 Jan 2003 08:22:19 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Crash Recovery Message-ID: <20030124082219.B26558@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <2147483647.1043361178@[10.0.1.133]> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <2147483647.1043361178@[10.0.1.133]>; from noah@allresearch.com on Thu, Jan 23, 2003 at 10:32:58PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/278 X-Sequence-Number: 925 On Thu, Jan 23, 2003 at 10:32:58PM -0500, Noah Silverman wrote: > To preface my question, we are still in the process of evaluating postgres > to determine if we want to switch our production environment over. > > I'm curious about where I can find documentation about crash recovery in > postgres. In mysql, there is a nice table recovery utility (myisamchk). It recovers automatically. Make sure you run with fsync turned on. That calls fsync on the WAL at the point of every COMMIT, and COMMIT isn't finished before the fsync returns. Then, in case of a crash, the WAL just plays back and fixes up the data area. > is there something similar in postgres? What do we do if a table or > database becomes corrupted? (I'm aware of backup techniques, but it isn't I have never had a table become corrupted under Postgres. There have been some recent cases where people's bad hardware caused bad data to make it into a table. Postgres's error reporting usually saves you there, because you can go in and stomp on the bad tuple if need be. There are some utilities to help in this; one of them, from Red Hat, allows you to look at the binary data in various formats (it's pretty slick). I believe it's available from sources.redhat.com/rhdb. > feasible for some of our larger tables. We're already running on raid 5, > but can't do much more) I suspect you can. First, are you using ECC memory in your production machines? If not, start doing so. Now. It is _the most important_ thing, aside from RAID, that you can do to protect your data. Almost every problem of inconsistency I've seen on the lists in the past year and a bit has been to do with bad hardware -- usually memory or disk controllers. (BTW, redundant disk controllers, and ones with some intelligence built in so that they check themsleves, are also mighty valuable here. But memory goes bad way more often.) Also, I'm not sure just what you mean about backups "not being feasible" for some of the larger tables, but you need to back up daily. Since pg_dump takes a consistent snapshot, there's no data inconsistency trouble, and you can just start the backup and go away. If the resulting files are too large, use split. And if the problem is space, well, disk is cheap these days, and so is tape, compared to having to re-get the data you lost. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Jan 24 08:53:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C178547632B for ; Fri, 24 Jan 2003 08:52:59 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 112704762E3 for ; Fri, 24 Jan 2003 08:52:59 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030124135303.BQWH8666.lakemtao03.cox.net@[192.168.1.1]> for ; Fri, 24 Jan 2003 08:53:03 -0500 Subject: Re: Crash Recovery From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <2147483647.1043361178@[10.0.1.133]> References: <2147483647.1043361178@[10.0.1.133]> Content-Type: text/plain Organization: Message-Id: <1043416377.29437.70.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 24 Jan 2003 07:52:57 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/279 X-Sequence-Number: 926 On Thu, 2003-01-23 at 21:32, Noah Silverman wrote: > To preface my question, we are still in the process of evaluating postgres > to determine if we want to switch our production environment over. > > I'm curious about where I can find documentation about crash recovery in > postgres. In mysql, there is a nice table recovery utility (myisamchk). > is there something similar in postgres? What do we do if a table or > database becomes corrupted? (I'm aware of backup techniques, but it isn't > feasible for some of our larger tables. We're already running on raid 5, > but can't do much more) Of course it's feasible!! If corporations can backup terrabyte-sized databases, then you can backup your comparatively puny DB. In fact, if your data is vital to your company, you *must* back it up. Otherwise, poof goes the company if the computer is destroyed. Now, it might cost some bucks to buy a tape drive, or a multi-loader, if you have *lots* of data, but it *can* be done... Btw, what happens if an obscure bug in the RAID controller shows is head, and starts corrupting your data? A table recovery utility wouldn't do squat, then... -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Fri Jan 24 09:12:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 61376475C8B for ; Fri, 24 Jan 2003 09:12:16 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id A8A01475B8E for ; Fri, 24 Jan 2003 09:12:15 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030124141219.END6744.lakemtao02.cox.net@[192.168.1.1]> for ; Fri, 24 Jan 2003 09:12:19 -0500 Subject: Crash Recovery, pt 2 From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <20030124082219.B26558@mail.libertyrms.com> References: <2147483647.1043361178@[10.0.1.133]> <20030124082219.B26558@mail.libertyrms.com> Content-Type: text/plain Organization: Message-Id: <1043417539.29437.82.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 24 Jan 2003 08:12:19 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/280 X-Sequence-Number: 927 On Fri, 2003-01-24 at 07:22, Andrew Sullivan wrote: > On Thu, Jan 23, 2003 at 10:32:58PM -0500, Noah Silverman wrote: > > To preface my question, we are still in the process of evaluating postgres > > to determine if we want to switch our production environment over. > > > > I'm curious about where I can find documentation about crash recovery in > > postgres. In mysql, there is a nice table recovery utility (myisamchk). > > It recovers automatically. Make sure you run with fsync turned on. > That calls fsync on the WAL at the point of every COMMIT, and COMMIT > isn't finished before the fsync returns. Then, in case of a crash, > the WAL just plays back and fixes up the data area. On commercial databases, there's a command to flush the roll-forward logs to tape at intervals during the day. Thus, if the disk(s) get corrupted, one can restore the database to new disks, then apply the on-tape roll-forward logs to the database, and you'd have only lost a few hours of data, instead of however many hours (or days) it's been since the last database backup. Also, flushing them to tape (or a different partition) ensures that they don't fill up the partition during a particularly intensive batch job. Are there any FM's that explain how this works in Postgres? Thanks, Ron -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Fri Jan 24 10:26:33 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9AD824766DF for ; Fri, 24 Jan 2003 10:26:32 -0500 (EST) Received: from VL-MS-MR002.sc1.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id 85311477182 for ; Fri, 24 Jan 2003 10:17:54 -0500 (EST) Received: from mochima.com ([66.131.15.233]) by VL-MS-MR002.sc1.videotron.ca (iPlanet Messaging Server 5.2 HotFix 0.9 (built Jul 29 2002)) with ESMTP id <0H98008GU55V58@VL-MS-MR002.sc1.videotron.ca> for pgsql-performance@postgresql.org; Fri, 24 Jan 2003 10:17:55 -0500 (EST) Date: Fri, 24 Jan 2003 10:16:42 -0500 From: Carlos Moreno Subject: Having trouble with backups (was: Re: Crash Recovery) Cc: PgSQL Performance ML Message-id: <3E3158DA.7080807@mochima.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3 References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/281 X-Sequence-Number: 928 Speaking about daily backups... We are running into some serious trouble with our backup policy. First (and less important), the size of our backups is increasing a lot; yet information is not changing, only being added; so, the obvious question: is there a way to make incremental backup? And the second (and intriguing) problem: whenever I run pg_dump, my system *freezes* until pg_dump finishes. When I say "system", I mean the software that is running and sending data to the PG database. It just freezes, users are unable to connect during several minutes, and the ones already connected think the server died, so they end up disconnecting after one or two minutes seeing that the server does not respond. Is this normal? Is there any way to avoid it? (I guess if I have a solution to the first problem -- i.e., doing incremental backups -- then that would solve this one, since it would only "freeze" the system for a few seconds, which wouldn't be that bad...) Thanks for any comments! Carlos -- From pgsql-performance-owner@postgresql.org Fri Jan 24 11:07:56 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 75BB247730F for ; Fri, 24 Jan 2003 11:07:55 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id A1C224758FE for ; Fri, 24 Jan 2003 10:48:29 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18c64I-0001GX-00 for ; Fri, 24 Jan 2003 10:48:34 -0500 Date: Fri, 24 Jan 2003 10:48:34 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: Crash Recovery, pt 2 Message-ID: <20030124104834.B32645@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <2147483647.1043361178@[10.0.1.133]> <20030124082219.B26558@mail.libertyrms.com> <1043417539.29437.82.camel@haggis> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1043417539.29437.82.camel@haggis>; from ron.l.johnson@cox.net on Fri, Jan 24, 2003 at 08:12:19AM -0600 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/282 X-Sequence-Number: 929 On Fri, Jan 24, 2003 at 08:12:19AM -0600, Ron Johnson wrote: > On commercial databases, there's a command to flush the roll-forward > logs to tape at intervals during the day. [. . .] > Are there any FM's that explain how this works in Postgres? Not yet, because you can't do it. There is, I understand, some code currently being included in 7.4 to do this. So that's when it'll happen. Look for "point in time recovery" or "PITR" on the -hackers list to see the progress. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Jan 24 11:31:48 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ED299475BC3 for ; Fri, 24 Jan 2003 11:31:47 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 8959147705C for ; Fri, 24 Jan 2003 11:08:47 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0OG8tBt065380; Fri, 24 Jan 2003 11:08:57 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: Having trouble with backups (was: Re: Crash Recovery) From: Rod Taylor To: Carlos Moreno Cc: PgSQL Performance ML In-Reply-To: <3E3158DA.7080807@mochima.com> References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-1pw3W80GWt4Hc/tZSe3s" Organization: Message-Id: <1043424535.58142.65.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 24 Jan 2003 11:08:55 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/283 X-Sequence-Number: 930 --=-1pw3W80GWt4Hc/tZSe3s Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2003-01-24 at 10:16, Carlos Moreno wrote: > Speaking about daily backups... We are running into some serious > trouble with our backup policy. >=20 > First (and less important), the size of our backups is increasing > a lot; yet information is not changing, only being added; so, the > obvious question: is there a way to make incremental backup? Incremental backups are coming. Some folks at RedHat are working on finishing a PIT implementation, with with any luck 7.4 will do what you want. For the time being you might be able to cheat. If you're not touching the old data, it should come out in roughly the same order every time. You might be able to get away with doing a diff between the new backup and an older one, and simply store that. When restoring, you'll need to patch together the proper restore file. > And the second (and intriguing) problem: whenever I run pg_dump, > my system *freezes* until pg_dump finishes. When I say "system", No, this isn't normal -- nor do I believe it. The only explanation would be a hardware or operating system limitation. I.e. with heavy disk usage it used to be possible to peg the CPU -- making everything else CPU starved, but the advent of DMA drives put an end to that. A pg_dump is not resource friendly, simply due to the quantity of information its dealing with. Are you dumping across a network? Perhaps the NIC is maxed out. --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-1pw3W80GWt4Hc/tZSe3s 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 (FreeBSD) iD8DBQA+MWUW6DETLow6vwwRAiAfAJ4vg1s0uo3+KL78kLgrTUFWPxcQagCfXGZO AaCChZInF1yJD0GA5c8l/Jw= =Gujt -----END PGP SIGNATURE----- --=-1pw3W80GWt4Hc/tZSe3s-- From pgsql-performance-owner@postgresql.org Fri Jan 24 11:32:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 62BD5476FAF for ; Fri, 24 Jan 2003 11:32:16 -0500 (EST) Received: from smtp3.ihug.com.au (smtp3.ihug.com.au [203.109.250.76]) by postgresql.org (Postfix) with ESMTP id 6165F4772E8 for ; Fri, 24 Jan 2003 11:09:04 -0500 (EST) Received: from 203-30-124-221.cust.iweb.net.au (postgresql.org) [203.30.124.221] by smtp3.ihug.com.au with esmtp (Exim 3.22 #1 (Debian)) id 18c6OA-0000re-00; Sat, 25 Jan 2003 03:09:07 +1100 Message-ID: <3E31651C.9060306@postgresql.org> Date: Sat, 25 Jan 2003 02:39:00 +1030 From: Justin Clift User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Carlos Moreno Cc: PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> In-Reply-To: <3E3158DA.7080807@mochima.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/284 X-Sequence-Number: 931 Carlos Moreno wrote: > And the second (and intriguing) problem: whenever I run pg_dump, > my system *freezes* until pg_dump finishes. When I say "system", > I mean the software that is running and sending data to the PG > database. It just freezes, users are unable to connect during > several minutes, and the ones already connected think the server > died, so they end up disconnecting after one or two minutes > seeing that the server does not respond. Is there any chance that you have hardware problems? For example a couple of disk areas that are defective and the system is not happy about, or maybe hard drive controller problems? With PC's, this sort of thing generally seems to mean hardware problems of some sort that are being triggered by PostgreSQL having to run through the entire dataset. Could be caused by I/O load, could be caused by hard drive errors, etc. ? > Is this normal? No. Out of curiosity, which operating system are you using? :-( Regards and best wishes, Justin Clift > Is there any way to avoid it? (I guess if I > have a solution to the first problem -- i.e., doing incremental > backups -- then that would solve this one, since it would only > "freeze" the system for a few seconds, which wouldn't be that > bad...) > > Thanks for any comments! > > Carlos > -- > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi From pgsql-performance-owner@postgresql.org Fri Jan 24 11:37:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C483F476F4A for ; Fri, 24 Jan 2003 11:37:25 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id C65784770E2 for ; Fri, 24 Jan 2003 11:13:28 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18c6ST-0001o8-00 for ; Fri, 24 Jan 2003 11:13:33 -0500 Date: Fri, 24 Jan 2003 11:13:33 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) Message-ID: <20030124111333.C32645@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3E3158DA.7080807@mochima.com>; from moreno@mochima.com on Fri, Jan 24, 2003 at 10:16:42AM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/285 X-Sequence-Number: 932 On Fri, Jan 24, 2003 at 10:16:42AM -0500, Carlos Moreno wrote: > obvious question: is there a way to make incremental backup? Not really, at the moment. Sorry. It's supposed to be coming soon (see my other message about PITR). > my system *freezes* until pg_dump finishes. When I say "system", > Is this normal? Is there any way to avoid it? (I guess if I No, it's not normal. I think some additional digging is needed. One thing that is important is to make sure your pg_dump doesn't cause swapping on the machine. Causing swapping is easy if you have been too aggressive in shared-memory allocation for the postmaster, and your OS is careless about who gets to be a candidate for paging. (Solaris 7.1 without priority paging was subject to this problem, for instance). A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Jan 24 11:50:21 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8F3F447630B for ; Fri, 24 Jan 2003 11:50:20 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 001C3477243 for ; Fri, 24 Jan 2003 11:26:58 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 92B6DD896; Fri, 24 Jan 2003 08:27:03 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 87EFA5C21; Fri, 24 Jan 2003 08:27:03 -0800 (PST) Date: Fri, 24 Jan 2003 08:27:03 -0800 (PST) From: Stephan Szabo To: Tom Lane Cc: Ron Mayer , Subject: Re: Does "correlation" mislead the optimizer on large In-Reply-To: <11025.1043390899@sss.pgh.pa.us> Message-ID: <20030124081405.W30842-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/286 X-Sequence-Number: 933 On Fri, 24 Jan 2003, Tom Lane wrote: > Ron Mayer writes: > > In particular, if I have a large table t with columns 'a','b','c', etc, > > and I cluster the table as follows: > > create table t_ordered as select * from t order by a,b; > > vacuum analyze t_ordered; > > Column "b" will (correctly) get a very low "correlation" in > > the pg_stats table -- but I think the optimizer would do better > > assuming a high correlation because similar 'b' values are still > > grouped closely on the same disk pages. > > How would that be? They'll be separated by the stride of 'a'. I think it's a clumping effect. For example, I made a table (ordered) with 20 values of a, 50 values of b (each showing up in each a) and 100 values of c (not used, just means 100 rows for each (a,b) combination. It's got 541 pages it looks like. Analyze sets the correlation to about 0.08 on the table and so a query like: select * from test1 where b=1; prefers a sequence scan (1791 vs 2231) while the index scan actually performs about 5 times better. I guess the reason is that in general, the index scan *really* is reading something on the order of 40 pages rather than the much larger estimate (I'd guess something on the order of say 300-400? I'm not sure how to find that except by trying to reverse engineer the estimate number), because pretty much each value of a will probably have 1 or 2 pages with b=1. I'm not really sure how to measure that, however. From pgsql-performance-owner@postgresql.org Fri Jan 24 14:26:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C41E6477182 for ; Fri, 24 Jan 2003 14:26:56 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 1937B4773A2 for ; Fri, 24 Jan 2003 13:46:50 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030124184651.ETFT8666.lakemtao03.cox.net@[192.168.1.1]> for ; Fri, 24 Jan 2003 13:46:51 -0500 Subject: Re: Crash Recovery, pt 2 From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <20030124104834.B32645@mail.libertyrms.com> References: <2147483647.1043361178@[10.0.1.133]> <20030124082219.B26558@mail.libertyrms.com> <1043417539.29437.82.camel@haggis> <20030124104834.B32645@mail.libertyrms.com> Content-Type: text/plain Organization: Message-Id: <1043434008.30882.8.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 24 Jan 2003 12:46:49 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/287 X-Sequence-Number: 934 On Fri, 2003-01-24 at 09:48, Andrew Sullivan wrote: > On Fri, Jan 24, 2003 at 08:12:19AM -0600, Ron Johnson wrote: > > > On commercial databases, there's a command to flush the roll-forward > > logs to tape at intervals during the day. > > [. . .] > > > Are there any FM's that explain how this works in Postgres? > > Not yet, because you can't do it. > > There is, I understand, some code currently being included in 7.4 to > do this. So that's when it'll happen. Look for "point in time > recovery" or "PITR" on the -hackers list to see the progress. Great! That's a big step towards enterprise functiomality. Another big step would be aggregate functions using indexes, but that's been discussed before... -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Fri Jan 24 14:57:12 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 32A6E477581 for ; Fri, 24 Jan 2003 14:57:10 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 2129E47731F for ; Fri, 24 Jan 2003 14:19:38 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2324561 for pgsql-performance@postgresql.org; Fri, 24 Jan 2003 11:19:42 -0800 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Subject: Mount options for Ext3? Date: Fri, 24 Jan 2003 11:20:14 -0800 X-Mailer: KMail [version 1.4] MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301241120.14404.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/288 X-Sequence-Number: 935 Folks, What mount options to people use for Ext3, particularly what do you set "da= ta=20 =3D " for a high-transaction database? I'm used to ReiserFS ("noatime,=20 notail") and am not really sure where to go with Ext3. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jan 24 15:10:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B907E4773E1 for ; Fri, 24 Jan 2003 15:10:10 -0500 (EST) Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id 2045F477400 for ; Fri, 24 Jan 2003 14:36:42 -0500 (EST) Received: from antares.intervideo.com [206.112.112.139] by torque.intervideoinc.com with ESMTP (SMTPD32-5.05) id AA48157B029A; Fri, 24 Jan 2003 11:55:52 -0800 Date: Fri, 24 Jan 2003 11:36:50 -0800 (PST) From: Ron Mayer X-X-Sender: ron@localhost.localdomain To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Does "correlation" mislead the optimizer on large In-Reply-To: <11025.1043390899@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/289 X-Sequence-Number: 936 On Fri, 24 Jan 2003, Tom Lane wrote: > > Ron Mayer writes: > > On a large tables, I think the "correlation" pg_stats field as calculated > > by "vacuum analyze" or "analyze" can mislead the optimizer. > > If you look in the pghackers archives, you will find some discussion > about changing the equation that cost_index() uses to estimate the > impact of correlation on indexscan cost. The existing equation is > ad-hoc and surely wrong, but so far no one's proposed a replacement > that can be justified any better. If you've got such a replacement > then we're all ears... I've got a very slow one (full table scan perl script) that helps my database... I don't know if it's a good general purpose solution. That's why I'm asking if the concept is good here. :-) > > In particular, if I have a large table t with columns 'a','b','c', etc, > > and I cluster the table as follows: > > create table t_ordered as select * from t order by a,b; > > vacuum analyze t_ordered; > > Column "b" will (correctly) get a very low "correlation" in > > the pg_stats table -- but I think the optimizer would do better > > assuming a high correlation because similar 'b' values are still > > grouped closely on the same disk pages. > > How would that be? They'll be separated by the stride of 'a'. In the case of date/time (for the queries I showed) the issue was that 'a's were not at all unique so I had data like this: dat | time | value ------------|----------|-------------------------------- 2002-01-01 | 00:00:00 | whatever 2002-01-01 | 00:00:00 | 2002-01-01 | 00:00:00 | 2002-01-01 | 00:00:01 | 2002-01-01 | 00:00:01 | [many pages of 12am] 2002-01-01 | 00:00:01 | 2002-01-01 | 00:00:01 | ... thousands more rows.... 2002-01-01 | 00:00:59 | 2002-01-01 | 00:01:00 | [many pages of 1am] ... tens of thousands of rows. 2002-01-01 | 23:59:59 | 2002-01-01 | 23:59:59 | 2002-01-01 | 23:59:59 | [many pages of 11pm] 2002-01-02 | 00:00:00 | [many *MORE* pages of 12am] 2002-01-02 | 00:00:00 | 2002-01-02 | 00:00:00 | ... tens of thousands of rows... 2002-01-02 | 23:59:59 | [many pages of 11pm] 2002-01-03 | 00:00:00 | [many *MORE* pages of 12am] ... millions more rows ... A similar problem actually shows up again in the dimention tables of my database; where I bulk load many pages at a time (which can easily be ordered to give a good correlation for a single load) ... but then the next week's data gets appended to the end. id | value ------|---------------------------------- 1 | aalok mehta [many pages of all 'a's] 2 | aamir khan 3 | aaron beall | [...] 6234 | axel rose 6234 | austin wolf 6123 | barbara boxer [many pages of all 'b's] | [...] 123456 | young 123457 | zebra | [...data loaded later..] 123458 | aaron whatever [more pages of all 'a's] 123458 | aaron something else 123458 | aaron something else | [...] 512344 | zelany In this case I get many clustered blocks of "a" values, but these clustered blocks happen at many different times across the table. > It seems likely to me that a one-dimensional correlation statistic may > be inadequate, but I haven't seen any proposals for better stats. The idea is it walks the whole table and looks for more local correlations and replaces the correlation value with a "good" value if values "close" to each other on the disk are similar. This way a single "correlation" value still works ... so I didn't have to change the optimizer logic, just the "analyze" logic. Basically if data within each block is highly correlated, it doesn't matter as much (yeah, I now the issue about sequential reads vs. random reads). Ron From pgsql-performance-owner@postgresql.org Fri Jan 24 15:41:43 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4E689477310 for ; Fri, 24 Jan 2003 15:41:42 -0500 (EST) Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id CC3314773C0 for ; Fri, 24 Jan 2003 15:04:05 -0500 (EST) Received: from antares.intervideo.com [206.112.112.139] by torque.intervideoinc.com with ESMTP (SMTPD32-5.05) id A0B3221701C2; Fri, 24 Jan 2003 12:23:15 -0800 Date: Fri, 24 Jan 2003 12:04:12 -0800 (PST) From: Ron Mayer X-X-Sender: ron@localhost.localdomain To: Stephan Szabo Cc: Tom Lane , Subject: Re: Does "correlation" mislead the optimizer on large In-Reply-To: <20030124081405.W30842-100000@megazone23.bigpanda.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/290 X-Sequence-Number: 937 On Fri, 24 Jan 2003, Stephan Szabo wrote: > > I think it's a clumping effect. Yup, I think that's exactly the effect. A proposal.... (yes I I'm volunteering if people point me in the right direction)... would be to have a "plugable" set of analyze functions so that a huge database that runs analyze infrequently could choose to have a very slow analyze that might work better for it's data. I see no reason different analyze functions would to be compiled into the source code ... but could probably exists as PL/pgSQL languages. The one thing compiling it in would help with is to let me know the exact number of tuples on each individual page, but I guess reltuples/relpages from pg_class is a good estimate. > For example, I made a table (ordered) with 20 values of a, 50 values of b > (each showing up in each a) and 100 values of c (not used, just means 100 > rows for each (a,b) combination. It's got 541 pages it looks like. Analyze > sets the correlation to about 0.08 on the table and so a query like: > select * from test1 where b=1; prefers a sequence scan (1791 vs 2231) > while the index scan actually performs about 5 times better. That sounds like the same situation I was in. If my logic is right, this means you had about 184 tuples/page (200*50*100/541), so it looks to me like for each "a", you get half-a-page where "b=1". If you had 'c' have 200 values, I think you'd get even a bigger speedup because half the page is still "wasted" with b=2 values. If you had 'c' have 10000 values, I think you'd get even a slightly bigger speedup because you'd have so many b=1 pages next to each other you'd benefit from more sequential disk access. > I guess the reason is that in general, the index scan *really* is reading > something on the order of 40 pages rather than the much larger estimate > (I'd guess something on the order of say 300-400? I'm not sure how to > find that except by trying to reverse engineer the estimate number), Or by adding a printf()... I think it'd be in cost_index in costsize.c. > because pretty much each value of a will probably have 1 or 2 pages with > b=1. > > I'm not really sure how to measure that, however. As I said... I'm happy to volunteer and experiment if people point me in a good direction. Ron From pgsql-performance-owner@postgresql.org Fri Jan 24 16:02:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 315F7477198 for ; Fri, 24 Jan 2003 16:02:16 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 5F894476B41 for ; Fri, 24 Jan 2003 15:22:27 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0OKML5u021094; Fri, 24 Jan 2003 15:22:21 -0500 (EST) To: Ron Mayer Cc: Stephan Szabo , pgsql-performance@postgresql.org Subject: Re: Does "correlation" mislead the optimizer on large In-reply-to: References: Comments: In-reply-to Ron Mayer message dated "Fri, 24 Jan 2003 12:04:12 -0800" Date: Fri, 24 Jan 2003 15:22:21 -0500 Message-ID: <21093.1043439741@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/291 X-Sequence-Number: 938 Ron Mayer writes: > A proposal.... (yes I I'm volunteering if people point me in the right > direction)... would be to have a "plugable" set of analyze functions so that a > huge database that runs analyze infrequently could choose to have a very slow > analyze that might work better for it's data. I do not think ANALYZE is the problem here; at least, it's premature to worry about that end of things until you've defined (a) what's to be stored in pg_statistic, and (b) what computation the planner needs to make to derive a cost estimate given the stats. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 16:27:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EE0CF475EE2 for ; Fri, 24 Jan 2003 16:27:56 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 20339476027 for ; Fri, 24 Jan 2003 16:01:42 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0OL1f5u022651; Fri, 24 Jan 2003 16:01:42 -0500 (EST) To: Carlos Moreno Cc: PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) In-reply-to: <3E3158DA.7080807@mochima.com> References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> Comments: In-reply-to Carlos Moreno message dated "Fri, 24 Jan 2003 10:16:42 -0500" Date: Fri, 24 Jan 2003 16:01:41 -0500 Message-ID: <22650.1043442101@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/292 X-Sequence-Number: 939 Carlos Moreno writes: > And the second (and intriguing) problem: whenever I run pg_dump, > my system *freezes* until pg_dump finishes. When I say "system", > I mean the software that is running and sending data to the PG > database. Other people have responded on the assumption that this is a performance problem, but you should also consider the possibility that it's bad coding of your application software. Does your app try to grab exclusive table locks? If so, it'll sit there waiting for the pg_dump to complete. pg_dump only takes ACCESS SHARE lock on the tables it's working on, which is the weakest type of lock and does not conflict with most database operations ... but it does conflict with ACCESS EXCLUSIVE lock requests. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 17:21:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BE965476030 for ; Fri, 24 Jan 2003 17:21:06 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 940174773C0 for ; Fri, 24 Jan 2003 16:55:44 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 4FF653C1D1 for ; Fri, 24 Jan 2003 16:55:46 -0500 (EST) Date: Fri, 24 Jan 2003 16:55:45 -0500 Subject: Re: Does "correlation" mislead the optimizer on large Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: pgsql-performance@postgresql.org To: pgsql-performance@postgresql.org From: Noah Silverman In-Reply-To: <21093.1043439741@sss.pgh.pa.us> Message-Id: <975BA89C-2FE6-11D7-A3A3-000393AA8F3C@allresearch.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/293 X-Sequence-Number: 940 Hi! Another fun question in our ongoing analysis on whether to switch from mysql to postgres. (Just as an update, Postgres has performed flawlessly on all of our stress tests so far.) We have a situation where we will be creating two fairly large and complex databases with many tables (thousands) each. From what I understand, postgres keeps everything in one big data directory. Would there be an advantage to putting each of the two databases into a separate directory and starting two instances of postgres? Is it better to just lump everything together. In a perfect world, we would buy another database server and raid for the second database, but being a small company, we just don't have the budget right now. The raid on our current server is much bigger than we need. Thanks, -N From pgsql-performance-owner@postgresql.org Fri Jan 24 18:06:37 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1C67E475E3E for ; Fri, 24 Jan 2003 18:06:37 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 86E23476160 for ; Fri, 24 Jan 2003 17:39:40 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id B329E2D3D5 for ; Fri, 24 Jan 2003 17:39:42 -0500 (EST) Date: Fri, 24 Jan 2003 17:39:42 -0500 Subject: Multiple databases one directory Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: Noah Silverman To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit In-Reply-To: <975BA89C-2FE6-11D7-A3A3-000393AA8F3C@allresearch.com> Message-Id: X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/294 X-Sequence-Number: 941 Hi! Another fun question in our ongoing analysis on whether to switch from mysql to postgres. (Just as an update, Postgres has performed flawlessly on all of our stress tests so far.) We have a situation where we will be creating two fairly large and complex databases with many tables (thousands) each. From what I understand, postgres keeps everything in one big data directory. Would there be an advantage to putting each of the two databases into a separate directory and starting two instances of postgres? Is it better to just lump everything together. In a perfect world, we would buy another database server and raid for the second database, but being a small company, we just don't have the budget right now. The raid on our current server is much bigger than we need. Thanks, -N From pgsql-performance-owner@postgresql.org Fri Jan 24 18:23:02 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 45F5F476F55 for ; Fri, 24 Jan 2003 18:23:01 -0500 (EST) Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id C350C476A6D for ; Fri, 24 Jan 2003 18:09:08 -0500 (EST) Received: from antares.intervideo.com [206.112.112.139] by torque.intervideoinc.com with ESMTP (SMTPD32-5.05) id AC1414EB01B0; Fri, 24 Jan 2003 15:28:20 -0800 Date: Fri, 24 Jan 2003 15:09:19 -0800 (PST) From: Ron Mayer X-X-Sender: ron@localhost.localdomain To: Tom Lane Cc: Stephan Szabo , Subject: Re: Does "correlation" mislead the optimizer on large In-Reply-To: <21093.1043439741@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/295 X-Sequence-Number: 942 On Fri, 24 Jan 2003, Tom Lane wrote: > > Ron Mayer writes: > > A proposal.... (yes I I'm volunteering if people point me in the right > > direction)... > > I do not think ANALYZE is the problem here; at least, it's premature to > worry about that end of things until you've defined (a) what's to be > stored in pg_statistic, and (b) what computation the planner needs to > make to derive a cost estimate given the stats. Cool. Thanks for a good starting point. If I wanted to brainstorm further, should I do so here, or should I encourage interested people to take it off line with me (ron@intervideo.com) and I can post a summary of the conversation? Ron For those who do want to brainstorm with me, my starting point is this: With my particular table, I think the main issue is still that I have a lot of data that looks like: values: aaaaaaaaaaabbbbbbbbccccccccddddddddddaaaabbbbbbbccccccccddddd... disk page: |page 1|page 2|page 3|page 4|page 5|page 6|page 7|page 8|page 9| The problem I'm trying to address is that the current planner guesses that most of the pages will need to be read; however the local clustering means that in fact only a small subset need to be accessed. My first guess is that modifying the definition of "correlation" to account for page-sizes would be a good approach. I.e. Instead of the correlation across the whole table, for each row perform an auto-correlation (http://astronomy.swin.edu.au/~pbourke/analysis/correlate/) and keep only the values with a "delay" of less than 1 page-size. If you want to share thoughts offline (ron@intervideo.com), I'll gladly post a summary of responses here to save the bandwidth of the group. From pgsql-performance-owner@postgresql.org Fri Jan 24 18:28:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 59E1A476242 for ; Fri, 24 Jan 2003 18:28:38 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 2BB1A476246 for ; Fri, 24 Jan 2003 18:21:50 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2324884; Fri, 24 Jan 2003 15:21:56 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Noah Silverman , pgsql-performance@postgresql.org Subject: Re: Multiple databases one directory Date: Fri, 24 Jan 2003 15:22:28 -0800 X-Mailer: KMail [version 1.4] References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301241522.28521.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/296 X-Sequence-Number: 943 Noah, > Would there be an advantage to putting each of the two databases into a= =20 > separate directory and starting two instances of postgres? Is it=20 > better to just lump everything together. You can use the WITH LOCATION option in CREATE DATABASE to put the two=20 databases into seperate directories *without* running two instances of=20 postgres. For that matter, the databases each have their own directories, by OID numb= er. Of course, this only helps you if the seperate directories are on seperate= =20 disks/arrays/channels. If everying is on the same disk or array, don't=20 bother. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jan 24 18:59:59 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3FF2347580B for ; Fri, 24 Jan 2003 18:59:56 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 06233475461 for ; Fri, 24 Jan 2003 18:59:56 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id E80FC3C1DE; Fri, 24 Jan 2003 18:59:58 -0500 (EST) Date: Fri, 24 Jan 2003 18:59:58 -0500 Subject: WEIRD CRASH?!?! Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: pgsql-performance@postgresql.org To: josh@agliodbs.com From: Noah Silverman In-Reply-To: <200301241522.28521.josh@agliodbs.com> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/297 X-Sequence-Number: 944 I think my server crashed and then restarted itself. Does anybody know what all this means: 2003-01-24 18:28:06 PANIC: link from /RAID/pgsql/pg_xlog/00000009000000BC to /RAID/pgsql/pg_xlog/00000009000000C4 (initialization of log file 9, segment 196) failed: File exists 2003-01-24 18:28:06 LOG: server process (pid 1574) was terminated by signal 6 2003-01-24 18:28:06 LOG: terminating any other active server processes 2003-01-24 18:28:06 WARNING: Message from PostgreSQL backend: The Postmaster has informed me that some other backend died abnormally and possibly corrupted shared memory. I have rolled back the current transaction and am going to terminate your database system connection and exit. Please reconnect to the database system and repeat your query. 2003-01-24 18:28:06 LOG: all server processes terminated; reinitializing shared memory and semaphores 2003-01-24 18:28:06 LOG: database system was interrupted at 2003-01-24 18:28:06 EST 2003-01-24 18:28:06 LOG: checkpoint record is at 9/C4574974 2003-01-24 18:28:06 LOG: redo record is at 9/C200D144; undo record is at 0/0; shutdown FALSE 2003-01-24 18:28:06 LOG: next transaction id: 5159292; next oid: 50856954 2003-01-24 18:28:06 LOG: database system was not properly shut down; automatic recovery in progress 2003-01-24 18:28:06 LOG: redo starts at 9/C200D144 2003-01-24 18:28:13 LOG: ReadRecord: record with zero length at 9/C4578CC0 2003-01-24 18:28:13 LOG: redo done at 9/C4578C9C 2003-01-24 18:29:02 LOG: recycled transaction log file 00000009000000C0 2003-01-24 18:29:02 LOG: recycled transaction log file 00000009000000C1 2003-01-24 18:29:02 LOG: recycled transaction log file 00000009000000BC 2003-01-24 18:29:02 LOG: recycled transaction log file 00000009000000BD 2003-01-24 18:29:02 LOG: recycled transaction log file 00000009000000BE 2003-01-24 18:29:02 LOG: recycled transaction log file 00000009000000BF 2003-01-24 18:29:02 LOG: database system is ready From pgsql-performance-owner@postgresql.org Fri Jan 24 19:03:05 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DAEFB475ADD for ; Fri, 24 Jan 2003 19:03:03 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 227B54758E6 for ; Fri, 24 Jan 2003 19:03:03 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2324930; Fri, 24 Jan 2003 16:03:09 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Noah Silverman Subject: Re: WEIRD CRASH?!?! Date: Fri, 24 Jan 2003 16:03:42 -0800 X-Mailer: KMail [version 1.4] Cc: pgsql-performance@postgresql.org References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301241603.42263.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/298 X-Sequence-Number: 945 Noah, > I think my server crashed and then restarted itself. Does anybody know= =20 > what all this means: >=20 > 2003-01-24 18:28:06 PANIC: link from=20 > /RAID/pgsql/pg_xlog/00000009000000BC to=20 > /RAID/pgsql/pg_xlog/00000009000000C4 (initialization of log file 9,=20 > segment 196) failed: File exists > 2003-01-24 18:28:06 LOG: server process (pid 1574) was terminated by=20 > signal 6 > 2003-01-24 18:28:06 LOG: terminating any other active server processes > 2003-01-24 18:28:06 WARNING: Message from PostgreSQL backend: > The Postmaster has informed me that some other backend > died abnormally and possibly corrupted shared memory. > I have rolled back the current transaction and am > going to terminate your database system connection and exit. > Please reconnect to the database system and repeat your query. This means that somebody KILL -9'd a postgres process or the postmaster, an= d=20 Postgres restarted in order to clear the shared buffers. If the database= =20 started up again, you are fine. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jan 24 19:08:29 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8DF374758E6 for ; Fri, 24 Jan 2003 19:08:27 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 0B859475461 for ; Fri, 24 Jan 2003 19:08:27 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 09CC335EAF; Fri, 24 Jan 2003 19:08:30 -0500 (EST) Date: Fri, 24 Jan 2003 19:08:29 -0500 Subject: Re: WEIRD CRASH?!?! Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: pgsql-performance@postgresql.org To: josh@agliodbs.com From: Noah Silverman In-Reply-To: <200301241603.42263.josh@agliodbs.com> Message-Id: <22021C37-2FF9-11D7-A3A3-000393AA8F3C@allresearch.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/299 X-Sequence-Number: 946 Yes, but I'm the only one logged into this box, and I didn't kill anything. It appears to have died all by itself. Thanks, -N On Friday, January 24, 2003, at 07:03 PM, Josh Berkus wrote: > Noah, > >> I think my server crashed and then restarted itself. Does anybody >> know >> what all this means: >> >> 2003-01-24 18:28:06 PANIC: link from >> /RAID/pgsql/pg_xlog/00000009000000BC to >> /RAID/pgsql/pg_xlog/00000009000000C4 (initialization of log file 9, >> segment 196) failed: File exists >> 2003-01-24 18:28:06 LOG: server process (pid 1574) was terminated by >> signal 6 >> 2003-01-24 18:28:06 LOG: terminating any other active server >> processes >> 2003-01-24 18:28:06 WARNING: Message from PostgreSQL backend: >> The Postmaster has informed me that some other backend >> died abnormally and possibly corrupted shared memory. >> I have rolled back the current transaction and am >> going to terminate your database system connection and exit. >> Please reconnect to the database system and repeat your >> query. > > This means that somebody KILL -9'd a postgres process or the > postmaster, and > Postgres restarted in order to clear the shared buffers. If the > database > started up again, you are fine. > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > > From pgsql-performance-owner@postgresql.org Fri Jan 24 19:21:33 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8B2ED4763E6 for ; Fri, 24 Jan 2003 19:21:32 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 39B4B476247 for ; Fri, 24 Jan 2003 19:19:28 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id h0P0IAXv027326; Fri, 24 Jan 2003 17:18:11 -0700 (MST) Date: Fri, 24 Jan 2003 17:13:49 -0700 (MST) From: "scott.marlowe" To: Noah Silverman Cc: , Subject: Re: WEIRD CRASH?!?! In-Reply-To: <22021C37-2FF9-11D7-A3A3-000393AA8F3C@allresearch.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/302 X-Sequence-Number: 949 On Fri, 24 Jan 2003, Noah Silverman wrote: > Yes, > but I'm the only one logged into this box, and I didn't kill anything. > It appears to have died all by itself. > It certainly sounds that way. Can you recreate the circumstances and make it happen reliably? If not, the likely it's just an isolated occurance and nothing to get too worried about. Your data is still coherent, that's why all the backends were forced to reset, to cleanse the buffers from possible corruption. From pgsql-performance-owner@postgresql.org Fri Jan 24 19:14:47 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 38DC5475DDB for ; Fri, 24 Jan 2003 19:14:46 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 7D663475DBC for ; Fri, 24 Jan 2003 19:14:45 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2324959; Fri, 24 Jan 2003 16:14:52 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Noah Silverman Subject: Re: WEIRD CRASH?!?! Date: Fri, 24 Jan 2003 16:15:24 -0800 X-Mailer: KMail [version 1.4] Cc: pgsql-performance@postgresql.org References: <22021C37-2FF9-11D7-A3A3-000393AA8F3C@allresearch.com> In-Reply-To: <22021C37-2FF9-11D7-A3A3-000393AA8F3C@allresearch.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301241615.24767.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/300 X-Sequence-Number: 947 Noah, > but I'm the only one logged into this box, and I didn't kill anything.=20= =20 > It appears to have died all by itself. I'd check your disk array, then. It doesn't happen to be a Mylex, does it? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jan 24 19:20:36 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5C28E4762F7 for ; Fri, 24 Jan 2003 19:20:34 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 06419476381 for ; Fri, 24 Jan 2003 19:17:46 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id F33A314535; Fri, 24 Jan 2003 19:17:48 -0500 (EST) Date: Fri, 24 Jan 2003 19:17:48 -0500 Subject: Re: WEIRD CRASH?!?! Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: pgsql-performance@postgresql.org To: josh@agliodbs.com From: Noah Silverman In-Reply-To: <200301241615.24767.josh@agliodbs.com> Message-Id: <6F2E6C98-2FFA-11D7-A3A3-000393AA8F3C@allresearch.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/301 X-Sequence-Number: 948 We are using a 3ware escalade on this box. One clue. I actually moved the pg_xlog directory to another drive and then symbolically linked it back to the data directory. Another idea is that Linux killed one of the processes because postgres was using up too much memory. I belive the part of the kernel is called "oomkiller". We're not sure if this happened, just a guess. Thanks, -N On Friday, January 24, 2003, at 07:15 PM, Josh Berkus wrote: > > Noah, > >> but I'm the only one logged into this box, and I didn't kill anything. >> It appears to have died all by itself. > > I'd check your disk array, then. It doesn't happen to be a Mylex, > does it? > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > > From pgsql-performance-owner@postgresql.org Fri Jan 24 19:29:09 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B69D3475E30 for ; Fri, 24 Jan 2003 19:29:08 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 4EF4D4761A1 for ; Fri, 24 Jan 2003 19:27:48 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id DC1E1D9A7; Fri, 24 Jan 2003 16:27:50 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id D13245C29; Fri, 24 Jan 2003 16:27:50 -0800 (PST) Date: Fri, 24 Jan 2003 16:27:50 -0800 (PST) From: Stephan Szabo To: Josh Berkus Cc: Noah Silverman , Subject: Re: WEIRD CRASH?!?! In-Reply-To: <200301241603.42263.josh@agliodbs.com> Message-ID: <20030124162229.K38264-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/303 X-Sequence-Number: 950 On Fri, 24 Jan 2003, Josh Berkus wrote: > Noah, > > > I think my server crashed and then restarted itself. Does anybody know > > what all this means: > > > > 2003-01-24 18:28:06 PANIC: link from > > /RAID/pgsql/pg_xlog/00000009000000BC to > > /RAID/pgsql/pg_xlog/00000009000000C4 (initialization of log file 9, > > segment 196) failed: File exists > > 2003-01-24 18:28:06 LOG: server process (pid 1574) was terminated by > > signal 6 > > 2003-01-24 18:28:06 LOG: terminating any other active server processes > > 2003-01-24 18:28:06 WARNING: Message from PostgreSQL backend: > > The Postmaster has informed me that some other backend > > died abnormally and possibly corrupted shared memory. > > I have rolled back the current transaction and am > > going to terminate your database system connection and exit. > > Please reconnect to the database system and repeat your query. > > This means that somebody KILL -9'd a postgres process or the postmaster, and > Postgres restarted in order to clear the shared buffers. If the database > started up again, you are fine. Actually, it looks like an abort() (signal 6) to me. Probably from the PANIC listed. The question is why did it get confused and end up linking to a filename that already existed? From pgsql-performance-owner@postgresql.org Fri Jan 24 19:30:58 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 83D584758E6 for ; Fri, 24 Jan 2003 19:30:56 -0500 (EST) Received: from VL-MS-MR002.sc1.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id 46FB847630B for ; Fri, 24 Jan 2003 19:30:52 -0500 (EST) Received: from mochima.com ([66.131.15.233]) by VL-MS-MR002.sc1.videotron.ca (iPlanet Messaging Server 5.2 HotFix 0.9 (built Jul 29 2002)) with ESMTP id <0H98003HXURGVE@VL-MS-MR002.sc1.videotron.ca> for pgsql-performance@postgresql.org; Fri, 24 Jan 2003 19:30:52 -0500 (EST) Date: Fri, 24 Jan 2003 19:29:52 -0500 From: Carlos Moreno Subject: Re: Having trouble with backups (was: Re: Crash Recovery) To: PgSQL Performance ML Message-id: <3E31DA80.7000000@mochima.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020827 References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> <22650.1043442101@sss.pgh.pa.us> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/305 X-Sequence-Number: 952 Tom Lane wrote: >Carlos Moreno writes: > >>And the second (and intriguing) problem: whenever I run pg_dump, >>my system *freezes* until pg_dump finishes. When I say "system", >>I mean the software that is running and sending data to the PG >>database. >> > >Other people have responded on the assumption that this is a performance >problem, but you should also consider the possibility that it's bad >coding of your application software. Does your app try to grab >exclusive table locks? If so, it'll sit there waiting for the pg_dump >to complete. > Thanks Tom and the others that have replied. One quick question, Tom, before some general comments and reply to the other messages... Where would I specify any locks the software wants to do? Is it something you do when connecting to the database, or when executing the query?? (I ask this because, that I know, we're not doing any locks; but this may just be lack of knowledge on my part; I may be doing that without being aware of it) (I guess I'll check the docs, instead of asking you guys to do my homework! :-)) Assuming that I indeed am not locking any tables, I tend to suspect that it is a problem of excessive workload; I'd like to doubt the possibility of defective hardware -- it's a dedicated server hired from a company that I'd like to believe are serious guys :-) (Rackforce.com, in case someone wants to break some bad news to me :-O ) The server is a Dual Athlon 1.8GHz, with 1GB of RAM, running Linux 7.3, and approx. 250MB for shared buffers. I installed PostgreSQL from the sources (7.2.3). It's running nothing else (I mean, no apache, no public ftp or downloads), other than our application, that is. "vmstat -n 1" reports ZERO swaps (si and so columns) during normal operation at peak times, and also during pg_dump (CPU idle time typically is around 95%, maybe going down to70 or 80 at peak times, and drops to approx. 40-60% during the time pg_dump is running -- would that be high enough load to make the software slow down to a crawl?). And no, as I said above, I don't think the software locks any tables -- in fact, if you ask me, I would say *there is* bad coding in the application, but precisely because there are no locks, no transactions (I know, shame on me! That's near the top in the list of most important things to do...), so that's why I was so reluctant to believe my colleague when he insisted that the pg_dump's were "freezing" the application... I had to see it with my own eyes, and on two different occasions, to be convinced :-( In case this tells you something... The size of the backup files (in plain ASCII) are around 300MB (the command is "nice pg_dump -c -f file.sql dbname"). Any further comments will be welcome and highly appreciated. But thank you all for the replies so far! It gives me a good starting point to do some digging. Thanks, Carlos -- From pgsql-performance-owner@postgresql.org Fri Jan 24 19:30:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 862CC475E30 for ; Fri, 24 Jan 2003 19:30:10 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id F34B2475E2E for ; Fri, 24 Jan 2003 19:30:08 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Fri, 24 Jan 2003 16:30:11 -0800 Date: Fri, 24 Jan 2003 16:30:11 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? Message-ID: <20030125003011.GA28252@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <200301241120.14404.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <200301241120.14404.josh@agliodbs.com> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/304 X-Sequence-Number: 951 Josh Berkus wrote: > Folks, > > What mount options to people use for Ext3, particularly what do you set "data > = " for a high-transaction database? I'm used to ReiserFS ("noatime, > notail") and am not really sure where to go with Ext3. For ReiserFS, I can certainly understand using "noatime", but I'm not sure why you use "notail" except to allow LILO to operate properly on it. The default for ext3 is to do ordered writes: data is written before the associated metadata transaction commits, but the data itself isn't journalled. But because PostgreSQL synchronously writes the transaction log (using fsync() by default, if I'm not mistaken) and uses sync() during a savepoint, I would think that ordered writes at the filesystem level would probably buy you very little in the way of additional data integrity in the event of a crash. So if I'm right about that, then you might consider using the "data=writeback" option for the filesystem that contains the actual data (usually /usr/local/pgsql/data), but I'd use the default ("data=ordered") at the very least (I suppose there's no harm in using "data=journal" if you're willing to put up with the performance hit, but it's not clear to me what benefit, if any, there is) for everything else. I use ReiserFS also, so I'm basing the above on what knowledge I have of the ext3 filesystem and the way PostgreSQL writes data. The more interesting question in my mind is: if you use PostgreSQL on an ext3 filesystem with "data=ordered" or "data=journal", can you get away with turning off PostgreSQL's fsync altogether and still get the same kind of data integrity that you'd get with fsync enabled? If the operating system is able to guarantee data integrity, is it still necessary to worry about it at the database level? I suspect the answer to that is that you can safely turn off fsync only if the operating system will guarantee that write transactions from a process are actually committed in the order they arrive from that process. Otherwise you'd have to worry about write transactions to the transaction log committing before the writes to the data files during a savepoint, which would leave the overall database in an inconsistent state if the system were to crash after the transaction log write (which marks the savepoint as completed) committed but before the data file writes committed. And my suspicion is that the operating system rarely makes any such guarantee, journalled filesystem or not. -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Fri Jan 24 19:50:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7BD63476179 for ; Fri, 24 Jan 2003 19:50:36 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 003AE475E3E for ; Fri, 24 Jan 2003 19:50:21 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P0oO5u027965; Fri, 24 Jan 2003 19:50:24 -0500 (EST) To: Noah Silverman Cc: pgsql-performance@postgresql.org Subject: Re: Multiple databases one directory In-reply-to: References: Comments: In-reply-to Noah Silverman message dated "Fri, 24 Jan 2003 17:39:42 -0500" Date: Fri, 24 Jan 2003 19:50:24 -0500 Message-ID: <27964.1043455824@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/306 X-Sequence-Number: 953 Noah Silverman writes: > We have a situation where we will be creating two fairly large and > complex databases with many tables (thousands) each. From what I > understand, postgres keeps everything in one big data directory. Yeah. You're kind of at the mercy of the operating system when you do that: if it copes well with big directories, no problem, but if lookups in big directories are slow then you'll take a performance hit. The first thing I'd ask is *why* you think you need thousands of tables. How will you keep track of them? Are there really thousands of different table schemas? Maybe you can combine tables by introducing an extra key column. Perhaps a little bit of rethinking will yield a small design screaming to get out of this big one ... regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 19:59:50 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 66CC14762B8 for ; Fri, 24 Jan 2003 19:59:49 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id C1B77476127 for ; Fri, 24 Jan 2003 19:56:58 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 3A3453C178; Fri, 24 Jan 2003 19:57:02 -0500 (EST) Date: Fri, 24 Jan 2003 19:57:01 -0500 Subject: Re: Multiple databases one directory Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: pgsql-performance@postgresql.org To: Tom Lane From: Noah Silverman In-Reply-To: <27964.1043455824@sss.pgh.pa.us> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/307 X-Sequence-Number: 954 Thanks, We're considering this. On an unrelated note, it looks like our crash was due to running out of file descriptors for the bash shell. Linux won't let me increase the limit for a user other than root. Does anyone know how to change this (We're running slackware) Thanks, -N On Friday, January 24, 2003, at 07:50 PM, Tom Lane wrote: > Noah Silverman writes: >> We have a situation where we will be creating two fairly large and >> complex databases with many tables (thousands) each. From what I >> understand, postgres keeps everything in one big data directory. > > Yeah. You're kind of at the mercy of the operating system when you do > that: if it copes well with big directories, no problem, but if lookups > in big directories are slow then you'll take a performance hit. > > The first thing I'd ask is *why* you think you need thousands of > tables. How will you keep track of them? Are there really thousands > of > different table schemas? Maybe you can combine tables by introducing > an extra key column. > > Perhaps a little bit of rethinking will yield a small design screaming > to get out of this big one ... > > regards, tom lane > From pgsql-performance-owner@postgresql.org Fri Jan 24 20:10:00 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4C77D47613F for ; Fri, 24 Jan 2003 20:09:59 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D697F4764C9 for ; Fri, 24 Jan 2003 20:04:26 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P1475u028080; Fri, 24 Jan 2003 20:04:08 -0500 (EST) To: Noah Silverman Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: WEIRD CRASH?!?! In-reply-to: <6F2E6C98-2FFA-11D7-A3A3-000393AA8F3C@allresearch.com> References: <6F2E6C98-2FFA-11D7-A3A3-000393AA8F3C@allresearch.com> Comments: In-reply-to Noah Silverman message dated "Fri, 24 Jan 2003 19:17:48 -0500" Date: Fri, 24 Jan 2003 20:04:07 -0500 Message-ID: <28079.1043456647@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/308 X-Sequence-Number: 955 Noah Silverman writes: > One clue. > I actually moved the pg_xlog directory to another drive and then > symbolically linked it back to the data directory. Uh, did you have the postmaster shut down while you did that? This looks like a collision between two processes both trying to create the next segment of the xlog at about the same time. But there are interlocks that are supposed to prevent that. I don't think you need to worry about the integrity of your data; the panic reset should put everything right. But I'd sure be interested if you can reproduce this problem. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 20:10:10 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9916C476260 for ; Fri, 24 Jan 2003 20:10:07 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id 1D8CB476852 for ; Fri, 24 Jan 2003 20:04:33 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Fri, 24 Jan 2003 17:04:36 -0800 Date: Fri, 24 Jan 2003 17:04:36 -0800 From: Kevin Brown To: PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) Message-ID: <20030125010436.GB28252@filer> Mail-Followup-To: Kevin Brown , PgSQL Performance ML References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> <22650.1043442101@sss.pgh.pa.us> <3E31DA80.7000000@mochima.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <3E31DA80.7000000@mochima.com> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/309 X-Sequence-Number: 956 Carlos Moreno wrote: > And no, as I said above, I don't think the software locks > any tables -- in fact, if you ask me, I would say *there > is* bad coding in the application, but precisely because > there are no locks, no transactions (I know, shame on me! > That's near the top in the list of most important things > to do...), so that's why I was so reluctant to believe > my colleague when he insisted that the pg_dump's were > "freezing" the application... I had to see it with my > own eyes, and on two different occasions, to be convinced > :-( > > In case this tells you something... The size of the > backup files (in plain ASCII) are around 300MB (the > command is "nice pg_dump -c -f file.sql dbname"). One thing you can do to help track this down is to place stats_command_string = on in your postgresql.conf and restart the database (it may be sufficient to tell the database to reread the config file via "pg_ctl reload"). Then, when the backup is going, run the application. When it "freezes", connect to the database via psql as the user postgres and do a "select * from pg_stat_activity". You'll see the list of connected processes and the current query being executed by each, if any. Do that multiple times and you should see the progress, if any, the application is making in terms of database queries. Hope this helps... -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Fri Jan 24 20:11:41 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 06B474761A1 for ; Fri, 24 Jan 2003 20:11:40 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 1F23C475E3E for ; Fri, 24 Jan 2003 20:09:04 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0P18Oe5080765; Fri, 24 Jan 2003 20:08:25 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: WEIRD CRASH?!?! From: Rod Taylor To: Noah Silverman Cc: josh@agliodbs.com, Postgresql Performance In-Reply-To: <6F2E6C98-2FFA-11D7-A3A3-000393AA8F3C@allresearch.com> References: <6F2E6C98-2FFA-11D7-A3A3-000393AA8F3C@allresearch.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-oBQQt+Qyi65FG5beWoGY" Organization: Message-Id: <1043456904.58142.96.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 24 Jan 2003 20:08:24 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/310 X-Sequence-Number: 957 --=-oBQQt+Qyi65FG5beWoGY Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2003-01-24 at 19:17, Noah Silverman wrote: > We are using a 3ware escalade on this box. >=20 > One clue. >=20 > I actually moved the pg_xlog directory to another drive and then=20 > symbolically linked it back to the data directory. You shut it down first right? --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-oBQQt+Qyi65FG5beWoGY 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 (FreeBSD) iD8DBQA+MeOH6DETLow6vwwRAuqcAJ0YxcnV3HZ2huNrrWLPaKxVqbHluQCfdKwL XyFYWGP9QFu3P5bY+aG1cmA= =Lp5M -----END PGP SIGNATURE----- --=-oBQQt+Qyi65FG5beWoGY-- From pgsql-performance-owner@postgresql.org Fri Jan 24 20:14:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1AB0047607D for ; Fri, 24 Jan 2003 20:14:05 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 98CE7476167 for ; Fri, 24 Jan 2003 20:12:08 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P1C75u028127; Fri, 24 Jan 2003 20:12:07 -0500 (EST) To: Stephan Szabo Cc: Josh Berkus , Noah Silverman , pgsql-performance@postgresql.org Subject: Re: WEIRD CRASH?!?! In-reply-to: <20030124162229.K38264-100000@megazone23.bigpanda.com> References: <20030124162229.K38264-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Fri, 24 Jan 2003 16:27:50 -0800" Date: Fri, 24 Jan 2003 20:12:06 -0500 Message-ID: <28126.1043457126@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/311 X-Sequence-Number: 958 Stephan Szabo writes: > The question is why did it get confused and end up linking to a filename > that already existed? The message comes from InstallXLogFileSegment(), which is careful to ensure that the link() cannot fail, either by unlinking the previous file, or searching for an unused name. But it failed anyway. It seems to me that there are only two possible explanations: a race condition (but holding ControlFileLock should prevent that) or BasicOpenFile() failed for a reason other than nonexistence of the file. Hmm ... I wonder if Noah's machine could have been running out of kernel file table slots, or something like that? It does seem that it'd be more robust to use something like stat(2) to probe for an existing file. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 20:14:35 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4E8864762DC for ; Fri, 24 Jan 2003 20:14:34 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 4E1354760CC for ; Fri, 24 Jan 2003 20:14:06 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 9BEB93C235; Fri, 24 Jan 2003 20:14:09 -0500 (EST) Date: Fri, 24 Jan 2003 20:14:09 -0500 Subject: Re: WEIRD CRASH?!?! Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: Postgresql Performance , josh@agliodbs.com To: Rod Taylor From: Noah Silverman In-Reply-To: <1043456904.58142.96.camel@jester> Message-Id: <4E61F6E7-3002-11D7-A3A3-000393AA8F3C@allresearch.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/312 X-Sequence-Number: 959 OF COURSE! It actually looks like the problem was with file descriptors. Our shell only had 1024 set, and we also have mysql running and using up a bunch of those. We just upped to limit to 8000 to see it that would give postgres more room to breathe. -N On Friday, January 24, 2003, at 08:08 PM, Rod Taylor wrote: > On Fri, 2003-01-24 at 19:17, Noah Silverman wrote: >> We are using a 3ware escalade on this box. >> >> One clue. >> >> I actually moved the pg_xlog directory to another drive and then >> symbolically linked it back to the data directory. > > You shut it down first right? > > -- > Rod Taylor > > PGP Key: http://www.rbt.ca/rbtpub.asc > From pgsql-performance-owner@postgresql.org Fri Jan 24 20:16:46 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1A39C475B33 for ; Fri, 24 Jan 2003 20:16:46 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 514A9475461 for ; Fri, 24 Jan 2003 20:16:45 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P1Gm5u028177; Fri, 24 Jan 2003 20:16:48 -0500 (EST) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? In-reply-to: <20030125003011.GA28252@filer> References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> Comments: In-reply-to Kevin Brown message dated "Fri, 24 Jan 2003 16:30:11 -0800" Date: Fri, 24 Jan 2003 20:16:48 -0500 Message-ID: <28176.1043457408@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/313 X-Sequence-Number: 960 Kevin Brown writes: > I suspect the answer to that is that you can safely turn off fsync > only if the operating system will guarantee that write transactions > from a process are actually committed in the order they arrive from > that process. Yeah. We use fsync partly so that when we tell a client a transaction is committed, it really is committed (ie, down to disk) --- but also as a means of controlling write order. I strongly doubt that any modern filesystem will promise to execute writes exactly in the order issued, unless prodded by means such as fsync. > Otherwise you'd have to worry about write transactions > to the transaction log committing before the writes to the data files > during a savepoint, Actually, the other way around is the problem. The WAL algorithm works so long as log writes hit disk before the data-file changes they describe (that's why it's called write *ahead* log). regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 20:19:03 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D5D57475F1A for ; Fri, 24 Jan 2003 20:19:01 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 2780C475D17 for ; Fri, 24 Jan 2003 20:19:01 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P1J35u028205; Fri, 24 Jan 2003 20:19:03 -0500 (EST) To: Carlos Moreno Cc: PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) In-reply-to: <3E31DA80.7000000@mochima.com> References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> <22650.1043442101@sss.pgh.pa.us> <3E31DA80.7000000@mochima.com> Comments: In-reply-to Carlos Moreno message dated "Fri, 24 Jan 2003 19:29:52 -0500" Date: Fri, 24 Jan 2003 20:19:02 -0500 Message-ID: <28204.1043457542@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/314 X-Sequence-Number: 961 Carlos Moreno writes: > Tom Lane wrote: >> Other people have responded on the assumption that this is a performance >> problem, but you should also consider the possibility that it's bad >> coding of your application software. Does your app try to grab >> exclusive table locks? > One quick question, Tom, before some general comments and > reply to the other messages... Where would I specify any > locks the software wants to do? If you are not issuing any explicit "LOCK" SQL commands, then you can disregard my theory. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 20:20:01 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8190B475B33 for ; Fri, 24 Jan 2003 20:19:59 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 0AE11475461 for ; Fri, 24 Jan 2003 20:19:58 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0P1KBe5080819; Fri, 24 Jan 2003 20:20:15 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: WEIRD CRASH?!?! From: Rod Taylor To: Noah Silverman Cc: Postgresql Performance , josh@agliodbs.com In-Reply-To: <4E61F6E7-3002-11D7-A3A3-000393AA8F3C@allresearch.com> References: <4E61F6E7-3002-11D7-A3A3-000393AA8F3C@allresearch.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-Wp5XeiECyJWSJvOp1B35" Organization: Message-Id: <1043457611.58142.99.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 24 Jan 2003 20:20:11 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/315 X-Sequence-Number: 962 --=-Wp5XeiECyJWSJvOp1B35 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2003-01-24 at 20:14, Noah Silverman wrote: > OF COURSE! Sorry, but I've seen people try to do that stuff before. > On Friday, January 24, 2003, at 08:08 PM, Rod Taylor wrote: >=20 > > On Fri, 2003-01-24 at 19:17, Noah Silverman wrote: > >> We are using a 3ware escalade on this box. > >> > >> One clue. > >> > >> I actually moved the pg_xlog directory to another drive and then > >> symbolically linked it back to the data directory. > > > > You shut it down first right? > > > > --=20 > > Rod Taylor > > > > PGP Key: http://www.rbt.ca/rbtpub.asc > > --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-Wp5XeiECyJWSJvOp1B35 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 (FreeBSD) iD8DBQA+MeZL6DETLow6vwwRAhDnAJ9Go/2GrHMRVPVzc2dAIEh9uml5xACfe+uU yjvoG5gwcQd+PvQIX1Kvd1s= =V4FH -----END PGP SIGNATURE----- --=-Wp5XeiECyJWSJvOp1B35-- From pgsql-performance-owner@postgresql.org Fri Jan 24 20:29:42 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 66875475B33 for ; Fri, 24 Jan 2003 20:29:40 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 52CBB475461 for ; Fri, 24 Jan 2003 20:29:39 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P1Tf5u028261; Fri, 24 Jan 2003 20:29:41 -0500 (EST) To: Carlos Moreno , PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) In-reply-to: <28204.1043457542@sss.pgh.pa.us> References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> <22650.1043442101@sss.pgh.pa.us> <3E31DA80.7000000@mochima.com> <28204.1043457542@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 24 Jan 2003 20:19:02 -0500" Date: Fri, 24 Jan 2003 20:29:41 -0500 Message-ID: <28260.1043458181@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/316 X-Sequence-Number: 963 I said: > Carlos Moreno writes: >> One quick question, Tom, before some general comments and >> reply to the other messages... Where would I specify any >> locks the software wants to do? > If you are not issuing any explicit "LOCK" SQL commands, then you can > disregard my theory. Actually, that's too simple. Are you creating and dropping tables, or issuing schema-change commands (such as ADD COLUMN or RENAME)? All of those things take exclusive locks on the tables they modify. Ordinary SELECT/INSERT/UPDATE/DELETE operations can run in parallel with pg_dump, but messing with the database structure is another story. I guess the real question here is whether your app is actually stopped dead (as it would be if waiting for a lock), or just slowed to a crawl (as a performance problem could do). I cannot tell if your "frozen" description is hyperbole or literal truth. One thing that might help diagnose it is to look at the output of ps auxww (or ps -ef on SysV-ish platforms) to see what all the backends are currently doing while the problem exists. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 20:38:43 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5217E475B33 for ; Fri, 24 Jan 2003 20:38:43 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8F2F7475461 for ; Fri, 24 Jan 2003 20:38:42 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P1ci5u028321; Fri, 24 Jan 2003 20:38:44 -0500 (EST) To: Noah Silverman Cc: Rod Taylor , Postgresql Performance , josh@agliodbs.com Subject: Re: WEIRD CRASH?!?! In-reply-to: <4E61F6E7-3002-11D7-A3A3-000393AA8F3C@allresearch.com> References: <4E61F6E7-3002-11D7-A3A3-000393AA8F3C@allresearch.com> Comments: In-reply-to Noah Silverman message dated "Fri, 24 Jan 2003 20:14:09 -0500" Date: Fri, 24 Jan 2003 20:38:44 -0500 Message-ID: <28320.1043458724@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/317 X-Sequence-Number: 964 Noah Silverman writes: > It actually looks like the problem was with file descriptors. Our > shell only had 1024 set, and we also have mysql running and using up a > bunch of those. We just upped to limit to 8000 to see it that would > give postgres more room to breathe. Ah-hah. You might also want to set max_files_per_process (in postgresql.conf) to something small enough to ensure Postgres can't run you out of descriptors. Linux has a bad habit of promising more than it can deliver when Postgres asks how many FDs are okay to use. The max_files_per_process setting is useful to prevent Postgres from believing whatever fairy-tale sysconf(3) tells it. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 21:11:59 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1FF1475F1A for ; Fri, 24 Jan 2003 21:11:58 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id 136CF475E2E for ; Fri, 24 Jan 2003 21:11:56 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Fri, 24 Jan 2003 18:11:59 -0800 Date: Fri, 24 Jan 2003 18:11:59 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? Message-ID: <20030125021159.GC28252@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@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: <28176.1043457408@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/318 X-Sequence-Number: 965 Tom Lane wrote: > > Otherwise you'd have to worry about write transactions > > to the transaction log committing before the writes to the data files > > during a savepoint, > > Actually, the other way around is the problem. The WAL algorithm works > so long as log writes hit disk before the data-file changes they > describe (that's why it's called write *ahead* log). Hmm...a case where the transaction data gets written to the files before the transaction itself even manages to get written to the log? True. But I was thinking about the following: I was presuming that when a savepoint occurs, a marker is written to the log indicating which transactions had been committed to the data files, and that this marker was paid attention to during database startup. So suppose the marker makes it to the log but not all of the data the marker refers to makes it to the data files. Then the system crashes. When the database starts back up, the savepoint marker in the transaction log shows that the transactions had already been committed to disk. But because the OS wrote the requested data (including the savepoint marker) out of order, the savepoint marker made it to the disk before some of the data made it to the data files. And so, the database is in an inconsistent state and it has no way to know about it. But then, I guess the easy way around the above problem is to always commit all the transactions in the log to disk when the database comes up, which renders the savepoint marker moot...and leads back to the scenario you were referring to... If the savepoint only commits the older transactions in the log (and not all of them) to disk, the possibility of the situation you're referring would, I'd think, be reduced (possibly quite considerably). ...or is my understanding of how all this works completely off? -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Fri Jan 24 21:22:10 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6E09C475F1A for ; Fri, 24 Jan 2003 21:22:09 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 0CD604758E6 for ; Fri, 24 Jan 2003 21:21:53 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2325202; Fri, 24 Jan 2003 18:22:00 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Kevin Brown , pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? Date: Fri, 24 Jan 2003 18:22:33 -0800 X-Mailer: KMail [version 1.4] References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> In-Reply-To: <20030125003011.GA28252@filer> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301241822.33731.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/319 X-Sequence-Number: 966 Kevin, > So if I'm right about that, then you might consider using the > "data=3Dwriteback" option for the filesystem that contains the actual > data (usually /usr/local/pgsql/data), but I'd use the default > ("data=3Dordered") at the very least (I suppose there's no harm in using > "data=3Djournal" if you're willing to put up with the performance hit, > but it's not clear to me what benefit, if any, there is) for > everything else. Well, the only reason I use Ext3 rather than Ext2 is to prevent fsck's on= =20 restart after a crash. So I'm interested in the data option that gives t= he=20 minimum performance hit, even if it means that I sacrifice some reliability= .=20=20=20 I'm running with fsynch on, and the DB is on a mirrored drive array, so I'm= =20 not too worried about filesystem-level errors. So would that be "data=3Dwriteback"? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jan 24 21:50:07 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E202C4758E6 for ; Fri, 24 Jan 2003 21:50:05 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id 2F2C8475461 for ; Fri, 24 Jan 2003 21:50:05 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Fri, 24 Jan 2003 18:50:08 -0800 Date: Fri, 24 Jan 2003 18:50:08 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? Message-ID: <20030125025008.GD28252@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <200301241822.33731.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <200301241822.33731.josh@agliodbs.com> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/320 X-Sequence-Number: 967 Josh Berkus wrote: > Well, the only reason I use Ext3 rather than Ext2 is to prevent fsck's on > restart after a crash. So I'm interested in the data option that gives the > minimum performance hit, even if it means that I sacrifice some reliability. > I'm running with fsynch on, and the DB is on a mirrored drive array, so I'm > not too worried about filesystem-level errors. > > So would that be "data=writeback"? Yes. That should give almost the same semantics as ext2 does by default, except that metadata is journalled, so no fsck needed. :-) In fact, I believe that's exactly how ReiserFS works, if I'm not mistaken (I saw someone claim that it does data journalling, but I've never seen any references to how to get ReiserFS to journal data). BTW, why exactly are you running ext3? It has some nice journalling features but it sounds like you don't want to use them. But at the same time, it uses pre-allocated inodes just like ext2 does, so it's possible to run out of inodes on ext2/3 while AFAIK that's not possible under ReiserFS. That's not likely to be a problem unless you're running a news server or something, though. :-) On the other hand, ext3 with data=writeback will probably be faster than ReiserFS for a number of things. No idea how stable ext3 is versus ReiserFS... -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Fri Jan 24 21:58:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 08EAD4758E6 for ; Fri, 24 Jan 2003 21:58:53 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3490B475461 for ; Fri, 24 Jan 2003 21:58:52 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P2wu5u001261; Fri, 24 Jan 2003 21:58:56 -0500 (EST) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? In-reply-to: <20030125021159.GC28252@filer> References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> Comments: In-reply-to Kevin Brown message dated "Fri, 24 Jan 2003 18:11:59 -0800" Date: Fri, 24 Jan 2003 21:58:55 -0500 Message-ID: <1260.1043463535@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/321 X-Sequence-Number: 968 Kevin Brown writes: > I was presuming that when a savepoint occurs, a marker is written to > the log indicating which transactions had been committed to the data > files, and that this marker was paid attention to during database > startup. Not quite. The marker says that all datafile updates described by log entries before point X have been flushed to disk by the checkpoint --- and, therefore, if we need to restart we need only replay log entries occurring after the last checkpoint's point X. This has nothing directly to do with which transactions are committed or not committed. If we based checkpoint behavior on that, we'd need to maintain an indefinitely large amount of WAL log to cope with long-running transactions. The actual checkpoint algorithm is take note of current logical end of WAL (this will be point X) write() all dirty buffers in shared buffer arena sync() to ensure that above writes, as well as previous ones, are on disk put checkpoint record referencing point X into WAL; write and fsync WAL update pg_control with new checkpoint record, fsync it Since pg_control is what's examined after restart, the checkpoint is effectively committed when the pg_control write hits disk. At any instant before that, a crash would result in replaying from the prior checkpoint's point X. The algorithm is correct if and only if the pg_control write hits disk after all the other writes mentioned. The key assumption we are making about the filesystem's behavior is that writes scheduled by the sync() will occur before the pg_control write that's issued after it. People have occasionally faulted this algorithm by quoting the sync() man page, which saith (in the Gospel According To HP) The writing, although scheduled, is not necessarily complete upon return from sync. This, however, is not a problem in itself. What we need to know is whether the filesystem will allow writes issued after the sync() to complete before those "scheduled" by the sync(). > So suppose the marker makes it to the log but not all of the data the > marker refers to makes it to the data files. Then the system crashes. I think that this analysis is not relevant to what we're doing. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 22:10:32 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D10EB475D17 for ; Fri, 24 Jan 2003 22:10:30 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 16E1B475B33 for ; Fri, 24 Jan 2003 22:10:30 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P3AR5u001331; Fri, 24 Jan 2003 22:10:28 -0500 (EST) To: Stephan Szabo , Josh Berkus , Noah Silverman , pgsql-performance@postgresql.org Subject: Re: WEIRD CRASH?!?! In-reply-to: <28126.1043457126@sss.pgh.pa.us> References: <20030124162229.K38264-100000@megazone23.bigpanda.com> <28126.1043457126@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 24 Jan 2003 20:12:06 -0500" Date: Fri, 24 Jan 2003 22:10:27 -0500 Message-ID: <1330.1043464227@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/322 X-Sequence-Number: 969 I wrote: > Hmm ... I wonder if Noah's machine could have been running out of kernel > file table slots, or something like that? It does seem that it'd be > more robust to use something like stat(2) to probe for an existing file. I've applied a patch to do it that way in CVS HEAD. After examining the code further I'm inclined not to risk back-patching it into 7.3, though. xlog.c is full of open() calls that will elog(PANIC) if they fail, so I think there was only a very small window of opportunity for Noah to see this failure and not another one. The patch thus probably contributes little real gain in reliability. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jan 24 23:13:17 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EC9B1475461 for ; Fri, 24 Jan 2003 23:13:15 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id 2182E474E42 for ; Fri, 24 Jan 2003 23:13:15 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Fri, 24 Jan 2003 20:13:19 -0800 Date: Fri, 24 Jan 2003 20:13:19 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? Message-ID: <20030125041319.GE28252@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> <1260.1043463535@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: <1260.1043463535@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/323 X-Sequence-Number: 970 Tom Lane wrote: > Kevin Brown writes: > > I was presuming that when a savepoint occurs, a marker is written to > > the log indicating which transactions had been committed to the data > > files, and that this marker was paid attention to during database > > startup. > > Not quite. The marker says that all datafile updates described by > log entries before point X have been flushed to disk by the checkpoint > --- and, therefore, if we need to restart we need only replay log > entries occurring after the last checkpoint's point X. > > This has nothing directly to do with which transactions are committed > or not committed. If we based checkpoint behavior on that, we'd need > to maintain an indefinitely large amount of WAL log to cope with > long-running transactions. Ah. My apologies for my imprecise wording. I should have said "...indicating which transactions had been written to the data files" instead of "...had been committed to the data files", and meant to say "checkpoint" but instead said "savepoint". I'll try to do better here. > The actual checkpoint algorithm is > > take note of current logical end of WAL (this will be point X) > write() all dirty buffers in shared buffer arena > sync() to ensure that above writes, as well as previous ones, > are on disk > put checkpoint record referencing point X into WAL; write and > fsync WAL > update pg_control with new checkpoint record, fsync it > > Since pg_control is what's examined after restart, the checkpoint is > effectively committed when the pg_control write hits disk. At any > instant before that, a crash would result in replaying from the > prior checkpoint's point X. The algorithm is correct if and only if > the pg_control write hits disk after all the other writes mentioned. [...] > > So suppose the marker makes it to the log but not all of the data the > > marker refers to makes it to the data files. Then the system crashes. > > I think that this analysis is not relevant to what we're doing. Agreed. The context of that analysis is when synchronous writes by the database are turned off and one is left to rely on the operating system to do the right thing. Clearly it doesn't apply when synchronous writes are enabled. As long as only one process handles a checkpoint, an operating system that guarantees that a process' writes are committed to disk in the same order that they were requested, combined with a journalling filesystem that at least wrote all data prior to committing the associated metadata transactions, would be sufficient to guarantee the integrity of the database even if all synchronous writes by the database were turned off. This would hold even if the operating system reordered writes from multiple processes. It suggests an operating system feature that could be considered highly desirable (and relates to the discussion elsewhere about trading off shared buffers against OS file cache: it's often better to rely on the abilities of the OS rather than roll your own mechanism). One question I have is: in the event of a crash, why not simply replay all the transactions found in the WAL? Is the startup time of the database that badly affected if pg_control is ignored? If there exists somewhere a reasonably succinct description of the reasoning behind the current transaction management scheme (including an analysis of the pros and cons), I'd love to read it and quit bugging you. :-) -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Fri Jan 24 23:21:00 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BA26E475B33 for ; Fri, 24 Jan 2003 23:20:58 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id C9405475AAC for ; Fri, 24 Jan 2003 23:20:57 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id 0F76AC003; Sat, 25 Jan 2003 04:20:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id 2AF268736; Sat, 25 Jan 2003 13:20:49 +0900 (JST) Date: Sat, 25 Jan 2003 13:20:49 +0900 (JST) From: Curt Sampson To: Carlos Moreno Cc: PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) In-Reply-To: <3E31DA80.7000000@mochima.com> Message-ID: References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> <22650.1043442101@sss.pgh.pa.us> <3E31DA80.7000000@mochima.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/324 X-Sequence-Number: 971 On Fri, 24 Jan 2003, Carlos Moreno wrote: > The server is a Dual Athlon 1.8GHz, with 1GB of RAM, > running Linux 7.3, and approx. 250MB for shared buffers. > ... > In case this tells you something... The size of the > backup files (in plain ASCII) are around 300MB (the > command is "nice pg_dump -c -f file.sql dbname"). I was going to ask you to check your disk I/O statistics, but that tells me that disk I/O is probably not the problem. If the ASCII dump file (I assume by "plain ASCII" you mean uncompressed as well) is only 300 MB, your database size is likely well under 100 MB. In which case the entire database ought to be residing in the buffer cache, and you should see maximum CPU utilisation during the dump, and not too much disk I/O. (This is, however, assuming that that's the only database on your machine. You don't have another 250 GB database that gets lots of random access hiding there, do you? :-)) On a big machine like that, with such a small database, you should be able to do a dump in a couple of minutes with little noticable impact on the performance of clients. I would probably start with carefully tracing what your clients are doing during backup, and where they're blocking. cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-hackers-owner@postgresql.org Sat Jan 25 01:46:03 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1089A476E5B; Sat, 25 Jan 2003 01:46:03 -0500 (EST) Received: from sss.pgh.pa.us (sss-backup.pgh.pa.us [216.151.103.158]) by postgresql.org (Postfix) with ESMTP id 5858D476E4E; Sat, 25 Jan 2003 01:46:01 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0P5eX5u006918; Sat, 25 Jan 2003 00:40:33 -0500 (EST) To: Kevin Brown Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: WAL replay logic (was Re: [PERFORM] Mount options for Ext3?) In-reply-to: <20030125041319.GE28252@filer> References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> <1260.1043463535@sss.pgh.pa.us> <20030125041319.GE28252@filer> Comments: In-reply-to Kevin Brown message dated "Fri, 24 Jan 2003 20:13:19 -0800" Date: Sat, 25 Jan 2003 00:40:33 -0500 Message-ID: <6917.1043473233@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/943 X-Sequence-Number: 34553 Kevin Brown writes: > One question I have is: in the event of a crash, why not simply replay > all the transactions found in the WAL? Is the startup time of the > database that badly affected if pg_control is ignored? Interesting thought, indeed. Since we truncate the WAL after each checkpoint, seems like this approach would no more than double the time for restart. The win is it'd eliminate pg_control as a single point of failure. It's always bothered me that we have to update pg_control on every checkpoint --- it should be a write-pretty-darn-seldom file, considering how critical it is. I think we'd have to make some changes in the code for deleting old WAL segments --- right now it's not careful to delete them in order. But surely that can be coped with. OTOH, this might just move the locus for fatal failures out of pg_control and into the OS' algorithms for writing directory updates. We would have no cross-check that the set of WAL file names visible in pg_xlog is sensible or aligned with the true state of the datafile area. We'd have to take it on faith that we should replay the visible files in their name order. This might mean we'd have to abandon the current hack of recycling xlog segments by renaming them --- which would be a nontrivial performance hit. Comments anyone? > If there exists somewhere a reasonably succinct description of the > reasoning behind the current transaction management scheme (including > an analysis of the pros and cons), I'd love to read it and quit > bugging you. :-) Not that I know of. Would you care to prepare such a writeup? There is a lot of material in the source-code comments, but no coherent presentation. regards, tom lane From pgsql-hackers-owner@postgresql.org Sat Jan 25 03:00:03 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0AB66475EE4 for ; Sat, 25 Jan 2003 03:00:02 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id 99932475E2B for ; Sat, 25 Jan 2003 02:59:59 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id DD1F2C005; Sat, 25 Jan 2003 07:59:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id 7644D8736; Sat, 25 Jan 2003 16:59:17 +0900 (JST) Date: Sat, 25 Jan 2003 16:59:17 +0900 (JST) From: Curt Sampson To: Tom Lane Cc: Kevin Brown , pgsql-hackers@postgresql.org Subject: Re: WAL replay logic (was Re: [PERFORM] Mount options for Ext3?) In-Reply-To: <6917.1043473233@sss.pgh.pa.us> Message-ID: References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> <1260.1043463535@sss.pgh.pa.us> <20030125041319.GE28252@filer> <6917.1043473233@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/944 X-Sequence-Number: 34554 On Sat, 25 Jan 2003, Tom Lane wrote: > We'd have to take it on faith that we should replay the visible files > in their name order. Couldn't you could just put timestamp information at the beginning if each file, (or perhaps use that of the first transaction), and read the beginning of each file to find out what order to run them in. Perhaps you could even check the last transaction in each file as well to see if there are "holes" between the available logs. > This might mean we'd have to abandon the current > hack of recycling xlog segments by renaming them --- which would be a > nontrivial performance hit. Rename and write a "this is an empty logfile" record at the beginning? Though I don't see how you could do this in an atomic manner.... Maybe if you included the filename in the WAL file header, you'd see that if the name doesn't match the header, it's a recycled file.... (This response sent only to hackers.) cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-hackers-owner@postgresql.org Sat Jan 25 05:11:22 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 76451475EC7; Sat, 25 Jan 2003 05:11:16 -0500 (EST) Received: from filer (12-235-198-106.client.attbi.com [12.235.198.106]) by postgresql.org (Postfix) with ESMTP id 9737E475EE4; Sat, 25 Jan 2003 05:11:15 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Sat, 25 Jan 2003 02:11:12 -0800 Date: Sat, 25 Jan 2003 02:11:12 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: WAL replay logic (was Re: [PERFORM] Mount options for Ext3?) Message-ID: <20030125101111.GB12957@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> <1260.1043463535@sss.pgh.pa.us> <20030125041319.GE28252@filer> <6917.1043473233@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: <6917.1043473233@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/945 X-Sequence-Number: 34555 Tom Lane wrote: > Kevin Brown writes: > > One question I have is: in the event of a crash, why not simply replay > > all the transactions found in the WAL? Is the startup time of the > > database that badly affected if pg_control is ignored? > > Interesting thought, indeed. Since we truncate the WAL after each > checkpoint, seems like this approach would no more than double the time > for restart. Hmm...truncating the WAL after each checkpoint minimizes the amount of disk space eaten by the WAL, but on the other hand keeping older segments around buys you some safety in the event that things get really hosed. But your later comments make it sound like the older WAL segments are kept around anyway, just rotated. > The win is it'd eliminate pg_control as a single point of > failure. It's always bothered me that we have to update pg_control on > every checkpoint --- it should be a write-pretty-darn-seldom file, > considering how critical it is. > > I think we'd have to make some changes in the code for deleting old > WAL segments --- right now it's not careful to delete them in order. > But surely that can be coped with. Even that might not be necessary. See below. > OTOH, this might just move the locus for fatal failures out of > pg_control and into the OS' algorithms for writing directory updates. > We would have no cross-check that the set of WAL file names visible in > pg_xlog is sensible or aligned with the true state of the datafile > area. Well, what we somehow need to guarantee is that there is always WAL data that is older than the newest consistent data in the datafile area, right? Meaning that if the datafile area gets scribbled on in an inconsistent manner, you always have WAL data to fill in the gaps. Right now we do that by using fsync() and sync(). But I think it would be highly desirable to be able to more or less guarantee database consistency even if fsync were turned off. The price for that might be too high, though. > We'd have to take it on faith that we should replay the visible files > in their name order. This might mean we'd have to abandon the current > hack of recycling xlog segments by renaming them --- which would be a > nontrivial performance hit. It's probably a bad idea for the replay to be based on the filenames. Instead, it should probably be based strictly on the contents of the xlog segment files. Seems to me the beginning of each segment file should have some kind of header information that makes it clear where in the scheme of things it belongs. Additionally, writing some sort of checksum, either at the beginning or the end, might not be a bad idea either (doesn't have to be a strict checksum, but it needs to be something that's reasonably likely to catch corruption within a segment). Do that, and you don't have to worry about renaming xlog segments at all: you simply move on to the next logical segment in the list (a replay just reads the header info for all the segments and orders the list as it sees fit, and discards all segments prior to any gap it finds. It may be that you simply have to bail out if you find a gap, though). As long as the xlog segment checksum information is consistent with the contents of the segment and as long as its transactions pick up where the previous segment's left off (assuming it's not the first segment, of course), you can safely replay the transactions it contains. I presume we're recycling xlog segments in order to avoid file creation and unlink overhead? Otherwise you can simply create new segments as needed and unlink old segments as policy dictates. > Comments anyone? > > > If there exists somewhere a reasonably succinct description of the > > reasoning behind the current transaction management scheme (including > > an analysis of the pros and cons), I'd love to read it and quit > > bugging you. :-) > > Not that I know of. Would you care to prepare such a writeup? There > is a lot of material in the source-code comments, but no coherent > presentation. Be happy to. Just point me to any non-obvious source files. Thus far on my plate: 1. PID file locking for postmaster startup (doesn't strictly need to be the PID file but it may as well be, since we're already messing with it anyway). I'm currently looking at how to do the autoconf tests, since I've never developed using autoconf before. 2. Documenting the transaction management scheme. I was initially interested in implementing the explicit JOIN reordering but based on your recent comments I think you have a much better handle on that than I. I'll be very interested to see what you do, to see if it's anything close to what I figure has to happen... -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Sat Jan 25 10:20:53 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E107C475C14 for ; Sat, 25 Jan 2003 10:20:50 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 67852476179 for ; Sat, 25 Jan 2003 10:20:45 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18cS6z-0003lF-00 for ; Sat, 25 Jan 2003 10:20:49 -0500 Date: Sat, 25 Jan 2003 10:20:49 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) Message-ID: <20030125102049.A14300@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> <22650.1043442101@sss.pgh.pa.us> <3E31DA80.7000000@mochima.com> <28204.1043457542@sss.pgh.pa.us> <28260.1043458181@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <28260.1043458181@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Fri, Jan 24, 2003 at 08:29:41PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/327 X-Sequence-Number: 974 On Fri, Jan 24, 2003 at 08:29:41PM -0500, Tom Lane wrote: > auxww (or ps -ef on SysV-ish platforms) to see what all the backends are Except Solaris, where ps -ef gives you no information at all. Use /usr/ucb/ps -auxww. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Sat Jan 25 10:23:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E26F8475D22 for ; Sat, 25 Jan 2003 10:23:54 -0500 (EST) Received: from VL-MS-MR001.sc1.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id 4CF32475CED for ; Sat, 25 Jan 2003 10:23:54 -0500 (EST) Received: from mochima.com ([66.131.15.233]) by VL-MS-MR001.sc1.videotron.ca (iPlanet Messaging Server 5.2 HotFix 0.9 (built Jul 29 2002)) with ESMTP id <0H9A0068F049WE@VL-MS-MR001.sc1.videotron.ca> for pgsql-performance@postgresql.org; Sat, 25 Jan 2003 10:24:09 -0500 (EST) Date: Sat, 25 Jan 2003 10:22:51 -0500 From: Carlos Moreno Subject: Re: Having trouble with backups (was: Re: Crash Recovery) To: PgSQL Performance ML Message-id: <3E32ABCB.6070003@mochima.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3 References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> <22650.1043442101@sss.pgh.pa.us> <3E31DA80.7000000@mochima.com> <28204.1043457542@sss.pgh.pa.us> <28260.1043458181@sss.pgh.pa.us> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/328 X-Sequence-Number: 975 Tom Lane wrote: >I said: > >>Carlos Moreno writes: >> >>>One quick question, Tom, before some general comments and >>>reply to the other messages... Where would I specify any >>>locks the software wants to do? >>> > >>If you are not issuing any explicit "LOCK" SQL commands, then you can >>disregard my theory. >> Well, it was a good thing that you brought it to my attention. Yes, two minutes after I wrote the message I found the docs that told me it is an SQL command -- which means that I'm positively sure that I'm not doing any of those :-) I guess a well-developed software could use some locks here and there, and the risk of making a mistake and "over-blocking" things is there... >>Actually, that's too simple. Are you creating and dropping tables, >>or issuing schema-change commands (such as ADD COLUMN or RENAME)? >>All of those things take exclusive locks on the tables they modify. >>Ordinary SELECT/INSERT/UPDATE/DELETE operations can run in parallel with >>pg_dump, but messing with the database structure is another story. >> I do that (changing the database schema while the system is running) once in a while -- but not on a regular basis, and definitely never during the time a pg_dump is in progress (*that* would have scared me to death ;-)) > >I guess the real question here is whether your app is actually stopped >dead (as it would be if waiting for a lock), or just slowed to a crawl >(as a performance problem could do). I cannot tell if your "frozen" >description is hyperbole or literal truth. > Actually, you got me on that one... From the "practical" point of view, you could say it's literal truth (i.e., the system responsiveness falls to ZERO). The system is an online multi-player game, where the main things the database is doing is holding the users information to process the login authentications, and logging results and the progress of games (to later -- offline -- compute statistics, rankings, etc.). Logging is done on a separate worker thread, so it shouldn't matter if that stops for a few minutes (the lists of SQL's pending to be executed would just grow during that time)... But the thing is, when I run pg_dump, the games freeze, you are absolutely unable to connect (the server does not respond, period), and the players that are in a game, playing, massively abandon games, and you then see comments in the chat window that the server went down, etc. (i.e., I take it the server stopped responding to them and they abandoned thinking that the connection had dropped, or that the server had died). Now, I guess a more specific answer to your question is important (i.e., is the above behaviour the result of the system slowing to a crawl, or is it that the software just hung on a single db.Exec statement in the main loop and no single line of code is being executed until the pg_dump finishes? -- according to the comments so far, I would say this last option is not possible), and I think I'll get such an answer when running some tests as suggested by you and others that replied. >One thing that might help diagnose it is to look at the output of ps >auxww (or ps -ef on SysV-ish platforms) to see what all the backends are >currently doing while the problem exists. > We have done (IIRC) top (the command "top", that is), and yes, the postmaster process takes a lot of CPU... (not sure of the exact numbers, but it was at the top). Anyway, thanks again guys for the valuable comments and ideas!! Carlos -- From pgsql-hackers-owner@postgresql.org Sat Jan 25 11:16:24 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9C0FC475CED for ; Sat, 25 Jan 2003 11:16:22 -0500 (EST) Received: from sss.pgh.pa.us (sss-backup.pgh.pa.us [216.151.103.158]) by postgresql.org (Postfix) with ESMTP id 3F511475CB4 for ; Sat, 25 Jan 2003 11:16:21 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0PGGC5u010918; Sat, 25 Jan 2003 11:16:12 -0500 (EST) To: Curt Sampson Cc: Kevin Brown , pgsql-hackers@postgresql.org Subject: Re: WAL replay logic (was Re: [PERFORM] Mount options for Ext3?) In-reply-to: References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> <1260.1043463535@sss.pgh.pa.us> <20030125041319.GE28252@filer> <6917.1043473233@sss.pgh.pa.us> Comments: In-reply-to Curt Sampson message dated "Sat, 25 Jan 2003 16:59:17 +0900" Date: Sat, 25 Jan 2003 11:16:12 -0500 Message-ID: <10916.1043511372@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/946 X-Sequence-Number: 34556 Curt Sampson writes: > On Sat, 25 Jan 2003, Tom Lane wrote: >> We'd have to take it on faith that we should replay the visible files >> in their name order. > Couldn't you could just put timestamp information at the beginning if > each file, Good thought --- there's already an xlp_pageaddr field on every page of WAL, and you could examine that to be sure it matches the file name. If not, the file csn be ignored. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Jan 25 12:17:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E7FF9475BF9 for ; Sat, 25 Jan 2003 12:17:05 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 3266A475AD4 for ; Sat, 25 Jan 2003 12:17:05 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18cTva-0005Z4-00 for ; Sat, 25 Jan 2003 12:17:10 -0500 Date: Sat, 25 Jan 2003 12:17:10 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: Having trouble with backups (was: Re: Crash Recovery) Message-ID: <20030125121710.F20026@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <2147483647.1043361178@[10.0.1.133]> <1043416377.29437.70.camel@haggis> <3E3158DA.7080807@mochima.com> <22650.1043442101@sss.pgh.pa.us> <3E31DA80.7000000@mochima.com> <28204.1043457542@sss.pgh.pa.us> <28260.1043458181@sss.pgh.pa.us> <3E32ABCB.6070003@mochima.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3E32ABCB.6070003@mochima.com>; from moreno@mochima.com on Sat, Jan 25, 2003 at 10:22:51AM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/329 X-Sequence-Number: 976 On Sat, Jan 25, 2003 at 10:22:51AM -0500, Carlos Moreno wrote: > Well, it was a good thing that you brought it to my attention. > Yes, two minutes after I wrote the message I found the docs > that told me it is an SQL command -- which means that I'm > positively sure that I'm not doing any of those :-) I guess If you have a lot of foreign keys and are doing long-running UPDATES (or other related things), I think you might also see the same thing. You could spot this with ps -auxww (or friends) by looking for [some db operation] waiting. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Sat Jan 25 13:44:14 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B6BB1475D1C for ; Sat, 25 Jan 2003 13:44:12 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id F3146475BF9 for ; Sat, 25 Jan 2003 13:44:11 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18cVHo-0006nM-00 for ; Sat, 25 Jan 2003 13:44:12 -0500 Date: Sat, 25 Jan 2003 13:44:12 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: WEIRD CRASH?!?! Message-ID: <20030125134412.K20026@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <200301241603.42263.josh@agliodbs.com> <22021C37-2FF9-11D7-A3A3-000393AA8F3C@allresearch.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <22021C37-2FF9-11D7-A3A3-000393AA8F3C@allresearch.com>; from noah@allresearch.com on Fri, Jan 24, 2003 at 07:08:29PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/330 X-Sequence-Number: 977 On Fri, Jan 24, 2003 at 07:08:29PM -0500, Noah Silverman wrote: > Yes, > but I'm the only one logged into this box, and I didn't kill anything. > It appears to have died all by itself. Is this on Linux, and were you short on memory? Linux, in a completely brain-dead design, runs around 'kill -9'-ing random processes when it starts to think the machine is going to exhaust its memory (or at least it used to. I dunno if it still does). A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Sat Jan 25 13:57:41 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E4A23475AD4 for ; Sat, 25 Jan 2003 13:57:38 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 2BA3C474E61 for ; Sat, 25 Jan 2003 13:57:38 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030125185735.QHYY8666.lakemtao03.cox.net@[192.168.1.1]> for ; Sat, 25 Jan 2003 13:57:35 -0500 Subject: LOCK TABLE & speeding up mass data loads From: Ron Johnson To: PgSQL Performance ML Content-Type: text/plain Organization: Message-Id: <1043521053.818.32.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 25 Jan 2003 12:57:33 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/331 X-Sequence-Number: 978 Hi, Would LOCK TABLE ACCESS EXCLUSIVE MODE speed things up, when I have a script that loads data by setting transactions, and then committing works after every few thousand INSERTs? Thanks, Ron -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sat Jan 25 14:07:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B6A6C475AD4 for ; Sat, 25 Jan 2003 14:07:36 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id CE468474E61 for ; Sat, 25 Jan 2003 14:07:35 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id h0PJ7kqu081649; Sat, 25 Jan 2003 14:07:46 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: LOCK TABLE & speeding up mass data loads From: Rod Taylor To: Ron Johnson Cc: PgSQL Performance ML In-Reply-To: <1043521053.818.32.camel@haggis> References: <1043521053.818.32.camel@haggis> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-SoMw60ebdgyBE0D1x2w5" Organization: Message-Id: <1043521665.58142.135.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 25 Jan 2003 14:07:46 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/332 X-Sequence-Number: 979 --=-SoMw60ebdgyBE0D1x2w5 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sat, 2003-01-25 at 13:57, Ron Johnson wrote: > Hi, >=20 > Would LOCK TABLE ACCESS EXCLUSIVE MODE speed things up, when I have > a script that loads data by setting transactions, and then committing > works after every few thousand INSERTs? If you're the only person working on the database, then no. If you're fighting for resources with a bunch of other people -- then possibly, but the others won't get anything done during this timeframe (of course). Oh, and you're using COPY right? --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-SoMw60ebdgyBE0D1x2w5 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 (FreeBSD) iD8DBQA+MuCB6DETLow6vwwRAsQeAJ97EljImU0a+5PVu8zynHY+xg6kqgCfZU9F rqHwa5faLDcJkakZX0gOMbI= =cJNP -----END PGP SIGNATURE----- --=-SoMw60ebdgyBE0D1x2w5-- From pgsql-performance-owner@postgresql.org Sat Jan 25 14:19:12 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 05B2F475BF9 for ; Sat, 25 Jan 2003 14:19:11 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 1D9F3475AD4 for ; Sat, 25 Jan 2003 14:19:10 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030125191911.QNEL8666.lakemtao03.cox.net@[192.168.1.1]> for ; Sat, 25 Jan 2003 14:19:11 -0500 Subject: Re: LOCK TABLE & speeding up mass data loads From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <1043521665.58142.135.camel@jester> References: <1043521053.818.32.camel@haggis> <1043521665.58142.135.camel@jester> Content-Type: text/plain Organization: Message-Id: <1043522349.818.36.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 25 Jan 2003 13:19:09 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/333 X-Sequence-Number: 980 On Sat, 2003-01-25 at 13:07, Rod Taylor wrote: > On Sat, 2003-01-25 at 13:57, Ron Johnson wrote: > > Hi, > > > > Would LOCK TABLE ACCESS EXCLUSIVE MODE speed things up, when I have > > a script that loads data by setting transactions, and then committing > > works after every few thousand INSERTs? > > If you're the only person working on the database, then no. If you're > fighting for resources with a bunch of other people -- then possibly, > but the others won't get anything done during this timeframe (of > course). Ok. > Oh, and you're using COPY right? No. Too much data manipulation to do 1st. Also, by committing every X thousand rows, then if the process must be aborted, then there's no huge rollback, and the script can then skip to the last comitted row and pick up from there. -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sat Jan 25 18:21:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 98644475E52 for ; Sat, 25 Jan 2003 18:21:54 -0500 (EST) Received: from mail2.mediadesign.nl (md2.mediadesign.nl [212.19.205.67]) by postgresql.org (Postfix) with SMTP id 7DC55475E14 for ; Sat, 25 Jan 2003 18:21:53 -0500 (EST) Received: (qmail 13771 invoked by uid 666); 25 Jan 2003 23:21:54 -0000 Date: Sun, 26 Jan 2003 00:21:54 +0100 From: pgsql.spam@vinz.nl To: pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? Message-ID: <20030125232154.GK14898@md2.mediadesign.nl> References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> <1260.1043463535@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1260.1043463535@sss.pgh.pa.us> User-Agent: Mutt/1.3.28i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/334 X-Sequence-Number: 981 On 2003-01-24 21:58:55 -0500, Tom Lane wrote: > The key assumption we are making about the filesystem's behavior is that > writes scheduled by the sync() will occur before the pg_control write > that's issued after it. People have occasionally faulted this algorithm > by quoting the sync() man page, which saith (in the Gospel According To > HP) > > The writing, although scheduled, is not necessarily complete upon > return from sync. > > This, however, is not a problem in itself. What we need to know is > whether the filesystem will allow writes issued after the sync() to > complete before those "scheduled" by the sync(). > Certain linux 2.4.* kernels (not sure which, newer ones don't seem to have it) have the following kernel config option: Use the NOOP Elevator (WARNING) CONFIG_BLK_DEV_ELEVATOR_NOOP If you are using a raid class top-level driver above the ATA/IDE core, one may find a performance boost by preventing a merging and re-sorting of the new requests. If unsure, say N. If one were certain his OS wouldn't do any re-ordering of writes, would it be safe to run with fsync = off? (not that I'm going to try this, but I'm just curious) Vincent van Leeuwen Media Design From pgsql-hackers-owner@postgresql.org Sun Jan 26 00:27:53 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2B385475E4D; Sun, 26 Jan 2003 00:27:51 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 68405475D91; Sun, 26 Jan 2003 00:27:50 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0Q5Rp5u026546; Sun, 26 Jan 2003 00:27:52 -0500 (EST) To: josh@agliodbs.com Cc: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org Subject: Re: [PERFORM] Proposal: relaxing link between explicit JOINs and execution order In-reply-to: <200301221617.41680.josh@agliodbs.com> References: <25071.1043276513@sss.pgh.pa.us> <200301221617.41680.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 22 Jan 2003 16:17:41 -0800" Date: Sun, 26 Jan 2003 00:27:51 -0500 Message-ID: <26545.1043558871@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/968 X-Sequence-Number: 34578 Josh Berkus writes: > How about: > EXPLICIT_JOIN_MINIMUM > and > FROM_COLLAPSE_LIMIT I've implemented this using FROM_COLLAPSE_LIMIT and JOIN_COLLAPSE_LIMIT as the variable names. It'd be easy enough to change if someone comes up with better names. You can read updated documentation at http://developer.postgresql.org/docs/postgres/explicit-joins.html regards, tom lane From pgsql-performance-owner@postgresql.org Sun Jan 26 00:35:31 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AFB414764CF for ; Sun, 26 Jan 2003 00:35:29 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id ADE38476902 for ; Sun, 26 Jan 2003 00:34:43 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0Q5Ym5u026593; Sun, 26 Jan 2003 00:34:48 -0500 (EST) To: pgsql@vinz.nl Cc: pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? In-reply-to: <20030125232154.GK14898@md2.mediadesign.nl> References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> <1260.1043463535@sss.pgh.pa.us> <20030125232154.GK14898@md2.mediadesign.nl> Comments: In-reply-to pgsql.spam@vinz.nl message dated "Sun, 26 Jan 2003 00:21:54 +0100" Date: Sun, 26 Jan 2003 00:34:48 -0500 Message-ID: <26592.1043559288@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/336 X-Sequence-Number: 983 pgsql.spam@vinz.nl writes: > If one were certain his OS wouldn't do any re-ordering of writes, would it be > safe to run with fsync = off? (not that I'm going to try this, but I'm just > curious) I suppose so ... but if your OS doesn't do *any* re-ordering of writes, I'd say you need a better OS. Even in Postgres, we'd often like the OS to collapse multiple writes of the same disk page into one write. And we certainly want the various writes forced by a sync() to be done with some intelligence about disk layout, not blindly in order of issuance. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Jan 26 03:04:51 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9ABED475E3E for ; Sun, 26 Jan 2003 03:04:49 -0500 (EST) Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) by postgresql.org (Postfix) with ESMTP id B0E0A475E23 for ; Sun, 26 Jan 2003 03:04:48 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao01.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030126080448.WIXR16369.lakemtao01.cox.net@[192.168.1.1]> for ; Sun, 26 Jan 2003 03:04:48 -0500 Subject: Re: Mount options for Ext3? From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <26592.1043559288@sss.pgh.pa.us> References: <200301241120.14404.josh@agliodbs.com> <20030125003011.GA28252@filer> <28176.1043457408@sss.pgh.pa.us> <20030125021159.GC28252@filer> <1260.1043463535@sss.pgh.pa.us> <20030125232154.GK14898@md2.mediadesign.nl> <26592.1043559288@sss.pgh.pa.us> Content-Type: text/plain Organization: Message-Id: <1043568285.818.241.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 26 Jan 2003 02:04:45 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/337 X-Sequence-Number: 984 On Sat, 2003-01-25 at 23:34, Tom Lane wrote: > pgsql.spam@vinz.nl writes: > > If one were certain his OS wouldn't do any re-ordering of writes, would it be > > safe to run with fsync = off? (not that I'm going to try this, but I'm just > > curious) > > I suppose so ... but if your OS doesn't do *any* re-ordering of writes, > I'd say you need a better OS. Even in Postgres, we'd often like the OS > to collapse multiple writes of the same disk page into one write. And > we certainly want the various writes forced by a sync() to be done with > some intelligence about disk layout, not blindly in order of issuance. And anyway, wouldn't SCSI's Tagged Command Queueing override it all, no matter if the OS did re-ordering or not? But then, it really means it when it says that fsync() succeeds, so does TCQ matter in this case? -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sun Jan 26 16:24:05 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E1EE44758C9 for ; Sun, 26 Jan 2003 16:24:03 -0500 (EST) Received: from smtp.enternet.hu (smtp.enternet.hu [62.112.192.21]) by postgresql.org (Postfix) with ESMTP id 0310D475843 for ; Sun, 26 Jan 2003 16:24:03 -0500 (EST) Received: from localhost.localdomain (maci@3e70db28.adsl.enternet.hu [62.112.219.40]) by smtp.enternet.hu (8.12.6/8.12.6) with ESMTP id h0QLNwrb036283 for ; Sun, 26 Jan 2003 22:23:59 +0100 (CET) (envelope-from eire@enternet.hu) Subject: bigserial vs serial - which one I'd have to use? From: Medve Gabor To: pgsql-performance@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.5 Date: 26 Jan 2003 22:24:41 +0100 Message-Id: <1043616281.829.38.camel@maci> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/338 X-Sequence-Number: 985 Hi all, Have you got any data (ie in percentage) of around how much more CPU work needed with the bigserial type in the queries? I have a log database with 100million records (the biggest table contains 65million records) and I use bigserial data type as primary key now. The primary key looks this way: YYYYMMDD1xxxxxxx where the first 8 numbers are the date, and the x's are the record sequence number on that day. This way the records are in ascendant order. Almost all of the queries contains date constraints (PK like 'YYYYMMDD%'). I'd like to know if I do it in a stupid way or not. I'm not a DBA expert so every idea are welcome. If you need more information about the hardware/software environment, the DB structure then I'll post them. Thanks in advance for your help. Gabor From pgsql-performance-owner@postgresql.org Sun Jan 26 18:10:33 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B0F7E475843 for ; Sun, 26 Jan 2003 18:10:32 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id 37C4C47580B for ; Sun, 26 Jan 2003 18:10:32 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id 75C14C003; Sun, 26 Jan 2003 23:10:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id 471418736; Mon, 27 Jan 2003 08:10:09 +0900 (JST) Date: Mon, 27 Jan 2003 08:10:09 +0900 (JST) From: Curt Sampson To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: LOCK TABLE & speeding up mass data loads In-Reply-To: <1043522349.818.36.camel@haggis> Message-ID: References: <1043521053.818.32.camel@haggis> <1043521665.58142.135.camel@jester> <1043522349.818.36.camel@haggis> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/339 X-Sequence-Number: 986 On Sun, 25 Jan 2003, Ron Johnson wrote: > > Oh, and you're using COPY right? > > No. Too much data manipulation to do 1st. Also, by committing every > X thousand rows, then if the process must be aborted, then there's > no huge rollback, and the script can then skip to the last comitted > row and pick up from there. I don't see how the amount of data manipulation makes a difference. Where you now issue a BEGIN, issue a COPY instead. Where you now INSERT, just print the data for the columns, separated by tabs. Where you now issue a COMMIT, end the copy. cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-general-owner@postgresql.org Sun Jan 26 19:54:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9DF224761DD; Sun, 26 Jan 2003 19:54:50 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 40915476128; Sun, 26 Jan 2003 19:54:49 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h0R0sP721325; Sun, 26 Jan 2003 19:54:25 -0500 (EST) From: Bruce Momjian Message-Id: <200301270054.h0R0sP721325@candle.pha.pa.us> Subject: Re: [PERFORM] optimizing query In-Reply-To: <25976.1043335579@sss.pgh.pa.us> To: Tom Lane Date: Sun, 26 Jan 2003 19:54:25 -0500 (EST) Cc: Chantal Ackermann , Stephan Szabo , pgsql-general@postgresql.org, pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/1102 X-Sequence-Number: 36223 Tom Lane wrote: > > postgresql.conf: > > shared_buffers: 121600 > > max_connections: 64 > > max_fsm_relations = 200 > > max_fsm_pages = 40000 > > effective_cache_size = 8000 > > Try increasing sort_mem. > > Also, I'd back off on shared_buffers if I were you. There's no evidence > that values above a few thousand buy anything. Increasing shared_buffers above several thousand will only be a win if your entire working set will fit in the larger buffer pool, but didn't in the previous size. If you working set is smaller or larger than that, pushing it above several thousand isn't a win. Is that a more definitive answer? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Mon Jan 27 03:18:22 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 77D12475425 for ; Mon, 27 Jan 2003 03:18:20 -0500 (EST) Received: from perrin.int.nxad.com (internal.ext.nxad.com [66.250.180.251]) by postgresql.org (Postfix) with ESMTP id 49F07476A02 for ; Mon, 27 Jan 2003 03:18:15 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 55B4220F01; Mon, 27 Jan 2003 00:17:45 -0800 (PST) Date: Mon, 27 Jan 2003 00:17:45 -0800 From: Sean Chittenden To: Tom Lane Cc: Jeff , Bruce Momjian , Josh Berkus , Roman Fail , "sszabo@megazone23.bigpanda.com" , "pgsql-performance@postgresql.org" Subject: Re: 7.3.1 New install, large queries are slow Message-ID: <20030127081745.GK15936@perrin.int.nxad.com> References: <21623.1042865371@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21623.1042865371@sss.pgh.pa.us> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 6CEB 1B06 BFD3 70F6 95BE 7E4D 8E85 2E0A 5F5B 3ECB X-Web-Homepage: http://sean.chittenden.org/ X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/341 X-Sequence-Number: 988 > >> Yeah, but isn't that theory a hangover from pre-Unix operating systems? > > > Informix, oracle, etc all do raw device access bypassing the kernels > > buffering, etc. So they need heaping gobules of memory to do the same > > thing the kernel does.. > > D'oh, I believe Jeff's put his finger on it. You need lotsa RAM if you > are trying to bypass the OS. But Postgres would like to work with the > OS, not bypass it. > > > but since they know the exact patterns of data and > > how things will be done they can fine tune their buffer caches to get much > > better performance than the kernel (15-20% in informix's case) since the > > kernel needs to be a "works good generally" > > They go to all that work for 15-20% ??? Remind me not to follow that > primrose path. I can think of lots of places where we can buy 20% for > less work than implementing (and maintaining) our own raw-device access > layer. This is related somewhat to the raw device access discussion. This is a quote from Matt Dillion (FreeBSD VM guru) on the topic of disk caches (Message-Id: <200301270657.h0R6v2qH071774@apollo.backplane.com>) and a few bits at the end: ### Begin quote Mmmmm. Basically what it comes down to is that without foreknowledge of the data locations being accessed, it is not possible for any cache algorithm to adapt to all the myriad ways data might be accessed. If you focus the cache on one methodology it will probably perform terribly when presented with some other methodology. What this means is that for the cases where you *KNOW* how a program intends to access a dataset larger then main memory, it is better to have the program explicitly cache/not-cache the data under program control rather then trying to force the system cache to adapt. I'll also be nice and decode some of Terry's Jargon for the rest of the readers. :will result in significant failure of random page replacement to :result in cache hits; likewise, going to 85% overage will practically :guarantee an almost 100% failure rate, as cyclical access with random :replacement is statistically more likely, in aggregate, to replace :the pages which are there longer (the probability is iterative and :additive: it's effectively a permutation). What Terry is saying is that if you have a dataset that is 2x the size of your cache, the cache hit rate on that data with random page replacement is NOT going to be 50%. This is because with random page replacement the likelihood of a piece of data being found in the cache depends on how long the data has been sitting in the cache. The longer the data has been sitting in the cache, the less likely you will find it when you need it (because it is more likely to have been replaced by the random replacement algorithm over time). So, again, the best caching methodology to use in the case where you *know* how much data you will be accessing and how you will access it is to build the caching directly into your program and not depend on system caching at all (for datasets which are far larger then main memory). This is true of all systems, not just BSD. This is one reason why databases do their own caching (another is so databases know when an access will require I/O for scheduling reasons, but that's a different story). The FreeBSD VM caching system does prevent one process from exhausting another process's cached data due to a sequential access, but the FreeBSD VM cache does not try to outsmart sequential data accesses to datasets which are larger then available cache space because it's an insanely difficult (impossible) problem to solve properly without foreknowledge of what data elements will be accessed when. This isn't to say that we can't improve on what we have now. I certainly think we can. But there is no magic bullet that will deal with every situation. -Matt ### End quote So if there really is only a 15-20% performance gain to be had from using raw disk access, that 15-20% loss comes from not being able to tell the OS what to cache, what not to cache, and what order to have the pages in... which only really matters if there is RAM available to the kernel to cache, and that it is able to determine what is valuable to cache in the course of its operations. Predictive caching by the OS isn't done because it understands PostgreSQL, because it understands a generic algorithm for page hits/misses. What is interesting after reading this, however, is the prospect of a 15-20% speed up on certain tables that we know are accessed frequently by implicitly specifying a set of data to be preferred in a user space cache. It's impossible for the OS to cache the pages that make the biggest impact on user visible performance given the OS has no understanding of what pages make a big difference on user visible performance, a user land database process, however, would. As things stand, it's entirely possible for a set of large queries to come through and wipe the kernel's cache that smaller queries were using. Once a cache misses, the kernel then has to fetch the data again which could slow down over all number of transactions per second. That said, this is something that an in-database scheduler could avoid by placing a lower priority on larger, more complex queries with the assumption being that having the smaller queries continue to process and get in/out is more important than shaving a few seconds off of a larger query that would deplete the cache used by the smaller queries. Oh to be a DBA and being able to make those decisions instead of the kernel... Hrm, so two ideas or questions come to mind: 1) On some of my really large read only queries, it would be SUUUPER nice to be able to re-nice the process from SQL land to 5, 10, or even 20. IIRC, BSD's VM system is smart enough to prevent lower priority jobs from monopolizing the disk cache, which would let the smaller faster turn around queries, continue to exist with their data in the kernel's disk cache. (some kind of query complexity threshold that results in a reduction of priority or an explicit directive to run at a lower priority) 2) Is there any way of specifying that a particular set of tables should be kept in RAM or some kind of write through cache? I know data is selected into a backend out of the catalogs, but would it be possible to have them kept in memory and only re-read on change with some kind of semaphore? Now that all system tables are in their own schemas (pg_catalog and pg_toast), would it be hard to set a flag on a change to those tables that would cause the postmaster, or children, to re-read then instead of rely on their cache? With copy-on-write forking, this could be pretty efficient if the postmaster did this and forked off a copy with the tables already in memory instead of on disk. Just a few ideas/ramblings, hope someone finds them interesting... the renice function is one that I think I'll spend some time looking into here shortly actually. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Mon Jan 27 04:08:32 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3E39D475E3A for ; Mon, 27 Jan 2003 04:08:29 -0500 (EST) Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) by postgresql.org (Postfix) with ESMTP id 8613B475425 for ; Mon, 27 Jan 2003 04:08:28 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao01.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030127090829.IXJQ16369.lakemtao01.cox.net@[192.168.1.1]> for ; Mon, 27 Jan 2003 04:08:29 -0500 Subject: Re: LOCK TABLE & speeding up mass data loads From: Ron Johnson To: PgSQL Performance ML In-Reply-To: References: <1043521053.818.32.camel@haggis> <1043521665.58142.135.camel@jester> <1043522349.818.36.camel@haggis> Content-Type: text/plain Organization: Message-Id: <1043658500.818.398.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 27 Jan 2003 03:08:20 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/342 X-Sequence-Number: 989 On Sun, 2003-01-26 at 17:10, Curt Sampson wrote: > On Sun, 25 Jan 2003, Ron Johnson wrote: > > > > Oh, and you're using COPY right? > > > > No. Too much data manipulation to do 1st. Also, by committing every > > X thousand rows, then if the process must be aborted, then there's > > no huge rollback, and the script can then skip to the last comitted > > row and pick up from there. > > I don't see how the amount of data manipulation makes a difference. > Where you now issue a BEGIN, issue a COPY instead. Where you now INSERT, > just print the data for the columns, separated by tabs. Where you now > issue a COMMIT, end the copy. Yes, create an input file for COPY. Great idea. However, If I understand you correctly, then if I want to be able to not have to roll-back and re-run and complete COPY (which may entail millions of rows), then I'd have to have thousands of seperate input files (which would get processed sequentially). Here's what I'd like to see: COPY table [ ( column [, ...] ) ] FROM { 'filename' | stdin } [ [ WITH ] [ BINARY ] [ OIDS ] [ DELIMITER [ AS ] 'delimiter' ] [ NULL [ AS ] 'null string' ] ] [COMMIT EVERY ... ROWS WITH LOGGING] <<<<<<<<<<<<< [SKIP ... ROWS] <<<<<<<<<<<<< This way, if I'm loading 25M rows, I can have it commit every, say, 1000 rows, and if it pukes 1/2 way thru, then when I restart the COPY, it can SKIP past what's already been loaded, and proceed apace. -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 27 04:18:46 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AF2B3475F38 for ; Mon, 27 Jan 2003 04:18:44 -0500 (EST) Received: from lakemtao04.cox.net (lakemtao04.cox.net [68.1.17.241]) by postgresql.org (Postfix) with ESMTP id E538E475E75 for ; Mon, 27 Jan 2003 04:18:43 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao04.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030127091845.UCKR22825.lakemtao04.cox.net@[192.168.1.1]> for ; Mon, 27 Jan 2003 04:18:45 -0500 Subject: Re: bigserial vs serial - which one I'd have to use? From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <1043616281.829.38.camel@maci> References: <1043616281.829.38.camel@maci> Content-Type: text/plain Organization: Message-Id: <1043659121.815.407.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 27 Jan 2003 03:18:41 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/343 X-Sequence-Number: 990 On Sun, 2003-01-26 at 15:24, Medve Gabor wrote: > Hi all, > > Have you got any data (ie in percentage) of around how much more CPU > work needed with the bigserial type in the queries? > > I have a log database with 100million records (the biggest table > contains 65million records) and I use bigserial data type as primary key > now. The primary key looks this way: YYYYMMDD1xxxxxxx where the first 8 > numbers are the date, and the x's are the record sequence number on that > day. This way the records are in ascendant order. Almost all of the > queries contains date constraints (PK like 'YYYYMMDD%'). I'd like to > know if I do it in a stupid way or not. I'm not a DBA expert so every > idea are welcome. If you need more information about the > hardware/software environment, the DB structure then I'll post them. I think you can only do LIKE queries on CHAR-type fields. BETWEEN ought to help you, though: SELECT * FROM foo where prim_key BETWEEN YYYYMMDD00000000 and YYYYMMDD999999999; Alternatively, if you really want to do 'YYYYMMDD%', you could create a functional index on to_char(prim_key). Lastly, you could create 2 fields and create a compound PK: PK_DATE DATE, PK_SERIAL BIGINT Then you could say: SELECT * FROM foo where pk_date = 'YYYY-MM-DD' Of course, then you'd be adding an extra 8 bytes to each column... -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 27 04:44:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 39B96476142 for ; Mon, 27 Jan 2003 04:44:46 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id D8A28476135 for ; Mon, 27 Jan 2003 04:44:43 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0R9il417579 for ; Mon, 27 Jan 2003 15:14:47 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0R9il717574 for ; Mon, 27 Jan 2003 15:14:47 +0530 From: "Shridhar Daithankar" To: PgSQL Performance ML Date: Mon, 27 Jan 2003 15:15:07 +0530 MIME-Version: 1.0 Subject: Re: LOCK TABLE & speeding up mass data loads Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E354CFB.32732.A38120C@localhost> References: In-reply-to: <1043658500.818.398.camel@haggis> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/344 X-Sequence-Number: 991 On 27 Jan 2003 at 3:08, Ron Johnson wrote: > Here's what I'd like to see: > COPY table [ ( column [, ...] ) ] > FROM { 'filename' | stdin } > [ [ WITH ] > [ BINARY ] > [ OIDS ] > [ DELIMITER [ AS ] 'delimiter' ] > [ NULL [ AS ] 'null string' ] ] > [COMMIT EVERY ... ROWS WITH LOGGING] <<<<<<<<<<<<< > [SKIP ... ROWS] <<<<<<<<<<<<< > > This way, if I'm loading 25M rows, I can have it commit every, say, > 1000 rows, and if it pukes 1/2 way thru, then when I restart the > COPY, it can SKIP past what's already been loaded, and proceed apace. IIRc, there is a hook to \copy, not the postgreSQL command copy for how many transactions you would like to see. I remember to have benchmarked that and concluded that doing copy in one transaction is the fastest way of doing it. DOn't have a postgresql installation handy, me being in linux, but this is definitely possible.. Bye Shridhar -- I still maintain the point that designing a monolithic kernel in 1991 is afundamental error. Be thankful you are not my student. You would not get ahigh grade for such a design :-)(Andrew Tanenbaum to Linus Torvalds) From pgsql-performance-owner@postgresql.org Mon Jan 27 04:54:30 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 87E56476099 for ; Mon, 27 Jan 2003 04:54:28 -0500 (EST) Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) by postgresql.org (Postfix) with ESMTP id 64849475E3A for ; Mon, 27 Jan 2003 04:54:27 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao01.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030127095428.JDDD16369.lakemtao01.cox.net@[192.168.1.1]> for ; Mon, 27 Jan 2003 04:54:28 -0500 Subject: Re: LOCK TABLE & speeding up mass data loads From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <3E354CFB.32732.A38120C@localhost> References: <3E354CFB.32732.A38120C@localhost> Content-Type: text/plain Organization: Message-Id: <1043661264.9231.8.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 27 Jan 2003 03:54:25 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/345 X-Sequence-Number: 992 On Mon, 2003-01-27 at 03:45, Shridhar Daithankar wrote: > On 27 Jan 2003 at 3:08, Ron Johnson wrote: > > > Here's what I'd like to see: > > COPY table [ ( column [, ...] ) ] > > FROM { 'filename' | stdin } > > [ [ WITH ] > > [ BINARY ] > > [ OIDS ] > > [ DELIMITER [ AS ] 'delimiter' ] > > [ NULL [ AS ] 'null string' ] ] > > [COMMIT EVERY ... ROWS WITH LOGGING] <<<<<<<<<<<<< > > [SKIP ... ROWS] <<<<<<<<<<<<< > > > > This way, if I'm loading 25M rows, I can have it commit every, say, > > 1000 rows, and if it pukes 1/2 way thru, then when I restart the > > COPY, it can SKIP past what's already been loaded, and proceed apace. > > IIRc, there is a hook to \copy, not the postgreSQL command copy for how many I'll have to look into that. > transactions you would like to see. I remember to have benchmarked that and > concluded that doing copy in one transaction is the fastest way of doing it. Boy Scout motto: Be prepared!! (Serves me well as a DBA.) So it takes a little longer. In case of failure, the time would be more than made up. Also, wouldn't the WAL grow hugely if many millions of rows were inserted in one txn? -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 27 04:56:50 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 01E35475425 for ; Mon, 27 Jan 2003 04:56:48 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 05B14476099 for ; Mon, 27 Jan 2003 04:56:45 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0R9ujO18925 for ; Mon, 27 Jan 2003 15:26:45 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0R9uj718920 for ; Mon, 27 Jan 2003 15:26:45 +0530 From: "Shridhar Daithankar" To: PgSQL Performance ML Date: Mon, 27 Jan 2003 15:27:05 +0530 MIME-Version: 1.0 Subject: Re: LOCK TABLE & speeding up mass data loads Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E354FC9.21573.A43098B@localhost> In-reply-to: <3E354CFB.32732.A38120C@localhost> References: <1043658500.818.398.camel@haggis> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/346 X-Sequence-Number: 993 On 27 Jan 2003 at 15:15, Shridhar Daithankar wrote: > IIRc, there is a hook to \copy, not the postgreSQL command copy for how many > transactions you would like to see. I remember to have benchmarked that and > concluded that doing copy in one transaction is the fastest way of doing it. > > DOn't have a postgresql installation handy, me being in linux, but this is > definitely possible.. I am sleeping. That should have read XP rather than linux. Grrr.. Bye Shridhar -- Lowery's Law: If it jams -- force it. If it breaks, it needed replacing anyway. From pgsql-performance-owner@postgresql.org Mon Jan 27 05:00:18 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7C3064762C6 for ; Mon, 27 Jan 2003 05:00:17 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id A23E54762BE for ; Mon, 27 Jan 2003 05:00:15 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0RA0J219361 for ; Mon, 27 Jan 2003 15:30:19 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0RA0J719356 for ; Mon, 27 Jan 2003 15:30:19 +0530 From: "Shridhar Daithankar" To: PgSQL Performance ML Date: Mon, 27 Jan 2003 15:30:39 +0530 MIME-Version: 1.0 Subject: Re: LOCK TABLE & speeding up mass data loads Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E35509F.29103.A464C91@localhost> References: <3E354CFB.32732.A38120C@localhost> In-reply-to: <1043661264.9231.8.camel@haggis> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/347 X-Sequence-Number: 994 On 27 Jan 2003 at 3:54, Ron Johnson wrote: > On Mon, 2003-01-27 at 03:45, Shridhar Daithankar wrote: > > transactions you would like to see. I remember to have benchmarked that and > > concluded that doing copy in one transaction is the fastest way of doing it. > > Boy Scout motto: Be prepared!! (Serves me well as a DBA.) Goes for everything else as well.. > > So it takes a little longer. In case of failure, the time would be > more than made up. Also, wouldn't the WAL grow hugely if many millions > of rows were inserted in one txn? Nops.. If WAL starts recycling, postgresql should start flishing data from WAL to data files. At any given moment, WAL will not exceed of what you have configured. They are just read ahead logs most of the times intended for crash recovery. (Consequently it does not help setting WAL bigger than required.) Bye Shridhar -- nominal egg: New Yorkerese for expensive. From pgsql-performance-owner@postgresql.org Mon Jan 27 05:23:13 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 79DC2475E75 for ; Mon, 27 Jan 2003 05:23:12 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id C3670475E3A for ; Mon, 27 Jan 2003 05:23:11 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id 2C838C003; Mon, 27 Jan 2003 10:23:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id AD1AD8736; Mon, 27 Jan 2003 19:23:10 +0900 (JST) Date: Mon, 27 Jan 2003 19:23:10 +0900 (JST) From: Curt Sampson To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: LOCK TABLE & speeding up mass data loads In-Reply-To: <1043658500.818.398.camel@haggis> Message-ID: References: <1043521053.818.32.camel@haggis> <1043521665.58142.135.camel@jester> <1043522349.818.36.camel@haggis> <1043658500.818.398.camel@haggis> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/348 X-Sequence-Number: 995 On Mon, 27 Jan 2003, Ron Johnson wrote: > > I don't see how the amount of data manipulation makes a difference. > > Where you now issue a BEGIN, issue a COPY instead. Where you now INSERT, > > just print the data for the columns, separated by tabs. Where you now > > issue a COMMIT, end the copy. > > Yes, create an input file for COPY. Great idea. That's not quite what I was thinking of. Don't create an input file, just send the commands directly to the server (if your API supports it). If worst comes to worst, you could maybe open up a subprocess for a psql and write to its standard input. > However, If I understand you correctly, then if I want to be able > to not have to roll-back and re-run and complete COPY (which may > entail millions of rows), then I'd have to have thousands of seperate > input files (which would get processed sequentially). Right. But you can probably commit much less often than 1000 rows. 10,000 or 100,000 would probably be more practical. cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-performance-owner@postgresql.org Mon Jan 27 05:34:56 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0414A475E75 for ; Mon, 27 Jan 2003 05:34:55 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id 4BBF3475E3A for ; Mon, 27 Jan 2003 05:34:54 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id E6116C003; Mon, 27 Jan 2003 10:34:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id 0CFC58736; Mon, 27 Jan 2003 19:34:42 +0900 (JST) Date: Mon, 27 Jan 2003 19:34:42 +0900 (JST) From: Curt Sampson To: Sean Chittenden Cc: Tom Lane , Jeff , Bruce Momjian , Josh Berkus , Roman Fail , "sszabo@megazone23.bigpanda.com" , "pgsql-performance@postgresql.org" Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <20030127081745.GK15936@perrin.int.nxad.com> Message-ID: References: <21623.1042865371@sss.pgh.pa.us> <20030127081745.GK15936@perrin.int.nxad.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/349 X-Sequence-Number: 996 On Mon, 27 Jan 2003, Sean Chittenden wrote: > The FreeBSD VM caching system does prevent one process from exhausting > another process's cached data due to a sequential access, but the > FreeBSD VM cache does not try to outsmart sequential data accesses to > datasets which are larger then available cache space because it's an > insanely difficult (impossible) problem to solve properly without > foreknowledge of what data elements will be accessed when. This is not impossible; Solaris does just this. I'm a little short of time right now, but I can probably dig up the paper on google if nobody else finds it. Also, it is not hard to give the OS foreknowledge of your access pattern, if you use mmap. Just call madvise and use the MADV_RANDOM, MADV_SEQUENTIAL, MADV_WILLNEED and MADV_DONTNEED flags. (This is one of the reasons I think we might see a performance improvement from switching from regular I/O to mmap I/O.) You can go back through the archives and see a much fuller discussion of all of this. cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-performance-owner@postgresql.org Mon Jan 27 10:17:30 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 01FB6475EDC for ; Mon, 27 Jan 2003 10:17:30 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id 6363A475CA9 for ; Mon, 27 Jan 2003 10:17:29 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030127151734.JYVJ6744.lakemtao02.cox.net@[192.168.1.1]> for ; Mon, 27 Jan 2003 10:17:34 -0500 Subject: Re: 7.3.1 New install, large queries are slow From: Ron Johnson To: PgSQL Performance ML In-Reply-To: References: <21623.1042865371@sss.pgh.pa.us> <20030127081745.GK15936@perrin.int.nxad.com> Content-Type: text/plain Organization: Message-Id: <1043680648.9896.24.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 27 Jan 2003 09:17:28 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/350 X-Sequence-Number: 997 On Mon, 2003-01-27 at 04:34, Curt Sampson wrote: > On Mon, 27 Jan 2003, Sean Chittenden wrote: > > > The FreeBSD VM caching system does prevent one process from exhausting > > another process's cached data due to a sequential access, but the > > FreeBSD VM cache does not try to outsmart sequential data accesses to > > datasets which are larger then available cache space because it's an > > insanely difficult (impossible) problem to solve properly without > > foreknowledge of what data elements will be accessed when. > > This is not impossible; Solaris does just this. I'm a little short of Quite. One way to do it is: - the OS notices that process X has been sequentially reading thru file Y for, say, 3 seconds. - the OS knows that X is currently at the mid-point of file Y - OS says, "Hey, I think I'll be a bit more agressive about, when I have a bit of time, trying to read Y faster than X is requesting it It wouldn't work well, though, in a client-server DB like Postgres, which, in a busy multi-user system, is constantly hitting different parts of different files. The algorithm, though, is used in the RDBMS Rdb. It uses the algorithm above, substituting "process X" for "client X", and passes the agressive reads of Y on to the OS. It's a big win when processing a complete table, like during a CREATE INDEX, or "SELECT foo, COUNT(*)" where there's no index on foo. -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 27 14:23:21 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CBC2C475C22 for ; Mon, 27 Jan 2003 14:23:19 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 37D71475843 for ; Mon, 27 Jan 2003 14:23:19 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2327352; Mon, 27 Jan 2003 11:23:14 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Kevin Brown , pgsql-performance@postgresql.org Subject: Re: Mount options for Ext3? Date: Mon, 27 Jan 2003 11:23:58 -0800 X-Mailer: KMail [version 1.4] References: <200301241120.14404.josh@agliodbs.com> <200301241822.33731.josh@agliodbs.com> <20030125025008.GD28252@filer> In-Reply-To: <20030125025008.GD28252@filer> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301271123.58727.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/351 X-Sequence-Number: 998 Kevin, > BTW, why exactly are you running ext3? It has some nice journalling > features but it sounds like you don't want to use them.=20=20 Because our RAID array controller, an Adaptec 2200S, is only compatible wit= h=20 RedHat 8.0, without some fancy device driver hacking. It certainly wasn't = my=20 first choice, I've been using Reiser for 4 years and am very happy with it. Warning to anyone following this thread: The web site info for the 2200S s= ays=20 "Redhat and SuSE", but drivers are only available for RedHat. Adaptec's= =20 Linux guru, Brian, has been unable to get the web site maintainers to corre= ct=20 the information on the site. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Jan 27 14:32:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 73629475C22 for ; Mon, 27 Jan 2003 14:32:48 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id C8D07475843 for ; Mon, 27 Jan 2003 14:32:47 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2327378; Mon, 27 Jan 2003 11:32:53 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Medve Gabor , pgsql-performance@postgresql.org Subject: Re: bigserial vs serial - which one I'd have to use? Date: Mon, 27 Jan 2003 11:33:37 -0800 X-Mailer: KMail [version 1.4] References: <1043616281.829.38.camel@maci> In-Reply-To: <1043616281.829.38.camel@maci> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301271133.37738.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/352 X-Sequence-Number: 999 Medve, > Have you got any data (ie in percentage) of around how much more CPU > work needed with the bigserial type in the queries? >=20 > I have a log database with 100million records (the biggest table > contains 65million records) and I use bigserial data type as primary key > now. The primary key looks this way: YYYYMMDD1xxxxxxx where the first 8 > numbers are the date, and the x's are the record sequence number on that > day. This way the records are in ascendant order. Almost all of the > queries contains date constraints (PK like 'YYYYMMDD%'). I'd like to > know if I do it in a stupid way or not. I'm not a DBA expert so every > idea are welcome. If you need more information about the > hardware/software environment, the DB structure then I'll post them. Given that structure, I'd personally create a table with a 2-column primary= =20 key, one column of type DATE and one SERIAL column. Alternately, if you fi= nd=20 the conversion of DATE to char for output purposes really slows things down= ,=20 one column of INT and one of SERIAL. Either way, the two columns togethe= r=20 make up the primary key. I would definitely suggest avoiting the temptation to do this as a single= =20 column of type CHAR(). That would be vastly more costly than either=20 strategy mentioned above: DATE + SERIAL (INT) =3D 8 bytes INT + SERIAL (INT) =3D 8 bytes CHAR(16) =3D 18 bytes --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Jan 27 14:43:51 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A93AD4767D1 for ; Mon, 27 Jan 2003 14:43:49 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 0D91A4767B8 for ; Mon, 27 Jan 2003 14:43:49 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030127194350.OTHN8666.lakemtao03.cox.net@[192.168.1.1]> for ; Mon, 27 Jan 2003 14:43:50 -0500 Subject: Re: Mount options for Ext3? From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <200301271123.58727.josh@agliodbs.com> References: <200301241120.14404.josh@agliodbs.com> <200301241822.33731.josh@agliodbs.com> <20030125025008.GD28252@filer> <200301271123.58727.josh@agliodbs.com> Content-Type: text/plain Organization: Message-Id: <1043696628.9899.49.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 27 Jan 2003 13:43:48 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/353 X-Sequence-Number: 1000 On Mon, 2003-01-27 at 13:23, Josh Berkus wrote: > Kevin, > > > BTW, why exactly are you running ext3? It has some nice journalling > > features but it sounds like you don't want to use them. > > Because our RAID array controller, an Adaptec 2200S, is only compatible with > RedHat 8.0, without some fancy device driver hacking. It certainly wasn't my Binary-only, or OSS and just tuned to their kernels? -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 27 14:55:11 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 144FB475C22 for ; Mon, 27 Jan 2003 14:55:11 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id 7E32A475843 for ; Mon, 27 Jan 2003 14:55:10 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030127195511.NBQX6744.lakemtao02.cox.net@[192.168.1.1]> for ; Mon, 27 Jan 2003 14:55:11 -0500 Subject: Re: bigserial vs serial - which one I'd have to use? From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <200301271133.37738.josh@agliodbs.com> References: <1043616281.829.38.camel@maci> <200301271133.37738.josh@agliodbs.com> Content-Type: text/plain Organization: Message-Id: <1043697304.9899.60.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 27 Jan 2003 13:55:04 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/354 X-Sequence-Number: 1001 On Mon, 2003-01-27 at 13:33, Josh Berkus wrote: > Medve, > > > Have you got any data (ie in percentage) of around how much more CPU > > work needed with the bigserial type in the queries? > > > > I have a log database with 100million records (the biggest table > > contains 65million records) and I use bigserial data type as primary key > > now. The primary key looks this way: YYYYMMDD1xxxxxxx where the first 8 > > numbers are the date, and the x's are the record sequence number on that > > day. This way the records are in ascendant order. Almost all of the > > queries contains date constraints (PK like 'YYYYMMDD%'). I'd like to > > know if I do it in a stupid way or not. I'm not a DBA expert so every > > idea are welcome. If you need more information about the > > hardware/software environment, the DB structure then I'll post them. > > Given that structure, I'd personally create a table with a 2-column primary > key, one column of type DATE and one SERIAL column. Alternately, if you find > the conversion of DATE to char for output purposes really slows things down, > one column of INT and one of SERIAL. Either way, the two columns together > make up the primary key. > > I would definitely suggest avoiting the temptation to do this as a single > column of type CHAR(). That would be vastly more costly than either > strategy mentioned above: > > DATE + SERIAL (INT) = 8 bytes Ah, cool. I thought DATE was 8 bytes. Should have RTFM, of course. > INT + SERIAL (INT) = 8 bytes > > CHAR(16) = 18 bytes -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 27 15:11:39 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0BD35476B62 for ; Mon, 27 Jan 2003 15:11:39 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id A935D476B1D for ; Mon, 27 Jan 2003 15:11:33 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h0RKBI227504; Mon, 27 Jan 2003 15:11:18 -0500 (EST) From: Bruce Momjian Message-Id: <200301272011.h0RKBI227504@candle.pha.pa.us> Subject: Re: Mount options for Ext3? In-Reply-To: <20030125025008.GD28252@filer> To: Kevin Brown Date: Mon, 27 Jan 2003 15:11:18 -0500 (EST) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/355 X-Sequence-Number: 1002 Let me add that I have heard that on Linux XFS is better for PostgreSQL than either ext3 or Reiser. --------------------------------------------------------------------------- Kevin Brown wrote: > Josh Berkus wrote: > > Well, the only reason I use Ext3 rather than Ext2 is to prevent fsck's on > > restart after a crash. So I'm interested in the data option that gives the > > minimum performance hit, even if it means that I sacrifice some reliability. > > I'm running with fsynch on, and the DB is on a mirrored drive array, so I'm > > not too worried about filesystem-level errors. > > > > So would that be "data=writeback"? > > Yes. That should give almost the same semantics as ext2 does by > default, except that metadata is journalled, so no fsck needed. :-) > > In fact, I believe that's exactly how ReiserFS works, if I'm not > mistaken (I saw someone claim that it does data journalling, but I've > never seen any references to how to get ReiserFS to journal data). > > > BTW, why exactly are you running ext3? It has some nice journalling > features but it sounds like you don't want to use them. But at the > same time, it uses pre-allocated inodes just like ext2 does, so it's > possible to run out of inodes on ext2/3 while AFAIK that's not > possible under ReiserFS. That's not likely to be a problem unless > you're running a news server or something, though. :-) > > On the other hand, ext3 with data=writeback will probably be faster > than ReiserFS for a number of things. > > No idea how stable ext3 is versus ReiserFS... > > > > -- > Kevin Brown kevin@sysexperts.com > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-hackers-owner@postgresql.org Mon Jan 27 15:28:52 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 64B5A476B1E; Mon, 27 Jan 2003 15:28:51 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 8B75F476B96; Mon, 27 Jan 2003 15:26:45 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h0RKQS329900; Mon, 27 Jan 2003 15:26:28 -0500 (EST) From: Bruce Momjian Message-Id: <200301272026.h0RKQS329900@candle.pha.pa.us> Subject: Re: WAL replay logic (was Re: [PERFORM] Mount options for Ext3?) In-Reply-To: <20030125101111.GB12957@filer> To: Kevin Brown Date: Mon, 27 Jan 2003 15:26:27 -0500 (EST) Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/1027 X-Sequence-Number: 34637 Is there a TODO here? I like the idea of not writing pg_controldata, or at least allowing it not to be read, perhaps with a pg_resetxlog flag so we can cleanly recover from a corrupt pg_controldata if the WAL files are OK. We don't want to get rid of the WAL file rename optimization because those are 16mb files and keeping them from checkpoint to checkpoint is probably a win. I also like the idea of allowing something between our "at the instant" recovery, and no recovery with fsync off. A "recover from last checkpooint time" option would be really valuable for some. --------------------------------------------------------------------------- Kevin Brown wrote: > Tom Lane wrote: > > Kevin Brown writes: > > > One question I have is: in the event of a crash, why not simply replay > > > all the transactions found in the WAL? Is the startup time of the > > > database that badly affected if pg_control is ignored? > > > > Interesting thought, indeed. Since we truncate the WAL after each > > checkpoint, seems like this approach would no more than double the time > > for restart. > > Hmm...truncating the WAL after each checkpoint minimizes the amount of > disk space eaten by the WAL, but on the other hand keeping older > segments around buys you some safety in the event that things get > really hosed. But your later comments make it sound like the older > WAL segments are kept around anyway, just rotated. > > > The win is it'd eliminate pg_control as a single point of > > failure. It's always bothered me that we have to update pg_control on > > every checkpoint --- it should be a write-pretty-darn-seldom file, > > considering how critical it is. > > > > I think we'd have to make some changes in the code for deleting old > > WAL segments --- right now it's not careful to delete them in order. > > But surely that can be coped with. > > Even that might not be necessary. See below. > > > OTOH, this might just move the locus for fatal failures out of > > pg_control and into the OS' algorithms for writing directory updates. > > We would have no cross-check that the set of WAL file names visible in > > pg_xlog is sensible or aligned with the true state of the datafile > > area. > > Well, what we somehow need to guarantee is that there is always WAL > data that is older than the newest consistent data in the datafile > area, right? Meaning that if the datafile area gets scribbled on in > an inconsistent manner, you always have WAL data to fill in the gaps. > > Right now we do that by using fsync() and sync(). But I think it > would be highly desirable to be able to more or less guarantee > database consistency even if fsync were turned off. The price for > that might be too high, though. > > > We'd have to take it on faith that we should replay the visible files > > in their name order. This might mean we'd have to abandon the current > > hack of recycling xlog segments by renaming them --- which would be a > > nontrivial performance hit. > > It's probably a bad idea for the replay to be based on the filenames. > Instead, it should probably be based strictly on the contents of the > xlog segment files. Seems to me the beginning of each segment file > should have some kind of header information that makes it clear where > in the scheme of things it belongs. Additionally, writing some sort > of checksum, either at the beginning or the end, might not be a bad > idea either (doesn't have to be a strict checksum, but it needs to be > something that's reasonably likely to catch corruption within a > segment). > > Do that, and you don't have to worry about renaming xlog segments at > all: you simply move on to the next logical segment in the list (a > replay just reads the header info for all the segments and orders the > list as it sees fit, and discards all segments prior to any gap it > finds. It may be that you simply have to bail out if you find a gap, > though). As long as the xlog segment checksum information is > consistent with the contents of the segment and as long as its > transactions pick up where the previous segment's left off (assuming > it's not the first segment, of course), you can safely replay the > transactions it contains. > > I presume we're recycling xlog segments in order to avoid file > creation and unlink overhead? Otherwise you can simply create new > segments as needed and unlink old segments as policy dictates. > > > Comments anyone? > > > > > If there exists somewhere a reasonably succinct description of the > > > reasoning behind the current transaction management scheme (including > > > an analysis of the pros and cons), I'd love to read it and quit > > > bugging you. :-) > > > > Not that I know of. Would you care to prepare such a writeup? There > > is a lot of material in the source-code comments, but no coherent > > presentation. > > Be happy to. Just point me to any non-obvious source files. > > Thus far on my plate: > > 1. PID file locking for postmaster startup (doesn't strictly need > to be the PID file but it may as well be, since we're already > messing with it anyway). I'm currently looking at how to do > the autoconf tests, since I've never developed using autoconf > before. > > 2. Documenting the transaction management scheme. > > I was initially interested in implementing the explicit JOIN > reordering but based on your recent comments I think you have a much > better handle on that than I. I'll be very interested to see what you > do, to see if it's anything close to what I figure has to happen... > > > -- > Kevin Brown kevin@sysexperts.com > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Mon Jan 27 15:40:24 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F0CE2476997 for ; Mon, 27 Jan 2003 15:40:22 -0500 (EST) Received: from txsmtp03.texas.rr.com (ms-smtp-03.texas.rr.com [24.93.36.231]) by postgresql.org (Postfix) with ESMTP id B28F6476B7D for ; Mon, 27 Jan 2003 15:39:56 -0500 (EST) Received: from spaceship.com (cs24243214-140.austin.rr.com [24.243.214.140]) by txsmtp03.texas.rr.com (8.12.5/8.12.2) with ESMTP id h0RKZxEL003881 for ; Mon, 27 Jan 2003 15:35:59 -0500 (EST) Message-ID: <3E35991D.5050704@spaceship.com> Date: Mon, 27 Jan 2003 14:39:57 -0600 From: Matt Mello User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Indexing foreign keys Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/357 X-Sequence-Number: 1004 Due to reasons that everyone can probably intuit, we are porting a large server application from IBM Informix to PG. However, things that take milliseconds in IFX are taking HOURS (not joking) in PG. I *think* I may have come across some reasons why, but I would like to see if anyone else has an opinion. I could not find anything relevant in docs (but if it is there, please point me to it). Let me give an example of one of the problems... I have a table that utilizes 2 foreign keys. It has 400000 records of approximately 512 bytes each (mostly text, except for the keys). When I run a specific query on it, it takes 8000ms to complete, and it always does a full scan. I "assumed" that since I did not have to create an index on those foreign key fields in IFX, that I did not have to in PG. However, just for kicks, I created an index on those 2 fields, and my query time (after the first, longer attempt, which I presume is from loading an index) went from 8000ms to 100ms. So, do we ALWAYS have to create indexes for foreign key fields in PG? Do the docs say this? (I couldn't find the info.) I will create other threads for my other issues. Thanks! -- Matt Mello From pgsql-performance-owner@postgresql.org Mon Jan 27 15:56:40 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 23E4A47603B for ; Mon, 27 Jan 2003 15:56:40 -0500 (EST) Received: from txsmtp02.texas.rr.com (ms-smtp-02.texas.rr.com [24.93.36.230]) by postgresql.org (Postfix) with ESMTP id 8B5614759AF for ; Mon, 27 Jan 2003 15:56:39 -0500 (EST) Received: from spaceship.com (cs24243214-140.austin.rr.com [24.243.214.140]) by txsmtp02.texas.rr.com (8.12.5/8.12.2) with ESMTP id h0RKsN5D021623 for ; Mon, 27 Jan 2003 15:54:23 -0500 (EST) Message-ID: <3E359D06.5020408@spaceship.com> Date: Mon, 27 Jan 2003 14:56:38 -0600 From: Matt Mello User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Indexing foreign keys References: <3E35991D.5050704@spaceship.com> <030201c2c644$e14cfcb0$32021aac@chad> In-Reply-To: <030201c2c644$e14cfcb0$32021aac@chad> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/358 X-Sequence-Number: 1005 Yes, I had not only done a "vacuum full analyze" on the PG db once I stuffed it, but I also compared that with an IFX db that I had run "update statistics high" on. Things are much better with the FK indexes. Did the docs say to index those FK fields (is that standard in the DB industry?), or was I just spoiled by IFX doing it for me? ;) Thanks! Chad Thompson wrote: > Make sure that you've run a vacuum and an analyze. There is also a > performance hit if the types of the fields or values are different. ie int > to int8 -- Matt Mello From pgsql-performance-owner@postgresql.org Mon Jan 27 16:10:57 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D5E86476CC6 for ; Mon, 27 Jan 2003 16:10:56 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id C8DA1476B62 for ; Mon, 27 Jan 2003 16:09:04 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h0RL8xA05911; Mon, 27 Jan 2003 16:08:59 -0500 (EST) From: Bruce Momjian Message-Id: <200301272108.h0RL8xA05911@candle.pha.pa.us> Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <1043680648.9896.24.camel@haggis> To: Ron Johnson Date: Mon, 27 Jan 2003 16:08:59 -0500 (EST) Cc: PgSQL Performance ML X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/359 X-Sequence-Number: 1006 Detecting sequential scan and increasing read-ahead is a standard OS capability, and most/all do that already. Solaris has code to detect when a sequential scan is wiping the cache and adjusting the buffer frees, called "free-behind." --------------------------------------------------------------------------- Ron Johnson wrote: > On Mon, 2003-01-27 at 04:34, Curt Sampson wrote: > > On Mon, 27 Jan 2003, Sean Chittenden wrote: > > > > > The FreeBSD VM caching system does prevent one process from exhausting > > > another process's cached data due to a sequential access, but the > > > FreeBSD VM cache does not try to outsmart sequential data accesses to > > > datasets which are larger then available cache space because it's an > > > insanely difficult (impossible) problem to solve properly without > > > foreknowledge of what data elements will be accessed when. > > > > This is not impossible; Solaris does just this. I'm a little short of > > Quite. One way to do it is: > - the OS notices that process X has been sequentially reading thru > file Y for, say, 3 seconds. > - the OS knows that X is currently at the mid-point of file Y > - OS says, "Hey, I think I'll be a bit more agressive about, when I > have a bit of time, trying to read Y faster than X is requesting > it > > It wouldn't work well, though, in a client-server DB like Postgres, > which, in a busy multi-user system, is constantly hitting different > parts of different files. > > The algorithm, though, is used in the RDBMS Rdb. It uses the algorithm > above, substituting "process X" for "client X", and passes the agressive > reads of Y on to the OS. It's a big win when processing a complete > table, like during a CREATE INDEX, or "SELECT foo, COUNT(*)" where > there's no index on foo. > > -- > +---------------------------------------------------------------+ > | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | > | Jefferson, LA USA http://members.cox.net/ron.l.johnson | > | | > | "Fear the Penguin!!" | > +---------------------------------------------------------------+ > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Mon Jan 27 16:13:04 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7E384476CC6 for ; Mon, 27 Jan 2003 16:13:03 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id E98B1476C9D for ; Mon, 27 Jan 2003 16:11:18 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2334697; Mon, 27 Jan 2003 13:11:23 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Matt Mello , pgsql-performance@postgresql.org Subject: Re: Indexing foreign keys Date: Mon, 27 Jan 2003 13:12:09 -0800 X-Mailer: KMail [version 1.4] References: <3E35991D.5050704@spaceship.com> <030201c2c644$e14cfcb0$32021aac@chad> <3E359D06.5020408@spaceship.com> In-Reply-To: <3E359D06.5020408@spaceship.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301271312.09105.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/360 X-Sequence-Number: 1007 Matt, > Did the docs say to index those FK fields (is that standard in the DB=20 > industry?), or was I just spoiled by IFX doing it for me? ;) It's pretty standard in the DB industry. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Jan 27 16:15:37 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EC75A476BF8 for ; Mon, 27 Jan 2003 16:15:35 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 4129A476CED for ; Mon, 27 Jan 2003 16:13:33 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030127211335.PTRE8666.lakemtao03.cox.net@[192.168.1.1]> for ; Mon, 27 Jan 2003 16:13:35 -0500 Subject: Re: Indexing foreign keys From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <3E35991D.5050704@spaceship.com> References: <3E35991D.5050704@spaceship.com> Content-Type: text/plain Organization: Message-Id: <1043702012.9896.72.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 27 Jan 2003 15:13:32 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/361 X-Sequence-Number: 1008 On Mon, 2003-01-27 at 14:39, Matt Mello wrote: > Due to reasons that everyone can probably intuit, we are porting a large > server application from IBM Informix to PG. However, things that take > milliseconds in IFX are taking HOURS (not joking) in PG. I *think* I > may have come across some reasons why, but I would like to see if anyone > else has an opinion. I could not find anything relevant in docs (but if > it is there, please point me to it). > > Let me give an example of one of the problems... > > I have a table that utilizes 2 foreign keys. It has 400000 records of > approximately 512 bytes each (mostly text, except for the keys). When I > run a specific query on it, it takes 8000ms to complete, and it always > does a full scan. > > I "assumed" that since I did not have to create an index on those > foreign key fields in IFX, that I did not have to in PG. However, just > for kicks, I created an index on those 2 fields, and my query time > (after the first, longer attempt, which I presume is from loading an > index) went from 8000ms to 100ms. > > So, do we ALWAYS have to create indexes for foreign key fields in PG? > Do the docs say this? (I couldn't find the info.) When you say "I created an index on those 2 fields", so you mean on the fields in the 400K row table, or on the keys in the "fact tables" that the 400K row table? Also, in IFX, could the creation of the foreign indexes have implicitly created indexes? The reason I ask is that this is what happens in Pg when you create a PK. -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Jan 27 16:19:23 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A7C1D476C0D for ; Mon, 27 Jan 2003 16:19:22 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id D29DD476A75 for ; Mon, 27 Jan 2003 16:16:48 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 130F5D606; Mon, 27 Jan 2003 13:16:50 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 08CB35C03; Mon, 27 Jan 2003 13:16:50 -0800 (PST) Date: Mon, 27 Jan 2003 13:16:49 -0800 (PST) From: Stephan Szabo To: Matt Mello Cc: Subject: Re: Indexing foreign keys In-Reply-To: <3E35991D.5050704@spaceship.com> Message-ID: <20030127131057.F81562-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/362 X-Sequence-Number: 1009 On Mon, 27 Jan 2003, Matt Mello wrote: > Due to reasons that everyone can probably intuit, we are porting a large > server application from IBM Informix to PG. However, things that take > milliseconds in IFX are taking HOURS (not joking) in PG. I *think* I > may have come across some reasons why, but I would like to see if anyone > else has an opinion. I could not find anything relevant in docs (but if > it is there, please point me to it). > > Let me give an example of one of the problems... > > I have a table that utilizes 2 foreign keys. It has 400000 records of > approximately 512 bytes each (mostly text, except for the keys). When I > run a specific query on it, it takes 8000ms to complete, and it always > does a full scan. > > I "assumed" that since I did not have to create an index on those > foreign key fields in IFX, that I did not have to in PG. However, just > for kicks, I created an index on those 2 fields, and my query time > (after the first, longer attempt, which I presume is from loading an > index) went from 8000ms to 100ms. > > So, do we ALWAYS have to create indexes for foreign key fields in PG? > Do the docs say this? (I couldn't find the info.) You don't always need to create them, because there are fk patterns where an index is counterproductive, but if you're not in one of those cases you should create them. I'm not sure the docs actually say anything about this however. From pgsql-performance-owner@postgresql.org Mon Jan 27 16:25:06 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 39A15476B91 for ; Mon, 27 Jan 2003 16:25:05 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 86D78476CF4 for ; Mon, 27 Jan 2003 16:22:29 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2335945; Mon, 27 Jan 2003 13:22:34 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Stephan Szabo , Matt Mello Subject: Re: Indexing foreign keys Date: Mon, 27 Jan 2003 13:23:19 -0800 X-Mailer: KMail [version 1.4] Cc: References: <20030127131057.F81562-100000@megazone23.bigpanda.com> In-Reply-To: <20030127131057.F81562-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301271323.19644.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/363 X-Sequence-Number: 1010 Guys, > You don't always need to create them, because there are fk patterns where > an index is counterproductive, but if you're not in one of those cases you > should create them. I'm not sure the docs actually say anything about > this however. See: http://techdocs.postgresql.org/techdocs/pgsqladventuresep2.php http://techdocs.postgresql.org/techdocs/pgsqladventuresep3.php (and yes, I know I need to finish this series ...) --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Jan 27 19:05:42 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5254747627E for ; Mon, 27 Jan 2003 19:05:41 -0500 (EST) Received: from silmaril.syscor.priv (h24-77-52-251.sbm.shawcable.net [24.77.52.251]) by postgresql.org (Postfix) with ESMTP id 3B39E475D64 for ; Mon, 27 Jan 2003 19:05:40 -0500 (EST) Received: from syscor.com (strider.syscor.priv [192.168.1.3]) by silmaril.syscor.priv (8.11.1/8.11.1) with ESMTP id h0S05l120238 for ; Mon, 27 Jan 2003 16:05:47 -0800 Message-ID: <3E35C99B.5020105@syscor.com> Date: Mon, 27 Jan 2003 16:06:51 -0800 From: "Ron St.Pierre" User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.2) Gecko/20021126 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Indexing foreign keys References: <3E35991D.5050704@spaceship.com> <030201c2c644$e14cfcb0$32021aac@chad> <3E359D06.5020408@spaceship.com> <200301271312.09105.josh@agliodbs.com> In-Reply-To: <200301271312.09105.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/364 X-Sequence-Number: 1011 Josh Berkus wrote: > Matt, >>Did the docs say to index those FK fields (is that standard in the DB >>industry?), or was I just spoiled by IFX doing it for me? ;) > It's pretty standard in the DB industry. I didn't know that, but I'm new to the DB field. I've gleaned quite a few tips from this group, especially from responses to people with slow queries/databases, but this is the first I've noticed it this tip. I'll try it on my db too. -- Ron St.Pierre Syscor R&D tel: 250-361-1681 email: rstpierre@syscor.com From pgsql-performance-owner@postgresql.org Mon Jan 27 20:42:43 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 88650475E1E for ; Mon, 27 Jan 2003 20:42:41 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id 7BFBD475D64 for ; Mon, 27 Jan 2003 20:42:40 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030128014242.RREX6744.lakemtao02.cox.net@[192.168.1.1]> for ; Mon, 27 Jan 2003 20:42:42 -0500 Subject: Re: 7.3.1 New install, large queries are slow From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <200301272108.h0RL8xA05911@candle.pha.pa.us> References: <200301272108.h0RL8xA05911@candle.pha.pa.us> Content-Type: text/plain Organization: Message-Id: <1043718161.9896.120.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 27 Jan 2003 19:42:41 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/365 X-Sequence-Number: 1012 On Mon, 2003-01-27 at 15:08, Bruce Momjian wrote: > Detecting sequential scan and increasing read-ahead is a standard OS > capability, and most/all do that already. Solaris has code to detect > when a sequential scan is wiping the cache and adjusting the buffer > frees, called "free-behind." Ah, didn't know that. > --------------------------------------------------------------------------- > > Ron Johnson wrote: > > On Mon, 2003-01-27 at 04:34, Curt Sampson wrote: > > > On Mon, 27 Jan 2003, Sean Chittenden wrote: > > > > > > > The FreeBSD VM caching system does prevent one process from exhausting > > > > another process's cached data due to a sequential access, but the > > > > FreeBSD VM cache does not try to outsmart sequential data accesses to > > > > datasets which are larger then available cache space because it's an > > > > insanely difficult (impossible) problem to solve properly without > > > > foreknowledge of what data elements will be accessed when. > > > > > > This is not impossible; Solaris does just this. I'm a little short of > > > > Quite. One way to do it is: > > - the OS notices that process X has been sequentially reading thru > > file Y for, say, 3 seconds. > > - the OS knows that X is currently at the mid-point of file Y > > - OS says, "Hey, I think I'll be a bit more agressive about, when I > > have a bit of time, trying to read Y faster than X is requesting > > it > > > > It wouldn't work well, though, in a client-server DB like Postgres, > > which, in a busy multi-user system, is constantly hitting different > > parts of different files. > > > > The algorithm, though, is used in the RDBMS Rdb. It uses the algorithm > > above, substituting "process X" for "client X", and passes the agressive > > reads of Y on to the OS. It's a big win when processing a complete > > table, like during a CREATE INDEX, or "SELECT foo, COUNT(*)" where > > there's no index on foo. -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Tue Jan 28 00:46:46 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D427C475FED for ; Tue, 28 Jan 2003 00:46:44 -0500 (EST) Received: from txsmtp01.texas.rr.com (ms-smtp-01.texas.rr.com [24.93.36.229]) by postgresql.org (Postfix) with ESMTP id 52179475FEC for ; Tue, 28 Jan 2003 00:46:44 -0500 (EST) Received: from spaceship.com (cs24243214-140.austin.rr.com [24.243.214.140]) by txsmtp01.texas.rr.com (8.12.5/8.12.2) with ESMTP id h0S5fxua013648 for ; Tue, 28 Jan 2003 00:41:59 -0500 (EST) Message-ID: <3E361946.4060000@spaceship.com> Date: Mon, 27 Jan 2003 23:46:46 -0600 From: Matt Mello User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: PgSQL Performance ML Subject: Re: Indexing foreign keys References: <3E35991D.5050704@spaceship.com> <1043702012.9896.72.camel@haggis> In-Reply-To: <1043702012.9896.72.camel@haggis> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/366 X-Sequence-Number: 1013 Ron Johnson wrote: > When you say "I created an index on those 2 fields", so you mean on > the fields in the 400K row table, or on the keys in the "fact tables" > that the 400K row table? > > Also, in IFX, could the creation of the foreign indexes have implicitly > created indexes? > The reason I ask is that this is what happens in Pg when you create a > PK. > The 400K row table has 2 fields that are FK fields. The already-indexed PK fields that they reference are in another table. I just recently added indexes to the 2 FK fields in the 400K row table to get the speed boost. Yes. In IFX, when you create a FK, it seems to create indexes automatically for you, just like PG does with PK's. In fact, I can't imagine a situation where you would NOT want a FK indexed. I guess there must be one, or else I'm sure the developers would have already added auto-creation of indexes to the FK creation, as well. -- Matt Mello From pgsql-performance-owner@postgresql.org Tue Jan 28 00:51:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0F292475D99 for ; Tue, 28 Jan 2003 00:51:27 -0500 (EST) Received: from txsmtp02.texas.rr.com (ms-smtp-02.texas.rr.com [24.93.36.230]) by postgresql.org (Postfix) with ESMTP id 57F31475A71 for ; Tue, 28 Jan 2003 00:51:26 -0500 (EST) Received: from spaceship.com (cs24243214-140.austin.rr.com [24.243.214.140]) by txsmtp02.texas.rr.com (8.12.5/8.12.2) with ESMTP id h0S5nE5D023572 for ; Tue, 28 Jan 2003 00:49:15 -0500 (EST) Message-ID: <3E361A63.6010409@spaceship.com> Date: Mon, 27 Jan 2003 23:51:31 -0600 From: Matt Mello User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Indexing foreign keys References: <20030127131057.F81562-100000@megazone23.bigpanda.com> In-Reply-To: <20030127131057.F81562-100000@megazone23.bigpanda.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/367 X-Sequence-Number: 1014 > You don't always need to create them, because there are fk patterns where > an index is counterproductive, but if you're not in one of those cases you > should create them. I'm not sure the docs actually say anything about > this however. I would try to add a comment about this to the interactive docs if they weren't so far behind already (7.2.1). :\ -- Matt Mello From pgsql-performance-owner@postgresql.org Tue Jan 28 02:49:54 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BB407475F13 for ; Tue, 28 Jan 2003 02:49:52 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 45D87475DD0 for ; Tue, 28 Jan 2003 02:49:52 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 9FF89D610; Mon, 27 Jan 2003 23:49:52 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 95B215C03; Mon, 27 Jan 2003 23:49:52 -0800 (PST) Date: Mon, 27 Jan 2003 23:49:52 -0800 (PST) From: Stephan Szabo To: Matt Mello Cc: PgSQL Performance ML Subject: Re: Indexing foreign keys In-Reply-To: <3E361946.4060000@spaceship.com> Message-ID: <20030127234454.N88775-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/368 X-Sequence-Number: 1015 On Mon, 27 Jan 2003, Matt Mello wrote: > Yes. In IFX, when you create a FK, it seems to create indexes > automatically for you, just like PG does with PK's. > > In fact, I can't imagine a situation where you would NOT want a FK > indexed. I guess there must be one, or else I'm sure the developers > would have already added auto-creation of indexes to the FK creation, as > well. Any case where the pk table is small enough and the values are fairly evenly distributed so that the index isn't very selective. You end up not using the index anyway because it's not selective and you pay the costs involved in keeping it up to date. From pgsql-performance-owner@postgresql.org Tue Jan 28 05:54:53 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7C7A8475D00 for ; Tue, 28 Jan 2003 05:54:52 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id BCACD475CEE for ; Tue, 28 Jan 2003 05:54:51 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id C38ADBFFB; Tue, 28 Jan 2003 10:54:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id D07A58736; Tue, 28 Jan 2003 19:54:50 +0900 (JST) Date: Tue, 28 Jan 2003 19:54:50 +0900 (JST) From: Curt Sampson To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: 7.3.1 New install, large queries are slow In-Reply-To: <1043680648.9896.24.camel@haggis> Message-ID: References: <21623.1042865371@sss.pgh.pa.us> <20030127081745.GK15936@perrin.int.nxad.com> <1043680648.9896.24.camel@haggis> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/369 X-Sequence-Number: 1016 On Tue, 27 Jan 2003, Ron Johnson wrote: > [read-ahead detection stuff deleted] > > It wouldn't work well, though, in a client-server DB like Postgres, > which, in a busy multi-user system, is constantly hitting different > parts of different files. It works great. You just do it on a file-descriptor by file-descriptor basis. Unfortunately, I don't know of any OSes that detect backwards scans. cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-performance-owner@postgresql.org Tue Jan 28 10:15:10 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3E4CB475F39 for ; Tue, 28 Jan 2003 10:15:09 -0500 (EST) Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) by postgresql.org (Postfix) with ESMTP id C0BBB475D00 for ; Tue, 28 Jan 2003 10:15:05 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao01.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030128151508.ZUTQ16369.lakemtao01.cox.net@[192.168.1.1]> for ; Tue, 28 Jan 2003 10:15:08 -0500 Subject: Re: Indexing foreign keys From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <3E361946.4060000@spaceship.com> References: <3E35991D.5050704@spaceship.com> <1043702012.9896.72.camel@haggis> <3E361946.4060000@spaceship.com> Content-Type: text/plain Organization: Message-Id: <1043766909.9899.132.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 28 Jan 2003 09:15:09 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/370 X-Sequence-Number: 1017 On Mon, 2003-01-27 at 23:46, Matt Mello wrote: > Ron Johnson wrote: > > When you say "I created an index on those 2 fields", so you mean on > > the fields in the 400K row table, or on the keys in the "fact tables" > > that the 400K row table? > > > > Also, in IFX, could the creation of the foreign indexes have implicitly > > created indexes? > > The reason I ask is that this is what happens in Pg when you create a > > PK. > > > > The 400K row table has 2 fields that are FK fields. The already-indexed > PK fields that they reference are in another table. I just recently > added indexes to the 2 FK fields in the 400K row table to get the speed > boost. > > Yes. In IFX, when you create a FK, it seems to create indexes > automatically for you, just like PG does with PK's. > > In fact, I can't imagine a situation where you would NOT want a FK > indexed. I guess there must be one, or else I'm sure the developers > would have already added auto-creation of indexes to the FK creation, as > well. When I took my brain out of 1st gear, it was "Doh!": I realized that I was thinking backwards... -- +---------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "Fear the Penguin!!" | +---------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Tue Jan 28 12:29:50 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 11DF24770C0 for ; Tue, 28 Jan 2003 12:29:49 -0500 (EST) Received: from smtp.web.de (smtp03.web.de [217.72.192.158]) by postgresql.org (Postfix) with ESMTP id DD21347713C for ; Tue, 28 Jan 2003 11:50:52 -0500 (EST) Received: from p50818051.dip0.t-ipconnect.de ([80.129.128.81] helo=web.de) by smtp.web.de with asmtp (WEB.DE(Exim) 4.93 #1) id 18dYwo-00075t-00 for pgsql-performance@postgresql.org; Tue, 28 Jan 2003 17:50:55 +0100 Message-ID: <3E36B4F2.1020506@web.de> Date: Tue, 28 Jan 2003 17:50:58 +0100 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: inefficient query plan with left joined view Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/371 X-Sequence-Number: 1018 What I'm doing on V7.3.1: select t1.keycol, t2.keycol from tab1 t1 LEFT join myview t2 on t1.keycol=t2.keycol where t1.keycol=1000001 t1 has 100 rows, t2 has 4000, both with keycol as PK. the view is created as CREATE myview AS SELECT keycol, 22::integer as calc_col FROM tab2 The query plan will show an ugly subquery scan on all tab2 rows. If the view is created without calculated columns, the query plan looks as expected showing and index scan on tab2 with the correct condition, inner join will always be ok. In real life, the view consists of a lot more tables, and the tables may contain >1,000,000 rows so you may imagine the performance... From pgsql-performance-owner@postgresql.org Tue Jan 28 15:05:09 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 37E2F47728F for ; Tue, 28 Jan 2003 14:41:54 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 5054D4775DC for ; Tue, 28 Jan 2003 13:30:09 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0SIU85u022634; Tue, 28 Jan 2003 13:30:08 -0500 (EST) To: Andreas Pflug Cc: pgsql-performance@postgresql.org Subject: Re: inefficient query plan with left joined view In-reply-to: <3E36B4F2.1020506@web.de> References: <3E36B4F2.1020506@web.de> Comments: In-reply-to Andreas Pflug message dated "Tue, 28 Jan 2003 17:50:58 +0100" Date: Tue, 28 Jan 2003 13:30:07 -0500 Message-ID: <22633.1043778607@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/372 X-Sequence-Number: 1019 Andreas Pflug writes: > What I'm doing on V7.3.1: > select t1.keycol, t2.keycol > from tab1 t1 > LEFT join myview t2 on t1.keycol=t2.keycol > where t1.keycol=1000001 > the view is created as > CREATE myview AS SELECT keycol, 22::integer as calc_col FROM tab2 The subquery isn't pulled up because it doesn't pass the has_nullable_targetlist test in src/backend/optimizer/plan/planner.c. If we did flatten it, then references to calc_col wouldn't correctly go to NULL when the LEFT JOIN should make them do so --- they'd be 22 all the time. As the notes in that routine say, it could be made smarter: strict functions of nullable variables could be allowed. So if your real concern is not '22' but something like 'othercol + 22' then this is fixable. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jan 28 15:38:06 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A27A647933F for ; Tue, 28 Jan 2003 15:29:45 -0500 (EST) Received: from smtp.web.de (smtp02.web.de [217.72.192.151]) by postgresql.org (Postfix) with ESMTP id 8D35F476AD8 for ; Tue, 28 Jan 2003 14:31:48 -0500 (EST) Received: from p50818051.dip0.t-ipconnect.de ([80.129.128.81] helo=web.de) by smtp.web.de with asmtp (WEB.DE(Exim) 4.93 #1) id 18dbSV-0002QB-00 for pgsql-performance@postgresql.org; Tue, 28 Jan 2003 20:31:47 +0100 Message-ID: <3E36DAA2.4010003@web.de> Date: Tue, 28 Jan 2003 20:31:46 +0100 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: inefficient query plan with left joined view References: <3E36B4F2.1020506@web.de> <22633.1043778607@sss.pgh.pa.us> In-Reply-To: <22633.1043778607@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/373 X-Sequence-Number: 1020 Tom Lane wrote: >The subquery isn't pulled up because it doesn't pass the >has_nullable_targetlist test in src/backend/optimizer/plan/planner.c. >If we did flatten it, then references to calc_col wouldn't correctly >go to NULL when the LEFT JOIN should make them do so --- they'd be >22 all the time. > >As the notes in that routine say, it could be made smarter: strict >functions of nullable variables could be allowed. So if your real >concern is not '22' but something like 'othercol + 22' then this is >fixable. > > regards, tom lane > > > Tom, actually my views do use calculated columns (mostly concated strings, e.g. full name from title/1st/last name). As the example shows even columns that are never used will be taken into account when checking has_nullable_targetlist. Unfortunately I have a lot of views containing views which containing.... delivering a lot more columns than needed. But they are checked anyway... I'd expect the parser to look at the join construction only to find out about available data. Why should the selected (and even unselected) columns be evaluated if the join delivers no result? Maybe this can be achieved by checking only JOIN ON/WHERE columns with has_nullable_targetlist? Regards, Andreas From pgsql-general-owner@postgresql.org Tue Jan 28 17:56:49 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 884F8479285 for ; Tue, 28 Jan 2003 17:56:47 -0500 (EST) Received: from mail.com-stock.com (mail.com-stock.com [204.255.137.254]) by postgresql.org (Postfix) with ESMTP id D283A4771CD for ; Tue, 28 Jan 2003 16:27:20 -0500 (EST) Received: by mail.com-stock.com (Postfix, from userid 1000) id 00D8713E; Tue, 28 Jan 2003 16:27:14 -0500 (EST) Received: from deimos (deimos.com-stock.com [204.255.137.120]) by mail.com-stock.com (Postfix) with SMTP id B2524DA36 for ; Tue, 28 Jan 2003 16:27:13 -0500 (EST) Message-ID: <020301c2c715$03cef290$7889ffcc@comstock.com> From: "Gregory Wood" To: "PostgreSQL-General" References: <20030127234454.N88775-100000@megazone23.bigpanda.com> Subject: Re: [PERFORM] Indexing foreign keys Date: Tue, 28 Jan 2003 16:23:08 -0500 Organization: Comstock Net Services 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/1274 X-Sequence-Number: 36395 > > In fact, I can't imagine a situation where you would NOT want a FK > > indexed. I guess there must be one, or else I'm sure the developers > > would have already added auto-creation of indexes to the FK creation, as > > well. > > Any case where the pk table is small enough and the values are fairly > evenly distributed so that the index isn't very selective. You end up not > using the index anyway because it's not selective and you pay the costs > involved in keeping it up to date. Or you want an index on two or more fields that includes the FK as the primary field. No sense in making two indexes. Greg From pgsql-performance-owner@postgresql.org Tue Jan 28 19:12:19 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9574F477645 for ; Tue, 28 Jan 2003 18:47:01 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 68B054775C5 for ; Tue, 28 Jan 2003 17:40:58 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0SMf05u004510; Tue, 28 Jan 2003 17:41:00 -0500 (EST) To: Andreas Pflug Cc: pgsql-performance@postgresql.org Subject: Re: inefficient query plan with left joined view In-reply-to: <3E36DAA2.4010003@web.de> References: <3E36B4F2.1020506@web.de> <22633.1043778607@sss.pgh.pa.us> <3E36DAA2.4010003@web.de> Comments: In-reply-to Andreas Pflug message dated "Tue, 28 Jan 2003 20:31:46 +0100" Date: Tue, 28 Jan 2003 17:41:00 -0500 Message-ID: <4509.1043793660@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/374 X-Sequence-Number: 1021 Andreas Pflug writes: > As the example shows even > columns that are never used will be taken into account when checking > has_nullable_targetlist. It's not really practical to do otherwise, as the code that needs to check this doesn't have access to a list of the columns actually used. Even if we kluged things up enough to make it possible to find that out, that would merely mean that *some* of your queries wouldn't have a problem. What about improving the intelligence of the nullability check --- or do you have non-strict expressions in there? regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jan 28 23:19:21 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A4E0E477389 for ; Tue, 28 Jan 2003 23:18:35 -0500 (EST) Received: from johnlaptop.darkcore.net (h24-82-231-93.wp.shawcable.net [24.82.231.93]) by postgresql.org (Postfix) with ESMTP id 9873B476F96 for ; Tue, 28 Jan 2003 22:21:40 -0500 (EST) Received: by johnlaptop.darkcore.net (Postfix, from userid 501) id 17751F2497; Tue, 28 Jan 2003 22:21:41 -0500 (EST) Subject: Re: Query plan and Inheritance. Weird behavior From: John Lange To: Andras Kadinger Cc: PostgreSQL In-Reply-To: <3E3717A4.CAD034EC@surfnonstop.com> References: <3E31A255.5250DCF1@surfnonstop.com> <1043770598.2045.23.camel@johnlaptop.darkcore.net> <3E3717A4.CAD034EC@surfnonstop.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8-3mdk Date: 28 Jan 2003 21:21:41 -0600 Message-Id: <1043810501.3719.28.camel@johnlaptop.darkcore.net> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/375 X-Sequence-Number: 1022 > I don't see how performance would be significantly better if you stored > the common columns of all rows (parent and children) in the parent > table, in contrast with how it is done now, storing entire rows of child > tables in the child table and omitting them from the parent table. Well there are a couple of points. Firstly, from the simple standpoint of database normalization you shouldn't have tables that have the same columns. The way it is implemented, child tables are copies of parent tables. But more importantly it is bad for performance because selecting from a parent table causes the same select to be done on all the child tables. In my case selecting from the parent causes six selects to be done (one for every child table). I would have assumed that child tables only contained the new columns unique to it, not duplicates of the columns already in the parent table. An insert to a child table would actually cause two inserts to be done (assuming only one level of inheritance), one to the parent, and then one to the child. Therefore, selects from the parent table would only require a single select (because the common data is all stored in the parent table). Selects to a child would require two selects to get the entire row (one to the parent, one to the child). Similar to a view. As I said previously, performance would depend on what operation you were mostly doing. I think I have more or less covered this in my previous postings. John Lange On Tue, 2003-01-28 at 17:52, Andras Kadinger wrote: > I see. > > I don't see how performance would be significantly better if you stored > the common columns of all rows (parent and children) in the parent > table, in contrast with how it is done now, storing entire rows of child > tables in the child table and omitting them from the parent table. > > Hmm, reviewing your posts to pgsql-performance, I must admit I cannot > really see what you feel you are losing performance-wise. > > As the discussion on pgsql-performance seems to have died off, would you > be willing to explain to me? > > Regards, > Andras > > John Lange wrote: > > > > No, the keyword ONLY will limit selects to that table ONLY. I need to > > return the rows which are common to all tables. Postgres is doing the > > work in the correct way, however, the issue is the underlaying design > > which is terribly inefficient requiring a separate table scan for every > > child table. > > > > Thanks for the suggestion. > > > > John Lange > > > > On Fri, 2003-01-24 at 14:30, Andras Kadinger wrote: > > > Hi John, > > > > > > Isn't the keyword ONLY is what you are after? > > > > > > "EXPLAIN select * from tbl_objects where id = 1;" - this will select > > > from table tbl_objects and all it's descendant tables. > > > > > > "EXPLAIN select * from tbl_objects ONLY where id = 1;" - this will > > > select from table tbl_objects only. > > > > > > Regards, > > > Andras Kadinger From pgsql-performance-owner@postgresql.org Wed Jan 29 01:37:46 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 29D70479EA8 for ; Wed, 29 Jan 2003 00:54:44 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 33BB44776AE for ; Wed, 29 Jan 2003 00:05:12 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0T55G5u019548; Wed, 29 Jan 2003 00:05:16 -0500 (EST) To: John Lange Cc: Andras Kadinger , PostgreSQL Subject: Re: Query plan and Inheritance. Weird behavior In-reply-to: <1043810501.3719.28.camel@johnlaptop.darkcore.net> References: <3E31A255.5250DCF1@surfnonstop.com> <1043770598.2045.23.camel@johnlaptop.darkcore.net> <3E3717A4.CAD034EC@surfnonstop.com> <1043810501.3719.28.camel@johnlaptop.darkcore.net> Comments: In-reply-to John Lange message dated "28 Jan 2003 21:21:41 -0600" Date: Wed, 29 Jan 2003 00:05:15 -0500 Message-ID: <19547.1043816715@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/376 X-Sequence-Number: 1023 John Lange writes: > Firstly, from the simple standpoint of database normalization you > shouldn't have tables that have the same columns. The way it is > implemented, child tables are copies of parent tables. There is no copied data though. Or are you saying that if any table in the database has, say, a timestamp column, then it's a failure of normalization for any other one to have a timestamp column? Don't think I buy that. > But more importantly it is bad for performance because selecting from a > parent table causes the same select to be done on all the child tables. So? The same amount of data gets scanned either way. To the extent that the planner fails to generate an optimal plan in such cases, we have a performance problem --- but that's just an implementation shortcoming, not a fundamental limitation AFAICS. The only real disadvantage I can see to the current storage scheme is that we can't easily make an index that covers both a parent and all its children; the index would have to include a table pointer as well as a row pointer. This creates problems for foreign keys and unique constraints. But there is more than one way to attack that. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jan 29 03:25:09 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5F6D2477109 for ; Wed, 29 Jan 2003 03:14:07 -0500 (EST) Received: from ms-smtp-01.texas.rr.com (ms-smtp-01.texas.rr.com [24.93.36.229]) by postgresql.org (Postfix) with ESMTP id B8FA147A11A for ; Wed, 29 Jan 2003 01:22:53 -0500 (EST) Received: from spaceship.com (cs24243214-140.austin.rr.com [24.243.214.140]) by ms-smtp-01.texas.rr.com (8.12.5/8.12.2) with ESMTP id h0T6I0Hs016054 for ; Wed, 29 Jan 2003 01:18:00 -0500 (EST) Message-ID: <3E37733D.90205@spaceship.com> Date: Wed, 29 Jan 2003 00:22:53 -0600 From: Matt Mello User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance Subject: 1 char in the world Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/377 X-Sequence-Number: 1024 TEXT vs "char" ... vs BOOLEAN I am porting from Informix to PG. In doing so, I had to pick some data types for fields, and began wondering about the performance of char/text fields with one character. For example, I have a field which has one of the following values/states: {'A', 'D', 'F', 'U'}. Since CHAR(n), VARCHAR, and TEXT are all supposed to have the same performance according to the docs, it seems that they will all perform the same. For this reason, I did not squabble over which one of these to use. However, since "char" is implemented differently, I thought I would compare it to one of the others. I chose to pit TEXT against "char". Test query = explain analyze select count(*) from table where onechar='D'; Table size = 512 wide [mostly TEXT] * 400000 rows Performance averages: "char" 44ms TEXT 63ms This seems somewhat reasonable, and makes me want to use "char" for my single-char field. Does everyone else find this to be reasonable? Is this pretty much the behavior I can expect on extraordinarily large tables, too? And, should I worry about things like the backend developers removing "char" as a type later? -- This naturally led me to another question. How do TEXT, "char", and BOOLEAN compare for storing t/f values. The test results I saw were surprising. Test query= "char"/TEXT: explain analyze select count(*) from table where bool='Y'; boolean: explain analyze select count(*) from table where bool=true; Table size (see above) Performance averages: TEXT 24ms BOOLEAN 28ms "char" 17ms Why does boolean rate closer to TEXT than "char"? I would think that BOOLEANs would actually be stored like "char"s to prevent using the extra 4 bytes with TEXT types. Based on these results, I will probably store my booleans as "char" instead of boolean. I don't use stored procedures with my application server, so I should never need my booleans to be the BOOLEAN type. I can convert faster in my own code. -- NOTE: the above tests all had the same relative data in the different fields (what was in TEXT could be found in "char", etc.) and were all indexed equally. Thanks! -- Matt Mello From pgsql-performance-owner@postgresql.org Wed Jan 29 04:22:38 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 59C34477494 for ; Wed, 29 Jan 2003 04:03:32 -0500 (EST) Received: from ogoun.tvnet.hu (ogoun.tvnet.hu [195.38.96.10]) by postgresql.org (Postfix) with ESMTP id CEBAB479F0F for ; Wed, 29 Jan 2003 02:52:33 -0500 (EST) Received: from surfnonstop.com (kadinger.telant.tvnet.hu [195.38.114.41]) by ogoun.tvnet.hu (8.11.6/8.11.6) with ESMTP id h0T7qKW25887; Wed, 29 Jan 2003 08:52:21 +0100 Message-ID: <3E378828.91E23F3D@surfnonstop.com> Date: Wed, 29 Jan 2003 08:52:08 +0100 From: Andras Kadinger X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.19 i686) X-Accept-Language: hu, en, de MIME-Version: 1.0 To: John Lange Cc: PostgreSQL Subject: Re: Query plan and Inheritance. Weird behavior References: <3E31A255.5250DCF1@surfnonstop.com> <1043770598.2045.23.camel@johnlaptop.darkcore.net> <3E3717A4.CAD034EC@surfnonstop.com> <1043810501.3719.28.camel@johnlaptop.darkcore.net> Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/378 X-Sequence-Number: 1025 John Lange wrote: > > > I don't see how performance would be significantly better if you stored > > the common columns of all rows (parent and children) in the parent > > table, in contrast with how it is done now, storing entire rows of child > > tables in the child table and omitting them from the parent table. > > Well there are a couple of points. > > Firstly, from the simple standpoint of database normalization you > shouldn't have tables that have the same columns. The way it is > implemented, child tables are copies of parent tables. As Tom pointed out, only the schema is copied, but not the data. This has the following advantages: - if you select from child tables, PostgreSQL will only have to scan rows that belong to that child (and further down), and not all rows in all tables of the inheritance hierarchy; so if you have 100 million rows in the whole hierarchy, but only have say 1 million in the child you are currently interested in, you only have to scan those 1 million rows, and not the whole 100 million. - all columns of rows are stored together, so to read a row only one disk access is needed (your way it would probably need roughly one random disk access per each inheritance level upwards, both for reads/selects and writes/inserts/updates; with a sizable inheritance hierarchy this would be a considerable performance hit) - it doesn't really cost much in terms of disk space, only some bookkeeping information is needed I don't think inheritance really fits into 'database normalization' itself, but still there are cases where it is more convenient/efficient than with traditional database normalization, where you would have to either go create completely separate tables for each type (and do UNIONs of SELECTs if you are interested in more than one child only), or what's even more cumbersome, create a table with common columns ('parent' here) and then go create children and children of children that each link upwards to their respective parents through some kind of key: in a select, you would have to explicitly specify all tables upwards the inheritance hierarchy, and specify the respective joins for them. So I think whether you should choose more traditional database normalization or use inheritance depends on what you want to do. > But more importantly it is bad for performance because selecting from a > parent table causes the same select to be done on all the child tables. > In my case selecting from the parent causes six selects to be done (one > for every child table). 'causes the same select to be done on all the child tables' - I don't agree with that, and I hope this is where the misunderstanding lies. Consider this: CREATE TABLE parent ( id integer NOT NULL, text text); CREATE TABLE child1 ( child1field text) INHERITS (parent); CREATE TABLE child2 ( child2field text) INHERITS (parent); CREATE TABLE child3 ( child3field text) INHERITS (parent); CREATE TABLE child4 ( child4field text) INHERITS (parent); CREATE TABLE othertable ( id integer NOT NULL, othertext text); ALTER TABLE ONLY parent ADD CONSTRAINT parent_pkey PRIMARY KEY (id); ALTER TABLE ONLY child1 ADD CONSTRAINT child1_pkey PRIMARY KEY (id); ALTER TABLE ONLY child2 ADD CONSTRAINT child2_pkey PRIMARY KEY (id); ALTER TABLE ONLY child3 ADD CONSTRAINT child3_pkey PRIMARY KEY (id); ALTER TABLE ONLY child4 ADD CONSTRAINT child4_pkey PRIMARY KEY (id); ALTER TABLE ONLY othertable ADD CONSTRAINT othertable_pkey PRIMARY KEY (id); Then I filled all tables with 10000 rows of synthetic data and ANALYZEd just to make sure the optimizer considers indexes to be valuable. First I tried this: johnlange=# explain select * from parent where id=13; QUERY PLAN ---------------------------------------------------------------------------------------------- Result (cost=0.00..15.07 rows=5 width=36) -> Append (cost=0.00..15.07 rows=5 width=36) -> Index Scan using parent_pkey on parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using child1_pkey on child1 parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using child2_pkey on child2 parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using child3_pkey on child3 parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using child4_pkey on child4 parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) (12 rows) The planner has rightly chosen to use indexes, and as a result the query will be pretty fast. Also, at first sight this might look like the multiple selects you mention, but actually it isn't; here's another example to show that: inh=# explain select * from parent natural join othertable where parent.id=13; QUERY PLAN ---------------------------------------------------------------------------------------------- Nested Loop (cost=0.00..30.20 rows=5 width=72) -> Append (cost=0.00..15.07 rows=5 width=36) -> Index Scan using parent_pkey on parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using child1_pkey on child1 parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using child2_pkey on child2 parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using child3_pkey on child3 parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using child4_pkey on child4 parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using othertable_pkey on othertable (cost=0.00..3.01 rows=1 width=36) Index Cond: ("outer".id = othertable.id) (14 rows) As you can see, the planner decided to use the indexes on parent and children here too, retrieved and then collated the resulting rows first and only then performed the join against othertable. In other words, it is not peforming 5 separate selects with their respective joins; it collects all qualifying rows first from the inheritance hierarchy, and only then performs the join; so the extra cost compared to the non-inheriting case is pretty much only the added cost of consulting five indexes instead of just one - unless you have inheritance hierarchies consisting of several dozen tables or more (and even then) I don't think this added cost would be significant. > This is entirely reasonable and efficient compared to the current model > where a select on a parent table requires the same select to be executed > on EVERY child table. If it's a large expensive JOIN of some kind then > this is verging on un-workable. Please show us a join that you would like to use and let us see how well the planner handles it. Regards, Andras PS (John, don't look here :) ): I have found some queries with plans that are less efficient than I think they could be. Changing the where clause in the above query to refer to othertable gives: johnlange=# explain select * from parent natural join othertable where othertable.id=13; QUERY PLAN ----------------------------------------------------------------------------------------------- Hash Join (cost=3.02..978.08 rows=5 width=72) Hash Cond: ("outer".id = "inner".id) -> Append (cost=0.00..725.00 rows=50000 width=36) -> Seq Scan on parent (cost=0.00..145.00 rows=10000 width=36) -> Seq Scan on child1 parent (cost=0.00..145.00 rows=10000 width=36) -> Seq Scan on child2 parent (cost=0.00..145.00 rows=10000 width=36) -> Seq Scan on child3 parent (cost=0.00..145.00 rows=10000 width=36) -> Seq Scan on child4 parent (cost=0.00..145.00 rows=10000 width=36) -> Hash (cost=3.01..3.01 rows=1 width=36) -> Index Scan using othertable_pkey on othertable (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) (11 rows) While: johnlange=# explain select * from ONLY parent natural join othertable where othertable.id=13; QUERY PLAN ----------------------------------------------------------------------------------------- Nested Loop (cost=0.00..6.04 rows=1 width=72) -> Index Scan using othertable_pkey on othertable (cost=0.00..3.01 rows=1 width=36) Index Cond: (id = 13) -> Index Scan using parent_pkey on parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (parent.id = "outer".id) (5 rows) Similarly, as a somewhat more real-life example: johnlange=# explain select * from parent natural join othertable where othertable.othertext='apple'; QUERY PLAN -------------------------------------------------------------------------------------------------- Hash Join (cost=131.37..1234.50 rows=250 width=72) Hash Cond: ("outer".id = "inner".id) -> Append (cost=0.00..725.00 rows=50000 width=36) -> Seq Scan on parent (cost=0.00..145.00 rows=10000 width=36) -> Seq Scan on child1 parent (cost=0.00..145.00 rows=10000 width=36) -> Seq Scan on child2 parent (cost=0.00..145.00 rows=10000 width=36) -> Seq Scan on child3 parent (cost=0.00..145.00 rows=10000 width=36) -> Seq Scan on child4 parent (cost=0.00..145.00 rows=10000 width=36) -> Hash (cost=131.25..131.25 rows=50 width=36) -> Index Scan using othertable_text on othertable (cost=0.00..131.25 rows=50 width=36) Index Cond: (othertext = 'alma'::text) (11 rows) What's more strange, that it still does it with enable_seqscan set to off: johnlange=# explain select * from parent natural join othertable where othertable.othertext='apple'; QUERY PLAN -------------------------------------------------------------------------------------------------- Hash Join (cost=100000131.37..500001234.50 rows=250 width=72) Hash Cond: ("outer".id = "inner".id) -> Append (cost=100000000.00..500000725.00 rows=50000 width=36) -> Seq Scan on parent (cost=100000000.00..100000145.00 rows=10000 width=36) -> Seq Scan on child1 parent (cost=100000000.00..100000145.00 rows=10000 width=36) -> Seq Scan on child2 parent (cost=100000000.00..100000145.00 rows=10000 width=36) -> Seq Scan on child3 parent (cost=100000000.00..100000145.00 rows=10000 width=36) -> Seq Scan on child4 parent (cost=100000000.00..100000145.00 rows=10000 width=36) -> Hash (cost=131.25..131.25 rows=50 width=36) -> Index Scan using othertable_text on othertable (cost=0.00..131.25 rows=50 width=36) Index Cond: (othertext = 'apple'::text) (11 rows) While: johnlange=# explain select * from ONLY parent natural join othertable where othertable.othertext='apple'; QUERY PLAN -------------------------------------------------------------------------------------------- Nested Loop (cost=0.00..282.55 rows=50 width=72) -> Index Scan using othertable_text on othertable (cost=0.00..131.25 rows=50 width=36) Index Cond: (othertext = 'apple'::text) -> Index Scan using parent_pkey on parent (cost=0.00..3.01 rows=1 width=36) Index Cond: (parent.id = "outer".id) (5 rows) If I try to make it more efficient and get rid of the seq scans by pushing the condition into a subselect, I get an even more interesting plan: johnlange=# explain select * from parent where id in (select id from othertable where othertext='alma'); QUERY PLAN --------------------------------------------------------------------------------------------------------------- Result (cost=0.00..6563171.43 rows=25000 width=36) -> Append (cost=0.00..6563171.43 rows=25000 width=36) -> Seq Scan on parent (cost=0.00..1312634.29 rows=5000 width=36) Filter: (subplan) SubPlan -> Materialize (cost=131.25..131.25 rows=50 width=4) -> Index Scan using othertable_text on othertable (cost=0.00..131.25 rows=50 width=4) Index Cond: (othertext = 'alma'::text) -> Seq Scan on child1 parent (cost=0.00..1312634.29 rows=5000 width=36) Filter: (subplan) SubPlan -> Materialize (cost=131.25..131.25 rows=50 width=4) -> Index Scan using othertable_text on othertable (cost=0.00..131.25 rows=50 width=4) Index Cond: (othertext = 'alma'::text) -> Seq Scan on child2 parent (cost=0.00..1312634.29 rows=5000 width=36) Filter: (subplan) SubPlan -> Materialize (cost=131.25..131.25 rows=50 width=4) -> Index Scan using othertable_text on othertable (cost=0.00..131.25 rows=50 width=4) Index Cond: (othertext = 'alma'::text) -> Seq Scan on child3 parent (cost=0.00..1312634.29 rows=5000 width=36) Filter: (subplan) SubPlan -> Materialize (cost=131.25..131.25 rows=50 width=4) -> Index Scan using othertable_text on othertable (cost=0.00..131.25 rows=50 width=4) Index Cond: (othertext = 'alma'::text) -> Seq Scan on child4 parent (cost=0.00..1312634.29 rows=5000 width=36) Filter: (subplan) SubPlan -> Materialize (cost=131.25..131.25 rows=50 width=4) -> Index Scan using othertable_text on othertable (cost=0.00..131.25 rows=50 width=4) Index Cond: (othertext = 'alma'::text) (32 rows) johnlange=# select version(); version -------------------------------------------------------------------------------------------------------- PostgreSQL 7.3.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.1 (Mandrake Linux 9.1 3.2.1-2mdk) (1 row) From pgsql-performance-owner@postgresql.org Wed Jan 29 05:50:40 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C2B93476414 for ; Wed, 29 Jan 2003 05:50:39 -0500 (EST) Received: from mail005.syd.optusnet.com.au (mail005.syd.optusnet.com.au [210.49.20.136]) by postgresql.org (Postfix) with ESMTP id 6E313477415 for ; Wed, 29 Jan 2003 05:20:14 -0500 (EST) Received: from postgresql.org (adlax2-107.dialup.optusnet.com.au [198.142.52.107]) by mail005.syd.optusnet.com.au (8.11.1/8.11.1) with ESMTP id h0TAJsc02275; Wed, 29 Jan 2003 21:19:55 +1100 Message-ID: <3E37AAD0.8010606@postgresql.org> Date: Wed, 29 Jan 2003 20:50:00 +1030 From: Justin Clift User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Matt Mello Cc: pgsql-performance Subject: Re: 1 char in the world References: <3E37733D.90205@spaceship.com> In-Reply-To: <3E37733D.90205@spaceship.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/379 X-Sequence-Number: 1026 Matt Mello wrote: > This naturally led me to another question. How do TEXT, "char", and > BOOLEAN compare for storing t/f values. The test results I saw were > surprising. > > Test query= > "char"/TEXT: explain analyze select count(*) from table where bool='Y'; > boolean: explain analyze select count(*) from table where bool=true; > Table size (see above) > Performance averages: > TEXT 24ms > BOOLEAN 28ms > "char" 17ms Hi Matt, This is interesting. As a thought, would you be ok to run the same test using int4 and int8 as well? That would probably round out the test nicely. :) Regards and best wishes, Justin Clift -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi From pgsql-performance-owner@postgresql.org Wed Jan 29 05:53:59 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5EB08476B0C for ; Wed, 29 Jan 2003 05:53:58 -0500 (EST) Received: from localhost.localdomain (sein.itera.ee [194.126.109.126]) by postgresql.org (Postfix) with ESMTP id 87262476E95 for ; Wed, 29 Jan 2003 05:25:17 -0500 (EST) Received: (from hannu@localhost) by localhost.localdomain (8.11.6/8.11.6) id h0TCIKI05048; Wed, 29 Jan 2003 12:18:20 GMT X-Authentication-Warning: localhost.localdomain: hannu set sender to hannu@tm.ee using -f Subject: Re: 1 char in the world From: Hannu Krosing To: Matt Mello Cc: pgsql-performance In-Reply-To: <3E37733D.90205@spaceship.com> References: <3E37733D.90205@spaceship.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1043842700.5008.11.camel@huli> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 29 Jan 2003 12:18:20 +0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/380 X-Sequence-Number: 1027 On Wed, 2003-01-29 at 06:22, Matt Mello wrote: > TEXT vs "char" ... vs BOOLEAN > > I am porting from Informix to PG. In doing so, I had to pick some data > types for fields, and began wondering about the performance of char/text > fields with one character. For example, I have a field which has one of > the following values/states: {'A', 'D', 'F', 'U'}. Since CHAR(n), > VARCHAR, and TEXT are all supposed to have the same performance > according to the docs, it seems that they will all perform the same. > For this reason, I did not squabble over which one of these to use. > However, since "char" is implemented differently, I thought I would > compare it to one of the others. I chose to pit TEXT against "char". > > Test query = explain analyze select count(*) from table where onechar='D'; > Table size = 512 wide [mostly TEXT] * 400000 rows > Performance averages: > "char" 44ms > TEXT 63ms > > This seems somewhat reasonable, and makes me want to use "char" for my > single-char field. Does everyone else find this to be reasonable? Is > this pretty much the behavior I can expect on extraordinarily large > tables, too? The actual compares will likely stay faster for char than for text. OTOH the actual storage of one-char datatype should not play so significant role for very large tables, even if this is the only field in that table, as most of the overhead will be in other places - storage overhead in page/tuple headers, performance in retrieving the pages/tuples and cache lookups, etc. Also, for very big tables you will most likely want to restrict selects on other criteria than a 4-valued field, so that indexes could be used in retrieving data. > And, should I worry about things like the backend > developers removing "char" as a type later? > > -- > > This naturally led me to another question. How do TEXT, "char", and > BOOLEAN compare for storing t/f values. The test results I saw were > surprising. > > Test query= > "char"/TEXT: explain analyze select count(*) from table where bool='Y'; You could also try just select count(*) from table where bool; > boolean: explain analyze select count(*) from table where bool=true; > Table size (see above) > Performance averages: > TEXT 24ms > BOOLEAN 28ms > "char" 17ms > > Why does boolean rate closer to TEXT than "char"? I would think that > BOOLEANs would actually be stored like "char"s to prevent using the > extra 4 bytes with TEXT types. > > Based on these results, I will probably store my booleans as "char" > instead of boolean. I don't use stored procedures with my application > server, so I should never need my booleans to be the BOOLEAN type. I > can convert faster in my own code. > > -- > > NOTE: the above tests all had the same relative data in the different > fields (what was in TEXT could be found in "char", etc.) and were all > indexed equally. Did you repeat the texts enough times to be sure that you get reliable results ? > > Thanks! -- Hannu Krosing From pgsql-performance-owner@postgresql.org Wed Jan 29 10:58:26 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 063E847702C for ; Wed, 29 Jan 2003 10:58:26 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 40372476F54 for ; Wed, 29 Jan 2003 10:56:23 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0TFuR5u026668; Wed, 29 Jan 2003 10:56:27 -0500 (EST) To: Matt Mello Cc: pgsql-performance Subject: Re: 1 char in the world In-reply-to: <3E37733D.90205@spaceship.com> References: <3E37733D.90205@spaceship.com> Comments: In-reply-to Matt Mello message dated "Wed, 29 Jan 2003 00:22:53 -0600" Date: Wed, 29 Jan 2003 10:56:27 -0500 Message-ID: <26667.1043855787@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/381 X-Sequence-Number: 1028 Matt Mello writes: > Test query= > "char"/TEXT: explain analyze select count(*) from table where bool='Y'; > boolean: explain analyze select count(*) from table where bool=true; > Table size (see above) > Performance averages: > TEXT 24ms > BOOLEAN 28ms > "char" 17ms I don't believe those numbers for a moment. All else being equal, comparing a "char" field to a literal should be exactly the same speed as comparing a bool field to a literal (and if you'd just said "where bool", the bool field would be faster). Both ought to be markedly faster than text. Look for errors in your test procedure. One thing I'd particularly wonder about is whether the query plans are the same. In the absence of any VACUUM ANALYZE data, I'd fully expect the planner to pick a different plan for a bool field than text/char --- because even without ANALYZE data, it knows that a bool column has only two possible values. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jan 29 13:30:36 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D0AED476860 for ; Wed, 29 Jan 2003 13:30:33 -0500 (EST) Received: from johnlaptop.darkcore.net (link.clearoption.com [205.200.121.81]) by postgresql.org (Postfix) with ESMTP id 9548E477206 for ; Wed, 29 Jan 2003 13:29:01 -0500 (EST) Received: by johnlaptop.darkcore.net (Postfix, from userid 501) id A7B3AF2497; Wed, 29 Jan 2003 13:29:00 -0500 (EST) Subject: Re: Query plan and Inheritance. Weird behavior From: John Lange To: Andras Kadinger Cc: PostgreSQL In-Reply-To: <3E378828.91E23F3D@surfnonstop.com> References: <3E31A255.5250DCF1@surfnonstop.com> <1043770598.2045.23.camel@johnlaptop.darkcore.net> <3E3717A4.CAD034EC@surfnonstop.com> <1043810501.3719.28.camel@johnlaptop.darkcore.net> <3E378828.91E23F3D@surfnonstop.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8-3mdk Date: 29 Jan 2003 12:29:00 -0600 Message-Id: <1043864940.2368.53.camel@johnlaptop.darkcore.net> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/382 X-Sequence-Number: 1029 On Wed, 2003-01-29 at 01:52, Andras Kadinger wrote: > John Lange wrote: > > > > > I don't see how performance would be significantly better if you stored > > > the common columns of all rows (parent and children) in the parent > > > table, in contrast with how it is done now, storing entire rows of child > > > tables in the child table and omitting them from the parent table. > > > > Well there are a couple of points. > > > > Firstly, from the simple standpoint of database normalization you > > shouldn't have tables that have the same columns. The way it is > > implemented, child tables are copies of parent tables. > > As Tom pointed out, only the schema is copied, but not the data. I guess you are right, strictly speaking this isn't a violation of normalization since no data is duplicated. > This has the following advantages: > - if you select from child tables, PostgreSQL will only have to scan > rows that belong to that child (and further down), and not all rows in > all tables of the inheritance hierarchy; so if you have 100 million rows > in the whole hierarchy, but only have say 1 million in the child you are > currently interested in, you only have to scan those 1 million rows, and > not the whole 100 million. > - all columns of rows are stored together, so to read a row only one > disk access is needed (your way it would probably need roughly one > random disk access per each inheritance level upwards, both for > reads/selects and writes/inserts/updates; with a sizable inheritance > hierarchy this would be a considerable performance hit) > - it doesn't really cost much in terms of disk space, only some > bookkeeping information is needed > > I don't think inheritance really fits into 'database normalization' > itself, but still there are cases where it is more convenient/efficient > than with traditional database normalization, where you would have to > either go create completely separate tables for each type (and do UNIONs > of SELECTs if you are interested in more than one child only), or what's > even more cumbersome, create a table with common columns ('parent' here) > and then go create children and children of children that each link > upwards to their respective parents through some kind of key: in a > select, you would have to explicitly specify all tables upwards the > inheritance hierarchy, and specify the respective joins for them. > > So I think whether you should choose more traditional database > normalization or use inheritance depends on what you want to do. > > > But more importantly it is bad for performance because selecting from a > > parent table causes the same select to be done on all the child tables. > > In my case selecting from the parent causes six selects to be done (one > > for every child table). > > 'causes the same select to be done on all the child tables' - I don't > agree with that, and I hope this is where the misunderstanding lies. > > Consider this: > > CREATE TABLE parent ( id integer NOT NULL, text text); > CREATE TABLE child1 ( child1field text) INHERITS (parent); > CREATE TABLE child2 ( child2field text) INHERITS (parent); > CREATE TABLE child3 ( child3field text) INHERITS (parent); > CREATE TABLE child4 ( child4field text) INHERITS (parent); > > CREATE TABLE othertable ( id integer NOT NULL, othertext text); > > ALTER TABLE ONLY parent ADD CONSTRAINT parent_pkey PRIMARY KEY (id); > ALTER TABLE ONLY child1 ADD CONSTRAINT child1_pkey PRIMARY KEY (id); > ALTER TABLE ONLY child2 ADD CONSTRAINT child2_pkey PRIMARY KEY (id); > ALTER TABLE ONLY child3 ADD CONSTRAINT child3_pkey PRIMARY KEY (id); > ALTER TABLE ONLY child4 ADD CONSTRAINT child4_pkey PRIMARY KEY (id); > > ALTER TABLE ONLY othertable ADD CONSTRAINT othertable_pkey PRIMARY KEY > (id); > > Then I filled all tables with 10000 rows of synthetic data and ANALYZEd > just to make sure the optimizer considers indexes to be valuable. > > First I tried this: > > johnlange=# explain select * from parent where id=13; > QUERY > PLAN > ---------------------------------------------------------------------------------------------- > Result (cost=0.00..15.07 rows=5 width=36) > -> Append (cost=0.00..15.07 rows=5 width=36) > -> Index Scan using parent_pkey on parent (cost=0.00..3.01 > rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using child1_pkey on child1 parent > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using child2_pkey on child2 parent > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using child3_pkey on child3 parent > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using child4_pkey on child4 parent > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > (12 rows) > > The planner has rightly chosen to use indexes, and as a result the query > will be pretty fast. > > Also, at first sight this might look like the multiple selects you > mention, but actually it isn't; here's another example to show that: > > inh=# explain select * from parent natural join othertable where > parent.id=13; > QUERY > PLAN > ---------------------------------------------------------------------------------------------- > Nested Loop (cost=0.00..30.20 rows=5 width=72) > -> Append (cost=0.00..15.07 rows=5 width=36) > -> Index Scan using parent_pkey on parent (cost=0.00..3.01 > rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using child1_pkey on child1 parent > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using child2_pkey on child2 parent > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using child3_pkey on child3 parent > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using child4_pkey on child4 parent > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using othertable_pkey on othertable (cost=0.00..3.01 > rows=1 width=36) > Index Cond: ("outer".id = othertable.id) > (14 rows) > > As you can see, the planner decided to use the indexes on parent and > children here too, retrieved and then collated the resulting rows first > and only then performed the join against othertable. > > In other words, it is not peforming 5 separate selects with their > respective joins; it collects all qualifying rows first from the > inheritance hierarchy, and only then performs the join; so the extra > cost compared to the non-inheriting case is pretty much only the added > cost of consulting five indexes instead of just one - unless you have > inheritance hierarchies consisting of several dozen tables or more (and > even then) I don't think this added cost would be significant. > > > This is entirely reasonable and efficient compared to the current model > > where a select on a parent table requires the same select to be executed > > on EVERY child table. If it's a large expensive JOIN of some kind then > > this is verging on un-workable. > > Please show us a join that you would like to use and let us see how well > the planner handles it. Ok, your reply here is very informative. Firstly, I can see from your example that I likely don't have my keys and constraints implemented properly. However, the issue of indexes is not necessarily that relevant since you may not be selecting rows based on columns that have indexes. So the issue of indexes aside, I think some of the misunderstanding is related to my assumption that the appended operations are relatively more expensive than scanning the same number of rows in a single select. Here is the way it looks on my system when I select a single object. db_drs0001=> explain select * from tbl_objects where id = 1; NOTICE: QUERY PLAN: Result (cost=0.00..153.70 rows=6 width=111) -> Append (cost=0.00..153.70 rows=6 width=111) -> Seq Scan on tbl_objects (cost=0.00..144.35 rows=1 width=107) -> Seq Scan on tbl_viewers tbl_objects (cost=0.00..1.06 rows=1 width=97) -> Seq Scan on tbl_documents tbl_objects (cost=0.00..4.91 rows=1 width=111) -> Seq Scan on tbl_formats tbl_objects (cost=0.00..1.11 rows=1 width=100) -> Seq Scan on tbl_massemails tbl_objects (cost=0.00..1.01 rows=1 width=90) -> Seq Scan on tbl_icons tbl_objects (cost=0.00..1.25 rows=1 width=110) db_drs0001=> select version(); version --------------------------------------------------------------- PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.3 (1 row) The only question here is, if a select requires the scanning of all rows to return a result set, is it dramatically less efficient to have it scanning 100,000 rows spread over 6 tables or to scan 100,000 rows in a single table? (At the moment I have no where near that amount of data. Side question, what technique do you use to generate data to fill your tables for testing?) I'm now starting to see that it likely isn't that much different either way so the benefits of the way it's implemented probably out weigh the negatives. Your end up scanning the same number of rows either way. On the topic of proper indexes, if you would indulge me, can you show me where I have gone wrong in that regard? My biggest point of confusion here is with regards to the sequences that are used in the parent table. Here is the schema as produced by pg_dump. The original create used the keyword "serial" or "bigserial" as the case may be. I've edited some of the columns out just to keep the example shorter: CREATE SEQUENCE "tbl_objects_id_seq" start 1 increment 1 maxvalue 9223372036854775807 minvalue 1 cache 1; CREATE TABLE "tbl_objects" ( "id" bigint DEFAULT nextval('"tbl_objects_id_seq"'::text) NOT NULL, "name" text DEFAULT '' NOT NULL, "description" text DEFAULT '' NOT NULL, "status" smallint DEFAULT '1' NOT NULL, "class" text ); CREATE TABLE "tbl_viewers" ( "exec" text DEFAULT '' NOT NULL ) INHERITS ("tbl_objects"); CREATE TABLE "tbl_documents" ( "filename" text DEFAULT '' NOT NULL ) INHERITS ("tbl_objects"); CREATE TABLE "tbl_massemails" ( "from" text DEFAULT '' NOT NULL, "subject" text DEFAULT '' NOT NULL, "message" text DEFAULT '' NOT NULL ) INHERITS ("tbl_objects"); CREATE TABLE "tbl_icons" ( "format_id" bigint DEFAULT '0' NOT NULL ) INHERITS ("tbl_documents"); CREATE TABLE "tbl_formats" ( "viewer_id" bigint DEFAULT '0' NOT NULL, "extension" text DEFAULT '' NOT NULL, "contenttype" text DEFAULT '' NOT NULL, "upload_class" text ) INHERITS ("tbl_objects"); CREATE UNIQUE INDEX tbl_objects_id_key ON tbl_objects USING btree (id); Thanks very much for taking the time to look into this with me. It has been most informative. John Lange > > Regards, > Andras > > PS (John, don't look here :) ): I have found some queries with plans > that are less efficient than I think they could be. > > Changing the where clause in the above query to refer to othertable > gives: > > johnlange=# explain select * from parent natural join othertable where > othertable.id=13; > QUERY > PLAN > ----------------------------------------------------------------------------------------------- > Hash Join (cost=3.02..978.08 rows=5 width=72) > Hash Cond: ("outer".id = "inner".id) > -> Append (cost=0.00..725.00 rows=50000 width=36) > -> Seq Scan on parent (cost=0.00..145.00 rows=10000 width=36) > -> Seq Scan on child1 parent (cost=0.00..145.00 rows=10000 > width=36) > -> Seq Scan on child2 parent (cost=0.00..145.00 rows=10000 > width=36) > -> Seq Scan on child3 parent (cost=0.00..145.00 rows=10000 > width=36) > -> Seq Scan on child4 parent (cost=0.00..145.00 rows=10000 > width=36) > -> Hash (cost=3.01..3.01 rows=1 width=36) > -> Index Scan using othertable_pkey on othertable > (cost=0.00..3.01 rows=1 width=36) > Index Cond: (id = 13) > (11 rows) > > While: > > johnlange=# explain select * from ONLY parent natural join othertable > where othertable.id=13; > QUERY > PLAN > ----------------------------------------------------------------------------------------- > Nested Loop (cost=0.00..6.04 rows=1 width=72) > -> Index Scan using othertable_pkey on othertable (cost=0.00..3.01 > rows=1 width=36) > Index Cond: (id = 13) > -> Index Scan using parent_pkey on parent (cost=0.00..3.01 rows=1 > width=36) > Index Cond: (parent.id = "outer".id) > (5 rows) > > Similarly, as a somewhat more real-life example: > > johnlange=# explain select * from parent natural join othertable where > othertable.othertext='apple'; > QUERY > PLAN > -------------------------------------------------------------------------------------------------- > Hash Join (cost=131.37..1234.50 rows=250 width=72) > Hash Cond: ("outer".id = "inner".id) > -> Append (cost=0.00..725.00 rows=50000 width=36) > -> Seq Scan on parent (cost=0.00..145.00 rows=10000 width=36) > -> Seq Scan on child1 parent (cost=0.00..145.00 rows=10000 > width=36) > -> Seq Scan on child2 parent (cost=0.00..145.00 rows=10000 > width=36) > -> Seq Scan on child3 parent (cost=0.00..145.00 rows=10000 > width=36) > -> Seq Scan on child4 parent (cost=0.00..145.00 rows=10000 > width=36) > -> Hash (cost=131.25..131.25 rows=50 width=36) > -> Index Scan using othertable_text on othertable > (cost=0.00..131.25 rows=50 width=36) > Index Cond: (othertext = 'alma'::text) > (11 rows) > > What's more strange, that it still does it with enable_seqscan set to > off: > > johnlange=# explain select * from parent natural join othertable where > othertable.othertext='apple'; > QUERY > PLAN > -------------------------------------------------------------------------------------------------- > Hash Join (cost=100000131.37..500001234.50 rows=250 width=72) > Hash Cond: ("outer".id = "inner".id) > -> Append (cost=100000000.00..500000725.00 rows=50000 width=36) > -> Seq Scan on parent (cost=100000000.00..100000145.00 > rows=10000 width=36) > -> Seq Scan on child1 parent (cost=100000000.00..100000145.00 > rows=10000 width=36) > -> Seq Scan on child2 parent (cost=100000000.00..100000145.00 > rows=10000 width=36) > -> Seq Scan on child3 parent (cost=100000000.00..100000145.00 > rows=10000 width=36) > -> Seq Scan on child4 parent (cost=100000000.00..100000145.00 > rows=10000 width=36) > -> Hash (cost=131.25..131.25 rows=50 width=36) > -> Index Scan using othertable_text on othertable > (cost=0.00..131.25 rows=50 width=36) > Index Cond: (othertext = 'apple'::text) > (11 rows) > > While: > > johnlange=# explain select * from ONLY parent natural join othertable > where othertable.othertext='apple'; > QUERY > PLAN > -------------------------------------------------------------------------------------------- > Nested Loop (cost=0.00..282.55 rows=50 width=72) > -> Index Scan using othertable_text on othertable > (cost=0.00..131.25 rows=50 width=36) > Index Cond: (othertext = 'apple'::text) > -> Index Scan using parent_pkey on parent (cost=0.00..3.01 rows=1 > width=36) > Index Cond: (parent.id = "outer".id) > (5 rows) > > If I try to make it more efficient and get rid of the seq scans by > pushing the condition into a subselect, I get an even more interesting > plan: > > johnlange=# explain select * from parent where id in (select id from > othertable where othertext='alma'); > QUERY > PLAN > --------------------------------------------------------------------------------------------------------------- > Result (cost=0.00..6563171.43 rows=25000 width=36) > -> Append (cost=0.00..6563171.43 rows=25000 width=36) > -> Seq Scan on parent (cost=0.00..1312634.29 rows=5000 > width=36) > Filter: (subplan) > SubPlan > -> Materialize (cost=131.25..131.25 rows=50 width=4) > -> Index Scan using othertable_text on > othertable (cost=0.00..131.25 rows=50 width=4) > Index Cond: (othertext = 'alma'::text) > -> Seq Scan on child1 parent (cost=0.00..1312634.29 rows=5000 > width=36) > Filter: (subplan) > SubPlan > -> Materialize (cost=131.25..131.25 rows=50 width=4) > -> Index Scan using othertable_text on > othertable (cost=0.00..131.25 rows=50 width=4) > Index Cond: (othertext = 'alma'::text) > -> Seq Scan on child2 parent (cost=0.00..1312634.29 rows=5000 > width=36) > Filter: (subplan) > SubPlan > -> Materialize (cost=131.25..131.25 rows=50 width=4) > -> Index Scan using othertable_text on > othertable (cost=0.00..131.25 rows=50 width=4) > Index Cond: (othertext = 'alma'::text) > -> Seq Scan on child3 parent (cost=0.00..1312634.29 rows=5000 > width=36) > Filter: (subplan) > SubPlan > -> Materialize (cost=131.25..131.25 rows=50 width=4) > -> Index Scan using othertable_text on > othertable (cost=0.00..131.25 rows=50 width=4) > Index Cond: (othertext = 'alma'::text) > -> Seq Scan on child4 parent (cost=0.00..1312634.29 rows=5000 > width=36) > Filter: (subplan) > SubPlan > -> Materialize (cost=131.25..131.25 rows=50 width=4) > -> Index Scan using othertable_text on > othertable (cost=0.00..131.25 rows=50 width=4) > Index Cond: (othertext = 'alma'::text) > (32 rows) > > johnlange=# select version(); > > version > -------------------------------------------------------------------------------------------------------- > PostgreSQL 7.3.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.1 > (Mandrake Linux 9.1 3.2.1-2mdk) > (1 row) From pgsql-performance-owner@postgresql.org Wed Jan 29 18:29:59 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9346F47600C for ; Wed, 29 Jan 2003 18:29:57 -0500 (EST) Received: from mta4.rcsntx.swbell.net (mta4.rcsntx.swbell.net [151.164.30.28]) by postgresql.org (Postfix) with ESMTP id C8955476003 for ; Wed, 29 Jan 2003 18:29:56 -0500 (EST) Received: from spaceship.com ([65.65.110.10]) by mta4.rcsntx.swbell.net (iPlanet Messaging Server 5.1 HotFix 1.6 (built Oct 18 2002)) with ESMTP id <0H9I00DUE19YXM@mta4.rcsntx.swbell.net> for pgsql-performance@postgresql.org; Wed, 29 Jan 2003 17:29:59 -0600 (CST) Date: Wed, 29 Jan 2003 17:29:58 -0600 From: Matt Mello Subject: Re: 1 char in the world In-reply-to: <1043842700.5008.11.camel@huli> To: pgsql-performance Message-id: <3E3863F6.2020004@spaceship.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 References: <3E37733D.90205@spaceship.com> <1043842700.5008.11.camel@huli> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/383 X-Sequence-Number: 1030 > OTOH the actual storage of one-char datatype should not play so > significant role for very large tables, even if this is the only field > in that table, as most of the overhead will be in other places - storage > overhead in page/tuple headers, performance in retrieving the > pages/tuples and cache lookups, etc. Is that true if I have a table that consists of lots of 1-char fields? For example, if I have a table with 4 billion records, which consist of (20) 1-char fields each, then the storage for the data will be something like 5 times as large if I use TEXT than if I use "char". > Also, for very big tables you will most likely want to restrict selects > on other criteria than a 4-valued field, so that indexes could be used > in retrieving data. I do. I was just using that query for this test only. I have some very complex queries that are constrained by many foriegn-key int4 fields, but also a few of these 1-char fields. > You could also try just > > select count(*) from table where bool; > I will do this in a while and report to the list. I am going to try make a reproducable test that anyone can do, to be sure my results are "real". > Did you repeat the texts enough times to be sure that you get reliable > results ? I think so. Not so much as hundreds of times, though. -- Matt Mello 512-350-6900 From pgsql-performance-owner@postgresql.org Wed Jan 29 18:59:26 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 600ED475E71 for ; Wed, 29 Jan 2003 18:59:25 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8F33E475C22 for ; Wed, 29 Jan 2003 18:59:24 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h0TNxR5u005514; Wed, 29 Jan 2003 18:59:27 -0500 (EST) To: Matt Mello Cc: pgsql-performance Subject: Re: 1 char in the world In-reply-to: <3E3863F6.2020004@spaceship.com> References: <3E37733D.90205@spaceship.com> <1043842700.5008.11.camel@huli> <3E3863F6.2020004@spaceship.com> Comments: In-reply-to Matt Mello message dated "Wed, 29 Jan 2003 17:29:58 -0600" Date: Wed, 29 Jan 2003 18:59:26 -0500 Message-ID: <5513.1043884766@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/384 X-Sequence-Number: 1031 Matt Mello writes: > Is that true if I have a table that consists of lots of 1-char fields? > For example, if I have a table with 4 billion records, which consist of > (20) 1-char fields each, then the storage for the data will be something > like 5 times as large if I use TEXT than if I use "char". Probably more like 8 times as large, when you allow for alignment padding --- on most machines, TEXT fields will be aligned on 4-byte boundaries, so several TEXT fields in a row will take up 8 bytes apiece, vs one byte apiece for consecutive "char" or bool fields. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jan 29 20:03:04 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8215647595A for ; Wed, 29 Jan 2003 20:03:03 -0500 (EST) Received: from ogoun.tvnet.hu (ogoun.tvnet.hu [195.38.96.10]) by postgresql.org (Postfix) with ESMTP id 47C424758BD for ; Wed, 29 Jan 2003 20:03:02 -0500 (EST) Received: from surfnonstop.com (kadinger.telant.tvnet.hu [195.38.114.41]) by ogoun.tvnet.hu (8.11.6/8.11.6) with ESMTP id h0U12sW29716; Thu, 30 Jan 2003 02:02:55 +0100 Message-ID: <3E3879B9.F9060B14@surfnonstop.com> Date: Thu, 30 Jan 2003 02:02:49 +0100 From: Andras Kadinger X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.19 i686) X-Accept-Language: hu, en, de MIME-Version: 1.0 To: John Lange Cc: PostgreSQL Subject: Re: Query plan and Inheritance. Weird behavior References: <3E31A255.5250DCF1@surfnonstop.com> <1043770598.2045.23.camel@johnlaptop.darkcore.net> <3E3717A4.CAD034EC@surfnonstop.com> <1043810501.3719.28.camel@johnlaptop.darkcore.net> <3E378828.91E23F3D@surfnonstop.com> <1043864940.2368.53.camel@johnlaptop.darkcore.net> Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/385 X-Sequence-Number: 1032 John Lange wrote: > > On Wed, 2003-01-29 at 01:52, Andras Kadinger wrote: > > As Tom pointed out, only the schema is copied, but not the data. > > I guess you are right, strictly speaking this isn't a violation of > normalization since no data is duplicated. [...] > Ok, your reply here is very informative. Firstly, I can see from your > example that I likely don't have my keys and constraints implemented > properly. > > However, the issue of indexes is not necessarily that relevant since you > may not be selecting rows based on columns that have indexes. Granted, now I see that was not strictly related to your point, I just wanted to avoid most avoidable objections against performance of inheritance, and I wasn't 100% sure you seeing seq scans was not part of you thinking performance of this method would be suboptimal so just to be sure, I explicitly went for an example with indexes. > So the issue of indexes aside, I think some of the misunderstanding is > related to my assumption that the appended operations are relatively > more expensive than scanning the same number of rows in a single select. I see. Well, the Append step itself I suppose is not doing much else than iterates over its subnodes and asks each of them to return their rows, and forwards the rows upwards to the rest of the plan as it receives them - it doesn't buffer them, or collect them all before forwarding them upwards (I think the Materialize step that were to be seen in an example in my last PS is the one that does that). So I don't think the Append incurs any significant costs much more than a few CPU cycles for that iteration and row forwarding (pass of one pointer to in-memory row I guess) steps - I think these are minuscule compared to the cost of any disk I/O, and in most non-CPU-bound queries are hidden by disk throughput/latency anyway. > Here is the way it looks on my system when I select a single object. > > db_drs0001=> explain select * from tbl_objects where id = 1; > NOTICE: QUERY PLAN: > > Result (cost=0.00..153.70 rows=6 width=111) > -> Append (cost=0.00..153.70 rows=6 width=111) > -> Seq Scan on tbl_objects (cost=0.00..144.35 rows=1 width=107) > -> Seq Scan on tbl_viewers tbl_objects (cost=0.00..1.06 rows=1 > width=97) > -> Seq Scan on tbl_documents tbl_objects (cost=0.00..4.91 rows=1 > width=111) > -> Seq Scan on tbl_formats tbl_objects (cost=0.00..1.11 rows=1 > width=100) > -> Seq Scan on tbl_massemails tbl_objects (cost=0.00..1.01 rows=1 > width=90) > -> Seq Scan on tbl_icons tbl_objects (cost=0.00..1.25 rows=1 > width=110) > > db_drs0001=> select version(); > version > --------------------------------------------------------------- > PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.3 > (1 row) > > The only question here is, if a select requires the scanning of all rows > to return a result set, is it dramatically less efficient to have it > scanning 100,000 rows spread over 6 tables or to scan 100,000 rows in a > single table? I see. Well, the Append step itself I suppose isn't doing much more than iterates over its subnodes (the seq scans in the case above) and asks each of them to return rows, and forwards the rows upwards to the rest of the plan as it receives them - it doesn't buffer them, or collect them all before forwarding them upwards (I think the Materialize step that were to be seen in an example in my last PS does that). So aside for any costs of consulting indexes, I don't think the Append step - which is the added step when scanning multiple tables versus scanning one table - incurs any significant costs much more than a few CPU cycles for those iteration and row forwarding (pass of one pointer to in-memory row I guess) steps - I think these are minuscule compared to the cost of any disk I/O, and in most non-CPU-bound queries are hidden by disk throughput/latency anyway. > (At the moment I have no where near that amount of data. Side question, > what technique do you use to generate data to fill your tables for > testing?) For this occasion I just went and created a dozen-line PHP script that simply inserted 10000 rows with consecutive ids into each table. I suggest you to try to populate your test database with test data on the order of your expected working data set and use EXPLAIN ANALYZE to make estimates of expected performance of the database. > I'm now starting to see that it likely isn't that much different either > way so the benefits of the way it's implemented probably out weigh the > negatives. Your end up scanning the same number of rows either way. Aside from extreme cases where child rows are considerably much more wider than parent rows and thus result in considerably more data needed to be read in case of a sequential scan, yes. > On the topic of proper indexes, if you would indulge me, can you show me > where I have gone wrong in that regard? Hmm, I think you should only have gone and created indexes for child tables by hand, as indexes are not inherited. Also, don't forget, PostgreSQL has an advanced query cost estimation subsystem, which decides for or against using an index based on, among others, statistics collected on distribution of values in the index to determine its selectivity (so don't forget to ANALYZE/VACUUM ANALYZE after inserting/changing a lot of rows that significantly change distribution of values - this includes initial table fillup), and also it accounts for costs of accessing index pages, so with less than say a couple of thousand rows or with not very selective indexes it will (rightly) decide not to use the index but do a seq scan instead - probably the reason for why you don't see an index scan on tbl_objects above despite there being an index on the primary key. > My biggest point of confusion > here is with regards to the sequences that are used in the parent table. Child tables inherit the "nextval('...')" default value, so as a result they will all draw from the same one sequence, which sequence exists outside of the tables; as a result as long as you use that default value, it is guaranteed that the column in question will have unique values among all tables parent and children; they won't be consecutive - but that's not a drawback of inheritance either, as a sequence is not guaranteed to provide consecutive numbers with single tables either due to transaction concurrency (rolled back transactions don't 'put back' numbers into the sequence, so in the case of rolled back transactions there will be numbers drawn from the sequence that never actually get into any table - this is nicely documented with sequences and transactions). > Here is the schema as produced by pg_dump. The original create used the > keyword "serial" or "bigserial" as the case may be. I've edited some of > the columns out just to keep the example shorter: > > CREATE SEQUENCE "tbl_objects_id_seq" start 1 increment 1 maxvalue > 9223372036854775807 minvalue 1 cache 1; > > CREATE TABLE "tbl_objects" ( > "id" bigint DEFAULT nextval('"tbl_objects_id_seq"'::text) NOT NULL, > "name" text DEFAULT '' NOT NULL, > "description" text DEFAULT '' NOT NULL, > "status" smallint DEFAULT '1' NOT NULL, > "class" text > ); > > CREATE TABLE "tbl_viewers" ( > "exec" text DEFAULT '' NOT NULL ) > INHERITS ("tbl_objects"); > > CREATE TABLE "tbl_documents" ( > "filename" text DEFAULT '' NOT NULL ) > INHERITS ("tbl_objects"); > > CREATE TABLE "tbl_massemails" ( > "from" text DEFAULT '' NOT NULL, > "subject" text DEFAULT '' NOT NULL, > "message" text DEFAULT '' NOT NULL ) > INHERITS ("tbl_objects"); > > CREATE TABLE "tbl_icons" ( > "format_id" bigint DEFAULT '0' NOT NULL ) > INHERITS ("tbl_documents"); > > CREATE TABLE "tbl_formats" ( > "viewer_id" bigint DEFAULT '0' NOT NULL, > "extension" text DEFAULT '' NOT NULL, > "contenttype" text DEFAULT '' NOT NULL, > "upload_class" text ) > INHERITS ("tbl_objects"); > > CREATE UNIQUE INDEX tbl_objects_id_key ON tbl_objects USING btree (id); Hmm, I wonder whether you have a specific goal with or reason for explicitly specifying NOT NULL and empty string ('') as default value for all these text fields? If it's just because your frontend makes it inconvenient for you to treat a NULL as empty string, you might want to consider allowing NULLs and using the coalesce() function in your select - this would incur a few CPU cycles per returned result row, but will spare you a few bytes in storage - I think 4 or 8 per column - for each NULL value. Whether this is worth it or not depends on the percentage of empty/NULL values in your data though. > Thanks very much for taking the time to look into this with me. It has > been most informative. You're welcome! Regards, Andras From pgsql-performance-owner@postgresql.org Thu Jan 30 03:25:20 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 59404475E2B for ; Thu, 30 Jan 2003 03:25:18 -0500 (EST) Received: from web13902.mail.yahoo.com (web13902.mail.yahoo.com [216.136.175.28]) by postgresql.org (Postfix) with SMTP id A74FC475C85 for ; Thu, 30 Jan 2003 03:25:17 -0500 (EST) Message-ID: <20030130082518.8953.qmail@web13902.mail.yahoo.com> Received: from [202.88.238.180] by web13902.mail.yahoo.com via HTTP; Thu, 30 Jan 2003 00:25:18 PST Date: Thu, 30 Jan 2003 00:25:18 -0800 (PST) From: Anil Kumar Subject: Strangae Query Plans To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/386 X-Sequence-Number: 1033 Greetings to all, I have found strange query execution plans with the same version of PostgreSQL but on different types of server machines. Here are the details of the servers: Server 1: Pentium III, 800 MHz, 64 MB of RAM RedHat Linux 7.2, Postgres ver 7.1 Server 2: Dual Pentium III, 1.3 GHz, 512 MB of RAM RedHat Linux 7.3 (SMP kernel), Postgres ver 7.1 Here is the query I tried: --- query --- explain select bill.customer_no, bill.bill_no, bill.bill_date from bill, ( select customer_no, max( bill_date) as bill_date from bill group by customer_no) as t_bill where bill.customer_no = t_bill.customer_no and bill.bill_date = t_bill.bill_date order by bill.customer_no; --- query--- Result on Server 1: ---result--- NOTICE: QUERY PLAN: Merge Join (cost=2436.88..2571.99 rows=671 width=44) -> Sort (cost=1178.15..1178.15 rows=8189 width=28) -> Seq Scan on bill (cost=0.00..645.89 rows=8189 width=28) -> Sort (cost=1258.72..1258.72 rows=819 width=16) -> Subquery Scan t_bill (cost=1178.15..1219.10 rows=819 width=16) -> Aggregate (cost=1178.15..1219.10 rows=819 width=16) -> Group (cost=1178.15..1198.63 rows=8189 width=16) -> Sort (cost=1178.15..1178.15 rows=8189 width=16) -> Seq Scan on bill (cost=0.00..645.89 rows=8189 width=16) EXPLAIN ---result--- Result on Server 2: ---result--- NOTICE: QUERY PLAN: Sort (cost=0.04..0.04 rows=1 width=44) -> Nested Loop (cost=0.01..0.03 rows=1 width=44) -> Seq Scan on bill (cost=0.00..0.00 rows=1 width=28) -> Subquery Scan t_bill (cost=0.01..0.02 rows=1 width=16) -> Aggregate (cost=0.01..0.02 rows=1 width=16) -> Group (cost=0.01..0.01 rows=1 width=16) -> Sort (cost=0.01..0.01 rows=1 width=16) -> Seq Scan on bill (cost=0.00..0.00 rows=1 width=16) EXPLAIN ---result--- Can someone help me to figure out why the query plans come out differently despite the fact that almost everything but the number of CPUs are same in both the machines? Also the dual processor machine is awfully slow when I execute this query and the postmaster hogs the CPU (99.9%) for several minutes literally leaving that server unusable. thank you very much Anil __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Thu Jan 30 04:09:01 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F2C43475B33 for ; Thu, 30 Jan 2003 04:08:58 -0500 (EST) Received: from web13906.mail.yahoo.com (web13906.mail.yahoo.com [216.136.175.69]) by postgresql.org (Postfix) with SMTP id 3BF2D475AAC for ; Thu, 30 Jan 2003 04:08:58 -0500 (EST) Message-ID: <20030130090859.68342.qmail@web13906.mail.yahoo.com> Received: from [202.88.238.180] by web13906.mail.yahoo.com via HTTP; Thu, 30 Jan 2003 01:08:59 PST Date: Thu, 30 Jan 2003 01:08:59 -0800 (PST) From: Anil Kumar Subject: Re: Strangae Query Plans To: pgsql-performance@postgresql.org In-Reply-To: <20030130082518.8953.qmail@web13902.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/387 X-Sequence-Number: 1034 Hi, I got this solved. We ran "vacuum" with the --analyze flag on the second server. And now the query plan is same as the first one and it returns in a fraction of a second! Anil --- Anil Kumar wrote: > > Greetings to all, > > I have found strange query execution plans with the > same version of > PostgreSQL but on different types of server machines. > Here are the details > of the servers: > > Server 1: > Pentium III, 800 MHz, 64 MB of RAM > RedHat Linux 7.2, Postgres ver 7.1 > > Server 2: > Dual Pentium III, 1.3 GHz, 512 MB of RAM > RedHat Linux 7.3 (SMP kernel), Postgres ver 7.1 > > Here is the query I tried: > --- query --- > explain > select bill.customer_no, bill.bill_no, bill.bill_date > from bill, ( select customer_no, max( > bill_date) as bill_date from > bill group by customer_no) as t_bill where > bill.customer_no = t_bill.customer_no and > bill.bill_date = t_bill.bill_date order by > bill.customer_no; > --- query--- > > > Result on Server 1: > ---result--- > NOTICE: QUERY PLAN: > > Merge Join (cost=2436.88..2571.99 rows=671 width=44) > -> Sort (cost=1178.15..1178.15 rows=8189 width=28) > -> Seq Scan on bill (cost=0.00..645.89 > rows=8189 width=28) > -> Sort (cost=1258.72..1258.72 rows=819 width=16) > -> Subquery Scan t_bill > (cost=1178.15..1219.10 rows=819 width=16) > -> Aggregate (cost=1178.15..1219.10 > rows=819 width=16) > -> Group (cost=1178.15..1198.63 > rows=8189 width=16) > -> Sort > (cost=1178.15..1178.15 rows=8189 width=16) > -> Seq Scan on bill > (cost=0.00..645.89 rows=8189 width=16) > > EXPLAIN > ---result--- > > Result on Server 2: > ---result--- > NOTICE: QUERY PLAN: > > Sort (cost=0.04..0.04 rows=1 width=44) > -> Nested Loop (cost=0.01..0.03 rows=1 width=44) > -> Seq Scan on bill (cost=0.00..0.00 rows=1 > width=28) > -> Subquery Scan t_bill (cost=0.01..0.02 > rows=1 width=16) > -> Aggregate (cost=0.01..0.02 rows=1 > width=16) > -> Group (cost=0.01..0.01 rows=1 > width=16) > -> Sort (cost=0.01..0.01 > rows=1 width=16) > -> Seq Scan on bill > (cost=0.00..0.00 rows=1 width=16) > > EXPLAIN > ---result--- > > > Can someone help me to figure out why the query plans > come out differently > despite the fact that almost everything but the number > of CPUs are same in > both the machines? > > Also the dual processor machine is awfully slow when I > execute this query > and the postmaster hogs the CPU (99.9%) for several > minutes literally > leaving that server unusable. > > thank you very much > Anil > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com From pgsql-performance-owner@postgresql.org Thu Jan 30 05:43:08 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 585D4476361 for ; Thu, 30 Jan 2003 05:43:07 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 12EC44762C1 for ; Thu, 30 Jan 2003 05:43:02 -0500 (EST) Received: (qmail 18046 invoked from network); 30 Jan 2003 10:39:15 -0000 Received: from unknown (HELO system67.trade-india-local.com) (192.168.0.67) by infocom-236-129-del.trade-india.com with SMTP; 30 Jan 2003 10:39:15 -0000 From: "Rajesh Kumar Mallah." Organization: Infocom Network Limited. To: Anil Kumar , pgsql-performance@postgresql.org Subject: Re: Strangae Query Plans Date: Thu, 30 Jan 2003 16:18:11 +0530 User-Agent: KMail/1.5 References: <20030130090859.68342.qmail@web13906.mail.yahoo.com> In-Reply-To: <20030130090859.68342.qmail@web13906.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200301301618.11952.mallah@trade-india.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/388 X-Sequence-Number: 1035 you could consider vacuuming thru a cron job daily.. its good for db severs' health ;-) On Thursday 30 January 2003 02:38 pm, Anil Kumar wrote: > Hi, > > I got this solved. We ran "vacuum" with the --analyze flag on the > second server. And now the query plan is same as the first one and > it returns in a fraction of a second! > > Anil > > --- Anil Kumar wrote: > > Greetings to all, > > > > I have found strange query execution plans with the > > same version of > > PostgreSQL but on different types of server machines. > > Here are the details > > of the servers: > > > > Server 1: > > Pentium III, 800 MHz, 64 MB of RAM > > RedHat Linux 7.2, Postgres ver 7.1 > > > > Server 2: > > Dual Pentium III, 1.3 GHz, 512 MB of RAM > > RedHat Linux 7.3 (SMP kernel), Postgres ver 7.1 > > > > Here is the query I tried: > > --- query --- > > explain > > select bill.customer_no, bill.bill_no, bill.bill_date > > from bill, ( select customer_no, max( > > bill_date) as bill_date from > > bill group by customer_no) as t_bill where > > bill.customer_no = t_bill.customer_no and > > bill.bill_date = t_bill.bill_date order by > > bill.customer_no; > > --- query--- > > > > > > Result on Server 1: > > ---result--- > > NOTICE: QUERY PLAN: > > > > Merge Join (cost=2436.88..2571.99 rows=671 width=44) > > -> Sort (cost=1178.15..1178.15 rows=8189 width=28) > > -> Seq Scan on bill (cost=0.00..645.89 > > rows=8189 width=28) > > -> Sort (cost=1258.72..1258.72 rows=819 width=16) > > -> Subquery Scan t_bill > > (cost=1178.15..1219.10 rows=819 width=16) > > -> Aggregate (cost=1178.15..1219.10 > > rows=819 width=16) > > -> Group (cost=1178.15..1198.63 > > rows=8189 width=16) > > -> Sort > > (cost=1178.15..1178.15 rows=8189 width=16) > > -> Seq Scan on bill > > (cost=0.00..645.89 rows=8189 width=16) > > > > EXPLAIN > > ---result--- > > > > Result on Server 2: > > ---result--- > > NOTICE: QUERY PLAN: > > > > Sort (cost=0.04..0.04 rows=1 width=44) > > -> Nested Loop (cost=0.01..0.03 rows=1 width=44) > > -> Seq Scan on bill (cost=0.00..0.00 rows=1 > > width=28) > > -> Subquery Scan t_bill (cost=0.01..0.02 > > rows=1 width=16) > > -> Aggregate (cost=0.01..0.02 rows=1 > > width=16) > > -> Group (cost=0.01..0.01 rows=1 > > width=16) > > -> Sort (cost=0.01..0.01 > > rows=1 width=16) > > -> Seq Scan on bill > > (cost=0.00..0.00 rows=1 width=16) > > > > EXPLAIN > > ---result--- > > > > > > Can someone help me to figure out why the query plans > > come out differently > > despite the fact that almost everything but the number > > of CPUs are same in > > both the machines? > > > > Also the dual processor machine is awfully slow when I > > execute this query > > and the postmaster hogs the CPU (99.9%) for several > > minutes literally > > leaving that server unusable. > > > > thank you very much > > Anil > > > > > > __________________________________________________ > > Do you Yahoo!? > > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > > http://mailplus.yahoo.com > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 6: Have you searched our list archives? > > > > http://archives.postgresql.org > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- -------------------------------------------- Regds Mallah Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)26152172 (221) (L) 9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Thu Jan 30 12:34:50 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 411AC4775AE for ; Thu, 30 Jan 2003 12:34:50 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id 619624773E7 for ; Thu, 30 Jan 2003 12:34:32 -0500 (EST) Received: by allresearch.com (Postfix, from userid 8677) id 75D383CD7A; Thu, 30 Jan 2003 12:34:37 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 4414C3CBE5 for ; Thu, 30 Jan 2003 12:34:36 -0500 (EST) Date: Thu, 30 Jan 2003 12:34:36 -0500 Subject: One large v. many small From: Noah Silverman To: pgsql-performance@postgresql.org Message-Id: <1A107C56-3479-11D7-A3A3-000393AA8F3C@allresearch.com> X-Mailer: Apple Mail (2.551) X-Spam-Status: No, hits=-100.8 required=5.0 tests=LINES_OF_YELLING,SPAM_PHRASE_00_01,USER_AGENT_APPLEMAIL, USER_IN_WHITELIST version=2.43 X-Spam-Level: X-Sanitizer: Advosys mail filter MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII"; format="flowed" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/389 X-Sequence-Number: 1036 As we continue our evaluation of Postgres, another interesting topic has come up that I want to run by the group. In our current model, we have about 3,000 small tables that we use track data for our clients. Each table is an identical structure, and holds the data for one client. Another idea that we are considering is one big table instead of 3,000 smaller ones. We could simply add a numeric field to indicate which client a particular record was for. Each table has between 500 and 50,000 records, so the big table could have up to 10 million rows if we combined everything. A query on our current system is (for client #4) Select (*) from client_4 where foo=2; A query from the new, proposed system would be Select (*) from big_results where client=4 and foo=2. The big questions is, WHICH WILL BE FASTER with Postgres. Is there any performance improvement or cost to switching to this new structure. ANY AND ALL FEEDBACK/OPINIONS ARE WELCOME!! Thanks, Noah From pgsql-performance-owner@postgresql.org Thu Jan 30 12:59:12 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D0444475FC8 for ; Thu, 30 Jan 2003 12:59:08 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 4A37F475EFD for ; Thu, 30 Jan 2003 12:59:07 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2753530; Thu, 30 Jan 2003 09:57:45 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Noah Silverman , pgsql-performance@postgresql.org Subject: Re: One large v. many small Date: Thu, 30 Jan 2003 09:56:56 -0800 User-Agent: KMail/1.4.3 References: <1A107C56-3479-11D7-A3A3-000393AA8F3C@allresearch.com> In-Reply-To: <1A107C56-3479-11D7-A3A3-000393AA8F3C@allresearch.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200301300956.56041.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/390 X-Sequence-Number: 1037 Noah, > As we continue our evaluation of Postgres, another interesting topic > has come up that I want to run by the group. > > In our current model, we have about 3,000 small tables that we use > track data for our clients. Each table is an identical structure, and > holds the data for one client. I'd list what's wrong with this structure, but frankly it would take me long enough that I'd need a consulting fee. Suffice it to say that the above is a very, very bad (or at least antiquated) design idea and you need to transition out of it as soon as possible. > Another idea that we are considering is one big table instead of 3,000 > smaller ones. We could simply add a numeric field to indicate which > client a particular record was for. Yes. Absolutely. Although I'd suggest an Integer field. > Each table has between 500 and 50,000 records, so the big table could > have up to 10 million rows if we combined everything. Sure. > A query on our current system is (for client #4) > > Select (*) from client_4 where foo=2; > > A query from the new, proposed system would be > > Select (*) from big_results where client=4 and foo=2. > > The big questions is, WHICH WILL BE FASTER with Postgres. Is there any > performance improvement or cost to switching to this new structure. Oh, no question query 1 will be faster ... FOR THAT QUERY. You are asking the wrong question. However, explain to me how, under the current system, you can find the client who ordered $3000 worth of widgets on January 12th if you don't already know who it is? I'm not sure a 3000-table UNION query is even *possible*. Or how about giving me the average number of customer transactions in a month, across all clients? You've enslaved your application design to performance considerations ... an approach which was valid in 1990, because processing power was so limited then. But now that dual-processor servers with RAID can be had for less than $3000, there's simply no excuse for violating the principles of good relational database design just to speed up a query. Buying more RAM is much cheaper than having an engineer spend 3 weeks fixing data integrity problems. The proper way to go about application design is to build your application on paper or in a modelling program according to the best principles of software design available, and *then* to discuss performance issues -- addressing them *first* by buying hardware, and only compromising your applcation design when no other alternative is available. I strongly suggest that you purchase Pascal's "Practical Issues in Database Design" and give it a read. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Jan 30 13:02:44 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 406654772FF for ; Thu, 30 Jan 2003 13:02:44 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 8D3254770B4 for ; Thu, 30 Jan 2003 13:02:40 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18eJ1M-0003CI-00 for ; Thu, 30 Jan 2003 13:02:40 -0500 Date: Thu, 30 Jan 2003 13:02:40 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: One large v. many small Message-ID: <20030130130240.I983@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <1A107C56-3479-11D7-A3A3-000393AA8F3C@allresearch.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1A107C56-3479-11D7-A3A3-000393AA8F3C@allresearch.com>; from noah@allresearch.com on Thu, Jan 30, 2003 at 12:34:36PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/391 X-Sequence-Number: 1038 On Thu, Jan 30, 2003 at 12:34:36PM -0500, Noah Silverman wrote: > Select (*) from client_4 where foo=2; > > A query from the new, proposed system would be > > Select (*) from big_results where client=4 and foo=2. > > The big questions is, WHICH WILL BE FASTER with Postgres. Is there any > performance improvement or cost to switching to this new structure. Faster overall, or faster for that operation? I can't prove it, but I suspect that the first one will return faster just because both the index and the table itself is smaller. The possibility is thatit will cause you problems overall, however, because of the large number of files you have to keep if you use 3000 tables. This is dependent on your filesytem (and its implementation). Note, too, that a lot of transactions frequently updating the table might make a difference. A large number of dead tuples sitting on a 10 million row table will make anything crawl. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Jan 30 13:24:41 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 64190475CB4 for ; Thu, 30 Jan 2003 13:24:40 -0500 (EST) Received: from allresearch.com (allresearch.com [209.73.229.162]) by postgresql.org (Postfix) with ESMTP id E4AE2475BD7 for ; Thu, 30 Jan 2003 13:24:39 -0500 (EST) Received: by allresearch.com (Postfix, from userid 8677) id A74E43CEF2; Thu, 30 Jan 2003 13:24:39 -0500 (EST) Received: from allresearch.com (office.allresearch.com [209.73.255.249]) by allresearch.com (Postfix) with ESMTP id 7071F3C258 for ; Thu, 30 Jan 2003 13:24:38 -0500 (EST) Date: Thu, 30 Jan 2003 13:24:38 -0500 Subject: Re: One large v. many small Cc: pgsql-performance@postgresql.org To: pgsql-performance@postgresql.org From: Noah Silverman In-Reply-To: <20030130130240.I983@mail.libertyrms.com> Message-Id: <176C96F6-3480-11D7-A3A3-000393AA8F3C@allresearch.com> X-Mailer: Apple Mail (2.551) X-Spam-Status: No, hits=-102.1 required=5.0 tests=IN_REP_TO,SPAM_PHRASE_01_02,USER_AGENT_APPLEMAIL, USER_IN_WHITELIST version=2.43 X-Spam-Level: X-Sanitizer: Advosys mail filter MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII"; format="flowed" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/392 X-Sequence-Number: 1039 OK, Thanks for the quick responses. A bit more information. We are in the business of gathering data for our clients. (We're a news service). Subsequently, we do a lot of inserting and very rarely do any deleting. (We periodically clear out results that are over 6 months old.) On a give day, we will insert around 100,000 records in total. (Currently split across all the client tables). A challenging part of the process is that we have to keep track of previous content that may be similar. We CAN'T do this with a unique index (don't ask, it would take too long to explain, but trust me, it isn't possible). So, we have to query the table first and then compare the results of that query to what we are inserting. SO, we probably do close to 1 million queries, but then only make about 100,000 inserts. The basic flow is 1) our system finds something it likes, 2) query the table to see if something similar already exists, 3) if nothing similar exists, insert. While all this is going on, our clients are accessing our online reporting system. This system makes a variety of count and record requests from the database. As I mentioned in our earlier post, we are attempting to decide if Postgres will run faster/better/ with one big table, or a bunch of smaller ones. It really doesn't make much difference to us, we just want whatever structure will be faster. Thanks, -N From pgsql-performance-owner@postgresql.org Thu Jan 30 14:13:40 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B203747752D for ; Thu, 30 Jan 2003 14:13:39 -0500 (EST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.215.169]) by postgresql.org (Postfix) with SMTP id 6F1F54770CB for ; Thu, 30 Jan 2003 14:13:33 -0500 (EST) Received: (qmail 40651 invoked from network); 30 Jan 2003 19:13:38 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 30 Jan 2003 19:13:38 -0000 Date: Thu, 30 Jan 2003 14:13:38 -0500 (EST) From: Jeff To: Josh Berkus Cc: Noah Silverman , "pgsql-performance@postgresql.org" Subject: Re: One large v. many small In-Reply-To: <200301300956.56041.josh@agliodbs.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/393 X-Sequence-Number: 1040 On Thu, 30 Jan 2003, Josh Berkus wrote: > > The proper way to go about application design is to build your application on > paper or in a modelling program according to the best principles of software > design available, and *then* to discuss performance issues -- addressing them > *first* by buying hardware, and only compromising your applcation design when > no other alternative is available. > App design & performance go hand-in-hand. the trick is to balance them. Who wants a _wonderful_ design that runs like a piece of poo? in this case I agree with you - not the best design around. buying hardware to fix speed problems is useful, but the software side should not be neglected - imagine this scenario using your methods (with a wonderful pg performance problem in hand (unless you are running cvs)) User has a schema and writes a query along the lines of select somevalue from sometable where othervalue not in (select badvalues from badvaluetable where id = 12345) we all know this runs horrifically on postgres. using your method I should go out, spend thousands on multi-processor boxes, raid, ram If you do a little app tuning (maybe spend 10-30 minutes readig pgsql archives) you'll learn to rewrite it as an exists query and make it faster than it ever could have been on the fast hardware. I just saved the company $10k too! (depends on if you consider that change a design change).. some designs are fatally flawed from the start. but hey.. oh well. 'tis a fine line though.. balancing hardware vs software optimization. (I'm also guessing they are not constrained by things such as an embedded system too) ------------------------------------------------------------------------------ Jeff Trout http://www.jefftrout.com/ Ronald McDonald, with the help of cheese soup, controls America from a secret volkswagon hidden in the past ------------------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Jan 30 14:14:05 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 14708475FD9 for ; Thu, 30 Jan 2003 14:14:05 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id 2D362475F1C for ; Thu, 30 Jan 2003 14:14:04 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h0UJaH6P020140; Thu, 30 Jan 2003 14:36:17 -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 h0UJE1j28863; Thu, 30 Jan 2003 14:14:02 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id CWVLCV3C; Thu, 30 Jan 2003 14:14:01 -0500 Subject: Re: One large v. many small From: Robert Treat To: Noah Silverman Cc: pgsql-performance@postgresql.org In-Reply-To: <176C96F6-3480-11D7-A3A3-000393AA8F3C@allresearch.com> References: <176C96F6-3480-11D7-A3A3-000393AA8F3C@allresearch.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 30 Jan 2003 14:14:01 -0500 Message-Id: <1043954041.2644.59.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/394 X-Sequence-Number: 1041 I'm going to go against the grain here and say that if you already have all of the code and schema worked out, you probably should stick with the many table design. While there are many reasons you'd be better off with the one big table design, a speed increase really isn't one of them. If you we're starting from scratch, or even had a slew of development work you we're planning to do, I'd probably recommend the one big table approach, but if you don't have any bottlenecks in your current system and the type of query you've given is typical of the majority of what your application is doing, there's no sense redesigning your application in the middle of a database switch. Robert Treat PS. Josh, are you referring to Pascal's "Practical Issues In Database Management" book or does he have a different book out that I'm not aware of? On Thu, 2003-01-30 at 13:24, Noah Silverman wrote: > OK, > > Thanks for the quick responses. > > A bit more information. > > We are in the business of gathering data for our clients. (We're a news > service). Subsequently, we do a lot of inserting and very rarely do > any deleting. (We periodically clear out results that are over 6 months > old.) > > On a give day, we will insert around 100,000 records in total. > (Currently split across all the client tables). > > A challenging part of the process is that we have to keep track of > previous content that may be similar. We CAN'T do this with a unique > index (don't ask, it would take too long to explain, but trust me, it > isn't possible). So, we have to query the table first and then compare > the results of that query to what we are inserting. SO, we probably do > close to 1 million queries, but then only make about 100,000 inserts. > The basic flow is 1) our system finds something it likes, 2) query the > table to see if something similar already exists, 3) if nothing similar > exists, insert. > > While all this is going on, our clients are accessing our online > reporting system. This system makes a variety of count and record > requests from the database. > > As I mentioned in our earlier post, we are attempting to decide if > Postgres will run faster/better/ with one big table, or a bunch of > smaller ones. It really doesn't make much difference to us, we just > want whatever structure will be faster. > > Thanks, > > -N > From pgsql-performance-owner@postgresql.org Thu Jan 30 17:27:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4D90E476102 for ; Thu, 30 Jan 2003 17:27:46 -0500 (EST) Received: from utahisp.com (cyber-wire.com [66.239.12.3]) by postgresql.org (Postfix) with ESMTP id 3DDF74775F9 for ; Thu, 30 Jan 2003 17:27:41 -0500 (EST) Received: from chad [63.230.8.76] by utahisp.com (SMTPD32-7.13) id A0BB8914024A; Thu, 30 Jan 2003 12:44:59 -0700 Message-ID: <011301c2c897$d22719f0$32021aac@chad> From: "Chad Thompson" To: "Noah Silverman" , "pgsql-performance" References: <176C96F6-3480-11D7-A3A3-000393AA8F3C@allresearch.com> Subject: Re: One large v. many small Date: Thu, 30 Jan 2003 12:43:09 -0700 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.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Declude-Sender: chad@weblinkservices.com [63.230.8.76] X-Note: This E-mail was scanned by Declude JunkMail (www.declude.com) for spam. X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/395 X-Sequence-Number: 1042 I have a database running on PostgresSQL w/ close to 7 million records in one table and ~ 3 million in another, along w/ various smaller supportive tables. Before I started here everything was run out of small tables, one for each client, similar ( i think ) to what you are doing now. We submit ~ 50 - 100K records each week. And before we moved to one table, our company had no idea of how it was doing on a daily, weekly or monthly basis. Now that we have moved to one large structure, new ideas about reporting funtions and added services we can give to our clients are poping up all the time. There are MANY benifts to following Josh's advice and putting all your information in one table. Others than those given, what if you wanted to give an added service to your clients where they are made aware of similar postings by your other clients. Running this kind of report would be a nightmare in your current situation. As far as performance goes, I am able to join these 2 tables along w/ others and get the information, counts etc., that I need, using some rather complicated queries, in about 2-3 seconds per query. While this may sound awful realize that Im running on a standard workstation PIII 700, and for the money, Its a dream! More importantly you need to realize, as my coworkers have now done, that anything that you can do w/ a small table, you can do w/ one big table and an extra line in the where clause (eg. Where client_id = 'blah' ). PostgresSQL has wonderful support and many excellent DBA's that if you post a SQL problem they are very supportive in helping solve the problem. I hope this helps make your decision. Thanks Chad ----- Original Message ----- From: "Noah Silverman" To: Cc: Sent: Thursday, January 30, 2003 11:24 AM Subject: Re: [PERFORM] One large v. many small > OK, > > Thanks for the quick responses. > > A bit more information. > > We are in the business of gathering data for our clients. (We're a news > service). Subsequently, we do a lot of inserting and very rarely do > any deleting. (We periodically clear out results that are over 6 months > old.) > > On a give day, we will insert around 100,000 records in total. > (Currently split across all the client tables). > > A challenging part of the process is that we have to keep track of > previous content that may be similar. We CAN'T do this with a unique > index (don't ask, it would take too long to explain, but trust me, it > isn't possible). So, we have to query the table first and then compare > the results of that query to what we are inserting. SO, we probably do > close to 1 million queries, but then only make about 100,000 inserts. > The basic flow is 1) our system finds something it likes, 2) query the > table to see if something similar already exists, 3) if nothing similar > exists, insert. > > While all this is going on, our clients are accessing our online > reporting system. This system makes a variety of count and record > requests from the database. > > As I mentioned in our earlier post, we are attempting to decide if > Postgres will run faster/better/ with one big table, or a bunch of > smaller ones. It really doesn't make much difference to us, we just > want whatever structure will be faster. > > Thanks, > > -N > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > From pgsql-general-owner@postgresql.org Thu Jan 30 17:24:57 2003 X-Original-To: pgsql-general@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4A20F475A5C for ; Thu, 30 Jan 2003 17:24:56 -0500 (EST) Received: from mail.com-stock.com (mail.com-stock.com [204.255.137.254]) by postgresql.org (Postfix) with ESMTP id E98074762AF for ; Thu, 30 Jan 2003 14:42:01 -0500 (EST) Received: by mail.com-stock.com (Postfix, from userid 1000) id B896B110; Thu, 30 Jan 2003 14:42:01 -0500 (EST) Received: from deimos (deimos.com-stock.com [204.255.137.120]) by mail.com-stock.com (Postfix) with SMTP id 7122ADA0B; Thu, 30 Jan 2003 14:41:59 -0500 (EST) Message-ID: <016b01c2c898$891d05c0$7889ffcc@comstock.com> From: "Gregory Wood" To: "Jeff" Cc: "PostgreSQL-General" References: Subject: Re: [PERFORM] One large v. many small Date: Thu, 30 Jan 2003 14:48:16 -0500 Organization: Comstock Net Services 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/1535 X-Sequence-Number: 36656 > imagine this scenario using your > methods (with a wonderful pg performance problem in hand (unless you are > running cvs)) > If you do a little app tuning (maybe spend 10-30 minutes readig pgsql > archives) you'll learn to rewrite it as an exists query and make it faster > than it ever could have been on the fast hardware. Your example is invalid... you're talking about an implementation detail, not an architectural design issue. I have to agree with the original point... normalize the database into the proper form, then denormalize as necessary to make things perform acceptably. In other words, do things the right way and then muck it up if you have to. While you make an excellent point (i.e. you can't always through hardware, especially excessive hardware at the problem), I would err on the side of doing things the right way. It usually ends up making the software easier to maintain and add to. A poor design to save a few thousand dollars on hardware now can cost many tens of thousands (or more) dollars on programming time down the road. I've seen entirely too many cases where people started thinking about performance before they considered overall design. It almost always ends in disaster (especially since hardware only gets faster over time and software only gets more complex). Greg From pgsql-performance-owner@postgresql.org Thu Jan 30 18:18:57 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 730B847747C for ; Thu, 30 Jan 2003 18:18:56 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 02490475E45 for ; Thu, 30 Jan 2003 18:18:56 -0500 (EST) Received: from DU150.N224.ResNet.QueensU.CA (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 66E1A1F68; Thu, 30 Jan 2003 18:18:57 -0500 (EST) Subject: Re: Postgres 7.3.1 poor insert/update/search performance From: Neil Conway To: Andrew Sullivan Cc: pgsql-performance@postgresql.org In-Reply-To: <20030122070524.F27014@mail.libertyrms.com> References: <13165.1043188295@sss.pgh.pa.us> <1CE2D1AE-2DAB-11D7-BE6C-000393D9FD00@mobygames.com> <20030122070524.F27014@mail.libertyrms.com> Content-Type: text/plain Organization: Message-Id: <1043968734.3123.27.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 Date: 30 Jan 2003 18:18:54 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/396 X-Sequence-Number: 1043 On Wed, 2003-01-22 at 07:05, Andrew Sullivan wrote: > (As you point out, this caclulation is complicated by the potential to > waste memory by caching the data twice If we had a good buffer replacement algorithm (which we currently do not), ISTM that hot pages retained in PostgreSQL's buffer cache would never get loaded from the OS's IO cache, thus causing those pages to eventually be evicted from the OS's cache. So the "cache the data twice" problem doesn't apply in all circumstances. > Some systems, like Solaris, allow you to turn off the > disk cache, so the problem may not be one you face.) I think it would be interesting to investigate disabling the OS' cache for all relation I/O (i.e. heap files, index files). That way we could both improve performance (by moving all the caching into PostgreSQL's domain, where there is more room for optimization), as well as make configuration simpler: in an ideal world, it would remove the need to consider the OS' caching when configuring the amount of shared memory to allocate to PostgreSQL. Can this be done using O_DIRECT? If so, is it portable? BTW, if anyone has any information on actually *using* O_DIRECT, I'd be interested in it. I tried to quickly hack PostgreSQL to use it, without success... Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-performance-owner@postgresql.org Thu Jan 30 23:57:11 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 77A224765C6 for ; Thu, 30 Jan 2003 23:30:07 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id A0FDB4765C2 for ; Thu, 30 Jan 2003 23:30:06 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id 0E628C006; Fri, 31 Jan 2003 03:54:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id 4F3DF8736; Fri, 31 Jan 2003 12:54:26 +0900 (JST) Date: Fri, 31 Jan 2003 12:54:26 +0900 (JST) From: Curt Sampson To: Josh Berkus Cc: Noah Silverman , pgsql-performance@postgresql.org Subject: Re: One large v. many small In-Reply-To: <200301300956.56041.josh@agliodbs.com> Message-ID: References: <1A107C56-3479-11D7-A3A3-000393AA8F3C@allresearch.com> <200301300956.56041.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/398 X-Sequence-Number: 1045 On Thu, 30 Jan 2003, Josh Berkus wrote: > > Another idea that we are considering is one big table instead of 3,000 > > smaller ones. We could simply add a numeric field to indicate which > > client a particular record was for. > > Yes. Absolutely. Although I'd suggest an Integer field. From the description given in Noah's message, and also the one given in his later message, I have little doubt that 3000 small tables are going to be significantly faster than one large table. If you don't believe me, work out just where the disk blocks are going to end up, and how many blocks are going to have to be fetched for his typical query in a semi-clustered or non-clustered table. (If postgres had clustered indexes a la MS SQL server, where the rows are physically stored in the order of the clustered index, it would be a different matter.) > However, explain to me how, under the current system, you can find the client > who ordered $3000 worth of widgets on January 12th if you don't already know > who it is? Explain to me why he has to do this. It's all very nice to have a general system that can do well on all sorts of queries, but if you lose time on the queries you do do, in order to save time on queries you don't do, you're definitely not getting the best performance out of the system. > I'm not sure a 3000-table UNION query is even *possible*. This is not the only solution, either. You could simply just do 3000 queries. If this is something you execute only once a month, the making that query three or four orders of magnitude more expensive might be a small price to pay for making cheaper the queries you run several times per second. > > > You've enslaved your application design to performance considerations ... an > approach which was valid in 1990, because processing power was so limited > then. But now that dual-processor servers with RAID can be had for less than > $3000, there's simply no excuse for violating the principles of good > relational database design just to speed up a query. Buying more RAM is > much cheaper than having an engineer spend 3 weeks fixing data integrity > problems. *Sigh.* Ok, my turn to rant. RAM is not cheap enough yet for me to buy several hundred gigabytes of it for typical applications, even if I could find a server that I could put it in. Disk performance is not growing the way CPU performance is. And three weeks of engineering time plus a ten thousand dollar server is, even at my top billing rate, still a heck of a lot cheaper than a quarter-million dollar server. Applying your strategy to all situations is not always going to produce the most cost-effective solution. And for most businesses, that's what it's all about. They're not interested in the more "thoretically pure" way of doing things except insofar as it makes them money. As for the data integrity problems, I don't know where that came from. I think that was made up out of whole cloth, because it didn't seem to me that the original question involved any. cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-performance-owner@postgresql.org Thu Jan 30 23:04:10 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6599F476829 for ; Thu, 30 Jan 2003 23:04:04 -0500 (EST) Received: from platonic.cynic.net (platonic.cynic.net [204.80.150.245]) by postgresql.org (Postfix) with ESMTP id AE90B476759 for ; Thu, 30 Jan 2003 23:04:03 -0500 (EST) Received: from angelic.cynic.net (angelic-platonic.cvpn.cynic.net [198.73.220.226]) by platonic.cynic.net (Postfix) with ESMTP id DB54BC009; Fri, 31 Jan 2003 04:02:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by angelic.cynic.net (Postfix) with ESMTP id 7C4698736; Fri, 31 Jan 2003 13:02:52 +0900 (JST) Date: Fri, 31 Jan 2003 13:02:52 +0900 (JST) From: Curt Sampson To: Neil Conway Cc: Andrew Sullivan , pgsql-performance@postgresql.org Subject: Re: Postgres 7.3.1 poor insert/update/search performance In-Reply-To: <1043968734.3123.27.camel@tokyo> Message-ID: References: <13165.1043188295@sss.pgh.pa.us> <1CE2D1AE-2DAB-11D7-BE6C-000393D9FD00@mobygames.com> <20030122070524.F27014@mail.libertyrms.com> <1043968734.3123.27.camel@tokyo> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/397 X-Sequence-Number: 1044 On Fri, 30 Jan 2003, Neil Conway wrote: > If we had a good buffer replacement algorithm (which we currently do > not), ISTM that hot pages retained in PostgreSQL's buffer cache would > never get loaded from the OS's IO cache, thus causing those pages to > eventually be evicted from the OS's cache. So the "cache the data twice" > problem doesn't apply in all circumstances. No, but it does apply to every block at some point, since during the initial load it's present in both caches, and it has to be flushed from the OS's cache at some point. > > Some systems, like Solaris, allow you to turn off the > > disk cache, so the problem may not be one you face.) > > I think it would be interesting to investigate disabling the OS' cache > for all relation I/O (i.e. heap files, index files). That way we could > both improve performance (by moving all the caching into PostgreSQL's > domain, where there is more room for optimization)... I'm not so sure that there is that all much more room for optimization. But take a look at what Solaris and FFS do now, and consider how much work it would be to rewrite it, and then see if you even want to do that before adding stuff to improve performance. > , as well as make configuration simpler: in an ideal world, it would > remove the need to consider the OS' caching when configuring the > amount of shared memory to allocate to PostgreSQL. We could do that much more simply by using mmap. > Can this be done using O_DIRECT? It can, but you're doing to lose some of the advantages that you'd get from using raw devices instead. In particular, you have no way to know the physical location of blocks on the disk, because those locations are often different from the location in the file. > If so, is it portable? O_DIRECT is not all that portable, I don't think. Certainly not as portable as mmap. cjs -- Curt Sampson +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're all light. --XTC From pgsql-performance-owner@postgresql.org Fri Jan 31 01:03:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 24A88476599 for ; Fri, 31 Jan 2003 01:03:26 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 6E3FA4761F6; Fri, 31 Jan 2003 01:03:24 -0500 (EST) Received: by davinci.ethosmedia.com (CommuniGate Pro PIPE 4.0.2) with PIPE id 2807722; Thu, 30 Jan 2003 21:57:49 -0800 X-Spam-Status: Scanner Called Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2807562; Thu, 30 Jan 2003 21:55:40 -0800 From: "Josh Berkus" Subject: Re: One large v. many small To: Josh Berkus Cc: Noah Silverman , pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Thu, 30 Jan 2003 21:55:40 -0800 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" X-Spam-Status: No, hits=1.4 required=6.5 tests=FROM_AND_TO_SAME_6,IN_REP_TO,SPAM_PHRASE_00_01 version=2.43 X-Spam-Level: . Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/399 X-Sequence-Number: 1046 Noah, Well, there you have it: a unanimous consensus of opinion. You should either combine all of your tables or not. But definitely one or the other. Hope you feel informed now. -Josh From pgsql-performance-owner@postgresql.org Fri Jan 31 01:28:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 09E364761F6 for ; Fri, 31 Jan 2003 01:28:42 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 3E50D475C2B for ; Fri, 31 Jan 2003 01:28:37 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h0V6RHK27150 for ; Fri, 31 Jan 2003 11:57:17 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h0V6RH527145 for ; Fri, 31 Jan 2003 11:57:17 +0530 Content-Type: text/plain; charset="iso-8859-1" From: "Shridhar Daithankar" To: pgsql-performance@postgresql.org Subject: Re: One large v. many small Date: Fri, 31 Jan 2003 11:57:40 +0530 User-Agent: KMail/1.4.3 References: <176C96F6-3480-11D7-A3A3-000393AA8F3C@allresearch.com> In-Reply-To: <176C96F6-3480-11D7-A3A3-000393AA8F3C@allresearch.com> MIME-Version: 1.0 Message-Id: <200301311157.40351.shridhar_daithankar@persistent.co.in> X-MIME-Autoconverted: from quoted-printable to 8bit by www.pspl.co.in id h0V6RH527145 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/400 X-Sequence-Number: 1047 On Thursday 30 Jan 2003 11:54 pm, you wrote: > As I mentioned in our earlier post, we are attempting to decide if > Postgres will run faster/better/ with one big table, or a bunch of > smaller ones. It really doesn't make much difference to us, we just > want whatever structure will be faster. I would say create a big table with client id. Create a index on it and cre= ate=20 3000 views. Of course you need to figure out SQL voodoo to insert into=20 postgresql views using rules. But that would save you from modifying your app. up and down. But there is= =20 going to be massive framgmentation. Consider clustering tables once in a=20 while. HTH Shridhar From pgsql-general-owner@postgresql.org Sun Feb 2 00:27:36 2003 X-Original-To: pgsql-general@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 550844760F0 for ; Fri, 31 Jan 2003 08:03:17 -0500 (EST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.215.169]) by postgresql.org (Postfix) with SMTP id A4D4D475FB5 for ; Fri, 31 Jan 2003 08:03:16 -0500 (EST) Received: (qmail 45821 invoked from network); 31 Jan 2003 13:01:24 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 31 Jan 2003 13:01:24 -0000 Date: Fri, 31 Jan 2003 08:01:24 -0500 (EST) From: Jeff To: Gregory Wood Cc: PostgreSQL-General Subject: Re: [PERFORM] One large v. many small In-Reply-To: <016b01c2c898$891d05c0$7889ffcc@comstock.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/28 X-Sequence-Number: 36782 On Thu, 30 Jan 2003, Gregory Wood wrote: > While you make an excellent point (i.e. you can't always through hardware, > especially excessive hardware at the problem), I would err on the side of > doing things the right way. It usually ends up making the software easier to > maintain and add to. A poor design to save a few thousand dollars on > hardware now can cost many tens of thousands (or more) dollars on > programming time down the road. > fun story - I was part of a dot com and we had an informix database and the schema was pretty "good" - ref integrity and "logical layout". What happened was our traffic started increasng dramatically. We ended up having to disable all the ref integrity simply because it gave us a 50% boost. It was unfortuate, but you have to do it. Sometimes you have to comprimise. As for throwing hardware at it - it was already running on a $500k sun box, an upgrade would have likely gone into the 7 digit range. Not to mention you don't exactly get a quick turnaround on hardware of that type.. a u10 perhaps, but not a big beefy box. (Eventually we did upgrade the db machine when we got another round of funding) so after a week of engineering and futzing we had things under control.. (db changes, massive app changes (agressive caching)) Yes it was horrid to throw out RI (which caused some minor issues later) but when the business is riding on it.. you make it work any way you can. In a perfect world I would have done it another way, but when the site is down (read: your business is not running, you are losing large amounts of money) you need to put on your fire fighter suit, not your lab coat. I remember one time we were featured on CNBC and our traffic jumped by 1000% (yes, 1000) - our poor machines were hosed. Now we did throw hardware at this problem (more frontends) however aquiring hardware in time of crisis is not terribly easy (took 3 days in this case). So you have to look at your other routes. sometimes your design or some implementation details will be comprimised.. its a fact of business. If the best design always won then why don't I have an alpha for my machine machine? they are the fastest, best cpu around. (I'll admit, alpha failed a lot because of marketing issues and cost) Business drives everything. I'd rather continue getting a paycheck than having a wonderfully designed db that doesn't perform well and is causing us to lose money. If you have the ability (ie, you know your site is going to end up doing 22M page views, or some other statistic like that) to see what things will be like later and are not fighting a fire, design is wonderful. (Lets not forget time. I was just on a major project and they scheduled _3_ weeks of design & coding.. we were quite upset about that one.. and they arranged it so the launch date was set in stone. man.. worked some long nights..) getting back to the original posters thing - why not just try a test to see how things perform yourself? Try some tests with 3000 tables, and try a test with 1 table with a client_id (int) field. Or as said, you could even make a boatload of views and change your insertion logic.. anyway, sorry if I flamed anybody or if they took it personally. just stating some experiences I've had. ------------------------------------------------------------------------------ Jeff Trout http://www.jefftrout.com/ Ronald McDonald, with the help of cheese soup, controls America from a secret volkswagon hidden in the past ------------------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Fri Jan 31 13:24:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5A36C4760F5 for ; Fri, 31 Jan 2003 10:08:52 -0500 (EST) Received: from curtislaptop (unknown [63.164.0.44]) by postgresql.org (Postfix) with SMTP id 85F8C475C26 for ; Fri, 31 Jan 2003 10:08:51 -0500 (EST) Received: from [127.0.0.1] by curtislaptop (ArGoSoft Mail Server Freeware, Version 1.8 (1.8.1.7)); Fri, 31 Jan 2003 10:32:15 -0400 From: "Curtis Faith" To: "'Curt Sampson'" , "'Josh Berkus'" , "'Noah Silverman'" Cc: Subject: Re: One large v. many small Date: Fri, 31 Jan 2003 10:32:11 -0400 Message-ID: <001401c2c935$8c759140$a200a8c0@curtislaptop> 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: Importance: Normal X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/402 X-Sequence-Number: 1049 Curt Sampson wrote: > >From the description given in Noah's message, and also the > one given in his later message, I have little doubt that 3000 > small tables are going to be significantly faster than one > large table. If you don't believe me, work out just where the > disk blocks are going to end up, and how many blocks are going > to have to be fetched for his typical query in a semi-clustered or > non-clustered table. You may be right, Curt, but I've seen unintuitive results for this kind of thing in the past. Depending on the way the records are accessed and the cache size, the exact opposite could be true. The index pages will most likely rarely be in memory when you have 3000 different tables. Meaning that each search will require at least three or four index page retrievals plus the tuple page. So what you might lose due to lack of clustering will be made up by the more efficient caching of the upper levels of the index btree pages. Combine a multi-part index (on both client and foo, which order would depend on the access required) that is clustered once a week or so using the admittedly non-optimal PostgreSQL CLUSTER command and I'll bet you can get equivalent or better performance with the single table with the concomitant advantages of much better reporting options. I've also seen many examples of linear algorithms in database data dictionaries which would cause a 3000+ table database to perform poorly during the parsing/query optimization stage. I don't have any idea whether or not PostgreSQL suffers from this problem. I don't think there is any substitute for just trying it out. It shouldn't be that hard to create a bunch of SQL statements that concatenate the tables into one large one. Try the most common queries against both scenarios. You might be surprised. - Curtis From pgsql-general-owner@postgresql.org Fri Jan 31 13:08:59 2003 X-Original-To: pgsql-general@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9D4F4475F73 for ; Fri, 31 Jan 2003 12:07:33 -0500 (EST) Received: from mail.com-stock.com (mail.com-stock.com [204.255.137.254]) by postgresql.org (Postfix) with ESMTP id 0313C475EE4 for ; Fri, 31 Jan 2003 12:07:32 -0500 (EST) Received: by mail.com-stock.com (Postfix, from userid 1000) id 57AAFAA; Fri, 31 Jan 2003 12:05:57 -0500 (EST) Received: from eng3 (eng3.com-stock.com [204.255.137.79]) by mail.com-stock.com (Postfix) with SMTP id CA7CADA33; Fri, 31 Jan 2003 12:05:55 -0500 (EST) Message-ID: <00be01c2c94b$e92f8150$4f89ffcc@eng3> From: "Gregory Wood" To: "Jeff" Cc: "PostgreSQL-General" References: Subject: Re: [PERFORM] One large v. many small Date: Fri, 31 Jan 2003 12:12:18 -0500 Organization: Comstock Net Services 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/1572 X-Sequence-Number: 36693 > > While you make an excellent point (i.e. you can't always through hardware, > > especially excessive hardware at the problem), I would err on the side of > > doing things the right way. It usually ends up making the software easier to > > maintain and add to. A poor design to save a few thousand dollars on > > hardware now can cost many tens of thousands (or more) dollars on > > programming time down the road. > > > > > fun story - I was part of a dot com and we had an informix database and > the schema was pretty "good" - ref integrity and "logical layout". What > happened > was our traffic started increasng dramatically. We ended up having to > disable all the ref integrity simply because it gave us a 50% boost. It > was unfortuate, but you have to do it. Sometimes you have to comprimise. You did what I was suggesting then... start with a good design and work your way backwards for the performance you needed and not the other way around. I've had to compromise all too often at my business (which upsets me more because it's often cost the business more in terms of customers and revenue in the long run, but they aren't my decisions to make), so I understand that not everything is a matter of "do it right"... all too often it's a matter of "get it done". > As for throwing hardware at it - it was already running on a $500k sun > box, an upgrade would have likely gone into the 7 digit range. I don't envy you on that... as nice as it is to have that kind of a budget, that adds a lot of pressure to "make it work". > Yes it was horrid to throw out RI (which caused some minor issues > later) but when the business is riding on it.. you make it work any way > you can. In a perfect world I would have done it another way, but when > the site is down (read: your business is not running, you are losing large > amounts of money) you need to put on your fire fighter suit, not your lab > coat. Well said. > anyway, sorry if I flamed anybody or if they took it personally. > just stating some experiences I've had. The more experiences shared, the more well rounded the conclusions of the person reading them. Greg From pgsql-performance-owner@postgresql.org Fri Jan 31 12:50:39 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D755C4760F5 for ; Fri, 31 Jan 2003 12:39:53 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 0F1A3475DC0 for ; Fri, 31 Jan 2003 12:39:52 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2814877 for pgsql-performance@postgresql.org; Fri, 31 Jan 2003 09:35:29 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: One large v. many small Date: Fri, 31 Jan 2003 09:34:28 -0800 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Message-Id: <200301310934.28980.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/401 X-Sequence-Number: 1048 Folks, Many, many replies on this topic: Jeff: > App design & performance go hand-in-hand. the trick is to balance them. > Who wants a _wonderful_ design that runs like a piece of poo? in this >Select somevalue from sometable where othervalue not in (select badvalues > from badvaluetable where id =3D 12345) > we all know this runs horrifically on postgres. using your method I should > go out, spend thousands on multi-processor boxes, raid, ram Sorry, no, Jeff. The above is what one calls a "bad query" and is not,=20 therefore, a performance vs. design issue: that query is bad design-wise, a= nd=20 bad performance-wise. Perhpas another example of your argument? Since you do not seem to have understood my argument, it is this:=20=20 Design changes, made for the sake of performance or rapid app building, whi= ch=20 completely violate good RDBMS design and normalization principles, almost= =20 always cost you more over the life of the application than you gain in=20 performance in the short term.=20=20=20 Curt: > It's all very nice to have a general system that can do well on all > sorts of queries, but if you lose time on the queries you do do, in > order to save time on queries you don't do, you're definitely not > getting the best performance out of the system. This is a good point; I tend to build for posterity because, so far, 90% of= my=20 clients who started out having me build a "single-purpose" database ended u= p=20 expanding the application to cover 2-10 additional needs, thus forcing me t= o=20 clean up any design shortcuts I took with the original app. However, Noa= h=20 may have more control over his company than that. > RAM is not cheap enough yet for me to buy several hundred gigabytes of > it for typical applications, even if I could find a server that I could > put it in. Disk performance is not growing the way CPU performance is. > And three weeks of engineering time plus a ten thousand dollar server > is, even at my top billing rate, still a heck of a lot cheaper than a > quarter-million dollar server. I was thinking more of the difference between a $3000 server and a $9000=20 server myself; unless you're doing nuclear test modelling, I don't see any= =20 need for a $250,000 server for anything.=20=20=20 To give an extreme example, I have a client who purchased a $150,000=20 accounting system that turned out to be badly designed, normalization-wise,= =20 partly because the accounting system engineers were focusing on 8-year-old= =20 technology with performance restrictions which were no longer really=20 applicable (for example, they talked the client into buying a quad-processo= r=20 server and then wrote all of their middleware code on a platform that does= =20 not do SMP). Over the last two years, they have paid my company $175,000 t= o=20=20 "fix" this accounting database ... more, in fact, than I would have charged= =20 them to write a better system from scratch. > Applying your strategy to all situations is not always going to produce > the most cost-effective solution. That's very true. In fact, that could be taken as a "general truism" ... = no=20 one strategy applies to *all* situations. > PS. Josh, are you referring to Pascal's "Practical Issues In Database > Management" book or does he have a different book out that I'm not aware > of? Yes, you're correct. Sorry! --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jan 31 13:29:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0D1F64774F2 for ; Fri, 31 Jan 2003 13:20:48 -0500 (EST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.215.169]) by postgresql.org (Postfix) with SMTP id 650EC47709F for ; Fri, 31 Jan 2003 13:20:47 -0500 (EST) Received: (qmail 47481 invoked from network); 31 Jan 2003 18:19:36 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 31 Jan 2003 18:19:36 -0000 Date: Fri, 31 Jan 2003 13:19:36 -0500 (EST) From: Jeff To: pgsql-performance@postgresql.org Subject: Re: One large v. many small (fwd) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/403 X-Sequence-Number: 1050 On Thu, 30 Jan 2003, Gregory Wood wrote: > While you make an excellent point (i.e. you can't always through hardware, > especially excessive hardware at the problem), I would err on the side of > doing things the right way. It usually ends up making the software easier to > maintain and add to. A poor design to save a few thousand dollars on > hardware now can cost many tens of thousands (or more) dollars on > programming time down the road. > fun story - I was part of a dot com and we had an informix database and the schema was pretty "good" - ref integrity and "logical layout". What happened was our traffic started increasng dramatically. We ended up having to disable all the ref integrity simply because it gave us a 50% boost. It was unfortuate, but you have to do it. Sometimes you have to comprimise. As for throwing hardware at it - it was already running on a $500k sun box, an upgrade would have likely gone into the 7 digit range. Not to mention you don't exactly get a quick turnaround on hardware of that type.. a u10 perhaps, but not a big beefy box. (Eventually we did upgrade the db machine when we got another round of funding) so after a week of engineering and futzing we had things under control.. (db changes, massive app changes (agressive caching)) Yes it was horrid to throw out RI (which caused some minor issues later) but when the business is riding on it.. you make it work any way you can. In a perfect world I would have done it another way, but when the site is down (read: your business is not running, you are losing large amounts of money) you need to put on your fire fighter suit, not your lab coat. I remember one time we were featured on CNBC and our traffic jumped by 1000% (yes, 1000) - our poor machines were hosed. Now we did throw hardware at this problem (more frontends) however aquiring hardware in time of crisis is not terribly easy (took 3 days in this case). So you have to look at your other routes. sometimes your design or some implementation details will be comprimised.. its a fact of business. If the best design always won then why don't I have an alpha for my machine machine? they are the fastest, best cpu around. (I'll admit, alpha failed a lot because of marketing issues and cost) Business drives everything. I'd rather continue getting a paycheck than having a wonderfully designed db that doesn't perform well and is causing us to lose money. If you have the ability (ie, you know your site is going to end up doing 22M page views, or some other statistic like that) to see what things will be like later and are not fighting a fire, design is wonderful. (Lets not forget time. I was just on a major project and they scheduled _3_ weeks of design & coding.. we were quite upset about that one.. and they arranged it so the launch date was set in stone. man.. worked some long nights..) getting back to the original posters thing - why not just try a test to see how things perform yourself? Try some tests with 3000 tables, and try a test with 1 table with a client_id (int) field. Or as said, you could even make a boatload of views and change your insertion logic.. anyway, sorry if I flamed anybody or if they took it personally. just stating some experiences I've had. ------------------------------------------------------------------------------ Jeff Trout http://www.jefftrout.com/ Ronald McDonald, with the help of cheese soup, controls America from a secret volkswagon hidden in the past ------------------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Fri Jan 31 13:43:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 74E7C4762C8 for ; Fri, 31 Jan 2003 13:43:33 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id D4EDD475FD9 for ; Fri, 31 Jan 2003 13:43:32 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2815030; Fri, 31 Jan 2003 10:42:52 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Jeff , pgsql-performance@postgresql.org Subject: Re: One large v. many small (fwd) Date: Fri, 31 Jan 2003 10:44:00 -0800 X-Mailer: KMail [version 1.4] References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301311044.00583.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/404 X-Sequence-Number: 1051 Jeff, > so after a week of engineering and futzing we had things under control.. > (db changes, massive app changes (agressive caching)) >=20 > Yes it was horrid to throw out RI (which caused some minor issues > later) but when the business is riding on it.. you make it work any way > you can. In a perfect world I would have done it another way, but when > the site is down (read: your business is not running, you are losing large > amounts of money) you need to put on your fire fighter suit, not your lab > coat. Actually, I'd say this is a great example of what I'm advocating. You=20 started out with a "correct" design, from an RDBMS perspective, and=20 compromised on it only when the performance issues became insurmountable.= =20=20 That sounds like a good approach to me. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jan 31 18:16:27 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9F66747A271 for ; Fri, 31 Jan 2003 18:16:26 -0500 (EST) Received: from mail.sandvine.com (sandvine.com [199.243.201.138]) by postgresql.org (Postfix) with ESMTP id 017CE47F877 for ; Fri, 31 Jan 2003 16:12:47 -0500 (EST) Received: by mail.sandvine.com with Internet Mail Service (5.5.2653.19) id ; Fri, 31 Jan 2003 16:12:48 -0500 Message-ID: From: Don Bowman To: "'pgsql-performance@postgresql.org'" Subject: not using index for select min(...) Date: Fri, 31 Jan 2003 16:12:38 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/405 X-Sequence-Number: 1052 I have a table which is very large (~65K rows). I have a column in it which is indexed, and I wish to use for a join. I'm finding that I'm using a sequential scan for this when selecting a MIN. I've boiled this down to something like this: => create table X( value int primary key ); => explain select min(value) from x; Aggregate (cost=22.50..22.50 rows=1 width=4) -> Seq Scan on x (cost=0.00..20.00 rows=1000 width=4) => \d x Table "public.x" Column | Type | Modifiers --------+---------+----------- value | integer | not null Indexes: x_pkey primary key btree (value) Why wouldn't I be doing an index scan on this table? --don From pgsql-performance-owner@postgresql.org Fri Jan 31 20:49:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 134D84797C1 for ; Fri, 31 Jan 2003 20:49:36 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 5F37747D77C for ; Fri, 31 Jan 2003 18:31:02 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ekci-0007f3-00 for ; Fri, 31 Jan 2003 18:31:04 -0500 Date: Fri, 31 Jan 2003 18:31:04 -0500 From: Andrew Sullivan To: "'pgsql-performance@postgresql.org'" Subject: Re: not using index for select min(...) Message-ID: <20030131183104.L24535@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , "'pgsql-performance@postgresql.org'" References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from don@sandvine.com on Fri, Jan 31, 2003 at 04:12:38PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/407 X-Sequence-Number: 1054 On Fri, Jan 31, 2003 at 04:12:38PM -0500, Don Bowman wrote: > Why wouldn't I be doing an index scan on this table? Because you're using the aggregate function min(). See A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Jan 31 20:49:04 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 74E2F479DBF for ; Fri, 31 Jan 2003 20:49:02 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id EC50D47DAFE for ; Fri, 31 Jan 2003 18:29:56 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2815469; Fri, 31 Jan 2003 15:30:04 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Don Bowman , "'pgsql-performance@postgresql.org'" Subject: Re: not using index for select min(...) Date: Fri, 31 Jan 2003 15:31:12 -0800 X-Mailer: KMail [version 1.4] References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301311531.12605.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/406 X-Sequence-Number: 1053 Don, > I have a table which is very large (~65K rows). I have > a column in it which is indexed, and I wish to use for > a join. I'm finding that I'm using a sequential scan > for this when selecting a MIN. Due to Postgres' system of extensible aggregates (i.e. you can write your o= wn=20 aggregates), all aggregates will trigger a Seq Scan in a query. It's a=20 known drawrback that nobody has yet found a good way around. --=20 -Josh Berkus Aglio Database Solutions San Francisco