From pgsql-performance-owner@postgresql.org Sun May 1 20:23:36 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 950375323A for ; Sun, 1 May 2005 20:22:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79817-07 for ; Sun, 1 May 2005 23:22:50 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 7D1BA536BC for ; Sun, 1 May 2005 20:22:48 -0300 (ADT) Received: (qmail 23007 invoked from network); 2 May 2005 01:23:07 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 2 May 2005 01:23:07 +0200 Date: Mon, 02 May 2005 01:22:49 +0200 To: apoc9009@yahoo.de, pgsql-performance@postgresql.org Subject: Re: BLOB's bypassing the OS Filesystem for better Image References: <426DFA46.8090402@yahoo.de> <426E0B35.9080509@yahoo.de> <426E045C.7010601@archonet.com> From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <426E0B35.9080509@yahoo.de> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/1 X-Sequence-Number: 12165 My laptop reads an entire compiled linux kernel (23000 files totalling 250 MBytes) in about 1.5 seconds if they're in cache. It's about 15.000 files/second. You think it's slow ? If you want to read them in random order, you'll probably use something else than a laptop drive, but you get the idea. Filesystem is reiser4. If you use ext2, you'll have a problem with many files in the same directory because I believe it uses a linear search, hence time proportional to the number of files (ouch). I once tried to put a million 1-kbyte files in a directory ; it was with reiserfs 3, and it didn't seem to feel anything close to molested. I believe it took some 10 minutes, but it was two years ago so I don't remember very well. NTFS took a day, that I do remember ! By curiosity I tried to stuff 1 million 1KB files in a directory on my laptop right now, It took a bit less than two minutes. On Tue, 26 Apr 2005 11:34:45 +0200, apoc9009@yahoo.de wrote: > >> Which filesystems? I know ext2 used to have issues with many-thousands >> of files in one directory, but that was a directory scanning issue >> rather than file reading. > > From my Point of view i think it is better to let one Process do the > operation to an Postgres Cluster Filestructure as > if i bypass it with a second process. > > For example: > A User loads up some JPEG Images over HTTP. > > a) (Filesystem) > On Filesystem it would be written in a File with a random generated > Filename (timestamp or what ever) > (the Directory Expands and over a Million Fileobjects with will be > archived, written, replaced, e.t.c) > > b) (Database) > The JPEG Image Information will be stored into a BLOB as Part of a > special Table, where is linked > wit the custid of the primary Usertable. > > From my Point of view is any outside Process (must be created, forked, > Memory allocated, e.t.c) > a bad choice. I think it is generall better to Support the Postmaster in > all Ways and do some > Hardware RAID Configurations. > >>> My Question: >>> Can i speedup my Webapplication if i store my JPEG Images with small >>> sizes inside my PostgreSQL Database (on verry large Databasis over 1 >>> GByte >>> and above without Images at this time!) >> >> >> No. Otherwise the filesystem people would build their filesystems on >> top of PostgreSQL not the other way around. Of course, if you want >> image updates to be part of a database transaction, then it might be >> worth storing them in the database. > > Hmm, ORACLE is going the other Way. All File Objects can be stored into > the Database if the DB > has the IFS Option (Database Filesystem and Fileserver insinde the > Database). > > >> >>> I hope some Peoples can give me a Tip or Hint where in can >>> some usefull Information about it! >> >> Look into having a separate server (process or actual hardware) to >> handle requests for static text and images. Keep the Java server for >> actually processing > > > Thanks > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > From pgsql-performance-owner@postgresql.org Mon May 2 10:52:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4AB0F53776 for ; Mon, 2 May 2005 10:52:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01501-02 for ; Mon, 2 May 2005 13:52:29 +0000 (GMT) Received: from mail.se.linux.org (naskur.se.linux.org [213.141.80.20]) by svr1.postgresql.org (Postfix) with ESMTP id 0FE205352F for ; Mon, 2 May 2005 10:52:28 -0300 (ADT) Received: from tim (helo=localhost) by mail.se.linux.org with local-esmtp (Exim 3.35 #1 (Debian)) id 1DSbLb-0000R3-00 for ; Mon, 02 May 2005 15:52:31 +0200 Date: Mon, 2 May 2005 15:52:31 +0200 (CEST) From: =?iso-8859-1?Q?Tim_Terleg=E5rd?= Reply-To: tim@se.linux.org To: pgsql-performance@postgresql.org Subject: batch inserts are "slow" Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/2 X-Sequence-Number: 12166 Howdy! I'm converting an application to be using postgresql instead of oracle. There seems to be only one issue left, batch inserts in postgresql seem significant slower than in oracle. I have about 200 batch jobs, each consisting of about 14 000 inserts. Each job takes 1.3 seconds in postgresql and 0.25 seconds in oracle. With 200 jobs this means several more minutes to complete the task. By fixing this I think the application using postgresql over all would be faster than when using oracle. I'd like some advice of what could enhance the performance. I use PostgreSQL 8. The table that is loaded with a bunch of data has no indexes. I use Gentoo Linux on a P4 3GHz with 1GB RAM. I use JDBC from jdbc.postgresql.org, postgresql-8.0-311.jdbc3.jar. I've changed a few parameters as I hoped that would help me: wal_buffers = 64 checkpoint_segments = 10 shared_buffers = 15000 work_mem = 4096 maintenance_work_mem = 70000 effective_cache_size = 30000 shmmax is 150000000 These settings made creating index faster for instance. Don't know if they can be tweaked further so these batch jobs are executed faster? Some setting I forgot to tweak? I tried setting fsync to false, but that didnt change anything. Something like this is what runs and takes a bit too long imho: conn.setAutoCommit(false); pst = conn.prepareStatement("INSERT INTO tmp (...) VALUES (?,?)"); for (int i = 0; i < len; i++) { pst.setInt(0, 2); pst.setString(1, "xxx"); pst.addBatch(); } pst.executeBatch(); conn.commit(); This snip takes 1.3 secs in postgresql. How can I lower that? Thanks, Tim From pgsql-performance-owner@postgresql.org Mon May 2 12:10:49 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B25C154446 for ; Mon, 2 May 2005 12:10:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13906-02 for ; Mon, 2 May 2005 15:10:43 +0000 (GMT) Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) by svr1.postgresql.org (Postfix) with ESMTP id 5FEB953247 for ; Mon, 2 May 2005 12:10:41 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with ESMTP id 527B811CF7F; Mon, 2 May 2005 23:10:34 +0800 (WST) Received: from vscan02.westnet.com.au ([127.0.0.1]) by localhost (vscan02.westnet.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 15068-12; Mon, 2 May 2005 23:10:34 +0800 (WST) Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au [202.72.133.22]) by vscan02.westnet.com.au (Postfix) with ESMTP id E75B711CEAF; Mon, 2 May 2005 23:10:33 +0800 (WST) Message-ID: <427642E9.2080500@familyhealth.com.au> Date: Mon, 02 May 2005 23:10:33 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: tim@se.linux.org Cc: pgsql-performance@postgresql.org Subject: Re: batch inserts are "slow" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/3 X-Sequence-Number: 12167 > conn.setAutoCommit(false); > pst = conn.prepareStatement("INSERT INTO tmp (...) VALUES (?,?)"); > for (int i = 0; i < len; i++) { > pst.setInt(0, 2); > pst.setString(1, "xxx"); > pst.addBatch(); > } > pst.executeBatch(); > conn.commit(); > > This snip takes 1.3 secs in postgresql. How can I lower that? You're batching them as one transaction, and using a prepared query both of which are good. I guess the next step for a great performance improvement is to use the COPY command. However, you'd have to find out how to access that via Java. I have a nasty suspicion that the release JDBC driver doesn't support it and you may have to apply a patch. Ask on pgsql-jdbc@postgresql.org perhaps. Chris From pgsql-performance-owner@postgresql.org Mon May 2 12:17:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4989753236 for ; Mon, 2 May 2005 12:17:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14316-08 for ; Mon, 2 May 2005 15:17:20 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) by svr1.postgresql.org (Postfix) with ESMTP id 3425553224 for ; Mon, 2 May 2005 12:17:19 -0300 (ADT) Received: by rproxy.gmail.com with SMTP id a41so910115rng for ; Mon, 02 May 2005 08:17:19 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gyBLtuQiLOOzS8bK8MBkTzkl8gwc365ikNx/d7mEQfeoqLty8ZkjRhVCTE3JnTHa7nx0WBkD9jsUvAmnX6GfszwJcm+Vo8PPLCu+KblgTkYP8RiY8xS+Rs0nuWx6OFNJjFzSBRYff6ivXL+yYdjfyKgVhiBlua7OOZ6kgPXQd3E= Received: by 10.38.12.8 with SMTP id 8mr6312512rnl; Mon, 02 May 2005 08:17:18 -0700 (PDT) Received: by 10.38.207.41 with HTTP; Mon, 2 May 2005 08:17:18 -0700 (PDT) Message-ID: <59d991c405050208174b6ebbc@mail.gmail.com> Date: Mon, 2 May 2005 11:17:18 -0400 From: Christopher Petrilli Reply-To: Christopher Petrilli To: tim@se.linux.org Subject: Re: batch inserts are "slow" Cc: pgsql-performance@postgresql.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.319 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/4 X-Sequence-Number: 12168 On 5/2/05, Tim Terleg=E5rd wrote: > Howdy! >=20 > I'm converting an application to be using postgresql instead of oracle. > There seems to be only one issue left, batch inserts in postgresql seem > significant slower than in oracle. I have about 200 batch jobs, each > consisting of about 14 000 inserts. Each job takes 1.3 seconds in > postgresql and 0.25 seconds in oracle. With 200 jobs this means several > more minutes to complete the task. By fixing this I think the > application using postgresql over all would be faster than when using > oracle. Just as on Oracle you would use SQL*Loader for this application, you should use the COPY syntax for PostgreSQL. You will find it a lot faster. I have used it by building the input files and executing 'psql' with a COPY command, and also by using it with a subprocess, both are quite effective. Chris --=20 | Christopher Petrilli | petrilli@gmail.com From pgsql-performance-owner@postgresql.org Mon May 2 12:20:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 96EF55321A for ; Mon, 2 May 2005 12:20:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15495-04 for ; Mon, 2 May 2005 15:20:24 +0000 (GMT) Received: from mail.se.linux.org (naskur.se.linux.org [213.141.80.20]) by svr1.postgresql.org (Postfix) with ESMTP id 20149531FE for ; Mon, 2 May 2005 12:20:19 -0300 (ADT) Received: from tim (helo=localhost) by mail.se.linux.org with local-esmtp (Exim 3.35 #1 (Debian)) id 1DSciN-0007Ri-00; Mon, 02 May 2005 17:20:07 +0200 Date: Mon, 2 May 2005 17:20:07 +0200 (CEST) From: =?iso-8859-1?Q?Tim_Terleg=E5rd?= Reply-To: tim@se.linux.org To: Pawel Bernat Cc: pgsql-performance@postgresql.org Subject: Re: batch inserts are "slow" In-Reply-To: <20050502160321.A14165@vlo> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/5 X-Sequence-Number: 12169 > > Howdy! > > > > I'm converting an application to be using postgresql instead of oracle. > > There seems to be only one issue left, batch inserts in postgresql seem > > significant slower than in oracle. I have about 200 batch jobs, each > > consisting of about 14 000 inserts. Each job takes 1.3 seconds in > > postgresql and 0.25 seconds in oracle. With 200 jobs this means several > > more minutes to complete the task. By fixing this I think the > > application using postgresql over all would be faster than when using > > oracle. > > Have you tried COPY statement? I did that now. I copied all 3 million rows of data into a text file and executed the COPY command. It takes about 0.25 seconds per job. So that's much better. I'm afraid jdbc doesn't support COPY though. But now I know what the theoretical lower limit is atleast. Should it be possible to get anyway nearer 0.25s from my current 1.3s? Tim From pgsql-performance-owner@postgresql.org Mon May 2 12:27:46 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 115F65321F for ; Mon, 2 May 2005 12:27:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15876-08 for ; Mon, 2 May 2005 15:27:38 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) by svr1.postgresql.org (Postfix) with ESMTP id 866A1531FE for ; Mon, 2 May 2005 12:27:37 -0300 (ADT) Received: by rproxy.gmail.com with SMTP id a41so912019rng for ; Mon, 02 May 2005 08:27:37 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ZI4IJD44egRl7HYxrYXCJsNpcgdZgA3erbE0xJHR5YpnM8zn0XUVddvbh0GXQ4FLePbiVQauuuhk9Xk3k4hQOyEzwc8xsrYq8wdSyBxcd/6dF0JzA646zyq3kleTzkM68Zf0pkenulqnxTgxnjt/gJ94XIq5XOMEa3/jvxAUAdM= Received: by 10.38.149.48 with SMTP id w48mr6314657rnd; Mon, 02 May 2005 08:27:37 -0700 (PDT) Received: by 10.38.207.41 with HTTP; Mon, 2 May 2005 08:27:37 -0700 (PDT) Message-ID: <59d991c40505020827e694eeb@mail.gmail.com> Date: Mon, 2 May 2005 11:27:37 -0400 From: Christopher Petrilli Reply-To: Christopher Petrilli To: tim@se.linux.org Subject: Re: batch inserts are "slow" Cc: Pawel Bernat , pgsql-performance@postgresql.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20050502160321.A14165@vlo> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.319 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/6 X-Sequence-Number: 12170 On 5/2/05, Tim Terleg=E5rd wrote: > > > Howdy! > > > > > > I'm converting an application to be using postgresql instead of oracl= e. > > > There seems to be only one issue left, batch inserts in postgresql se= em > > > significant slower than in oracle. I have about 200 batch jobs, each > > > consisting of about 14 000 inserts. Each job takes 1.3 seconds in > > > postgresql and 0.25 seconds in oracle. With 200 jobs this means sever= al > > > more minutes to complete the task. By fixing this I think the > > > application using postgresql over all would be faster than when using > > > oracle. > > > > Have you tried COPY statement? >=20 > I did that now. I copied all 3 million rows of data into a text file and > executed the COPY command. It takes about 0.25 seconds per job. So that's > much better. I'm afraid jdbc doesn't support COPY though. But now I know > what the theoretical lower limit is atleast. >=20 > Should it be possible to get anyway nearer 0.25s from my current 1.3s? My experience says 'no'. What you're likely seeing is the parse overhead of the setup. When you use COPY (as opposed to \copy), the postmaster is reading the file directory. There's just a lot less overhead. Can you write the files on disk and then kick off the psql process to run t= hem? Chris --=20 | Christopher Petrilli | petrilli@gmail.com From pgsql-performance-owner@postgresql.org Mon May 2 12:30:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E14D75294D for ; Mon, 2 May 2005 12:30:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15866-10 for ; Mon, 2 May 2005 15:30:02 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CF3C25351C for ; Mon, 2 May 2005 12:30:00 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j42FTxK1018687; Mon, 2 May 2005 11:29:59 -0400 (EDT) To: tim@se.linux.org Cc: pgsql-performance@postgresql.org Subject: Re: batch inserts are "slow" In-reply-to: References: Comments: In-reply-to =?iso-8859-1?Q?Tim_Terleg=E5rd?= message dated "Mon, 02 May 2005 15:52:31 +0200" Date: Mon, 02 May 2005 11:29:59 -0400 Message-ID: <18686.1115047799@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/7 X-Sequence-Number: 12171 =?iso-8859-1?Q?Tim_Terleg=E5rd?= writes: > There seems to be only one issue left, batch inserts in postgresql seem > significant slower than in oracle. I have about 200 batch jobs, each > consisting of about 14 000 inserts. > conn.setAutoCommit(false); > pst = conn.prepareStatement("INSERT INTO tmp (...) VALUES (?,?)"); > for (int i = 0; i < len; i++) { > pst.setInt(0, 2); > pst.setString(1, "xxx"); > pst.addBatch(); > } > pst.executeBatch(); > conn.commit(); Hmm. It's good that you are wrapping this in a transaction, but I wonder about doing it as a single "batch". I have no idea what the internal implementation of batches in JDBC is like, but it seems possible that it would have some performance issues with 14000 statements in a batch. Have you checked whether the bulk of the runtime is being consumed on the server or client side? Also, make sure that the JDBC driver is using "real" prepared statements --- until pretty recently, it faked them. I think build 311 is new enough, but it would be good to check in the docs or by asking on pgsql-jdbc. regards, tom lane From pgsql-performance-owner@postgresql.org Mon May 2 12:53:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DC3D7535EC for ; Mon, 2 May 2005 12:53:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20317-05 for ; Mon, 2 May 2005 15:53:36 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 6DD855352A for ; Mon, 2 May 2005 12:53:34 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: batch inserts are "slow" Date: Mon, 2 May 2005 11:53:33 -0400 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C67EF1F@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] batch inserts are "slow" Thread-Index: AcVPK2Bx0b+ax4tLToiQSjMlMTnD0QAAtUgQ From: "David Parker" To: "Christopher Kings-Lynne" , Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.088 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/8 X-Sequence-Number: 12172 We ran into the need to use COPY, but our application is also in Java. We wrote a JNI bridge to a C++ routine that uses the libpq library to do the COPY. The coding is a little bit weird, but not too complicated - the biggest pain in the neck is probably getting it into your build system. Here's the Java tutorial on JNI: http://java.sun.com/docs/books/tutorial/native1.1/concepts/index.html=20 Hope that helps! - DAP >-----Original Message----- >From: pgsql-performance-owner@postgresql.org=20 >[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 >Christopher Kings-Lynne >Sent: Monday, May 02, 2005 11:11 AM >To: tim@se.linux.org >Cc: pgsql-performance@postgresql.org >Subject: Re: [PERFORM] batch inserts are "slow" > >> conn.setAutoCommit(false); >> pst =3D conn.prepareStatement("INSERT INTO tmp (...) VALUES=20 >(?,?)"); for=20 >> (int i =3D 0; i < len; i++) { >> pst.setInt(0, 2); >> pst.setString(1, "xxx"); >> pst.addBatch(); >> } >> pst.executeBatch(); >> conn.commit(); >>=20 >> This snip takes 1.3 secs in postgresql. How can I lower that? > >You're batching them as one transaction, and using a prepared=20 >query both of which are good. I guess the next step for a=20 >great performance improvement is to use the COPY command. =20 >However, you'd have to find out how to access that via Java. > >I have a nasty suspicion that the release JDBC driver doesn't=20 >support it and you may have to apply a patch. > >Ask on pgsql-jdbc@postgresql.org perhaps. > >Chris > >---------------------------(end of=20 >broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to=20 >majordomo@postgresql.org > From pgsql-hackers-owner@postgresql.org Mon May 2 14:32:59 2005 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2CE9453535 for ; Mon, 2 May 2005 13:14:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22957-10 for ; Mon, 2 May 2005 16:14:05 +0000 (GMT) Received: from agp.stanford.edu (agp.Stanford.EDU [171.67.73.10]) by svr1.postgresql.org (Postfix) with ESMTP id E8D435350A for ; Mon, 2 May 2005 13:14:04 -0300 (ADT) Received: from xenon.stanford.edu ([171.64.66.201]) by agp.stanford.edu with esmtps (TLSv1:DES-CBC3-SHA:168) (Exim 4.43) id 1DSdYX-000892-30; Mon, 02 May 2005 09:14:01 -0700 Received: from manku (helo=localhost) by xenon.Stanford.EDU with local-esmtp (Exim 4.50) id 1DSdYW-00026W-9a; Mon, 02 May 2005 09:14:00 -0700 Date: Mon, 2 May 2005 09:14:00 -0700 (PDT) From: Gurmeet Manku To: Gurmeet Manku Cc: pgsql-perform , Subject: Citation for "Bad n_distinct estimation; hacks suggested?" In-Reply-To: <1114549351.21529.363.camel@localhost.localdomain> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.242 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/89 X-Sequence-Number: 66965 Actually, the earliest paper that solves the distinct_n estimation problem in 1 pass is the following: "Estimating simple functions on the union of data streams" by Gibbons and Tirthapura, SPAA 2001. http://home.eng.iastate.edu/~snt/research/streaming.pdf The above paper addresses a more difficult problem (1 pass _and_ a distributed setting). Gibbon's followup paper in VLDB 2001 limits the problem to a single machine and contains primarily experimental results (for a database audience). The algorithmic breakthrough had already been accomplished in the SPAA paper. Gurmeet -- ---------------------------------------------------- Gurmeet Singh Manku Google Inc. http://www.cs.stanford.edu/~manku (650) 967 1890 ---------------------------------------------------- From pgsql-performance-owner@postgresql.org Mon May 2 14:04:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F2B8D53690 for ; Mon, 2 May 2005 14:04:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40580-07 for ; Mon, 2 May 2005 17:04:08 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 269095364B for ; Mon, 2 May 2005 14:04:07 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id A2C0C30952; Mon, 2 May 2005 19:02:20 +0200 (MET DST) From: Chris Browne X-Newsgroups: pgsql.performance Subject: Re: batch inserts are "slow" Date: Mon, 02 May 2005 12:16:42 -0400 Organization: cbbrowne Computing Inc Lines: 38 Message-ID: <60wtqhy55h.fsf@dba2.int.libertyrms.com> References: <59d991c405050208174b6ebbc@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:nyksrB2eSi9NtHXM1q2RaIenbAM= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.157 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/10 X-Sequence-Number: 12174 petrilli@gmail.com (Christopher Petrilli) writes: > On 5/2/05, Tim Terleg�rd wrote: >> Howdy! >> >> I'm converting an application to be using postgresql instead of >> oracle. There seems to be only one issue left, batch inserts in >> postgresql seem significant slower than in oracle. I have about 200 >> batch jobs, each consisting of about 14 000 inserts. Each job takes >> 1.3 seconds in postgresql and 0.25 seconds in oracle. With 200 jobs >> this means several more minutes to complete the task. By fixing >> this I think the application using postgresql over all would be >> faster than when using oracle. > > Just as on Oracle you would use SQL*Loader for this application, you > should use the COPY syntax for PostgreSQL. You will find it a lot > faster. I have used it by building the input files and executing > 'psql' with a COPY command, and also by using it with a subprocess, > both are quite effective. I'd suggest taking a peek at the PGForge project, pgloader . This is intended to provide somewhat analagous functionality to SQL*Loader; a particularly useful thing about it is that it will load those records that it can, and generate a file consisting of just the failures. It uses COPY, internally, so it does run reasonably fast. To the extent to which it is inadequate, it would be neat to see some enhancements... -- (format nil "~S@~S" "cbbrowne" "acm.org") http://www.ntlug.org/~cbbrowne/sap.html Rules of the Evil Overlord #78. "I will not tell my Legions of Terror "And he must be taken alive!" The command will be: ``And try to take him alive if it is reasonably practical.''" From pgsql-hackers-owner@postgresql.org Tue May 3 13:36:16 2005 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2B0753F95; Tue, 3 May 2005 10:08:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27718-05; Tue, 3 May 2005 13:08:16 +0000 (GMT) Received: from mail.logix-tt.com (wallaby.dingens.org [212.75.36.180]) by svr1.postgresql.org (Postfix) with ESMTP id 511BC53F93; Tue, 3 May 2005 10:08:15 -0300 (ADT) Received: from kingfisher.intern.logi-track.com (pD95DD5E9.dip0.t-ipconnect.de [217.93.213.233]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id DD1F3A861E; Tue, 3 May 2005 15:08:18 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with ESMTP id 9EBC3AB2D2; Tue, 3 May 2005 15:06:24 +0200 (CEST) Message-ID: <4277774F.7040205@logix-tt.com> Date: Tue, 03 May 2005 15:06:23 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-perform Cc: pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Bad n_distinct estimation; hacks suggested? References: <200504191209.05181.josh@agliodbs.com> <1114580284.426f253cc0087@webmail.telus.net> <426F9703.4010108@dunslane.net> <200504270825.17550.josh@agliodbs.com> In-Reply-To: <200504270825.17550.josh@agliodbs.com> X-Enigmail-Version: 0.91.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/202 X-Sequence-Number: 67078 Hi, Josh, Josh Berkus wrote: > Yes, actually. We need 3 different estimation methods: > 1 for tables where we can sample a large % of pages (say, >= 0.1) > 1 for tables where we sample a small % of pages but are "easily estimated" > 1 for tables which are not easily estimated by we can't afford to sample a > large % of pages. > > If we're doing sampling-based estimation, I really don't want people to lose > sight of the fact that page-based random sampling is much less expensive than > row-based random sampling. We should really be focusing on methods which > are page-based. Would it make sense to have a sample method that scans indices? I think that, at least for tree based indices (btree, gist), rather good estimates could be derived. And the presence of a unique index should lead to 100% distinct values estimation without any scan at all. Markus From pgsql-performance-owner@postgresql.org Tue May 3 11:42:42 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9C5C353FC4 for ; Tue, 3 May 2005 11:42:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41904-07 for ; Tue, 3 May 2005 14:42:37 +0000 (GMT) Received: from mail.logix-tt.com (wallaby.dingens.org [212.75.36.180]) by svr1.postgresql.org (Postfix) with ESMTP id 8EA1653FA0 for ; Tue, 3 May 2005 11:42:36 -0300 (ADT) Received: from kingfisher.intern.logi-track.com (pD95DD5E9.dip0.t-ipconnect.de [217.93.213.233]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id C4AB5A861E; Tue, 3 May 2005 16:42:42 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with ESMTP id 7B471AB2D2; Tue, 3 May 2005 16:40:47 +0200 (CEST) Message-ID: <42778D6E.4030401@logix-tt.com> Date: Tue, 03 May 2005 16:40:46 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Parker Cc: Christopher Kings-Lynne , tim@se.linux.org, pgsql-performance@postgresql.org Subject: Re: batch inserts are "slow" References: <07FDEE0ED7455A48AC42AC2070EDFF7C67EF1F@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C67EF1F@corpsrv2.tazznetworks.com> X-Enigmail-Version: 0.91.0.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/12 X-Sequence-Number: 12176 Hi, all, David Parker wrote: > We ran into the need to use COPY, but our application is also in Java. > We wrote a JNI bridge to a C++ routine that uses the libpq library to do > the COPY. The coding is a little bit weird, but not too complicated - > the biggest pain in the neck is probably getting it into your build > system. There are several hacks floating around that add COPY capabilities to the pgjdbc driver. As they all are rather simple hacks, they have not been included in the cvs yet, but they tend to work fine. Markus From pgsql-performance-owner@postgresql.org Tue May 3 12:11:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B397252C7A for ; Tue, 3 May 2005 12:11:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46804-10 for ; Tue, 3 May 2005 15:11:27 +0000 (GMT) Received: from mail.openskysoftware.com (ip67-153-26-131.z26-153-67.customer.algx.net [67.153.26.131]) by svr1.postgresql.org (Postfix) with ESMTP id 36D0C53DCA for ; Tue, 3 May 2005 12:11:24 -0300 (ADT) Received: from [192.168.10.8] (helo=openskysoftware.com) by mail.openskysoftware.com with esmtp (Exim 4.30) id 1DSz3T-0004Hz-Sy for pgsql-performance@postgresql.org; Tue, 03 May 2005 10:11:23 -0500 Received: from [192.168.1.101] (HELO testbench.openskysoftware.com) by openskysoftware.com (CommuniGate Pro SMTP 4.2.9) with ESMTP id 261636 for pgsql-performance@postgresql.org; Tue, 03 May 2005 10:11:23 -0500 Subject: Foreign key constraints compile faster in 7.4 From: Ashish Arte Reply-To: ashish@openskysoftware.com To: pgsql-perform In-Reply-To: References: Content-Type: text/plain Organization: Open Sky Software Inc. Message-Id: <1115133083.3961.5.camel@skyserver1.openskysoftware.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 (1.4.5-9) Date: Tue, 03 May 2005 10:11:23 -0500 Content-Transfer-Encoding: 7bit X-Scan-Signature: af18dd7a9fb5c3c4828d91f7181742be X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/13 X-Sequence-Number: 12177 Hello Everybody, We recently upgraded to Postgres 7.4 from 7.3.9 and noticed that the foreign key constraints compile noticeably faster. In 7.3 the constraints would typically take more than an hour to run on our production data. Now they take a minute or two. Can anybody explain such a major performance improvement ? Thanks -- Ashish Arte Open Sky Software From pgsql-performance-owner@postgresql.org Tue May 3 12:41:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2C64C53588 for ; Tue, 3 May 2005 12:41:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51914-07 for ; Tue, 3 May 2005 15:41:46 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id A96FA52AA8 for ; Tue, 3 May 2005 12:41:46 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7315527; Tue, 03 May 2005 08:43:45 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Markus Schaber Subject: Re: batch inserts are "slow" Date: Tue, 3 May 2005 08:41:43 -0700 User-Agent: KMail/1.8 Cc: David Parker , Christopher Kings-Lynne , tim@se.linux.org, pgsql-performance@postgresql.org References: <07FDEE0ED7455A48AC42AC2070EDFF7C67EF1F@corpsrv2.tazznetworks.com> <42778D6E.4030401@logix-tt.com> In-Reply-To: <42778D6E.4030401@logix-tt.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505030841.44159.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.012 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/14 X-Sequence-Number: 12178 People, > There are several hacks floating around that add COPY capabilities to > the pgjdbc driver. As they all are rather simple hacks, they have not > been included in the cvs yet, but they tend to work fine. FWIW, Dave Cramer just added beta COPY capability to JDBC. Contact him on the JDBC list for details; I think he needs testers. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue May 3 12:55:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A67153518 for ; Tue, 3 May 2005 12:55:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55374-02 for ; Tue, 3 May 2005 15:55:21 +0000 (GMT) Received: from e6.ny.us.ibm.com (e6.ny.us.ibm.com [32.97.182.146]) by svr1.postgresql.org (Postfix) with ESMTP id 78E18534A5 for ; Tue, 3 May 2005 12:55:20 -0300 (ADT) Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e6.ny.us.ibm.com (8.12.11/8.12.11) with ESMTP id j43FtJL8005945 for ; Tue, 3 May 2005 11:55:19 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay02.pok.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j43FtIlf097372 for ; Tue, 3 May 2005 11:55:19 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11/8.13.3) with ESMTP id j43FtIPA016031 for ; Tue, 3 May 2005 11:55:18 -0400 Received: from d01ml255.pok.ibm.com (d01ml255.pok.ibm.com [9.56.227.128]) by d01av04.pok.ibm.com (8.12.11/8.12.11) with ESMTP id j43FtIgN016026 for ; Tue, 3 May 2005 11:55:18 -0400 Subject: To: pgsql-perform X-Mailer: Lotus Notes Release 6.0.2CF1 June 9, 2003 Message-ID: From: Steven Rosenstein Date: Tue, 3 May 2005 11:55:15 -0400 X-MIMETrack: Serialize by Router on D01ML255/01/M/IBM(Release 6.53HF103 | November 15, 2004) at 05/03/2005 11:55:18 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.056 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, MISSING_SUBJECT X-Spam-Level: * X-Archive-Number: 200505/15 X-Sequence-Number: 12179 In our application we have tables that we regularly load with 5-10 million records daily. We *were* using INSERT (I know... Still kicking ourselves for *that* design decision), and we now converting over to COPY. For the sake of robustness, we are planning on breaking the entire load into chunks of a couple hundred thousand records each. This is to constrain the amount of data we'd have to re-process if one of the COPYs fails. My question is, are there any advantages, drawbacks, or outright restrictions to using multiple simultaneous COPY commands to load data into the same table? One issue that comes to mind is the loss of data sequencing if we have multiple chunks interleaving records in the table at the same time. But from a purely technical point of view, is there any reason why the backend would not be happy with two or more COPY commands trying to insert data into the same table at the same time? Does COPY take out any locks on a table? Thanks in advance, --- Steve From pgsql-performance-owner@postgresql.org Tue May 3 12:57:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 25DC353482 for ; Tue, 3 May 2005 12:57:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54699-04 for ; Tue, 3 May 2005 15:57:23 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 2B8745374A for ; Tue, 3 May 2005 12:57:22 -0300 (ADT) Received: (qmail 15507 invoked by uid 1112); 3 May 2005 15:57:21 -0000 Date: Tue, 3 May 2005 10:57:21 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Josh Berkus Cc: Markus Schaber , David Parker , Christopher Kings-Lynne , tim@se.linux.org, pgsql-performance@postgresql.org Subject: Re: batch inserts are "slow" In-Reply-To: <200505030841.44159.josh@agliodbs.com> Message-ID: References: <07FDEE0ED7455A48AC42AC2070EDFF7C67EF1F@corpsrv2.tazznetworks.com> <42778D6E.4030401@logix-tt.com> <200505030841.44159.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/16 X-Sequence-Number: 12180 On Tue, 3 May 2005, Josh Berkus wrote: > > There are several hacks floating around that add COPY capabilities to > > the pgjdbc driver. As they all are rather simple hacks, they have not > > been included in the cvs yet, but they tend to work fine. > > FWIW, Dave Cramer just added beta COPY capability to JDBC. Contact him on > the JDBC list for details; I think he needs testers. > I believe Dave has remerged a patch for COPY I posted over a year ago, but he has not yet published it. I would guess it has the same bugs as the original (transaction + error handling) and will meet the same objections that kept the original patch out of the driver in the first place (we want a friendlier API than just a data stream). Kris Jurka From pgsql-performance-owner@postgresql.org Tue May 3 13:00:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BD58C53874 for ; Tue, 3 May 2005 13:00:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56178-05 for ; Tue, 3 May 2005 15:59:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 42FEB53710 for ; Tue, 3 May 2005 12:59:56 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j43FxlgS019632; Tue, 3 May 2005 11:59:47 -0400 (EDT) To: ashish@openskysoftware.com Cc: pgsql-perform Subject: Re: Foreign key constraints compile faster in 7.4 In-reply-to: <1115133083.3961.5.camel@skyserver1.openskysoftware.com> References: <1115133083.3961.5.camel@skyserver1.openskysoftware.com> Comments: In-reply-to Ashish Arte message dated "Tue, 03 May 2005 10:11:23 -0500" Date: Tue, 03 May 2005 11:59:47 -0400 Message-ID: <19631.1115135987@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/17 X-Sequence-Number: 12181 Ashish Arte writes: > We recently upgraded to Postgres 7.4 from 7.3.9 and noticed that the > foreign key constraints compile noticeably faster. In 7.3 the > constraints would typically take more than an hour to run on our > production data. Now they take a minute or two. > Can anybody explain such a major performance improvement ? Hey, we do do some work on this thing from time to time ;-) Probably you are talking about this: 2003-10-06 12:38 tgl * src/: backend/commands/tablecmds.c, backend/utils/adt/ri_triggers.c, include/commands/trigger.h: During ALTER TABLE ADD FOREIGN KEY, try to check the existing rows using a single LEFT JOIN query instead of firing the check trigger for each row individually. Stephan Szabo, with some kibitzing from Tom Lane and Jan Wieck. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 3 13:12:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EDF10538AF for ; Tue, 3 May 2005 13:12:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58328-05 for ; Tue, 3 May 2005 16:12:24 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 88EC4538AE for ; Tue, 3 May 2005 13:12:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j43GCL3H021155; Tue, 3 May 2005 12:12:22 -0400 (EDT) To: Steven Rosenstein Cc: pgsql-perform Subject: Re: In-reply-to: References: Comments: In-reply-to Steven Rosenstein message dated "Tue, 03 May 2005 11:55:15 -0400" Date: Tue, 03 May 2005 12:12:21 -0400 Message-ID: <21154.1115136741@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/18 X-Sequence-Number: 12182 Steven Rosenstein writes: > My question is, are there any advantages, drawbacks, or outright > restrictions to using multiple simultaneous COPY commands to load data into > the same table? It will work; not sure about whether there is any performance benefit. I vaguely recall someone having posted about doing this, so you might check the archives. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 3 14:29:12 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 465D3536C3 for ; Tue, 3 May 2005 14:29:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46771-09 for ; Tue, 3 May 2005 17:29:08 +0000 (GMT) Received: from oismail.com (unknown [38.117.22.100]) by svr1.postgresql.org (Postfix) with ESMTP id 9BFF05342B for ; Tue, 3 May 2005 14:29:07 -0300 (ADT) Received: from [192.168.8.102] ([213.173.234.215]) (authenticated bits=0) by oismail.com (8.12.11/8.12.11) with ESMTP id j43HTGJb027566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 3 May 2005 13:29:18 -0400 Message-ID: <4277B5D2.8020205@oismail.com> Date: Tue, 03 May 2005 19:33:06 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Testing list access References: <07FDEE0ED7455A48AC42AC2070EDFF7C67EF1F@corpsrv2.tazznetworks.com> <42778D6E.4030401@logix-tt.com> In-Reply-To: <42778D6E.4030401@logix-tt.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/19 X-Sequence-Number: 12183 Testing list access From pgsql-performance-owner@postgresql.org Tue May 3 14:37:42 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6F3B053A92 for ; Tue, 3 May 2005 14:37:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49275-03 for ; Tue, 3 May 2005 17:37:39 +0000 (GMT) Received: from oismail.com (unknown [38.117.22.100]) by svr1.postgresql.org (Postfix) with ESMTP id 444D85380C for ; Tue, 3 May 2005 14:37:38 -0300 (ADT) Received: from [192.168.8.102] ([213.173.234.215]) (authenticated bits=0) by oismail.com (8.12.11/8.12.11) with ESMTP id j43HblqQ027830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 3 May 2005 13:37:49 -0400 Message-ID: <4277B7D1.6060204@oismail.com> Date: Tue, 03 May 2005 19:41:37 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 part 2 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.038 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/20 X-Sequence-Number: 12184 Please refer to part 1 for question and query 1 Cheers Jona ----------------------------------------------------------------------------------------------------------------------- Query 2: EXPLAIN ANALYZE SELECT DISTINCT CatType_Tbl.id, CatType_Tbl.url, Category_Tbl.name, Min(SubCatType_Tbl.id) AS subcatid FROM (CatType_Tbl INNER JOIN Category_Tbl ON CatType_Tbl.id = Category_Tbl.cattpid AND Category_Tbl.enabled = true INNER JOIN Language_Tbl ON Language_Tbl.id = Category_Tbl.langid AND Language_Tbl.sysnm = UPPER('us') AND Language_Tbl.enabled = true INNER JOIN SubCatType_Tbl ON CatType_Tbl.id = SubCatType_Tbl.cattpid AND SubCatType_Tbl.enabled = true INNER JOIN SCT2SubCatType_Tbl ON SubCatType_Tbl.id = SCT2SubCatType_Tbl.subcattpid INNER JOIN Price_Tbl ON SCT2SubCatType_Tbl.sctid = Price_Tbl.sctid AND Price_Tbl.affid = 8) WHERE CatType_Tbl.spcattpid = 1 AND CatType_Tbl.enabled = true GROUP BY CatType_Tbl.id, CatType_Tbl.url, Category_Tbl.name ORDER BY CatType_Tbl.id ASC Plan on PostGre 7.3.6 on Red Hat Linux 3.2.3-39 "Unique (cost=94.57..94.58 rows=1 width=147) (actual time=134.85..134.86 rows=4 loops=1)" " -> Sort (cost=94.57..94.57 rows=1 width=147) (actual time=134.85..134.85 rows=4 loops=1)" " Sort Key: cattype_tbl.id, cattype_tbl.url, category_tbl.name, min(subcattype_tbl.id)" " -> Aggregate (cost=94.54..94.56 rows=1 width=147) (actual time=127.49..134.77 rows=4 loops=1)" " -> Group (cost=94.54..94.55 rows=1 width=147) (actual time=114.85..132.44 rows=2117 loops=1)" " -> Sort (cost=94.54..94.55 rows=1 width=147) (actual time=114.84..116.10 rows=2117 loops=1)" " Sort Key: cattype_tbl.id, cattype_tbl.url, category_tbl.name" " -> Nested Loop (cost=4.54..94.53 rows=1 width=147) (actual time=0.64..52.65 rows=2117 loops=1)" " -> Nested Loop (cost=4.54..88.51 rows=1 width=143) (actual time=0.55..18.23 rows=2838 loops=1)" " -> Hash Join (cost=4.54..8.93 rows=1 width=135) (actual time=0.44..1.34 rows=48 loops=1)" " Hash Cond: ("outer".langid = "inner".id)" " -> Hash Join (cost=3.47..7.84 rows=1 width=131) (actual time=0.35..1.05 rows=96 loops=1)" " Hash Cond: ("outer".cattpid = "inner".id)" " -> Seq Scan on subcattype_tbl (cost=0.00..3.98 rows=79 width=8) (actual time=0.03..0.37 rows=156 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=3.46..3.46 rows=1 width=123) (actual time=0.30..0.30 rows=0 loops=1)" " -> Hash Join (cost=1.50..3.46 rows=1 width=123) (actual time=0.12..0.29 rows=10 loops=1)" " Hash Cond: ("outer".cattpid = "inner".id)" " -> Seq Scan on category_tbl (cost=0.00..1.80 rows=32 width=51) (actual time=0.03..0.13 rows=64 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=1.50..1.50 rows=1 width=72) (actual time=0.07..0.07 rows=0 loops=1)" " -> Seq Scan on cattype_tbl (cost=0.00..1.50 rows=1 width=72) (actual time=0.04..0.06 rows=5 loops=1)" " Filter: ((spcattpid = 1) AND (enabled = true))" " -> Hash (cost=1.07..1.07 rows=1 width=4) (actual time=0.05..0.05 rows=0 loops=1)" " -> Seq Scan on language_tbl (cost=0.00..1.07 rows=1 width=4) (actual time=0.05..0.05 rows=1 loops=1)" " Filter: (((sysnm)::text = 'US'::text) AND (enabled = true))" " -> Index Scan using subcat_uq on sct2subcattype_tbl (cost=0.00..79.26 rows=26 width=8) (actual time=0.01..0.17 rows=59 loops=48)" " Index Cond: ("outer".id = sct2subcattype_tbl.subcattpid)" " -> Index Scan using aff_price_uq on price_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.01..0.01 rows=1 loops=2838)" " Index Cond: ((price_tbl.affid = 8) AND ("outer".sctid = price_tbl.sctid))" "Total runtime: 135.39 msec" Plan on PostGre 7.3.9 on Red Hat Linux 3.2.3-49 "Unique (cost=1046.36..1046.54 rows=1 width=75) (actual time=279.67..279.69 rows=4 loops=1)" " -> Sort (cost=1046.36..1046.40 rows=15 width=75) (actual time=279.67..279.67 rows=4 loops=1)" " Sort Key: cattype_tbl.id, cattype_tbl.url, category_tbl.name, min(subcattype_tbl.id)" " -> Aggregate (cost=1044.22..1046.07 rows=15 width=75) (actual time=266.85..279.20 rows=4 loops=1)" " -> Group (cost=1044.22..1045.70 rows=148 width=75) (actual time=245.28..275.37 rows=2555 loops=1)" " -> Sort (cost=1044.22..1044.59 rows=148 width=75) (actual time=245.27..248.35 rows=2555 loops=1)" " Sort Key: cattype_tbl.id, cattype_tbl.url, category_tbl.name" " -> Hash Join (cost=141.39..1038.89 rows=148 width=75) (actual time=67.81..153.45 rows=2555 loops=1)" " Hash Cond: ("outer".sctid = "inner".sctid)" ------------------- Bad idea, price_tbl hold 38.5k records " -> Seq Scan on price_tbl (cost=0.00..883.48 rows=2434 width=4) (actual time=0.86..67.25 rows=4570 loops=1)" " Filter: (affid = 8)" " -> Hash (cost=140.62..140.62 rows=309 width=71) (actual time=66.85..66.85 rows=0 loops=1)" " -> Hash Join (cost=9.87..140.62 rows=309 width=71) (actual time=9.08..60.17 rows=3214 loops=1)" " Hash Cond: ("outer".subcattpid = "inner".id)" ------------------- Bad idea, sct2subcattype_tbl hold 5.5k records " -> Seq Scan on sct2subcattype_tbl (cost=0.00..99.26 rows=5526 width=8) (actual time=0.01..30.16 rows=5526 loops=1)" " -> Hash (cost=9.85..9.85 rows=9 width=63) (actual time=8.97..8.97 rows=0 loops=1)" " -> Hash Join (cost=4.99..9.85 rows=9 width=63) (actual time=7.96..8.87 rows=48 loops=1)" " Hash Cond: ("outer".cattpid = "inner".cattpid)" " -> Seq Scan on subcattype_tbl (cost=0.00..3.98 rows=156 width=8) (actual time=0.02..0.50 rows=156 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=4.98..4.98 rows=2 width=55) (actual time=7.83..7.83 rows=0 loops=1)" " -> Hash Join (cost=2.58..4.98 rows=2 width=55) (actual time=7.34..7.81 rows=5 loops=1)" " Hash Cond: ("outer".cattpid = "inner".id)" " -> Hash Join (cost=1.08..3.36 rows=13 width=27) (actual time=0.32..0.73 rows=32 loops=1)" " Hash Cond: ("outer".langid = "inner".id)" " -> Seq Scan on category_tbl (cost=0.00..1.80 rows=64 width=23) (actual time=0.02..0.24 rows=64 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=1.07..1.07 rows=1 width=4) (actual time=0.10..0.10 rows=0 loops=1)" " -> Seq Scan on language_tbl (cost=0.00..1.07 rows=1 width=4) (actual time=0.09..0.10 rows=1 loops=1)" " Filter: (((sysnm)::text = 'US'::text) AND (enabled = true))" " -> Hash (cost=1.50..1.50 rows=5 width=28) (actual time=6.87..6.87 rows=0 loops=1)" " -> Seq Scan on cattype_tbl (cost=0.00..1.50 rows=5 width=28) (actual time=6.81..6.86 rows=5 loops=1)" " Filter: ((spcattpid = 1) AND (enabled = true))" "Total runtime: 297.35 msec" ----------------------------------------------------------------------------------------------------------------------- Query 3: EXPLAIN ANALYZE SELECT Count(DISTINCT SCT2SubCatType_Tbl.id) AS num FROM (SCT2SubCatType_Tbl INNER JOIN StatConTrans_Tbl ON SCT2SubCatType_Tbl.sctid = StatConTrans_Tbl.id AND StatConTrans_Tbl.enabled = true INNER JOIN SCT2Lang_Tbl ON StatConTrans_Tbl.id = SCT2Lang_Tbl.sctid INNER JOIN Info_Tbl ON StatConTrans_Tbl.id = Info_Tbl.sctid INNER JOIN Language_Tbl ON SCT2Lang_Tbl.langid = Language_Tbl.id AND Info_Tbl.langid = Language_Tbl.id AND Language_Tbl.sysnm = UPPER('us') AND Language_Tbl.enabled = true INNER JOIN Price_Tbl ON StatConTrans_Tbl.id = Price_Tbl.sctid AND Price_Tbl.affid = 8 INNER JOIN StatCon_Tbl ON StatConTrans_Tbl.id = StatCon_Tbl.sctid AND StatCon_Tbl.ctpid = 1 INNER JOIN B2SC_Tbl ON StatCon_Tbl.id = B2SC_Tbl.scid AND B2SC_Tbl.bid = 80 INNER JOIN B2M_Tbl ON StatCon_Tbl.mtpid = B2M_Tbl.mtpid AND B2M_Tbl.bid = 80 INNER JOIN SMSC2MimeType_Tbl ON StatCon_Tbl.mtpid = SMSC2MimeType_Tbl.mtpid AND SMSC2MimeType_Tbl.smscid = 3) WHERE SCT2SubCatType_Tbl.subcattpid = 138 Plan on PostGre 7.3.6 on Red Hat Linux 3.2.3-39 "Aggregate (cost=495.96..495.96 rows=1 width=60) (actual time=62.36..62.36 rows=1 loops=1)" " -> Nested Loop (cost=80.40..495.96 rows=1 width=60) (actual time=62.30..62.30 rows=0 loops=1)" " Join Filter: ("outer".mtpid = "inner".mtpid)" " -> Nested Loop (cost=80.40..489.99 rows=1 width=56) (actual time=62.30..62.30 rows=0 loops=1)" " -> Nested Loop (cost=80.40..484.07 rows=1 width=52) (actual time=62.29..62.29 rows=0 loops=1)" " -> Nested Loop (cost=80.40..478.05 rows=1 width=44) (actual time=62.29..62.29 rows=0 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Nested Loop (cost=80.40..472.03 rows=1 width=40) (actual time=62.29..62.29 rows=0 loops=1)" " -> Nested Loop (cost=80.40..315.17 rows=1 width=36) (actual time=1.01..27.62 rows=69 loops=1)" " Join Filter: ("outer".id = "inner".sctid)" " -> Nested Loop (cost=80.40..309.14 rows=1 width=24) (actual time=0.91..26.31 rows=69 loops=1)" " -> Hash Join (cost=80.40..275.63 rows=6 width=20) (actual time=0.80..25.18 rows=69 loops=1)" " Hash Cond: ("outer".sctid = "inner".sctid)" " -> Hash Join (cost=1.08..195.80 rows=43 width=12) (actual time=0.15..21.75 rows=3947 loops=1)" " Hash Cond: ("outer".langid = "inner".id)" ----------------- Bad idea, sct2lang_tbl has 8.6k records, but the query is still faster than the one below where it uses its index? " -> Seq Scan on sct2lang_tbl (cost=0.00..150.79 rows=8679 width=8) (actual time=0.03..10.70 rows=8679 loops=1)" " -> Hash (cost=1.07..1.07 rows=1 width=4) (actual time=0.05..0.05 rows=0 loops=1)" " -> Seq Scan on language_tbl (cost=0.00..1.07 rows=1 width=4) (actual time=0.04..0.05 rows=1 loops=1)" " Filter: (((sysnm)::text = 'US'::text) AND (enabled = true))" " -> Hash (cost=79.26..79.26 rows=26 width=8) (actual time=0.39..0.39 rows=0 loops=1)" " -> Index Scan using subcat_uq on sct2subcattype_tbl (cost=0.00..79.26 rows=26 width=8) (actual time=0.10..0.33 rows=69 loops=1)" " Index Cond: (subcattpid = 138)" " -> Index Scan using statcontrans_pk on statcontrans_tbl (cost=0.00..5.99 rows=1 width=4) (actual time=0.01..0.01 rows=1 loops=69)" " Index Cond: (statcontrans_tbl.id = "outer".sctid)" " Filter: (enabled = true)" " -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 rows=1 width=12) (actual time=0.01..0.01 rows=1 loops=69)" " Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))" " -> Index Scan using b2sc_uq on b2sc_tbl (cost=0.00..156.38 rows=38 width=4) (actual time=0.50..0.50 rows=0 loops=69)" " Index Cond: ((b2sc_tbl.bid = 80) AND ("outer".id = b2sc_tbl.scid))" " -> Index Scan using aff_price_uq on price_tbl (cost=0.00..6.01 rows=1 width=4) (never executed)" " Index Cond: ((price_tbl.affid = 8) AND (price_tbl.sctid = "outer".sctid))" " -> Index Scan using info_uq on info_tbl (cost=0.00..6.00 rows=1 width=8) (never executed)" " Index Cond: ((info_tbl.sctid = "outer".sctid) AND (info_tbl.langid = "outer".langid))" " -> Index Scan using b2m_uq on b2m_tbl (cost=0.00..5.91 rows=1 width=4) (never executed)" " Index Cond: ((b2m_tbl.bid = 80) AND ("outer".mtpid = b2m_tbl.mtpid))" " -> Index Scan using smsc2mimetype_uq on smsc2mimetype_tbl (cost=0.00..5.95 rows=1 width=4) (never executed)" " Index Cond: ((smsc2mimetype_tbl.smscid = 3) AND (smsc2mimetype_tbl.mtpid = "outer".mtpid))" "Total runtime: 62.98 msec" Plan on PostGre 7.3.9 on Red Hat Linux 3.2.3-49 "Aggregate (cost=538.89..538.89 rows=1 width=60) (actual time=1699.01..1699.01 rows=1 loops=1)" " -> Nested Loop (cost=1.08..538.89 rows=1 width=60) (actual time=1698.94..1698.94 rows=0 loops=1)" " Join Filter: ("outer".mtpid = "inner".mtpid)" " -> Nested Loop (cost=1.08..533.21 rows=1 width=56) (actual time=1698.94..1698.94 rows=0 loops=1)" " -> Nested Loop (cost=1.08..526.96 rows=1 width=52) (actual time=1698.93..1698.93 rows=0 loops=1)" " -> Nested Loop (cost=1.08..518.61 rows=1 width=44) (actual time=1698.93..1698.93 rows=0 loops=1)" " -> Nested Loop (cost=1.08..501.22 rows=3 width=40) (actual time=6.98..466.52 rows=69 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Nested Loop (cost=1.08..440.65 rows=3 width=28) (actual time=6.92..331.23 rows=69 loops=1)" " Join Filter: ("inner".id = "outer".sctid)" " -> Hash Join (cost=1.08..418.73 rows=4 width=24) (actual time=3.59..172.15 rows=69 loops=1)" " Hash Cond: ("outer".langid = "inner".id)" " -> Nested Loop (cost=0.00..417.51 rows=19 width=20) (actual time=3.20..171.27 rows=138 loops=1)" " -> Nested Loop (cost=0.00..287.97 rows=16 width=12) (actual time=3.15..5.27 rows=69 loops=1)" " -> Index Scan using subcat_uq on sct2subcattype_tbl (cost=0.00..92.56 rows=33 width=8) (actual time=3.06..3.45 rows=69 loops=1)" " Index Cond: (subcattpid = 138)" " -> Index Scan using aff_price_uq on price_tbl (cost=0.00..5.88 rows=1 width=4) (actual time=0.02..0.02 rows=1 loops=69)" " Index Cond: ((price_tbl.affid = 8) AND (price_tbl.sctid = "outer".sctid))" " -> Index Scan using sct2lang_uq on sct2lang_tbl (cost=0.00..8.13 rows=2 width=8) (actual time=1.10..2.39 rows=2 loops=69)" " Index Cond: (sct2lang_tbl.sctid = "outer".sctid)" " -> Hash (cost=1.07..1.07 rows=1 width=4) (actual time=0.20..0.20 rows=0 loops=1)" " -> Seq Scan on language_tbl (cost=0.00..1.07 rows=1 width=4) (actual time=0.18..0.19 rows=1 loops=1)" " Filter: (((sysnm)::text = 'US'::text) AND (enabled = true))" " -> Index Scan using statcontrans_pk on statcontrans_tbl (cost=0.00..5.88 rows=1 width=4) (actual time=2.29..2.30 rows=1 loops=69)" " Index Cond: (statcontrans_tbl.id = "outer".sctid)" " Filter: (enabled = true)" " -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 rows=5 width=12) (actual time=1.95..1.95 rows=1 loops=69)" " Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))" " -> Index Scan using sc2b on b2sc_tbl (cost=0.00..5.96 rows=1 width=4) (actual time=17.86..17.86 rows=0 loops=69)" " Index Cond: (("outer".id = b2sc_tbl.scid) AND (b2sc_tbl.bid = 80))" " -> Index Scan using info_uq on info_tbl (cost=0.00..5.93 rows=1 width=8) (never executed)" " Index Cond: ((info_tbl.sctid = "outer".sctid) AND (info_tbl.langid = "outer".langid))" " -> Index Scan using b2m_uq on b2m_tbl (cost=0.00..5.59 rows=1 width=4) (never executed)" " Index Cond: ((b2m_tbl.bid = 80) AND ("outer".mtpid = b2m_tbl.mtpid))" " -> Index Scan using smsc2mimetype_uq on smsc2mimetype_tbl (cost=0.00..5.67 rows=1 width=4) (never executed)" " Index Cond: ((smsc2mimetype_tbl.smscid = 3) AND (smsc2mimetype_tbl.mtpid = "outer".mtpid))" "Total runtime: 1710.07 msec" From pgsql-performance-owner@postgresql.org Tue May 3 14:44:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ED8225342B for ; Tue, 3 May 2005 14:44:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49459-09 for ; Tue, 3 May 2005 17:44:21 +0000 (GMT) Received: from mail.se.linux.org (naskur.se.linux.org [213.141.80.20]) by svr1.postgresql.org (Postfix) with ESMTP id EA49653411 for ; Tue, 3 May 2005 14:44:19 -0300 (ADT) Received: from tim (helo=localhost) by mail.se.linux.org with local-esmtp (Exim 3.35 #1 (Debian)) id 1DT1RI-0007KK-00; Tue, 03 May 2005 19:44:08 +0200 Date: Tue, 3 May 2005 19:44:08 +0200 (CEST) From: =?iso-8859-1?Q?Tim_Terleg=E5rd?= Reply-To: tim@se.linux.org To: Christopher Petrilli Cc: pgsql-performance@postgresql.org Subject: Re: batch inserts are "slow" In-Reply-To: <59d991c405050208174b6ebbc@mail.gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/21 X-Sequence-Number: 12185 > > I'm converting an application to be using postgresql instead of oracle. > > There seems to be only one issue left, batch inserts in postgresql seem > > significant slower than in oracle. I have about 200 batch jobs, each > > consisting of about 14 000 inserts. Each job takes 1.3 seconds in > > postgresql and 0.25 seconds in oracle. With 200 jobs this means several > > more minutes to complete the task. By fixing this I think the > > application using postgresql over all would be faster than when using > > oracle. > > Just as on Oracle you would use SQL*Loader for this application, you > should use the COPY syntax for PostgreSQL. You will find it a lot > faster. I have used it by building the input files and executing > 'psql' with a COPY command, and also by using it with a subprocess, > both are quite effective. I tried this now. Now it's down to 0.45 seconds. It feels a bit hacky to run /usr/bin/psql from java, but it sure works. Thanks for the hint! Tim From pgsql-performance-owner@postgresql.org Tue May 3 14:57:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 368D7535F8 for ; Tue, 3 May 2005 14:52:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52014-04 for ; Tue, 3 May 2005 17:52:45 +0000 (GMT) Received: from oismail.com (unknown [38.117.22.100]) by svr1.postgresql.org (Postfix) with ESMTP id 1120553550 for ; Tue, 3 May 2005 14:52:44 -0300 (ADT) Received: from [192.168.8.102] ([213.173.234.215]) (authenticated bits=0) by oismail.com (8.12.11/8.12.11) with ESMTP id j43HqsOa028303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 3 May 2005 13:52:56 -0400 Message-ID: <4277BB5C.3000902@oismail.com> Date: Tue, 03 May 2005 19:56:44 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 part 1b Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.084 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/22 X-Sequence-Number: 12186 Please refer to part 1a for questions and part 2 for more queries and query plans. Why won't this list accept my questions and sample data in one mail??? /Jona ---------------------------------------------------------------------------------------------------- Query 1: EXPLAIN ANALYZE SELECT DISTINCT StatConTrans_Tbl.id, Code_Tbl.sysnm AS code, PriceCat_Tbl.amount AS price, Country_Tbl.currency, CreditsCat_Tbl.amount AS credits, Info_Tbl.title, Info_Tbl.description FROM (SCT2SubCatType_Tbl INNER JOIN SCT2Lang_Tbl ON SCT2SubCatType_Tbl.sctid = SCT2Lang_Tbl.sctid INNER JOIN Language_Tbl ON SCT2Lang_Tbl.langid = Language_Tbl.id AND Language_Tbl.sysnm = UPPER('us') AND Language_Tbl.enabled = true INNER JOIN Info_Tbl ON SCT2SubCatType_Tbl.sctid = Info_Tbl.sctid AND Language_Tbl.id = Info_Tbl.langid INNER JOIN SubCatType_Tbl ON SCT2SubCatType_Tbl.subcattpid = SubCatType_Tbl.id AND SubCatType_Tbl.enabled = true INNER JOIN CatType_Tbl ON SubCatType_Tbl.cattpid = CatType_Tbl.id AND CatType_Tbl.enabled = true INNER JOIN SuperCatType_Tbl ON CatType_Tbl.spcattpid = SuperCatType_Tbl.id AND SuperCatType_Tbl.enabled = true INNER JOIN StatConTrans_Tbl ON SCT2SubCatType_Tbl.sctid = StatConTrans_Tbl.id AND StatConTrans_Tbl.enabled = true INNER JOIN Price_Tbl ON StatConTrans_Tbl.id = Price_Tbl.sctid AND Price_Tbl.affid = 8 INNER JOIN PriceCat_Tbl ON Price_Tbl.prccatid = PriceCat_Tbl.id AND PriceCat_Tbl.enabled = true INNER JOIN Country_Tbl ON PriceCat_Tbl.cntid = Country_Tbl.id AND Country_Tbl.enabled = true INNER JOIN CreditsCat_Tbl ON Price_Tbl.crdcatid = CreditsCat_Tbl.id AND CreditsCat_Tbl.enabled = true INNER JOIN StatCon_Tbl ON StatConTrans_Tbl.id = StatCon_Tbl.sctid AND StatCon_Tbl.ctpid = 1 INNER JOIN Code_Tbl ON SuperCatType_Tbl.id = Code_Tbl.spcattpid AND Code_Tbl.affid = 8 AND Code_Tbl.cdtpid = 1) WHERE SCT2SubCatType_Tbl.subcattpid = 79 ORDER BY StatConTrans_Tbl.id DESC LIMIT 8 OFFSET 0 Plan on PostGre 7.3.6 on Red Hat Linux 3.2.3-39 "Limit (cost=178.59..178.61 rows=1 width=330) (actual time=22.77..28.51 rows=4 loops=1)" " -> Unique (cost=178.59..178.61 rows=1 width=330) (actual time=22.77..28.50 rows=4 loops=1)" " -> Sort (cost=178.59..178.60 rows=1 width=330) (actual time=22.76..22.85 rows=156 loops=1)" " Sort Key: statcontrans_tbl.id, code_tbl.sysnm, pricecat_tbl.amount, country_tbl.currency, creditscat_tbl.amount, info_tbl.title, info_tbl.description" " -> Hash Join (cost=171.19..178.58 rows=1 width=330) (actual time=3.39..6.55 rows=156 loops=1)" " Hash Cond: ("outer".cntid = "inner".id)" " -> Nested Loop (cost=170.13..177.51 rows=1 width=312) (actual time=3.27..5.75 rows=156 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Hash Join (cost=170.13..171.48 rows=1 width=308) (actual time=3.12..3.26 rows=4 loops=1)" " Hash Cond: ("outer".crdcatid = "inner".id)" " -> Hash Join (cost=169.03..170.38 rows=1 width=300) (actual time=3.00..3.11 rows=4 loops=1)" " Hash Cond: ("outer".spcattpid = "inner".spcattpid)" " -> Hash Join (cost=167.22..168.56 rows=1 width=253) (actual time=2.88..2.97 rows=4 loops=1)" " Hash Cond: ("outer".id = "inner".prccatid)" " -> Seq Scan on pricecat_tbl (cost=0.00..1.29 rows=12 width=12) (actual time=0.04..0.08 rows=23 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=167.21..167.21 rows=1 width=241) (actual time=2.80..2.80 rows=0 loops=1)" " -> Nested Loop (cost=3.77..167.21 rows=1 width=241) (actual time=1.31..2.79 rows=4 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Nested Loop (cost=3.77..161.19 rows=1 width=229) (actual time=1.19..2.60 rows=4 loops=1)" " Join Filter: ("outer".sctid = "inner".sctid)" " -> Hash Join (cost=3.77..155.17 rows=1 width=44) (actual time=1.07..2.37 rows=4 loops=1)" " Hash Cond: ("outer".langid = "inner".id)" " -> Nested Loop (cost=2.69..154.06 rows=7 width=40) (actual time=0.90..2.18 rows=8 loops=1)" " Join Filter: ("outer".sctid = "inner".sctid)" " -> Nested Loop (cost=2.69..21.30 rows=1 width=32) (actual time=0.78..1.94 rows=4 loops=1)" " -> Nested Loop (cost=2.69..15.30 rows=1 width=28) (actual time=0.66..1.76 rows=4 loops=1)" " -> Hash Join (cost=2.69..7.07 rows=1 width=20) (actual time=0.39..1.15 rows=154 loops=1)" " Hash Cond: ("outer".cattpid = "inner".id)" " -> Seq Scan on subcattype_tbl (cost=0.00..3.98 rows=79 width=8) (actual time=0.03..0.35 rows=156 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=2.68..2.68 rows=3 width=12) (actual time=0.31..0.31 rows=0 loops=1)" " -> Hash Join (cost=1.15..2.68 rows=3 width=12) (actual time=0.16..0.27 rows=31 loops=1)" " Hash Cond: ("outer".spcattpid = "inner".id)" " -> Seq Scan on cattype_tbl (cost=0.00..1.41 rows=16 width=8) (actual time=0.04..0.09 rows=31 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=1.14..1.14 rows=6 width=4) (actual time=0.06..0.06 rows=0 loops=1)" " -> Seq Scan on supercattype_tbl (cost=0.00..1.14 rows=6 width=4) (actual time=0.03..0.05 rows=10 loops=1)" " Filter: (enabled = true)" " -> Index Scan using subcat_uq on sct2subcattype_tbl (cost=0.00..5.97 rows=1 width=8) (actual time=0.00..0.00 rows=0 loops=154)" " Index Cond: ((sct2subcattype_tbl.subcattpid = "outer".id) AND (sct2subcattype_tbl.subcattpid = 79))" " -> Index Scan using statcontrans_pk on statcontrans_tbl (cost=0.00..5.99 rows=1 width=4) (actual time=0.04..0.04 rows=1 loops=4)" " Index Cond: ("outer".sctid = statcontrans_tbl.id)" " Filter: (enabled = true)" " -> Index Scan using sct2lang_uq on sct2lang_tbl (cost=0.00..132.22 rows=43 width=8) (actual time=0.04..0.05 rows=2 loops=4)" " Index Cond: ("outer".id = sct2lang_tbl.sctid)" " -> Hash (cost=1.07..1.07 rows=1 width=4) (actual time=0.11..0.11 rows=0 loops=1)" " -> Seq Scan on language_tbl (cost=0.00..1.07 rows=1 width=4) (actual time=0.10..0.11 rows=1 loops=1)" " Filter: (((sysnm)::text = 'US'::text) AND (enabled = true))" " -> Index Scan using info_uq on info_tbl (cost=0.00..6.00 rows=1 width=185) (actual time=0.05..0.05 rows=1 loops=4)" " Index Cond: ((info_tbl.sctid = "outer".sctid) AND (info_tbl.langid = "outer".langid))" " -> Index Scan using aff_price_uq on price_tbl (cost=0.00..6.01 rows=1 width=12) (actual time=0.03..0.03 rows=1 loops=4)" " Index Cond: ((price_tbl.affid = 8) AND (price_tbl.sctid = "outer".sctid))" " -> Hash (cost=1.81..1.81 rows=1 width=47) (actual time=0.08..0.08 rows=0 loops=1)" " -> Seq Scan on code_tbl (cost=0.00..1.81 rows=1 width=47) (actual time=0.04..0.07 rows=5 loops=1)" " Filter: ((affid = 8) AND (cdtpid = 1))" " -> Hash (cost=1.09..1.09 rows=4 width=8) (actual time=0.06..0.06 rows=0 loops=1)" " -> Seq Scan on creditscat_tbl (cost=0.00..1.09 rows=4 width=8) (actual time=0.03..0.04 rows=7 loops=1)" " Filter: (enabled = true)" " -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4)" " Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))" " -> Hash (cost=1.06..1.06 rows=2 width=18) (actual time=0.06..0.06 rows=0 loops=1)" " -> Seq Scan on country_tbl (cost=0.00..1.06 rows=2 width=18) (actual time=0.04..0.05 rows=4 loops=1)" " Filter: (enabled = true)" "Total runtime: 29.56 msec" Plan on PostGre 7.3.9 on Red Hat Linux 3.2.3-49 "Limit (cost=545.53..545.60 rows=1 width=135) (actual time=1251.71..1261.25 rows=4 loops=1)" " -> Unique (cost=545.53..545.60 rows=1 width=135) (actual time=1251.71..1261.24 rows=4 loops=1)" " -> Sort (cost=545.53..545.54 rows=4 width=135) (actual time=1251.70..1251.90 rows=156 loops=1)" " Sort Key: statcontrans_tbl.id, code_tbl.sysnm, pricecat_tbl.amount, country_tbl.currency, creditscat_tbl.amount, info_tbl.title, info_tbl.description" " -> Nested Loop (cost=485.61..545.49 rows=4 width=135) (actual time=603.77..1230.96 rows=156 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Hash Join (cost=485.61..486.06 rows=3 width=131) (actual time=541.87..542.22 rows=4 loops=1)" " Hash Cond: ("outer".crdcatid = "inner".id)" " -> Hash Join (cost=484.51..484.90 rows=3 width=123) (actual time=529.09..529.36 rows=4 loops=1)" " Hash Cond: ("outer".spcattpid = "inner".spcattpid)" " -> Hash Join (cost=482.68..482.93 rows=3 width=114) (actual time=517.60..517.77 rows=4 loops=1)" " Hash Cond: ("outer".cntid = "inner".id)" " -> Merge Join (cost=481.60..481.80 rows=4 width=105) (actual time=517.36..517.43 rows=4 loops=1)" " Merge Cond: ("outer".id = "inner".prccatid)" " -> Sort (cost=1.81..1.87 rows=23 width=12) (actual time=8.44..8.45 rows=6 loops=1)" " Sort Key: pricecat_tbl.id" " -> Seq Scan on pricecat_tbl (cost=0.00..1.29 rows=23 width=12) (actual time=8.31..8.37 rows=23 loops=1)" " Filter: (enabled = true)" " -> Sort (cost=479.80..479.81 rows=4 width=93) (actual time=508.87..508.87 rows=4 loops=1)" " Sort Key: price_tbl.prccatid" " -> Nested Loop (cost=13.69..479.75 rows=4 width=93) (actual time=444.70..508.81 rows=4 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Nested Loop (cost=13.69..427.04 rows=9 width=81) (actual time=444.60..508.62 rows=4 loops=1)" " Join Filter: ("outer".sctid = "inner".sctid)" " -> Nested Loop (cost=13.69..377.03 rows=8 width=44) (actual time=345.13..398.38 rows=4 loops=1)" " Join Filter: ("outer".sctid = "inner".id)" " -> Hash Join (cost=13.69..327.32 rows=8 width=40) (actual time=219.17..272.27 rows=4 loops=1)" " Hash Cond: ("outer".langid = "inner".id)" " -> Nested Loop (cost=12.61..325.92 rows=42 width=36) (actual time=209.77..262.79 rows=8 loops=1)" " -> Hash Join (cost=12.61..106.32 rows=27 width=28) (actual time=101.88..102.00 rows=4 loops=1)" " Hash Cond: ("outer".cattpid = "inner".id)" " -> Hash Join (cost=9.47..102.68 rows=33 width=16) (actual time=84.14..84.21 rows=4 loops=1)" " Hash Cond: ("outer".subcattpid = "inner".id)" " -> Index Scan using subcat_uq on sct2subcattype_tbl (cost=0.00..92.56 rows=33 width=8) (actual time=83.33..83.37 rows=4 loops=1)" " Index Cond: (subcattpid = 79)" " -> Hash (cost=3.98..3.98 rows=156 width=8) (actual time=0.76..0.76 rows=0 loops=1)" " -> Seq Scan on subcattype_tbl (cost=0.00..3.98 rows=156 width=8) (actual time=0.03..0.49 rows=156 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=3.07..3.07 rows=27 width=12) (actual time=17.58..17.58 rows=0 loops=1)" " -> Hash Join (cost=1.16..3.07 rows=27 width=12) (actual time=17.30..17.52 rows=31 loops=1)" " Hash Cond: ("outer".spcattpid = "inner".id)" " -> Seq Scan on cattype_tbl (cost=0.00..1.41 rows=31 width=8) (actual time=0.02..0.12 rows=31 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=1.14..1.14 rows=10 width=4) (actual time=17.09..17.09 rows=0 loops=1)" " -> Seq Scan on supercattype_tbl (cost=0.00..1.14 rows=10 width=4) (actual time=17.05..17.07 rows=10 loops=1)" " Filter: (enabled = true)" " -> Index Scan using sct2lang_uq on sct2lang_tbl (cost=0.00..8.13 rows=2 width=8) (actual time=26.97..40.18 rows=2 loops=4)" " Index Cond: ("outer".sctid = sct2lang_tbl.sctid)" " -> Hash (cost=1.07..1.07 rows=1 width=4) (actual time=9.04..9.04 rows=0 loops=1)" " -> Seq Scan on language_tbl (cost=0.00..1.07 rows=1 width=4) (actual time=9.02..9.03 rows=1 loops=1)" " Filter: (((sysnm)::text = 'US'::text) AND (enabled = true))" " -> Index Scan using statcontrans_pk on statcontrans_tbl (cost=0.00..5.88 rows=1 width=4) (actual time=31.51..31.52 rows=1 loops=4)" " Index Cond: (statcontrans_tbl.id = "outer".sctid)" " Filter: (enabled = true)" " -> Index Scan using info_uq on info_tbl (cost=0.00..5.93 rows=1 width=37) (actual time=27.54..27.54 rows=1 loops=4)" " Index Cond: ((info_tbl.sctid = "outer".sctid) AND (info_tbl.langid = "outer".langid))" " -> Index Scan using aff_price_uq on price_tbl (cost=0.00..5.88 rows=1 width=12) (actual time=0.03..0.03 rows=1 loops=4)" " Index Cond: ((price_tbl.affid = 8) AND (price_tbl.sctid = "outer".sctid))" " -> Hash (cost=1.06..1.06 rows=4 width=9) (actual time=0.05..0.05 rows=0 loops=1)" " -> Seq Scan on country_tbl (cost=0.00..1.06 rows=4 width=9) (actual time=0.02..0.03 rows=4 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=1.81..1.81 rows=8 width=9) (actual time=11.31..11.31 rows=0 loops=1)" " -> Seq Scan on code_tbl (cost=0.00..1.81 rows=8 width=9) (actual time=11.24..11.29 rows=5 loops=1)" " Filter: ((affid = 8) AND (cdtpid = 1))" " -> Hash (cost=1.09..1.09 rows=7 width=8) (actual time=12.59..12.59 rows=0 loops=1)" " -> Seq Scan on creditscat_tbl (cost=0.00..1.09 rows=7 width=8) (actual time=12.55..12.57 rows=7 loops=1)" " Filter: (enabled = true)" " -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4)" " Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))" "Total runtime: 1299.02 msec" From pgsql-performance-owner@postgresql.org Tue May 3 15:30:15 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DEA26533C1 for ; Tue, 3 May 2005 15:30:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69201-08 for ; Tue, 3 May 2005 18:30:03 +0000 (GMT) Received: from noao.edu (noao.edu [140.252.1.54]) by svr1.postgresql.org (Postfix) with ESMTP id 9B5BE5408B for ; Tue, 3 May 2005 15:30:02 -0300 (ADT) X-TFF-CGPSA-Version: 1.4f1 X-TFF-CGPSA-Filter: Scanned Received: from [140.252.14.8] (HELO weaver.tuc.noao.edu) by noao.edu (CommuniGate Pro SMTP 4.3c5) with ESMTPS id 17999795; Tue, 03 May 2005 11:29:55 -0700 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by weaver.tuc.noao.edu (8.13.1/8.13.1) with ESMTP id j43ITs3V028685; Tue, 3 May 2005 11:29:55 -0700 Message-ID: <4277C322.2010901@noao.edu> Date: Tue, 03 May 2005 11:29:54 -0700 From: Steve Wampler User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: tim@se.linux.org Cc: Christopher Petrilli , pgsql-performance@postgresql.org Subject: Re: batch inserts are "slow" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/23 X-Sequence-Number: 12187 Tim Terleg�rd wrote: >> >>Just as on Oracle you would use SQL*Loader for this application, you >>should use the COPY syntax for PostgreSQL. You will find it a lot >>faster. I have used it by building the input files and executing >>'psql' with a COPY command, and also by using it with a subprocess, >>both are quite effective. > > > I tried this now. Now it's down to 0.45 seconds. It feels a bit hacky to > run /usr/bin/psql from java, but it sure works. Thanks for the hint! There was a patch against 7.4 that provided direct JDBC access to PostgreSQL's COPY. (I have it installed here and *love* it - it gives outstanding performance.) However, it hasn't made into an official release yet. I don't know why, perhaps there's a problem yet to be solved with it ('works for me', though)? Is this still on the board? I won't upgrade past 7.4 without it. -- Steve Wampler -- swampler@noao.edu The gods that smiled on your birth are now laughing out loud. From pgsql-performance-owner@postgresql.org Tue May 3 15:53:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 436AC54092 for ; Tue, 3 May 2005 15:53:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07857-01 for ; Tue, 3 May 2005 18:53:18 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id D33B8539ED for ; Tue, 3 May 2005 15:53:16 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050503185317.YIVQ13846.priv-edtnes56.telusplanet.net@localhost> for ; Tue, 3 May 2005 12:53:17 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 3 May 2005 11:53:17 -0700 Message-ID: <1115146397.4277c89dc37b4@webmail.telus.net> Date: Tue, 3 May 2005 11:53:17 -0700 From: Mischa Sandberg To: pgsql-perform Subject: Re: COPY vs INSERT References: <21154.1115136741@sss.pgh.pa.us> In-Reply-To: <21154.1115136741@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.07 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/24 X-Sequence-Number: 12188 > Steven Rosenstein writes: > > My question is, are there any advantages, drawbacks, or outright > > restrictions to using multiple simultaneous COPY commands to load > data into > > the same table? Do you mean, multiple COPY commands (connections) being putline'd from the same thread (process)? I have indirect evidence that this may hurt. Two copy commands from different threads/processes are fine, and can help, if they alternate contention on some other resource (disk/CPU). I'm basing this on being at the third generation of a COPY implementation. The app loads about 1M objects/hour from 6 servers. Each object is split across four tables. The batch load opens four connections and firehoses records down each. A batch is 10K objects. COPY invokes all the same logic as INSERT on the server side (rowexclusive locking, transaction log, updating indexes, rules). The difference is that all the rows are inserted as a single transaction. This reduces the number of fsync's on the xlog, which may be a limiting factor for you. You'll want to crank WAL_BUFFERS and CHECKPOINT_SEGMENTS to match, though. One of my streams has 6K records; I run with WB=1000, CS=128. The downside I found with multiple clients inserting large blocks of rows was, that they serialized. I THINK that's because at some point they all needed to lock the same portions of the same indexes. I'm still working on how to avoid that, tuning the batch size and inserting into a "queue" table with fewer indexes. COPY (via putline) didn't do measurably better than INSERT until I batched 40 newline-separate rows into one putline call, which improved it 2-3:1. The suspect problem was stalling on the TCP stream; the driver was flushing small packets. This may or may not be relevant to you; depends on how much processing (waiting) your app does between posting of rows. In such a case, writing alternately to two TCP streams from the same process increases the likelihood of a stall. I've never tested that set-up; it would have been heading AWAY from the solution in my case. Hope that helps. -- Engineers think equations approximate reality. Physicists think reality approximates the equations. Mathematicians never make the connection. From pgsql-performance-owner@postgresql.org Tue May 3 16:17:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1046253707 for ; Tue, 3 May 2005 16:17:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69202-05 for ; Tue, 3 May 2005 19:17:19 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.197]) by svr1.postgresql.org (Postfix) with ESMTP id 8B866533C3 for ; Tue, 3 May 2005 16:17:18 -0300 (ADT) Received: by rproxy.gmail.com with SMTP id a41so22126rng for ; Tue, 03 May 2005 12:17:20 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=F8XBdedxne+r66x4oZA5EfpGNztvqBnRrb+Fg2oE4oEeyX5LlZpefGxN8ordDBGUEIl667Z2rBsEpAgIHSuxop8/Iml5LuSpHmk9nDivkZunhB5GvasQXkW3GwVEGUYKCerFeelxO1mdfjXuH1xgjnPJFrOWA2hUh8c/PTTg1io= Received: by 10.38.72.11 with SMTP id u11mr127059rna; Tue, 03 May 2005 12:17:20 -0700 (PDT) Received: by 10.38.207.41 with HTTP; Tue, 3 May 2005 12:17:20 -0700 (PDT) Message-ID: <59d991c4050503121725619c6d@mail.gmail.com> Date: Tue, 3 May 2005 15:17:20 -0400 From: Christopher Petrilli Reply-To: Christopher Petrilli To: tim@se.linux.org Subject: Re: batch inserts are "slow" Cc: pgsql-performance@postgresql.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <59d991c405050208174b6ebbc@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.318 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/25 X-Sequence-Number: 12189 On 5/3/05, Tim Terleg=E5rd wrote: > > Just as on Oracle you would use SQL*Loader for this application, you > > should use the COPY syntax for PostgreSQL. You will find it a lot > > faster. I have used it by building the input files and executing > > 'psql' with a COPY command, and also by using it with a subprocess, > > both are quite effective. >=20 > I tried this now. Now it's down to 0.45 seconds. It feels a bit hacky to > run /usr/bin/psql from java, but it sure works. Thanks for the hint! It may feel hacky, but I think if you want to use SQL*Loader on Oracle, you have to do the same thing. I know a C++ app that I use that runs SQL*Loader about once per second to deal with a HUGE volume (10K/sec). In fact, moving the load files onto ramdisk has helped a lot. Chris --=20 | Christopher Petrilli | petrilli@gmail.com From pgsql-performance-owner@postgresql.org Tue May 3 16:59:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 02981538AA for ; Tue, 3 May 2005 16:59:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08345-08 for ; Tue, 3 May 2005 19:59:04 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id E870153547 for ; Tue, 3 May 2005 16:59:02 -0300 (ADT) Received: (qmail 12896 invoked from network); 3 May 2005 19:57:36 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 3 May 2005 19:57:36 -0000 Message-ID: <4277D803.6060902@fastcrypt.com> Date: Tue, 03 May 2005 15:58:59 -0400 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kris Jurka Cc: Josh Berkus , Markus Schaber , David Parker , Christopher Kings-Lynne , tim@se.linux.org, pgsql-performance@postgresql.org Subject: Re: batch inserts are "slow" References: <07FDEE0ED7455A48AC42AC2070EDFF7C67EF1F@corpsrv2.tazznetworks.com> <42778D6E.4030401@logix-tt.com> <200505030841.44159.josh@agliodbs.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.026 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/26 X-Sequence-Number: 12190 Kris is correct, This code was not added or even submitted to CVS. The purpose of this was to work out the bugs with people who are actually using copy. The api is a separate issue however. There's no reason that copy can't support more than one api. Dave Kris Jurka wrote: >On Tue, 3 May 2005, Josh Berkus wrote: > > > >>>There are several hacks floating around that add COPY capabilities to >>>the pgjdbc driver. As they all are rather simple hacks, they have not >>>been included in the cvs yet, but they tend to work fine. >>> >>> >>FWIW, Dave Cramer just added beta COPY capability to JDBC. Contact him on >>the JDBC list for details; I think he needs testers. >> >> >> > >I believe Dave has remerged a patch for COPY I posted over a year ago, but >he has not yet published it. I would guess it has the same bugs as the >original (transaction + error handling) and will meet the same objections >that kept the original patch out of the driver in the first place (we want >a friendlier API than just a data stream). > >Kris Jurka > >---------------------------(end of broadcast)--------------------------- >TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > > > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 From pgsql-hackers-owner@postgresql.org Tue May 3 18:33:18 2005 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EDFC553406; Tue, 3 May 2005 18:33:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03749-05; Tue, 3 May 2005 21:33:11 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 45B1E5322A; Tue, 3 May 2005 18:33:09 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050503213311.KSVN13846.priv-edtnes56.telusplanet.net@localhost>; Tue, 3 May 2005 15:33:11 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 3 May 2005 14:33:10 -0700 Message-ID: <1115155990.4277ee16aba34@webmail.telus.net> Date: Tue, 3 May 2005 14:33:10 -0700 From: Mischa Sandberg To: Markus Schaber Cc: pgsql-perform , pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Bad n_distinct estimation; hacks suggested? References: <200504191209.05181.josh@agliodbs.com> <1114580284.426f253cc0087@webmail.telus.net> <426F9703.4010108@dunslane.net> <200504270825.17550.josh@agliodbs.com> <4277774F.7040205@logix-tt.com> In-Reply-To: <4277774F.7040205@logix-tt.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.071 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/254 X-Sequence-Number: 67130 Quoting Markus Schaber : > Hi, Josh, > > Josh Berkus wrote: > > > Yes, actually. We need 3 different estimation methods: > > 1 for tables where we can sample a large % of pages (say, >= 0.1) > > 1 for tables where we sample a small % of pages but are "easily > estimated" > > 1 for tables which are not easily estimated by we can't afford to > sample a > > large % of pages. > > > > If we're doing sampling-based estimation, I really don't want > people to lose > > sight of the fact that page-based random sampling is much less > expensive than > > row-based random sampling. We should really be focusing on > methods which > > are page-based. Okay, although given the track record of page-based sampling for n-distinct, it's a bit like looking for your keys under the streetlight, rather than in the alley where you dropped them :-) How about applying the distinct-sampling filter on a small extra data stream to the stats collector? -- Engineers think equations approximate reality. Physicists think reality approximates the equations. Mathematicians never make the connection. From pgsql-hackers-owner@postgresql.org Tue May 3 18:42:36 2005 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2BB1653635; Tue, 3 May 2005 18:42:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05399-01; Tue, 3 May 2005 21:42:34 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 691F453601; Tue, 3 May 2005 18:42:33 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7316960; Tue, 03 May 2005 14:44:35 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Mischa Sandberg Subject: Re: [PERFORM] Bad n_distinct estimation; hacks suggested? Date: Tue, 3 May 2005 14:43:44 -0700 User-Agent: KMail/1.7.1 Cc: Markus Schaber , pgsql-perform , pgsql-hackers@postgresql.org References: <200504191209.05181.josh@agliodbs.com> <4277774F.7040205@logix-tt.com> <1115155990.4277ee16aba34@webmail.telus.net> In-Reply-To: <1115155990.4277ee16aba34@webmail.telus.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505031443.44859.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.047 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/256 X-Sequence-Number: 67132 Mischa, > Okay, although given the track record of page-based sampling for > n-distinct, it's a bit like looking for your keys under the streetlight, > rather than in the alley where you dropped them :-) Bad analogy, but funny. The issue with page-based vs. pure random sampling is that to do, for example, 10% of rows purely randomly would actually mean loading 50% of pages. With 20% of rows, you might as well scan the whole table. Unless, of course, we use indexes for sampling, which seems like a *really good* idea to me .... -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-hackers-owner@postgresql.org Wed May 4 10:30:07 2005 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1FF7752A6B; Tue, 3 May 2005 21:45:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45468-01; Wed, 4 May 2005 00:45:26 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 0749054225; Tue, 3 May 2005 21:45:23 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j440jMvF005033; (envelope-from ) Tue, 3 May 2005 19:45:22 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j440jILb006109 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 3 May 2005 19:45:19 -0500 (CDT) Message-ID: <42781B1D.7070101@arbash-meinel.com> Date: Tue, 03 May 2005 19:45:17 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: Mischa Sandberg , Markus Schaber , pgsql-perform , pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Bad n_distinct estimation; hacks suggested? References: <200504191209.05181.josh@agliodbs.com> <4277774F.7040205@logix-tt.com> <1115155990.4277ee16aba34@webmail.telus.net> <200505031443.44859.josh@agliodbs.com> In-Reply-To: <200505031443.44859.josh@agliodbs.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig218E20F1D20FF38DF2FF840B" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/301 X-Sequence-Number: 67177 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig218E20F1D20FF38DF2FF840B Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Josh Berkus wrote: > Mischa, > > >>Okay, although given the track record of page-based sampling for >>n-distinct, it's a bit like looking for your keys under the streetlight, >>rather than in the alley where you dropped them :-) > > > Bad analogy, but funny. > > The issue with page-based vs. pure random sampling is that to do, for example, > 10% of rows purely randomly would actually mean loading 50% of pages. With > 20% of rows, you might as well scan the whole table. > > Unless, of course, we use indexes for sampling, which seems like a *really > good* idea to me .... > But doesn't an index only sample one column at a time, whereas with page-based sampling, you can sample all of the columns at once. And not all columns would have indexes, though it could be assumed that if a column doesn't have an index, then it doesn't matter as much for calculations such as n_distinct. But if you had 5 indexed rows in your table, then doing it index wise means you would have to make 5 passes instead of just one. Though I agree that page-based sampling is important for performance reasons. John =:-> --------------enig218E20F1D20FF38DF2FF840B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCeBsdJdeBCYSNAAMRAu9UAKDDdD+Gc/SgZXjTo15SPIUtklrYZgCfd3VR 4o/cdrYTBR9vdo3fekGjZns= =dsMV -----END PGP SIGNATURE----- --------------enig218E20F1D20FF38DF2FF840B-- From pgsql-hackers-owner@postgresql.org Tue May 3 21:51:51 2005 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 321F45381D; Tue, 3 May 2005 21:51:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45468-05; Wed, 4 May 2005 00:51:48 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 9D4A5533FC; Tue, 3 May 2005 21:51:48 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7317551; Tue, 03 May 2005 17:53:51 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: John A Meinel Subject: Re: [PERFORM] Bad n_distinct estimation; hacks suggested? Date: Tue, 3 May 2005 17:52:54 -0700 User-Agent: KMail/1.7.1 Cc: Mischa Sandberg , Markus Schaber , pgsql-perform , pgsql-hackers@postgresql.org References: <200504191209.05181.josh@agliodbs.com> <200505031443.44859.josh@agliodbs.com> <42781B1D.7070101@arbash-meinel.com> In-Reply-To: <42781B1D.7070101@arbash-meinel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505031752.54293.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.047 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/264 X-Sequence-Number: 67140 John, > But doesn't an index only sample one column at a time, whereas with > page-based sampling, you can sample all of the columns at once. Hmmm. Yeah, we're not currently doing that though. Another good idea ... -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue May 3 22:13:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C7F505364C for ; Tue, 3 May 2005 22:13:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49195-05 for ; Wed, 4 May 2005 01:13:10 +0000 (GMT) Received: from hummer.onthenet.com.au (hummer.OntheNet.com.au [203.13.68.9]) by svr1.postgresql.org (Postfix) with ESMTP id C7F5153601 for ; Tue, 3 May 2005 22:13:09 -0300 (ADT) Received: from [192.168.2.26] (imp5.dsl.onthenet.net [203.144.16.135]) by hummer.onthenet.com.au (Postfix) with ESMTP id D997119FCA1 for ; Wed, 4 May 2005 11:13:10 +1000 (EST) Received: from 127.0.0.1 (AVG SMTP 7.0.308 [266.11.2]); Wed, 04 May 2005 11:12:52 +1000 Message-ID: <42782194.7040500@wildcash.com> Date: Wed, 04 May 2005 11:12:52 +1000 From: Chris Hebrard User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en To: pgsql-performance@postgresql.org Subject: Kernel Resources and max_connections X-Enigmail-Version: 0.89.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/31 X-Sequence-Number: 12195 Hi, I have postgres 8.0.2 installed on FreeBSD FreeBSD 4.11-RELEASE with 2GB of RAM. When trying to set max_connections=256 I get the following error message: FATAL: could not create semaphores: No space left on device DETAIL: Failed system call was semget(5432017, 17, 03600). HINT: This error does *not* mean that you have run out of disk space. It occurs when either the system limit for the maximum number of semaphore sets (SEMMNI), or the system wide maximum number of semaphores (SEMMNS), would be exceeded. You need to raise the respective kernel parameter. Alternatively, reduce PostgreSQL's consumption of semaphores by reducing its max_connections parameter (currently 256). The PostgreSQL documentation contains more information about configuring your system for PostgreSQL. I have read through the kernel resources documentation for postgres 8 and set values accordingly. Some settings are not staying after a reboot, even if I place them in /boot/loader.conf. So far I'm able to get max_connections to 250. Here is a dump of kern.ipc values: kern.ipc.maxsockbuf: 262144 kern.ipc.sockbuf_waste_factor: 8 kern.ipc.somaxconn: 128 kern.ipc.max_linkhdr: 16 kern.ipc.max_protohdr: 60 kern.ipc.max_hdr: 76 kern.ipc.max_datalen: 136 kern.ipc.nmbclusters: 65536 kern.ipc.msgmax: 16384 kern.ipc.msgmni: 40 kern.ipc.msgmnb: 2048 kern.ipc.msgtql: 40 kern.ipc.msgssz: 8 kern.ipc.msgseg: 2048 kern.ipc.semmap: 30 kern.ipc.semmni: 256 kern.ipc.semmns: 272 kern.ipc.semmnu: 30 kern.ipc.semmsl: 60 kern.ipc.semopm: 100 kern.ipc.semume: 10 kern.ipc.semusz: 92 kern.ipc.semvmx: 32767 kern.ipc.semaem: 16384 kern.ipc.shmmax: 33554432 kern.ipc.shmmin: 1 kern.ipc.shmmni: 192 kern.ipc.shmseg: 128 kern.ipc.shmall: 8192 kern.ipc.shm_use_phys: 0 kern.ipc.shm_allow_removed: 0 kern.ipc.mbuf_wait: 32 kern.ipc.mbtypes: 38 551 3 0 0 0 0 0 0 0 0 0 0 0 0 0 kern.ipc.nmbufs: 262144 kern.ipc.nsfbufs: 8704 kern.ipc.nsfbufspeak: 7 kern.ipc.nsfbufsused: 0 kern.ipc.m_clreflimithits: 0 kern.ipc.mcl_pool_max: 0 kern.ipc.mcl_pool_now: 0 kern.ipc.maxsockets: 65536 And boot/loader.conf: userconfig_script_load="YES" kern.ipc.nmbclusters="65536" kern.maxfiles="65536" kern.maxfilesperproc="65536" net.inet.tcp.mssdflt="1460" kern.somaxconn="4096" kern.ipc.semmns="272" kern.ipc.semmni="256" kern.ipc.shmmax="66099200" kern.ipc.shmmax and kern.ipc.shmmin will not stay to what I set them to. What am I doing wrong or not doing at all? Your help is greatly appreciated. Regards, Chris. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 5/2/2005 From pgsql-performance-owner@postgresql.org Tue May 3 22:46:36 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0737D537D4 for ; Tue, 3 May 2005 22:46:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53706-04 for ; Wed, 4 May 2005 01:46:33 +0000 (GMT) Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz [202.0.58.22]) by svr1.postgresql.org (Postfix) with ESMTP id 9C86653765 for ; Tue, 3 May 2005 22:46:32 -0300 (ADT) Received: from smtp-2.paradise.net.nz (smtp-2b.paradise.net.nz [202.0.32.211]) by linda-3.paradise.net.nz (Paradise.net.nz) with ESMTP id <0IFX00L8WZLNJ7@linda-3.paradise.net.nz> for pgsql-performance@postgresql.org; Wed, 04 May 2005 13:46:36 +1200 (NZST) Received: from [192.168.1.11] (218-101-45-163.paradise.net.nz [218.101.45.163]) by smtp-2.paradise.net.nz (Postfix) with ESMTP id 699199E277; Wed, 04 May 2005 13:46:35 +1200 (NZST) Date: Wed, 04 May 2005 13:46:34 +1200 From: Mark Kirkwood Subject: Re: Kernel Resources and max_connections In-reply-to: <42782194.7040500@wildcash.com> To: Chris Hebrard Cc: pgsql-performance@postgresql.org Message-id: <4278297A.1010703@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8b) Gecko/20050301 References: <42782194.7040500@wildcash.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.145 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/32 X-Sequence-Number: 12196 Chris Hebrard wrote: > kern.ipc.shmmax and kern.ipc.shmmin will not stay to what I set them to. > > What am I doing wrong or not doing at all? > These need to go in /etc/sysctl.conf. You might need to set shmall as well. (This not-very-clear distinction between what is sysctl'abe and what is a kernel tunable is a bit of a downer). cheers Mark From pgsql-performance-owner@postgresql.org Tue May 3 23:04:45 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5FC9D53797 for ; Tue, 3 May 2005 23:04:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57110-09 for ; Wed, 4 May 2005 02:04:37 +0000 (GMT) Received: from hummer.onthenet.com.au (hummer.OntheNet.com.au [203.13.68.9]) by svr1.postgresql.org (Postfix) with ESMTP id 31C0C536F8 for ; Tue, 3 May 2005 23:04:36 -0300 (ADT) Received: from [192.168.2.26] (imp5.dsl.onthenet.net [203.144.16.135]) by hummer.onthenet.com.au (Postfix) with ESMTP id 1554019FB11 for ; Wed, 4 May 2005 12:04:40 +1000 (EST) Received: from 127.0.0.1 (AVG SMTP 7.0.308 [266.11.2]); Wed, 04 May 2005 12:04:21 +1000 Message-ID: <42782DA5.70701@wildcash.com> Date: Wed, 04 May 2005 12:04:21 +1000 From: Chris Hebrard User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en To: pgsql-performance@postgresql.org Subject: Re: Kernel Resources and max_connections References: <42782194.7040500@wildcash.com> <4278297A.1010703@paradise.net.nz> In-Reply-To: <4278297A.1010703@paradise.net.nz> X-Enigmail-Version: 0.89.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/33 X-Sequence-Number: 12197 Mark Kirkwood wrote: > Chris Hebrard wrote: > >> kern.ipc.shmmax and kern.ipc.shmmin will not stay to what I set them to. >> >> What am I doing wrong or not doing at all? >> > > These need to go in /etc/sysctl.conf. You might need to set shmall as > well. > > (This not-very-clear distinction between what is sysctl'abe and what > is a kernel tunable is a bit of a downer). > > cheers > > Mark > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > Thanks for your reply, I set the values in etc/sysctl.conf: # $FreeBSD: src/etc/sysctl.conf,v 1.1.2.3 2002/04/15 00:44:13 dougb Exp $ # # This file is read when going to multi-user and its contents piped thru # ``sysctl'' to adjust kernel values. ``man 5 sysctl.conf'' for details. # # Added by IMP 2005-05-04 net.inet.tcp.rfc1323=1 kern.ipc.somaxconn=1024 kern.ipc.maxsockbuf=8388608 net.inet.tcp.sendspace=3217968 net.inet.tcp.recvspace=3217968 kern.ipc.semmns="272" kern.ipc.semmni="256" kern.ipc.shmmax="66099200" kern.ipc.shmmin="256" After a restart both shmmax and shmmin are now 0 and postgres failed to start. kern.ipc.maxsockbuf: 8388608 kern.ipc.sockbuf_waste_factor: 8 kern.ipc.somaxconn: 1024 kern.ipc.max_linkhdr: 16 kern.ipc.max_protohdr: 60 kern.ipc.max_hdr: 76 kern.ipc.max_datalen: 136 kern.ipc.nmbclusters: 65536 kern.ipc.msgmax: 16384 kern.ipc.msgmni: 40 kern.ipc.msgmnb: 2048 kern.ipc.msgtql: 40 kern.ipc.msgssz: 8 kern.ipc.msgseg: 2048 kern.ipc.semmap: 30 kern.ipc.semmni: 10 kern.ipc.semmns: 60 kern.ipc.semmnu: 30 kern.ipc.semmsl: 60 kern.ipc.semopm: 100 kern.ipc.semume: 10 kern.ipc.semusz: 92 kern.ipc.semvmx: 32767 kern.ipc.semaem: 16384 kern.ipc.shmmax: 0 kern.ipc.shmmin: 0 kern.ipc.shmmni: 192 kern.ipc.shmseg: 128 kern.ipc.shmall: 8192 kern.ipc.shm_use_phys: 0 kern.ipc.shm_allow_removed: 0 kern.ipc.mbuf_wait: 32 kern.ipc.mbtypes: 24 550 2 0 0 0 0 0 0 0 0 0 0 0 0 0 kern.ipc.nmbufs: 262144 kern.ipc.nsfbufs: 8704 kern.ipc.nsfbufspeak: 0 kern.ipc.nsfbufsused: 0 kern.ipc.m_clreflimithits: 0 kern.ipc.mcl_pool_max: 0 kern.ipc.mcl_pool_now: 0 kern.ipc.maxsockets: 65536 I'm lost here. Chris. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 5/2/2005 From pgsql-performance-owner@postgresql.org Tue May 3 23:40:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 41F3653873 for ; Tue, 3 May 2005 23:40:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61397-07 for ; Wed, 4 May 2005 02:40:26 +0000 (GMT) Received: from hummer.onthenet.com.au (hummer.OntheNet.com.au [203.13.68.9]) by svr1.postgresql.org (Postfix) with ESMTP id E8BCE535C2 for ; Tue, 3 May 2005 23:40:24 -0300 (ADT) Received: from [192.168.2.26] (imp5.dsl.onthenet.net [203.144.16.135]) by hummer.onthenet.com.au (Postfix) with ESMTP id 75B6F19FB68 for ; Wed, 4 May 2005 12:40:28 +1000 (EST) Received: from 127.0.0.1 (AVG SMTP 7.0.308 [266.11.2]); Wed, 04 May 2005 12:40:10 +1000 Message-ID: <4278360A.9050501@wildcash.com> Date: Wed, 04 May 2005 12:40:10 +1000 From: Chris Hebrard User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en To: pgsql-performance@postgresql.org Subject: Kernel Resources Solved X-Enigmail-Version: 0.89.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/34 X-Sequence-Number: 12198 Problem sovled by setting: kern.ipc.semmni: 280 kern.ipc.semmns: 300 Chris. > Mark Kirkwood wrote: > >> Chris Hebrard wrote: >> >>> kern.ipc.shmmax and kern.ipc.shmmin will not stay to what I set them >>> to. >>> >>> What am I doing wrong or not doing at all? >>> >> >> These need to go in /etc/sysctl.conf. You might need to set shmall as >> well. >> >> (This not-very-clear distinction between what is sysctl'abe and what >> is a kernel tunable is a bit of a downer). >> >> cheers >> >> Mark >> >> >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >> >> >> >> kern.ipc.maxsockbuf: 8388608 >> kern.ipc.sockbuf_waste_factor: 8 >> kern.ipc.somaxconn: 1024 >> kern.ipc.max_linkhdr: 16 >> kern.ipc.max_protohdr: 60 >> kern.ipc.max_hdr: 76 >> kern.ipc.max_datalen: 136 >> kern.ipc.nmbclusters: 65536 >> kern.ipc.msgmax: 16384 >> kern.ipc.msgmni: 40 >> kern.ipc.msgmnb: 2048 >> kern.ipc.msgtql: 40 >> kern.ipc.msgssz: 8 >> kern.ipc.msgseg: 2048 >> kern.ipc.semmap: 30 >> kern.ipc.semmni: 256 >> kern.ipc.semmns: 272 >> kern.ipc.semmnu: 30 >> kern.ipc.semmsl: 60 >> kern.ipc.semopm: 100 >> kern.ipc.semume: 10 >> kern.ipc.semusz: 92 >> kern.ipc.semvmx: 32767 >> kern.ipc.semaem: 16384 >> kern.ipc.shmmax: 66099200 >> kern.ipc.shmmin: 256 >> kern.ipc.shmmni: 192 >> kern.ipc.shmseg: 128 >> kern.ipc.shmall: 8192 >> kern.ipc.shm_use_phys: 0 >> kern.ipc.shm_allow_removed: 0 >> kern.ipc.mbuf_wait: 32 >> kern.ipc.mbtypes: 37 552 3 0 0 0 0 0 0 0 0 0 0 0 0 0 >> kern.ipc.nmbufs: 262144 >> kern.ipc.nsfbufs: 8704 >> kern.ipc.nsfbufspeak: 4 >> kern.ipc.nsfbufsused: 0 >> kern.ipc.m_clreflimithits: 0 >> kern.ipc.mcl_pool_max: 0 >> kern.ipc.mcl_pool_now: 0 >> kern.ipc.maxsockets: 65536 > > > I've got the values to what I want them to be now, after loading some > values in loader.conf and others in sysctl.conf. > > loader.conf: > > userconfig_script_load="YES" > kern.ipc.nmbclusters="65536" > kern.maxfiles="65536" > kern.maxfilesperproc="65536" > net.inet.tcp.mssdflt="1460" > kern.somaxconn="4096" > kern.ipc.semmns="272" > kern.ipc.semmni="256" > > sysctl.conf: > > net.inet.tcp.rfc1323=1 > kern.ipc.somaxconn=1024 > kern.ipc.maxsockbuf=8388608 > net.inet.tcp.sendspace=3217968 > net.inet.tcp.recvspace=3217968 > kern.ipc.shmmax=66099200 > kern.ipc.shmmin=256 > kern.ipc.shmall=16138 > > and kern.ipc values are now: > kern.ipc.maxsockbuf: 8388608 > kern.ipc.sockbuf_waste_factor: 8 > kern.ipc.somaxconn: 1024 > kern.ipc.max_linkhdr: 16 > kern.ipc.max_protohdr: 60 > kern.ipc.max_hdr: 76 > kern.ipc.max_datalen: 136 > kern.ipc.nmbclusters: 65536 > kern.ipc.msgmax: 16384 > kern.ipc.msgmni: 40 > kern.ipc.msgmnb: 2048 > kern.ipc.msgtql: 40 > kern.ipc.msgssz: 8 > kern.ipc.msgseg: 2048 > kern.ipc.semmap: 30 > kern.ipc.semmni: 256 > kern.ipc.semmns: 272 > kern.ipc.semmnu: 30 > kern.ipc.semmsl: 60 > kern.ipc.semopm: 100 > kern.ipc.semume: 10 > kern.ipc.semusz: 92 > kern.ipc.semvmx: 32767 > kern.ipc.semaem: 16384 > kern.ipc.shmmax: 66099200 > kern.ipc.shmmin: 256 > kern.ipc.shmmni: 192 > kern.ipc.shmseg: 128 > kern.ipc.shmall: 16138 > kern.ipc.shm_use_phys: 0 > kern.ipc.shm_allow_removed: 0 > kern.ipc.mbuf_wait: 32 > kern.ipc.mbtypes: 7 550 3 0 0 0 0 0 0 0 0 0 0 0 0 0 > kern.ipc.nmbufs: 262144 > kern.ipc.nsfbufs: 8704 > kern.ipc.nsfbufspeak: 6 > kern.ipc.nsfbufsused: 0 > kern.ipc.m_clreflimithits: 0 > kern.ipc.mcl_pool_max: 0 > kern.ipc.mcl_pool_now: 0 > kern.ipc.maxsockets: 65536 > > > Postgres still refuses to start with 256 max_connections. > > Chris. > > > > -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.11.2 - Release Date: 5/2/2005 From pgsql-hackers-owner@postgresql.org Tue May 3 23:52:24 2005 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1C1755375F; Tue, 3 May 2005 23:52:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62434-09; Wed, 4 May 2005 02:52:13 +0000 (GMT) Received: from priv-edtnes51.telusplanet.net (outbound04.telus.net [199.185.220.223]) by svr1.postgresql.org (Postfix) with ESMTP id 1308053726; Tue, 3 May 2005 23:52:12 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes51.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050504025216.HOTO13643.priv-edtnes51.telusplanet.net@localhost>; Tue, 3 May 2005 20:52:16 -0600 Received: from 64.180.225.200 ( [64.180.225.200]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Tue, 3 May 2005 19:52:16 -0700 Message-ID: <1115175136.427838e0ae263@webmail.telus.net> Date: Tue, 3 May 2005 19:52:16 -0700 From: Mischa Sandberg To: pgsql-perform , pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Bad n_distinct estimation; hacks suggested? References: <200504191209.05181.josh@agliodbs.com> <4277774F.7040205@logix-tt.com> <1115155990.4277ee16aba34@webmail.telus.net> <200505031443.44859.josh@agliodbs.com> In-Reply-To: <200505031443.44859.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 64.180.225.200 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.067 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/270 X-Sequence-Number: 67146 Quoting Josh Berkus : > Mischa, > > > Okay, although given the track record of page-based sampling for > > n-distinct, it's a bit like looking for your keys under the > streetlight, > > rather than in the alley where you dropped them :-) > > Bad analogy, but funny. Bad analogy? Page-sampling effort versus row-sampling effort, c'est moot. It's not good enough for stats to produce good behaviour on the average. Straight random sampling, page or row, is going to cause enough untrustworthy engine behaviour,for any %ages small enough to allow sampling from scratch at any time. I'm curious what the problem is with relying on a start-up plus incremental method, when the method in the distinct-sampling paper doesn't degenerate: you can start when the table is still empty. Constructing an index requires an initial full scan plus incremental update; what's the diff? > Unless, of course, we use indexes for sampling, which seems like a > *really > good* idea to me .... "distinct-sampling" applies for indexes, too. I started tracking the discussion of this a bit late. Smart method for this is in VLDB'92: Gennady Antoshenkov, "Random Sampling from Pseudo-ranked B+-trees". I don't think this is online anywhere, except if you have a DBLP membership. Does nybod else know better? Antoshenkov was the brains behind some of the really cool stuff in DEC Rdb (what eventually became Oracle). Compressed bitmap indices, parallel competing query plans, and smart handling of keys with hyperbolic distributions. -- Engineers think equations approximate reality. Physicists think reality approximates the equations. Mathematicians never make the connection. From pgsql-performance-owner@postgresql.org Wed May 4 01:07:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2B2CB53338 for ; Wed, 4 May 2005 01:07:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75539-08 for ; Wed, 4 May 2005 04:07:20 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 281C05331E for ; Wed, 4 May 2005 01:07:19 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id A6197152B4; Tue, 3 May 2005 23:07:18 -0500 (CDT) Date: Tue, 3 May 2005 23:07:18 -0500 From: "Jim C. Nasby" To: Mark Kirkwood Cc: Chris Hebrard , pgsql-performance@postgresql.org Subject: Re: Kernel Resources and max_connections Message-ID: <20050504040718.GU47820@decibel.org> References: <42782194.7040500@wildcash.com> <4278297A.1010703@paradise.net.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4278297A.1010703@paradise.net.nz> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/36 X-Sequence-Number: 12200 On Wed, May 04, 2005 at 01:46:34PM +1200, Mark Kirkwood wrote: > (This not-very-clear distinction between what is sysctl'abe and what is > a kernel tunable is a bit of a downer). I think this is documented somewhere, though I can't think of where right now. Also, note that some sysctl's can only be set in /boot/loader.conf. hw.ata.wc=0 is an example (which you want to set on any box with IDE drives if you want fsync to actually do what it thinks it's doing). -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed May 4 02:17:38 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3E0375374B for ; Wed, 4 May 2005 02:17:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86790-03 for ; Wed, 4 May 2005 05:17:29 +0000 (GMT) Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [202.0.58.20]) by svr1.postgresql.org (Postfix) with ESMTP id 38CCC52A43 for ; Wed, 4 May 2005 02:17:26 -0300 (ADT) Received: from smtp-3.paradise.net.nz (smtp-3b.paradise.net.nz [202.0.32.212]) by linda-1.paradise.net.nz (Paradise.net.nz) with ESMTP id <0IFY00EP49CL26@linda-1.paradise.net.nz> for pgsql-performance@postgresql.org; Wed, 04 May 2005 17:17:13 +1200 (NZST) Received: from [192.168.1.11] (218-101-13-88.paradise.net.nz [218.101.13.88]) by smtp-3.paradise.net.nz (Postfix) with ESMTP id E01FEAE5FF; Wed, 04 May 2005 17:16:56 +1200 (NZST) Date: Wed, 04 May 2005 17:16:36 +1200 From: Mark Kirkwood Subject: Re: Kernel Resources and max_connections In-reply-to: <42782DA5.70701@wildcash.com> To: Chris Hebrard Cc: pgsql-performance@postgresql.org Message-id: <42785AB4.5080206@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8b) Gecko/20050301 References: <42782194.7040500@wildcash.com> <4278297A.1010703@paradise.net.nz> <42782DA5.70701@wildcash.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.138 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/37 X-Sequence-Number: 12201 Chris Hebrard wrote: > > I set the values in etc/sysctl.conf: > > # $FreeBSD: src/etc/sysctl.conf,v 1.1.2.3 2002/04/15 00:44:13 dougb Exp $ > # > # This file is read when going to multi-user and its contents piped thru > # ``sysctl'' to adjust kernel values. ``man 5 sysctl.conf'' for details. > # > # Added by IMP 2005-05-04 > net.inet.tcp.rfc1323=1 > kern.ipc.somaxconn=1024 > kern.ipc.maxsockbuf=8388608 > net.inet.tcp.sendspace=3217968 > net.inet.tcp.recvspace=3217968 > kern.ipc.semmns="272" > kern.ipc.semmni="256" > kern.ipc.shmmax="66099200" > kern.ipc.shmmin="256" > > > After a restart both shmmax and shmmin are now 0 and postgres failed to > start. > > Hmmm - puzzling. One point to check, did you take them out of /boot/loader.conf ? Assuming so, maybe don't quote 'em (see below). Finally you need to to set shmall, otherwise it will over(under)ride the shmmax setting. So try: net.inet.tcp.rfc1323=1 kern.ipc.somaxconn=1024 kern.ipc.maxsockbuf=8388608 net.inet.tcp.sendspace=3217968 net.inet.tcp.recvspace=3217968 kern.ipc.semmns=272 kern.ipc.semmni=256 kern.ipc.shmmax=66099200 kern.ipc.shmmin=256 kern.ipc.shmall=32768 From pgsql-performance-owner@postgresql.org Wed May 4 08:09:05 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 370B25381E for ; Wed, 4 May 2005 08:08:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31465-07 for ; Wed, 4 May 2005 11:08:44 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.205]) by svr1.postgresql.org (Postfix) with ESMTP id 45A735322A for ; Wed, 4 May 2005 08:08:43 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so238990wra for ; Wed, 04 May 2005 04:08:47 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=l6vw5U17ABPiHQzjdCnZwS4RKjEK7Xc7s5iiH46PZTqe5ATI4+Gq3LtNLpiePXgN52Q94paP3SOfhFNja0Btax5nrQXD8b7Y/2sGI8f3k1W68l4CR6GUszqF3X//4XecwTkHd1jNWMfXSShoI/0+r15Q7rp/BD4nGdxhze47U1M= Received: by 10.54.54.73 with SMTP id c73mr125777wra; Wed, 04 May 2005 04:08:47 -0700 (PDT) Received: by 10.54.150.14 with HTTP; Wed, 4 May 2005 04:08:46 -0700 (PDT) Message-ID: Date: Wed, 4 May 2005 11:08:46 +0000 From: Mike Rylander Reply-To: Mike Rylander To: Tom Lane Subject: Re: Cc: Steven Rosenstein , pgsql-perform In-Reply-To: <21154.1115136741@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <21154.1115136741@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.255 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/38 X-Sequence-Number: 12202 On 5/3/05, Tom Lane wrote: > Steven Rosenstein writes: > > My question is, are there any advantages, drawbacks, or outright > > restrictions to using multiple simultaneous COPY commands to load data = into > > the same table? >=20 > It will work; not sure about whether there is any performance benefit. > I vaguely recall someone having posted about doing this, so you might > check the archives. >=20 I may be one of Tom's vague "voices". ;) The only issue would be that you need to remove all you UNIQUE constraints before sending multiple COPYs to the server. This includes the PRIMARY KEY constraint. To the backend, COPY is just like INSERT and all constraints need to be checked and this will block the commit of one of the COPY streams. However, multiple COPYs may no be needed. I regularly load several table totaling around 50M rows with a single COPY per table. I drop (actually, this is during DB reload, so I don't yet create...) all fkeys, constraints and indexes and the data loads in a matter of 5 minutes or so. Hope that helps! --=20 Mike Rylander mrylander@gmail.com GPLS -- PINES Development Database Developer http://open-ils.org From pgsql-performance-owner@postgresql.org Wed May 4 11:58:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 96705549AE for ; Wed, 4 May 2005 11:58:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71837-06 for ; Wed, 4 May 2005 14:58:31 +0000 (GMT) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by svr1.postgresql.org (Postfix) with ESMTP id 5715453653 for ; Wed, 4 May 2005 11:58:27 -0300 (ADT) Received: from localhost.localdomain (c-67-167-246-79.hsd1.il.comcast.net[67.167.246.79]) by comcast.net (rwcrmhc11) with ESMTP id <2005050414582801300favo4e>; Wed, 4 May 2005 14:58:28 +0000 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.11/8.12.11) with ESMTP id j44EwQmD027013 for ; Wed, 4 May 2005 09:58:26 -0500 Received: (from spike@localhost) by localhost.localdomain (8.12.11/8.12.11/Submit) id j44EwPEk027012 for pgsql-performance@postgresql.org; Wed, 4 May 2005 09:58:25 -0500 X-Authentication-Warning: localhost.localdomain: spike set sender to mike@thegodshalls.com using -f Date: Wed, 4 May 2005 09:58:25 -0500 From: "Mike G." To: pgsql-performance@postgresql.org Subject: Table stats Message-ID: <20050504145825.GA26993@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Virus-Scanned: ClamAV 0.80/748/Fri Mar 4 16:19:11 2005 clamav-milter version 0.80j on localhost X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.053 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/39 X-Sequence-Number: 12203 Hello, I have a table collecting stats that shows 5 Index Tuples Fetched but no Index Scans. Should there not be at least one Index Scan showing in the stats? Mike From pgsql-performance-owner@postgresql.org Wed May 4 19:41:47 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 986A55372D for ; Wed, 4 May 2005 19:41:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29018-08 for ; Wed, 4 May 2005 22:41:38 +0000 (GMT) Received: from out2.smtp.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by svr1.postgresql.org (Postfix) with ESMTP id E6488535EF for ; Wed, 4 May 2005 19:41:36 -0300 (ADT) Received: from web2.messagingengine.com (web2.internal [10.202.2.211]) by frontend1.messagingengine.com (Postfix) with ESMTP id E82F1C89C07; Wed, 4 May 2005 18:41:38 -0400 (EDT) Received: by web2.messagingengine.com (Postfix, from userid 99) id 0A3073657; Wed, 4 May 2005 18:41:30 -0400 (EDT) Message-Id: <1115246490.1709.233393619@webmail.messagingengine.com> X-Sasl-Enc: OtoNTuGhbhgq/6iTxxqGceWlq/NRzJSDfjE6VLCsAAxr 1115246490 From: "David Roussel" To: "Mischa Sandberg" , "pgsql-perform" Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1" MIME-Version: 1.0 X-Mailer: MIME::Lite 1.5 (F2.73; T1.001; A1.64; B3.05; Q3.03) References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> Subject: Re: COPY vs INSERT In-Reply-To: <1115146397.4277c89dc37b4@webmail.telus.net> Date: Wed, 04 May 2005 23:41:30 +0100 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/40 X-Sequence-Number: 12204 > COPY invokes all the same logic as INSERT on the server side > (rowexclusive locking, transaction log, updating indexes, rules). > The difference is that all the rows are inserted as a single > transaction. This reduces the number of fsync's on the xlog, > which may be a limiting factor for you. You'll want to crank > WAL_BUFFERS and CHECKPOINT_SEGMENTS to match, though. > One of my streams has 6K records; I run with WB=1000, CS=128. So what's the difference between a COPY and a batch of INSERT statements. Also, surely, fsyncs only occur at the end of a transaction, no need to fsync before a commit has been issued, right? David From pgsql-performance-owner@postgresql.org Wed May 4 20:11:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E990954831 for ; Wed, 4 May 2005 20:11:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34135-02 for ; Wed, 4 May 2005 23:11:31 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id F062553C70 for ; Wed, 4 May 2005 20:11:29 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050504231132.UNMM13983.priv-edtnes56.telusplanet.net@localhost> for ; Wed, 4 May 2005 17:11:32 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Wed, 4 May 2005 16:11:32 -0700 Message-ID: <1115248292.427956a468a55@webmail.telus.net> Date: Wed, 4 May 2005 16:11:32 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: COPY vs INSERT References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> In-Reply-To: <1115246490.1709.233393619@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.044 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/41 X-Sequence-Number: 12205 Quoting David Roussel : > > COPY invokes all the same logic as INSERT on the server side > > (rowexclusive locking, transaction log, updating indexes, rules). > > The difference is that all the rows are inserted as a single > > transaction. This reduces the number of fsync's on the xlog, > > which may be a limiting factor for you. You'll want to crank > > WAL_BUFFERS and CHECKPOINT_SEGMENTS to match, though. > > One of my streams has 6K records; I run with WB=1000, CS=128. > > So what's the difference between a COPY and a batch of INSERT > statements. Also, surely, fsyncs only occur at the end of a > transaction, no need to fsync before a commit has been issued, > right? Sorry, I was comparing granularities the other way araound. As far as xlog is concerned, a COPY is ALWAYS one big txn, no matter how many putline commands you use to feed the copy. With inserts, you can choose whether to commit every row, every nth row, etc. Copy makes better use of the TCP connection for transmission. COPY uses the TCP connection like a one-way pipe. INSERT is like an RPC: the sender has to wait until the insert's return status roundtrips. -- Engineers think equations approximate reality. Physicists think reality approximates the equations. Mathematicians never make the connection. From pgsql-performance-owner@postgresql.org Wed May 4 20:24:02 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6E42454A13 for ; Wed, 4 May 2005 20:24:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35087-10 for ; Wed, 4 May 2005 23:23:58 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 93F2254A0D for ; Wed, 4 May 2005 20:23:57 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j44NNvZ6021224; (envelope-from ) Wed, 4 May 2005 18:23:57 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j44NNttB008933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Wed, 4 May 2005 18:23:56 -0500 (CDT) Message-ID: <4279598B.5010908@arbash-meinel.com> Date: Wed, 04 May 2005 18:23:55 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Roussel Cc: Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> In-Reply-To: <1115246490.1709.233393619@webmail.messagingengine.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig5AFDC63DD17149B68ADC8371" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/42 X-Sequence-Number: 12206 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig5AFDC63DD17149B68ADC8371 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit David Roussel wrote: >>COPY invokes all the same logic as INSERT on the server side >>(rowexclusive locking, transaction log, updating indexes, rules). >>The difference is that all the rows are inserted as a single >>transaction. This reduces the number of fsync's on the xlog, >>which may be a limiting factor for you. You'll want to crank >>WAL_BUFFERS and CHECKPOINT_SEGMENTS to match, though. >>One of my streams has 6K records; I run with WB=1000, CS=128. > > > So what's the difference between a COPY and a batch of INSERT > statements. Also, surely, fsyncs only occur at the end of a > transaction, no need to fsync before a commit has been issued, right? I think COPY also has the advantage that for index updates it only grabs the lock once, rather than grabbing and releasing for each row. But I believe you are right that fsync only happens on COMMIT. > > David John =:-> --------------enig5AFDC63DD17149B68ADC8371 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCeVmLJdeBCYSNAAMRAuWrAKCbyhxIXWmpXWuKbPGRhjyloIU7swCgxjPE Gn0DQu9Wj5m+Mr3Wv5Zzokk= =pkfD -----END PGP SIGNATURE----- --------------enig5AFDC63DD17149B68ADC8371-- From pgsql-performance-owner@postgresql.org Wed May 4 20:29:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC75354A0E for ; Wed, 4 May 2005 20:29:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36260-02 for ; Wed, 4 May 2005 23:29:29 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by svr1.postgresql.org (Postfix) with ESMTP id 78C8E549BF for ; Wed, 4 May 2005 20:29:28 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so416174wri for ; Wed, 04 May 2005 16:29:29 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ON3czTN41G3HV3pD4tDSX4Do6uhtkdrjQzrrmJOfYIZihyhQCovtkrrg15JWRGyDFCZmIsbFXtdlovUV/fZ1g1vm70pOJW7o4m2dJhc+tQSvPu8GxHK0BtcrsrFOv1ynUMdtxbKIC6eAz85liZeyNUO1a0FXRNXuQYZeecSFC88= Received: by 10.54.153.19 with SMTP id a19mr405095wre; Wed, 04 May 2005 16:29:29 -0700 (PDT) Received: by 10.54.120.16 with HTTP; Wed, 4 May 2005 16:29:29 -0700 (PDT) Message-ID: <59d991c40505041629449b2b1b@mail.gmail.com> Date: Wed, 4 May 2005 19:29:29 -0400 From: Christopher Petrilli Reply-To: Christopher Petrilli To: Mischa Sandberg Subject: Re: COPY vs INSERT Cc: pgsql-performance@postgresql.org In-Reply-To: <1115248292.427956a468a55@webmail.telus.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <1115248292.427956a468a55@webmail.telus.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.318 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/43 X-Sequence-Number: 12207 On 5/4/05, Mischa Sandberg wrote: > Quoting David Roussel : >=20 > > > COPY invokes all the same logic as INSERT on the server side > > > (rowexclusive locking, transaction log, updating indexes, rules). > > > The difference is that all the rows are inserted as a single > > > transaction. This reduces the number of fsync's on the xlog, > > > which may be a limiting factor for you. You'll want to crank > > > WAL_BUFFERS and CHECKPOINT_SEGMENTS to match, though. > > > One of my streams has 6K records; I run with WB=3D1000, CS=3D128. > > > > So what's the difference between a COPY and a batch of INSERT > > statements. Also, surely, fsyncs only occur at the end of a > > transaction, no need to fsync before a commit has been issued, > > right? >=20 > Sorry, I was comparing granularities the other way araound. As far as > xlog is concerned, a COPY is ALWAYS one big txn, no matter how many > putline commands you use to feed the copy. With inserts, you can choose > whether to commit every row, every nth row, etc. >=20 > Copy makes better use of the TCP connection for transmission. COPY uses > the TCP connection like a one-way pipe. INSERT is like an RPC: the > sender has to wait until the insert's return status roundtrips. I have found even greater performance increases by using COPY FROM not COPY FROM STDIN. This allows the backend process to directly read the file, rather than shoving it over a pipe (thereby potentially hitting the CPU multiple times). My experience is that this is anywhere from 5-10x faster than INSERT statements on the whole, and sometimes 200x. Chris --=20 | Christopher Petrilli | petrilli@gmail.com From pgsql-performance-owner@postgresql.org Wed May 4 20:33:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 99DB553385 for ; Wed, 4 May 2005 20:33:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35947-09 for ; Wed, 4 May 2005 23:33:49 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 7F3A352956 for ; Wed, 4 May 2005 20:33:48 -0300 (ADT) Received: (qmail 2256 invoked by uid 1112); 4 May 2005 23:33:50 -0000 Date: Wed, 4 May 2005 18:33:50 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: COPY vs INSERT In-Reply-To: <1115248292.427956a468a55@webmail.telus.net> Message-ID: References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <1115248292.427956a468a55@webmail.telus.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/44 X-Sequence-Number: 12208 On Wed, 4 May 2005, Mischa Sandberg wrote: > Copy makes better use of the TCP connection for transmission. COPY uses > the TCP connection like a one-way pipe. INSERT is like an RPC: the > sender has to wait until the insert's return status roundtrips. Not true. A client may send any number of Bind/Execute messages on a prepared statement before a Sync message. So multiple inserts may be sent in one network roundtrip. This is exactly how the JDBC driver implements batch statements. There is some limit to the number of queries in flight at any given moment because there is the potential to deadlock if both sides of network buffers are filled up and each side is blocked waiting on a write. The JDBC driver has conservatively selected 256 as the maximum number of queries to send at once. Kris Jurka From pgsql-performance-owner@postgresql.org Wed May 4 22:49:01 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1FC4A53828 for ; Wed, 4 May 2005 22:49:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54133-02 for ; Thu, 5 May 2005 01:48:51 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id C573453246 for ; Wed, 4 May 2005 22:48:50 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 0EDD624FDF; Thu, 5 May 2005 09:48:54 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id C693C24FCE; Thu, 5 May 2005 09:48:53 +0800 (WST) Message-ID: <42797C1A.3090303@familyhealth.com.au> Date: Thu, 05 May 2005 09:51:22 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Roussel Cc: Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> In-Reply-To: <1115246490.1709.233393619@webmail.messagingengine.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.068 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/45 X-Sequence-Number: 12209 > So what's the difference between a COPY and a batch of INSERT > statements. Also, surely, fsyncs only occur at the end of a > transaction, no need to fsync before a commit has been issued, right? With COPY, the data being inserted itself does not have to pass through the postgresql parser. Chris From pgsql-performance-owner@postgresql.org Wed May 4 23:23:46 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 64FE1543FD for ; Wed, 4 May 2005 23:23:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58482-04 for ; Thu, 5 May 2005 02:23:34 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5B96D53C9E for ; Wed, 4 May 2005 23:23:33 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j452MuEF016748; Wed, 4 May 2005 22:22:56 -0400 (EDT) To: Christopher Kings-Lynne Cc: David Roussel , Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT In-reply-to: <42797C1A.3090303@familyhealth.com.au> References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <42797C1A.3090303@familyhealth.com.au> Comments: In-reply-to Christopher Kings-Lynne message dated "Thu, 05 May 2005 09:51:22 +0800" Date: Wed, 04 May 2005 22:22:56 -0400 Message-ID: <16747.1115259776@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/46 X-Sequence-Number: 12210 Christopher Kings-Lynne writes: >> So what's the difference between a COPY and a batch of INSERT >> statements. Also, surely, fsyncs only occur at the end of a >> transaction, no need to fsync before a commit has been issued, right? > With COPY, the data being inserted itself does not have to pass through > the postgresql parser. Also, there is a whole lot of one-time-per-statement overhead that can be amortized across many rows instead of only one. Stuff like opening the target table, looking up the per-column I/O conversion functions, identifying trigger functions if any, yadda yadda. It's not *that* expensive, but compared to an operation as small as inserting a single row, it's significant. regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 5 01:41:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A1DC1542B5 for ; Thu, 5 May 2005 01:41:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82154-06 for ; Thu, 5 May 2005 04:41:48 +0000 (GMT) Received: from priv-edtnes51.telusplanet.net (outbound04.telus.net [199.185.220.223]) by svr1.postgresql.org (Postfix) with ESMTP id 37D7153CA3 for ; Thu, 5 May 2005 01:41:47 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes51.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050505044146.TWXG16460.priv-edtnes51.telusplanet.net@localhost> for ; Wed, 4 May 2005 22:41:46 -0600 Received: from 64.180.225.200 ( [64.180.225.200]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Wed, 4 May 2005 21:41:46 -0700 Message-ID: <1115268106.4279a40a7481a@webmail.telus.net> Date: Wed, 4 May 2005 21:41:46 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: COPY vs INSERT References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <1115248292.427956a468a55@webmail.telus.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 64.180.225.200 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.056 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/47 X-Sequence-Number: 12211 Quoting Kris Jurka : > On Wed, 4 May 2005, Mischa Sandberg wrote: > > > Copy makes better use of the TCP connection for transmission. COPY > uses > > the TCP connection like a one-way pipe. INSERT is like an RPC: the > > sender has to wait until the insert's return status roundtrips. > > Not true. A client may send any number of Bind/Execute messages on a > prepared statement before a Sync message. So multiple inserts may be > sent > in one network roundtrip. This is exactly how the JDBC driver > implements batch statements. There is some limit to the number of > queries > in flight at any given moment because there is the potential to > deadlock > if both sides of network buffers are filled up and each side is > blocked > waiting on a write. The JDBC driver has conservatively selected 256 > as > the maximum number of queries to send at once. Hunh. Interesting optimization in the JDBC driver. I gather it is sending a string of (;)-separated inserts. Sounds like efficient-but-risky stuff we did for ODBC drivers at Simba ... gets interesting when one of the insert statements in the middle fails. Good to know. Hope that the batch size is parametric, given that you can have inserts with rather large strings bound to 'text' columns in PG --- harder to identify BLOBs when talking to PG, than when talking to MSSQL/Oracle/Sybase. -- Engineers think equations approximate reality. Physicists think reality approximates the equations. Mathematicians never make the connection. From pgsql-performance-owner@postgresql.org Thu May 5 06:15:47 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9ABAC563A8 for ; Thu, 5 May 2005 06:15:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20486-07 for ; Thu, 5 May 2005 09:15:41 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id E575C542BD for ; Thu, 5 May 2005 06:15:40 -0300 (ADT) Received: (qmail 6217 invoked by uid 1112); 5 May 2005 09:15:40 -0000 Date: Thu, 5 May 2005 04:15:40 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: COPY vs INSERT In-Reply-To: <1115268106.4279a40a7481a@webmail.telus.net> Message-ID: References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <1115248292.427956a468a55@webmail.telus.net> <1115268106.4279a40a7481a@webmail.telus.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/48 X-Sequence-Number: 12212 On Wed, 4 May 2005, Mischa Sandberg wrote: > Quoting Kris Jurka : > > > Not true. A client may send any number of Bind/Execute messages on > > a prepared statement before a Sync message. > Hunh. Interesting optimization in the JDBC driver. I gather it is > sending a string of (;)-separated inserts. No, it uses the V3 protocol and a prepared statement and uses Bind/Execute, as I mentioned. > Sounds like efficient-but-risky stuff we did for ODBC drivers at Simba > ... gets interesting when one of the insert statements in the middle > fails. When running inside a transaction (as you really want to do anyway when bulk loading) it is well defined, it is a little odd for auto commit mode though. In autocommit mode the transaction boundary is at the Sync message, not the individual Execute messages, so you will get some rollback on error. The JDBC spec is poorly defined in this area, so we can get away with this. > Good to know. Hope that the batch size is parametric, given that > you can have inserts with rather large strings bound to 'text' columns > in PG --- harder to identify BLOBs when talking to PG, than when talking > to MSSQL/Oracle/Sybase. The batch size is not a parameter and I don't think it needs to be. The issue of filling both sides of network buffers and deadlocking only needs to be avoided on one side. The response to an insert request is small and not dependent on the size of the data sent, so we can send as much as we want as long as the server doesn't send much back to us. Kris Jurka From pgsql-performance-owner@postgresql.org Thu May 5 06:48:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E781053B35 for ; Thu, 5 May 2005 06:48:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25848-04 for ; Thu, 5 May 2005 09:48:51 +0000 (GMT) Received: from taanari.planescape.cydev.biz (port259.ds1-brh.adsl.cybercity.dk [217.157.160.140]) by svr1.postgresql.org (Postfix) with ESMTP id 10B03536C8 for ; Thu, 5 May 2005 06:48:48 -0300 (ADT) Received: from [10.0.0.2] ([217.157.160.140]) (authenticated user jona@cydev.biz) by taanari.planescape.cydev.biz (Kerio MailServer 5.7.1) (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for pgsql-performance@postgresql.org; Thu, 5 May 2005 11:52:05 +0200 Message-ID: <4279ECC1.4050000@oismail.com> Date: Thu, 05 May 2005 11:52:01 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 part 1 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/49 X-Sequence-Number: 12213 Hi I'm currently experiencing problems with long query execution times. What I believe makes these problems particularly interesting is the difference in execution plans between our test server running PostGreSQL 7.3.6 and our production server running PostGreSQL 7.3.9. The test server is an upgraded "home machine", a Pentium 4 with 1GB of memory and IDE disk. The production server is a dual CPU XEON Pentium 4 with 2GB memory and SCSI disks. One should expect the production server to be faster, but appearently not as the outlined query plans below shows. My questions can be summoned up to: 1) How come the query plans between the 2 servers are different? 2) How come the production server in general estimates the cost of the query plans so horribly wrong? (ie. it chooses a bad query plan where as the test server chooses a good plan) 3) In Query 2, how come the production server refuses the use its indexes (subcat_uq and aff_price_uq, both unique indexes) where as the test server determines that the indexes are the way to go 4) In Query 3, how come the test server refuses to use its index (sct2lang_uq) and the production server uses it? And why is the test server still faster eventhough it makes a sequential scan of a table with 8.5k records in? Please note, a VACUUM ANALYSE is run on the production server once a day (used to be once an hour but it seemed to make no difference), however there are generally no writes to the tables used in the queries. If anyone could shed some light on these issues I would truly appreciate it. Cheers Jona PS. Please refer to part 2 for the other queries and query plans ---------------------------------------------------------------------------------------------------- Query 1: EXPLAIN ANALYZE SELECT DISTINCT StatConTrans_Tbl.id, Code_Tbl.sysnm AS code, PriceCat_Tbl.amount AS price, Country_Tbl.currency, CreditsCat_Tbl.amount AS credits, Info_Tbl.title, Info_Tbl.description FROM (SCT2SubCatType_Tbl INNER JOIN SCT2Lang_Tbl ON SCT2SubCatType_Tbl.sctid = SCT2Lang_Tbl.sctid INNER JOIN Language_Tbl ON SCT2Lang_Tbl.langid = Language_Tbl.id AND Language_Tbl.sysnm = UPPER('us') AND Language_Tbl.enabled = true INNER JOIN Info_Tbl ON SCT2SubCatType_Tbl.sctid = Info_Tbl.sctid AND Language_Tbl.id = Info_Tbl.langid INNER JOIN SubCatType_Tbl ON SCT2SubCatType_Tbl.subcattpid = SubCatType_Tbl.id AND SubCatType_Tbl.enabled = true INNER JOIN CatType_Tbl ON SubCatType_Tbl.cattpid = CatType_Tbl.id AND CatType_Tbl.enabled = true INNER JOIN SuperCatType_Tbl ON CatType_Tbl.spcattpid = SuperCatType_Tbl.id AND SuperCatType_Tbl.enabled = true INNER JOIN StatConTrans_Tbl ON SCT2SubCatType_Tbl.sctid = StatConTrans_Tbl.id AND StatConTrans_Tbl.enabled = true INNER JOIN Price_Tbl ON StatConTrans_Tbl.id = Price_Tbl.sctid AND Price_Tbl.affid = 8 INNER JOIN PriceCat_Tbl ON Price_Tbl.prccatid = PriceCat_Tbl.id AND PriceCat_Tbl.enabled = true INNER JOIN Country_Tbl ON PriceCat_Tbl.cntid = Country_Tbl.id AND Country_Tbl.enabled = true INNER JOIN CreditsCat_Tbl ON Price_Tbl.crdcatid = CreditsCat_Tbl.id AND CreditsCat_Tbl.enabled = true INNER JOIN StatCon_Tbl ON StatConTrans_Tbl.id = StatCon_Tbl.sctid AND StatCon_Tbl.ctpid = 1 INNER JOIN Code_Tbl ON SuperCatType_Tbl.id = Code_Tbl.spcattpid AND Code_Tbl.affid = 8 AND Code_Tbl.cdtpid = 1) WHERE SCT2SubCatType_Tbl.subcattpid = 79 ORDER BY StatConTrans_Tbl.id DESC LIMIT 8 OFFSET 0 Plan on PostGre 7.3.6 on Red Hat Linux 3.2.3-39 "Limit (cost=178.59..178.61 rows=1 width=330) (actual time=22.77..28.51 rows=4 loops=1)" " -> Unique (cost=178.59..178.61 rows=1 width=330) (actual time=22.77..28.50 rows=4 loops=1)" " -> Sort (cost=178.59..178.60 rows=1 width=330) (actual time=22.76..22.85 rows=156 loops=1)" " Sort Key: statcontrans_tbl.id, code_tbl.sysnm, pricecat_tbl.amount, country_tbl.currency, creditscat_tbl.amount, info_tbl.title, info_tbl.description" " -> Hash Join (cost=171.19..178.58 rows=1 width=330) (actual time=3.39..6.55 rows=156 loops=1)" " Hash Cond: ("outer".cntid = "inner".id)" " -> Nested Loop (cost=170.13..177.51 rows=1 width=312) (actual time=3.27..5.75 rows=156 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Hash Join (cost=170.13..171.48 rows=1 width=308) (actual time=3.12..3.26 rows=4 loops=1)" " Hash Cond: ("outer".crdcatid = "inner".id)" " -> Hash Join (cost=169.03..170.38 rows=1 width=300) (actual time=3.00..3.11 rows=4 loops=1)" " Hash Cond: ("outer".spcattpid = "inner".spcattpid)" " -> Hash Join (cost=167.22..168.56 rows=1 width=253) (actual time=2.88..2.97 rows=4 loops=1)" " Hash Cond: ("outer".id = "inner".prccatid)" " -> Seq Scan on pricecat_tbl (cost=0.00..1.29 rows=12 width=12) (actual time=0.04..0.08 rows=23 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=167.21..167.21 rows=1 width=241) (actual time=2.80..2.80 rows=0 loops=1)" " -> Nested Loop (cost=3.77..167.21 rows=1 width=241) (actual time=1.31..2.79 rows=4 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Nested Loop (cost=3.77..161.19 rows=1 width=229) (actual time=1.19..2.60 rows=4 loops=1)" " Join Filter: ("outer".sctid = "inner".sctid)" " -> Hash Join (cost=3.77..155.17 rows=1 width=44) (actual time=1.07..2.37 rows=4 loops=1)" " Hash Cond: ("outer".langid = "inner".id)" " -> Nested Loop (cost=2.69..154.06 rows=7 width=40) (actual time=0.90..2.18 rows=8 loops=1)" " Join Filter: ("outer".sctid = "inner".sctid)" " -> Nested Loop (cost=2.69..21.30 rows=1 width=32) (actual time=0.78..1.94 rows=4 loops=1)" " -> Nested Loop (cost=2.69..15.30 rows=1 width=28) (actual time=0.66..1.76 rows=4 loops=1)" " -> Hash Join (cost=2.69..7.07 rows=1 width=20) (actual time=0.39..1.15 rows=154 loops=1)" " Hash Cond: ("outer".cattpid = "inner".id)" " -> Seq Scan on subcattype_tbl (cost=0.00..3.98 rows=79 width=8) (actual time=0.03..0.35 rows=156 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=2.68..2.68 rows=3 width=12) (actual time=0.31..0.31 rows=0 loops=1)" " -> Hash Join (cost=1.15..2.68 rows=3 width=12) (actual time=0.16..0.27 rows=31 loops=1)" " Hash Cond: ("outer".spcattpid = "inner".id)" " -> Seq Scan on cattype_tbl (cost=0.00..1.41 rows=16 width=8) (actual time=0.04..0.09 rows=31 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=1.14..1.14 rows=6 width=4) (actual time=0.06..0.06 rows=0 loops=1)" " -> Seq Scan on supercattype_tbl (cost=0.00..1.14 rows=6 width=4) (actual time=0.03..0.05 rows=10 loops=1)" " Filter: (enabled = true)" " -> Index Scan using subcat_uq on sct2subcattype_tbl (cost=0.00..5.97 rows=1 width=8) (actual time=0.00..0.00 rows=0 loops=154)" " Index Cond: ((sct2subcattype_tbl.subcattpid = "outer".id) AND (sct2subcattype_tbl.subcattpid = 79))" " -> Index Scan using statcontrans_pk on statcontrans_tbl (cost=0.00..5.99 rows=1 width=4) (actual time=0.04..0.04 rows=1 loops=4)" " Index Cond: ("outer".sctid = statcontrans_tbl.id)" " Filter: (enabled = true)" " -> Index Scan using sct2lang_uq on sct2lang_tbl (cost=0.00..132.22 rows=43 width=8) (actual time=0.04..0.05 rows=2 loops=4)" " Index Cond: ("outer".id = sct2lang_tbl.sctid)" " -> Hash (cost=1.07..1.07 rows=1 width=4) (actual time=0.11..0.11 rows=0 loops=1)" " -> Seq Scan on language_tbl (cost=0.00..1.07 rows=1 width=4) (actual time=0.10..0.11 rows=1 loops=1)" " Filter: (((sysnm)::text = 'US'::text) AND (enabled = true))" " -> Index Scan using info_uq on info_tbl (cost=0.00..6.00 rows=1 width=185) (actual time=0.05..0.05 rows=1 loops=4)" " Index Cond: ((info_tbl.sctid = "outer".sctid) AND (info_tbl.langid = "outer".langid))" " -> Index Scan using aff_price_uq on price_tbl (cost=0.00..6.01 rows=1 width=12) (actual time=0.03..0.03 rows=1 loops=4)" " Index Cond: ((price_tbl.affid = 8) AND (price_tbl.sctid = "outer".sctid))" " -> Hash (cost=1.81..1.81 rows=1 width=47) (actual time=0.08..0.08 rows=0 loops=1)" " -> Seq Scan on code_tbl (cost=0.00..1.81 rows=1 width=47) (actual time=0.04..0.07 rows=5 loops=1)" " Filter: ((affid = 8) AND (cdtpid = 1))" " -> Hash (cost=1.09..1.09 rows=4 width=8) (actual time=0.06..0.06 rows=0 loops=1)" " -> Seq Scan on creditscat_tbl (cost=0.00..1.09 rows=4 width=8) (actual time=0.03..0.04 rows=7 loops=1)" " Filter: (enabled = true)" " -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4)" " Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))" " -> Hash (cost=1.06..1.06 rows=2 width=18) (actual time=0.06..0.06 rows=0 loops=1)" " -> Seq Scan on country_tbl (cost=0.00..1.06 rows=2 width=18) (actual time=0.04..0.05 rows=4 loops=1)" " Filter: (enabled = true)" "Total runtime: 29.56 msec" Plan on PostGre 7.3.9 on Red Hat Linux 3.2.3-49 "Limit (cost=545.53..545.60 rows=1 width=135) (actual time=1251.71..1261.25 rows=4 loops=1)" " -> Unique (cost=545.53..545.60 rows=1 width=135) (actual time=1251.71..1261.24 rows=4 loops=1)" " -> Sort (cost=545.53..545.54 rows=4 width=135) (actual time=1251.70..1251.90 rows=156 loops=1)" " Sort Key: statcontrans_tbl.id, code_tbl.sysnm, pricecat_tbl.amount, country_tbl.currency, creditscat_tbl.amount, info_tbl.title, info_tbl.description" " -> Nested Loop (cost=485.61..545.49 rows=4 width=135) (actual time=603.77..1230.96 rows=156 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Hash Join (cost=485.61..486.06 rows=3 width=131) (actual time=541.87..542.22 rows=4 loops=1)" " Hash Cond: ("outer".crdcatid = "inner".id)" " -> Hash Join (cost=484.51..484.90 rows=3 width=123) (actual time=529.09..529.36 rows=4 loops=1)" " Hash Cond: ("outer".spcattpid = "inner".spcattpid)" " -> Hash Join (cost=482.68..482.93 rows=3 width=114) (actual time=517.60..517.77 rows=4 loops=1)" " Hash Cond: ("outer".cntid = "inner".id)" " -> Merge Join (cost=481.60..481.80 rows=4 width=105) (actual time=517.36..517.43 rows=4 loops=1)" " Merge Cond: ("outer".id = "inner".prccatid)" " -> Sort (cost=1.81..1.87 rows=23 width=12) (actual time=8.44..8.45 rows=6 loops=1)" " Sort Key: pricecat_tbl.id" " -> Seq Scan on pricecat_tbl (cost=0.00..1.29 rows=23 width=12) (actual time=8.31..8.37 rows=23 loops=1)" " Filter: (enabled = true)" " -> Sort (cost=479.80..479.81 rows=4 width=93) (actual time=508.87..508.87 rows=4 loops=1)" " Sort Key: price_tbl.prccatid" " -> Nested Loop (cost=13.69..479.75 rows=4 width=93) (actual time=444.70..508.81 rows=4 loops=1)" " Join Filter: ("inner".sctid = "outer".sctid)" " -> Nested Loop (cost=13.69..427.04 rows=9 width=81) (actual time=444.60..508.62 rows=4 loops=1)" " Join Filter: ("outer".sctid = "inner".sctid)" " -> Nested Loop (cost=13.69..377.03 rows=8 width=44) (actual time=345.13..398.38 rows=4 loops=1)" " Join Filter: ("outer".sctid = "inner".id)" " -> Hash Join (cost=13.69..327.32 rows=8 width=40) (actual time=219.17..272.27 rows=4 loops=1)" " Hash Cond: ("outer".langid = "inner".id)" " -> Nested Loop (cost=12.61..325.92 rows=42 width=36) (actual time=209.77..262.79 rows=8 loops=1)" " -> Hash Join (cost=12.61..106.32 rows=27 width=28) (actual time=101.88..102.00 rows=4 loops=1)" " Hash Cond: ("outer".cattpid = "inner".id)" " -> Hash Join (cost=9.47..102.68 rows=33 width=16) (actual time=84.14..84.21 rows=4 loops=1)" " Hash Cond: ("outer".subcattpid = "inner".id)" " -> Index Scan using subcat_uq on sct2subcattype_tbl (cost=0.00..92.56 rows=33 width=8) (actual time=83.33..83.37 rows=4 loops=1)" " Index Cond: (subcattpid = 79)" " -> Hash (cost=3.98..3.98 rows=156 width=8) (actual time=0.76..0.76 rows=0 loops=1)" " -> Seq Scan on subcattype_tbl (cost=0.00..3.98 rows=156 width=8) (actual time=0.03..0.49 rows=156 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=3.07..3.07 rows=27 width=12) (actual time=17.58..17.58 rows=0 loops=1)" " -> Hash Join (cost=1.16..3.07 rows=27 width=12) (actual time=17.30..17.52 rows=31 loops=1)" " Hash Cond: ("outer".spcattpid = "inner".id)" " -> Seq Scan on cattype_tbl (cost=0.00..1.41 rows=31 width=8) (actual time=0.02..0.12 rows=31 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=1.14..1.14 rows=10 width=4) (actual time=17.09..17.09 rows=0 loops=1)" " -> Seq Scan on supercattype_tbl (cost=0.00..1.14 rows=10 width=4) (actual time=17.05..17.07 rows=10 loops=1)" " Filter: (enabled = true)" " -> Index Scan using sct2lang_uq on sct2lang_tbl (cost=0.00..8.13 rows=2 width=8) (actual time=26.97..40.18 rows=2 loops=4)" " Index Cond: ("outer".sctid = sct2lang_tbl.sctid)" " -> Hash (cost=1.07..1.07 rows=1 width=4) (actual time=9.04..9.04 rows=0 loops=1)" " -> Seq Scan on language_tbl (cost=0.00..1.07 rows=1 width=4) (actual time=9.02..9.03 rows=1 loops=1)" " Filter: (((sysnm)::text = 'US'::text) AND (enabled = true))" " -> Index Scan using statcontrans_pk on statcontrans_tbl (cost=0.00..5.88 rows=1 width=4) (actual time=31.51..31.52 rows=1 loops=4)" " Index Cond: (statcontrans_tbl.id = "outer".sctid)" " Filter: (enabled = true)" " -> Index Scan using info_uq on info_tbl (cost=0.00..5.93 rows=1 width=37) (actual time=27.54..27.54 rows=1 loops=4)" " Index Cond: ((info_tbl.sctid = "outer".sctid) AND (info_tbl.langid = "outer".langid))" " -> Index Scan using aff_price_uq on price_tbl (cost=0.00..5.88 rows=1 width=12) (actual time=0.03..0.03 rows=1 loops=4)" " Index Cond: ((price_tbl.affid = 8) AND (price_tbl.sctid = "outer".sctid))" " -> Hash (cost=1.06..1.06 rows=4 width=9) (actual time=0.05..0.05 rows=0 loops=1)" " -> Seq Scan on country_tbl (cost=0.00..1.06 rows=4 width=9) (actual time=0.02..0.03 rows=4 loops=1)" " Filter: (enabled = true)" " -> Hash (cost=1.81..1.81 rows=8 width=9) (actual time=11.31..11.31 rows=0 loops=1)" " -> Seq Scan on code_tbl (cost=0.00..1.81 rows=8 width=9) (actual time=11.24..11.29 rows=5 loops=1)" " Filter: ((affid = 8) AND (cdtpid = 1))" " -> Hash (cost=1.09..1.09 rows=7 width=8) (actual time=12.59..12.59 rows=0 loops=1)" " -> Seq Scan on creditscat_tbl (cost=0.00..1.09 rows=7 width=8) (actual time=12.55..12.57 rows=7 loops=1)" " Filter: (enabled = true)" " -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4)" " Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))" "Total runtime: 1299.02 msec" From pgsql-performance-owner@postgresql.org Thu May 5 13:02:49 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A16A45359B for ; Thu, 5 May 2005 13:02:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89500-06 for ; Thu, 5 May 2005 16:02:39 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 309EC5379B for ; Thu, 5 May 2005 13:02:38 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j45G2YbX024107; Thu, 5 May 2005 12:02:34 -0400 (EDT) To: Jona Cc: pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 part 1 In-reply-to: <4279ECC1.4050000@oismail.com> References: <4279ECC1.4050000@oismail.com> Comments: In-reply-to Jona message dated "Thu, 05 May 2005 11:52:01 +0200" Date: Thu, 05 May 2005 12:02:34 -0400 Message-ID: <24106.1115308954@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/50 X-Sequence-Number: 12214 Jona writes: > I'm currently experiencing problems with long query execution times. > What I believe makes these problems particularly interesting is the > difference in execution plans between our test server running PostGreSQL > 7.3.6 and our production server running PostGreSQL 7.3.9. > The test server is an upgraded "home machine", a Pentium 4 with 1GB of > memory and IDE disk. > The production server is a dual CPU XEON Pentium 4 with 2GB memory and > SCSI disks. > One should expect the production server to be faster, but appearently > not as the outlined query plans below shows. I think the plans are fine; it looks to me like the production server has serious table-bloat or index-bloat problems, probably because of inadequate vacuuming. For instance compare these entries: -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4) Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4) Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) Appears to be exactly the same task ... but the test server spent 1.24 msec total while the production server spent 687.36 msec total. That's more than half of your problem right there. Some of the other scans seem a lot slower on the production machine too. > 1) How come the query plans between the 2 servers are different? The production server's rowcount estimates are pretty good, the test server's are not. How long since you vacuumed/analyzed the test server? It'd be interesting to see the output of "vacuum verbose statcon_tbl" on both servers ... regards, tom lane PS: if you post any more query plans, please try to use software that doesn't mangle the formatting so horribly ... From pgsql-performance-owner@postgresql.org Thu May 5 20:59:42 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 390F15337C for ; Thu, 5 May 2005 20:59:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90393-10 for ; Thu, 5 May 2005 23:59:39 +0000 (GMT) Received: from out2.smtp.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by svr1.postgresql.org (Postfix) with ESMTP id D08BC53317 for ; Thu, 5 May 2005 20:59:38 -0300 (ADT) Received: from frontend3.messagingengine.com (frontend3.internal [10.202.2.152]) by frontend1.messagingengine.com (Postfix) with ESMTP id EFD5DC89F60; Thu, 5 May 2005 19:59:39 -0400 (EDT) X-Sasl-enc: 7VRdjRc3LEgVurxZ0Dj+iN4K4tb/+mcHNdiAs65JW4RV 1115337578 Received: from [192.168.0.4] (i-83-67-25-205.freedom2surf.net [83.67.25.205]) by www.fastmail.fm (Postfix) with ESMTP id 952A51DA; Thu, 5 May 2005 19:59:37 -0400 (EDT) In-Reply-To: <20050504145825.GA26993@localhost.localdomain> References: <20050504145825.GA26993@localhost.localdomain> Mime-Version: 1.0 (Apple Message framework v622) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: David Roussel Subject: Re: Table stats Date: Fri, 6 May 2005 00:59:32 +0100 To: "Mike G." X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/51 X-Sequence-Number: 12215 > Should there not be at least one Index Scan showing in the stats? not if there was a table scan From pgsql-performance-owner@postgresql.org Thu May 5 21:53:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 860F05322C for ; Thu, 5 May 2005 21:53:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02582-01 for ; Fri, 6 May 2005 00:53:30 +0000 (GMT) Received: from mxsf24.cluster1.charter.net (mxsf24.cluster1.charter.net [209.225.28.224]) by svr1.postgresql.org (Postfix) with ESMTP id 4A8EB52D44 for ; Thu, 5 May 2005 21:53:29 -0300 (ADT) Received: from mxip17.cluster1.charter.net (mxip17a.cluster1.charter.net [209.225.28.147]) by mxsf24.cluster1.charter.net (8.12.11/8.12.11) with ESMTP id j460rWw9001085 for ; Thu, 5 May 2005 20:53:32 -0400 Received: from pc-68-118-180-13.will.ct.charter.com (HELO [192.168.116.102]) (68.118.180.13) by mxip17.cluster1.charter.net with ESMTP; 05 May 2005 20:53:32 -0400 X-Ironport-AV: i="3.92,158,1112587200"; d="scan'208"; a="1057003439:sNHT13881740" Message-ID: <427AC00B.3030500@NarrowPathInc.com> Date: Thu, 05 May 2005 20:53:31 -0400 From: Keith Worthington Reply-To: KeithW@NarrowPathInc.com Organization: Narrow Path, Inc. User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christopher Petrilli Cc: pgsql-performance@postgresql.org Subject: Re: COPY vs INSERT References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <1115248292.427956a468a55@webmail.telus.net> <59d991c40505041629449b2b1b@mail.gmail.com> In-Reply-To: <59d991c40505041629449b2b1b@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.068 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/52 X-Sequence-Number: 12216 Christopher Petrilli wrote: > On 5/4/05, Mischa Sandberg wrote: > >>Quoting David Roussel : >> >> >>>>COPY invokes all the same logic as INSERT on the server side >>>>(rowexclusive locking, transaction log, updating indexes, rules). >>>>The difference is that all the rows are inserted as a single >>>>transaction. This reduces the number of fsync's on the xlog, >>>>which may be a limiting factor for you. You'll want to crank >>>>WAL_BUFFERS and CHECKPOINT_SEGMENTS to match, though. >>>>One of my streams has 6K records; I run with WB=1000, CS=128. >>> >>>So what's the difference between a COPY and a batch of INSERT >>>statements. Also, surely, fsyncs only occur at the end of a >>>transaction, no need to fsync before a commit has been issued, >>>right? >> >>Sorry, I was comparing granularities the other way araound. As far as >>xlog is concerned, a COPY is ALWAYS one big txn, no matter how many >>putline commands you use to feed the copy. With inserts, you can choose >>whether to commit every row, every nth row, etc. >> >>Copy makes better use of the TCP connection for transmission. COPY uses >>the TCP connection like a one-way pipe. INSERT is like an RPC: the >>sender has to wait until the insert's return status roundtrips. > > > I have found even greater performance increases by using COPY FROM > not COPY FROM STDIN. This allows the backend process to > directly read the file, rather than shoving it over a pipe (thereby > potentially hitting the CPU multiple times). My experience is that > this is anywhere from 5-10x faster than INSERT statements on the > whole, and sometimes 200x. > > Chris > Unfortunately, COPY FROM '' can only be done by a superuser. If you that option then that is great. If not... -- Kind Regards, Keith From pgsql-performance-owner@postgresql.org Fri May 6 03:51:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC32452D91 for ; Fri, 6 May 2005 03:51:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52446-10 for ; Fri, 6 May 2005 06:51:29 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 14AF152C7A for ; Fri, 6 May 2005 03:51:28 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 8BF611522D; Fri, 6 May 2005 01:51:29 -0500 (CDT) Date: Fri, 6 May 2005 01:51:29 -0500 From: "Jim C. Nasby" To: Tom Lane Cc: Christopher Kings-Lynne , David Roussel , Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT Message-ID: <20050506065129.GL88920@decibel.org> References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <42797C1A.3090303@familyhealth.com.au> <16747.1115259776@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16747.1115259776@sss.pgh.pa.us> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/53 X-Sequence-Number: 12217 On Wed, May 04, 2005 at 10:22:56PM -0400, Tom Lane wrote: > Also, there is a whole lot of one-time-per-statement overhead that can > be amortized across many rows instead of only one. Stuff like opening > the target table, looking up the per-column I/O conversion functions, > identifying trigger functions if any, yadda yadda. It's not *that* > expensive, but compared to an operation as small as inserting a single > row, it's significant. Has thought been given to supporting inserting multiple rows in a single insert? DB2 supported: INSERT INTO table VALUES( (1,2,3), (4,5,6), (7,8,9) ); I'm not sure how standard that is or if other databases support it. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Fri May 6 04:25:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 378E652D90 for ; Fri, 6 May 2005 04:25:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57199-09 for ; Fri, 6 May 2005 07:25:06 +0000 (GMT) Received: from taanari.planescape.cydev.biz (port259.ds1-brh.adsl.cybercity.dk [217.157.160.140]) by svr1.postgresql.org (Postfix) with ESMTP id 476C752A72 for ; Fri, 6 May 2005 04:25:04 -0300 (ADT) Received: from [10.0.0.2] ([217.157.160.140]) (authenticated user jona@cydev.biz) by taanari.planescape.cydev.biz (Kerio MailServer 5.7.1) (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)); Fri, 6 May 2005 09:28:11 +0200 Message-ID: <427B1C86.6040601@oismail.com> Date: Fri, 06 May 2005 09:28:06 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 References: <4279ECC1.4050000@oismail.com> <24106.1115308954@sss.pgh.pa.us> In-Reply-To: <24106.1115308954@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------030907030800050903090406" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.198 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_10_20, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/54 X-Sequence-Number: 12218 This is a multi-part message in MIME format. --------------030907030800050903090406 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Thank you for the swift reply. The test server is hardly ever vacuumed as it in general sees very limited traffic. vacuum is only necessary if the server sees a lot of write operations, i.e. update, delete, insert right? What explains the different choice of query plans then? As can be seen from the following snippets the test server decides to use an index twice in Query 2, where as the live server decides to do a full scan of tables with 38.5k and 5.5k records. In Query 3 it's vice versa. Seems strange to me... Query 2: ------------------- Bad idea, price_tbl hold 38.5k records Test: -> Index Scan using aff_price_uq on price_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.01..0.01 rows=1 loops=2838)" Live: -> Seq Scan on price_tbl (cost=0.00..883.48 rows=2434 width=4) (actual time=0.86..67.25 rows=4570 loops=1)" Filter: (affid = 8)" ------------------- Bad idea, sct2subcattype_tbl hold 5.5k records Test: -> Index Scan using subcat_uq on sct2subcattype_tbl (cost=0.00..79.26 rows=26 width=8) (actual time=0.01..0.17 rows=59 loops=48) Live: -> Seq Scan on sct2subcattype_tbl (cost=0.00..99.26 rows=5526 width=8) (actual time=0.01..30.16 rows=5526 loops=1)" Query 3: ----------------- Bad idea, sct2lang_tbl has 8.6k records Test: -> Seq Scan on sct2lang_tbl (cost=0.00..150.79 rows=8679 width=8) (actual time=0.03..10.70 rows=8679 loops=1)" Live: -> Index Scan using sct2lang_uq on sct2lang_tbl (cost=0.00..8.13 rows=2 width=8) (actual time=1.10..2.39 rows=2 loops=69)" Will get a VACUUM VERBOSE of StatCon_Tbl Cheers Jona PS: The query plans are extracted using pgAdmin on Windows, if you can recommend a better cross-platform postgre client I'd be happy to try it out. Tom Lane wrote: >Jona writes: > > >>I'm currently experiencing problems with long query execution times. >>What I believe makes these problems particularly interesting is the >>difference in execution plans between our test server running PostGreSQL >>7.3.6 and our production server running PostGreSQL 7.3.9. >>The test server is an upgraded "home machine", a Pentium 4 with 1GB of >>memory and IDE disk. >>The production server is a dual CPU XEON Pentium 4 with 2GB memory and >>SCSI disks. >>One should expect the production server to be faster, but appearently >>not as the outlined query plans below shows. >> >> > >I think the plans are fine; it looks to me like the production server >has serious table-bloat or index-bloat problems, probably because of >inadequate vacuuming. For instance compare these entries: > >-> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4) > Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) > >-> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4) > Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) > >Appears to be exactly the same task ... but the test server spent >1.24 msec total while the production server spent 687.36 msec total. >That's more than half of your problem right there. Some of the other >scans seem a lot slower on the production machine too. > > > >>1) How come the query plans between the 2 servers are different? >> >> > >The production server's rowcount estimates are pretty good, the test >server's are not. How long since you vacuumed/analyzed the test server? > >It'd be interesting to see the output of "vacuum verbose statcon_tbl" >on both servers ... > > regards, tom lane > >PS: if you post any more query plans, please try to use software that >doesn't mangle the formatting so horribly ... > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > --------------030907030800050903090406 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Thank you for the swift reply.
The test server is hardly ever vacuumed as it in general sees very limited traffic. vacuum is only necessary if the server sees a lot of write operations, i.e. update, delete, insert right?

What explains the different choice of query plans then?
As can be seen from the following snippets the test server decides to use an index twice in Query 2, where as the live server decides to do a full scan of tables with 38.5k and 5.5k records.
In Query 3 it's vice versa.
Seems strange to me...

Query 2:
------------------- Bad idea, price_tbl hold 38.5k records
Test:
->  Index Scan using aff_price_uq on price_tbl  (cost=0.00..6.01 rows=1 width=4) (actual time=0.01..0.01 rows=1 loops=2838)"
Live:
->  Seq Scan on price_tbl  (cost=0.00..883.48 rows=2434 width=4) (actual time=0.86..67.25 rows=4570 loops=1)"
Filter: (affid = 8)"

------------------- Bad idea, sct2subcattype_tbl hold 5.5k records
Test:
->  Index Scan using subcat_uq on sct2subcattype_tbl  (cost=0.00..79.26 rows=26 width=8) (actual time=0.01..0.17 rows=59 loops=48)
Live:
 ->  Seq Scan on sct2subcattype_tbl  (cost=0.00..99.26 rows=5526 width=8) (actual time=0.01..30.16 rows=5526 loops=1)"

Query 3:
----------------- Bad idea, sct2lang_tbl has 8.6k records
Test:
 ->  Seq Scan on sct2lang_tbl  (cost=0.00..150.79 rows=8679 width=8) (actual time=0.03..10.70 rows=8679 loops=1)"
Live:
->  Index Scan using sct2lang_uq on sct2lang_tbl  (cost=0.00..8.13 rows=2 width=8) (actual time=1.10..2.39 rows=2 loops=69)"

Will get a VACUUM VERBOSE of StatCon_Tbl

Cheers
Jona

PS: The query plans are extracted using pgAdmin on Windows, if you can recommend a better cross-platform postgre client I'd be happy to try it out.

Tom Lane wrote:
Jona <jonanews@oismail.com> writes:
  
I'm currently experiencing problems with long query execution times.
What I believe makes these problems particularly interesting is the 
difference in execution plans between our test server running PostGreSQL 
7.3.6 and our production server running PostGreSQL 7.3.9.
The test server is an upgraded "home machine", a Pentium 4 with 1GB of 
memory and IDE disk.
The production server is a dual CPU XEON Pentium 4 with 2GB memory and 
SCSI disks.
One should expect the production server to be faster, but appearently 
not as the outlined query plans below shows.
    

I think the plans are fine; it looks to me like the production server
has serious table-bloat or index-bloat problems, probably because of
inadequate vacuuming.  For instance compare these entries:

->  Index Scan using ctp_statcon on statcon_tbl  (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4)
      Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))

->  Index Scan using ctp_statcon on statcon_tbl  (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4)
      Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))

Appears to be exactly the same task ... but the test server spent
1.24 msec total while the production server spent 687.36 msec total.
That's more than half of your problem right there.  Some of the other
scans seem a lot slower on the production machine too.

  
1) How come the query plans between the 2 servers are different?
    

The production server's rowcount estimates are pretty good, the test
server's are not.  How long since you vacuumed/analyzed the test server?

It'd be interesting to see the output of "vacuum verbose statcon_tbl"
on both servers ...

			regards, tom lane

PS: if you post any more query plans, please try to use software that
doesn't mangle the formatting so horribly ...

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
  
--------------030907030800050903090406-- From pgsql-performance-owner@postgresql.org Fri May 6 04:30:50 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C60B05321B for ; Fri, 6 May 2005 04:30:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58675-10 for ; Fri, 6 May 2005 07:30:48 +0000 (GMT) Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) by svr1.postgresql.org (Postfix) with ESMTP id 2D41153213 for ; Fri, 6 May 2005 04:30:46 -0300 (ADT) Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) by zigo.dhs.org (Postfix) with ESMTP id 365368467; Fri, 6 May 2005 09:30:46 +0200 (CEST) Date: Fri, 6 May 2005 09:30:46 +0200 (CEST) From: Dennis Bjorklund To: "Jim C. Nasby" Cc: Tom Lane , Christopher Kings-Lynne , David Roussel , Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT In-Reply-To: <20050506065129.GL88920@decibel.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.328 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/55 X-Sequence-Number: 12219 On Fri, 6 May 2005, Jim C. Nasby wrote: > Has thought been given to supporting inserting multiple rows in a single > insert? DB2 supported: > > INSERT INTO table VALUES( > (1,2,3), > (4,5,6), > (7,8,9) > ); > > I'm not sure how standard that is or if other databases support it. The sql standard include this, except that you can not have the outer (). So it should be INSERT INTO table VALUES (1,2,3), (4,5,6), (7,8,9); Do DB2 demand these extra ()? -- /Dennis Bj�rklund From pgsql-performance-owner@postgresql.org Fri May 6 04:31:30 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 99E735321C for ; Fri, 6 May 2005 04:31:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60568-01 for ; Fri, 6 May 2005 07:31:28 +0000 (GMT) Received: from taanari.planescape.cydev.biz (port259.ds1-brh.adsl.cybercity.dk [217.157.160.140]) by svr1.postgresql.org (Postfix) with ESMTP id 5A12353213 for ; Fri, 6 May 2005 04:31:26 -0300 (ADT) Received: from [10.0.0.2] ([217.157.160.140]) (authenticated user jona@cydev.biz) by taanari.planescape.cydev.biz (Kerio MailServer 5.7.1) (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)); Fri, 6 May 2005 09:34:38 +0200 Message-ID: <427B1E0A.3000108@oismail.com> Date: Fri, 06 May 2005 09:34:34 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 References: <4279ECC1.4050000@oismail.com> <24106.1115308954@sss.pgh.pa.us> In-Reply-To: <24106.1115308954@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------040507010809080801070807" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.345 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_20_30, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/56 X-Sequence-Number: 12220 This is a multi-part message in MIME format. --------------040507010809080801070807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Results of VACUUM VERBOSE from both servers Test server: comm=# VACUUM VERBOSE StatCon_Tbl; INFO: --Relation public.statcon_tbl-- INFO: Pages 338: Changed 338, Empty 0; Tup 11494: Vac 0, Keep 0, UnUsed 0. Total CPU 0.02s/0.00u sec elapsed 0.04 sec. INFO: --Relation pg_toast.pg_toast_179851-- INFO: Pages 85680: Changed 85680, Empty 0; Tup 343321: Vac 0, Keep 0, UnUsed 0. Total CPU 4.03s/0.40u sec elapsed 70.99 sec. VACUUM Live Server: comm=# VACUUM VERBOSE StatCon_Tbl; INFO: --Relation public.statcon_tbl-- INFO: Pages 424: Changed 0, Empty 0; Tup 12291: Vac 0, Keep 0, UnUsed 6101. Total CPU 0.01s/0.00u sec elapsed 0.60 sec. INFO: --Relation pg_toast.pg_toast_891830-- INFO: Pages 89234: Changed 0, Empty 0; Tup 352823: Vac 0, Keep 0, UnUsed 5487. Total CPU 4.44s/0.34u sec elapsed 35.48 sec. VACUUM Cheers Jona Tom Lane wrote: >Jona writes: > > >>I'm currently experiencing problems with long query execution times. >>What I believe makes these problems particularly interesting is the >>difference in execution plans between our test server running PostGreSQL >>7.3.6 and our production server running PostGreSQL 7.3.9. >>The test server is an upgraded "home machine", a Pentium 4 with 1GB of >>memory and IDE disk. >>The production server is a dual CPU XEON Pentium 4 with 2GB memory and >>SCSI disks. >>One should expect the production server to be faster, but appearently >>not as the outlined query plans below shows. >> >> > >I think the plans are fine; it looks to me like the production server >has serious table-bloat or index-bloat problems, probably because of >inadequate vacuuming. For instance compare these entries: > >-> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4) > Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) > >-> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4) > Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) > >Appears to be exactly the same task ... but the test server spent >1.24 msec total while the production server spent 687.36 msec total. >That's more than half of your problem right there. Some of the other >scans seem a lot slower on the production machine too. > > > >>1) How come the query plans between the 2 servers are different? >> >> > >The production server's rowcount estimates are pretty good, the test >server's are not. How long since you vacuumed/analyzed the test server? > >It'd be interesting to see the output of "vacuum verbose statcon_tbl" >on both servers ... > > regards, tom lane > >PS: if you post any more query plans, please try to use software that >doesn't mangle the formatting so horribly ... > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > --------------040507010809080801070807 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Results of VACUUM VERBOSE from both servers

Test server:
comm=# VACUUM VERBOSE StatCon_Tbl;
INFO:  --Relation public.statcon_tbl--
INFO:  Pages 338: Changed 338, Empty 0; Tup 11494: Vac 0, Keep 0, UnUsed 0.
        Total CPU 0.02s/0.00u sec elapsed 0.04 sec.
INFO:  --Relation pg_toast.pg_toast_179851--
INFO:  Pages 85680: Changed 85680, Empty 0; Tup 343321: Vac 0, Keep 0, UnUsed 0.
        Total CPU 4.03s/0.40u sec elapsed 70.99 sec.
VACUUM

Live Server:
comm=# VACUUM VERBOSE StatCon_Tbl;
INFO:  --Relation public.statcon_tbl--
INFO:  Pages 424: Changed 0, Empty 0; Tup 12291: Vac 0, Keep 0, UnUsed 6101.
        Total CPU 0.01s/0.00u sec elapsed 0.60 sec.
INFO:  --Relation pg_toast.pg_toast_891830--
INFO:  Pages 89234: Changed 0, Empty 0; Tup 352823: Vac 0, Keep 0, UnUsed 5487.
        Total CPU 4.44s/0.34u sec elapsed 35.48 sec.
VACUUM

Cheers
Jona

Tom Lane wrote:
Jona <jonanews@oismail.com> writes:
  
I'm currently experiencing problems with long query execution times.
What I believe makes these problems particularly interesting is the 
difference in execution plans between our test server running PostGreSQL 
7.3.6 and our production server running PostGreSQL 7.3.9.
The test server is an upgraded "home machine", a Pentium 4 with 1GB of 
memory and IDE disk.
The production server is a dual CPU XEON Pentium 4 with 2GB memory and 
SCSI disks.
One should expect the production server to be faster, but appearently 
not as the outlined query plans below shows.
    

I think the plans are fine; it looks to me like the production server
has serious table-bloat or index-bloat problems, probably because of
inadequate vacuuming.  For instance compare these entries:

->  Index Scan using ctp_statcon on statcon_tbl  (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4)
      Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))

->  Index Scan using ctp_statcon on statcon_tbl  (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4)
      Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1))

Appears to be exactly the same task ... but the test server spent
1.24 msec total while the production server spent 687.36 msec total.
That's more than half of your problem right there.  Some of the other
scans seem a lot slower on the production machine too.

  
1) How come the query plans between the 2 servers are different?
    

The production server's rowcount estimates are pretty good, the test
server's are not.  How long since you vacuumed/analyzed the test server?

It'd be interesting to see the output of "vacuum verbose statcon_tbl"
on both servers ...

			regards, tom lane

PS: if you post any more query plans, please try to use software that
doesn't mangle the formatting so horribly ...

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
  
--------------040507010809080801070807-- From pgsql-performance-owner@postgresql.org Fri May 6 05:37:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1C70353315 for ; Fri, 6 May 2005 05:37:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67225-09 for ; Fri, 6 May 2005 08:37:36 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id A0DB153317 for ; Fri, 6 May 2005 05:37:30 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 8C09924FE0; Fri, 6 May 2005 16:37:29 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 7F69624FDF; Fri, 6 May 2005 16:37:29 +0800 (WST) Message-ID: <427B2D9E.2030804@familyhealth.com.au> Date: Fri, 06 May 2005 16:41:02 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jona Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 References: <4279ECC1.4050000@oismail.com> <24106.1115308954@sss.pgh.pa.us> <427B1E0A.3000108@oismail.com> In-Reply-To: <427B1E0A.3000108@oismail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.068 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/57 X-Sequence-Number: 12221 You didn't do analyze. Chris Jona wrote: > Results of VACUUM VERBOSE from both servers > > Test server: > comm=# VACUUM VERBOSE StatCon_Tbl; > INFO: --Relation public.statcon_tbl-- > INFO: Pages 338: Changed 338, Empty 0; Tup 11494: Vac 0, Keep 0, UnUsed 0. > Total CPU 0.02s/0.00u sec elapsed 0.04 sec. > INFO: --Relation pg_toast.pg_toast_179851-- > INFO: Pages 85680: Changed 85680, Empty 0; Tup 343321: Vac 0, Keep 0, > UnUsed 0. > Total CPU 4.03s/0.40u sec elapsed 70.99 sec. > VACUUM > > Live Server: > comm=# VACUUM VERBOSE StatCon_Tbl; > INFO: --Relation public.statcon_tbl-- > INFO: Pages 424: Changed 0, Empty 0; Tup 12291: Vac 0, Keep 0, UnUsed 6101. > Total CPU 0.01s/0.00u sec elapsed 0.60 sec. > INFO: --Relation pg_toast.pg_toast_891830-- > INFO: Pages 89234: Changed 0, Empty 0; Tup 352823: Vac 0, Keep 0, > UnUsed 5487. > Total CPU 4.44s/0.34u sec elapsed 35.48 sec. > VACUUM > > Cheers > Jona > > Tom Lane wrote: > >>Jona writes: >> >> >>>I'm currently experiencing problems with long query execution times. >>>What I believe makes these problems particularly interesting is the >>>difference in execution plans between our test server running PostGreSQL >>>7.3.6 and our production server running PostGreSQL 7.3.9. >>>The test server is an upgraded "home machine", a Pentium 4 with 1GB of >>>memory and IDE disk. >>>The production server is a dual CPU XEON Pentium 4 with 2GB memory and >>>SCSI disks. >>>One should expect the production server to be faster, but appearently >>>not as the outlined query plans below shows. >>> >>> >>I think the plans are fine; it looks to me like the production server >>has serious table-bloat or index-bloat problems, probably because of >>inadequate vacuuming. For instance compare these entries: >> >>-> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4) >> Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) >> >>-> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4) >> Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) >> >>Appears to be exactly the same task ... but the test server spent >>1.24 msec total while the production server spent 687.36 msec total. >>That's more than half of your problem right there. Some of the other >>scans seem a lot slower on the production machine too. >> >> >> >>>1) How come the query plans between the 2 servers are different? >>> >>> >>The production server's rowcount estimates are pretty good, the test >>server's are not. How long since you vacuumed/analyzed the test server? >> >>It'd be interesting to see the output of "vacuum verbose statcon_tbl" >>on both servers ... >> >> regards, tom lane >> >>PS: if you post any more query plans, please try to use software that >>doesn't mangle the formatting so horribly ... >> >>---------------------------(end of broadcast)--------------------------- >>TIP 4: Don't 'kill -9' the postmaster >> >> From pgsql-performance-owner@postgresql.org Fri May 6 06:28:55 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4A0015333B for ; Fri, 6 May 2005 06:28:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71865-09 for ; Fri, 6 May 2005 09:28:42 +0000 (GMT) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id 15CF253322 for ; Fri, 6 May 2005 06:28:40 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DTz1Z-0002zz-Pm for pgsql-performance@postgresql.org; Fri, 06 May 2005 11:21:33 +0200 Received: from srv.protecting.net ([212.126.218.242]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 May 2005 11:21:33 +0200 Received: from hf1122x by srv.protecting.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 May 2005 11:21:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: Harald Fuchs Subject: Re: COPY vs INSERT Date: 06 May 2005 11:27:43 +0200 Organization: Linux Private Site Lines: 25 Message-ID: References: <20050506065129.GL88920@decibel.org> Reply-To: hf1122x@protecting.net Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: srv.protecting.net User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/58 X-Sequence-Number: 12222 In article , Dennis Bjorklund writes: > On Fri, 6 May 2005, Jim C. Nasby wrote: >> Has thought been given to supporting inserting multiple rows in a single >> insert? DB2 supported: >> >> INSERT INTO table VALUES( >> (1,2,3), >> (4,5,6), >> (7,8,9) >> ); >> >> I'm not sure how standard that is or if other databases support it. > The sql standard include this, except that you can not have the outer (). > So it should be > INSERT INTO table VALUES > (1,2,3), > (4,5,6), > (7,8,9); Since MySQL has benn supporting this idiom for ages, it can't be standard ;-) From pgsql-performance-owner@postgresql.org Fri May 6 08:12:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 521B252A8B for ; Fri, 6 May 2005 08:12:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89362-01 for ; Fri, 6 May 2005 11:12:05 +0000 (GMT) Received: from taanari.planescape.cydev.biz (port259.ds1-brh.adsl.cybercity.dk [217.157.160.140]) by svr1.postgresql.org (Postfix) with ESMTP id 65AA152808 for ; Fri, 6 May 2005 08:12:03 -0300 (ADT) Received: from [10.0.0.2] ([217.157.160.140]) (authenticated user jona@cydev.biz) by taanari.planescape.cydev.biz (Kerio MailServer 5.7.1) (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)); Fri, 6 May 2005 13:14:55 +0200 Message-ID: <427B51AB.4060501@oismail.com> Date: Fri, 06 May 2005 13:14:51 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christopher Kings-Lynne Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 References: <4279ECC1.4050000@oismail.com> <24106.1115308954@sss.pgh.pa.us> <427B1E0A.3000108@oismail.com> <427B2D9E.2030804@familyhealth.com.au> In-Reply-To: <427B2D9E.2030804@familyhealth.com.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.139 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/59 X-Sequence-Number: 12223 Now with analyze Test Server: comm=# VACUUM ANALYZE VERBOSE StatCon_Tbl; INFO: --Relation public.statcon_tbl-- INFO: Pages 338: Changed 0, Empty 0; Tup 11494: Vac 0, Keep 0, UnUsed 0. Total CPU 0.02s/0.00u sec elapsed 1.98 sec. INFO: --Relation pg_toast.pg_toast_179851-- INFO: Pages 85680: Changed 0, Empty 0; Tup 343321: Vac 0, Keep 0, UnUsed 0. Total CPU 1.75s/0.23u sec elapsed 30.36 sec. INFO: Analyzing public.statcon_tbl VACUUM Live Server: comm=# VACUUM ANALYZE VERBOSE StatCon_Tbl; INFO: --Relation public.statcon_tbl-- INFO: Pages 424: Changed 0, Empty 0; Tup 12291: Vac 0, Keep 0, UnUsed 6101. Total CPU 0.00s/0.01u sec elapsed 0.01 sec. INFO: --Relation pg_toast.pg_toast_891830-- INFO: Pages 89234: Changed 0, Empty 0; Tup 352823: Vac 0, Keep 0, UnUsed 5487. Total CPU 3.21s/0.47u sec elapsed 18.03 sec. INFO: Analyzing public.statcon_tbl VACUUM Have done some sampling running the same query a few times through the past few hours and it appears that the VACUUM has helped. The following are the results after the Vacuum: After VACUUM VERBOSE: Index Scan using ctp_statcon on statcon_tbl (cost=0.00..21.29 rows=5 width=4) (actual time=0.07..0.37 rows=39 loops=4) Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) After VACUUM ANALYZE VERBOSE: Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.03 rows=5 width=4) (actual time=0.09..0.37 rows=39 loops=4) Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND (statcon_tbl.ctpid = 1)) Only question remains why one server uses its indexes and the other don't eventhough VACUUM ANALYZE has now been run on both servers? And even more interesting, before the VACUUM ANALYZEit was the server where no vacuum had taken place that used its index. Cheers Jona Christopher Kings-Lynne wrote: > You didn't do analyze. > > Chris > > Jona wrote: > >> Results of VACUUM VERBOSE from both servers >> >> Test server: >> comm=# VACUUM VERBOSE StatCon_Tbl; >> INFO: --Relation public.statcon_tbl-- >> INFO: Pages 338: Changed 338, Empty 0; Tup 11494: Vac 0, Keep 0, >> UnUsed 0. >> Total CPU 0.02s/0.00u sec elapsed 0.04 sec. >> INFO: --Relation pg_toast.pg_toast_179851-- >> INFO: Pages 85680: Changed 85680, Empty 0; Tup 343321: Vac 0, Keep >> 0, UnUsed 0. >> Total CPU 4.03s/0.40u sec elapsed 70.99 sec. >> VACUUM >> >> Live Server: >> comm=# VACUUM VERBOSE StatCon_Tbl; >> INFO: --Relation public.statcon_tbl-- >> INFO: Pages 424: Changed 0, Empty 0; Tup 12291: Vac 0, Keep 0, >> UnUsed 6101. >> Total CPU 0.01s/0.00u sec elapsed 0.60 sec. >> INFO: --Relation pg_toast.pg_toast_891830-- >> INFO: Pages 89234: Changed 0, Empty 0; Tup 352823: Vac 0, Keep 0, >> UnUsed 5487. >> Total CPU 4.44s/0.34u sec elapsed 35.48 sec. >> VACUUM >> >> Cheers >> Jona >> >> Tom Lane wrote: >> >>> Jona writes: >>> >>> >>>> I'm currently experiencing problems with long query execution times. >>>> What I believe makes these problems particularly interesting is the >>>> difference in execution plans between our test server running >>>> PostGreSQL 7.3.6 and our production server running PostGreSQL 7.3.9. >>>> The test server is an upgraded "home machine", a Pentium 4 with 1GB >>>> of memory and IDE disk. >>>> The production server is a dual CPU XEON Pentium 4 with 2GB memory >>>> and SCSI disks. >>>> One should expect the production server to be faster, but >>>> appearently not as the outlined query plans below shows. >>>> >>> >>> I think the plans are fine; it looks to me like the production server >>> has serious table-bloat or index-bloat problems, probably because of >>> inadequate vacuuming. For instance compare these entries: >>> >>> -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..6.01 >>> rows=1 width=4) (actual time=0.05..0.31 rows=39 loops=4) >>> Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND >>> (statcon_tbl.ctpid = 1)) >>> >>> -> Index Scan using ctp_statcon on statcon_tbl (cost=0.00..20.40 >>> rows=5 width=4) (actual time=27.97..171.84 rows=39 loops=4) >>> Index Cond: ((statcon_tbl.sctid = "outer".sctid) AND >>> (statcon_tbl.ctpid = 1)) >>> >>> Appears to be exactly the same task ... but the test server spent >>> 1.24 msec total while the production server spent 687.36 msec total. >>> That's more than half of your problem right there. Some of the other >>> scans seem a lot slower on the production machine too. >>> >>> >>> >>>> 1) How come the query plans between the 2 servers are different? >>>> >>> >>> The production server's rowcount estimates are pretty good, the test >>> server's are not. How long since you vacuumed/analyzed the test >>> server? >>> >>> It'd be interesting to see the output of "vacuum verbose statcon_tbl" >>> on both servers ... >>> >>> regards, tom lane >>> >>> PS: if you post any more query plans, please try to use software that >>> doesn't mangle the formatting so horribly ... >>> >>> ---------------------------(end of >>> broadcast)--------------------------- >>> TIP 4: Don't 'kill -9' the postmaster >>> >>> > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Fri May 6 09:18:28 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D5095533AE for ; Fri, 6 May 2005 09:18:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99179-02 for ; Fri, 6 May 2005 12:18:22 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 67081533AB for ; Fri, 6 May 2005 09:18:21 -0300 (ADT) Received: (qmail 17012 invoked by uid 500); 6 May 2005 12:38:31 -0000 Date: Fri, 6 May 2005 07:38:31 -0500 From: Bruno Wolff III To: "Jim C. Nasby" Cc: Tom Lane , Christopher Kings-Lynne , David Roussel , Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT Message-ID: <20050506123831.GA14417@wolff.to> Mail-Followup-To: "Jim C. Nasby" , Tom Lane , Christopher Kings-Lynne , David Roussel , Mischa Sandberg , pgsql-perform References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <42797C1A.3090303@familyhealth.com.au> <16747.1115259776@sss.pgh.pa.us> <20050506065129.GL88920@decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050506065129.GL88920@decibel.org> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/60 X-Sequence-Number: 12224 On Fri, May 06, 2005 at 01:51:29 -0500, "Jim C. Nasby" wrote: > On Wed, May 04, 2005 at 10:22:56PM -0400, Tom Lane wrote: > > Also, there is a whole lot of one-time-per-statement overhead that can > > be amortized across many rows instead of only one. Stuff like opening > > the target table, looking up the per-column I/O conversion functions, > > identifying trigger functions if any, yadda yadda. It's not *that* > > expensive, but compared to an operation as small as inserting a single > > row, it's significant. > > Has thought been given to supporting inserting multiple rows in a single > insert? DB2 supported: > > INSERT INTO table VALUES( > (1,2,3), > (4,5,6), > (7,8,9) > ); > > I'm not sure how standard that is or if other databases support it. It's on the TODO list. I don't remember anyone bringing this up for about a year now, so I doubt anyone is actively working on it. From pgsql-performance-owner@postgresql.org Fri May 6 10:52:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DADC953422 for ; Fri, 6 May 2005 10:52:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12147-07 for ; Fri, 6 May 2005 13:52:11 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id EAA275337C for ; Fri, 6 May 2005 10:52:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j46Dptqc013783; Fri, 6 May 2005 09:51:55 -0400 (EDT) To: Bruno Wolff III Cc: "Jim C. Nasby" , Christopher Kings-Lynne , David Roussel , Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT In-reply-to: <20050506123831.GA14417@wolff.to> References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <42797C1A.3090303@familyhealth.com.au> <16747.1115259776@sss.pgh.pa.us> <20050506065129.GL88920@decibel.org> <20050506123831.GA14417@wolff.to> Comments: In-reply-to Bruno Wolff III message dated "Fri, 06 May 2005 07:38:31 -0500" Date: Fri, 06 May 2005 09:51:55 -0400 Message-ID: <13782.1115387515@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/61 X-Sequence-Number: 12225 Bruno Wolff III writes: > "Jim C. Nasby" wrote: >> Has thought been given to supporting inserting multiple rows in a single >> insert? > It's on the TODO list. I don't remember anyone bringing this up for about > a year now, so I doubt anyone is actively working on it. It is on TODO but I think it is only there for standards compliance. It won't produce near as much of a speedup as using COPY does --- in particular, trying to put thousands of rows through at once with such a command would probably be a horrible idea. You'd still have to pay the price of lexing/parsing, and there would also be considerable flailing about with deducing the data type of the VALUES() construct. (Per spec that can be used in SELECT FROM, not only in INSERT, and so it's not clear to what extent we can use knowledge of the insert target columns to avoid running the generic union-type-resolution algorithm for each column of the VALUES() :-(.) Add on the price of shoving an enormous expression tree through the planner and executor, and it starts to sound pretty grim. regards, tom lane From pgsql-performance-owner@postgresql.org Fri May 6 10:59:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ACF515334D for ; Fri, 6 May 2005 10:59:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15516-01 for ; Fri, 6 May 2005 13:59:47 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9272853421 for ; Fri, 6 May 2005 10:59:47 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j46DxiqR013859; Fri, 6 May 2005 09:59:44 -0400 (EDT) To: Jona Cc: Christopher Kings-Lynne , pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 In-reply-to: <427B51AB.4060501@oismail.com> References: <4279ECC1.4050000@oismail.com> <24106.1115308954@sss.pgh.pa.us> <427B1E0A.3000108@oismail.com> <427B2D9E.2030804@familyhealth.com.au> <427B51AB.4060501@oismail.com> Comments: In-reply-to Jona message dated "Fri, 06 May 2005 13:14:51 +0200" Date: Fri, 06 May 2005 09:59:43 -0400 Message-ID: <13858.1115387983@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/62 X-Sequence-Number: 12226 Jona writes: > Test Server: > comm=# VACUUM ANALYZE VERBOSE StatCon_Tbl; > INFO: --Relation public.statcon_tbl-- > INFO: Pages 338: Changed 0, Empty 0; Tup 11494: Vac 0, Keep 0, UnUsed 0. > Total CPU 0.02s/0.00u sec elapsed 1.98 sec. > INFO: --Relation pg_toast.pg_toast_179851-- > INFO: Pages 85680: Changed 0, Empty 0; Tup 343321: Vac 0, Keep 0, UnUsed 0. > Total CPU 1.75s/0.23u sec elapsed 30.36 sec. > INFO: Analyzing public.statcon_tbl > VACUUM > Live Server: > comm=# VACUUM ANALYZE VERBOSE StatCon_Tbl; > INFO: --Relation public.statcon_tbl-- > INFO: Pages 424: Changed 0, Empty 0; Tup 12291: Vac 0, Keep 0, UnUsed 6101. > Total CPU 0.00s/0.01u sec elapsed 0.01 sec. > INFO: --Relation pg_toast.pg_toast_891830-- > INFO: Pages 89234: Changed 0, Empty 0; Tup 352823: Vac 0, Keep 0, > UnUsed 5487. > Total CPU 3.21s/0.47u sec elapsed 18.03 sec. > INFO: Analyzing public.statcon_tbl > VACUUM Hm, the physical table sizes aren't very different, which suggests that the problem must lie with the indexes. Unfortunately, VACUUM in 7.3 doesn't tell you anything about indexes if it doesn't have any dead rows to clean up. Could you look at pg_class.relpages for all the indexes of this table, and see what that shows? regards, tom lane From pgsql-docs-owner@postgresql.org Fri May 6 11:44:25 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B3B0453456 for ; Fri, 6 May 2005 11:44:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21451-05 for ; Fri, 6 May 2005 14:44:19 +0000 (GMT) Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) by svr1.postgresql.org (Postfix) with ESMTP id 3C7445345A for ; Fri, 6 May 2005 11:44:15 -0300 (ADT) Received: from jefftrout.com ([24.61.201.181]) by comcast.net (rwcrmhc12) with SMTP id <2005050614441901400fvcdse>; Fri, 6 May 2005 14:44:20 +0000 Received: (qmail 86402 invoked from network); 6 May 2005 14:46:26 -0000 Received: from waltham-nat.ma.lycos.com (HELO ?10.124.7.97?) (209.202.205.1) by 192.168.0.109 with SMTP; 6 May 2005 14:46:26 -0000 Mime-Version: 1.0 (Apple Message framework v728) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: pgsql-docs@postgresql.org From: Jeff - Subject: SELinux & Redhat Date: Fri, 6 May 2005 10:43:49 -0400 X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.178 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP, RCVD_IN_SORBS_DUL X-Spam-Level: X-Archive-Number: 200505/2 X-Sequence-Number: 2967 I think we should put some notes about SELinux causing issues with pgsql in the OS notes or FAQ. Myself and a few coworkers just spent a few hours tracking down why pg_dump would produce no output. We'd fire it up in strace and we'd see all the successful write calls, but not output. We copied pg_dump from another machine and it worked fine, and that machine was running the same OS & pg rpms. Eventually we found it was SELinux was preventing pg_dump from producing output. Any thoughts? I could write up a short blurb but I'm not terribly familiar with selinux. we just disabled the whole thing to make it work. For the record: CentOS 4.0 postgresql-8.0.2-1PGDG.i686.rpm (and associated) rpms from postgresql.org's ftp server -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-docs-owner@postgresql.org Fri May 6 11:55:48 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CF6D253338 for ; Fri, 6 May 2005 11:55:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23986-04 for ; Fri, 6 May 2005 14:55:37 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id 48A07533F1 for ; Fri, 6 May 2005 11:55:36 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j46Etej28299; Fri, 6 May 2005 10:55:40 -0400 (EDT) From: Bruce Momjian Message-Id: <200505061455.j46Etej28299@candle.pha.pa.us> Subject: Re: SELinux & Redhat In-Reply-To: To: Jeff - Date: Fri, 6 May 2005 10:55:40 -0400 (EDT) Cc: pgsql-docs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/3 X-Sequence-Number: 2968 Jeff - wrote: > I think we should put some notes about SELinux causing issues with > pgsql in the OS notes or FAQ. > > Myself and a few coworkers just spent a few hours tracking down why > pg_dump would produce no output. We'd fire it up in strace and we'd > see all the successful write calls, but not output. > > We copied pg_dump from another machine and it worked fine, and that > machine was running the same OS & pg rpms. > > Eventually we found it was SELinux was preventing pg_dump from > producing output. > > Any thoughts? I could write up a short blurb but I'm not terribly > familiar with selinux. we just disabled the whole thing to make it work. > > For the record: > CentOS 4.0 > postgresql-8.0.2-1PGDG.i686.rpm (and associated) rpms from > postgresql.org's ftp server A blurb about what? No one else has reported such a problem so we have no reason to assume it isn't a misconfiguration on your end. -- 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-docs-owner@postgresql.org Fri May 6 12:13:48 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DF0115341D for ; Fri, 6 May 2005 12:13:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26967-02 for ; Fri, 6 May 2005 15:13:37 +0000 (GMT) Received: from gauss.credativ.com (ipx11302.ipxserver.de [212.112.227.254]) by svr1.postgresql.org (Postfix) with ESMTP id DEEE353418 for ; Fri, 6 May 2005 12:13:35 -0300 (ADT) Received: from bell.credativ.de (p508912BE.dip0.t-ipconnect.de [80.137.18.190]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by gauss.credativ.com (Postfix) with ESMTP id E83D2D77B4; Fri, 6 May 2005 17:14:41 +0200 (CEST) From: Peter Eisentraut To: Bruce Momjian Subject: Re: SELinux & Redhat Date: Fri, 6 May 2005 17:13:39 +0200 User-Agent: KMail/1.7.2 Cc: Jeff - , pgsql-docs@postgresql.org References: <200505061455.j46Etej28299@candle.pha.pa.us> In-Reply-To: <200505061455.j46Etej28299@candle.pha.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505061713.40511.peter_e@gmx.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/4 X-Sequence-Number: 2969 Am Freitag, 6. Mai 2005 16:55 schrieb Bruce Momjian: > A blurb about what? No one else has reported such a problem so we have > no reason to assume it isn't a misconfiguration on your end. *Countless* people are constantly reporting problems that can be attributed to selinux. We really need to write something about it. Of course, most people, including myself, just solve these issues by turning off selinux, but I'd be interested in a more thorough treatment. -- Peter Eisentraut http://developer.postgresql.org/~petere/ From pgsql-docs-owner@postgresql.org Fri May 6 12:21:40 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AFC6053493 for ; Fri, 6 May 2005 12:21:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28922-04 for ; Fri, 6 May 2005 15:21:34 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id A9D05534A5 for ; Fri, 6 May 2005 12:21:33 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j46FLQI02857; Fri, 6 May 2005 11:21:26 -0400 (EDT) From: Bruce Momjian Message-Id: <200505061521.j46FLQI02857@candle.pha.pa.us> Subject: Re: SELinux & Redhat In-Reply-To: <200505061713.40511.peter_e@gmx.net> To: Peter Eisentraut Date: Fri, 6 May 2005 11:21:26 -0400 (EDT) Cc: Jeff - , pgsql-docs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/5 X-Sequence-Number: 2970 Peter Eisentraut wrote: > Am Freitag, 6. Mai 2005 16:55 schrieb Bruce Momjian: > > A blurb about what? No one else has reported such a problem so we have > > no reason to assume it isn't a misconfiguration on your end. > > *Countless* people are constantly reporting problems that can be attributed to > selinux. We really need to write something about it. Of course, most > people, including myself, just solve these issues by turning off selinux, but > I'd be interested in a more thorough treatment. Who makes SE Linux? Is it SuSE? What would we say in an FAQ? I would rather report something to people using that OS. -- 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-docs-owner@postgresql.org Fri May 6 12:24:07 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 830CE53493 for ; Fri, 6 May 2005 12:24:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28739-05 for ; Fri, 6 May 2005 15:23:56 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8CF5753379 for ; Fri, 6 May 2005 12:23:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j46FNsqZ014696; Fri, 6 May 2005 11:23:54 -0400 (EDT) To: Jeff - Cc: pgsql-docs@postgresql.org Subject: Re: SELinux & Redhat In-reply-to: References: Comments: In-reply-to Jeff - message dated "Fri, 06 May 2005 10:43:49 -0400" Date: Fri, 06 May 2005 11:23:54 -0400 Message-ID: <14695.1115393034@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/6 X-Sequence-Number: 2971 Jeff - writes: > Eventually we found it was SELinux was preventing pg_dump from > producing output. That's a new one on me. Why was it doing that --- mislabeling on the pg_dump executable, or what? regards, tom lane From pgsql-docs-owner@postgresql.org Fri May 6 12:28:50 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0D9BB53418 for ; Fri, 6 May 2005 12:28:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29821-07 for ; Fri, 6 May 2005 15:28:47 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A226A5341D for ; Fri, 6 May 2005 12:28:47 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j46FSg1J014760; Fri, 6 May 2005 11:28:42 -0400 (EDT) To: Peter Eisentraut Cc: Bruce Momjian , Jeff - , pgsql-docs@postgresql.org Subject: Re: SELinux & Redhat In-reply-to: <200505061713.40511.peter_e@gmx.net> References: <200505061455.j46Etej28299@candle.pha.pa.us> <200505061713.40511.peter_e@gmx.net> Comments: In-reply-to Peter Eisentraut message dated "Fri, 06 May 2005 17:13:39 +0200" Date: Fri, 06 May 2005 11:28:42 -0400 Message-ID: <14759.1115393322@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/7 X-Sequence-Number: 2972 Peter Eisentraut writes: > Am Freitag, 6. Mai 2005 16:55 schrieb Bruce Momjian: >> A blurb about what? No one else has reported such a problem so we have >> no reason to assume it isn't a misconfiguration on your end. > *Countless* people are constantly reporting problems that can be > attributed to selinux. That's mostly because selinux outright broke postgres in the initial FC3 releases :-(. I have to take most of the blame for this myself; I didn't realize there might be problems, and didn't test adequately. I believe the problems are all resolved in the latest Fedora RPMs, though this pg_dump report may be something new. regards, tom lane From pgsql-docs-owner@postgresql.org Fri May 6 12:33:31 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 93A0052808 for ; Fri, 6 May 2005 12:33:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31309-01 for ; Fri, 6 May 2005 15:33:27 +0000 (GMT) Received: from emo.org.tr (unknown [195.142.106.94]) by svr1.postgresql.org (Postfix) with ESMTP id 7DEEE53497 for ; Fri, 6 May 2005 12:33:26 -0300 (ADT) Received: by emo.org.tr (Postfix, from userid 41643) id 084352FD9C; Fri, 6 May 2005 18:33:21 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by emo.org.tr (Postfix) with ESMTP id EA3B71122BD; Fri, 6 May 2005 18:33:21 +0300 (EEST) Date: Fri, 6 May 2005 18:33:20 +0300 (EEST) From: Devrim GUNDUZ X-X-Sender: devrim2@emo.org.tr To: Tom Lane Cc: Jeff - , pgsql-docs@postgresql.org Subject: Re: SELinux & Redhat In-Reply-To: <14695.1115393034@sss.pgh.pa.us> Message-ID: References: <14695.1115393034@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.058 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/8 X-Sequence-Number: 2973 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, On Fri, 6 May 2005, Tom Lane wrote: > Jeff - writes: >> Eventually we found it was SELinux was preventing pg_dump from >> producing output. > > That's a new one on me. Why was it doing that --- mislabeling on > the pg_dump executable, or what? Looking at the strace report that someone has sent me before, there is a problem with devices: =================================================================== fstat64(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfe16a8c) = -1 ENOTTY (Inappropriate ioctl for device) mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7dee000 write(1, "pg_dump dumps a database as a te"..., 2367) = 2367 munmap(0xb7dee000, 4096) = 0 exit_group(0) = ? =================================================================== This one is from a server with SELinux enabled. My server does not produce this, and uses virtual console (as expected?). However with SELinux enabled, it wants to use ramdisk (expected? I think no...) Regards, - -- Devrim GUNDUZ devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr http://www.tdmsoft.com.tr http://www.gunduz.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFCe45Btl86P3SPfQ4RAhpbAJ0UhBh8dlOEpPsNm2NB1QIJ82X2swCg7JOg A1OCBrZRHxoOPQo0U9hNdNY= =ENTC -----END PGP SIGNATURE----- From pgsql-docs-owner@postgresql.org Fri May 6 12:43:00 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA34153414 for ; Fri, 6 May 2005 12:42:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30865-06 for ; Fri, 6 May 2005 15:42:50 +0000 (GMT) Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) by svr1.postgresql.org (Postfix) with ESMTP id C2D8852A37 for ; Fri, 6 May 2005 12:42:49 -0300 (ADT) Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) by sunsite.dcc.uchile.cl (8.13.4/8.12.11) with ESMTP id j46FgcXQ022207; Fri, 6 May 2005 11:42:38 -0400 (CLT) Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) id 29DC6523AF; Fri, 6 May 2005 11:42:38 -0400 (CLT) Date: Fri, 6 May 2005 11:42:38 -0400 From: Alvaro Herrera To: Bruce Momjian Cc: Peter Eisentraut , Jeff - , pgsql-docs@postgresql.org Subject: Re: SELinux & Redhat Message-ID: <20050506154238.GF9796@dcc.uchile.cl> References: <200505061713.40511.peter_e@gmx.net> <200505061521.j46FLQI02857@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200505061521.j46FLQI02857@candle.pha.pa.us> User-Agent: Mutt/1.5.8i X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (sunsite.dcc.uchile.cl [192.80.24.2]); Fri, 06 May 2005 11:42:38 -0400 (CLT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.34 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200505/9 X-Sequence-Number: 2974 On Fri, May 06, 2005 at 11:21:26AM -0400, Bruce Momjian wrote: > Peter Eisentraut wrote: > > Am Freitag, 6. Mai 2005 16:55 schrieb Bruce Momjian: > > > A blurb about what? No one else has reported such a problem so we have > > > no reason to assume it isn't a misconfiguration on your end. > > > > *Countless* people are constantly reporting problems that can be attributed to > > selinux. We really need to write something about it. Of course, most > > people, including myself, just solve these issues by turning off selinux, but > > I'd be interested in a more thorough treatment. > > Who makes SE Linux? Is it SuSE? What would we say in an FAQ? I would > rather report something to people using that OS. It's linux-distribution agnostic. Redhat is including it on its distributions, as is Debian. Not sure about the others but that is already a large population. (Of course it's Linux only.) -- Alvaro Herrera () "Aprende a avergonzarte m�s ante ti que ante los dem�s" (Dem�crito) From pgsql-docs-owner@postgresql.org Fri May 6 12:47:07 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2225D5323F for ; Fri, 6 May 2005 12:47:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30847-09 for ; Fri, 6 May 2005 15:46:58 +0000 (GMT) Received: from rwcrmhc14.comcast.net (rwcrmhc14.comcast.net [216.148.227.89]) by svr1.postgresql.org (Postfix) with ESMTP id 06FA85349B for ; Fri, 6 May 2005 12:46:57 -0300 (ADT) Received: from jefftrout.com ([24.61.201.181]) by comcast.net (rwcrmhc14) with SMTP id <200505061546550140086o9de>; Fri, 6 May 2005 15:46:56 +0000 Received: (qmail 87445 invoked from network); 6 May 2005 15:49:03 -0000 Received: from waltham-nat.ma.lycos.com (HELO ?10.124.7.97?) (209.202.205.1) by 192.168.0.109 with SMTP; 6 May 2005 15:49:03 -0000 In-Reply-To: <14695.1115393034@sss.pgh.pa.us> References: <14695.1115393034@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> Cc: pgsql-docs@postgresql.org Content-Transfer-Encoding: 7bit From: Jeff - Subject: Re: SELinux & Redhat Date: Fri, 6 May 2005 11:46:26 -0400 To: Tom Lane X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.177 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP, RCVD_IN_SORBS_DUL X-Spam-Level: X-Archive-Number: 200505/10 X-Sequence-Number: 2975 On May 6, 2005, at 11:23 AM, Tom Lane wrote: > Jeff - writes: > >> Eventually we found it was SELinux was preventing pg_dump from >> producing output. >> > > That's a new one on me. Why was it doing that --- mislabeling on > the pg_dump executable, or what? > We've got a stock CentOS 4 install I nabbed the rpms I mentioned (8.0.2) (-rw-r--r-- 1 root root 2955126 May 4 11:51 postgresql-8.0.2-1PGDG.i686.rpm & company) from /etc/selinux/targeted/contexts/files/file_contexts I see file_contexts:/usr/bin/pg_dump -- system_u:object_r:postgresql_exec_t file_contexts:/usr/bin/pg_dumpall -- system_u:object_r:postgresql_exec_t Syslog logs: May 6 09:01:25 starslice kernel: audit(1115384485.559:0): avc: denied { execute_no_trans } for pid=4485 exe=/bin/bash path=/usr/ bin/pg_dump dev=sda3 ino=5272966 scontext=user_u:system_r:postgresql_t tcontext=system_u:object_r:postgresql_exec_t tclass=file SELinux is on and under system-config-securitylevel's selinux tab, "SELinux Protection services" disable postgresql is not clicked. When I run pg_dump w/these settings the following happens running pg_dump (.broken is hte original file from the rpm) bash-3.00$ /usr/bin/pg_dump.broken planet bash-3.00$ Stracing it I get .... write(1, "file_pkey; Type: CONSTRAINT; Sch"..., 4096) = 4096 write(1, "\n-- Name: userprofile_pkey; Type"..., 4096) = 4096 write(1, "_idx_1 OWNER TO planet;\n\n--\n-- N"..., 4096) = 4096 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0 send(3, "X\0\0\0\4", 5, 0) = 5 rt_sigaction(SIGPIPE, {SIG_DFL}, {SIG_IGN}, 8) = 0 close(3) = 0 write(1, "me: top3_cmtcount_idx; Type: IND"..., 3992) = 3992 munmap(0xb7df0000, 4096) = 0 exit_group(0) = ? and what is interesting is it seems only sometimes things get logged to syslog about the failure. If I copy the file (not mv) it will work (possibly due to xattrs being set?) and if I disable pg checking, (or selinux all together) it works. COOL, HUH? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-docs-owner@postgresql.org Fri May 6 12:57:52 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 289845343D for ; Fri, 6 May 2005 12:57:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32973-06 for ; Fri, 6 May 2005 15:57:48 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4091953419 for ; Fri, 6 May 2005 12:57:47 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j46FvlgT015122; Fri, 6 May 2005 11:57:47 -0400 (EDT) To: Jeff - Cc: pgsql-docs@postgresql.org Subject: Re: SELinux & Redhat In-reply-to: <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> Comments: In-reply-to Jeff - message dated "Fri, 06 May 2005 11:46:26 -0400" Date: Fri, 06 May 2005 11:57:47 -0400 Message-ID: <15121.1115395067@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/11 X-Sequence-Number: 2976 Jeff - writes: > When I run pg_dump w/these settings the following happens running > pg_dump (.broken is hte original file from the rpm) > bash-3.00$ /usr/bin/pg_dump.broken planet > bash-3.00$ Does it work if you direct the output into a file, instead of letting it come to your terminal (which seems a bit useless anyway)? I've been bugging dwalsh about the fact that the selinux policy disallows writes to /dev/tty to things it thinks are daemons; that seems pretty stupid. But pg_dump isn't a daemon so there's no reason for it to be restricted this way anyway... > and what is interesting is it seems only sometimes things get logged > to syslog about the failure. Someone told me there's a rate limit on selinux complaints going to syslog, to keep it from swamping your logs. I suspect there are some actual bugs there too, because I've noticed cases where an action was blocked and there wasn't any log message, nor enough activity to justify a rate limit. Feel free to file a bugzilla report if you can get a reproducible case. regards, tom lane From pgsql-docs-owner@postgresql.org Fri May 6 14:45:08 2005 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8B86E534FF for ; Fri, 6 May 2005 14:45:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49348-08 for ; Fri, 6 May 2005 17:45:04 +0000 (GMT) Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by svr1.postgresql.org (Postfix) with ESMTP id E5FF6534F5 for ; Fri, 6 May 2005 14:45:02 -0300 (ADT) Received: from jefftrout.com ([24.61.201.181]) by comcast.net (sccrmhc11) with SMTP id <2005050617445801100ilok1e>; Fri, 6 May 2005 17:44:59 +0000 Received: (qmail 88679 invoked from network); 6 May 2005 17:40:25 -0000 Received: from waltham-nat.ma.lycos.com (HELO ?10.124.7.97?) (209.202.205.1) by 192.168.0.109 with SMTP; 6 May 2005 17:40:25 -0000 In-Reply-To: <15121.1115395067@sss.pgh.pa.us> References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-docs@postgresql.org Content-Transfer-Encoding: 7bit From: Jeff - Subject: Re: SELinux & Redhat Date: Fri, 6 May 2005 13:37:49 -0400 To: Tom Lane X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.177 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP, RCVD_IN_SORBS_DUL X-Spam-Level: X-Archive-Number: 200505/12 X-Sequence-Number: 2977 On May 6, 2005, at 11:57 AM, Tom Lane wrote: >> bash-3.00$ /usr/bin/pg_dump.broken planet >> bash-3.00$ >> > > Does it work if you direct the output into a file, instead of > letting it > come to your terminal (which seems a bit useless anyway)? > Interesting. Redirecting it worked, but I'm pretty sure at one point it didn't work. (I could also be smoking crack). Hmm.. piping it into another app worked. I only found out about this when another developer here tried to run it and got nothing. in any case, it might be something useful to jot somewhere. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-sql-owner@postgresql.org Fri May 6 16:48:38 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A8CA5355C for ; Fri, 6 May 2005 16:48:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82449-09 for ; Fri, 6 May 2005 19:48:35 +0000 (GMT) Received: from balrog.csolve.net (diablo.csolve.net [207.61.27.158]) by svr1.postgresql.org (Postfix) with ESMTP id 8626653574 for ; Fri, 6 May 2005 16:48:34 -0300 (ADT) Received: from [10.10.18.126] (helo=[10.10.18.126]) by balrog.csolve.net with esmtp (Exim 4.50 (FreeBSD)) id 1DU8oN-000HA7-Az for pgsql-sql@postgresql.org; Fri, 06 May 2005 15:48:35 -0400 Message-ID: <427BCA10.4090208@csolve.net> Date: Fri, 06 May 2005 15:48:32 -0400 From: Derek Buttineau|Compu-SOLVE Organization: Compu-SOLVE Internet Services User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050328) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: ORDER BY Optimization Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/56 X-Sequence-Number: 21369 Good Day, I'm hoping this is the right place to send this. I have a query that's causing me some grief trying to optimize it. The query cost is fine until I order the data set. Mind you after it's been ran and cached, subsequent calls to it are near instant. The Query in question is: select mr.*,m.* from maillog_received mr JOIN maillog m ON mr.maillog_id = m.id WHERE mr.subscription=89 and m.spam=1 ORDER BY m.msg_date desc limit 10 The strucutre of the tables involved in the query are as follows: Table "public.maillog_received" Column | Type | Modifiers --------------+------------------------+------------------------------------------------------------------ id | integer | not null default nextval('public.maillog_received_id_seq'::text) maillog_id | bigint | not null subscription | integer | not null local_part | character varying(255) | not null domain | character varying(255) | not null Indexes: "maillog_received_pkey" PRIMARY KEY, btree (id) "maillog_received_subscription_idx" btree (subscription) "maillog_received_subscription_maillog_id_idx" btree (subscription, maillog_id) Foreign-key constraints: "$1" FOREIGN KEY (subscription) REFERENCES subscriptions(id) ON DELETE CASCADE "$2" FOREIGN KEY (maillog_id) REFERENCES maillog(id) ON DELETE CASCADE Triggers: checkit BEFORE INSERT OR UPDATE ON maillog_received FOR EACH ROW EXECUTE PROCEDURE check_sub() Table "public.maillog" Column | Type | Modifiers -----------------+-----------------------------+--------------------------------------------------------- id | bigint | not null default nextval('public.maillog_id_seq'::text) message_id | character varying(16) | msg_date | timestamp without time zone | not null from_local_part | character varying(255) | not null from_domain | character varying(255) | not null from_ip | character varying(128) | from_host | character varying(255) | subject | character varying(255) | virus | integer | not null default 0 spam | integer | not null default 0 list | integer | not null default 0 bad_recipient | integer | not null default 0 bad_sender | integer | not null default 0 bad_relay | integer | not null default 0 bad_file | integer | not null default 0 bad_mime | integer | not null default 0 sascore | numeric(7,2) | sareport | text | vscanreport | text | contentreport | text | bypassed | integer | not null default 0 delivered | integer | not null default 1 complete | integer | not null default 1 Indexes: "maillog_pkey" PRIMARY KEY, btree (id) "maillog_msg_date_idx" btree (msg_date) EXPLAIN ANALYZE gives me the following: Limit (cost=31402.85..31402.87 rows=10 width=306) (actual time=87454.203..87454.334 rows=10 loops=1) -> Sort (cost=31402.85..31405.06 rows=886 width=306) (actual time=87454.187..87454.240 rows=10 loops=1) Sort Key: m.msg_date -> Nested Loop (cost=0.00..31359.47 rows=886 width=306) (actual time=4.740..86430.468 rows=26308 loops=1) -> Index Scan using maillog_received_subscription_idx on maillog_received mr (cost=0.00..17789.73 rows=4479 width=43) (actual time=0.030..33554.061 rows=65508 loops=1) Index Cond: (subscription = 89) -> Index Scan using maillog_pkey on maillog m (cost=0.00..3.02 rows=1 width=263) (actual time=0.776..0.780 rows=0 loops=65508) Index Cond: ("outer".maillog_id = m.id) Filter: (spam = 1) Total runtime: 87478.068 ms Now there is a lot of data in these tables, at least a few million records, but I'd hoped to get a bit better performance :) Now another odd thing I will mention, if I take the database schema to a second server (both running postgres 8.0.2 on FreeBSD 5.3), I get a much different (and to me, it looks much more effecient) query plan (though it's with substantially less data (about 500,000 records in the table)): Limit (cost=0.00..6482.60 rows=10 width=311) (actual time=25.340..26.885 rows=10 loops=1) -> Nested Loop (cost=0.00..1175943.99 rows=1814 width=311) (actual time=25.337..26.867 rows=10 loops=1) -> Index Scan Backward using maillog_msg_date_idx on maillog m (cost=0.00..869203.93 rows=51395 width=270) (actual time=25.156..26.050 rows=48 loops=1) Filter: (spam = 1) -> Index Scan using maillog_received_subscription_maillog_id_idx on maillog_received mr (cost=0.00..5.96 rows=1 width=41) (actual time=0.011..0.012 rows=0 loops=48) Index Cond: ((mr.subscription = 89) AND (mr.maillog_id = "outer".id)) Total runtime: 27.016 ms Any suggestions? -- Regards, Derek Buttineau Internet Systems Developer Compu-SOLVE Internet Services Compu-SOLVE Technologies Inc. 705.725.1212 x255 From pgsql-performance-owner@postgresql.org Fri May 6 17:35:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DA88153379 for ; Fri, 6 May 2005 17:35:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89990-06 for ; Fri, 6 May 2005 20:35:28 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) by svr1.postgresql.org (Postfix) with ESMTP id C223952A62 for ; Fri, 6 May 2005 17:35:28 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so233744wri for ; Fri, 06 May 2005 13:35:30 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rMDQ5ur5u03VR1323qgCccny1BzZr/waSc4fDjG/77yJ+73gpF2RywbYytoWxi7f6bkmGQCK+FrTycpxeMJkp2h0FFL9Rs5wmsIvxn28WUQ7Z1rH3eiq6cm4L3w6n/atGO38R9p+dYqC9675PVfvS7816562ve1q9Gm2GyyS79o= Received: by 10.54.84.2 with SMTP id h2mr1056364wrb; Fri, 06 May 2005 13:35:30 -0700 (PDT) Received: by 10.54.99.14 with HTTP; Fri, 6 May 2005 13:35:30 -0700 (PDT) Message-ID: <37d451f7050506133534923deb@mail.gmail.com> Date: Fri, 6 May 2005 15:35:30 -0500 From: Rosser Schwarz Reply-To: Rosser Schwarz To: Derek Buttineau|Compu-SOLVE Subject: Re: [SQL] ORDER BY Optimization Cc: pgsql-sql@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <427BCA10.4090208@csolve.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <427BCA10.4090208@csolve.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.28 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/63 X-Sequence-Number: 12227 while you weren't looking, Derek Buttineau|Compu-SOLVE wrote: > I'm hoping this is the right place to send this. The PostgreSQL Performance list, pgsql-performance@postgresql.org would be more appropriate. I'm copying my followup there, as well. As for your query, almost all the time is actually spent in the nestloop, not the sort. Compare: > -> Sort (cost=3D31402.85..31405.06 rows=3D886 width=3D306) (actual > time=3D87454.187..87454.240 rows=3D10 loops=3D1) vs. > -> Nested Loop (cost=3D0.00..31359.47 rows=3D886 width=3D306) > (actual time=3D4.740..86430.468 rows=3D26308 loops=3D1) That's 50-ish ms versus 80-odd seconds. It seems to me a merge join might be more appropriate here than a nestloop. What's your work_mem set at? Off-the-cuff numbers show the dataset weighing in the sub-ten mbyte range. Provided it's not already at least that big, and you don't want to up it permanently, try saying: SET work_mem =3D 10240; -- 10 mbytes immediately before running this query (uncached, of course) and see what happens. Also, your row-count estimates look pretty off-base. When were these tables last VACUUMed or ANALYZEd? /rls --=20 :wq From pgsql-performance-owner@postgresql.org Fri May 6 17:59:28 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 86B34533E9; Fri, 6 May 2005 17:55:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27930-06; Fri, 6 May 2005 20:54:59 +0000 (GMT) Received: from frodo.csolve.net (frodo.csolve.net [207.164.81.3]) by svr1.postgresql.org (Postfix) with ESMTP id 639DA533C6; Fri, 6 May 2005 17:54:56 -0300 (ADT) Received: from omega.csolve.net ([207.164.80.136] helo=[10.10.18.126]) by frodo.csolve.net with esmtp (Exim 4.24) id 1DU9qb-0006Rd-Er; Fri, 06 May 2005 16:54:57 -0400 Message-ID: <427BD9A1.3090901@csolve.net> Date: Fri, 06 May 2005 16:54:57 -0400 From: Derek Buttineau|Compu-SOLVE Organization: Compu-SOLVE Internet Services User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050328) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rosser Schwarz Cc: pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [SQL] ORDER BY Optimization References: <427BCA10.4090208@csolve.net> <37d451f7050506133534923deb@mail.gmail.com> In-Reply-To: <37d451f7050506133534923deb@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/64 X-Sequence-Number: 12228 Thanks for the response :) >That's 50-ish ms versus 80-odd seconds. > >It seems to me a merge join might be more appropriate here than a >nestloop. What's your work_mem set at? Off-the-cuff numbers show the >dataset weighing in the sub-ten mbyte range. > >Provided it's not already at least that big, and you don't want to up >it permanently, try saying: > >SET work_mem = 10240; -- 10 mbytes > > It's currently set at 16mb, I've also tried upping sort_mem as well without any noticible impact on the uncached query. :( >immediately before running this query (uncached, of course) and see >what happens. > >Also, your row-count estimates look pretty off-base. When were these >tables last VACUUMed or ANALYZEd? > > I'm not entirely sure what's up with the row-count estimates, the tables are updated quite frequently (and VACUUM is also run quite frequently), however I had just run a VACUUM ANALYZE on both databases before running the explain. I'm also still baffled at the differences in the plans between the two servers, on the one that uses the index to sort, I get for comparison a nestloop of: Nested Loop (cost=0.00..1175943.99 rows=1814 width=311) (actual time=25.337..26.867 rows=10 loops=1) The plan that the "live" server seems to be using seems fairly inefficient. Derek From pgsql-performance-owner@postgresql.org Fri May 6 18:39:21 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7E6A953508 for ; Fri, 6 May 2005 18:39:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87650-07 for ; Fri, 6 May 2005 21:39:11 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 2E063535B1 for ; Fri, 6 May 2005 18:39:10 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050506213912.ICYT4564.priv-edtnes56.telusplanet.net@localhost> for ; Fri, 6 May 2005 15:39:12 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Fri, 6 May 2005 14:39:11 -0700 Message-ID: <1115415551.427be3ffe44c8@webmail.telus.net> Date: Fri, 6 May 2005 14:39:11 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Whence the Opterons? References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> In-Reply-To: <15121.1115395067@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.046 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/65 X-Sequence-Number: 12229 After reading the comparisons between Opteron and Xeon processors for Linux, I'd like to add an Opteron box to our stable of Dells and Sparcs, for comparison. IBM, Sun and HP have their fairly pricey Opteron systems. The IT people are not swell about unsupported purchases off ebay. Anyone care to suggest any other vendors/distributors? Looking for names with national support, so that we can recommend as much to our customers. Many thanks in advance. -- "Dreams come true, not free." -- S.Sondheim From pgsql-performance-owner@postgresql.org Fri May 6 19:09:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AFF745346B for ; Fri, 6 May 2005 19:09:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90631-10 for ; Fri, 6 May 2005 22:09:18 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) by svr1.postgresql.org (Postfix) with ESMTP id D8BDF53492 for ; Fri, 6 May 2005 19:09:16 -0300 (ADT) Received: by rproxy.gmail.com with SMTP id a41so563599rng for ; Fri, 06 May 2005 15:09:19 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Q0eQyehdk+o/7yW37aIfeEUBS3x/5PBVwK6u0cracHEpO7K0wfuzhkHI/tZcXVl+cQCIPcuRDF96f9TtMpPB+AgdZ47bhwdYwX+vqv7V+Inj2Nka0y8IfQzQRFM3Ap0ZRdgXxGnv3Kqu4a18gcImhCaWeePst+zxdEPQVf5oXtk= Received: by 10.38.10.3 with SMTP id 3mr268529rnj; Fri, 06 May 2005 15:09:19 -0700 (PDT) Received: by 10.38.86.21 with HTTP; Fri, 6 May 2005 15:09:19 -0700 (PDT) Message-ID: Date: Fri, 6 May 2005 18:09:19 -0400 From: Ian Meyer Reply-To: Ian Meyer To: Mischa Sandberg Subject: Re: Whence the Opterons? Cc: pgsql-performance@postgresql.org In-Reply-To: <1115415551.427be3ffe44c8@webmail.telus.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/66 X-Sequence-Number: 12230 Mischa, What kind of budget are you on? penguincomputing.com deals with Opteron servers. I looked at a couple of their servers before deciding on a HP DL145. Ian On 5/6/05, Mischa Sandberg wrote: > After reading the comparisons between Opteron and Xeon processors for Lin= ux, > I'd like to add an Opteron box to our stable of Dells and Sparcs, for com= parison. >=20 > IBM, Sun and HP have their fairly pricey Opteron systems. > The IT people are not swell about unsupported purchases off ebay. > Anyone care to suggest any other vendors/distributors? > Looking for names with national support, so that we can recommend as much= to our > customers. >=20 > Many thanks in advance. > -- > "Dreams come true, not free." -- S.Sondheim >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if you= r > joining column's datatypes do not match > From pgsql-performance-owner@postgresql.org Fri May 6 19:30:18 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0C53553359 for ; Fri, 6 May 2005 19:30:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95631-02 for ; Fri, 6 May 2005 22:30:14 +0000 (GMT) Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net [66.238.115.135]) by svr1.postgresql.org (Postfix) with ESMTP id 844B352A62 for ; Fri, 6 May 2005 19:30:12 -0300 (ADT) Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; Fri, 6 May 2005 15:33:23 -0700 Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with Microsoft SMTPSVC(6.0.3790.0); Fri, 6 May 2005 15:33:18 -0700 Received: from barracuda.tecarta.com ([192.168.160.200]) by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id M2005050615331729281 for ; Fri, 06 May 2005 15:33:17 -0700 X-ASG-Debug-ID: 1115418608-26854-0-0 X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi Received: from mail1 (mail1.hq.corp [192.168.160.5]) by barracuda.tecarta.com (Spam Firewall) with SMTP id 5BD5B2014263 for ; Fri, 6 May 2005 15:30:08 -0700 (PDT) Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 6 May 2005 15:33:15 -0700 Message-ID: <427BEFC8.5040208@sfnet.cc> Date: Fri, 06 May 2005 15:29:28 -0700 From: Steve Poe User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mischa Sandberg Cc: pgsql-performance@postgresql.org X-ASG-Orig-Subj: Re: [PERFORM] Whence the Opterons? Subject: Re: Whence the Opterons? References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> In-Reply-To: <1115415551.427be3ffe44c8@webmail.telus.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 06 May 2005 22:33:15.0813 (UTC) FILETIME=[983F1550:01C5528B] X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=4.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_50 X-Barracuda-Spam-Report: Code version 3.02, rules version 3.0.813 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BAYES_50 BODY: Bayesian spam probability is 40 to 60% [score: 0.5454] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.172 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/67 X-Sequence-Number: 12231 >IBM, Sun and HP have their fairly pricey Opteron systems. >The IT people are not swell about unsupported purchases off ebay. Mischa, I certainly understand your concern, but the price and support sometimes go hand-in-hand. You may have to pick your batttles if your want more bang for the buck or more support. I might be wrong on this, but not everything you buy on E-Bay is unsupported. We purchase a dual Operton from Sun off their E-Bay store for about $3K less than the "buy it now" price. From an IT perspective, support is not as critical if I can do it myself. If it is for business 24/7 operations, then the company should be able to put some money behind what they want to put their business on. Your mileage may vary. Steve From pgsql-performance-owner@postgresql.org Fri May 6 19:44:56 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 177DA53589 for ; Fri, 6 May 2005 19:44:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96992-04 for ; Fri, 6 May 2005 22:44:48 +0000 (GMT) Received: from hades.cloud.glyphix.com (65-60-114-26-cust.telepacific.net [65.60.114.26]) by svr1.postgresql.org (Postfix) with ESMTP id 1359C53577 for ; Fri, 6 May 2005 19:44:47 -0300 (ADT) Received: from [192.168.1.115] (unknown [192.168.1.115]) by hades.cloud.glyphix.com (Postfix) with ESMTP id 262D067D066; Fri, 6 May 2005 15:45:32 -0700 (PDT) Message-ID: <427BF361.7050100@ehpg.net> Date: Fri, 06 May 2005 15:44:49 -0700 From: "Gavin M. Roy" User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050404) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Steve Poe Cc: Mischa Sandberg , pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> <427BEFC8.5040208@sfnet.cc> In-Reply-To: <427BEFC8.5040208@sfnet.cc> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.042 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/68 X-Sequence-Number: 12232 Please wait a week before buying Sun v20z's or v40z's from off of Ebay (j/k). (As I'm in the process of picking up a few) From everything I hear the v20z/v40z's are a great way to go and I'll know more in 15 days or so. Regards, Gavin Steve Poe wrote: >> IBM, Sun and HP have their fairly pricey Opteron systems. >> The IT people are not swell about unsupported purchases off ebay. > > > > Mischa, > > I certainly understand your concern, but the price and support > sometimes go hand-in-hand. You may have to pick your batttles if your > want more bang for the buck or more support. I might be wrong on this, > but not everything you buy on E-Bay is unsupported. > > We purchase a dual Operton from Sun off their E-Bay store for about > $3K less than the "buy it now" price. > > From an IT perspective, support is not as critical if I can do it > myself. If it is for business 24/7 operations, then the company should > be able to put some money behind what they want to put their business > on. Your mileage may vary. > > Steve > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Sat May 7 08:56:42 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 20B32536B9 for ; Sat, 7 May 2005 08:56:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05269-08 for ; Sat, 7 May 2005 11:56:35 +0000 (GMT) Received: from oismail.com (unknown [38.117.22.100]) by svr1.postgresql.org (Postfix) with ESMTP id 017F2535D4 for ; Sat, 7 May 2005 08:56:33 -0300 (ADT) Received: from [84.238.28.45] ([84.238.28.45]) (authenticated bits=0) by oismail.com (8.12.11/8.12.11) with ESMTP id j47BuL1C030463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 7 May 2005 07:56:23 -0400 Message-ID: <427CADD3.6050106@oismail.com> Date: Sat, 07 May 2005 14:00:19 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Christopher Kings-Lynne , pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 References: <4279ECC1.4050000@oismail.com> <24106.1115308954@sss.pgh.pa.us> <427B1E0A.3000108@oismail.com> <427B2D9E.2030804@familyhealth.com.au> <427B51AB.4060501@oismail.com> <13858.1115387983@sss.pgh.pa.us> In-Reply-To: <13858.1115387983@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------050902040801090006070600" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.107 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, HTML_30_40, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/69 X-Sequence-Number: 12233 This is a multi-part message in MIME format. --------------050902040801090006070600 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Wouldn't the VACUUM have made them equivalent?? anyway, here's the info for relpages: Live Server: 424 Test Server: 338 Please note though that there're more rows on the live server than on the test server due to recent upload. Total Row counts are as follows: Live Server: 12597 Test Server: 11494 When the problems started the tables had identical size though. Cheers Jona Tom Lane wrote: >Jona writes: > > >>Test Server: >>comm=# VACUUM ANALYZE VERBOSE StatCon_Tbl; >>INFO: --Relation public.statcon_tbl-- >>INFO: Pages 338: Changed 0, Empty 0; Tup 11494: Vac 0, Keep 0, UnUsed 0. >> Total CPU 0.02s/0.00u sec elapsed 1.98 sec. >>INFO: --Relation pg_toast.pg_toast_179851-- >>INFO: Pages 85680: Changed 0, Empty 0; Tup 343321: Vac 0, Keep 0, UnUsed 0. >> Total CPU 1.75s/0.23u sec elapsed 30.36 sec. >>INFO: Analyzing public.statcon_tbl >>VACUUM >> >> > > > >>Live Server: >>comm=# VACUUM ANALYZE VERBOSE StatCon_Tbl; >>INFO: --Relation public.statcon_tbl-- >>INFO: Pages 424: Changed 0, Empty 0; Tup 12291: Vac 0, Keep 0, UnUsed 6101. >> Total CPU 0.00s/0.01u sec elapsed 0.01 sec. >>INFO: --Relation pg_toast.pg_toast_891830-- >>INFO: Pages 89234: Changed 0, Empty 0; Tup 352823: Vac 0, Keep 0, >>UnUsed 5487. >> Total CPU 3.21s/0.47u sec elapsed 18.03 sec. >>INFO: Analyzing public.statcon_tbl >>VACUUM >> >> > >Hm, the physical table sizes aren't very different, which suggests that >the problem must lie with the indexes. Unfortunately, VACUUM in 7.3 >doesn't tell you anything about indexes if it doesn't have any dead rows >to clean up. Could you look at pg_class.relpages for all the indexes >of this table, and see what that shows? > > regards, tom lane > >---------------------------(end of broadcast)--------------------------- >TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > > --------------050902040801090006070600 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Wouldn't the VACUUM have made them equivalent??

anyway, here's the info for relpages:
Live Server: 424
Test Server: 338

Please note though that there're more rows on the live server than on the test server due to recent upload.
Total Row counts are as follows:
Live Server: 12597
Test Server: 11494

When the problems started the tables had identical size though.

Cheers
Jona

Tom Lane wrote:
Jona <jonanews@oismail.com> writes:
  
Test Server:
comm=# VACUUM ANALYZE VERBOSE StatCon_Tbl;
INFO:  --Relation public.statcon_tbl--
INFO:  Pages 338: Changed 0, Empty 0; Tup 11494: Vac 0, Keep 0, UnUsed 0.
        Total CPU 0.02s/0.00u sec elapsed 1.98 sec.
INFO:  --Relation pg_toast.pg_toast_179851--
INFO:  Pages 85680: Changed 0, Empty 0; Tup 343321: Vac 0, Keep 0, UnUsed 0.
        Total CPU 1.75s/0.23u sec elapsed 30.36 sec.
INFO:  Analyzing public.statcon_tbl
VACUUM
    

  
Live Server:
comm=# VACUUM ANALYZE VERBOSE StatCon_Tbl;
INFO:  --Relation public.statcon_tbl--
INFO:  Pages 424: Changed 0, Empty 0; Tup 12291: Vac 0, Keep 0, UnUsed 6101.
        Total CPU 0.00s/0.01u sec elapsed 0.01 sec.
INFO:  --Relation pg_toast.pg_toast_891830--
INFO:  Pages 89234: Changed 0, Empty 0; Tup 352823: Vac 0, Keep 0, 
UnUsed 5487.
        Total CPU 3.21s/0.47u sec elapsed 18.03 sec.
INFO:  Analyzing public.statcon_tbl
VACUUM
    

Hm, the physical table sizes aren't very different, which suggests that
the problem must lie with the indexes.  Unfortunately, VACUUM in 7.3
doesn't tell you anything about indexes if it doesn't have any dead rows
to clean up.  Could you look at pg_class.relpages for all the indexes
of this table, and see what that shows?

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org
  

--------------050902040801090006070600-- From pgsql-performance-owner@postgresql.org Sat May 7 11:57:50 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7785C535B4 for ; Sat, 7 May 2005 11:57:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42064-03 for ; Sat, 7 May 2005 14:57:44 +0000 (GMT) Received: from smtp104.rog.mail.re2.yahoo.com (smtp104.rog.mail.re2.yahoo.com [206.190.36.82]) by svr1.postgresql.org (Postfix) with SMTP id 1F5DF535BB for ; Sat, 7 May 2005 11:57:43 -0300 (ADT) Received: from unknown (HELO phlogiston.dydns.org) (a.sullivan@rogers.com@216.75.167.195 with login) by smtp104.rog.mail.re2.yahoo.com with SMTP; 7 May 2005 14:57:47 -0000 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id BF0543D2F; Sat, 7 May 2005 10:57:46 -0400 (EDT) Date: Sat, 7 May 2005 10:57:46 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? Message-ID: <20050507145746.GB15586@phlogiston.dyndns.org> References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1115415551.427be3ffe44c8@webmail.telus.net> User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/70 X-Sequence-Number: 12234 On Fri, May 06, 2005 at 02:39:11PM -0700, Mischa Sandberg wrote: > IBM, Sun and HP have their fairly pricey Opteron systems. We've had some quite good experiences with the HP boxes. They're not cheap, it's true, but boy are they sweet. A -- Andrew Sullivan | ajs@crankycanuck.ca In the future this spectacle of the middle classes shocking the avant- garde will probably become the textbook definition of Postmodernism. --Brad Holland From pgsql-performance-owner@postgresql.org Sat May 7 15:04:21 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5E3A253797 for ; Sat, 7 May 2005 15:01:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60961-09 for ; Sat, 7 May 2005 18:01:11 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id E2AC4537F2 for ; Sat, 7 May 2005 13:16:40 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr4.postgresql.org (Postfix) with ESMTP id DFBB85B06C4 for ; Sat, 7 May 2005 15:50:48 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j47FexaH002902; Sat, 7 May 2005 11:40:59 -0400 (EDT) To: Jona Cc: Christopher Kings-Lynne , pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 In-reply-to: <427CADD3.6050106@oismail.com> References: <4279ECC1.4050000@oismail.com> <24106.1115308954@sss.pgh.pa.us> <427B1E0A.3000108@oismail.com> <427B2D9E.2030804@familyhealth.com.au> <427B51AB.4060501@oismail.com> <13858.1115387983@sss.pgh.pa.us> <427CADD3.6050106@oismail.com> Comments: In-reply-to Jona message dated "Sat, 07 May 2005 14:00:19 +0200" Date: Sat, 07 May 2005 11:40:59 -0400 Message-ID: <2901.1115480459@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/71 X-Sequence-Number: 12235 Jona writes: > anyway, here's the info for relpages: > Live Server: 424 > Test Server: 338 I was asking about the indexes associated with the table, not the table itself. regards, tom lane From pgsql-performance-owner@postgresql.org Sat May 7 18:00:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7D8D053379 for ; Sat, 7 May 2005 18:00:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85059-05 for ; Sat, 7 May 2005 21:00:39 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 6DEA3534DD for ; Sat, 7 May 2005 18:00:38 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7334290; Sat, 07 May 2005 14:02:40 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Andrew Sullivan Subject: Re: Whence the Opterons? Date: Sat, 7 May 2005 14:00:34 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <1115415551.427be3ffe44c8@webmail.telus.net> <20050507145746.GB15586@phlogiston.dyndns.org> In-Reply-To: <20050507145746.GB15586@phlogiston.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505071400.35282.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/72 X-Sequence-Number: 12236 A- > On Fri, May 06, 2005 at 02:39:11PM -0700, Mischa Sandberg wrote: > > IBM, Sun and HP have their fairly pricey Opteron systems. > > We've had some quite good experiences with the HP boxes. They're not > cheap, it's true, but boy are they sweet. Question, though: is HP still using their proprietary RAID card? And, if so, have they fixed its performance problems? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat May 7 19:56:03 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E882753598 for ; Sat, 7 May 2005 19:56:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14678-02 for ; Sat, 7 May 2005 22:55:56 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3029C53517 for ; Sat, 7 May 2005 19:55:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j47Mtjuh006228; Sat, 7 May 2005 18:55:45 -0400 (EDT) To: Derek Buttineau|Compu-SOLVE Cc: Rosser Schwarz , pgsql-performance@postgresql.org Subject: Re: [SQL] ORDER BY Optimization In-reply-to: <427BD9A1.3090901@csolve.net> References: <427BCA10.4090208@csolve.net> <37d451f7050506133534923deb@mail.gmail.com> <427BD9A1.3090901@csolve.net> Comments: In-reply-to Derek Buttineau|Compu-SOLVE message dated "Fri, 06 May 2005 16:54:57 -0400" Date: Sat, 07 May 2005 18:55:45 -0400 Message-ID: <6227.1115506545@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/73 X-Sequence-Number: 12237 [ cc list limited to -performance ] Derek Buttineau|Compu-SOLVE writes: >> It seems to me a merge join might be more appropriate here than a >> nestloop. After some experimentation, I don't seem to be able to get the planner to generate a mergejoin based on a backwards index scan. I suspect it's not considering the idea of a merge using descending order at all. Might be a good enhancement, although we'd need to figure out how to keep this from just uselessly doubling the number of mergejoin paths considered :-( In the meantime, the nestloop is the only hope for avoiding a full-scan-and-sort. > I'm not entirely sure what's up with the row-count estimates, the tables > are updated quite frequently (and VACUUM is also run quite frequently), They're probably not as bad as they look. The estimates for the lower nodes are made without regard to the LIMIT, but the actuals of course reflect the fact that the LIMIT stopped execution of the plan early. The problem with this query is that the "fast" plan depends on the assumption that as we scan in backwards m.msg_date order, it won't take very long to find 10 rows that join to mr rows with mr.subscription=89. If that's true then the plan wins, if it's not true then the plan can lose big. That requires a pretty good density of rows with subscription=89, and in particular a good density near the end of the msg_date order. The planner effectively assumes that the proportion of rows with subscription=89 isn't changing over time, but perhaps it is --- if there's been a lot recently that could explain why the "fast" plan is fast. In any case I suppose that the reason the larger server doesn't want to try that plan is that its statistics show a much lower density of rows with subscription=89, and so the plan doesn't look promising compared to something that wins if there are few rows with subscription=89 ... which the other plan does. You could probably get your larger server to try the no-sort plan if you said "set enable_sort = 0" first. It would be interesting to compare the EXPLAIN ANALYZE results for that case with the other server. The contents of the pg_stats row for mr.subscription in each server would be informative, too. One rowcount estimate that does look wrong is -> Index Scan using maillog_received_subscription_idx on maillog_received mr (cost=0.00..17789.73 rows=4479 width=43) (actual time=0.030..33554.061 rows=65508 loops=1) Index Cond: (subscription = 89) so the stats row is suggesting there are only 4479 rows with subscription = 89 when really there are 65508. (The preceding discussion hopefully makes it clear why this is a potentially critical mistake.) This suggests that you may need to raise your statistics targets. regards, tom lane From pgsql-performance-owner@postgresql.org Sun May 8 08:06:51 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 021E553594 for ; Sun, 8 May 2005 08:06:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59216-10 for ; Sun, 8 May 2005 11:06:38 +0000 (GMT) Received: from oismail.com (unknown [38.117.22.100]) by svr1.postgresql.org (Postfix) with ESMTP id 4CC7B5295A for ; Sun, 8 May 2005 08:06:37 -0300 (ADT) Received: from [62.198.128.25] ([62.198.128.25]) (authenticated bits=0) by oismail.com (8.12.11/8.12.11) with ESMTP id j48B6CI5003493 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 8 May 2005 07:06:22 -0400 Message-ID: <427DF391.9060708@oismail.com> Date: Sun, 08 May 2005 13:10:09 +0200 From: Jona User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Christopher Kings-Lynne , pgsql-performance@postgresql.org Subject: Re: Bad choice of query plan from PG 7.3.6 to PG 7.3.9 References: <4279ECC1.4050000@oismail.com> <24106.1115308954@sss.pgh.pa.us> <427B1E0A.3000108@oismail.com> <427B2D9E.2030804@familyhealth.com.au> <427B51AB.4060501@oismail.com> <13858.1115387983@sss.pgh.pa.us> <427CADD3.6050106@oismail.com> <2901.1115480459@sss.pgh.pa.us> In-Reply-To: <2901.1115480459@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------050802080700010108030902" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.586 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, HTML_50_60, HTML_MESSAGE, HTML_TAG_EXIST_TBODY, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200505/74 X-Sequence-Number: 12238 This is a multi-part message in MIME format. --------------050802080700010108030902 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sorry Tom, misread your mail! My bad :-( I believe the following is the data you need ? Live Server relname relpages ctp_statcon 72 statcon_pk 135 Test Server relname relpages ctp_statcon 34 statcon_pk 28 Have executed the following query to obtain that data: SELECT relname, relpages FROM pg_class WHERE relname = 'statcon_pk' OR relname = 'sc2ctp_fk' OR relname = 'sc2mtp_fk' OR relname = 'sc2sc_fk' OR relname = 'ctp_statcon' The size difference for the index is surprisingly big I think, considering that there's only around 1000 rows more in the table on the live server than on the server. Count for Live Server: 12597 Count for Test Server: 11494 Any insight into this? Cheers Jona PS: The meta data for the table is: CREATE TABLE statcon_tbl ( id serial NOT NULL, data bytea, wm bool DEFAULT 'FALSE', created timestamp DEFAULT now(), modified timestamp DEFAULT now(), enabled bool DEFAULT 'TRUE', bitsperpixel int4 DEFAULT 0, mtpid int4, sctid int4, ctpid int4, CONSTRAINT statcon_pk PRIMARY KEY (id), CONSTRAINT sc2ctp_fk FOREIGN KEY (ctpid) REFERENCES contype_tbl (id) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT sc2mtp_fk FOREIGN KEY (mtpid) REFERENCES mimetype_tbl (id) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT sc2sct_fk FOREIGN KEY (sctid) REFERENCES statcontrans_tbl (id) ON UPDATE CASCADE ON DELETE CASCADE ) WITHOUT OIDS; CREATE INDEX ctp_statcon ON statcon_tbl USING btree (sctid, ctpid); Tom Lane wrote: >Jona writes: > > >>anyway, here's the info for relpages: >>Live Server: 424 >>Test Server: 338 >> >> > >I was asking about the indexes associated with the table, not the table >itself. > > regards, tom lane > > --------------050802080700010108030902 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sorry Tom, misread your mail! My bad :-(

I believe the following is the data you need ?
Live Server
relname relpages
ctp_statcon 72
statcon_pk 135


Test Server
relname relpages
ctp_statcon 34
statcon_pk 28

Have executed the following query to obtain that data:
SELECT relname, relpages
FROM pg_class
WHERE relname = 'statcon_pk' OR relname = 'sc2ctp_fk' OR relname = 'sc2mtp_fk' OR relname = 'sc2sc_fk' OR relname = 'ctp_statcon'

The size difference for the index is surprisingly big I think, considering that there's only around 1000 rows more in the table on the live server than on the server.
Count for Live Server: 12597
Count for Test Server: 11494
Any insight into this?

Cheers
Jona

PS: The meta data for the table is:
CREATE TABLE statcon_tbl
(
  id serial NOT NULL,
  data bytea,
  wm bool DEFAULT 'FALSE',
  created timestamp DEFAULT now(),
  modified timestamp DEFAULT now(),
  enabled bool DEFAULT 'TRUE',
  bitsperpixel int4 DEFAULT 0,
  mtpid int4,
  sctid int4,
  ctpid int4,
  CONSTRAINT statcon_pk PRIMARY KEY (id),
  CONSTRAINT sc2ctp_fk FOREIGN KEY (ctpid) REFERENCES contype_tbl (id) ON          UPDATE CASCADE ON DELETE CASCADE,
  CONSTRAINT sc2mtp_fk FOREIGN KEY (mtpid) REFERENCES mimetype_tbl (id) ON UPDATE CASCADE ON DELETE CASCADE,
  CONSTRAINT sc2sct_fk FOREIGN KEY (sctid) REFERENCES statcontrans_tbl (id) ON UPDATE CASCADE ON DELETE CASCADE
)
WITHOUT OIDS;
CREATE INDEX ctp_statcon  ON statcon_tbl  USING btree  (sctid, ctpid);


Tom Lane wrote:
Jona <jonanews@oismail.com> writes:
  
anyway, here's the info for relpages:
Live Server: 424
Test Server: 338
    

I was asking about the indexes associated with the table, not the table
itself.

			regards, tom lane
  

--------------050802080700010108030902-- From pgsql-performance-owner@postgresql.org Sun May 8 10:44:48 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E9D9053ABE for ; Sun, 8 May 2005 10:44:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79469-06 for ; Sun, 8 May 2005 13:44:38 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id AF26653A21 for ; Sun, 8 May 2005 10:44:36 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j48Dicph004331; (envelope-from ) Sun, 8 May 2005 08:44:38 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j48DiaW8024934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Sun, 8 May 2005 08:44:37 -0500 (CDT) Message-ID: <427E17BC.7050407@arbash-meinel.com> Date: Sun, 08 May 2005 08:44:28 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeroen van Iddekinge Cc: pgsql-performance@postgresql.org Subject: Re: sequence scan on PK References: <427E2941.9070105@lycos.com> In-Reply-To: <427E2941.9070105@lycos.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigEC5314BD4A2BDB8114BFA6BB" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/76 X-Sequence-Number: 12240 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigEC5314BD4A2BDB8114BFA6BB Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jeroen van Iddekinge wrote: > Hi, > > > I understand that when a table contains only a few rows it is better to > do a sequence scan than an index scan. But is this also for a table with > 99 records? > ... > explain select * from tblFolders where id=90; > QUERY PLAN > ----------------------------------------------------------- > Seq Scan on tblfolders (cost=0.00..3.24 rows=1 width=50) > Filter: (id = 90) > > > (I have analyze table bit still a sequence scan). > > With how manys rows it is ok to do an index scan or sequence scan? How > is this calculated in pg? > > Regards > Jer It depends on how many pages need to be read. To do an index scan you need to read the index pages, and then you read the page where the actual row resides. Usually the comment is if you are selecting >5% of the rows, seqscan is faster than an index scan. If I'm reading your query correctly, it is estimating needing to read about 3 pages to get the row you are asking for. If you used an index, it probably would have to read at least that many pages, and they would not be a sequential read, so it should be slower. If you want to prove it, try: \timing EXPLAIN ANALYZE SELECT * FROM tblFolders WHERE id=90; EXPLAIN ANALYZE SELECT * FROM tblFolders WHERE id=90; EXPLAIN ANALYZE SELECT * FROM tblFolders WHERE id=90; SET enable_seqscan TO OFF; EXPLAIN ANALYZE SELECT * FROM tblFolders WHERE id=90; EXPLAIN ANALYZE SELECT * FROM tblFolders WHERE id=90; EXPLAIN ANALYZE SELECT * FROM tblFolders WHERE id=90; Run multiple times to make sure everything is cached, and take the fastest time. On your machine it might be true that the index scan is slightly faster than the seqscan in this exact circumstance. But I have the feeling the time is trivially different, and if you had say 70 rows it would favor seqscan. Probably somewhere at 150-200 rows it will switch on it's own. You could tweak with several settings to get it to do an index scan earlier, but these would probably break other queries. You don't need to tune for 100 rows, more like 100k or 100M. John =:-> --------------enigEC5314BD4A2BDB8114BFA6BB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCfhe+JdeBCYSNAAMRAoEDAJ9OHPdMzjAd5KJXMMez+kuux8HlygCeOIBJ ZUOkCzlvqF2689jMlB1AMIE= =uWmL -----END PGP SIGNATURE----- --------------enigEC5314BD4A2BDB8114BFA6BB-- From pgsql-performance-owner@postgresql.org Sun May 8 09:59:09 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4BC0D539B5 for ; Sun, 8 May 2005 09:59:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72233-09 for ; Sun, 8 May 2005 12:58:59 +0000 (GMT) Received: from smtp2.versatel.nl (smtp2.versatel.nl [62.58.50.89]) by svr1.postgresql.org (Postfix) with ESMTP id 5F2B053594 for ; Sun, 8 May 2005 09:58:56 -0300 (ADT) Received: (qmail 9957 invoked by uid 10); 8 May 2005 12:58:57 -0000 Received: (vexira-qq 09948-351B5AD invoked from network) 08 May 2005 14:58:57 +0200 Received: from unknown (HELO [81.58.65.37]) ([81.58.65.37]) (envelope-sender ) by smtp2.versatel.nl (qmail-ldap-1.03) with SMTP for < >; 8 May 2005 12:58:57 -0000 Message-ID: <427E2941.9070105@lycos.com> Date: Sun, 08 May 2005 14:59:13 +0000 From: Jeroen van Iddekinge User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: sequence scan on PK Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.16; VAE: 6.30.0.2; VDF: 6.30.0.11; host: postbode02.zonnet.nl) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.278 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: * X-Archive-Number: 200505/75 X-Sequence-Number: 12239 Hi, I understand that when a table contains only a few rows it is better to do a sequence scan than an index scan. But is this also for a table with 99 records? A table contains id integer (primary key) name varchar(70) parent integer comment text owner integer inheritAccess integer defaultAccess integer sequence bigint contentsinheritaccessmove integer contentsinheritaccessadd integer explain select * from tblFolders where id=90; QUERY PLAN ----------------------------------------------------------- Seq Scan on tblfolders (cost=0.00..3.24 rows=1 width=50) Filter: (id = 90) (I have analyze table bit still a sequence scan). With how manys rows it is ok to do an index scan or sequence scan? How is this calculated in pg? Regards Jer From pgsql-performance-owner@postgresql.org Sun May 8 13:19:00 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 057B852A86 for ; Sun, 8 May 2005 13:19:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97976-03 for ; Sun, 8 May 2005 16:18:50 +0000 (GMT) Received: from mail1.fluidhosting.com (mail1.fluidhosting.com [66.150.201.101]) by svr1.postgresql.org (Postfix) with SMTP id A3F9A53986 for ; Sun, 8 May 2005 13:18:48 -0300 (ADT) Received: (qmail 62836 invoked by uid 399); 8 May 2005 16:18:47 -0000 Received: from unknown (HELO ?127.0.0.1?) (81.174.8.196) by mail1.fluidhosting.com with SMTP; 8 May 2005 16:18:47 -0000 Message-ID: <427E3BE6.5040702@beccati.com> Date: Sun, 08 May 2005 18:18:46 +0200 From: Matteo Beccati User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeroen van Iddekinge Cc: pgsql-performance@postgresql.org Subject: Re: sequence scan on PK References: <427E2941.9070105@lycos.com> <427E17BC.7050407@arbash-meinel.com> <427E5130.7020702@lycos.com> In-Reply-To: <427E5130.7020702@lycos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/78 X-Sequence-Number: 12242 Hi, > Thanks for respone. > The index scan was a little bit faster for id=1 and faster for id=99. > > Which settings shoud I change for this? cpu_index_tuple_cost , > cpu_operator_cost, cpu_tuple_cost? You should lower random_page_cost to make the planner choose an index scan vs sequential scan. Best regards -- Matteo Beccati http://phpadsnew.com/ http://phppgads.com/ From pgsql-performance-owner@postgresql.org Sun May 8 13:24:58 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E02E953873 for ; Sun, 8 May 2005 13:24:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96351-09 for ; Sun, 8 May 2005 16:24:47 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 7196752AA9 for ; Sun, 8 May 2005 13:24:46 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j48GOiTT006770; (envelope-from ) Sun, 8 May 2005 11:24:44 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j48GOeDI007216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Sun, 8 May 2005 11:24:44 -0500 (CDT) Message-ID: <427E3D44.4080503@arbash-meinel.com> Date: Sun, 08 May 2005 11:24:36 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeroen van Iddekinge Cc: pgsql-performance@postgresql.org Subject: Re: sequence scan on PK References: <427E2941.9070105@lycos.com> <427E17BC.7050407@arbash-meinel.com> <427E5130.7020702@lycos.com> In-Reply-To: <427E5130.7020702@lycos.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig54424BC0B47EE0772AF1F676" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/79 X-Sequence-Number: 12243 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig54424BC0B47EE0772AF1F676 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jeroen van Iddekinge wrote: > >> >> You could tweak with several settings to get it to do an index scan >> earlier, but these would probably break other queries. You don't need to >> tune for 100 rows, morelike 100k or 100M. > > > Thanks for respone. > The index scan was a little bit faster for id=1 and faster for id=99. > > Which settings shoud I change for this? cpu_index_tuple_cost , > cpu_operator_cost, cpu_tuple_cost? > > > Jer. Well, I would start with *don't*. You are only looking at one query, which is pretty much fast already, and probably is not going to be the bottleneck. You are optimizing the wrong thing. That being said, because you have everything cached in ram (since it is a tiny table), you probably would set random_page_cost = 2. In theory it should really never be lower than 2, though if you are trying to force an index scan you can do it. John =:-> --------------enig54424BC0B47EE0772AF1F676 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCfj1HJdeBCYSNAAMRAkUHAJ9jusMa60Ju+Mg4g5OcAaYqVuZLdgCfbftl LcIWwQ7oQGtjG0ThSLqvVsg= =9AY8 -----END PGP SIGNATURE----- --------------enig54424BC0B47EE0772AF1F676-- From pgsql-performance-owner@postgresql.org Sun May 8 13:49:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2455452AA9 for ; Sun, 8 May 2005 13:49:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02524-04 for ; Sun, 8 May 2005 16:49:23 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id C714C53A40 for ; Sun, 8 May 2005 13:49:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j48GnJoK012304; Sun, 8 May 2005 12:49:19 -0400 (EDT) To: Jeroen van Iddekinge Cc: pgsql-performance@postgresql.org Subject: Re: sequence scan on PK In-reply-to: <427E5130.7020702@lycos.com> References: <427E2941.9070105@lycos.com> <427E17BC.7050407@arbash-meinel.com> <427E5130.7020702@lycos.com> Comments: In-reply-to Jeroen van Iddekinge message dated "Sun, 08 May 2005 17:49:36 -0000" Date: Sun, 08 May 2005 12:49:19 -0400 Message-ID: <12303.1115570959@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/81 X-Sequence-Number: 12245 Jeroen van Iddekinge writes: >> You could tweak with several settings to get it to do an index scan >> earlier, but these would probably break other queries. You don't need to >> tune for 100 rows, morelike 100k or 100M. > Which settings shoud I change for this? I'd agree with John's response: if you change any settings based on just this one test case, you're a fool. But usually random_page_cost is the best knob to twiddle if you wish to encourage indexscans. regards, tom lane From pgsql-performance-owner@postgresql.org Sun May 8 14:05:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AE2FA53A02 for ; Sun, 8 May 2005 14:05:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04281-06 for ; Sun, 8 May 2005 17:05:16 +0000 (GMT) Received: from mail1.fluidhosting.com (mail1.fluidhosting.com [66.150.201.101]) by svr1.postgresql.org (Postfix) with SMTP id 943DF533A5 for ; Sun, 8 May 2005 14:05:14 -0300 (ADT) Received: (qmail 47441 invoked by uid 399); 8 May 2005 17:05:12 -0000 Received: from unknown (HELO ?127.0.0.1?) (81.174.8.196) by mail1.fluidhosting.com with SMTP; 8 May 2005 17:05:12 -0000 Message-ID: <427E46C7.1080208@beccati.com> Date: Sun, 08 May 2005 19:05:11 +0200 From: Matteo Beccati User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeroen van Iddekinge Cc: pgsql-performance@postgresql.org Subject: Re: sequence scan on PK References: <427E2941.9070105@lycos.com> <427E17BC.7050407@arbash-meinel.com> <427E5130.7020702@lycos.com> <427E3BE6.5040702@beccati.com> <427E5B2E.7020001@lycos.com> In-Reply-To: <427E5B2E.7020001@lycos.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/82 X-Sequence-Number: 12246 Hi, > Yes , it was a bit to high (18) so a lowered it. It speeded up some > pages for about 5%. 18? The default is 4 if I can remember correctly. I wonder if your db has ever seen an index scan ;) Best regards -- Matteo Beccati http://phpadsnew.com/ http://phppgads.com/ From pgsql-performance-owner@postgresql.org Sun May 8 14:12:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4A43353A14 for ; Sun, 8 May 2005 14:12:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05510-04 for ; Sun, 8 May 2005 17:12:32 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 078BD53A3D for ; Sun, 8 May 2005 14:12:32 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 3148915490; Sun, 8 May 2005 12:12:32 -0500 (CDT) Date: Sun, 8 May 2005 12:12:32 -0500 From: "Jim C. Nasby" To: Dennis Bjorklund Cc: Tom Lane , Christopher Kings-Lynne , David Roussel , Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT Message-ID: <20050508171232.GD88920@decibel.org> References: <20050506065129.GL88920@decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/83 X-Sequence-Number: 12247 On Fri, May 06, 2005 at 09:30:46AM +0200, Dennis Bjorklund wrote: > The sql standard include this, except that you can not have the outer (). > So it should be > > INSERT INTO table VALUES > (1,2,3), > (4,5,6), > (7,8,9); > > Do DB2 demand these extra ()? My recollection is that it does, but it's been a few years... -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Sun May 8 12:49:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 00FE452A38 for ; Sun, 8 May 2005 12:49:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94545-06 for ; Sun, 8 May 2005 15:49:23 +0000 (GMT) Received: from smtp1.versatel.nl (smtp1.versatel.nl [62.58.50.88]) by svr1.postgresql.org (Postfix) with ESMTP id EECAA52A2F for ; Sun, 8 May 2005 12:49:21 -0300 (ADT) Received: (qmail 10383 invoked by uid 10); 8 May 2005 15:49:19 -0000 Received: (vexira-qq 10376-26CE7BED invoked from network) 08 May 2005 17:49:19 +0200 Received: from unknown (HELO [81.58.65.37]) ([81.58.65.37]) (envelope-sender ) by smtp1.versatel.nl (qmail-ldap-1.03) with SMTP for < >; 8 May 2005 15:49:19 -0000 Message-ID: <427E5130.7020702@lycos.com> Date: Sun, 08 May 2005 17:49:36 +0000 From: Jeroen van Iddekinge User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: sequence scan on PK References: <427E2941.9070105@lycos.com> <427E17BC.7050407@arbash-meinel.com> In-Reply-To: <427E17BC.7050407@arbash-meinel.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.16; VAE: 6.30.0.2; VDF: 6.30.0.11; host: postbode01.zonnet.nl) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.309 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: * X-Archive-Number: 200505/77 X-Sequence-Number: 12241 > > You could tweak with several settings to get it to do an index scan > earlier, but these would probably break other queries. You don't need to > tune for 100 rows, morelike 100k or 100M. Thanks for respone. The index scan was a little bit faster for id=1 and faster for id=99. Which settings shoud I change for this? cpu_index_tuple_cost , cpu_operator_cost, cpu_tuple_cost? Jer. From pgsql-performance-owner@postgresql.org Sun May 8 13:32:02 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7541353A13 for ; Sun, 8 May 2005 13:32:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99813-01 for ; Sun, 8 May 2005 16:31:59 +0000 (GMT) Received: from smtp1.versatel.nl (smtp1.versatel.nl [62.58.50.88]) by svr1.postgresql.org (Postfix) with ESMTP id A93CD53A28 for ; Sun, 8 May 2005 13:31:57 -0300 (ADT) Received: (qmail 17134 invoked by uid 10); 8 May 2005 16:31:57 -0000 Received: (vexira-qq 17128-BFE2674D invoked from network) 08 May 2005 18:31:57 +0200 Received: from unknown (HELO [81.58.65.37]) ([81.58.65.37]) (envelope-sender ) by smtp1.versatel.nl (qmail-ldap-1.03) with SMTP for < >; 8 May 2005 16:31:57 -0000 Message-ID: <427E5B2E.7020001@lycos.com> Date: Sun, 08 May 2005 18:32:14 +0000 From: Jeroen van Iddekinge User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: sequence scan on PK References: <427E2941.9070105@lycos.com> <427E17BC.7050407@arbash-meinel.com> <427E5130.7020702@lycos.com> <427E3BE6.5040702@beccati.com> In-Reply-To: <427E3BE6.5040702@beccati.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.16; VAE: 6.30.0.2; VDF: 6.30.0.11; host: postbode01.zonnet.nl) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.327 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: * X-Archive-Number: 200505/80 X-Sequence-Number: 12244 > > You should lower random_page_cost to make the planner choose an index > scan vs sequential scan. > Yes , it was a bit to high (18) so a lowered it. It speeded up some pages for about 5%. Reg. Jer From pgsql-performance-owner@postgresql.org Sun May 8 15:15:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CE3D553B01 for ; Sun, 8 May 2005 15:15:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12964-08 for ; Sun, 8 May 2005 18:15:22 +0000 (GMT) Received: from smtp2.versatel.nl (smtp2.versatel.nl [62.58.50.89]) by svr1.postgresql.org (Postfix) with ESMTP id 93A6953B05 for ; Sun, 8 May 2005 15:15:20 -0300 (ADT) Received: (qmail 30089 invoked by uid 10); 8 May 2005 18:15:20 -0000 Received: (vexira-qq 30082-5E8C4A11 invoked from network) 08 May 2005 20:15:20 +0200 Received: from unknown (HELO [81.58.65.37]) ([81.58.65.37]) (envelope-sender ) by smtp2.versatel.nl (qmail-ldap-1.03) with SMTP for < >; 8 May 2005 18:15:20 -0000 Message-ID: <427E736A.4030107@lycos.com> Date: Sun, 08 May 2005 20:15:38 +0000 From: Jeroen van Iddekinge User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: sequence scan on PK References: <427E2941.9070105@lycos.com> <427E17BC.7050407@arbash-meinel.com> <427E5130.7020702@lycos.com> <427E3BE6.5040702@beccati.com> <427E5B2E.7020001@lycos.com> <427E46C7.1080208@beccati.com> In-Reply-To: <427E46C7.1080208@beccati.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.16; VAE: 6.30.0.2; VDF: 6.30.0.11; host: postbode02.zonnet.nl) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.339 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: * X-Archive-Number: 200505/84 X-Sequence-Number: 12248 Matteo Beccati wrote: > Hi, > >> Yes , it was a bit to high (18) so a lowered it. It speeded up some >> pages for about 5%. > > > 18? The default is 4 if I can remember correctly. I wonder if your db > has ever seen an index scan ;) > I was expermenting how much some setting influence has on the perfomance of some web application. So I think i forgot to change the setting back and got some strange query plans. Thanks Jer From pgsql-performance-owner@postgresql.org Sun May 8 18:59:38 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5CB98538E7 for ; Sun, 8 May 2005 18:59:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54068-08 for ; Sun, 8 May 2005 21:59:28 +0000 (GMT) Received: from mail.utsl.gen.nz (210-54-92-184.ipnets.xtra.co.nz [210.54.92.184]) by svr1.postgresql.org (Postfix) with ESMTP id 6E3A3537E0 for ; Sun, 8 May 2005 18:59:27 -0300 (ADT) Received: by mail.utsl.gen.nz (Postfix, from userid 65534) id 9501014021; Mon, 9 May 2005 09:59:15 +1200 (NZST) Received: from [127.0.0.1] (longdrop.clunker.utsl.gen.nz [192.168.255.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.utsl.gen.nz (Postfix) with ESMTP id CF6931401D; Mon, 9 May 2005 09:59:11 +1200 (NZST) Message-ID: <427E8BAB.7000607@vilain.net> Date: Mon, 09 May 2005 09:59:07 +1200 From: Sam Vilain User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> In-Reply-To: <1115415551.427be3ffe44c8@webmail.telus.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.835 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/85 X-Sequence-Number: 12249 Mischa Sandberg wrote: > After reading the comparisons between Opteron and Xeon processors for Linux, > I'd like to add an Opteron box to our stable of Dells and Sparcs, for comparison. > IBM, Sun and HP have their fairly pricey Opteron systems. > The IT people are not swell about unsupported purchases off ebay. > Anyone care to suggest any other vendors/distributors? Check out the Tyan Transport systems. Tyan are an ex Sparc clone manufacturer, and released the second available Opteron board - widely considered the first serious Opteron board to hit the market. Sam. From pgsql-performance-owner@postgresql.org Sun May 8 19:33:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E65953B8C for ; Sun, 8 May 2005 19:33:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60093-04 for ; Sun, 8 May 2005 22:33:10 +0000 (GMT) Received: from priv-edtnes57.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 8479153B88 for ; Sun, 8 May 2005 19:33:09 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes57.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050508223311.WTRS1849.priv-edtnes57.telusplanet.net@localhost>; Sun, 8 May 2005 16:33:11 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Sun, 8 May 2005 15:33:11 -0700 Message-ID: <1115591591.427e93a7cc882@webmail.telus.net> Date: Sun, 8 May 2005 15:33:11 -0700 From: Mischa Sandberg To: Sam Vilain Cc: pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> <427E8BAB.7000607@vilain.net> In-Reply-To: <427E8BAB.7000607@vilain.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.049 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/86 X-Sequence-Number: 12250 Thanks to everyone for their pointers to suppliers of Opteron systems. The system I'm pricing is under a tighter budget than a production machine, because it will be for perftests. Our customers tend to run on Dells but occasionally run on (Sun) Opterons. From pgsql-performance-owner@postgresql.org Sun May 8 20:20:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 237195396C for ; Sun, 8 May 2005 20:20:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65210-04 for ; Sun, 8 May 2005 23:20:41 +0000 (GMT) Received: from crestone.coronasolutions.com (crestone.coronasolutions.com [66.45.104.24]) by svr1.postgresql.org (Postfix) with ESMTP id 9C70B53858 for ; Sun, 8 May 2005 20:20:40 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by crestone.coronasolutions.com (Postfix) with ESMTP id 3B2696441D2 for ; Sun, 8 May 2005 17:20:35 -0600 (MDT) Received: from crestone.coronasolutions.com ([127.0.0.1]) by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24466-10 for ; Sun, 8 May 2005 17:20:34 -0600 (MDT) Received: from [192.168.1.3] (c-24-9-111-5.hsd1.co.comcast.net [24.9.111.5]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by crestone.coronasolutions.com (Postfix) with ESMTP id 0B723644180 for ; Sun, 8 May 2005 17:20:34 -0600 (MDT) Mime-Version: 1.0 (Apple Message framework v622) Content-Transfer-Encoding: 7bit Message-Id: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> Content-Type: text/plain; charset=US-ASCII; format=flowed To: pgsql-performance@postgresql.org From: Dan Harris Subject: Query tuning help Date: Sun, 8 May 2005 17:20:35 -0600 X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/87 X-Sequence-Number: 12251 Sorry to bother everyone with yet another "my query isn't using an index" problem but I am over my head on this one.. I am open to ways of restructuring this query to perform better. I have a table, 'ea', with 22 million rows in it. VACUUM ANALYZE has been just run on the table. This is the result of: explain analyze select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat from ea, em, eg where em.incidentid = ea.incidentid and em.incidentid = eg.incidentid and em.entrydate >= '2005-1-1 00:00' and em.entrydate <= '2005-5-9 00:00' and ea.incidentid in ( select incidentid from ea where recordtext like '%RED%' ) and ea.incidentid in ( select incidentid from ea where recordtext like '%CORVETTE%' ) and ( recordtext like '%RED%' or recordtext like '%CORVETTE%' ) order by em.entrydate --------------------- ANALYZE RESULTS --------------------- Unique (cost=774693.72..774693.76 rows=1 width=159) (actual time=446787.056..446787.342 rows=72 loops=1) -> Sort (cost=774693.72..774693.72 rows=1 width=159) (actual time=446787.053..446787.075 rows=72 loops=1) Sort Key: em.incidentid, public.ea.recordtext, eg.long, eg.lat -> Nested Loop (cost=771835.10..774693.71 rows=1 width=159) (actual time=444378.655..446786.746 rows=72 loops=1) -> Nested Loop (cost=771835.10..774688.81 rows=1 width=148) (actual time=444378.532..446768.381 rows=72 loops=1) -> Nested Loop IN Join (cost=771835.10..774678.88 rows=2 width=81) (actual time=444367.080..446191.864 rows=701 loops=1) -> Nested Loop (cost=771835.10..774572.05 rows=42 width=64) (actual time=444366.859..445463.232 rows=1011 loops=1) -> HashAggregate (cost=771835.10..771835.10 rows=1 width=17) (actual time=444366.702..444368.583 rows=473 loops=1) -> Seq Scan on ea (cost=0.00..771834.26 rows=335 width=17) (actual time=259.746..444358.837 rows=592 loops=1) Filter: ((recordtext)::text ~~ '%CORVETTE%'::text) -> Index Scan using ea1 on ea (cost=0.00..2736.43 rows=42 width=47) (actual time=2.085..2.309 rows=2 loops=473) Index Cond: ((ea.incidentid)::text = ("outer".incidentid)::text) Filter: (((recordtext)::text ~~ '%RED%'::text) OR ((recordtext)::text ~~ '%CORVETTE%'::text)) -> Index Scan using ea1 on ea (cost=0.00..2733.81 rows=42 width=17) (actual time=0.703..0.703 rows=1 loops=1011) Index Cond: (("outer".incidentid)::text = (ea.incidentid)::text) Filter: ((recordtext)::text ~~ '%RED%'::text) -> Index Scan using em_incidentid_idx on em (cost=0.00..4.95 rows=1 width=67) (actual time=0.820..0.821 rows=0 loops=701) Index Cond: (("outer".incidentid)::text = (em.incidentid)::text) Filter: ((entrydate >= '2005-01-01 00:00:00'::timestamp without time zone) AND (entrydate <= '2005-05-09 00:00:00'::timestamp without time zone)) -> Index Scan using eg_incidentid_idx on eg (cost=0.00..4.89 rows=1 width=79) (actual time=0.245..0.246 rows=1 loops=72) Index Cond: (("outer".incidentid)::text = (eg.incidentid)::text) Total runtime: 446871.880 ms (22 rows) ------------------------- EXPLANATION ------------------------- The reason for the redundant LIKE clause is that first, I only want those "incidentid"s that contain the words 'RED' and 'CORVETTE'. BUT, those two words may exist across multiple records with the same incidentid. Then, I only want to actually work with the rows that contain one of the words. This query will repeat the same logic for however many keywords are entered by the user. I have investigated text searching options and have not found them to be congruous with my application. Why is it choosing a sequential scan one part of the query when searching for the words, yet using an index scan for another part of it? Is there a better way to structure the query to give it better hints? I'm using 8.0.1 on a 4-way Opteron with beefy RAID-10 and 12GB of RAM. Thank you for any advice. -Dan From pgsql-performance-owner@postgresql.org Sun May 8 21:48:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6426D53AF2 for ; Sun, 8 May 2005 21:48:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91710-01 for ; Mon, 9 May 2005 00:48:15 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 206C953AEA for ; Sun, 8 May 2005 21:48:14 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7337704; Sun, 08 May 2005 17:50:17 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Dan Harris Subject: Re: Query tuning help Date: Sun, 8 May 2005 17:48:18 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> In-Reply-To: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200505081748.18362.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/88 X-Sequence-Number: 12252 Dan, > =A0=A0=A0=A0=A0=A0=A0=A0and ( =A0recordtext like '%RED%' or recordtext li= ke '%CORVETTE%' =A0) =A0 It is simply not possible to use B-tree indexes on these kind of text queri= es. =20 B-trees require you to start at the "left" side of the field, because B-tre= es=20 locate records via <> tests. "Anywhere in the field" text search requires = a=20 =46ull Text Index. > The reason for the redundant LIKE clause is that first, I only want > those "incidentid"s that contain the words 'RED' and 'CORVETTE'. =A0BUT, > those two words may exist across multiple records with the same > incidentid. =A0Then, I only want to actually work with the rows that > contain one of the words. =A0This query will repeat the same logic for > however many keywords are entered by the user. =A0I have investigated > text searching options and have not found them to be congruous with my > application. Sounds like you either need to restructure your application, restructure yo= ur=20 database (so that you're not doing "anywhere in field" searches), or buy 32= GB=20 of ram so that you can cache the whole table. =2D-=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun May 8 21:51:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4BDD4533D9 for ; Sun, 8 May 2005 21:51:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87543-05 for ; Mon, 9 May 2005 00:51:17 +0000 (GMT) Received: from pws.com.au (mail.pws.com.au [210.23.138.139]) by svr1.postgresql.org (Postfix) with SMTP id 5E248533AA for ; Sun, 8 May 2005 21:51:15 -0300 (ADT) Received: (qmail 22507 invoked from network); 9 May 2005 00:51:15 -0000 Received: from unknown (HELO wizzard.pws.com.au) (russell@pws.com.au@138.217.54.70) by mail.pws.com.au with SMTP; 9 May 2005 00:51:15 -0000 From: Russell Smith To: Dan Harris Subject: Re: Query tuning help Date: Mon, 9 May 2005 10:51:14 +1000 User-Agent: KMail/1.7.2 Cc: pgsql-performance@postgresql.org References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> In-Reply-To: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505091051.14689.mr-russ@pws.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/89 X-Sequence-Number: 12253 On Mon, 9 May 2005 09:20 am, Dan Harris wrote: > Sorry to bother everyone with yet another "my query isn't using an > index" problem but I am over my head on this one.. I am open to ways > of restructuring this query to perform better. > > I have a table, 'ea', with 22 million rows in it. VACUUM ANALYZE has > been just run on the table. > > This is the result of: > > explain analyze > select distinct > em.incidentid, > ea.recordtext as retdata, > eg.long, > eg.lat > from > ea, em, eg > where > em.incidentid = ea.incidentid and > em.incidentid = eg.incidentid and > em.entrydate >= '2005-1-1 00:00' and > em.entrydate <= '2005-5-9 00:00' > and ea.incidentid in ( > select > incidentid > from > ea > where > recordtext like '%RED%' > ) > > and ea.incidentid in ( > select > incidentid > from > ea > where > recordtext like '%CORVETTE%' > ) > and ( recordtext like '%RED%' or recordtext like '%CORVETTE%' ) > order by em.entrydate > You cannot use an index for %CORVETTE%, or %RED%. There is no way for the index to know if a row had that in the middle without scanning the whole index. So it's much cheaper to do a sequence scan. One possible way to make the query faster is to limit based on date, as you will only get about 700 rows. And then don't use subselects, as they are doing full sequence scans. I think this query does what you do above, and I think it will be faster, but I don't know. select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= '2005-1-1 00:00' AND em.entrydate <= '2005-5-9 00:00' AND ea.recordtext like '%RED%' AND ea.recordtext like '%CORVETTE%') JOIN eg ON em.incidentid = eg.incidentid WHERE (recordtext like '%RED%' or recordtext like '%CORVETTE%' ); > > --------------------- > ANALYZE RESULTS > --------------------- > > Unique (cost=774693.72..774693.76 rows=1 width=159) (actual time=446787.056..446787.342 rows=72 loops=1) > -> Sort (cost=774693.72..774693.72 rows=1 width=159) (actual time=446787.053..446787.075 rows=72 loops=1) > Sort Key: em.incidentid, public.ea.recordtext, eg.long, eg.lat > -> Nested Loop (cost=771835.10..774693.71 rows=1 width=159) (actual time=444378.655..446786.746 rows=72 loops=1) > -> Nested Loop (cost=771835.10..774688.81 rows=1 width=148) (actual time=444378.532..446768.381 rows=72 loops=1) > -> Nested Loop IN Join (cost=771835.10..774678.88 rows=2 width=81) (actual time=444367.080..446191.864 rows=701 loops=1) > -> Nested Loop (cost=771835.10..774572.05 rows=42 width=64) (actual time=444366.859..445463.232 rows=1011 loops=1) > -> HashAggregate (cost=771835.10..771835.10 rows=1 width=17) (actual time=444366.702..444368.583 rows=473 loops=1) > -> Seq Scan on ea (cost=0.00..771834.26 rows=335 width=17) (actual time=259.746..444358.837 rows=592 loops=1) > Filter: ((recordtext)::text ~~ '%CORVETTE%'::text) > -> Index Scan using ea1 on ea (cost=0.00..2736.43 rows=42 width=47) (actual time=2.085..2.309 rows=2 loops=473) > Index Cond: ((ea.incidentid)::text = ("outer".incidentid)::text) > Filter: (((recordtext)::text ~~ '%RED%'::text) OR ((recordtext)::text ~~ '%CORVETTE%'::text)) > -> Index Scan using ea1 on ea (cost=0.00..2733.81 rows=42 width=17) (actual time=0.703..0.703 rows=1 loops=1011) > Index Cond: (("outer".incidentid)::text = (ea.incidentid)::text) > Filter: ((recordtext)::text ~~ '%RED%'::text) > -> Index Scan using em_incidentid_idx on em (cost=0.00..4.95 rows=1 width=67) (actual time=0.820..0.821 rows=0 loops=701) > Index Cond: (("outer".incidentid)::text = (em.incidentid)::text) > Filter: ((entrydate >= '2005-01-01 00:00:00'::timestamp without time zone) AND (entrydate <= '2005-05-09 00:00:00'::timestamp without time zone)) > -> Index Scan using eg_incidentid_idx on eg (cost=0.00..4.89 rows=1 width=79) (actual time=0.245..0.246 rows=1 loops=72) > Index Cond: (("outer".incidentid)::text = (eg.incidentid)::text) > Total runtime: 446871.880 ms > (22 rows) > > > ------------------------- > EXPLANATION > ------------------------- > The reason for the redundant LIKE clause is that first, I only want > those "incidentid"s that contain the words 'RED' and 'CORVETTE'. BUT, > those two words may exist across multiple records with the same > incidentid. Then, I only want to actually work with the rows that > contain one of the words. This query will repeat the same logic for > however many keywords are entered by the user. I have investigated > text searching options and have not found them to be congruous with my > application. > > Why is it choosing a sequential scan one part of the query when > searching for the words, yet using an index scan for another part of > it? Is there a better way to structure the query to give it better > hints? > > I'm using 8.0.1 on a 4-way Opteron with beefy RAID-10 and 12GB of RAM. > > Thank you for any advice. > > -Dan > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > > From pgsql-performance-owner@postgresql.org Sun May 8 21:58:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6598D53B19 for ; Sun, 8 May 2005 21:58:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92815-02 for ; Mon, 9 May 2005 00:58:20 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 584BE533AA for ; Sun, 8 May 2005 21:58:19 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j490wMnk015031; Sun, 8 May 2005 20:58:22 -0400 (EDT) To: Russell Smith Cc: Dan Harris , pgsql-performance@postgresql.org Subject: Re: Query tuning help In-reply-to: <200505091051.14689.mr-russ@pws.com.au> References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> Comments: In-reply-to Russell Smith message dated "Mon, 09 May 2005 10:51:14 +1000" Date: Sun, 08 May 2005 20:58:22 -0400 Message-ID: <15030.1115600302@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/90 X-Sequence-Number: 12254 Russell Smith writes: > On Mon, 9 May 2005 09:20 am, Dan Harris wrote: >> and ( recordtext like '%RED%' or recordtext like '%CORVETTE%' ) >> > You cannot use an index for %CORVETTE%, or %RED%. Not a btree index anyway. Dan might have some success here with a full-text-indexing package (eg, contrib/tsearch2) regards, tom lane From pgsql-performance-owner@postgresql.org Sun May 8 22:49:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 96B0153B85 for ; Sun, 8 May 2005 22:49:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01287-06 for ; Mon, 9 May 2005 01:49:29 +0000 (GMT) Received: from crestone.coronasolutions.com (crestone.coronasolutions.com [66.45.104.24]) by svr1.postgresql.org (Postfix) with ESMTP id 6BDCF539B5 for ; Sun, 8 May 2005 22:49:28 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by crestone.coronasolutions.com (Postfix) with ESMTP id 534F76441CB for ; Sun, 8 May 2005 19:49:25 -0600 (MDT) Received: from crestone.coronasolutions.com ([127.0.0.1]) by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 25844-02 for ; Sun, 8 May 2005 19:49:24 -0600 (MDT) Received: from [192.168.1.3] (c-24-9-111-5.hsd1.co.comcast.net [24.9.111.5]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by crestone.coronasolutions.com (Postfix) with ESMTP id 33FFD6441C8 for ; Sun, 8 May 2005 19:49:24 -0600 (MDT) Mime-Version: 1.0 (Apple Message framework v622) In-Reply-To: <200505091051.14689.mr-russ@pws.com.au> References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> Content-Transfer-Encoding: 7bit From: Dan Harris Subject: Re: Query tuning help Date: Sun, 8 May 2005 19:49:30 -0600 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/91 X-Sequence-Number: 12255 On May 8, 2005, at 6:51 PM, Russell Smith wrote: > On Mon, 9 May 2005 09:20 am, Dan Harris wrote: > You cannot use an index for %CORVETTE%, or %RED%. There is no way > for the index to know if a row had that in the middle without scanning > the whole > index. So it's much cheaper to do a sequence scan. > While I believe you, I'm confused by this line in my original EXPLAIN ANALYZE: >> -> Index Scan using ea1 on ea (cost=0.00..2736.43 rows=42 width=47) >> (actual time=2.085..2.309 rows=2 loops=473) >> Index Cond: >> ((ea.incidentid)::text = ("outer".incidentid)::text) >> Filter: (((recordtext)::text >> ~~ '%RED%'::text) OR ((recordtext)::text ~~ '%CORVETTE%'::text)) Doesn't that mean it was using an index to filter? Along those lines, before I created index 'ea1', the query was much much slower. So, it seemed like creating this index made a difference. > One possible way to make the query faster is to limit based on date, > as you will only get about 700 rows. > And then don't use subselects, as they are doing full sequence scans. > I think this query does what you do > above, and I think it will be faster, but I don't know. > I REALLY like this idea! If I could just filter by date first and then sequential scan through those, it should be very manageable. Hopefully I can keep this goal while still accommodating the requirement listed in my next paragraph. > select distinct em.incidentid, ea.recordtext as retdata, eg.long, > eg.lat > FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= > '2005-1-1 00:00' > AND em.entrydate <= '2005-5-9 00:00' AND ea.recordtext like '%RED%' > AND ea.recordtext like '%CORVETTE%') > JOIN eg ON em.incidentid = eg.incidentid WHERE (recordtext like > '%RED%' or recordtext like '%CORVETTE%' ); > I have run this, and while it is very fast, I'm concerned it's not doing what I need. Here's the situation: Due to the format of the systems with which I integrate ( I have no control over these formats ), we will get these 'recordtext' values one line at a time, accumulating over time. The only way I can find to make this work is to insert a new record for each line. The problem is, that when someone wants to search multiple keywords, they expect these words to be matched across multiple records with a given incident number. For a very simple example: IncidentID Date Recordtext -------------- ------------- ------------------------------------------------------- 11111 2005-05-01 14:21 blah blah blah RED blah blah 2222 2005-05-01 14:23 not what we are looking for 11111 2005-05-02 02:05 blah CORVETTE blah blah So, doing a search with an 'and' condition, e.g. WHERE RECORDTEXT LIKE '%RED%' AND RECORDTEXT LIKE '%CORVETTE%' , will not match because the condition will only be applied to a single row of recordtext at a time, not a whole group with the same incident number. If I were to use tsearch2 for full-text indexing, would I need to create another table that merges all of my recordtext rows into a single 'text' field type? If so, this is where I run into problems, as my logic also needs to match multiple words in their original order. I may also receive additional updates to the previous data. In that case, I need to replace the original record with the latest version of it. If I have already concatenated these rows into a single field, the logic to in-line replace only the old text that has changed is very very difficult at best. So, that's the reason I had to do two subqueries in my example. Please tell me if I misunderstood your logic and it really will match given my condition above, but it didn't seem like it would. Thanks again for the quick responses! This list has been a great resource for me. -Dan From pgsql-performance-owner@postgresql.org Sun May 8 23:06:47 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6E12C5388B for ; Sun, 8 May 2005 23:06:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43417-04 for ; Mon, 9 May 2005 02:06:44 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 06DC15385B for ; Sun, 8 May 2005 23:06:43 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7337879; Sun, 08 May 2005 19:08:46 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Dan Harris Subject: Re: Query tuning help Date: Sun, 8 May 2005 19:06:47 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> In-Reply-To: <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505081906.47731.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/92 X-Sequence-Number: 12256 Dan, > While I believe you, I'm confused by this line in my original EXPLAIN > > ANALYZE: > >> -> Index Scan using ea1 on ea (cost=0.00..2736.43 rows=42 width=47) > >> (actual time=2.085..2.309 rows=2 loops=473) > >> Index Cond: > >> ((ea.incidentid)::text = ("outer".incidentid)::text) > >> Filter: (((recordtext)::text > >> ~~ '%RED%'::text) OR ((recordtext)::text ~~ '%CORVETTE%'::text)) The index named is matching based on incidentid -- the join condition. The "filter" is applied against the table rows, i.e. a scan. > If I were to use tsearch2 for full-text indexing, would I need to > create another table that merges all of my recordtext rows into a > single 'text' field type? No. Read the OpenFTS docs, they are fairly clear on how to set up a simple FTS index. (TSearch2 ~~ OpenFTS) > If so, this is where I run into problems, as > my logic also needs to match multiple words in their original order. You do that by doubling up ... that is, use the FTS index to pick all rows that contain "RED" and "CORVETTE", and then check the order. I'll also note that your current query is not checking word order. Example: WHERE recordtext_fti @@ to_tsquery ('default', 'RED && CORVETTE') AND recordtext LIKE '%RED%CORVETTE%' I'm doing something fairly similar on one of my projects and it works very well. The limitations on TSearch2 indexes are: 1) they are expensive to update, so your data loads would be noticably slower. 2) they are only fast when cached in RAM (and when cached, are *very* fast). So if you have a variety of other processes that tend to fill up RAM between searches, you may find them less useful. 3) You have to create a materialized index column next to recordtext, which will increase the size of the table. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun May 8 23:17:54 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CE082537CB for ; Sun, 8 May 2005 23:17:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51356-05 for ; Mon, 9 May 2005 02:17:44 +0000 (GMT) Received: from 3times25.net (66-23-211-34.clients.speedfactory.net [66.23.211.34]) by svr1.postgresql.org (Postfix) with ESMTP id 6501B52949 for ; Sun, 8 May 2005 23:17:43 -0300 (ADT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by 3times25.net (Postfix) with ESMTP id 2D3A174404; Sun, 8 May 2005 22:17:42 -0400 (EDT) Message-ID: <427EC845.8080608@3times25.net> Date: Sun, 08 May 2005 22:17:41 -0400 From: Geoffrey User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050422 Red Hat/1.7.7-1.4.2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> In-Reply-To: <1115415551.427be3ffe44c8@webmail.telus.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.039 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/93 X-Sequence-Number: 12257 Mischa Sandberg wrote: > After reading the comparisons between Opteron and Xeon processors for Linux, > I'd like to add an Opteron box to our stable of Dells and Sparcs, for comparison. > > IBM, Sun and HP have their fairly pricey Opteron systems. > The IT people are not swell about unsupported purchases off ebay. > Anyone care to suggest any other vendors/distributors? > Looking for names with national support, so that we can recommend as much to our > customers. Monarch Computer http://www.monarchcomputer.com/ They have prebuilt and custom built systems. -- Until later, Geoffrey From pgsql-performance-owner@postgresql.org Sun May 8 23:29:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5FD3E538A4 for ; Sun, 8 May 2005 23:28:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51272-10 for ; Mon, 9 May 2005 02:28:49 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CC157537CB for ; Sun, 8 May 2005 23:28:48 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j492Spsk015735; Sun, 8 May 2005 22:28:51 -0400 (EDT) To: Dan Harris Cc: pgsql-performance@postgresql.org Subject: Re: Query tuning help In-reply-to: <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> Comments: In-reply-to Dan Harris message dated "Sun, 08 May 2005 19:49:30 -0600" Date: Sun, 08 May 2005 22:28:51 -0400 Message-ID: <15734.1115605731@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/94 X-Sequence-Number: 12258 Dan Harris writes: >> -> Index Scan using ea1 on ea (cost=0.00..2736.43 rows=42 width=47) (actual time=2.085..2.309 rows=2 loops=473) >> Index Cond: ((ea.incidentid)::text = ("outer".incidentid)::text) >> Filter: (((recordtext)::text ~~ '%RED%'::text) OR ((recordtext)::text ~~ '%CORVETTE%'::text)) > Doesn't that mean it was using an index to filter? No. The "Index Cond" shows it is using the index only for the join condition. A "Filter" is an additional filter condition that happens to get applied at this plan node --- but it'll be applied to every row the index finds for the index condition. regards, tom lane From pgsql-performance-owner@postgresql.org Sun May 8 23:31:51 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B5C7C533EE for ; Sun, 8 May 2005 23:31:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57622-05 for ; Mon, 9 May 2005 02:31:40 +0000 (GMT) Received: from crestone.coronasolutions.com (crestone.coronasolutions.com [66.45.104.24]) by svr1.postgresql.org (Postfix) with ESMTP id B464552AA9 for ; Sun, 8 May 2005 23:31:36 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by crestone.coronasolutions.com (Postfix) with ESMTP id 324C36441C8 for ; Sun, 8 May 2005 20:31:34 -0600 (MDT) Received: from crestone.coronasolutions.com ([127.0.0.1]) by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26232-05 for ; Sun, 8 May 2005 20:31:33 -0600 (MDT) Received: from [192.168.1.3] (c-24-9-111-5.hsd1.co.comcast.net [24.9.111.5]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by crestone.coronasolutions.com (Postfix) with ESMTP id 533C96441B9 for ; Sun, 8 May 2005 20:31:33 -0600 (MDT) Mime-Version: 1.0 (Apple Message framework v622) In-Reply-To: <200505081906.47731.josh@agliodbs.com> References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> <200505081906.47731.josh@agliodbs.com> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <7fc67646a961f5ebef90def7aeb95fd0@drivefaster.net> Content-Transfer-Encoding: 7bit From: Dan Harris Subject: Re: Query tuning help Date: Sun, 8 May 2005 20:31:38 -0600 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/95 X-Sequence-Number: 12259 On May 8, 2005, at 8:06 PM, Josh Berkus wrote: > >> If I were to use tsearch2 for full-text indexing, would I need to >> create another table that merges all of my recordtext rows into a >> single 'text' field type? > > No. Read the OpenFTS docs, they are fairly clear on how to set up a > simple > FTS index. (TSearch2 ~~ OpenFTS) > >> If so, this is where I run into problems, as >> my logic also needs to match multiple words in their original order. I have been reading the Tsearch2 docs and either I don't understand something or I'm not communicating my situation clearly enough. It seems that Tsearch2 has a concept of "document". And, in everything I am reading, they expect your "document" to be all contained in a single row. Since my words can be spread across multiple rows, I don't see that Tsearch2 will combine all 'recordtext' row values with the same "incidentid" into a single vector. Am I overlooking something in the docs? > > I'm doing something fairly similar on one of my projects and it works > very > well. > I'd be curious what similarities they have? Is it the searching across multiple rows or the order of words? > The limitations on TSearch2 indexes are: > 1) they are expensive to update, so your data loads would be noticably > slower. > 2) they are only fast when cached in RAM (and when cached, are *very* > fast). > So if you have a variety of other processes that tend to fill up RAM > between > searches, you may find them less useful. > 3) You have to create a materialized index column next to recordtext, > which > will increase the size of the table. Duly noted. If this method can search across rows, I'm willing to accept this overhead for the speed it would add. In the meantime, is there any way I can reach my goal without Tsearch2 by just restructuring my query to narrow down the results by date first, then seq scan for the 'likes'? -Dan From pgsql-performance-owner@postgresql.org Sun May 8 23:32:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 48B35538D9 for ; Sun, 8 May 2005 23:32:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46853-10 for ; Mon, 9 May 2005 02:32:04 +0000 (GMT) Received: from pws.com.au (mail.pws.com.au [210.23.138.139]) by svr1.postgresql.org (Postfix) with SMTP id 51943538D8 for ; Sun, 8 May 2005 23:32:02 -0300 (ADT) Received: (qmail 31124 invoked from network); 9 May 2005 02:32:06 -0000 Received: from unknown (HELO wizzard.pws.com.au) (russell@pws.com.au@138.217.54.70) by mail.pws.com.au with SMTP; 9 May 2005 02:32:06 -0000 From: Russell Smith To: Dan Harris Subject: Re: Query tuning help Date: Mon, 9 May 2005 12:32:05 +1000 User-Agent: KMail/1.7.2 Cc: pgsql-performance@postgresql.org References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> In-Reply-To: <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505091232.05495.mr-russ@pws.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.034 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/96 X-Sequence-Number: 12260 On Mon, 9 May 2005 11:49 am, Dan Harris wrote: > > On May 8, 2005, at 6:51 PM, Russell Smith wrote: > [snip] > > select distinct em.incidentid, ea.recordtext as retdata, eg.long, > > eg.lat > > FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= > > '2005-1-1 00:00' > > AND em.entrydate <= '2005-5-9 00:00' AND ea.recordtext like '%RED%' > > AND ea.recordtext like '%CORVETTE%') > > JOIN eg ON em.incidentid = eg.incidentid WHERE (recordtext like > > '%RED%' or recordtext like '%CORVETTE%' ); > > > > I have run this, and while it is very fast, I'm concerned it's not > doing what I need. How fast is very fast? > Here's the situation: > > Due to the format of the systems with which I integrate ( I have no > control over these formats ), we will get these 'recordtext' values one > line at a time, accumulating over time. The only way I can find to > make this work is to insert a new record for each line. The problem > is, that when someone wants to search multiple keywords, they expect > these words to be matched across multiple records with a given incident > number. > > For a very simple example: > > IncidentID Date Recordtext > -------------- ------------- > ------------------------------------------------------- > 11111 2005-05-01 14:21 blah blah blah RED blah blah > 2222 2005-05-01 14:23 not what we are looking for > 11111 2005-05-02 02:05 blah CORVETTE blah blah > > So, doing a search with an 'and' condition, e.g. WHERE RECORDTEXT LIKE > '%RED%' AND RECORDTEXT LIKE '%CORVETTE%' , will not match because the > condition will only be applied to a single row of recordtext at a time, > not a whole group with the same incident number. > > If I were to use tsearch2 for full-text indexing, would I need to > create another table that merges all of my recordtext rows into a > single 'text' field type? If so, this is where I run into problems, as > my logic also needs to match multiple words in their original order. I > may also receive additional updates to the previous data. In that > case, I need to replace the original record with the latest version of > it. If I have already concatenated these rows into a single field, the > logic to in-line replace only the old text that has changed is very > very difficult at best. So, that's the reason I had to do two > subqueries in my example. Please tell me if I misunderstood your logic > and it really will match given my condition above, but it didn't seem > like it would. > > Thanks again for the quick responses! This list has been a great > resource for me. > select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= '2005-1-1 00:00' AND em.entrydate <= '2005-5-9 00:00' AND (ea.recordtext like '%RED%' OR ea.recordtext like '%CORVETTE%')) JOIN eg ON em.incidentid = eg.incidentid WHERE em.incidentid IN (select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= '2005-1-1 00:00' AND em.entrydate <= '2005-5-9 00:00' AND ea.recordtext like '%CORVETTE%')) JOIN eg ON em.incidentid = eg.incidentid) AND em.incidentid IN (select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= '2005-1-1 00:00' AND em.entrydate <= '2005-5-9 00:00' AND ea.recordtext like '%RED%')) JOIN eg ON em.incidentid = eg.incidentid) This may be more accurate. However I would cool it VERY NASTY. Josh's solutions may be better. However much of the data should be in memory once the subplans are done, so it may be quite fast. you may > > > -Dan > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > > From pgsql-performance-owner@postgresql.org Sun May 8 23:49:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD81B537E0 for ; Sun, 8 May 2005 23:49:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74178-08 for ; Mon, 9 May 2005 02:49:06 +0000 (GMT) Received: from crestone.coronasolutions.com (crestone.coronasolutions.com [66.45.104.24]) by svr1.postgresql.org (Postfix) with ESMTP id D7EA852AA9 for ; Sun, 8 May 2005 23:49:05 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by crestone.coronasolutions.com (Postfix) with ESMTP id A94E36440DF for ; Sun, 8 May 2005 20:49:02 -0600 (MDT) Received: from crestone.coronasolutions.com ([127.0.0.1]) by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26395-05 for ; Sun, 8 May 2005 20:49:01 -0600 (MDT) Received: from [192.168.1.3] (c-24-9-111-5.hsd1.co.comcast.net [24.9.111.5]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by crestone.coronasolutions.com (Postfix) with ESMTP id D913F6440C9 for ; Sun, 8 May 2005 20:49:01 -0600 (MDT) Mime-Version: 1.0 (Apple Message framework v622) In-Reply-To: <200505091232.05495.mr-russ@pws.com.au> References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> <200505091232.05495.mr-russ@pws.com.au> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <93c69c01ae38d2b95c902e05da1ffe19@drivefaster.net> Content-Transfer-Encoding: 7bit From: Dan Harris Subject: Re: Query tuning help Date: Sun, 8 May 2005 20:49:07 -0600 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/97 X-Sequence-Number: 12261 On May 8, 2005, at 8:32 PM, Russell Smith wrote: >> I have run this, and while it is very fast, I'm concerned it's not >> doing what I need. > How fast is very fast? > It took 35 seconds to complete versus ~450 my old way. > > select distinct em.incidentid, ea.recordtext as retdata, eg.long, > eg.lat > FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= > '2005-1-1 00:00' > AND em.entrydate <= '2005-5-9 00:00' AND (ea.recordtext like '%RED%' > OR ea.recordtext like '%CORVETTE%')) > JOIN eg ON em.incidentid = eg.incidentid WHERE > em.incidentid IN > (select distinct em.incidentid, ea.recordtext as retdata, eg.long, > eg.lat > FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= > '2005-1-1 00:00' > AND em.entrydate <= '2005-5-9 00:00' AND ea.recordtext like > '%CORVETTE%')) > JOIN eg ON em.incidentid = eg.incidentid) AND > em.incidentid IN > (select distinct em.incidentid, ea.recordtext as retdata, eg.long, > eg.lat > FROM em JOIN ea ON (em.incidentid = ea.incidentid AND em.entrydate >= > '2005-1-1 00:00' > AND em.entrydate <= '2005-5-9 00:00' AND ea.recordtext like '%RED%')) > JOIN eg ON em.incidentid = eg.incidentid) > Yes, it is nasty, but so was my previous query :) So long as this is faster, I'm ok with that. I'll see if i can make this work. Thank you very much. -Dan From pgsql-performance-owner@postgresql.org Mon May 9 01:14:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9562953C44 for ; Mon, 9 May 2005 01:14:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31244-09 for ; Mon, 9 May 2005 04:14:29 +0000 (GMT) Received: from mailhub1.une.edu.au (mailhub.une.edu.au [129.180.1.122]) by svr1.postgresql.org (Postfix) with ESMTP id 87FC553B33 for ; Mon, 9 May 2005 01:14:23 -0300 (ADT) Received: from icarus.une.edu.au (icarus.une.edu.au [129.180.47.120]) by mailhub1.une.edu.au (Postfix) with ESMTP id 7E92C7EA5; Mon, 9 May 2005 14:14:22 +1000 (EST) Received: from kgb ([129.180.47.225]) by icarus.une.edu.au (8.12.8/8.12.8) with SMTP id j494EMG7016022; Mon, 9 May 2005 14:14:22 +1000 Date: Mon, 09 May 2005 14:17:17 +1000 From: Klint Gore To: Dan Harris Cc: pgsql-performance@postgresql.org Subject: Re: Query tuning help In-Reply-To: <7fc67646a961f5ebef90def7aeb95fd0@drivefaster.net> References: <200505081906.47731.josh@agliodbs.com> <7fc67646a961f5ebef90def7aeb95fd0@drivefaster.net> Message-Id: <427EE44D37F.5629KG@129.180.47.120> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver 1.25.06 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/98 X-Sequence-Number: 12262 On Sun, 8 May 2005 20:31:38 -0600, Dan Harris wrote: > Duly noted. If this method can search across rows, I'm willing to > accept this overhead for the speed it would add. You could use intersect to search across rows. Using tsearch2 will look up the RED and CORVETTE using the index and intersect will pull out the commmon rows. > In the meantime, is there any way I can reach my goal without Tsearch2 > by just restructuring my query to narrow down the results by date > first, then seq scan for the 'likes'? select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat >from ea, em, eg, ( select ea.incidentid from ea, em where em.incidentid = ea.incidentid and em.entrydate >= '2005-1-1 00:00' and em.entrydate <= '2005-5-9 00:00' and recordtext like '%RED%' intersect select ea.incidentid from ea, em where em.incidentid = ea.incidentid and em.entrydate >= '2005-1-1 00:00' and em.entrydate <= '2005-5-9 00:00' and recordtext like '%CORVETTE%' ) as iid where em.incidentid = ea.incidentid and em.incidentid = eg.incidentid and em.entrydate >= '2005-1-1 00:00' and em.entrydate <= '2005-5-9 00:00' and ea.incidentid = iid.incidentid and ( recordtext like '%RED%' or recordtext like '%CORVETTE%' ) order by em.entrydate klint. +---------------------------------------+-----------------+ : Klint Gore : "Non rhyming : : EMail : kg@kgb.une.edu.au : slang - the : : Snail : A.B.R.I. : possibilities : : Mail University of New England : are useless" : : Armidale NSW 2351 Australia : L.J.J. : : Fax : +61 2 6772 5376 : : +---------------------------------------+-----------------+ From pgsql-performance-owner@postgresql.org Mon May 9 02:49:12 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A357253C62 for ; Mon, 9 May 2005 02:49:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48967-06 for ; Mon, 9 May 2005 05:49:05 +0000 (GMT) Received: from p0f.net (p0f.net [193.77.154.190]) by svr1.postgresql.org (Postfix) with ESMTP id E029553C59 for ; Mon, 9 May 2005 02:49:04 -0300 (ADT) Received: from [10.10.105.30] ([193.77.165.58]) (authenticated bits=0) by p0f.net (8.13.3/8.13.3) with ESMTP id j495NOqm006323 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 9 May 2005 07:23:29 +0200 Message-ID: <427EF8B4.7010203@p0f.net> Date: Mon, 09 May 2005 07:44:20 +0200 From: Grega Bremec Organization: P0F User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Jeroen van Iddekinge , pgsql-performance@postgresql.org Subject: Re: sequence scan on PK References: <427E2941.9070105@lycos.com> <427E17BC.7050407@arbash-meinel.com> <427E5130.7020702@lycos.com> <12303.1115570959@sss.pgh.pa.us> In-Reply-To: <12303.1115570959@sss.pgh.pa.us> X-Enigmail-Version: 0.91.0.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.22 tagged_above=0 required=5 tests=AWL, RCVD_IN_NJABL_DUL X-Spam-Level: * X-Archive-Number: 200505/99 X-Sequence-Number: 12263 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tom Lane wrote: | Jeroen van Iddekinge writes: | |>>You could tweak with several settings to get it to do an index scan |>>earlier, but these would probably break other queries. You don't need to |>>tune for 100 rows, morelike 100k or 100M. | | |>Which settings shoud I change for this? | | | I'd agree with John's response: if you change any settings based on just | this one test case, you're a fool. But usually random_page_cost is the | best knob to twiddle if you wish to encourage indexscans. | Perhaps just a small comment - before starting the tuning process, you want to make sure the query planner has the right ideas about the nature of data contained in your indexed column. Sometimes, if you insert reasonably sized batches of records containing the same value for that column (for example in a multicolumn key where you usually retrieve by only one column), statistics collector (used to) get out of sync with reality with regard to cardinality of data, because the default snapshot is too small to provide it with objective insight. If you're intimate with your data, you probably want to increase statistics target on that column and/or do some other statistics-related magic and ANALYZE the table again; that alone can mean the difference between a sequential and an index scan where appropriate, and most importantly, you don't need to distort the database's understanding of your hardware to achieve optimal plans (provided you have the value set to proper values, of course), so you won't get bitten where you don't expect it. :) Again, this might not pertain to a 100-row table, but is a good thing [tm] to know when optimizing. I personally would prefer to look at that aspect of optimizer's understanding of data before anything else. Hope this helps. Regards, - -- Grega Bremec gregab at p0f dot net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFCfvizfu4IwuB3+XoRAhI1AJ92uhoh0u9q7/XPllH37o5KXlpJdwCfQ+2b sJhq4ZWDdZU9x4APoGOsMes= =Tq99 -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Mon May 9 08:42:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3106153558 for ; Mon, 9 May 2005 08:42:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01353-05 for ; Mon, 9 May 2005 11:42:29 +0000 (GMT) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id 29BE65321E for ; Mon, 9 May 2005 08:42:27 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DV6Wk-0000hV-DY for pgsql-performance@postgresql.org; Mon, 09 May 2005 13:34:22 +0200 Received: from srv.protecting.net ([212.126.218.242]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 09 May 2005 13:34:22 +0200 Received: from hf1122x by srv.protecting.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 09 May 2005 13:34:22 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: Harald Fuchs Subject: Re: Query tuning help Date: 09 May 2005 13:39:30 +0200 Organization: Linux Private Site Lines: 31 Message-ID: References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> <200505081906.47731.josh@agliodbs.com> <7fc67646a961f5ebef90def7aeb95fd0@drivefaster.net> Reply-To: hf1122x@protecting.net Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: srv.protecting.net User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/100 X-Sequence-Number: 12264 In article <7fc67646a961f5ebef90def7aeb95fd0@drivefaster.net>, Dan Harris writes: > On May 8, 2005, at 8:06 PM, Josh Berkus wrote: >> >>> If I were to use tsearch2 for full-text indexing, would I need to >>> create another table that merges all of my recordtext rows into a >>> single 'text' field type? >> >> No. Read the OpenFTS docs, they are fairly clear on how to set up >> a simple >> FTS index. (TSearch2 ~~ OpenFTS) >> >>> If so, this is where I run into problems, as >>> my logic also needs to match multiple words in their original order. > I have been reading the Tsearch2 docs and either I don't understand > something or I'm not communicating my situation clearly enough. It > seems that Tsearch2 has a concept of "document". And, in everything I > am reading, they expect your "document" to be all contained in a > single row. Since my words can be spread across multiple rows, I > don't see that Tsearch2 will combine all 'recordtext' row values with > the same "incidentid" into a single vector. Am I overlooking > something in the docs? AFAICS no, but you could create a separate table containing just the distinct incidentids and the tsearch2 vectors of all recordtexts matching that incidentid. This table would get updated solely by triggers on the original table and would provide a fast way to get all incidentids for RED and CORVETTE. The question is: would this reduce the number of rows to check more than filtering on date? From pgsql-general-owner@postgresql.org Mon May 9 10:40:38 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BD4D55352E; Mon, 9 May 2005 10:40:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19073-03; Mon, 9 May 2005 13:40:34 +0000 (GMT) Received: from perseverance.encs.concordia.ca (perseverance-96.encs.concordia.ca [132.205.96.94]) by svr1.postgresql.org (Postfix) with ESMTP id 35B21534D3; Mon, 9 May 2005 10:40:33 -0300 (ADT) Received: from [132.205.44.35] (IDENT:emilu@curacao.cs.concordia.ca [132.205.44.35]) by perseverance.encs.concordia.ca (8.12.11/8.12.11) with ESMTP id j49DeaYa016604; Mon, 9 May 2005 09:40:36 -0400 Message-ID: <427F6853.90308@cs.concordia.ca> Date: Mon, 09 May 2005 09:40:35 -0400 From: Ying Lu User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-general@postgresql.org Cc: pgsql-performance@postgresql.org Subject: "Hash index" vs. "b-tree index" (PostgreSQL 8.0) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.43 on perseverance.encs.concordia.ca at 2005/05/09 09:40:36 EDT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.021 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/370 X-Sequence-Number: 77718 Greetings, We are working on speeding up the queries by creating indexes. We have queries with searching criteria such as "select ... where *col1='...'*". This is a simple query with only "=" operation. As a result I setup hash index on column "col1". While, in postgreSQL 8 doc, it is wirttern: *Note: * Testing has shown PostgreSQL's hash indexes to perform no better than B-tree indexes, and the index size and build time for hash indexes is much worse. For these reasons, hash index use is presently discouraged. May I know for simple "=" operation query, for "Hash index" vs. "B-tree" index, which can provide better performance please? Thanks, Emi From pgsql-general-owner@postgresql.org Mon May 9 11:37:04 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 55C8353C1F; Mon, 9 May 2005 11:37:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29355-06; Mon, 9 May 2005 14:36:57 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id EB1BF5364A; Mon, 9 May 2005 11:36:56 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 215D418CC84; Mon, 9 May 2005 10:37:01 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 81082-01-3; Mon, 9 May 2005 10:36:50 -0400 (EDT) Received: from [220.101.4.182] (r220-101-4-182.cpe.unwired.net.au [220.101.4.182]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 0195518CC16; Mon, 9 May 2005 10:36:48 -0400 (EDT) Message-ID: <427F757A.8000407@samurai.com> Date: Tue, 10 May 2005 00:36:42 +1000 From: Neil Conway User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ying Lu Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: "Hash index" vs. "b-tree index" (PostgreSQL 8.0) References: <427F6853.90308@cs.concordia.ca> In-Reply-To: <427F6853.90308@cs.concordia.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/376 X-Sequence-Number: 77724 Ying Lu wrote: > May I know for simple "=" operation query, for "Hash index" vs. "B-tree" > index, which can provide better performance please? I don't think we've found a case in which the hash index code outperforms B+-tree indexes, even for "=". The hash index code also has a number of additional issues: for example, it isn't WAL safe, it has relatively poor concurrency, and creating a hash index is significantly slower than creating a b+-tree index. -Neil From pgsql-performance-owner@postgresql.org Mon May 9 12:06:05 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 15CFD53DAF for ; Mon, 9 May 2005 12:06:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33165-03 for ; Mon, 9 May 2005 15:06:01 +0000 (GMT) Received: from vt-pe2550-001.VANTAGE.vantage.com (vt-pe2550-001.vantage.com [64.80.203.244]) by svr1.postgresql.org (Postfix) with ESMTP id 702D953DF4 for ; Mon, 9 May 2005 12:05:59 -0300 (ADT) 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: Whence the Opterons? Date: Mon, 9 May 2005 11:05:58 -0400 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850989F3@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Whence the Opterons? Thread-Index: AcVUPmQ4XW2yzkdtRcmGHcWhctkHFQAaQooQ From: "Anjan Dave" To: "Geoffrey" , "Mischa Sandberg" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/103 X-Sequence-Number: 12267 You also want to consider any whitebox opteron system being on the compatibility list of your storage vendor, as well as RedHat, etc. With EMC you can file an RPQ via your sales contacts to get it approved, though not sure how lengthy/painful that process might be, or if it's gonna be worth it. Read the article devoted to the v40z on anandtech.com. I am also trying to get a quad-Opteron versus the latest quad-XEON from Dell (6850), but it's hard to justify a difference between a 15K dell versus a 30k v40z for a 5-8% performance gain (read the XEON Vs. Opteron Database comparo on anandtech.com)... Thanks, Anjan -----Original Message----- From: Geoffrey [mailto:esoteric@3times25.net]=20 Sent: Sunday, May 08, 2005 10:18 PM To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Whence the Opterons? Mischa Sandberg wrote: > After reading the comparisons between Opteron and Xeon processors for Linux, > I'd like to add an Opteron box to our stable of Dells and Sparcs, for comparison. >=20 > IBM, Sun and HP have their fairly pricey Opteron systems. > The IT people are not swell about unsupported purchases off ebay. > Anyone care to suggest any other vendors/distributors? > Looking for names with national support, so that we can recommend as much to our > customers. Monarch Computer http://www.monarchcomputer.com/ They have prebuilt and custom built systems. --=20 Until later, Geoffrey ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq From pgsql-performance-owner@postgresql.org Mon May 9 12:18:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AEAFF5371C for ; Mon, 9 May 2005 12:18:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34764-05 for ; Mon, 9 May 2005 15:18:30 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 6693152A62 for ; Mon, 9 May 2005 12:18:29 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j49FINUM007330; (envelope-from ) Mon, 9 May 2005 10:18:25 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j49FILmb005834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Mon, 9 May 2005 10:18:22 -0500 (CDT) Message-ID: <427F7F37.8020001@arbash-meinel.com> Date: Mon, 09 May 2005 10:18:15 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Geoffrey Cc: Mischa Sandberg , pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> <427EC845.8080608@3times25.net> In-Reply-To: <427EC845.8080608@3times25.net> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigD1F833880983C7FF4C6F29CA" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/104 X-Sequence-Number: 12268 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD1F833880983C7FF4C6F29CA Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Geoffrey wrote: > Mischa Sandberg wrote: > >> After reading the comparisons between Opteron and Xeon processors for >> Linux, >> I'd like to add an Opteron box to our stable of Dells and Sparcs, for >> comparison. >> >> IBM, Sun and HP have their fairly pricey Opteron systems. >> The IT people are not swell about unsupported purchases off ebay. >> Anyone care to suggest any other vendors/distributors? >> Looking for names with national support, so that we can recommend as >> much to our >> customers. > > > Monarch Computer http://www.monarchcomputer.com/ > > They have prebuilt and custom built systems. > I believe we have had some issues with their workstation class systems. Just a high rate of part failure, and DOA systems. I believe they RMA'd without too great of difficulties, but it was something like 50%. John =:-> --------------enigD1F833880983C7FF4C6F29CA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCf383JdeBCYSNAAMRAkLaAKDUyzeUyyNhsSiB6PJoyzkyjlsTggCbBrbY pufN9A9QO0o5409Y3VlvCNk= =a3kJ -----END PGP SIGNATURE----- --------------enigD1F833880983C7FF4C6F29CA-- From pgsql-performance-owner@postgresql.org Mon May 9 12:22:18 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0B32953609 for ; Mon, 9 May 2005 12:22:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36084-05 for ; Mon, 9 May 2005 15:22:09 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 0AB4653604 for ; Mon, 9 May 2005 12:22:08 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j49FM7GG007458; (envelope-from ) Mon, 9 May 2005 10:22:07 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j49FM58h006766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Mon, 9 May 2005 10:22:06 -0500 (CDT) Message-ID: <427F801B.7070601@arbash-meinel.com> Date: Mon, 09 May 2005 10:22:03 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Anjan Dave Cc: Geoffrey , Mischa Sandberg , pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850989F3@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850989F3@vt-pe2550-001.vantage.vantage.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig68F584A6B6A3E6B4D551E210" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/105 X-Sequence-Number: 12269 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig68F584A6B6A3E6B4D551E210 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Anjan Dave wrote: > You also want to consider any whitebox opteron system being on the > compatibility list of your storage vendor, as well as RedHat, etc. With > EMC you can file an RPQ via your sales contacts to get it approved, > though not sure how lengthy/painful that process might be, or if it's > gonna be worth it. > > Read the article devoted to the v40z on anandtech.com. > > I am also trying to get a quad-Opteron versus the latest quad-XEON from > Dell (6850), but it's hard to justify a difference between a 15K dell > versus a 30k v40z for a 5-8% performance gain (read the XEON Vs. Opteron > Database comparo on anandtech.com)... > > Thanks, > Anjan > 15k vs 30k is indeed a big difference. But also realize that Postgres has a specific benefit to Opterons versus Xeons. The context switching storm happens less on an Opteron for some reason. I would venture a much greater benefit than 5-8%, more like 10-50%. John =:-> --------------enig68F584A6B6A3E6B4D551E210 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCf4AbJdeBCYSNAAMRAtESAJ0aYD5575f1F2b7vIbSY/wJaAPWTQCgt8oe 3gNXJoSGlAXNNPQQyNjk1zw= =fwp+ -----END PGP SIGNATURE----- --------------enig68F584A6B6A3E6B4D551E210-- From pgsql-general-owner@postgresql.org Mon May 9 12:28:02 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A63653748 for ; Mon, 9 May 2005 12:27:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36800-04 for ; Mon, 9 May 2005 15:27:56 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) by svr1.postgresql.org (Postfix) with ESMTP id F13EB5373E for ; Mon, 9 May 2005 12:27:54 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1181998wri for ; Mon, 09 May 2005 08:27:54 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ph1XGFTr7Mv9bgYAnwHXtZropYG30Np0kg3//1ndaJ/seq6iTyx3uqvJefcWtDhlpQUM4Uk2/OQKcLm27rF7wBJ4UJ00B8mkE4TQZ4v2DR6LQti7a464BPBfQ9PwYtl5bLEfpkE/HuXgZoJO3g7FPIm/Ej8vmwwLOFGP8HkfrbM= Received: by 10.54.84.2 with SMTP id h2mr2701404wrb; Mon, 09 May 2005 08:27:54 -0700 (PDT) Received: by 10.54.117.15 with HTTP; Mon, 9 May 2005 08:27:54 -0700 (PDT) Message-ID: <59d991c405050908271b55e673@mail.gmail.com> Date: Mon, 9 May 2005 11:27:54 -0400 From: Christopher Petrilli Reply-To: Christopher Petrilli To: Neil Conway Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL 8.0) Cc: Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <427F757A.8000407@samurai.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.319 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/380 X-Sequence-Number: 77728 On 5/9/05, Neil Conway wrote: > I don't think we've found a case in which the hash index code > outperforms B+-tree indexes, even for "=3D". The hash index code also has > a number of additional issues: for example, it isn't WAL safe, it has > relatively poor concurrency, and creating a hash index is significantly > slower than creating a b+-tree index. This being the case, is there ever ANY reason for someone to use it?=20 If not, then shouldn't we consider deprecating it and eventually removing it. This would reduce complexity, I think. Chris --=20 | Christopher Petrilli | petrilli@gmail.com From pgsql-performance-owner@postgresql.org Mon May 9 12:30:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D52F853723 for ; Mon, 9 May 2005 12:29:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36770-05 for ; Mon, 9 May 2005 15:29:57 +0000 (GMT) Received: from vt-pe2550-001.VANTAGE.vantage.com (vt-pe2550-001.vantage.com [64.80.203.244]) by svr1.postgresql.org (Postfix) with ESMTP id 40C3A53741 for ; Mon, 9 May 2005 12:29:56 -0300 (ADT) 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: Whence the Opterons? Date: Mon, 9 May 2005 11:29:55 -0400 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7D6@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Whence the Opterons? Thread-Index: AcVUquTL7G8QzIkDQWm49FXzigZqoQAALHTg From: "Anjan Dave" To: "John A Meinel" Cc: "Geoffrey" , "Mischa Sandberg" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.058 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/107 X-Sequence-Number: 12271 Wasn't the context switching issue occurring in specific cases only? I haven't seen any benchmarks for a 50% performance difference. Neither have I seen any benchmarks of pure disk IO performance of specific models of Dell vs HP or Sun Opterons. Thanks, Anjan -----Original Message----- From: John A Meinel [mailto:john@arbash-meinel.com]=20 Sent: Monday, May 09, 2005 11:22 AM To: Anjan Dave Cc: Geoffrey; Mischa Sandberg; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Whence the Opterons? Anjan Dave wrote: > You also want to consider any whitebox opteron system being on the > compatibility list of your storage vendor, as well as RedHat, etc. With > EMC you can file an RPQ via your sales contacts to get it approved, > though not sure how lengthy/painful that process might be, or if it's > gonna be worth it. > > Read the article devoted to the v40z on anandtech.com. > > I am also trying to get a quad-Opteron versus the latest quad-XEON from > Dell (6850), but it's hard to justify a difference between a 15K dell > versus a 30k v40z for a 5-8% performance gain (read the XEON Vs. Opteron > Database comparo on anandtech.com)... > > Thanks, > Anjan > 15k vs 30k is indeed a big difference. But also realize that Postgres has a specific benefit to Opterons versus Xeons. The context switching storm happens less on an Opteron for some reason. I would venture a much greater benefit than 5-8%, more like 10-50%. John =3D:-> From pgsql-general-owner@postgresql.org Mon May 9 12:35:19 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 038FA52A3D; Mon, 9 May 2005 12:35:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38689-02; Mon, 9 May 2005 15:35:09 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 22A96535A5; Mon, 9 May 2005 12:35:08 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 3128E18CD50; Mon, 9 May 2005 11:35:08 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 83359-01; Mon, 9 May 2005 11:35:06 -0400 (EDT) Received: from [192.168.0.3] (r220-101-4-60.cpe.unwired.net.au [220.101.4.60]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id CD42018CC6E; Mon, 9 May 2005 11:35:03 -0400 (EDT) Message-ID: <427F8321.5030702@samurai.com> Date: Tue, 10 May 2005 01:34:57 +1000 From: Neil Conway User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christopher Petrilli Cc: Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> In-Reply-To: <59d991c405050908271b55e673@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/382 X-Sequence-Number: 77730 Christopher Petrilli wrote: > This being the case, is there ever ANY reason for someone to use it? Well, someone might fix it up at some point in the future. I don't think there's anything fundamentally wrong with hash indexes, it is just that the current implementation is a bit lacking. > If not, then shouldn't we consider deprecating it and eventually > removing it. I would personally consider the code to be deprecated already. I don't think there is much to be gained b removing it: the code is pretty isolated from the rest of the tree, and (IMHO) not a significant maintenance burden. -Neil From pgsql-performance-owner@postgresql.org Mon May 9 12:40:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 31FFF535A5 for ; Mon, 9 May 2005 12:40:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37107-08 for ; Mon, 9 May 2005 15:40:12 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id BBEED5359D for ; Mon, 9 May 2005 12:40:11 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j49FeAV9008329; (envelope-from ) Mon, 9 May 2005 10:40:10 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j49Fe8J1013479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Mon, 9 May 2005 10:40:09 -0500 (CDT) Message-ID: <427F8457.6000001@arbash-meinel.com> Date: Mon, 09 May 2005 10:40:07 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Anjan Dave Cc: Geoffrey , Mischa Sandberg , pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7D6@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7D6@vt-pe2550-001.vantage.vantage.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigD7E9B7E06D7EDFB9ED088353" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/109 X-Sequence-Number: 12273 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD7E9B7E06D7EDFB9ED088353 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Anjan Dave wrote: > Wasn't the context switching issue occurring in specific cases only? > > I haven't seen any benchmarks for a 50% performance difference. Neither > have I seen any benchmarks of pure disk IO performance of specific > models of Dell vs HP or Sun Opterons. > > Thanks, > Anjan > Well, I'm speaking more from what I remember reading, than personal testing. Probably 50% is too high, but I thought I remembered it being more general than just specific cases. I agree, though, that disk bandwidth is probably more important than CPU issues, though. And the extra 15k might get you a lot of disk performance. John =:-> --------------enigD7E9B7E06D7EDFB9ED088353 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCf4RXJdeBCYSNAAMRAihvAJ9bMJp2/iDFuJscU1ZbTpJ18tgC2QCfTyLp WqVBCOLvUwFm742Jxz15Y84= =f1iO -----END PGP SIGNATURE----- --------------enigD7E9B7E06D7EDFB9ED088353-- From pgsql-general-owner@postgresql.org Mon May 9 13:34:30 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3C50F53E58; Mon, 9 May 2005 13:34:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45719-10; Mon, 9 May 2005 16:34:24 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 79BC853479; Mon, 9 May 2005 13:34:24 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 0B104154BD; Mon, 9 May 2005 11:34:23 -0500 (CDT) Date: Mon, 9 May 2005 11:34:23 -0500 From: "Jim C. Nasby" To: Neil Conway Cc: Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL Message-ID: <20050509163423.GH35026@decibel.org> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <427F8321.5030702@samurai.com> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/395 X-Sequence-Number: 77743 On Tue, May 10, 2005 at 01:34:57AM +1000, Neil Conway wrote: > Christopher Petrilli wrote: > >This being the case, is there ever ANY reason for someone to use it? > > Well, someone might fix it up at some point in the future. I don't think > there's anything fundamentally wrong with hash indexes, it is just that > the current implementation is a bit lacking. > > >If not, then shouldn't we consider deprecating it and eventually > >removing it. > > I would personally consider the code to be deprecated already. > > I don't think there is much to be gained b removing it: the code is > pretty isolated from the rest of the tree, and (IMHO) not a significant > maintenance burden. That may be true, but it's also a somewhat 'developer-centric' view. ;) Having indexes that people shouldn't be using does add confusion for users, and presents the opportunity for foot-shooting. I don't know what purpose they once served, but if there's no advantage to them they should be officially depricated and eventually removed. Even if there is some kind of advantage (would they possibly speed up hash joins?), if there's no plans to fix them they should still be removed. If someone ever really wanted to do something with, the code would still be in CVS. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-general-owner@postgresql.org Mon May 9 13:39:08 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C486A53E40; Mon, 9 May 2005 13:39:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49386-02; Mon, 9 May 2005 16:39:03 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 2194F53E4D; Mon, 9 May 2005 13:39:02 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id E5FBA18CC40; Mon, 9 May 2005 12:39:02 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 85759-01-7; Mon, 9 May 2005 12:38:49 -0400 (EDT) Received: from [220.101.4.182] (r220-101-4-182.cpe.unwired.net.au [220.101.4.182]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 5918D18CD6D; Mon, 9 May 2005 12:38:46 -0400 (EDT) Message-ID: <427F9211.2090008@samurai.com> Date: Tue, 10 May 2005 02:38:41 +1000 From: Neil Conway User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Jim C. Nasby" Cc: Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> In-Reply-To: <20050509163423.GH35026@decibel.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/396 X-Sequence-Number: 77744 Jim C. Nasby wrote: > Having indexes that people shouldn't be using does add confusion for > users, and presents the opportunity for foot-shooting. Emitting a warning/notice on hash-index creation is something I've suggested in the past -- that would be fine with me. > Even if there is some kind of advantage (would they possibly speed up > hash joins?) No, hash joins and hash indexes are unrelated. -Neil From pgsql-general-owner@postgresql.org Mon May 9 13:51:39 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8CD0F53DC4; Mon, 9 May 2005 13:51:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51384-01; Mon, 9 May 2005 16:51:34 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id CD29053DC2; Mon, 9 May 2005 13:51:33 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 9418F152B6; Mon, 9 May 2005 11:51:33 -0500 (CDT) Date: Mon, 9 May 2005 11:51:33 -0500 From: "Jim C. Nasby" To: Neil Conway Cc: Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL Message-ID: <20050509165133.GJ35026@decibel.org> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <427F9211.2090008@samurai.com> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/399 X-Sequence-Number: 77747 On Tue, May 10, 2005 at 02:38:41AM +1000, Neil Conway wrote: > Jim C. Nasby wrote: > >Having indexes that people shouldn't be using does add confusion for > >users, and presents the opportunity for foot-shooting. > > Emitting a warning/notice on hash-index creation is something I've > suggested in the past -- that would be fine with me. Probably not a bad idea. > >Even if there is some kind of advantage (would they possibly speed up > >hash joins?) > > No, hash joins and hash indexes are unrelated. I know they are now, but does that have to be the case? Like I said, I don't know the history, so I don't know why we even have them to begin with. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Mon May 9 14:10:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AEE0D52A6F for ; Mon, 9 May 2005 14:08:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53613-09 for ; Mon, 9 May 2005 17:08:36 +0000 (GMT) Received: from smtp816.mail.sc5.yahoo.com (smtp816.mail.sc5.yahoo.com [66.163.170.2]) by svr1.postgresql.org (Postfix) with SMTP id D015653DCF for ; Mon, 9 May 2005 14:08:34 -0300 (ADT) Received: from unknown (HELO discord.dyndns.org) (jeffroe996@sbcglobal.net@69.226.228.31 with plain) by smtp816.mail.sc5.yahoo.com with SMTP; 9 May 2005 17:08:33 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by discord.dyndns.org (8.13.1/8.13.1) with ESMTP id j49H8R2f015190; Mon, 9 May 2005 10:08:27 -0700 Date: Mon, 9 May 2005 10:08:27 -0700 (PDT) From: Jeff Frost X-X-Sender: jeff@discord.dyndns.org To: John A Meinel Cc: Anjan Dave , Geoffrey , Mischa Sandberg , pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? In-Reply-To: <427F8457.6000001@arbash-meinel.com> Message-ID: References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7D6@vt-pe2550-001.vantage.vantage.com> <427F8457.6000001@arbash-meinel.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.04 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/113 X-Sequence-Number: 12277 On Mon, 9 May 2005, John A Meinel wrote: > Well, I'm speaking more from what I remember reading, than personal > testing. Probably 50% is too high, but I thought I remembered it being > more general than just specific cases. Anadtech had a benchmark here: http://www.anandtech.com/linux/showdoc.aspx?i=2163&p=2 It's a little old, as it's listing an Opteron 150 vs 3.6 Xeon, but it does show that the opteron comes in almost twice as fast as the Xeon doing Postgres. -- Jeff Frost, Owner Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 From pgsql-performance-owner@postgresql.org Mon May 9 14:23:48 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E3F015350D for ; Mon, 9 May 2005 14:23:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57106-03 for ; Mon, 9 May 2005 17:23:43 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9DC1A53363 for ; Mon, 9 May 2005 14:23:41 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id DB97830953; Mon, 9 May 2005 19:21:31 +0200 (MET DST) From: William Yu X-Newsgroups: pgsql.performance Subject: Re: Whence the Opterons? Date: Mon, 09 May 2005 10:23:34 -0700 Organization: Hub.Org Networking Services Lines: 56 Message-ID: References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7D6@vt-pe2550-001.vantage.vantage.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7D6@vt-pe2550-001.vantage.vantage.com> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/114 X-Sequence-Number: 12278 Unfortunately, Anandtech only used Postgres just a single time in his benchmarks. And what it did show back then was a huge performance advantage for the Opteron architecture over Xeon in this case. Where the fastest Opterons were just 15% faster in MySQL/MSSQL/DB2 than the fastest Xeons, it was 100%+ faster in Postgres. He probably got rid of Postgres from his benchmark suite since it favors Opteron too much. As a general hardware review site, makes senses that he needs to get more neutral apps in order to get free systems to review and (ahem) ad dollars. That being said, I wouldn't get a quad Opteron system anyways now that the dual core Opterons are available. A DP+DC system would be faster and cheaper than a pure quad system. Unless of course, I needed a QP+DC for 8-way SMP. Anjan Dave wrote: > Wasn't the context switching issue occurring in specific cases only? > > I haven't seen any benchmarks for a 50% performance difference. Neither > have I seen any benchmarks of pure disk IO performance of specific > models of Dell vs HP or Sun Opterons. > > Thanks, > Anjan > >>EMC you can file an RPQ via your sales contacts to get it approved, >>though not sure how lengthy/painful that process might be, or if it's >>gonna be worth it. >> >>Read the article devoted to the v40z on anandtech.com. >> >>I am also trying to get a quad-Opteron versus the latest quad-XEON > > from > >>Dell (6850), but it's hard to justify a difference between a 15K dell >>versus a 30k v40z for a 5-8% performance gain (read the XEON Vs. > > Opteron > >>Database comparo on anandtech.com)... >> >>Thanks, >>Anjan >> > > > 15k vs 30k is indeed a big difference. But also realize that Postgres > has a specific benefit to Opterons versus Xeons. The context switching > storm happens less on an Opteron for some reason. > > I would venture a much greater benefit than 5-8%, more like 10-50%. From pgsql-performance-owner@postgresql.org Tue May 24 14:30:07 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 311AD5288B for ; Tue, 24 May 2005 14:30:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78339-05 for ; Tue, 24 May 2005 17:29:58 +0000 (GMT) Received: from mta10.nationwireless.net (mta10.nationwireless.net [63.163.128.10]) by svr1.postgresql.org (Postfix) with ESMTP id AC5D552888 for ; Tue, 24 May 2005 14:29:56 -0300 (ADT) Received: from jfradkin [63.162.100.127] by mta10.nationwireless.net with ESMTP (SMTPD-8.20) id A4920388; Tue, 24 May 2005 13:29:54 -0400 From: "Joel Fradkin" To: "'Amit V Shah'" , "'Joshua D. Drake'" Cc: Subject: Re: Need help to decide Mysql vs Postgres Date: Mon, 9 May 2005 13:30:36 -0400 Message-ID: <005901c554bc$cff3bf90$797ba8c0@jfradkin> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable In-Reply-To: <0C072E7CC947D511AC9600A0CC7341200256CF04@xeon400.tagaudit.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.607 tagged_above=0 required=5 tests=AWL, DATE_IN_PAST_96_XX, MSGID_DOLLARS X-Spam-Level: ** X-Archive-Number: 200505/363 X-Sequence-Number: 12527 I took an unbiased look and did some tests. Objectively for me MYSQL was not an improvement for speed. I had read the benchmarks in pcmagazine from a while back as well. I did some tests using ODBC, and .net connections and also used aqua = studios (hooks up to both data bases) and found postgres a bit faster. I did spend more time getting a feeling for setup on postgres, but I was = at a point of desperation as some queries were still too slow on postgres. I ended up re-engineering my app to use simpler(flattened) data sets. I still have a few I am working through, but all in all it is running = better then when I was on MSSQL, and MYSQL was just slower on the tests I did. I loaded both MYSQL and postgres on both my 4 processor Dell running red = hat AS3 and Windows XP on a optiplex. Joel Fradkin =20 Wazagua, Inc. 2520 Trailmate Dr Sarasota, Florida 34243 Tel. 941-753-7111 ext 305 =20 jfradkin@wazagua.com www.wazagua.com Powered by Wazagua Providing you with the latest Web-based technology & advanced tools. C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc This email message is for the use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized = review, use, disclosure or distribution is prohibited. If you are not the = intended recipient, please contact the sender by reply email and delete and = destroy all copies of the original message, including attachments. =20 =20 -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Amit V Shah Sent: Tuesday, May 24, 2005 12:22 PM To: 'Joshua D. Drake' Cc: 'pgsql-performance@postgresql.org' Subject: Re: [PERFORM] Need help to decide Mysql vs Postgres Hi Josh, Thanks for the prompt reply !! Actually migration is inevitable. We have = a totally messed up schema, not normalized and stuff like that. So the = goal of the migration is to get a new and better normalized schema. That part is done already. Now the decision point is, should we go with postgres or mysql.=20 Thanks, Amit =20 -----Original Message----- From: Joshua D. Drake [mailto:jd@commandprompt.com] Sent: Tuesday, May 24, 2005 1:15 PM To: Amit V Shah Cc: 'pgsql-performance@postgresql.org' Subject: Re: [PERFORM] Need help to decide Mysql vs Postgres >=20 > I am not trying to start a mysql vs postgres war so please dont > misunderstand me .... I tried to look around for mysql vs postgres articles, > but most of them said mysql is better in speed. However those articles were > very old so I dont know about recent stage. Please comment !!! It is my experience that MySQL is faster under smaller load scenarios.=20 Say 5 - 10 connections only doing simple SELECTS. E.g; a dymanic = website. It is also my experience that PostgreSQL is faster and more stable under consistent and heavy load. I have customers you regularly are using up=20 to 500 connections. Note that alot of this depends on how your database is designed. Foreign = keys slow things down. I think it would be important for you to look at your overall goal of=20 migration. MySQL is really not a bad product "IF" you are willing to=20 work within its limitations. PostgreSQL is a real RDMS, it is like Oracle or DB2 and comes with a=20 comparable feature set. Only you can decide if that is what you need. Sincerely, Joshua D. Drake Command Prompt, Inc. --=20 Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 PostgreSQL Replication, Consulting, Custom Programming, 24x7 support Managed Services, Shared and Dedicated Hosting Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Mon May 9 14:32:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 37ACF53E69 for ; Mon, 9 May 2005 14:32:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57347-04 for ; Mon, 9 May 2005 17:32:01 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 2289553699 for ; Mon, 9 May 2005 14:31:59 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050509173159.STHF22578.priv-edtnes56.telusplanet.net@localhost>; Mon, 9 May 2005 11:31:59 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Mon, 9 May 2005 10:31:58 -0700 Message-ID: <1115659918.427f9e8ee7789@webmail.telus.net> Date: Mon, 9 May 2005 10:31:58 -0700 From: Mischa Sandberg To: Russell Smith Cc: Dan Harris , pgsql-performance@postgresql.org Subject: Re: Query tuning help References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> <200505091051.14689.mr-russ@pws.com.au> <6f4a543a2fbd348c7e82876b8e477600@drivefaster.net> <200505091232.05495.mr-russ@pws.com.au> In-Reply-To: <200505091232.05495.mr-russ@pws.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.059 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/115 X-Sequence-Number: 12279 Quoting Russell Smith : > On Mon, 9 May 2005 11:49 am, Dan Harris wrote: > > On May 8, 2005, at 6:51 PM, Russell Smith wrote: > [snip] > > select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat > > FROM em > > JOIN ea ON em.incidentid = ea.incidentid --- slight paraphrase /Mischa. > > AND em.entrydate between '2005-1-1' and '2005-5-9' > > AND ea.recordtext like '%RED%' AND ea.recordtext like '%CORVETTE%' > > Here's the situation: > > Due to the format of the systems with which I integrate ( I have no > > control over these formats ), we will get these 'recordtext' values one > > line at a time, accumulating over time. The only way I can find to > > make this work is to insert a new record for each line. The problem > > is, that when someone wants to search multiple keywords, they expect > > these words to be matched across multiple records with a given incident > > number. > > > > For a very simple example: > > > > IncidentID Date Recordtext > > -------------- ------------- > > 11111 2005-05-01 14:21 blah blah blah RED blah blah > > 2222 2005-05-01 14:23 not what we are looking for > > 11111 2005-05-02 02:05 blah CORVETTE blah blah > > select em.incidentid, ea.recordtest as retdata from em join ( -- equivalent to "where incidentid in (...)", sometimes faster. select incidentid from em join ea using (incidentid) where em.entrydate between '2005-1-1' and '2005-5-9' group by incidentid having 1 = min(case when recordtest like '%RED%' then 1 end) and 1 = min(case when recordtest like '%CORVETTE%' then 1 end) ) as X using (incidentid); From pgsql-performance-owner@postgresql.org Mon May 9 15:10:12 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 282AE53249 for ; Mon, 9 May 2005 15:10:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64555-03 for ; Mon, 9 May 2005 18:10:04 +0000 (GMT) Received: from frodo.csolve.net (frodo.csolve.net [207.164.81.3]) by svr1.postgresql.org (Postfix) with ESMTP id 7E6FE53737 for ; Mon, 9 May 2005 15:10:03 -0300 (ADT) Received: from omega.csolve.net ([207.164.80.136] helo=[10.10.18.126]) by frodo.csolve.net with esmtp (Exim 4.24) id 1DVChf-0000th-6K; Mon, 09 May 2005 14:10:03 -0400 Message-ID: <427FA77A.8070307@csolve.net> Date: Mon, 09 May 2005 14:10:02 -0400 From: Derek Buttineau|Compu-SOLVE Organization: Compu-SOLVE Internet Services User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050328) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: ORDER BY Optimization References: <427BCA10.4090208@csolve.net> <37d451f7050506133534923deb@mail.gmail.com> <427BD9A1.3090901@csolve.net> <6227.1115506545@sss.pgh.pa.us> In-Reply-To: <6227.1115506545@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------040105060408090505050606" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/116 X-Sequence-Number: 12280 This is a multi-part message in MIME format. --------------040105060408090505050606 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Thanks for the response :) >You could probably get your larger server to try the no-sort plan if >you said "set enable_sort = 0" first. It would be interesting to >compare the EXPLAIN ANALYZE results for that case with the other >server. > > > Odd, I went to investigate this switch on the larger server, but the query planner is now using the reverse index sort for this particular subscription. I'm guessing it's now accumulated enough rows for the planner to justify the reverse sort? Limit (cost=0.00..14808.49 rows=10 width=299) (actual time=3.760..11.689 rows=10 loops=1) -> Nested Loop (cost=0.00..15594816.65 rows=10531 width=299) (actual time=3.750..11.600 rows=10 loops=1) -> Index Scan Backward using maillog_msg_date_idx on maillog m (cost=0.00..805268.22 rows=2454190 width=256) (actual time=0.132..5.548 rows=194 loops=1) Filter: (spam = 1) -> Index Scan using maillog_received_subscription_maillog_id_idx on maillog_received mr (cost=0.00..6.01 rows=1 width=43) (actual time=0.020..0.021 rows=0 loops=194) Index Cond: ((mr.subscription = 89) AND (mr.maillog_id = "outer".id)) Total runtime: 11.878 ms I decided to try the same query with enable_sort on and off to see what sort of a difference it made roughly: With enable_sort = 1: Limit (cost=7515.77..7515.79 rows=10 width=299) (actual time=13153.300..13153.412 rows=10 loops=1) -> Sort (cost=7515.77..7516.26 rows=196 width=299) (actual time=13153.288..13153.324 rows=10 loops=1) Sort Key: m.msg_date -> Nested Loop (cost=0.00..7508.30 rows=196 width=299) (actual time=0.171..13141.099 rows=853 loops=1) -> Index Scan using maillog_received_subscription_idx on maillog_received mr (cost=0.00..4266.90 rows=1069 width=43) (actual time=0.095..5240.645 rows=993 loops=1) Index Cond: (subscription = 15245) -> Index Scan using maillog_pkey on maillog m (cost=0.00..3.02 rows=1 width=256) (actual time=7.893..7.902 rows=1 loops=993) Index Cond: ("outer".maillog_id = m.id) Filter: (spam = 1) Total runtime: 13153.812 ms With enable_sort = 0; Limit (cost=0.00..795580.99 rows=10 width=299) (actual time=108.345..3801.446 rows=10 loops=1) -> Nested Loop (cost=0.00..15593387.49 rows=196 width=299) (actual time=108.335..3801.352 rows=10 loops=1) -> Index Scan Backward using maillog_msg_date_idx on maillog m (cost=0.00..805194.97 rows=2453965 width=256) (actual time=0.338..3338.096 rows=15594 loops=1) Filter: (spam = 1) -> Index Scan using maillog_received_subscription_maillog_id_idx on maillog_received mr (cost=0.00..6.01 rows=1 width=43) (actual time=0.020..0.020 rows=0 loops=15594) Index Cond: ((mr.subscription = 15245) AND (mr.maillog_id = "outer".id)) Total runtime: 3801.676 ms In comparsion, query plan on the smaller server (it used a sort for this subscription vs a reverse scan): Limit (cost=197.37..197.38 rows=6 width=313) (actual time=883.576..883.597 rows=10 loops=1) -> Sort (cost=197.37..197.38 rows=6 width=313) (actual time=883.571..883.577 rows=10 loops=1) Sort Key: m.msg_date -> Nested Loop (cost=0.00..197.29 rows=6 width=313) (actual time=106.334..873.928 rows=47 loops=1) -> Index Scan using maillog_received_subscription_idx on maillog_received mr (cost=0.00..109.17 rows=28 width=41) (actual time=47.289..389.775 rows=58 loops=1) Index Cond: (subscription = 15245) -> Index Scan using maillog_pkey on maillog m (cost=0.00..3.13 rows=1 width=272) (actual time=8.319..8.322 rows=1 loops=58) Index Cond: ("outer".maillog_id = m.id) Filter: (spam = 1) Total runtime: 883.820 ms >The contents of the pg_stats row for mr.subscription in each server >would be informative, too. > I've increased the statistics targets to 300, so these rows are pretty bulky, however I've included the rows as text files to this message (pg_stats_large.txt and pg_stats_small.txt). >One rowcount estimate that does look >wrong is > > -> Index Scan using maillog_received_subscription_idx on >maillog_received mr (cost=0.00..17789.73 rows=4479 width=43) (actual >time=0.030..33554.061 rows=65508 loops=1) > Index Cond: (subscription = 89) > >so the stats row is suggesting there are only 4479 rows with >subscription = 89 when really there are 65508. (The preceding >discussion hopefully makes it clear why this is a potentially critical >mistake.) > This could potentially make sense on the larger server (if my understanding of the vacuum process is correct). The regular maintenance of the large server (which is currently the only one being updated regularily), does a vacuum analyze once per day, a scheduled vacuum once / hour, and autovacuum for the remainder of the time (which might be overkill). With the function of these tables, it is easily possible for the maillog_received table to gain 60,000 rows for a single subscription in 24 hours. With that information, maybe it might be in my best interest to run the analyze hourly? > This suggests that you may need to raise your statistics >targets. > > > I've raised the statistics targets to 300 on these columns, it seems to have helped some. Interesting enough, when I query on the most_common_vals for the subscription argument, they tend to use the reverse scan method vs the sort. Thanks again, Derek --------------040105060408090505050606 Content-Type: text/plain; name="pg_stats_large.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="pg_stats_large.txt" public | maillog_received | subscription | 0 | 4 | = 4003 | {1,2131,16039,1496,1821,15033,1167,15055,710,982,1433,1608,60= 6,14214,1765,1873,15790,89,15265,2861,15040,1366,1270,14131,1792,505,1371= 7,15267,1076,1176,780,656,1839,676,15168,12227,10156,6051,820,10791,11527= ,1825,5563,8675,2335,8031,14962,14059,4965,13917,1134,1186,1977,1982,4973= ,6540,10666,3385,10005,1969,8503,13395,6154,12568,8284,8551,8630,13272,21= 50,5108,11166,13186,497,2533,6648,7470,1045,2846,3356,11378,12673,15264,1= 5456,5447,8594,13530,7353,13687,688,1759,5473,7804,10533,2437,3097,5227,6= 691,13130,4445,9142,9276,10212,12619,605,3470,4614,7550,7659,7772,8533,85= 86,13727,5727,6595,7817,9128,9806,10170,8743,8801,12631,13359,1881,2389,1= 0091,10394,11540,11643,11760,478,3870,8941,8979,9156,9201,9743,10114,1387= 2,15078,2531,2706,3641,9272,9514,9794,12527,463,3011,5193,5501,7114,7338,= 8819,9203,9291,9777,10342,13559,3449,7173,8093,8475,8701,10205,13353,1368= 5,1824,3078,3188,3781,7078,7700,7848,8410,8654,8891,8989,11261,12339,2659= ,2844,4326,6297,8404,8628,8703,9404,9638,10361,12311,2149,2877,4087,4325,= 5411,7018,7054,7818,9211,9359,9542,9795,10454,12217,12782,2287,4801,5338,= 7361,7625,7701,8836,9496,9677,9700,10118,10467,10725,10876,11259,11287,13= 409,13495,13829,2987,4482,4680,4718,4786,5286,5386,5543,5751,5798,6305,65= 37,7539,8098,8769,9015,10146,10445,11369,12236,12755,13094,13874} | {0.12= 2233,0.0794,0.0607889,0.0560444,0.0551222,0.0339333,0.0316556,0.0296667,0= =2E0235889,0.0130667,0.0103,0.0092,0.00691111,0.00658889,0.0064,0.0053333= 3,0.00505556,0.00442222,0.00414444,0.00404444,0.00396667,0.00317778,0.002= 75556,0.00265556,0.00255556,0.00253333,0.0016,0.00142222,0.00141111,0.001= 34444,0.00126667,0.00122222,0.00122222,0.00107778,0.00106667,0.00102222,0= =2E00101111,0.000988889,0.000888889,0.000866667,0.000788889,0.000755556,0= =2E000733333,0.000733333,0.000711111,0.000711111,0.000711111,0.000688889,= 0.000677778,0.000677778,0.000666667,0.000666667,0.000666667,0.000666667,0= =2E000655556,0.000655556,0.000655556,0.000644444,0.000644444,0.000633333,= 0.000633333,0.000622222,0.000611111,0.000611111,0.0006,0.0006,0.0006,0.00= 06,0.000566667,0.000566667,0.000566667,0.000555556,0.000544444,0.00054444= 4,0.000544444,0.000544444,0.000533333,0.000533333,0.000533333,0.000533333= ,0.000533333,0.000533333,0.000533333,0.000522222,0.000522222,0.000522222,= 0.000511111,0.000511111,0.0005,0.000488889,0.000488889,0.000488889,0.0004= 88889,0.000477778,0.000477778,0.000477778,0.000477778,0.000477778,0.00046= 6667,0.000466667,0.000466667,0.000466667,0.000466667,0.000455556,0.000455= 556,0.000455556,0.000455556,0.000455556,0.000455556,0.000455556,0.0004555= 56,0.000455556,0.000444444,0.000444444,0.000444444,0.000444444,0.00044444= 4,0.000444444,0.000433333,0.000433333,0.000433333,0.000433333,0.000422222= ,0.000422222,0.000422222,0.000422222,0.000422222,0.000422222,0.000422222,= 0.000411111,0.000411111,0.000411111,0.000411111,0.000411111,0.000411111,0= =2E000411111,0.000411111,0.000411111,0.000411111,0.0004,0.0004,0.0004,0.0= 004,0.0004,0.0004,0.0004,0.000388889,0.000388889,0.000388889,0.000388889,= 0.000388889,0.000388889,0.000388889,0.000388889,0.000388889,0.000388889,0= =2E000388889,0.000388889,0.000377778,0.000377778,0.000377778,0.000377778,= 0.000377778,0.000377778,0.000377778,0.000377778,0.000366667,0.000366667,0= =2E000366667,0.000366667,0.000366667,0.000366667,0.000366667,0.000366667,= 0.000366667,0.000366667,0.000366667,0.000366667,0.000366667,0.000355556,0= =2E000355556,0.000355556,0.000355556,0.000355556,0.000355556,0.000355556,= 0.000355556,0.000355556,0.000355556,0.000355556,0.000344444,0.000344444,0= =2E000344444,0.000344444,0.000344444,0.000344444,0.000344444,0.000344444,= 0.000344444,0.000344444,0.000344444,0.000344444,0.000344444,0.000344444,0= =2E000344444,0.000333333,0.000333333,0.000333333,0.000333333,0.000333333,= 0.000333333,0.000333333,0.000333333,0.000333333,0.000333333,0.000333333,0= =2E000333333,0.000333333,0.000333333,0.000333333,0.000333333,0.000333333,= 0.000333333,0.000333333,0.000322222,0.000322222,0.000322222,0.000322222,0= =2E000322222,0.000322222,0.000322222,0.000322222,0.000322222,0.000322222,= 0.000322222,0.000322222,0.000322222,0.000322222,0.000322222,0.000322222,0= =2E000322222,0.000322222,0.000322222,0.000322222,0.000322222,0.000322222,= 0.000322222} | {436,551,590,633,692,708,853,954,998,1061,1135,1178,1269,1= 343,1396,1443,1502,1605,1659,1723,1791,1845,1980,2085,2153,2192,2231,2245= ,2265,2303,2337,2369,2391,2414,2444,2484,2511,2546,2566,2597,2637,2697,27= 28,2758,2792,2832,2964,2995,3037,3052,3080,3112,3139,3171,3237,3275,3294,= 3344,3376,3404,3490,3527,3564,3584,3639,3713,3762,3800,3850,3898,3921,399= 4,4067,4085,4117,4156,4179,4209,4253,4274,4327,4400,4427,4495,4587,4628,4= 668,4697,4756,4789,4833,4877,4915,4969,5010,5069,5119,5150,5224,5257,5303= ,5353,5379,5405,5452,5491,5598,5613,5658,5713,5739,5775,5849,5905,5939,59= 73,6022,6061,6083,6156,6176,6198,6232,6252,6283,6290,6331,6377,6424,6476,= 6541,6570,6598,6624,6656,6696,6717,6791,6834,6860,6927,6995,7059,7101,714= 9,7204,7260,7292,7346,7370,7416,7455,7512,7575,7616,7673,7728,7765,7809,7= 864,7947,7996,8052,8081,8106,8153,8222,8246,8318,8357,8424,8439,8504,8557= ,8596,8664,8692,8730,8768,8792,8850,8900,8930,9013,9058,9106,9171,9224,92= 80,9314,9350,9393,9443,9482,9539,9560,9593,9658,9772,9854,9902,9941,9984,= 10030,10060,10095,10120,10145,10175,10231,10267,10319,10362,10464,10486,1= 0535,10563,10614,10653,10689,10738,10775,10801,10845,10874,10923,10969,11= 053,11088,11107,11159,11207,11268,11330,11366,11420,11474,11524,11577,116= 10,11686,11722,11799,11834,11883,11913,11947,12049,12090,12145,12191,1224= 3,12294,12336,12377,12428,12478,12530,12599,12618,12669,12714,12768,12828= ,12863,12898,12959,13010,13048,13093,13117,13154,13212,13243,13312,13369,= 13388,13475,13536,13593,13640,13688,13759,13798,13823,13849,13901,13955,1= 3999,14049,14095,14184,14882,15031,15072,15126,15370,15522,15817,15946,16= 211} | -0.0530052 --------------040105060408090505050606 Content-Type: text/plain; name="pg_stats_small.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="pg_stats_small.txt" public | maillog_received | subscription | 0 | 4 | = 3462 | {1,2131,1821,1496,89,15033,16039,1167,15055,1765,710,982,1608= ,1433,606,2861,1792,15265,1873,14214,15040,505,10156,1366,2846,13717,1270= ,2532,10605,15267,780,9156,15790,8654,1186,1176,1839,5793,686,14131,15168= ,9593,676,7817,12081,7114,1134,8093,7804,15072,3356,10104,3687,3746,8801,= 688,1825,7659,13272,13296,1922,12227,4614,8941,1759,1982,5501,8743,11527,= 8503,3282,5727,2335,3641,13530,13783,9795,10005,5447,5659,5798,7338,2811,= 4877,8675,10362,10467,5286,6297,7054,8031,11378,3364,5775,7772,8081,8551,= 4754,11209} | {0.248344,0.0744,0.0433222,0.0391111,0.0318778,0.0298111,0.= 0296556,0.0237444,0.0214333,0.0213333,0.0158333,0.0103,0.0089,0.00763333,= 0.00646667,0.00574444,0.00566667,0.00402222,0.00368889,0.00346667,0.00345= 556,0.00287778,0.00223333,0.00215556,0.00215556,0.00203333,0.00184444,0.0= 0157778,0.00143333,0.00135556,0.0013,0.00125556,0.00123333,0.0012,0.00116= 667,0.00113333,0.00113333,0.00108889,0.001,0.001,0.000911111,0.0009,0.000= 877778,0.000866667,0.000866667,0.000844444,0.000777778,0.000777778,0.0007= 22222,0.0007,0.000677778,0.0006,0.000588889,0.000577778,0.000566667,0.000= 555556,0.000533333,0.000533333,0.000533333,0.000533333,0.000522222,0.0005= 11111,0.0005,0.0005,0.000488889,0.000488889,0.000488889,0.000488889,0.000= 488889,0.000477778,0.000466667,0.000466667,0.000455556,0.000455556,0.0004= 55556,0.000444444,0.000433333,0.000433333,0.000422222,0.000422222,0.00042= 2222,0.000411111,0.0004,0.0004,0.0004,0.0004,0.0004,0.000388889,0.0003888= 89,0.000388889,0.000388889,0.000388889,0.000377778,0.000377778,0.00037777= 8,0.000377778,0.000377778,0.000366667,0.000366667} | {3,497,584,649,803,9= 27,1038,1070,1175,1365,1417,1468,1577,1636,1693,1791,1836,1956,2040,2128,= 2158,2192,2231,2245,2265,2287,2328,2363,2390,2413,2433,2467,2503,2533,256= 5,2609,2659,2697,2723,2748,2802,2840,2901,2987,3021,3039,3074,3084,3112,3= 142,3188,3246,3291,3344,3376,3401,3470,3509,3563,3592,3659,3739,3781,3833= ,3866,3898,3951,4020,4073,4099,4143,4179,4209,4250,4274,4325,4381,4420,44= 52,4547,4603,4662,4690,4756,4794,4838,4880,4917,4969,5010,5044,5108,5155,= 5227,5256,5299,5355,5386,5411,5452,5488,5575,5600,5626,5701,5739,5771,588= 1,5930,5973,6031,6067,6144,6162,6197,6232,6256,6285,6304,6339,6399,6461,6= 524,6545,6595,6620,6664,6696,6715,6769,6834,6866,6930,7019,7059,7100,7149= ,7201,7261,7293,7353,7370,7411,7455,7506,7550,7594,7625,7677,7707,7762,77= 89,7828,7862,7955,8019,8062,8098,8124,8186,8246,8314,8355,8404,8429,8475,= 8524,8574,8620,8672,8703,8744,8770,8813,8850,8900,8932,8979,9020,9063,909= 3,9142,9201,9224,9280,9302,9319,9356,9393,9423,9482,9507,9539,9560,9623,9= 658,9718,9777,9831,9887,9908,9973,10032,10064,10098,10120,10146,10172,101= 92,10231,10267,10319,10361,10403,10466,10525,10548,10596,10651,10680,1072= 1,10768,10791,10810,10857,10912,10958,11046,11091,11113,11165,11196,11261= ,11330,11368,11398,11446,11517,11556,11596,11636,11684,11746,11799,11835,= 11891,11927,11969,12030,12123,12145,12191,12242,12274,12317,12354,12416,1= 2485,12530,12576,12610,12631,12676,12721,12780,12828,12863,12903,12962,13= 026,13054,13104,13130,13185,13215,13305,13346,13369,13395,13477,13524,135= 70,13624,13685,13727,13787,13819,13837,13874,13917,13977,14028,14049,1416= 8,14962,15078,15245,15416,15616,15861,16090} | -0.206239 --------------040105060408090505050606-- From pgsql-performance-owner@postgresql.org Mon May 9 16:23:28 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 23FB853DEC for ; Mon, 9 May 2005 16:23:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76139-02 for ; Mon, 9 May 2005 19:23:22 +0000 (GMT) Received: from postfix4-1.free.fr (postfix4-1.free.fr [213.228.0.62]) by svr1.postgresql.org (Postfix) with ESMTP id 43CBF5371A for ; Mon, 9 May 2005 16:23:21 -0300 (ADT) Received: from imp1-q.free.fr (imp1-q.free.fr [212.27.42.1]) by postfix4-1.free.fr (Postfix) with ESMTP id E7FE6317A77 for ; Mon, 9 May 2005 21:23:19 +0200 (CEST) Received: by imp1-q.free.fr (Postfix, from userid 33) id 517743B833; Mon, 9 May 2005 21:22:40 +0200 (MEST) Received: from 140.157.100-84.rev.gaoland.net (140.157.100-84.rev.gaoland.net [84.100.157.140]) by imp1-q.free.fr (IMP) with HTTP for ; Mon, 9 May 2005 21:22:40 +0200 Message-ID: <1115666560.427fb8803c3a6@imp1-q.free.fr> Date: Mon, 9 May 2005 21:22:40 +0200 From: bouchia.nazha@free.fr To: pgsql-performance@postgresql.org Subject: PGSQL Capacity MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.5 X-Originating-IP: 84.100.157.140 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.178 tagged_above=0 required=5 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200505/117 X-Sequence-Number: 12281 Hello How can i know a capacity of a pg database ? How many records my table can have ? I saw in a message that someone have 50 000 records it's possible in a table ? (My table have 8 string field (length 32 car)). Thanks for your response. Nanou From pgsql-performance-owner@postgresql.org Mon May 9 17:35:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4B2C253363 for ; Mon, 9 May 2005 17:35:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85992-09 for ; Mon, 9 May 2005 20:35:12 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id BF9D9531C6 for ; Mon, 9 May 2005 17:35:10 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DVEy6-0002Zc-5y for pgsql-performance@postgresql.org; Mon, 09 May 2005 22:35:11 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1DVDzG-0003Tx-00 for ; Mon, 09 May 2005 21:32:18 +0200 Date: Mon, 9 May 2005 21:32:18 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: PGSQL Capacity Message-ID: <20050509193218.GB12502@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <1115666560.427fb8803c3a6@imp1-q.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1115666560.427fb8803c3a6@imp1-q.free.fr> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.017 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/122 X-Sequence-Number: 12286 On Mon, May 09, 2005 at 09:22:40PM +0200, bouchia.nazha@free.fr wrote: > How can i know a capacity of a pg database ? > How many records my table can have ? > I saw in a message that someone have 50 000 records it's possible in a table ? > (My table have 8 string field (length 32 car)). > Thanks for your response. You can have several million records in a table easily -- I've done 10 million personally, but you can find people doing that many records a _day_. Hitting 1 billion records should probably not be impossible either -- it all depends on your hardware, and perhaps more importantly, what kind of queries you're running against it. 50000 is absolutely no problem at all. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Mon May 9 16:41:07 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4AD945321A for ; Mon, 9 May 2005 16:41:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79295-07 for ; Mon, 9 May 2005 19:40:59 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id E2CF653E4D for ; Mon, 9 May 2005 16:40:58 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j49JewZb018927; (envelope-from ) Mon, 9 May 2005 14:40:58 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j49JetlQ026039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Mon, 9 May 2005 14:40:57 -0500 (CDT) Message-ID: <427FBCC4.5040804@arbash-meinel.com> Date: Mon, 09 May 2005 14:40:52 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: bouchia.nazha@free.fr Cc: pgsql-performance@postgresql.org Subject: Re: PGSQL Capacity References: <1115666560.427fb8803c3a6@imp1-q.free.fr> In-Reply-To: <1115666560.427fb8803c3a6@imp1-q.free.fr> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig860B003DEB6DBBCB26A9D3A9" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/118 X-Sequence-Number: 12282 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig860B003DEB6DBBCB26A9D3A9 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit bouchia.nazha@free.fr wrote: > Hello > > How can i know a capacity of a pg database ? > How many records my table can have ? > I saw in a message that someone have 50 000 records it's possible in a table ? > (My table have 8 string field (length 32 car)). > Thanks for your response. > > > Nanou The capacity for a PG database is just the limit of how much disk space you have. There are people who have 100 million or even up to a billion rows in one table. If you are in the billions you have to take some care about OID wraparound, but at the very least the maximum number of rows in one table is at least 2Billion. With 8 string fields and 32 chars each, if they are all filled, you will take about (32+4)*8 = 324 + overhead bytes each, so I would estimate about 400 per. If we add a whole lot to be safe, and say 1k per row, you can fit 1Million rows in 1GB of disk space. There is more taken up by indexes, etc. Generally, you are disk limited, not limited by Postgres. John =:-> --------------enig860B003DEB6DBBCB26A9D3A9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCf7zGJdeBCYSNAAMRAp0gAJ4wF8T1e9xUKWY1txDG2phopwfpIQCgkcl7 2A/4mWE+ZYQxJXJRbn9utRM= =iLUJ -----END PGP SIGNATURE----- --------------enig860B003DEB6DBBCB26A9D3A9-- From pgsql-performance-owner@postgresql.org Mon May 9 16:55:51 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6EC2553E73 for ; Mon, 9 May 2005 16:55:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80714-08 for ; Mon, 9 May 2005 19:55:46 +0000 (GMT) Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) by svr1.postgresql.org (Postfix) with ESMTP id BECC053D93 for ; Mon, 9 May 2005 16:55:44 -0300 (ADT) 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="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: PGSQL Capacity Date: Mon, 9 May 2005 14:55:40 -0500 Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F902618504@asg002.asg.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] PGSQL Capacity Thread-Index: AcVU0JolhGbFnZT9RNi5Omkgc6Vs9AAAFakw From: "Dave Held" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/119 X-Sequence-Number: 12283 > -----Original Message----- > From: bouchia.nazha@free.fr [mailto:bouchia.nazha@free.fr] > Sent: Monday, May 09, 2005 2:23 PM > To: pgsql-performance@postgresql.org > Subject: [PERFORM] PGSQL Capacity >=20 > How can i know a capacity of a pg database ? > How many records my table can have ? > I saw in a message that someone have 50 000 records it's=20 > possible in a table ? > (My table have 8 string field (length 32 car)). > Thanks for your response. You're basically limited to the size of your hard drive(s). The actual limit is in the terabyte range. __ David B. Held Software Engineer/Array Services Group 200 14th Ave. East, Sartell, MN 56377 320.534.3637 320.253.7800 800.752.8129 From pgsql-performance-owner@postgresql.org Mon May 9 17:01:09 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C6CD453E82 for ; Mon, 9 May 2005 17:01:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80821-10 for ; Mon, 9 May 2005 20:01:02 +0000 (GMT) Received: from 3times25.net (66-23-211-34.clients.speedfactory.net [66.23.211.34]) by svr1.postgresql.org (Postfix) with ESMTP id 3486C53E59 for ; Mon, 9 May 2005 17:01:00 -0300 (ADT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by 3times25.net (Postfix) with ESMTP id D3BE574404 for ; Mon, 9 May 2005 16:00:59 -0400 (EDT) Message-ID: <427FC17B.2020608@3times25.net> Date: Mon, 09 May 2005 16:00:59 -0400 From: Geoffrey User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050422 Red Hat/1.7.7-1.4.2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? References: <14695.1115393034@sss.pgh.pa.us> <6CD32D5F-B466-4E6D-9E73-CFB8957B396F@torgo.978.org> <15121.1115395067@sss.pgh.pa.us> <1115415551.427be3ffe44c8@webmail.telus.net> <427EC845.8080608@3times25.net> <427F7F37.8020001@arbash-meinel.com> In-Reply-To: <427F7F37.8020001@arbash-meinel.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.039 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/120 X-Sequence-Number: 12284 John A Meinel wrote: > Geoffrey wrote: > >> Mischa Sandberg wrote: >> >>> After reading the comparisons between Opteron and Xeon processors for >>> Linux, >>> I'd like to add an Opteron box to our stable of Dells and Sparcs, for >>> comparison. >>> >>> IBM, Sun and HP have their fairly pricey Opteron systems. >>> The IT people are not swell about unsupported purchases off ebay. >>> Anyone care to suggest any other vendors/distributors? >>> Looking for names with national support, so that we can recommend as >>> much to our >>> customers. >> >> >> >> Monarch Computer http://www.monarchcomputer.com/ >> >> They have prebuilt and custom built systems. >> > > I believe we have had some issues with their workstation class systems. > Just a high rate of part failure, and DOA systems. > > I believe they RMA'd without too great of difficulties, but it was > something like 50%. Ouch, that's not been my experiences. I'd like to hear if anyone else has had such problems with Monarch. -- Until later, Geoffrey From pgsql-performance-owner@postgresql.org Mon May 9 17:10:11 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4307953E85 for ; Mon, 9 May 2005 17:10:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82498-07 for ; Mon, 9 May 2005 20:10:04 +0000 (GMT) Received: from vt-pe2550-001.VANTAGE.vantage.com (vt-pe2550-001.vantage.com [64.80.203.244]) by svr1.postgresql.org (Postfix) with ESMTP id 3E4A553E83 for ; Mon, 9 May 2005 17:10:03 -0300 (ADT) 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: Whence the Opterons? Date: Mon, 9 May 2005 16:10:03 -0400 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7DB@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Whence the Opterons? Thread-Index: AcVUvA6EhkiTWDIzTtKjOOIy+AdwpAAFrH+g From: "Anjan Dave" To: "William Yu" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.054 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/121 X-Sequence-Number: 12285 The DP+DC isn't available yet, from Sun. Only QP+DC is, for which the bid opens at 38k, that is a bit pricey -:) -----Original Message----- From: William Yu [mailto:wyu@talisys.com]=20 Sent: Monday, May 09, 2005 1:24 PM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Whence the Opterons? Unfortunately, Anandtech only used Postgres just a single time in his=20 benchmarks. And what it did show back then was a huge performance=20 advantage for the Opteron architecture over Xeon in this case. Where the fastest Opterons were just 15% faster in MySQL/MSSQL/DB2 than the=20 fastest Xeons, it was 100%+ faster in Postgres. He probably got rid of=20 Postgres from his benchmark suite since it favors Opteron too much. As a general hardware review site, makes senses that he needs to get more=20 neutral apps in order to get free systems to review and (ahem) ad dollars. That being said, I wouldn't get a quad Opteron system anyways now that=20 the dual core Opterons are available. A DP+DC system would be faster and cheaper than a pure quad system. Unless of course, I needed a QP+DC for=20 8-way SMP. Anjan Dave wrote: > Wasn't the context switching issue occurring in specific cases only? >=20 > I haven't seen any benchmarks for a 50% performance difference. Neither > have I seen any benchmarks of pure disk IO performance of specific > models of Dell vs HP or Sun Opterons. >=20 > Thanks, > Anjan >=20 >>EMC you can file an RPQ via your sales contacts to get it approved, >>though not sure how lengthy/painful that process might be, or if it's >>gonna be worth it. >> >>Read the article devoted to the v40z on anandtech.com. >> >>I am also trying to get a quad-Opteron versus the latest quad-XEON >=20 > from >=20 >>Dell (6850), but it's hard to justify a difference between a 15K dell >>versus a 30k v40z for a 5-8% performance gain (read the XEON Vs. >=20 > Opteron >=20 >>Database comparo on anandtech.com)... >> >>Thanks, >>Anjan >> >=20 >=20 > 15k vs 30k is indeed a big difference. But also realize that Postgres > has a specific benefit to Opterons versus Xeons. The context switching > storm happens less on an Opteron for some reason. >=20 > I would venture a much greater benefit than 5-8%, more like 10-50%. ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly From pgsql-performance-owner@postgresql.org Mon May 9 17:55:47 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7BB9053E20 for ; Mon, 9 May 2005 17:55:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91013-04 for ; Mon, 9 May 2005 20:55:37 +0000 (GMT) Received: from mta10.nationwireless.net (mta10.nationwireless.net [63.163.128.10]) by svr1.postgresql.org (Postfix) with ESMTP id EA15E5377E for ; Mon, 9 May 2005 17:55:35 -0300 (ADT) Received: from jfradkin [63.162.100.127] by mta10.nationwireless.net with ESMTP (SMTPD-8.20) id AE4802D0; Mon, 09 May 2005 16:55:36 -0400 From: "Joel Fradkin" To: "PostgreSQL Perform" Subject: Configing 8 gig box. Date: Mon, 9 May 2005 16:55:53 -0400 Message-ID: <006c01c554d9$7d701120$797ba8c0@jfradkin> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_006D_01C554B7.F65E7120" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.617 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE, MSGID_DOLLARS X-Spam-Level: * X-Archive-Number: 200505/123 X-Sequence-Number: 12287 This is a multi-part message in MIME format. ------=_NextPart_000_006D_01C554B7.F65E7120 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Seems to be only using like 360 meg out of 7 gig free (odd thing is I = did see some used swap 4k out of 1.9) with a bunch of users (this may be = normal, but it is not going overly fast so thought I would ask). Items I modified per commandprompt.coma nd watching this list etc. =20 shared_buffers =3D 24576 work_mem =3D 32768 max_fsm_pages =3D 100000 max_fsm_relations =3D 1500 fsync =3D true wal_sync_method =3D open_sync wal_buffers =3D 2048 checkpoint_segments =3D 100=20 effective_cache_size =3D 524288 default_statistics_target =3D 250 =20 Any help is appreciated. =20 =20 =20 Joel Fradkin =20 Wazagua, Inc. 2520 Trailmate Dr Sarasota, Florida 34243 Tel. 941-753-7111 ext 305 =20 jfradkin@wazagua.com www.wazagua.com Powered by Wazagua Providing you with the latest Web-based technology & advanced tools. C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc This email message is for the use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized = review, use, disclosure or distribution is prohibited. If you are not the = intended recipient, please contact the sender by reply email and delete and = destroy all copies of the original message, including attachments. =20 =20 =20 ------=_NextPart_000_006D_01C554B7.F65E7120 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Seems to be only using like 360 meg out of 7 gig free = (odd thing is I did see some used swap 4k out of 1.9) with a bunch of users = (this may be normal, but it is not going overly fast so thought I would = ask).

Items I modified per commandprompt.coma nd watching = this list etc.

 

shared_buffers =3D = 24576

work_mem =3D = 32768

max_fsm_pages =3D = 100000

max_fsm_relations = =3D 1500

fsync =3D = true

wal_sync_method =3D = open_sync

wal_buffers =3D = 2048

checkpoint_segments = =3D 100

effective_cache_size =3D 524288

default_statistics_target =3D 250

 

Any help is = appreciated.

 

 

 

Joel Fradkin

 

Wazagua, Inc.
2520 Trailmate Dr
Sarasota, Florida = 34243
Tel.  941-753-7111 ext 305

 

jfradkin@wazagua.com
www.wazagua.com
Powered by Wazagua
Providing you with the latest Web-based technology & advanced = tools.
© 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
 This email message is for the use of the intended recipient(s) and = may contain confidential and privileged information.  Any unauthorized = review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and delete = and destroy all copies of the original message, including = attachments.

 


 

 

------=_NextPart_000_006D_01C554B7.F65E7120-- From pgsql-performance-owner@postgresql.org Mon May 9 19:04:12 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F16FF53E0B for ; Mon, 9 May 2005 19:04:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99931-04 for ; Mon, 9 May 2005 22:04:04 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2406252A38 for ; Mon, 9 May 2005 19:04:03 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 68F3330953; Tue, 10 May 2005 00:01:53 +0200 (MET DST) From: Chris Browne X-Newsgroups: pgsql.performance Subject: Re: PGSQL Capacity Date: Mon, 09 May 2005 17:46:23 -0400 Organization: cbbrowne Computing Inc Lines: 29 Message-ID: <60ll6oul74.fsf@dba2.int.libertyrms.com> References: <1115666560.427fb8803c3a6@imp1-q.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:BELzdprwblh0XYVrPHc+Kb0gKU8= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.155 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/124 X-Sequence-Number: 12288 bouchia.nazha@free.fr writes: > How can i know a capacity of a pg database ? > How many records my table can have ? > I saw in a message that someone have 50 000 records it's possible in a table ? > (My table have 8 string field (length 32 car)). > Thanks for your response. The capacity is much more likely to be limited by the size of the disk drives and filesystems you have available to you than by anything else. If your table consists of 8- 32 character strings, then each tuple will consume around 256 bytes of memory, and you will be able to fit on the order of 30 tuples into each 8K page. By default, you can extend a single table file to up to 1GB before it splits off to another piece. That would mean each file can have about 3.9M tuples. From there, you can have as many 1GB pieces as the disk will support. So you could have (plenty * 3.9M tuples), which could add up to be rather large. If you're expecting 50K records, that will be no big deal at all. -- (format nil "~S@~S" "cbbrowne" "acm.org") http://www.ntlug.org/~cbbrowne/sap.html Rules of the Evil Overlord #78. "I will not tell my Legions of Terror "And he must be taken alive!" The command will be: ``And try to take him alive if it is reasonably practical.''" From pgsql-performance-owner@postgresql.org Mon May 9 19:39:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1354C5350E for ; Mon, 9 May 2005 19:39:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02873-05 for ; Mon, 9 May 2005 22:39:34 +0000 (GMT) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by svr1.postgresql.org (Postfix) with ESMTP id 8D82653414 for ; Mon, 9 May 2005 19:38:58 -0300 (ADT) Received: from frontend3.messagingengine.com (frontend3.internal [10.202.2.152]) by frontend1.messagingengine.com (Postfix) with ESMTP id 27A60C8E619; Mon, 9 May 2005 18:38:50 -0400 (EDT) X-Sasl-enc: PuAeKWZaWJ3YFdmPrYz0VY8Mp5AymtlixCxBFraRs4ZS 1115678328 Received: from [192.168.0.4] (i-83-67-25-205.freedom2surf.net [83.67.25.205]) by www.fastmail.fm (Postfix) with ESMTP id A8C7C5F; Mon, 9 May 2005 18:38:47 -0400 (EDT) In-Reply-To: <427F6853.90308@cs.concordia.ca> References: <427F6853.90308@cs.concordia.ca> Mime-Version: 1.0 (Apple Message framework v622) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <6f6c081fabe7002128433e3b99b09e50@diroussel.xsmail.com> Content-Transfer-Encoding: 7bit Cc: pgsql-perform From: David Roussel Subject: Re: "Hash index" vs. "b-tree index" (PostgreSQL 8.0) Date: Mon, 9 May 2005 23:38:47 +0100 To: Ying Lu X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/125 X-Sequence-Number: 12289 > *Note: * Testing has shown PostgreSQL's hash indexes to perform no > better than B-tree indexes, and the index size and build time for hash > indexes is much worse. For these reasons, hash index use is presently > discouraged. > > May I know for simple "=" operation query, for "Hash index" vs. > "B-tree" index, which can provide better performance please? If you trust the documentation use a b-tree. If you don't trust the documentation do your own tests. please don't cross post. From pgsql-general-owner@postgresql.org Mon May 9 21:14:19 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8E2CE53E1F; Mon, 9 May 2005 21:14:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14341-07; Tue, 10 May 2005 00:14:17 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 175CA53E6E; Mon, 9 May 2005 21:14:14 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id B683518CCDA; Mon, 9 May 2005 20:14:17 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 01190-01-4; Mon, 9 May 2005 20:14:16 -0400 (EDT) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 9585D18CCE7; Mon, 9 May 2005 20:14:14 -0400 (EDT) Message-ID: <427FFCD3.1010803@samurai.com> Date: Tue, 10 May 2005 10:14:11 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Jim C. Nasby" Cc: Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> In-Reply-To: <20050509165133.GJ35026@decibel.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/433 X-Sequence-Number: 77781 Jim C. Nasby wrote: >> No, hash joins and hash indexes are unrelated. > I know they are now, but does that have to be the case? I mean, the algorithms are fundamentally unrelated. They share a bit of code such as the hash functions themselves, but they are really solving two different problems (disk based indexing with (hopefully) good concurrency and WAL logging vs. in-memory joins via hashing with spill to disk if needed). > Like I said, I don't know the history, so I don't know why we even > have them to begin with. As I said, the idea of using hash indexes for better performance on equality scans is perfectly valid, it is just the implementation that needs work. -Neil From pgsql-performance-owner@postgresql.org Sun May 15 15:28:06 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9B5D153E68 for ; Mon, 9 May 2005 23:10:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33265-03 for ; Tue, 10 May 2005 02:10:48 +0000 (GMT) Received: from atlantis.oceanconsulting.com (smtp.oceanconsulting.com [216.65.145.145]) by svr1.postgresql.org (Postfix) with ESMTP id AEB1553E56 for ; Mon, 9 May 2005 23:10:39 -0300 (ADT) Received: from seti.kavi.com (seti.kavi.com [64.242.113.166]) (authenticated bits=0) by atlantis.oceanconsulting.com (8.13.1/8.13.1) with ESMTP id j4A28OVC027390 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Mon, 9 May 2005 19:08:26 -0700 From: Matt Olson Reply-To: molson@oceanconsulting.com Organization: Ocean Consulting To: pgsql-performance@postgresql.org Subject: Prefetch Date: Mon, 9 May 2005 19:10:26 -0700 User-Agent: KMail/1.7.1 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200505091910.26407.molson@oceanconsulting.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/285 X-Sequence-Number: 12449 I wanted to get some opinions about row prefetching. AFAIK, there is no prefetching done by PostgreSQL; all prefetching is delegated to the operating system. The hardware (can't say enough good things about it): Athlon 64, dual channel 4GB ram 240GB usable 4 disk raid5 (ATA133) Fedora Core 3 PostgreSQL 7.4.7 I have what is essentially a data warehouse of stock data. Each day has around 30,000 records (tickers). A typical operation is to get the 200 day simple moving average (of price) for each ticker and write the result to a summary table. In running this process (Perl/DBI), it is typical to see 70-80% I/O wait time with postgres running a about 8-9%. If I run the next day's date, the postgres cache and file cache is now populated with 199 days of the needed data, postgres runs 80-90% of CPU and total run time is greatly reduced. My conclusion is that this is a high cache hit rate in action. I've done other things that make sense, like using indexes, playing with the planner constants and turning up the postgres cache buffers. Even playing with extream hdparm read-ahead numbers (i.e. 64738), there is no apparent difference in database performance. The random nature of the I/O drops disk reads down to about 1MB/sec for the array. A linear table scan can easily yield 70-80MB/sec on this system. Total table size is usually around 1GB and with indexes should be able to fit completely in main memory. Other databases like Oracle and DB2 implement some sort of row prefetch. Has there been serious consideration of implementing something like a prefetch subsystem? Does anyone have any opinions as to why this would be a bad idea for postgres? Postges is great for a multiuser environment and OLTP applications. However, in this set up, a data warehouse, the observed performance is not what I would hope for. Regards, Matt Olson Ocean Consulting http://www.oceanconsulting.com/ From pgsql-general-owner@postgresql.org Mon May 9 23:20:52 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AE26353E47; Mon, 9 May 2005 23:20:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32972-08; Tue, 10 May 2005 02:20:47 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id 0CAB053F6B; Mon, 9 May 2005 23:20:43 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j4A2KjI12976; Mon, 9 May 2005 22:20:45 -0400 (EDT) From: Bruce Momjian Message-Id: <200505100220.j4A2KjI12976@candle.pha.pa.us> Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-Reply-To: <20050509165133.GJ35026@decibel.org> To: "Jim C. Nasby" Date: Mon, 9 May 2005 22:20:45 -0400 (EDT) Cc: Neil Conway , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/439 X-Sequence-Number: 77787 Jim C. Nasby wrote: > On Tue, May 10, 2005 at 02:38:41AM +1000, Neil Conway wrote: > > Jim C. Nasby wrote: > > >Having indexes that people shouldn't be using does add confusion for > > >users, and presents the opportunity for foot-shooting. > > > > Emitting a warning/notice on hash-index creation is something I've > > suggested in the past -- that would be fine with me. > > Probably not a bad idea. Agreed. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Tue May 10 00:04:10 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E79153FC1 for ; Tue, 10 May 2005 00:04:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44513-01 for ; Tue, 10 May 2005 03:03:43 +0000 (GMT) Received: from sterling.investoranalytics.com (unknown [65.222.52.254]) by svr1.postgresql.org (Postfix) with ESMTP id DE3F253FAC for ; Tue, 10 May 2005 00:03:27 -0300 (ADT) Received: from [10.4.3.3] (unknown [10.4.3.3]) by sterling.investoranalytics.com (Postfix) with ESMTP id 516FB37A09 for ; Mon, 9 May 2005 23:03:26 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v728) In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7DB@vt-pe2550-001.vantage.vantage.com> References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF7DB@vt-pe2550-001.vantage.vantage.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Andrew Rawnsley Subject: Re: Whence the Opterons? Date: Mon, 9 May 2005 23:03:23 -0400 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/128 X-Sequence-Number: 12292 Iron Systems has a fair selection of opteron machines, up to 4 way. The one I have has Tyan guts. On May 9, 2005, at 4:10 PM, Anjan Dave wrote: > The DP+DC isn't available yet, from Sun. Only QP+DC is, for which the > bid opens at 38k, that is a bit pricey -:) > > > -----Original Message----- > From: William Yu [mailto:wyu@talisys.com] > Sent: Monday, May 09, 2005 1:24 PM > To: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Whence the Opterons? > > Unfortunately, Anandtech only used Postgres just a single time in his > benchmarks. And what it did show back then was a huge performance > advantage for the Opteron architecture over Xeon in this case. > Where the > > fastest Opterons were just 15% faster in MySQL/MSSQL/DB2 than the > fastest Xeons, it was 100%+ faster in Postgres. He probably got rid of > Postgres from his benchmark suite since it favors Opteron too much. > As a > > general hardware review site, makes senses that he needs to get more > neutral apps in order to get free systems to review and (ahem) ad > dollars. > > That being said, I wouldn't get a quad Opteron system anyways now that > the dual core Opterons are available. A DP+DC system would be > faster and > > cheaper than a pure quad system. Unless of course, I needed a QP+DC > for > 8-way SMP. > > > > > > > Anjan Dave wrote: > >> Wasn't the context switching issue occurring in specific cases only? >> >> I haven't seen any benchmarks for a 50% performance difference. >> > Neither > >> have I seen any benchmarks of pure disk IO performance of specific >> models of Dell vs HP or Sun Opterons. >> >> Thanks, >> Anjan >> >> >>> EMC you can file an RPQ via your sales contacts to get it approved, >>> though not sure how lengthy/painful that process might be, or if >>> it's >>> gonna be worth it. >>> >>> Read the article devoted to the v40z on anandtech.com. >>> >>> I am also trying to get a quad-Opteron versus the latest quad-XEON >>> >> >> from >> >> >>> Dell (6850), but it's hard to justify a difference between a 15K >>> dell >>> versus a 30k v40z for a 5-8% performance gain (read the XEON Vs. >>> >> >> Opteron >> >> >>> Database comparo on anandtech.com)... >>> >>> Thanks, >>> Anjan >>> >>> >> >> >> 15k vs 30k is indeed a big difference. But also realize that Postgres >> has a specific benefit to Opterons versus Xeons. The context >> switching >> storm happens less on an Opteron for some reason. >> >> I would venture a much greater benefit than 5-8%, more like 10-50%. >> > > ---------------------------(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 > > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend > > -------------------- Andrew Rawnsley President The Ravensfield Digital Resource Group, Ltd. (740) 587-0114 www.ravensfield.com From pgsql-general-owner@postgresql.org Tue May 10 01:11:20 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 17E035388C for ; Tue, 10 May 2005 01:11:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58513-06 for ; Tue, 10 May 2005 04:11:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5268A534EA for ; Tue, 10 May 2005 01:11:04 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4A4Aw5i004408; Tue, 10 May 2005 00:10:58 -0400 (EDT) To: Neil Conway Cc: "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <427FFCD3.1010803@samurai.com> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> Comments: In-reply-to Neil Conway message dated "Tue, 10 May 2005 10:14:11 +1000" Date: Tue, 10 May 2005 00:10:57 -0400 Message-ID: <4407.1115698257@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/444 X-Sequence-Number: 77792 Neil Conway writes: > Jim C. Nasby wrote: >>> No, hash joins and hash indexes are unrelated. >> I know they are now, but does that have to be the case? > I mean, the algorithms are fundamentally unrelated. They share a bit of > code such as the hash functions themselves, but they are really solving > two different problems In fact, up till fairly recently they didn't even share the hash functions. Which was a bug not a feature, but the fact remains --- there's not a lot of commonality. >> Like I said, I don't know the history, so I don't know why we even >> have them to begin with. I think it's largely because some Berkeley grad student had a need to implement hash indexes for academic reasons ;-) > As I said, the idea of using hash indexes for better performance on > equality scans is perfectly valid, it is just the implementation that > needs work. I was thinking about that earlier today. It seems to me there is a window within which hash indexes are theoretically superior, but it might be pretty narrow. The basic allure of a hash index is that you look at the search key, do some allegedly-trivial computations, and go directly to the relevant index page(s); whereas a btree index requires descending through several upper levels of index pages to reach the target leaf page. On the other hand, once you reach the target index page, a hash index has no better method than linear scan through all the page's index entries to find the actually wanted key(s); in fact you have to search all the pages in that index bucket. A btree index can use binary search to find the relevant items within the page. So it strikes me that important parameters include the index entry size and the number of entries matching any particular key value. btree will probably win for smaller keys, on two grounds: it will have fewer tree levels to descend through, because of higher fan-out, and it will be much more efficient at finding the target entries within the target page when there are many entries per page. (As against this, it will have to work harder at each upper tree page to decide where to descend to --- but I think that's a second-order consideration.) hash will tend to win as the number of duplicate keys increases, because its relative inefficiency at finding the matches within a particular bucket will become less significant. (The ideal situation for a hash index is to have only one actual key value per bucket. You can't really afford to store only one index entry per bucket, because of the sheer I/O volume that would result, so you need multiple entries that will all be responsive to your search.) (This also brings up the thought that it might be interesting to support hash buckets smaller than a page ... but I don't know how to make that work in an adaptive fashion.) I suspect that people haven't looked hard for a combination of these parameters within which hash can win. Of course the real question for us is whether the window is wide enough to justify the maintenance effort for hash. regards, tom lane From pgsql-general-owner@postgresql.org Tue May 10 01:25:23 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC3CB53363; Tue, 10 May 2005 01:25:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61618-03; Tue, 10 May 2005 04:25:14 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id D4F3D53921; Tue, 10 May 2005 01:25:13 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 84C3818CD50; Tue, 10 May 2005 00:25:13 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 09175-01-7; Tue, 10 May 2005 00:25:11 -0400 (EDT) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 3659B18CD45; Tue, 10 May 2005 00:25:09 -0400 (EDT) Message-ID: <428037A2.4060304@samurai.com> Date: Tue, 10 May 2005 14:25:06 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> In-Reply-To: <4407.1115698257@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/446 X-Sequence-Number: 77794 Tom Lane wrote: > On the other hand, once you reach the target index page, a hash index > has no better method than linear scan through all the page's index > entries to find the actually wanted key(s) I wonder if it would be possible to store the keys in a hash bucket in sorted order, provided that the necessary ordering is defined for the index keys -- considering the ubiquity of b+-trees in Postgres, the chances of an ordering being defined are pretty good. Handling overflow pages would be tricky: perhaps we could store the entries in a given page in sorted order, but not try to maintain that order for the hash bucket as a whole. This would mean we'd need to do a binary search for each page of the bucket, but that would still be a win. -Neil From pgsql-general-owner@postgresql.org Tue May 10 01:55:29 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88C6253A2F for ; Tue, 10 May 2005 01:55:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64387-04 for ; Tue, 10 May 2005 04:55:17 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1E5F45398C for ; Tue, 10 May 2005 01:55:15 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4A4smer006687; Tue, 10 May 2005 00:54:48 -0400 (EDT) To: Neil Conway Cc: "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <428037A2.4060304@samurai.com> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> Comments: In-reply-to Neil Conway message dated "Tue, 10 May 2005 14:25:06 +1000" Date: Tue, 10 May 2005 00:54:48 -0400 Message-ID: <6686.1115700888@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/448 X-Sequence-Number: 77796 Neil Conway writes: > Tom Lane wrote: >> On the other hand, once you reach the target index page, a hash index >> has no better method than linear scan through all the page's index >> entries to find the actually wanted key(s) > I wonder if it would be possible to store the keys in a hash bucket in > sorted order, provided that the necessary ordering is defined for the > index keys -- considering the ubiquity of b+-trees in Postgres, the > chances of an ordering being defined are pretty good. I have a gut reaction against that: it makes hash indexes fundamentally subservient to btrees. We shouldn't bring in concepts that are outside the basic opclass abstraction. However: what about storing the things in hashcode order? Ordering uint32s doesn't seem like any big conceptual problem. I think that efficient implementation of this would require explicitly storing the hash code for each index entry, which we don't do now, but it seems justifiable on multiple grounds --- besides this point, the search could avoid doing the data-type-specific comparison if the hash code isn't equal. There is evidence in the code that indexes used to store more info than what we now think of as a "standard" index tuple. I am not sure when that went away or what it'd cost to bring it back, but it seems worth looking into. regards, tom lane From pgsql-general-owner@postgresql.org Tue May 10 02:30:09 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 74BCC52A85; Tue, 10 May 2005 02:30:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70092-01; Tue, 10 May 2005 05:29:55 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 5A92D53693; Tue, 10 May 2005 02:29:54 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 2379F18CC12; Tue, 10 May 2005 01:29:55 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 11325-01-6; Tue, 10 May 2005 01:29:53 -0400 (EDT) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id AF2A418CCD9; Tue, 10 May 2005 01:29:51 -0400 (EDT) Message-ID: <428046CC.4090601@samurai.com> Date: Tue, 10 May 2005 15:29:48 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> In-Reply-To: <6686.1115700888@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/450 X-Sequence-Number: 77798 Tom Lane wrote: > I have a gut reaction against that: it makes hash indexes fundamentally > subservient to btrees. I wouldn't say "subservient" -- if there is no ordering defined for the index key, we just do a linear scan. > However: what about storing the things in hashcode order? Ordering uint32s > doesn't seem like any big conceptual problem. Hmm, my memory of the hash code is a bit fuzzy. Do I understand correctly? - we only use some of the bits in the hash to map from the hash of a key to its bucket - therefore within a bucket, we can still distinguish most of the non-equal tuples from one another by comparing their full hash values - if we keep the entries in a bucket (or page, I guess -- per earlier mail) sorted by full hash value, we can use that to perform a binary search Sounds like a good idea to me. How likely is it that the hash index will be sufficiently large that we're using most of the bits in the hash just to map hash values to buckets, so that the binary search won't be very effective? (At this point many of the distinct keys in each bucket will be full-on hash collisions, although sorting by the key values themselves would still be effective.) > I think that efficient implementation of this would require explicitly > storing the hash code for each index entry, which we don't do now, but > it seems justifiable on multiple grounds --- besides this point, the > search could avoid doing the data-type-specific comparison if the hash > code isn't equal. Another benefit is that it would speed up page splits -- there would be no need to rehash all the keys in a bucket when doing the split. -Neil From pgsql-general-owner@postgresql.org Tue May 10 03:12:36 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C1BD154034; Tue, 10 May 2005 03:12:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74263-08; Tue, 10 May 2005 06:12:27 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id C47875403C; Tue, 10 May 2005 03:12:26 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DVNyc-00073p-00; Tue, 10 May 2005 02:12:18 -0400 To: Tom Lane Cc: Neil Conway , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> In-Reply-To: <6686.1115700888@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 10 May 2005 02:12:17 -0400 Message-ID: <878y2nsj7i.fsf@stark.xeocode.com> Lines: 22 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/453 X-Sequence-Number: 77801 Tom Lane writes: > However: what about storing the things in hashcode order? Ordering uint32s > doesn't seem like any big conceptual problem. > > I think that efficient implementation of this would require explicitly > storing the hash code for each index entry, which we don't do now, but > it seems justifiable on multiple grounds --- besides this point, the > search could avoid doing the data-type-specific comparison if the hash > code isn't equal. It seems that means doubling the size of the hash index. That's a pretty big i/o to cpu tradeoff. What if the hash index stored *only* the hash code? That could be useful for indexing large datatypes that would otherwise create large indexes. A good hash function should have a pretty low collision rate anyways so the occasional extra i/o should more than be outweighed by the decrease in i/o needed to use the index. -- greg From pgsql-performance-owner@postgresql.org Tue May 10 06:03:45 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DCC37540D6 for ; Tue, 10 May 2005 06:03:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99438-02 for ; Tue, 10 May 2005 09:03:40 +0000 (GMT) Received: from mailgw.dmi.dk (mailgw.dmi.dk [130.226.71.185]) by svr1.postgresql.org (Postfix) with ESMTP id 23D72540BE for ; Tue, 10 May 2005 06:03:37 -0300 (ADT) Received: from localhost (localhost.dmi.dk [127.0.0.1]) by mailgw.dmi.dk (8.12.11/8.12.11/Debian-1) with ESMTP id j4A93cGA019332 for ; Tue, 10 May 2005 09:03:38 GMT Received: from mailgw.dmi.dk ([127.0.0.1]) by localhost (mailgw.dmi.dk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19315-01 for ; Tue, 10 May 2005 09:03:37 +0000 (GMT) Received: from postoffice.dmi.dk (postoffice.dmi.dk [130.226.64.60]) by mailgw.dmi.dk (8.12.11/8.12.11/Debian-1) with ESMTP id j4A93ZHS019325 for ; Tue, 10 May 2005 09:03:35 GMT Received: from [130.226.66.16] (anders [130.226.66.16]) by postoffice.dmi.dk (Postfix) with ESMTP id E7C031802E for ; Tue, 10 May 2005 09:03:34 +0000 (GMT) Message-ID: <428078E6.90007@dmi.dk> Date: Tue, 10 May 2005 11:03:34 +0200 From: Kim Bisgaard User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: full outer performance problem Content-Type: multipart/alternative; boundary="------------000700020602090301070908" X-Virus-Scanned: by amavisd-maia-1.0.0-rc5 (Debian) at dmi.dk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.341 tagged_above=0 required=5 tests=HTML_10_20, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: X-Archive-Number: 200505/134 X-Sequence-Number: 12298 This is a multi-part message in MIME format. --------------000700020602090301070908 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I'm having problems with the query optimizer and FULL OUTER JOIN on PostgreSQL 7.4. I cannot get it to use my indexes with full outer joins. I might be naive, but I think that it should be possible? I have two BIG tables (virtually identical) with 3 NOT NULL columns Station_id, TimeObs, Temp_XXXX, with indexes on (Station_id, TimeObs) and valid ANALYSE (set statistics=100). I want to join the two tables with a FULL OUTER JOIN. When I specify the query as: select temp_max_60min,temp_dry_at_2m from station s natural join temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs) where s.wmo_id=6065 and timeobs='2004-1-1 0:0:0' and '2004-1-1 0:0:0' between s.startdate and s.enddate; I get the correct results, BUT LOUSY performance, and the following explain: Nested Loop Left Join (cost=5.84..163484.08 rows=1349 width=12) (actual time=66146.815..119005.381 rows=1 loops=1) Filter: (COALESCE("outer".timeobs, "inner".timeobs) = '2004-01-01 00:00:00'::timestamp without time zone) -> Hash Join (cost=5.84..155420.24 rows=1349 width=16) (actual time=8644.449..110836.038 rows=109826 loops=1) Hash Cond: ("outer".station_id = "inner".station_id) -> Seq Scan on temp_dry_at_2m a (cost=0.00..120615.94 rows=6956994 width=16) (actual time=0.024..104548.515 rows=6956994 loops=1) -> Hash (cost=5.84..5.84 rows=1 width=4) (actual time=0.114..0.114 rows=0 loops=1) -> Index Scan using wmo_idx on station (cost=0.00..5.84 rows=1 width=4) (actual time=0.105..0.108 rows=1 loops=1) Index Cond: ((wmo_id = 6065) AND ('2004-01-01 00:00:00'::timestamp without time zone >= startdate) AND ('2004-01-01 00:00:00'::timestamp without time zone <= enddate)) -> Index Scan using temp_max_60min_idx on temp_max_60min b (cost=0.00..5.96 rows=1 width=20) (actual time=0.071..0.071 rows=0 loops=109826) Index Cond: (("outer".station_id = b.station_id) AND ("outer".timeobs = b.timeobs)) Total runtime: 119005.499 ms (11 rows) If I change the query to (and thus negates the full outer join): select temp_max_60min,temp_dry_at_2m from station s natural join temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs) where s.wmo_id=6065 and _a.timeobs='2004-1-1 0:0:0' and b._timeobs='2004-1-1 0:0:0' and '2004-1-1 0:0:0' between s.startdate and s.enddate; I get wrong results (In the case where one of the records is missing in one of the tables), BUT GOOD performance, and this query plan: Nested Loop (cost=0.00..17.83 rows=1 width=12) (actual time=79.221..79.236 rows=1 loops=1) -> Nested Loop (cost=0.00..11.82 rows=1 width=24) (actual time=65.517..65.526 rows=1 loops=1) -> Index Scan using wmo_idx on station (cost=0.00..5.83 rows=1 width=4) (actual time=0.022..0.026 rows=1 loops=1) Index Cond: ((wmo_id = 6065) AND ('2004-01-01 00:00:00'::timestamp without time zone >= startdate) AND ('2004-01-01 00:00:00'::timestamp without time zone <= enddate)) -> Index Scan using temp_max_60min_idx on temp_max_60min b (cost=0.00..5.97 rows=1 width=20) (actual time=65.483..65.486 rows=1 loops=1) Index Cond: (("outer".station_id = b.station_id) AND (b.timeobs = '2004-01-01 00:00:00'::timestamp without time zone)) -> Index Scan using temp_dry_at_2m_idx on temp_dry_at_2m a (cost=0.00..6.00 rows=1 width=16) (actual time=13.694..13.698 rows=1 loops=1) Index Cond: (("outer".station_id = a.station_id) AND (a.timeobs = '2004-01-01 00:00:00'::timestamp without time zone)) Total runtime: 79.340 ms (9 rows) If further info like EXPLAIN VERBOSE is useful please say so and I will provide it. Thanks in advance! Kim Bisgaard. --------------000700020602090301070908 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi,

I'm having problems with the query optimizer and FULL OUTER JOIN on PostgreSQL 7.4. I cannot get it to use my indexes with full outer joins. I might be naive, but I think that it should be possible?

I have two BIG tables (virtually identical) with 3 NOT NULL columns Station_id, TimeObs, Temp_XXXX, with indexes on (Station_id, TimeObs) and valid ANALYSE (set statistics=100). I want to join the two tables with a FULL OUTER JOIN.

When I specify the query as:
select temp_max_60min,temp_dry_at_2m
from station s natural join
temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs)
where s.wmo_id=6065 
and timeobs='2004-1-1 0:0:0'
and '2004-1-1 0:0:0' between s.startdate and s.enddate;
I get the correct results, BUT LOUSY performance, and the following explain:
 Nested Loop Left Join  (cost=5.84..163484.08 rows=1349 width=12) (actual time=66146.815..119005.381 rows=1 loops=1)
   Filter: (COALESCE("outer".timeobs, "inner".timeobs) = '2004-01-01 00:00:00'::timestamp without time zone)
   ->  Hash Join  (cost=5.84..155420.24 rows=1349 width=16) (actual time=8644.449..110836.038 rows=109826 loops=1)
         Hash Cond: ("outer".station_id = "inner".station_id)
         ->  Seq Scan on temp_dry_at_2m a  (cost=0.00..120615.94 rows=6956994 width=16) (actual time=0.024..104548.515 rows=6956994 loops=1)
         ->  Hash  (cost=5.84..5.84 rows=1 width=4) (actual time=0.114..0.114 rows=0 loops=1)
               ->  Index Scan using wmo_idx on station  (cost=0.00..5.84 rows=1 width=4) (actual time=0.105..0.108 rows=1 loops=1)
                     Index Cond: ((wmo_id = 6065) AND ('2004-01-01 00:00:00'::timestamp without time zone >= startdate) AND ('2004-01-01 00:00:00'::timestamp without time zone <= enddate))
   ->  Index Scan using temp_max_60min_idx on temp_max_60min b  (cost=0.00..5.96 rows=1 width=20) (actual time=0.071..0.071 rows=0 loops=109826)
         Index Cond: (("outer".station_id = b.station_id) AND ("outer".timeobs = b.timeobs))
 Total runtime: 119005.499 ms
(11 rows)
If I change the query to (and thus negates the full outer join):
select temp_max_60min,temp_dry_at_2m
from station s natural join
temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs)
where s.wmo_id=6065 
and a.timeobs='2004-1-1 0:0:0' and b.timeobs='2004-1-1 0:0:0' 
and '2004-1-1 0:0:0' between s.startdate and s.enddate;

I get wrong results (In the case where one of the records is missing in one of the tables), BUT GOOD performance, and this query plan:
 Nested Loop  (cost=0.00..17.83 rows=1 width=12) (actual time=79.221..79.236 rows=1 loops=1)
   ->  Nested Loop  (cost=0.00..11.82 rows=1 width=24) (actual time=65.517..65.526 rows=1 loops=1)
         ->  Index Scan using wmo_idx on station  (cost=0.00..5.83 rows=1 width=4) (actual time=0.022..0.026 rows=1 loops=1)
               Index Cond: ((wmo_id = 6065) AND ('2004-01-01 00:00:00'::timestamp without time zone >= startdate) AND ('2004-01-01 00:00:00'::timestamp without time zone <= enddate))
         ->  Index Scan using temp_max_60min_idx on temp_max_60min b  (cost=0.00..5.97 rows=1 width=20) (actual time=65.483..65.486 rows=1 loops=1)
               Index Cond: (("outer".station_id = b.station_id) AND (b.timeobs = '2004-01-01 00:00:00'::timestamp without time zone))
   ->  Index Scan using temp_dry_at_2m_idx on temp_dry_at_2m a  (cost=0.00..6.00 rows=1 width=16) (actual time=13.694..13.698 rows=1 loops=1)
         Index Cond: (("outer".station_id = a.station_id) AND (a.timeobs = '2004-01-01 00:00:00'::timestamp without time zone))
 Total runtime: 79.340 ms
(9 rows)

If further info like EXPLAIN VERBOSE is useful please say so and I will provide it.

Thanks in advance!
Kim Bisgaard.

--------------000700020602090301070908-- From pgsql-performance-owner@postgresql.org Tue May 10 07:03:38 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC94F536AD for ; Tue, 10 May 2005 07:03:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12926-01 for ; Tue, 10 May 2005 10:03:28 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id B87E753892 for ; Tue, 10 May 2005 07:03:25 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-5.tower-49.messagelabs.com!1115719406!172026!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 8218 invoked from network); 10 May 2005 10:03:26 -0000 Received: from mail.advfn.com (212.161.99.149) by server-5.tower-49.messagelabs.com with SMTP; 10 May 2005 10:03:26 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DVRaI-0008GJ-0E for pgsql-performance@postgresql.org; Tue, 10 May 2005 11:03:26 +0100 Mime-Version: 1.0 (Apple Message framework v728) Content-Transfer-Encoding: 7bit Message-Id: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: pgsql-performance@postgresql.org From: Alex Stapleton Subject: Partitioning / Clustering Date: Tue, 10 May 2005 11:03:26 +0100 X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/135 X-Sequence-Number: 12299 What is the status of Postgres support for any sort of multi-machine scaling support? What are you meant to do once you've upgraded your box and tuned the conf files as much as you can? But your query load is just too high for a single machine? Upgrading stock Dell boxes (I know we could be using better machines, but I am trying to tackle the real issue) is not a hugely price efficient way of getting extra performance, nor particularly scalable in the long term. So, when/is PG meant to be getting a decent partitioning system? MySQL is getting one (eventually) which is apparently meant to be similiar to Oracle's according to the docs. Clusgres does not appear to be widely/or at all used, and info on it seems pretty thin on the ground, so I am not too keen on going with that. Is the real solution to multi- machine partitioning (as in, not like MySQLs MERGE tables) on PostgreSQL actually doing it in our application API? This seems like a less than perfect solution once we want to add redundancy and things into the mix. From pgsql-performance-owner@postgresql.org Sun May 15 15:30:35 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9AEE65374F for ; Tue, 10 May 2005 10:01:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37876-01 for ; Tue, 10 May 2005 13:01:18 +0000 (GMT) Received: from www.vif.tm.fr (vignoninformatic.rain.fr [194.51.37.1]) by svr1.postgresql.org (Postfix) with ESMTP id CFFA1536EA for ; Tue, 10 May 2005 10:01:11 -0300 (ADT) Received: from Guillaumen (guillaumen.vif.tm.fr [128.1.1.114]) by www.vif.tm.fr (8.12.11/8.12.10) with ESMTP id j4ACtZe9029831 for ; Tue, 10 May 2005 14:55:36 +0200 From: "Guillaume Nobiron" To: Subject: Swapping and Kernel 2.6 Date: Tue, 10 May 2005 15:01:13 +0200 Message-ID: <001001c55560$58765aa0$72010180@Guillaumen> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Scanned-By: MIMEDefang 2.48 on 127.0.0.1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/286 X-Sequence-Number: 12450 Hi, Environment : - Fedora Core 2 (kernel 2.6.10) - postgresql 7.4.7 I am running a huge query with several joins that needs around 900 Mbytes of Memory (System RAM is 512 Mbytes). When the system starts to swap the postgres process, CPU consumed drops to around 2% (instead of around 50% on another system with kernel 2.4). The query was still working after more than 4 hours, spending the time with 98% if IO wait. So I tried to run the postmaster with the environment variable LD_ASSUME_KERNEL=2.4.1. With this, the query last 7 minutes !!! Why swapping is so bad with the new kernel ? Thanks, Guillaume From pgsql-performance-owner@postgresql.org Tue May 10 10:52:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A9A9542C9 for ; Tue, 10 May 2005 10:52:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44693-04 for ; Tue, 10 May 2005 13:52:27 +0000 (GMT) Received: from atlantis.oceanconsulting.com (smtp.oceanconsulting.com [216.65.145.145]) by svr1.postgresql.org (Postfix) with ESMTP id A22B653993 for ; Tue, 10 May 2005 10:52:26 -0300 (ADT) Received: from tex.pacific.oceanconsulting.com (ip150.145.dsl-acs2.pdx.iinet.com [216.65.145.150]) by atlantis.oceanconsulting.com (8.13.1/8.13.1) with ESMTP id j4ADoG79011299 for ; Tue, 10 May 2005 06:50:16 -0700 From: Matt Olson Subject: Prefetch Date: Tue, 10 May 2005 06:52:51 -0700 User-Agent: KMail/1.7.1 Organization: Ocean Consulting To: pgsql-performance@postgresql.org Reply-To: molson@oceanconsulting.com MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505100652.51401.molson@oceanconsulting.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/136 X-Sequence-Number: 12300 I wanted to get some opinions about row prefetching. AFAIK, there is no prefetching done by PostgreSQL; all prefetching is delegated to the operating system. The hardware (can't say enough good things about it): Athlon 64, dual channel 4GB ram 240GB usable 4 disk raid5 (ATA133) Fedora Core 3 PostgreSQL 7.4.7 I have what is essentially a data warehouse of stock data. Each day has around 30,000 records (tickers). A typical operation is to get the 200 day simple moving average (of price) for each ticker and write the result to a summary table. In running this process (Perl/DBI), it is typical to see 70-80% I/O wait time with postgres running a about 8-9%. If I run the next day's date, the postgres cache and file cache is now populated with 199 days of the needed data, postgres runs 80-90% of CPU and total run time is greatly reduced. My conclusion is that this is a high cache hit rate in action. I've done other things that make sense, like using indexes, playing with the planner constants and turning up the postgres cache buffers. Even playing with extream hdparm read-ahead numbers (i.e. 64738) yields no apparent difference in database performance. The random nature of the I/O drops disk reads down to about 1MB/sec for the array. A linear table scan can easily yield 70-80MB/sec on this system. Total table size is usually around 1GB and with indexes should be able to fit completely in main memory. Other databases like Oracle and DB2 implement some sort of row prefetch. Has there been serious consideration of implementing something like a prefetch subsystem? Does anyone have any opinions as to why this would be a bad idea for postgres? Postges is great for a multiuser environment and OLTP applications. However, in this set up, a data warehouse, the observed performance is not what I would hope for. Regards, Matt Olson Ocean Consulting http://www.oceanconsulting.com/ From pgsql-general-owner@postgresql.org Tue May 10 10:53:43 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6E16653979; Tue, 10 May 2005 10:53:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44108-07; Tue, 10 May 2005 13:53:31 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id EA24B5398F; Tue, 10 May 2005 10:53:30 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4ADrIZv009872; Tue, 10 May 2005 09:53:18 -0400 (EDT) To: Greg Stark Cc: Neil Conway , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <878y2nsj7i.fsf@stark.xeocode.com> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "10 May 2005 02:12:17 -0400" Date: Tue, 10 May 2005 09:53:18 -0400 Message-ID: <9871.1115733198@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/477 X-Sequence-Number: 77825 Greg Stark writes: > Tom Lane writes: >> I think that efficient implementation of this would require explicitly >> storing the hash code for each index entry, > It seems that means doubling the size of the hash index. That's a pretty big > i/o to cpu tradeoff. Hardly. The minimum possible size of a hash entry today is 8 bytes header plus 4 bytes datum, plus there's a 4-byte line pointer to factor in. So under the most pessimistic assumptions, storing the hash code would add 25% to the size. (On MAXALIGN=8 hardware, it might cost you nothing at all.) > What if the hash index stored *only* the hash code? That could be useful for > indexing large datatypes that would otherwise create large indexes. Hmm, that could be a thought. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 10 11:16:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2A3B6542C9 for ; Tue, 10 May 2005 11:16:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49047-02 for ; Tue, 10 May 2005 14:16:20 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9DF60542E8 for ; Tue, 10 May 2005 11:16:17 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4AEGKgb010062; Tue, 10 May 2005 10:16:20 -0400 (EDT) To: molson@oceanconsulting.com Cc: pgsql-performance@postgresql.org Subject: Re: Prefetch In-reply-to: <200505100652.51401.molson@oceanconsulting.com> References: <200505100652.51401.molson@oceanconsulting.com> Comments: In-reply-to Matt Olson message dated "Tue, 10 May 2005 06:52:51 -0700" Date: Tue, 10 May 2005 10:16:20 -0400 Message-ID: <10061.1115734580@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/138 X-Sequence-Number: 12302 Matt Olson writes: > Other databases like Oracle and DB2 implement some sort of row prefetch. Has > there been serious consideration of implementing something like a prefetch > subsystem? No. > Does anyone have any opinions as to why this would be a bad idea for > postgres? We know even less than the OS does about disk layout, and not a lot more than it about what our next request will be. (If we're doing a seqscan, then of course that's not true, but I would expect the OS to be able to figure that one out and do readahead.) You haven't shown us your problem queries, but I think that conventional query tuning would be a more appropriate answer. In particular I wonder whether you shouldn't be looking at ways to calculate multiple aggregates in parallel. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 10 12:05:37 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 35E2D53ED2 for ; Tue, 10 May 2005 12:04:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55526-10 for ; Tue, 10 May 2005 15:03:59 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 282ED53A35 for ; Tue, 10 May 2005 12:03:58 -0300 (ADT) Received: from 216-154-14-104.dsl.look.ca (216-154-14-104.dsl.look.ca [216.154.14.104]) by tht.net (Postfix) with ESMTP id 1CDADAA4BB; Tue, 10 May 2005 10:18:19 -0400 (EDT) Subject: Re: Prefetch From: Rod Taylor To: molson@oceanconsulting.com Cc: pgsql-performance@postgresql.org In-Reply-To: <200505100652.51401.molson@oceanconsulting.com> References: <200505100652.51401.molson@oceanconsulting.com> Content-Type: text/plain Date: Tue, 10 May 2005 10:17:59 -0400 Message-Id: <1115734679.6888.63.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/143 X-Sequence-Number: 12307 > I've done other things that make sense, like using indexes, playing with the > planner constants and turning up the postgres cache buffers. After you load the new days data try running CLUSTER on the structure using a key of (stockID, date) -- probably your primary key. This should significantly reduce the amount of IO required for your calculations involving a few stocks over a period of time. -- From pgsql-performance-owner@postgresql.org Tue May 10 11:29:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9492C53ED2 for ; Tue, 10 May 2005 11:29:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49465-10 for ; Tue, 10 May 2005 14:29:03 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 37489536EE for ; Tue, 10 May 2005 11:29:01 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4AET3YE022092; (envelope-from ) Tue, 10 May 2005 09:29:03 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4AESxnM001308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 10 May 2005 09:29:00 -0500 (CDT) Message-ID: <4280C526.3070609@arbash-meinel.com> Date: Tue, 10 May 2005 09:28:54 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kim Bisgaard Cc: pgsql-performance@postgresql.org Subject: Re: full outer performance problem References: <428078E6.90007@dmi.dk> In-Reply-To: <428078E6.90007@dmi.dk> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig20A89A4C83E561DB1EC03F0A" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/139 X-Sequence-Number: 12303 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig20A89A4C83E561DB1EC03F0A Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Kim Bisgaard wrote: > Hi, > > I'm having problems with the query optimizer and FULL OUTER JOIN on > PostgreSQL 7.4. I cannot get it to use my indexes with full outer joins. > I might be naive, but I think that it should be possible? > > I have two BIG tables (virtually identical) with 3 NOT NULL columns > Station_id, TimeObs, Temp_XXXX, with indexes on (Station_id, TimeObs) > and valid ANALYSE (set statistics=100). I want to join the two tables > with a FULL OUTER JOIN. > > When I specify the query as: > > select temp_max_60min,temp_dry_at_2m > from station s natural join > temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs) > where s.wmo_id=6065 > and timeobs='2004-1-1 0:0:0' > and '2004-1-1 0:0:0' between s.startdate and s.enddate; > > I get the correct results, BUT LOUSY performance, and the following explain: > > Nested Loop Left Join (cost=5.84..163484.08 rows=1349 width=12) (actual time=66146.815..119005.381 rows=1 loops=1) > Filter: (COALESCE("outer".timeobs, "inner".timeobs) = '2004-01-01 00:00:00'::timestamp without time zone) > -> Hash Join (cost=5.84..155420.24 rows=1349 width=16) (actual time=8644.449..110836.038 rows=109826 loops=1) Well, the estimate here is quite a bit off. It thinks you will be getting 1349 (which is probably why it picked a nested loop plan), but then it is getting 109826 rows. I'm guessing it is misunderstanding the selectivity of the timeobs column. > Hash Cond: ("outer".station_id = "inner".station_id) > -> Seq Scan on temp_dry_at_2m a (cost=0.00..120615.94 rows=6956994 width=16) (actual time=0.024..104548.515 rows=6956994 loops=1) > -> Hash (cost=5.84..5.84 rows=1 width=4) (actual time=0.114..0.114 rows=0 loops=1) > -> Index Scan using wmo_idx on station (cost=0.00..5.84 rows=1 width=4) (actual time=0.105..0.108 rows=1 loops=1) > Index Cond: ((wmo_id = 6065) AND ('2004-01-01 00:00:00'::timestamp without time zone >= startdate) AND ('2004-01-01 00:00:00'::timestamp without time zone <= enddate)) > -> Index Scan using temp_max_60min_idx on temp_max_60min b (cost=0.00..5.96 rows=1 width=20) (actual time=0.071..0.071 rows=0 loops=109826) > Index Cond: (("outer".station_id = b.station_id) AND ("outer".timeobs = b.timeobs)) > Total runtime: 119005.499 ms > (11 rows) I think the bigger problem is that a full outer join says grab all rows, even if they are null. What about this query: SELECT temp_max_60min,temp_dry_at_2m FROM (station s LEFT JOIN temp_dry_at_2m a USING (station_id, timeobs) LEFT JOIN temp_max_60min b USING (station_id, timeobs) where s.wmo_id=6065 and timeobs='2004-1-1 0:0:0' and '2004-1-1 0:0:0' between s.startdate and s.enddate; After that, you should probably have a multi-column index on (station_id, timeobs), which lets postgres use just that index for the lookup, rather than using an index and then a filter. (Looking at your next query you might already have that index). > > If I change the query to (and thus negates the full outer join): This is the same query, I think you messed up your copy and paste. > > select temp_max_60min,temp_dry_at_2m > from station s natural join > temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs) > where s.wmo_id=6065 > and _a.timeobs='2004-1-1 0:0:0' and b._timeobs='2004-1-1 0:0:0' > and '2004-1-1 0:0:0' between s.startdate and s.enddate; > > > I get wrong results (In the case where one of the records is missing in > one of the tables), BUT GOOD performance, and this query plan: > > Nested Loop (cost=0.00..17.83 rows=1 width=12) (actual time=79.221..79.236 rows=1 loops=1) > -> Nested Loop (cost=0.00..11.82 rows=1 width=24) (actual time=65.517..65.526 rows=1 loops=1) > -> Index Scan using wmo_idx on station (cost=0.00..5.83 rows=1 width=4) (actual time=0.022..0.026 rows=1 loops=1) > Index Cond: ((wmo_id = 6065) AND ('2004-01-01 00:00:00'::timestamp without time zone >= startdate) AND ('2004-01-01 00:00:00'::timestamp without time zone <= enddate)) > -> Index Scan using temp_max_60min_idx on temp_max_60min b (cost=0.00..5.97 rows=1 width=20) (actual time=65.483..65.486 rows=1 loops=1) > Index Cond: (("outer".station_id = b.station_id) AND (b.timeobs = '2004-01-01 00:00:00'::timestamp without time zone)) > -> Index Scan using temp_dry_at_2m_idx on temp_dry_at_2m a (cost=0.00..6.00 rows=1 width=16) (actual time=13.694..13.698 rows=1 loops=1) > Index Cond: (("outer".station_id = a.station_id) AND (a.timeobs = '2004-01-01 00:00:00'::timestamp without time zone)) > Total runtime: 79.340 ms > (9 rows) > > > If further info like EXPLAIN VERBOSE is useful please say so and I will > provide it. > > Thanks in advance! > Kim Bisgaard. I still feel like you will have a problem with an outer join in this circumstance, because it will have to scan all of both tables. I think what you are wanting is "give me everything where station_id = X, and there is a row in either a or b". I think my LEFT JOIN example does that, but I also think there would be a subselect form which would work, which might do better. Something like: SELECT temp_max_60min,temp_dry_at_2m FROM (SELECT station_id, timeobs FROM station s WHERE s.wmo_id=6065 AND timeobs = '2004-1-1 0:0:0' AND '2004-1-1 0:0:0' BETWEEN s.startdate AND s.enddate ) AS s JOIN (SELECT temp_max_60min, temp_dry_at_2m FROM temp_dry_at_2m a FULL OUTER JOIN temp_max_60min b USING (station_id, timeobs) WHERE station_id = s.station_id AND timeobs = '2004-1-1 0:0:0' ) ; If I did this correctly, you should have a very restrictive scan done on station, which only returns a few rows based on timeobs & station_id. But it might be better to turn that final FULL OUTER JOIN into 2 LEFT JOINs like I did the first time: SELECT temp_max_60min,temp_dry_at_2m FROM (SELECT station_id, timeobs FROM station s WHERE s.wmo_id=6065 AND timeobs = '2004-1-1 0:0:0' AND '2004-1-1 0:0:0' BETWEEN s.startdate AND s.enddate ) AS s LEFT JOIN temp_dry_at_2m a USING (station_id, timeobs) LEFT JOIN temp_max_60min b USING (station_id, timeobs) ; I would hope postgres could do this from just my earlier plan. And I hope I understand what you want, such that 2 LEFT JOINS work better than your FULL OUTER JOIN. If you only want rows where one of both temp_dry or temp_max exist, you probably could just add the line: WHERE (temp_max_60_min IS NOT NULL OR temp_dry_at_2m IS NOT NULL) John =:-> --------------enig20A89A4C83E561DB1EC03F0A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCgMUpJdeBCYSNAAMRAm57AJ9eW1G+7I2DxK5H8RSlDKPfAcs8uQCfSM6H 5aNAvjaZRpEuW+By7YMLTM8= =uaxK -----END PGP SIGNATURE----- --------------enig20A89A4C83E561DB1EC03F0A-- From pgsql-performance-owner@postgresql.org Tue May 10 11:41:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8E34253A0C for ; Tue, 10 May 2005 11:41:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52648-07 for ; Tue, 10 May 2005 14:41:11 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id AD714536EE for ; Tue, 10 May 2005 11:41:10 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4AEfDl9022551; (envelope-from ) Tue, 10 May 2005 09:41:13 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4AEfCaX004366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 10 May 2005 09:41:13 -0500 (CDT) Message-ID: <4280C801.80603@arbash-meinel.com> Date: Tue, 10 May 2005 09:41:05 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alex Stapleton Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> In-Reply-To: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig28845E25F8C2B52172631B20" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/140 X-Sequence-Number: 12304 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig28845E25F8C2B52172631B20 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Alex Stapleton wrote: > What is the status of Postgres support for any sort of multi-machine > scaling support? What are you meant to do once you've upgraded your box > and tuned the conf files as much as you can? But your query load is > just too high for a single machine? > > Upgrading stock Dell boxes (I know we could be using better machines, > but I am trying to tackle the real issue) is not a hugely price > efficient way of getting extra performance, nor particularly scalable > in the long term. Switch from Dell Xeon boxes, and go to Opterons. :) Seriously, Dell is far away from Big Iron. I don't know what performance you are looking for, but you can easily get into inserting 10M rows/day with quality hardware. But actually is it your SELECT load that is too high, or your INSERT load, or something inbetween. Because Slony is around if it is a SELECT problem. http://gborg.postgresql.org/project/slony1/projdisplay.php Basically, Slony is a Master/Slave replication system. So if you have INSERT going into the Master, you can have as many replicated slaves, which can handle your SELECT load. Slony is an asynchronous replicator, so there is a time delay from the INSERT until it will show up on a slave, but that time could be pretty small. This would require some application level support, since an INSERT goes to a different place than a SELECT. But there has been some discussion about pg_pool being able to spread the query load, and having it be aware of the difference between a SELECT and an INSERT and have it route the query to the correct host. The biggest problem being that functions could cause a SELECT func() to actually insert a row, which pg_pool wouldn't know about. There are 2 possible solutions, a) don't do that when you are using this system, b) add some sort of comment hint so that pg_pool can understand that the select is actually an INSERT, and needs to be done on the master. > > So, when/is PG meant to be getting a decent partitioning system? MySQL > is getting one (eventually) which is apparently meant to be similiar to > Oracle's according to the docs. Clusgres does not appear to be > widely/or at all used, and info on it seems pretty thin on the ground, > so I am > not too keen on going with that. Is the real solution to multi- machine > partitioning (as in, not like MySQLs MERGE tables) on PostgreSQL > actually doing it in our application API? This seems like a less than > perfect solution once we want to add redundancy and things into the mix. There is also PGCluster http://pgfoundry.org/projects/pgcluster/ Which is trying to be more of a Synchronous multi-master system. I haven't heard of Clusgres, so I'm guessing it is an older attempt, which has been overtaken by pgcluster. Just realize that clusters don't necessarily scale like you would want them too. Because at some point you have to insert into the same table, which means you need to hold a lock which prevents the other machine from doing anything. And with synchronous replication, you have to wait for all of the machines to get a copy of the data before you can say it has been committed, which does *not* scale well with the number of machines. If you can make it work, I think having a powerful master server, who can finish an INSERT quickly, and then having a bunch of Slony slaves with a middleman (like pg_pool) to do load balancing among them, is the best way to scale up. There are still some requirements, like not having to see the results of an INSERT instantly (though if you are using hinting to pg_pool, you could hint that this query must be done on the master, realizing that the more you do it, the more you slow everything down). John =:-> PS> I don't know what functionality has been actually implemented in pg_pool, just that it was discussed in the past. Slony-II is also in the works. --------------enig28845E25F8C2B52172631B20 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCgMgBJdeBCYSNAAMRAvK7AJ4qOLvV2K3kG0fiHeYSMZyxWpjvFwCeMgZ4 KJvZX263H47G5nWxXF1rZic= =MgTR -----END PGP SIGNATURE----- --------------enig28845E25F8C2B52172631B20-- From pgsql-performance-owner@postgresql.org Tue May 10 11:47:36 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F0CF1542CE for ; Tue, 10 May 2005 11:45:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54078-02 for ; Tue, 10 May 2005 14:45:39 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 512DF54257 for ; Tue, 10 May 2005 11:45:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4AEjghw010319; Tue, 10 May 2005 10:45:42 -0400 (EDT) To: Kim Bisgaard Cc: pgsql-performance@postgresql.org Subject: Re: full outer performance problem In-reply-to: <428078E6.90007@dmi.dk> References: <428078E6.90007@dmi.dk> Comments: In-reply-to Kim Bisgaard message dated "Tue, 10 May 2005 11:03:34 +0200" Date: Tue, 10 May 2005 10:45:42 -0400 Message-ID: <10318.1115736342@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/141 X-Sequence-Number: 12305 Kim Bisgaard writes: > I have two BIG tables (virtually identical) with 3 NOT NULL columns > Station_id, TimeObs, Temp_XXXX, with indexes on (Station_id, TimeObs) > and valid ANALYSE (set statistics=100). I want to join the two tables > with a FULL OUTER JOIN. I'm confused. If the columns are NOT NULL, why isn't this a valid transformation of your original query? > select temp_max_60min,temp_dry_at_2m > from station s natural join > temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs) > where s.wmo_id=6065 > and _a.timeobs='2004-1-1 0:0:0' and b._timeobs='2004-1-1 0:0:0' > and '2004-1-1 0:0:0' between s.startdate and s.enddate; Seems like it's not eliminating any rows that would otherwise succeed. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 10 12:03:07 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 607FE53874 for ; Tue, 10 May 2005 12:03:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57242-03 for ; Tue, 10 May 2005 15:02:58 +0000 (GMT) Received: from flute.newsnipple.com (dsl017-049-240.sfo4.dsl.speakeasy.net [69.17.49.240]) by svr1.postgresql.org (Postfix) with ESMTP id 18BE3536EE for ; Tue, 10 May 2005 12:02:53 -0300 (ADT) Received: from ANSEL (unknown [192.168.1.198]) by flute.newsnipple.com (Postfix) with ESMTP id 00E453EFF for ; Tue, 10 May 2005 08:02:26 -0700 (PDT) From: "Adam Haberlach" To: Subject: Re: Partitioning / Clustering Date: Tue, 10 May 2005 08:02:50 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 In-Reply-To: <4280C801.80603@arbash-meinel.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcVVblH57m+5Af1XTraG0+7+9yFqnQAATVjg Message-Id: <20050510150226.00E453EFF@flute.newsnipple.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/142 X-Sequence-Number: 12306 I think that perhaps he was trying to avoid having to buy "Big Iron" at all. With all the Opteron v. Xeon around here, and talk of $30,000 machines, perhaps it would be worth exploring the option of buying 10 cheapass machines for $300 each. At the moment, that $300 buys you, from Dell, a 2.5Ghz Pentium 4 w/ 256mb of RAM and a 40Gb hard drive and gigabit ethernet. The aggregate CPU and bandwidth is pretty stupendous, but not as easy to harness as a single machine. For those of us looking at batch and data warehousing applications, it would be really handy to be able to partition databases, tables, and processing load across banks of cheap hardware. Yes, clustering solutions can distribute the data, and can even do it on a per-table basis in some cases. This still leaves it up to the application's logic to handle reunification of the data. Ideas: 1. Create a table/storage type that consists of a select statement on another machine. While I don't think the current executor is capable of working on multiple nodes of an execution tree at the same time, it would be great if it could offload a select of tuples from a remote table to an entirely different server and merge the resulting data into the current execution. I believe MySQL has this, and Oracle may implement it in another way. 2. There is no #2 at this time, but I'm sure one can be hypothesized. ...Google and other companies have definitely proved that one can harness huge clusters of cheap hardware. It can't be _that_ hard, can it. :) -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of John A Meinel Sent: Tuesday, May 10, 2005 7:41 AM To: Alex Stapleton Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Partitioning / Clustering Alex Stapleton wrote: > What is the status of Postgres support for any sort of multi-machine > scaling support? What are you meant to do once you've upgraded your > box and tuned the conf files as much as you can? But your query load > is just too high for a single machine? > > Upgrading stock Dell boxes (I know we could be using better machines, > but I am trying to tackle the real issue) is not a hugely price > efficient way of getting extra performance, nor particularly scalable > in the long term. Switch from Dell Xeon boxes, and go to Opterons. :) Seriously, Dell is far away from Big Iron. I don't know what performance you are looking for, but you can easily get into inserting 10M rows/day with quality hardware. But actually is it your SELECT load that is too high, or your INSERT load, or something inbetween. Because Slony is around if it is a SELECT problem. http://gborg.postgresql.org/project/slony1/projdisplay.php Basically, Slony is a Master/Slave replication system. So if you have INSERT going into the Master, you can have as many replicated slaves, which can handle your SELECT load. Slony is an asynchronous replicator, so there is a time delay from the INSERT until it will show up on a slave, but that time could be pretty small. This would require some application level support, since an INSERT goes to a different place than a SELECT. But there has been some discussion about pg_pool being able to spread the query load, and having it be aware of the difference between a SELECT and an INSERT and have it route the query to the correct host. The biggest problem being that functions could cause a SELECT func() to actually insert a row, which pg_pool wouldn't know about. There are 2 possible solutions, a) don't do that when you are using this system, b) add some sort of comment hint so that pg_pool can understand that the select is actually an INSERT, and needs to be done on the master. > > So, when/is PG meant to be getting a decent partitioning system? > MySQL is getting one (eventually) which is apparently meant to be > similiar to Oracle's according to the docs. Clusgres does not appear > to be widely/or at all used, and info on it seems pretty thin on the > ground, so I am not too keen on going with that. Is the real solution > to multi- machine partitioning (as in, not like MySQLs MERGE tables) > on PostgreSQL actually doing it in our application API? This seems > like a less than perfect solution once we want to add redundancy and > things into the mix. There is also PGCluster http://pgfoundry.org/projects/pgcluster/ Which is trying to be more of a Synchronous multi-master system. I haven't heard of Clusgres, so I'm guessing it is an older attempt, which has been overtaken by pgcluster. Just realize that clusters don't necessarily scale like you would want them too. Because at some point you have to insert into the same table, which means you need to hold a lock which prevents the other machine from doing anything. And with synchronous replication, you have to wait for all of the machines to get a copy of the data before you can say it has been committed, which does *not* scale well with the number of machines. If you can make it work, I think having a powerful master server, who can finish an INSERT quickly, and then having a bunch of Slony slaves with a middleman (like pg_pool) to do load balancing among them, is the best way to scale up. There are still some requirements, like not having to see the results of an INSERT instantly (though if you are using hinting to pg_pool, you could hint that this query must be done on the master, realizing that the more you do it, the more you slow everything down). John =:-> PS> I don't know what functionality has been actually implemented in pg_pool, just that it was discussed in the past. Slony-II is also in the works. From pgsql-performance-owner@postgresql.org Tue May 10 12:10:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 32F6952A38 for ; Tue, 10 May 2005 12:10:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58690-01 for ; Tue, 10 May 2005 15:10:35 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id 312D754452 for ; Tue, 10 May 2005 12:10:33 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-15.tower-49.messagelabs.com!1115737831!1175660!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 30531 invoked from network); 10 May 2005 15:10:31 -0000 Received: from mail.advfn.com (212.161.99.149) by server-15.tower-49.messagelabs.com with SMTP; 10 May 2005 15:10:31 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DVWNS-00074A-Qh; Tue, 10 May 2005 16:10:30 +0100 In-Reply-To: <4280C801.80603@arbash-meinel.com> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Partitioning / Clustering Date: Tue, 10 May 2005 16:10:30 +0100 To: John A Meinel X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/144 X-Sequence-Number: 12308 On 10 May 2005, at 15:41, John A Meinel wrote: > Alex Stapleton wrote: > >> What is the status of Postgres support for any sort of multi-machine >> scaling support? What are you meant to do once you've upgraded >> your box >> and tuned the conf files as much as you can? But your query load is >> just too high for a single machine? >> >> Upgrading stock Dell boxes (I know we could be using better machines, >> but I am trying to tackle the real issue) is not a hugely price >> efficient way of getting extra performance, nor particularly scalable >> in the long term. >> > > Switch from Dell Xeon boxes, and go to Opterons. :) Seriously, Dell is > far away from Big Iron. I don't know what performance you are looking > for, but you can easily get into inserting 10M rows/day with quality > hardware. Better hardware = More Efficient != More Scalable > But actually is it your SELECT load that is too high, or your INSERT > load, or something inbetween. > > Because Slony is around if it is a SELECT problem. > http://gborg.postgresql.org/project/slony1/projdisplay.php > > Basically, Slony is a Master/Slave replication system. So if you have > INSERT going into the Master, you can have as many replicated slaves, > which can handle your SELECT load. > Slony is an asynchronous replicator, so there is a time delay from the > INSERT until it will show up on a slave, but that time could be pretty > small. > >> >> So, when/is PG meant to be getting a decent partitioning system? >> MySQL >> is getting one (eventually) which is apparently meant to be >> similiar to >> Oracle's according to the docs. Clusgres does not appear to be >> widely/or at all used, and info on it seems pretty thin on the >> ground, >> so I am >> not too keen on going with that. Is the real solution to multi- >> machine >> partitioning (as in, not like MySQLs MERGE tables) on PostgreSQL >> actually doing it in our application API? This seems like a less >> than >> perfect solution once we want to add redundancy and things into >> the mix. >> > > There is also PGCluster > http://pgfoundry.org/projects/pgcluster/ > > Which is trying to be more of a Synchronous multi-master system. I > haven't heard of Clusgres, so I'm guessing it is an older attempt, > which > has been overtaken by pgcluster. > > Just realize that clusters don't necessarily scale like you would want > them too. Because at some point you have to insert into the same > table, > which means you need to hold a lock which prevents the other machine > from doing anything. And with synchronous replication, you have to > wait > for all of the machines to get a copy of the data before you can > say it > has been committed, which does *not* scale well with the number of > machines. This is why I mention partitioning. It solves this issue by storing different data sets on different machines under the same schema. These seperate chunks of the table can then be replicated as well for data redundancy and so on. MySQL are working on these things, but PG just has a bunch of third party extensions, I wonder why these are not being integrated into the main trunk :/ Thanks for pointing me to PGCluster though. It looks like it should be better than Slony at least. From pgsql-performance-owner@postgresql.org Tue May 10 12:24:32 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DA02D5407A for ; Tue, 10 May 2005 12:24:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58930-08 for ; Tue, 10 May 2005 15:24:26 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id 1925F54072 for ; Tue, 10 May 2005 12:24:25 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-7.tower-49.messagelabs.com!1115738664!18675407!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 17010 invoked from network); 10 May 2005 15:24:24 -0000 Received: from mail.advfn.com (212.161.99.149) by server-7.tower-49.messagelabs.com with SMTP; 10 May 2005 15:24:24 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DVWat-0000bI-IG; Tue, 10 May 2005 16:24:23 +0100 In-Reply-To: <20050510150226.00E453EFF@flute.newsnipple.com> References: <20050510150226.00E453EFF@flute.newsnipple.com> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Partitioning / Clustering Date: Tue, 10 May 2005 16:24:23 +0100 To: "Adam Haberlach" X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/145 X-Sequence-Number: 12309 On 10 May 2005, at 16:02, Adam Haberlach wrote: > > I think that perhaps he was trying to avoid having to buy "Big > Iron" at all. You would be right. Although we are not against paying a bit more than $300 for a server ;) > With all the Opteron v. Xeon around here, and talk of $30,000 > machines, > perhaps it would be worth exploring the option of buying 10 cheapass > machines for $300 each. At the moment, that $300 buys you, from > Dell, a > 2.5Ghz Pentium 4 w/ 256mb of RAM and a 40Gb hard drive and gigabit > ethernet. > The aggregate CPU and bandwidth is pretty stupendous, but not as > easy to > harness as a single machine. > Yes, clustering solutions can distribute the data, and can even do > it on a > per-table basis in some cases. This still leaves it up to the > application's > logic to handle reunification of the data. If your going to be programming that sort of logic into your API in the beginning, it's not too much more work to add basic replication, load balancing and partitioning into it either. But the DB should be able to do it for you, adding that stuff in later is often more difficult and less likely to get done. > Ideas: > 1. Create a table/storage type that consists of a select statement > on another machine. While I don't think the current executor is > capable of > working on multiple nodes of an execution tree at the same time, it > would be > great if it could offload a select of tuples from a remote table to an > entirely different server and merge the resulting data into the > current > execution. I believe MySQL has this, and Oracle may implement it > in another > way. MySQL sort of has this, it's not as good as Oracle's though. Apparently there is a much better version of it in 5.1 though, that should make it to stable sometime next year I imagine. > 2. There is no #2 at this time, but I'm sure one can be > hypothesized. I would of thought a particularly smart version of pg_pool could do it. It could partition data to different servers if it knew which columns to key by on each table. > ...Google and other companies have definitely proved that one can > harness > huge clusters of cheap hardware. It can't be _that_ hard, can it. :) I shudder to think how much the "Big Iron" equivalent of a google data-center would cost. > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of John A > Meinel > Sent: Tuesday, May 10, 2005 7:41 AM > To: Alex Stapleton > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Partitioning / Clustering > > Alex Stapleton wrote: > >> What is the status of Postgres support for any sort of multi-machine >> scaling support? What are you meant to do once you've upgraded your >> box and tuned the conf files as much as you can? But your query load >> is just too high for a single machine? >> >> Upgrading stock Dell boxes (I know we could be using better machines, >> but I am trying to tackle the real issue) is not a hugely price >> efficient way of getting extra performance, nor particularly scalable >> in the long term. >> > > Switch from Dell Xeon boxes, and go to Opterons. :) Seriously, Dell > is far > away from Big Iron. I don't know what performance you are looking > for, but > you can easily get into inserting 10M rows/day with quality hardware. > > But actually is it your SELECT load that is too high, or your > INSERT load, > or something inbetween. > > Because Slony is around if it is a SELECT problem. > http://gborg.postgresql.org/project/slony1/projdisplay.php > > Basically, Slony is a Master/Slave replication system. So if you > have INSERT > going into the Master, you can have as many replicated slaves, > which can > handle your SELECT load. > Slony is an asynchronous replicator, so there is a time delay from the > INSERT until it will show up on a slave, but that time could be pretty > small. > > This would require some application level support, since an INSERT > goes to a > different place than a SELECT. But there has been some discussion > about > pg_pool being able to spread the query load, and having it be aware > of the > difference between a SELECT and an INSERT and have it route the > query to the > correct host. The biggest problem being that functions could cause > a SELECT > func() to actually insert a row, which pg_pool wouldn't know about. > There > are 2 possible solutions, a) don't do that when you are using this > system, > b) add some sort of comment hint so that pg_pool can understand > that the > select is actually an INSERT, and needs to be done on the master. > > >> >> So, when/is PG meant to be getting a decent partitioning system? >> MySQL is getting one (eventually) which is apparently meant to be >> similiar to Oracle's according to the docs. Clusgres does not appear >> to be widely/or at all used, and info on it seems pretty thin on the >> ground, so I am not too keen on going with that. Is the real solution >> to multi- machine partitioning (as in, not like MySQLs MERGE tables) >> on PostgreSQL actually doing it in our application API? This seems >> like a less than perfect solution once we want to add redundancy and >> things into the mix. >> > > There is also PGCluster > http://pgfoundry.org/projects/pgcluster/ > > Which is trying to be more of a Synchronous multi-master system. I > haven't > heard of Clusgres, so I'm guessing it is an older attempt, which > has been > overtaken by pgcluster. > > Just realize that clusters don't necessarily scale like you would > want them > too. Because at some point you have to insert into the same table, > which > means you need to hold a lock which prevents the other machine from > doing > anything. And with synchronous replication, you have to wait for > all of the > machines to get a copy of the data before you can say it has been > committed, > which does *not* scale well with the number of machines. > > If you can make it work, I think having a powerful master server, > who can > finish an INSERT quickly, and then having a bunch of Slony slaves > with a > middleman (like pg_pool) to do load balancing among them, is the > best way to > scale up. There are still some requirements, like not having to see > the > results of an INSERT instantly (though if you are using hinting to > pg_pool, > you could hint that this query must be done on the master, > realizing that > the more you do it, the more you slow everything down). > > John > =:-> > > PS> I don't know what functionality has been actually implemented in > pg_pool, just that it was discussed in the past. Slony-II is also > in the > works. > > > ---------------------------(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-general-owner@postgresql.org Tue May 10 12:32:57 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 19141540CE; Tue, 10 May 2005 12:32:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60712-10; Tue, 10 May 2005 15:32:49 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 7B6E753A73; Tue, 10 May 2005 12:32:47 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id AC2A9152B4; Tue, 10 May 2005 10:32:45 -0500 (CDT) Date: Tue, 10 May 2005 10:32:45 -0500 From: "Jim C. Nasby" To: Neil Conway Cc: Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL Message-ID: <20050510153245.GA31103@decibel.org> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <427FFCD3.1010803@samurai.com> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/486 X-Sequence-Number: 77834 On Tue, May 10, 2005 at 10:14:11AM +1000, Neil Conway wrote: > Jim C. Nasby wrote: > >> No, hash joins and hash indexes are unrelated. > >I know they are now, but does that have to be the case? > > I mean, the algorithms are fundamentally unrelated. They share a bit of > code such as the hash functions themselves, but they are really solving > two different problems (disk based indexing with (hopefully) good > concurrency and WAL logging vs. in-memory joins via hashing with spill > to disk if needed). Well, in a hash-join right now you normally end up feeding at least one side of the join with a seqscan. Wouldn't it speed things up considerably if you could look up hashes in the hash index instead? That way you can eliminate going to the heap for any hashes that match. Of course, if limited tuple visibility info was added to hash indexes (similar to what I think is currently happening to B-tree's), many of the heap scans could be eliminated as well. A similar method could also be used for hash aggregates, assuming they use the same hash. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-general-owner@postgresql.org Tue May 10 12:39:40 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 65FE753FC5; Tue, 10 May 2005 12:39:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62612-03; Tue, 10 May 2005 15:39:29 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id AE2BD540D5; Tue, 10 May 2005 12:39:28 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 8C3FC152B6; Tue, 10 May 2005 10:39:27 -0500 (CDT) Date: Tue, 10 May 2005 10:39:27 -0500 From: "Jim C. Nasby" To: Tom Lane Cc: Neil Conway , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL Message-ID: <20050510153927.GB31103@decibel.org> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4407.1115698257@sss.pgh.pa.us> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/487 X-Sequence-Number: 77835 On Tue, May 10, 2005 at 12:10:57AM -0400, Tom Lane wrote: > be responsive to your search.) (This also brings up the thought that > it might be interesting to support hash buckets smaller than a page ... > but I don't know how to make that work in an adaptive fashion.) IIRC, other databases that support hash indexes also allow you to define the bucket size, so it might be a good start to allow for that. DBA's usually have a pretty good idea of what a table will look like in production, so if there's clear documentation on the effect of bucket size a good DBA should be able to make a good decision. What's the challange to making it adaptive, comming up with an algorithm that gives you the optimal bucket size (which I would think there's research on...) or allowing the index to accommodate different bucket sizes existing in the index at once? (Presumably you don't want to re-write the entire index every time it looks like a different bucket size would help.) -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue May 10 12:45:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BFE92541FA; Tue, 10 May 2005 12:45:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63435-10; Tue, 10 May 2005 15:45:23 +0000 (GMT) Received: from bos-gate4.raytheon.com (bos-gate4.raytheon.com [199.46.198.233]) by svr1.postgresql.org (Postfix) with ESMTP id 9888D541E4; Tue, 10 May 2005 12:45:21 -0300 (ADT) Received: from ds02e00.directory.ray.com (ds02e00.directory.ray.com [147.25.130.245]) by bos-gate4.raytheon.com (8.12.10/8.12.10) with ESMTP id j4AFj7xG025633; Tue, 10 May 2005 11:45:07 -0400 (EDT) Received: from ds02e00 (localhost [127.0.0.1]) by ds02e00.directory.ray.com (Switch-3.1.7/Switch-3.1.0) with ESMTP id j4AFixN2029831; Tue, 10 May 2005 15:45:00 GMT Received: from ds02e00.directory.ray.com with LMTP by ds02e00 (2.0.6/sieved-2-0-build-559); Tue, 10 May 2005 15:44:58 +0000 Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com [151.168.145.35]) by ds02e00.directory.ray.com (Switch-3.1.7/Switch-3.1.0) with ESMTP id j4AFiSV4029578 sender Richard_D_Levine@raytheon.com; Tue, 10 May 2005 15:44:35 GMT In-Reply-To: <20050510150226.00E453EFF@flute.newsnipple.com> Subject: Re: Partitioning / Clustering To: "Adam Haberlach" Cc: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org X-Mailer: Lotus Notes Release 6.5.2 June 01, 2004 Message-ID: From: Richard_D_Levine@raytheon.com Date: Tue, 10 May 2005 10:43:54 -0500 X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 6.5.2|June 01, 2004) at 05/10/2005 10:44:35 AM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-SPAM: 0.00 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.21 tagged_above=0 required=5 tests=AWL, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200505/148 X-Sequence-Number: 12312 > exploring the option of buying 10 cheapass > machines for $300 each. At the moment, that $300 buys you, from Dell, a > 2.5Ghz Pentium 4 Buy cheaper ass Dells with an AMD 64 3000+. Beats the crap out of the 2.5 GHz Pentium, especially for PostgreSQL. See the thread "Whence the Opterons" for more.... Rick pgsql-performance-owner@postgresql.org wrote on 05/10/2005 10:02:50 AM: > > I think that perhaps he was trying to avoid having to buy "Big Iron" at all. > > With all the Opteron v. Xeon around here, and talk of $30,000 machines, > perhaps it would be worth exploring the option of buying 10 cheapass > machines for $300 each. At the moment, that $300 buys you, from Dell, a > 2.5Ghz Pentium 4 w/ 256mb of RAM and a 40Gb hard drive and gigabit ethernet. > The aggregate CPU and bandwidth is pretty stupendous, but not as easy to > harness as a single machine. > > For those of us looking at batch and data warehousing applications, it would > be really handy to be able to partition databases, tables, and processing > load across banks of cheap hardware. > > Yes, clustering solutions can distribute the data, and can even do it on a > per-table basis in some cases. This still leaves it up to the application's > logic to handle reunification of the data. > > Ideas: > 1. Create a table/storage type that consists of a select statement > on another machine. While I don't think the current executor is capable of > working on multiple nodes of an execution tree at the same time, it would be > great if it could offload a select of tuples from a remote table to an > entirely different server and merge the resulting data into the current > execution. I believe MySQL has this, and Oracle may implement it in another > way. > > 2. There is no #2 at this time, but I'm sure one can be > hypothesized. > > ...Google and other companies have definitely proved that one can harness > huge clusters of cheap hardware. It can't be _that_ hard, can it. :) > > > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of John A Meinel > Sent: Tuesday, May 10, 2005 7:41 AM > To: Alex Stapleton > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Partitioning / Clustering > > Alex Stapleton wrote: > > What is the status of Postgres support for any sort of multi-machine > > scaling support? What are you meant to do once you've upgraded your > > box and tuned the conf files as much as you can? But your query load > > is just too high for a single machine? > > > > Upgrading stock Dell boxes (I know we could be using better machines, > > but I am trying to tackle the real issue) is not a hugely price > > efficient way of getting extra performance, nor particularly scalable > > in the long term. > > Switch from Dell Xeon boxes, and go to Opterons. :) Seriously, Dell is far > away from Big Iron. I don't know what performance you are looking for, but > you can easily get into inserting 10M rows/day with quality hardware. > > But actually is it your SELECT load that is too high, or your INSERT load, > or something inbetween. > > Because Slony is around if it is a SELECT problem. > http://gborg.postgresql.org/project/slony1/projdisplay.php > > Basically, Slony is a Master/Slave replication system. So if you have INSERT > going into the Master, you can have as many replicated slaves, which can > handle your SELECT load. > Slony is an asynchronous replicator, so there is a time delay from the > INSERT until it will show up on a slave, but that time could be pretty > small. > > This would require some application level support, since an INSERT goes to a > different place than a SELECT. But there has been some discussion about > pg_pool being able to spread the query load, and having it be aware of the > difference between a SELECT and an INSERT and have it route the query to the > correct host. The biggest problem being that functions could cause a SELECT > func() to actually insert a row, which pg_pool wouldn't know about. There > are 2 possible solutions, a) don't do that when you are using this system, > b) add some sort of comment hint so that pg_pool can understand that the > select is actually an INSERT, and needs to be done on the master. > > > > > So, when/is PG meant to be getting a decent partitioning system? > > MySQL is getting one (eventually) which is apparently meant to be > > similiar to Oracle's according to the docs. Clusgres does not appear > > to be widely/or at all used, and info on it seems pretty thin on the > > ground, so I am not too keen on going with that. Is the real solution > > to multi- machine partitioning (as in, not like MySQLs MERGE tables) > > on PostgreSQL actually doing it in our application API? This seems > > like a less than perfect solution once we want to add redundancy and > > things into the mix. > > There is also PGCluster > http://pgfoundry.org/projects/pgcluster/ > > Which is trying to be more of a Synchronous multi-master system. I haven't > heard of Clusgres, so I'm guessing it is an older attempt, which has been > overtaken by pgcluster. > > Just realize that clusters don't necessarily scale like you would want them > too. Because at some point you have to insert into the same table, which > means you need to hold a lock which prevents the other machine from doing > anything. And with synchronous replication, you have to wait for all of the > machines to get a copy of the data before you can say it has been committed, > which does *not* scale well with the number of machines. > > If you can make it work, I think having a powerful master server, who can > finish an INSERT quickly, and then having a bunch of Slony slaves with a > middleman (like pg_pool) to do load balancing among them, is the best way to > scale up. There are still some requirements, like not having to see the > results of an INSERT instantly (though if you are using hinting to pg_pool, > you could hint that this query must be done on the master, realizing that > the more you do it, the more you slow everything down). > > John > =:-> > > PS> I don't know what functionality has been actually implemented in > pg_pool, just that it was discussed in the past. Slony-II is also in the > works. > > > ---------------------------(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 May 10 12:47:21 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5FA1E541FA for ; Tue, 10 May 2005 12:47:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63757-09 for ; Tue, 10 May 2005 15:47:10 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 9C114541E8 for ; Tue, 10 May 2005 12:47:08 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4AFl6fJ025879; (envelope-from ) Tue, 10 May 2005 10:47:06 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4AFl2EV024298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 10 May 2005 10:47:06 -0500 (CDT) Message-ID: <4280D76E.3090209@arbash-meinel.com> Date: Tue, 10 May 2005 10:46:54 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Adam Haberlach Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <20050510150226.00E453EFF@flute.newsnipple.com> In-Reply-To: <20050510150226.00E453EFF@flute.newsnipple.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig16E3B799C81975E6D9B4F034" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/149 X-Sequence-Number: 12313 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig16E3B799C81975E6D9B4F034 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Adam Haberlach wrote: > I think that perhaps he was trying to avoid having to buy "Big Iron" at all. > > With all the Opteron v. Xeon around here, and talk of $30,000 machines, > perhaps it would be worth exploring the option of buying 10 cheapass > machines for $300 each. At the moment, that $300 buys you, from Dell, a > 2.5Ghz Pentium 4 w/ 256mb of RAM and a 40Gb hard drive and gigabit ethernet. > The aggregate CPU and bandwidth is pretty stupendous, but not as easy to > harness as a single machine. > > For those of us looking at batch and data warehousing applications, it would > be really handy to be able to partition databases, tables, and processing > load across banks of cheap hardware. > > Yes, clustering solutions can distribute the data, and can even do it on a > per-table basis in some cases. This still leaves it up to the application's > logic to handle reunification of the data. Sure. A lot of this is application dependent, though. For instance foreign key constraints. In a general cluster solution, you would allow foreign keys across partitions. I have a feeling this would be extra slow, and hard to do correctly. Multi-machine transactions are also a difficulty, since WAL now has to take into account all machines, and you have to wait for fsync on all of them. I'm not sure how Oracle does it, but these things seem like they prevent clustering from really scaling very well. > > Ideas: > 1. Create a table/storage type that consists of a select statement > on another machine. While I don't think the current executor is capable of > working on multiple nodes of an execution tree at the same time, it would be > great if it could offload a select of tuples from a remote table to an > entirely different server and merge the resulting data into the current > execution. I believe MySQL has this, and Oracle may implement it in another > way. > > 2. There is no #2 at this time, but I'm sure one can be > hypothesized. > > ...Google and other companies have definitely proved that one can harness > huge clusters of cheap hardware. It can't be _that_ hard, can it. :) Again, it depends on the application. A generic database with lots of cross reference integrity checking does not work on a cluster very well. A very distributed db where you don't worry about cross references does scale. Google made a point of making their application work in a distributed manner. In the other post he mentions that pg_pool could naturally split out the rows into different machines based on partitioning, etc. I would argue that it is more of a custom pool daemon based on the overall application. Because you have to start dealing with things like cross-machine joins. Who handles that? the pool daemon has to, since it is the only thing that talks to both tables. I think you could certainly write a reasonably simple application specific daemon where all of the clients send their queries to, and it figures out where they need to go, and aggregates them as necessary. But a fully generic one is *not* simple at all, and I think is far out of the scope of something like pg_pool. I'm guessing that PGCluster is looking at working on that, and it might be true that pg_pool is thinking about it. But just thinking about the very simple query: SELECT row1, row2 FROM table1_on_machine_a NATURAL JOIN table2_on_machine_b WHERE restrict_table_1 AND restrict_table_2 AND restrict_1_based_on_2; This needs to be broken into something like: SELECT row1 FROM table1_on_machine_a WHERE restrict_table_1 ORDER BY join_column; SELECT row2 FROM table2_on_machine_b WHERE restrict_table_2 ORDER BY join_column; Then these rows need to be merge_joined, and the restrict_1_based_on_2 needs to be applied. This is in no way trivial, and I think it is outside the scope of pg_pool. Now maybe if you restrict yourself so that each query stays within one machine you can make it work. Or write your own app to handle some of this transparently for the clients. But I would expect to make the problem feasible, it would not be a generic solution. Maybe I'm off base, I don't really keep track of pg_pool/PGCluster/etc. But I can see that the problem is very difficult. Not at the very least, this is a simple query. And it doesn't even do optimizations. You might actually prefer the above to be done with a Nestloop style, where table_1 is selected, and then for each row you do a single index select on table_2. But how is your app going to know that? It has to have the statistics from the backend databases. And if it has to place an extra query to get those statistics, you just hurt your scalability even more. Whereas big-iron already has all the statistics, and can optimize the query plan. Perhaps pg_cluster will handle this, by maintaining full statistics across the cluster on each machine, so that more optimal queries can be performed. I don't really know. John =:-> --------------enig16E3B799C81975E6D9B4F034 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCgNd1JdeBCYSNAAMRAh4wAKCQ7MKHlM/DojbGapkhP4EQNfXziQCg028j ofzXk6pjacA7SvQqKJ3g1A0= =XU9d -----END PGP SIGNATURE----- --------------enig16E3B799C81975E6D9B4F034-- From pgsql-general-owner@postgresql.org Tue May 10 12:50:08 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 00D83540E4 for ; Tue, 10 May 2005 12:50:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63938-09 for ; Tue, 10 May 2005 15:49:58 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id C77795406A for ; Tue, 10 May 2005 12:49:56 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4AFno15000595; Tue, 10 May 2005 11:49:50 -0400 (EDT) To: "Jim C. Nasby" Cc: Neil Conway , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <20050510153927.GB31103@decibel.org> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <20050510153927.GB31103@decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Tue, 10 May 2005 10:39:27 -0500" Date: Tue, 10 May 2005 11:49:50 -0400 Message-ID: <594.1115740190@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/489 X-Sequence-Number: 77837 "Jim C. Nasby" writes: > What's the challange to making it adaptive, comming up with an algorithm > that gives you the optimal bucket size (which I would think there's > research on...) or allowing the index to accommodate different bucket > sizes existing in the index at once? (Presumably you don't want to > re-write the entire index every time it looks like a different bucket > size would help.) Exactly. That's (a) expensive and (b) really hard to fit into the WAL paradigm --- I think we could only handle it as a REINDEX. So if it were adaptive at all I think we'd have to support multiple bucket sizes existing simultaneously in the index, and I do not see a good way to do that. Allowing a bucket size to be specified at CREATE INDEX doesn't seem out of line though. We'd have to think up a scheme for index-AM-specific index parameters ... regards, tom lane From pgsql-general-owner@postgresql.org Tue May 10 14:26:56 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3FE11542F5; Tue, 10 May 2005 14:26:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24177-02; Tue, 10 May 2005 17:26:53 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 825E6542F1; Tue, 10 May 2005 14:26:52 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id D94BB154BE; Tue, 10 May 2005 12:26:52 -0500 (CDT) Date: Tue, 10 May 2005 12:26:52 -0500 From: "Jim C. Nasby" To: Tom Lane Cc: Neil Conway , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL Message-ID: <20050510172652.GF31103@decibel.org> References: <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <20050510153927.GB31103@decibel.org> <594.1115740190@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <594.1115740190@sss.pgh.pa.us> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/496 X-Sequence-Number: 77844 On Tue, May 10, 2005 at 11:49:50AM -0400, Tom Lane wrote: > "Jim C. Nasby" writes: > > What's the challange to making it adaptive, comming up with an algorithm > > that gives you the optimal bucket size (which I would think there's > > research on...) or allowing the index to accommodate different bucket > > sizes existing in the index at once? (Presumably you don't want to > > re-write the entire index every time it looks like a different bucket > > size would help.) > > Exactly. That's (a) expensive and (b) really hard to fit into the WAL > paradigm --- I think we could only handle it as a REINDEX. So if it > were adaptive at all I think we'd have to support multiple bucket sizes > existing simultaneously in the index, and I do not see a good way to do > that. I'm not really familiar enough with hash indexes to know if this would work, but if the maximum bucket size was known you could use that to determine a maximum range of buckets to look at. In some cases, that range would include only one bucket, otherwise it would be a set of buckets. If you found a set of buckets, I think you could then just go to the specific one you need. If we assume that the maximum bucket size is one page it becomes more realistic to take an existing large bucket and split it into several smaller ones. This could be done on an update to the index page, or a background process could handle it. In any case, should this go on the TODO list? > Allowing a bucket size to be specified at CREATE INDEX doesn't seem out > of line though. We'd have to think up a scheme for index-AM-specific > index parameters ... -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue May 10 14:31:35 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C1A0D542F3 for ; Tue, 10 May 2005 14:31:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23340-05 for ; Tue, 10 May 2005 17:31:25 +0000 (GMT) Received: from boutiquenumerique.com (unknown [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 79F23540DA for ; Tue, 10 May 2005 14:31:21 -0300 (ADT) Received: (qmail 10820 invoked from network); 10 May 2005 19:30:22 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 10 May 2005 19:30:22 +0200 To: "John A Meinel" , "Adam Haberlach" Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <20050510150226.00E453EFF@flute.newsnipple.com> <4280D76E.3090209@arbash-meinel.com> Message-ID: Date: Tue, 10 May 2005 19:29:59 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <4280D76E.3090209@arbash-meinel.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/152 X-Sequence-Number: 12316 > SELECT row1, row2 FROM table1_on_machine_a NATURAL JOIN > table2_on_machine_b > WHERE restrict_table_1 AND restrict_table_2 > AND restrict_1_based_on_2; I don't think that's ever going to be efficient... What would be efficient would be, for instance, a Join of a part of a table against another part of another table which both happen to be on the same machine, because the partitioning was done with this in mind (ie. for instance partitioning on client_id and keeping the information for each client on the same machine). You could build your smart pool daemon in pl/pgsql and use dblink ! At least you have the query parser built-in. I wonder how Oracle does it ;) From pgsql-general-owner@postgresql.org Tue May 10 14:36:21 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3AD62542F1; Tue, 10 May 2005 14:36:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24391-06; Tue, 10 May 2005 17:36:11 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 3E0CB5422E; Tue, 10 May 2005 14:36:10 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DVYeG-00012d-00; Tue, 10 May 2005 13:36:00 -0400 To: Tom Lane Cc: Greg Stark , Neil Conway , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> <9871.1115733198@sss.pgh.pa.us> In-Reply-To: <9871.1115733198@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 10 May 2005 13:35:59 -0400 Message-ID: <87wtq7q8zk.fsf@stark.xeocode.com> Lines: 21 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/497 X-Sequence-Number: 77845 Tom Lane writes: > > What if the hash index stored *only* the hash code? That could be useful for > > indexing large datatypes that would otherwise create large indexes. > > Hmm, that could be a thought. Hm, if you go this route of having hash indexes store tuples ordered by hash code and storing the hash code in the index, then it seems hash indexes become just a macro for a btree index of HASH(index columns). I'm not saying that to criticize this plan. In fact I think that captures most (though not all) of what a hash index should be. It would be pretty useful. In fact if it isn't how hash indexes are implemented then it might be useful to provide a user visible hash(ROW) function that allows creating such indexes as functional indexes. Though hiding it would make the SQL simpler. -- greg From pgsql-performance-owner@postgresql.org Tue May 10 14:46:35 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E0F105445B for ; Tue, 10 May 2005 14:46:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25181-08 for ; Tue, 10 May 2005 17:46:24 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 10E5454326 for ; Tue, 10 May 2005 14:46:23 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7345177 for pgsql-performance@postgresql.org; Tue, 10 May 2005 10:48:24 -0700 From: Josh Berkus Organization: Aglio Database Solutions Subject: Re: Partitioning / Clustering Date: Tue, 10 May 2005 10:46:24 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline To: Undisclosed.Recipients: ; Message-Id: <200505101046.25108.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/154 X-Sequence-Number: 12318 Alex, > This is why I mention partitioning. It solves this issue by storing =A0 > different data sets on different machines under the same schema. =A0 That's clustering, actually. Partitioning is simply dividing up a table in= to=20 chunks and using the chunks intelligently. Putting those chunks on sepera= te=20 machines is another thing entirely. =20 We're working on partitioning through the Bizgres sub-project: www.bizgres.org / http://pgfoundry.org/projects/bizgres/ =2E.. and will be pushing it to the main PostgreSQL when we have something. I invite you to join the mailing list. > These seperate chunks of the table can then be replicated as well for =A0 > data redundancy and so on. MySQL are working on these things,=20 Don't hold your breath. MySQL, to judge by their first "clustering"=20 implementation, has a *long* way to go before they have anything usable. I= n=20 fact, at OSCON their engineers were asking Jan Wieck for advice. If you have $$$ to shell out, my employer (GreenPlum) has a multi-machine=20 distributed version of PostgreSQL. It's proprietary, though. =20 www.greenplum.com. If you have more time than money, I understand that Stanford is working on= =20 this problem: http://www-db.stanford.edu/~bawa/ But, overall, some people on this list are very mistaken in thinking it's a= n=20 easy problem. GP has devoted something like 5 engineers for 3 years to=20 develop their system. Oracle spent over $100 million to develop RAC. =20 > but PG =A0=20 > just has a bunch of third party extensions, I wonder why these are =A0 > not being integrated into the main trunk :/=20 Because it represents a host of complex functionality which is not applicab= le=20 to most users? Because there are 4 types of replication and 3 kinds of=20 clusering and not all users want the same kind? =2D-=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-general-owner@postgresql.org Tue May 10 15:07:11 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B43C354469 for ; Tue, 10 May 2005 15:07:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30677-04 for ; Tue, 10 May 2005 18:07:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4B8D0542BE for ; Tue, 10 May 2005 15:07:04 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4AI70Ep020885; Tue, 10 May 2005 14:07:00 -0400 (EDT) To: "Jim C. Nasby" Cc: Neil Conway , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <20050510153245.GA31103@decibel.org> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <20050510153245.GA31103@decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Tue, 10 May 2005 10:32:45 -0500" Date: Tue, 10 May 2005 14:07:00 -0400 Message-ID: <20884.1115748420@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/498 X-Sequence-Number: 77846 "Jim C. Nasby" writes: > Well, in a hash-join right now you normally end up feeding at least one > side of the join with a seqscan. Wouldn't it speed things up > considerably if you could look up hashes in the hash index instead? That's called a "nestloop with inner index scan", not a hash join. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 10 15:12:55 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 799D35445E for ; Tue, 10 May 2005 15:12:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30714-06 for ; Tue, 10 May 2005 18:12:46 +0000 (GMT) Received: from priv-edtnes46.telusplanet.net (defout.telus.net [199.185.220.240]) by svr1.postgresql.org (Postfix) with ESMTP id 130DD54314 for ; Tue, 10 May 2005 15:12:45 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes46.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050510181245.JWFY7617.priv-edtnes46.telusplanet.net@localhost> for ; Tue, 10 May 2005 12:12:45 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 11:12:45 -0700 Message-ID: <1115748765.4280f99d52dd5@webmail.telus.net> Date: Tue, 10 May 2005 11:12:45 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: [GENERAL] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <20050510153927.GB31103@decibel.org> <594.1115740190@sss.pgh.pa.us> <20050510172652.GF31103@decibel.org> In-Reply-To: <20050510172652.GF31103@decibel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.06 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/156 X-Sequence-Number: 12320 Quoting "Jim C. Nasby" : > I'm not really familiar enough with hash indexes to know if this > would > work, but if the maximum bucket size was known you could use that to > determine a maximum range of buckets to look at. In some cases, that > range would include only one bucket, otherwise it would be a set of > buckets. If you found a set of buckets, I think you could then just > go > to the specific one you need. > > If we assume that the maximum bucket size is one page it becomes > more > realistic to take an existing large bucket and split it into several > smaller ones. This could be done on an update to the index page, or > a > background process could handle it. > > In any case, should this go on the TODO list? > > > Allowing a bucket size to be specified at CREATE INDEX doesn't seem > out > > of line though. We'd have to think up a scheme for > index-AM-specific > > index parameters ... > -- > Jim C. Nasby, Database Consultant decibel@decibel.org > Give your computer some brain candy! www.distributed.net Team #1828 Google "dynamic hash" or "linear hash". It takes care of not needing to have varying bucket sizes. Hash indexes are useful if you ALWAYS require disk access; they behave like worst-case random cache-thrash tests. That's probably why dbs have gravitated toward tree indexes instead. On the other hand, there's more (good) to hashing than initially meets the eye. Dynamic multiway hashing has come a long way from just splicing the bits together from multiple columns' hash values. If you can lay your hands on Tim Merrett's old text "Relational Information Systems", it's an eye-opener. Picture an efficient terabyte spreadsheet. For one thing, unlike a btree, a multicolumn hash is symmetric: it doesn't matter which column(s) you do not specify in a partial match. For another, a multiway hash is useful for much lower selectivity than a btree. I built such indexes for OLAP cubes, and some dimensions were only 10 elements wide. At the point where btree indexing becomes worse than seqscan, a multiway hash tells you which 10% of the disk to scan. From pgsql-performance-owner@postgresql.org Tue May 10 15:13:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EE2785446A for ; Tue, 10 May 2005 15:13:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32175-01 for ; Tue, 10 May 2005 18:13:19 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 9A916538E0 for ; Tue, 10 May 2005 15:13:18 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DVZEF-0001HV-00; Tue, 10 May 2005 14:13:11 -0400 To: molson@oceanconsulting.com Cc: pgsql-performance@postgresql.org Subject: Re: Prefetch References: <200505100652.51401.molson@oceanconsulting.com> In-Reply-To: <200505100652.51401.molson@oceanconsulting.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 10 May 2005 14:13:11 -0400 Message-ID: <87r7gfq79k.fsf@stark.xeocode.com> Lines: 34 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/157 X-Sequence-Number: 12321 Matt Olson writes: > I've done other things that make sense, like using indexes, playing with the > planner constants and turning up the postgres cache buffers. > > Even playing with extream hdparm read-ahead numbers (i.e. 64738) yields no > apparent difference in database performance. The random nature of the I/O > drops disk reads down to about 1MB/sec for the array. A linear table scan > can easily yield 70-80MB/sec on this system. Total table size is usually > around 1GB and with indexes should be able to fit completely in main memory. Actually forcing things to use indexes is the wrong direction to go if you're trying to process lots of data and want to stream it off disk as rapidly as possible. I would think about whether you can structure your data such that you can use sequential scans. That might mean partitioning your raw data into separate tables and then accessing only the partitions that are relevant to the query. In your application that might be hard. It sounds like you would need more or less one table per stock ticker which would really be hard to manage. One thing you might look into is using the CLUSTER command. But postgres doesn't maintain the cluster ordering so it would require periodically rerunning it. I'm a bit surprised by your 1MB/s rate. I would expect to see about 10MB/s even for completely random reads. Is it possible you're seeing something else interfering? Do you have INSERT/UPDATE/DELETE transactions happening concurrently with this select scan? If so you should strongly look into separating the transaction log from the data files. -- greg From pgsql-performance-owner@postgresql.org Tue May 10 15:28:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 290325341D for ; Tue, 10 May 2005 15:28:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33164-08 for ; Tue, 10 May 2005 18:28:09 +0000 (GMT) Received: from mout.perfora.net (mout.perfora.net [217.160.230.41]) by svr1.postgresql.org (Postfix) with ESMTP id 9E76D54317 for ; Tue, 10 May 2005 15:28:06 -0300 (ADT) Received: from config9.kundenserver.de[172.23.4.136] (helo=togal2.1and1.com) by mrelay.perfora.net with ESMTP (Nemesis), id 0MKyxe-1DVZSc2SM6-0007Nl; Tue, 10 May 2005 14:28:02 -0400 To: Subject: =?iso-8859-1?Q?RE:__Partitioning_/_Clustering?= From: Cc: X-Binford: 6100 (more power) X-Originating-From: 28173515 X-Mailer: Webmail X-Received: from config9 by 68.162.219.184 with HTTP id 28173515 for alexs@advfn.com; Tue, 10 May 2005 20:26:02 +0200 Content-Type: text/plain; charset="iso-8859-1" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Priority: 3 Date: Tue, 10 May 2005 20:26:02 +0200 Message-ID: <0MKyxe-1DVZSc2SM6-0007Nl@mrelay.perfora.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.178 tagged_above=0 required=5 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200505/158 X-Sequence-Number: 12322 Hi Alex, Actually, our product can partition data among several clustered nodes running PostgreSQL, if that is what you are looking for. Data is distributed based on a designated column. Other tables can be replicated to all nodes. For SELECTs, it also knows when it can join locally or it needs to ship rows as part of the query plan. For FK constraints (discussed here), it also knows when it can enforce them locally or not. Please let me know if you would like some more information. Regards, Tom Drayton ExtenDB http://www.extendb.com > This is why I mention partitioning. It solves this issue by storing > different data sets on different machines under the same schema. > These seperate chunks of the table can then be replicated as > well for > data redundancy and so on. MySQL are working on these things, but PG > just has a bunch of third party extensions, I wonder why these are > not being integrated into the main trunk :/ Thanks for > pointing me to > PGCluster though. It looks like it should be better than > Slony at least. > From pgsql-performance-owner@postgresql.org Tue May 10 15:36:54 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E18C54036 for ; Tue, 10 May 2005 15:36:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40806-01 for ; Tue, 10 May 2005 18:36:50 +0000 (GMT) Received: from atlantis.oceanconsulting.com (smtp.oceanconsulting.com [216.65.145.145]) by svr1.postgresql.org (Postfix) with ESMTP id 7FA6B5388C for ; Tue, 10 May 2005 15:36:47 -0300 (ADT) Received: from seti.kavi.com (seti.kavi.com [64.242.113.166]) (authenticated bits=0) by atlantis.oceanconsulting.com (8.13.1/8.13.1) with ESMTP id j4AIYKXM018750 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Tue, 10 May 2005 11:34:21 -0700 From: Matt Olson Reply-To: molson@oceanconsulting.com Organization: Ocean Consulting To: Greg Stark Subject: Re: Prefetch Date: Tue, 10 May 2005 11:36:31 -0700 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <200505100652.51401.molson@oceanconsulting.com> <87r7gfq79k.fsf@stark.xeocode.com> In-Reply-To: <87r7gfq79k.fsf@stark.xeocode.com> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200505101136.31759.molson@oceanconsulting.com> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/159 X-Sequence-Number: 12323 My postgres binaries and WAL are on a separate disk from the raid array. The table I'm doing the selects from is probably about 4GB in size and 18-20 million records. No concurrent or dependent inserts or deletes are going on. Tom's point and your points about optimizing the application are well taken. I know my approach is sub optimal and prone to getting caught by latency issues (seek times, cache hit rates, etc.). However, the question of prefetch in my mind is all about eliminating latencies, so, I thought my problem would be good for the sake of discussing prefetching. The two approaches I'm in the process of testing are Rod and Greg's suggestion of using 'CLUSTER'. And for the sake of not letting a good idea get away, I'll probably spend time on doing a parallel query approach which Tom suggested. I'll report back to the list what I find and maybe do some _rough_ benchmarking. This is a production app, so I can't get too much in the way of the daily batches. -- Matt Olson Ocean Consulting http://www.oceanconsulting.com/ On Tuesday 10 May 2005 11:13 am, Greg Stark wrote: > Matt Olson writes: > > I've done other things that make sense, like using indexes, playing with > > the planner constants and turning up the postgres cache buffers. > > > > Even playing with extream hdparm read-ahead numbers (i.e. 64738) yields > > no apparent difference in database performance. The random nature of the > > I/O drops disk reads down to about 1MB/sec for the array. A linear table > > scan can easily yield 70-80MB/sec on this system. Total table size is > > usually around 1GB and with indexes should be able to fit completely in > > main memory. > > Actually forcing things to use indexes is the wrong direction to go if > you're trying to process lots of data and want to stream it off disk as > rapidly as possible. I would think about whether you can structure your > data such that you can use sequential scans. That might mean partitioning > your raw data into separate tables and then accessing only the partitions > that are relevant to the query. > > In your application that might be hard. It sounds like you would need more > or less one table per stock ticker which would really be hard to manage. > > One thing you might look into is using the CLUSTER command. But postgres > doesn't maintain the cluster ordering so it would require periodically > rerunning it. > > I'm a bit surprised by your 1MB/s rate. I would expect to see about 10MB/s > even for completely random reads. Is it possible you're seeing something > else interfering? Do you have INSERT/UPDATE/DELETE transactions happening > concurrently with this select scan? If so you should strongly look into > separating the transaction log from the data files. From pgsql-performance-owner@postgresql.org Tue May 10 15:54:10 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4FF3D54208 for ; Tue, 10 May 2005 15:54:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43382-03 for ; Tue, 10 May 2005 18:54:07 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3A4DC540AF for ; Tue, 10 May 2005 15:54:06 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4AIrwae023019; Tue, 10 May 2005 14:53:58 -0400 (EDT) To: Greg Stark Cc: molson@oceanconsulting.com, pgsql-performance@postgresql.org Subject: Re: Prefetch In-reply-to: <87r7gfq79k.fsf@stark.xeocode.com> References: <200505100652.51401.molson@oceanconsulting.com> <87r7gfq79k.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "10 May 2005 14:13:11 -0400" Date: Tue, 10 May 2005 14:53:58 -0400 Message-ID: <23018.1115751238@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/160 X-Sequence-Number: 12324 Greg Stark writes: > Actually forcing things to use indexes is the wrong direction to go if you're > trying to process lots of data and want to stream it off disk as rapidly as > possible. I would think about whether you can structure your data such that > you can use sequential scans. Agreed. > In your application that might be hard. It sounds like you would need more or > less one table per stock ticker which would really be hard to manage. Actually, in a previous lifetime I used to do pretty much the same stuff Matt is working on. The reason I suggested parallelizing is that what you want is usually not so much the 200day moving average of FOO, as the 200day moving averages of a whole bunch of things. If your input table contains time-ordered data for all those things, then a seqscan works out pretty well. > One thing you might look into is using the CLUSTER command. But postgres > doesn't maintain the cluster ordering so it would require periodically > rerunning it. If the desired sort order is time-based, it falls out pretty much for free in this application, because historical data doesn't change -- you are only interested in appending at the right. In said previous lifetime, we used Postgres for tracking our actual transactions, but we built a custom file format for storing the individual tick data. That's not stuff you need transactional semantics for; the historical data is what it is. Besides, you need to compress it as much as you can because there's always too much of it. Machines are faster and disk space cheaper than they were at the time, but I'd still question the wisdom of using a Postgres row for each daily bar, let alone finer-grain data. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 10 16:17:47 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 80C7A53623 for ; Tue, 10 May 2005 16:17:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45517-07 for ; Tue, 10 May 2005 19:17:35 +0000 (GMT) Received: from imail01.arbinet.com (imail.arbinet.com [64.74.47.121]) by svr1.postgresql.org (Postfix) with ESMTP id 6774C53363 for ; Tue, 10 May 2005 16:17:34 -0300 (ADT) Received: from imail01.arbinet.com (localhost [127.0.0.1]) by imail01.arbinet.com (8.12.10/8.12.2) with ESMTP id j4AJHUAI014831 for ; Tue, 10 May 2005 19:17:33 GMT Received: from vamail01.TheXchange.com (mailbox.arbinet.com [64.74.47.120]) by imail01.arbinet.com (8.12.2/8.12.2) with SMTP id j4AJHUvv014825; Tue, 10 May 2005 19:17:30 GMT content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Subject: Prefetch - OffTopic Date: Tue, 10 May 2005 19:17:07 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Prefetch - OffTopic Thread-Index: AcVVkfQ7aaxTfztVSHKyMxzvYtd6JgAApfxQ From: "Mohan, Ross" To: X-Spam-Details: Hits=-104.9, Required=2, Tests=BAYES_00,USER_IN_WHITELIST X-Scanned-By: MIMEDefang 2.39 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.115 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/161 X-Sequence-Number: 12325 for time-series and "insane fast", nothing beats kdB, I believe www.kx.com Not trying to Quisling-out PG here, just hoping to respond to Mr. = Olson.... -----Original Message----- From: pgsql-performance-owner@postgresql.org = [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tom Lane Sent: Tuesday, May 10, 2005 2:54 PM To: Greg Stark Cc: molson@oceanconsulting.com; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Prefetch=20 Greg Stark writes: > Actually forcing things to use indexes is the wrong direction to go if = > you're trying to process lots of data and want to stream it off disk=20 > as rapidly as possible. I would think about whether you can structure=20 > your data such that you can use sequential scans. Agreed. > In your application that might be hard. It sounds like you would need=20 > more or less one table per stock ticker which would really be hard to=20 > manage. Actually, in a previous lifetime I used to do pretty much the same stuff = Matt is working on. The reason I suggested parallelizing is that what = you want is usually not so much the 200day moving average of FOO, as the = 200day moving averages of a whole bunch of things. If your input table = contains time-ordered data for all those things, then a seqscan works = out pretty well. > One thing you might look into is using the CLUSTER command. But=20 > postgres doesn't maintain the cluster ordering so it would require=20 > periodically rerunning it. If the desired sort order is time-based, it falls out pretty much for = free in this application, because historical data doesn't change -- you = are only interested in appending at the right. In said previous lifetime, we used Postgres for tracking our actual = transactions, but we built a custom file format for storing the = individual tick data. That's not stuff you need transactional semantics = for; the historical data is what it is. Besides, you need to compress = it as much as you can because there's always too much of it. Machines = are faster and disk space cheaper than they were at the time, but I'd = still question the wisdom of using a Postgres row for each daily bar, = let alone finer-grain data. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings From pgsql-general-owner@postgresql.org Tue May 10 16:50:27 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E5B73541EE; Tue, 10 May 2005 16:50:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52828-01; Tue, 10 May 2005 19:50:24 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 252E7538C9; Tue, 10 May 2005 16:50:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4AJo57t025691; Tue, 10 May 2005 15:50:05 -0400 (EDT) To: Greg Stark Cc: Neil Conway , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <87wtq7q8zk.fsf@stark.xeocode.com> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> <9871.1115733198@sss.pgh.pa.us> <87wtq7q8zk.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "10 May 2005 13:35:59 -0400" Date: Tue, 10 May 2005 15:50:05 -0400 Message-ID: <25690.1115754605@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/504 X-Sequence-Number: 77852 Greg Stark writes: >>> What if the hash index stored *only* the hash code? That could be useful for >>> indexing large datatypes that would otherwise create large indexes. >> >> Hmm, that could be a thought. > Hm, if you go this route of having hash indexes store tuples ordered by hash > code and storing the hash code in the index, then it seems hash indexes become > just a macro for a btree index of HASH(index columns). No, not at all, because searching such an index will require a tree descent, thus negating the one true advantage of hash indexes. I see the potential value of sorting by hashcode within an individual page, but that doesn't mean we should do the same across the whole index. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 10 18:04:19 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 497E35443B for ; Tue, 10 May 2005 18:04:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65951-06 for ; Tue, 10 May 2005 21:04:05 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1872254428 for ; Tue, 10 May 2005 18:04:02 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id BAFFF30953; Tue, 10 May 2005 23:01:49 +0200 (MET DST) From: Chris Browne X-Newsgroups: pgsql.performance Subject: Re: Prefetch - OffTopic Date: Tue, 10 May 2005 16:14:05 -0400 Organization: cbbrowne Computing Inc Lines: 16 Message-ID: <607ji6vnxu.fsf@dba2.int.libertyrms.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:CuwOYA/Ccny8gmv0TAmGhjCclTk= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.153 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/164 X-Sequence-Number: 12328 RMohan@arbinet.com ("Mohan, Ross") writes: > for time-series and "insane fast", nothing beats kdB, I believe > > www.kx.com ... Which is well and fine if you're prepared to require that all of the staff that interact with data are skilled APL hackers. Skilled enough that they're all ready to leap into Whitney's ASCII-based variant, K. -- (format nil "~S@~S" "cbbrowne" "acm.org") http://www.ntlug.org/~cbbrowne/functional.html Rules of the Evil Overlord #78. "I will not tell my Legions of Terror "And he must be taken alive!" The command will be: ``And try to take him alive if it is reasonably practical.''" From pgsql-performance-owner@postgresql.org Tue May 10 17:49:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A173054428 for ; Tue, 10 May 2005 17:49:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63962-04 for ; Tue, 10 May 2005 20:49:08 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 7A2D95424A for ; Tue, 10 May 2005 17:49:06 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050510204905.JYJE5058.priv-edtnes56.telusplanet.net@localhost> for ; Tue, 10 May 2005 14:49:05 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 13:49:05 -0700 Message-ID: <1115758145.42811e41a1765@webmail.telus.net> Date: Tue, 10 May 2005 13:49:05 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.061 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/163 X-Sequence-Number: 12327 Quoting Richard_D_Levine@raytheon.com: > > exploring the option of buying 10 cheapass > > machines for $300 each. At the moment, that $300 buys you, from > Dell, a > > 2.5Ghz Pentium 4 > > Buy cheaper ass Dells with an AMD 64 3000+. Beats the crap out of > the 2.5 > GHz Pentium, especially for PostgreSQL. Whence "Dells with an AMD 64" ?? Perhaps you skimmed: http://www.thestreet.com/tech/kcswanson/10150604.html or http://www.eweek.com/article2/0,1759,1553822,00.asp From pgsql-performance-owner@postgresql.org Tue May 10 18:29:46 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2319053C54 for ; Tue, 10 May 2005 18:29:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69242-06 for ; Tue, 10 May 2005 21:29:36 +0000 (GMT) Received: from imail01.arbinet.com (imail.arbinet.com [64.74.47.121]) by svr1.postgresql.org (Postfix) with ESMTP id B267453C73 for ; Tue, 10 May 2005 18:29:34 -0300 (ADT) Received: from imail01.arbinet.com (localhost [127.0.0.1]) by imail01.arbinet.com (8.12.10/8.12.2) with ESMTP id j4ALTXAI022489 for ; Tue, 10 May 2005 21:29:35 GMT Received: from vamail01.TheXchange.com (mailbox.arbinet.com [64.74.47.120]) by imail01.arbinet.com (8.12.2/8.12.2) with SMTP id j4ALTLvt022482; Tue, 10 May 2005 21:29:33 GMT content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Subject: Re: Prefetch - OffTopic Date: Tue, 10 May 2005 21:28:23 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Prefetch - OffTopic Thread-Index: AcVVpCqGDk6xbMWKRn228aXbP4J6HgAAPMGw From: "Mohan, Ross" To: X-Spam-Details: Hits=-104.9, Required=2, Tests=BAYES_00,USER_IN_WHITELIST X-Scanned-By: MIMEDefang 2.39 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.113 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/165 X-Sequence-Number: 12329 Yes, that would be a sufficient (although not necessary) condition for = being well and fine with kdB.=20 Last time I used APL was.....pre-Gregorian, so yea, that's scary to me, = too.=20 ( Of course, one can use C/ODBC or Java/JDBC to reach kdB; once there, = one uses SQL92, or proprietary kSQL. ) -----Original Message----- From: pgsql-performance-owner@postgresql.org = [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Chris = Browne Sent: Tuesday, May 10, 2005 4:14 PM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Prefetch - OffTopic RMohan@arbinet.com ("Mohan, Ross") writes: > for time-series and "insane fast", nothing beats kdB, I believe > > www.kx.com ... Which is well and fine if you're prepared to require that all of the = staff that interact with data are skilled APL hackers. Skilled enough = that they're all ready to leap into Whitney's ASCII-based variant, K. --=20 (format nil "~S@~S" "cbbrowne" "acm.org") = http://www.ntlug.org/~cbbrowne/functional.html Rules of the Evil Overlord #78. "I will not tell my Legions of Terror = "And he must be taken alive!" The command will be: ``And try to take = him alive if it is reasonably practical.''" = ---------------------------(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-general-owner@postgresql.org Tue May 10 18:36:08 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7EA0F53833; Tue, 10 May 2005 18:36:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69912-10; Tue, 10 May 2005 21:35:57 +0000 (GMT) Received: from priv-edtnes46.telusplanet.net (defout.telus.net [199.185.220.240]) by svr1.postgresql.org (Postfix) with ESMTP id ECA6653C91; Tue, 10 May 2005 18:35:56 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes46.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050510213558.XRVH7617.priv-edtnes46.telusplanet.net@localhost>; Tue, 10 May 2005 15:35:58 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 14:35:57 -0700 Message-ID: <1115760957.4281293e0155b@webmail.telus.net> Date: Tue, 10 May 2005 14:35:58 -0700 From: Mischa Sandberg To: "Jim C. Nasby" Cc: Neil Conway , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <20050510153245.GA31103@decibel.org> In-Reply-To: <20050510153245.GA31103@decibel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.062 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/514 X-Sequence-Number: 77862 Quoting "Jim C. Nasby" : > Well, in a hash-join right now you normally end up feeding at least > one > side of the join with a seqscan. Wouldn't it speed things up > considerably if you could look up hashes in the hash index instead? You might want to google on "grace hash" and "hybrid hash". The PG hash join is the simplest possible: build a hash table in memory, and match an input stream against it. *Hybrid hash* is where you spill the hash to disk in a well-designed way. Instead of thinking of it as building a hash table in memory, think of it as partitioning one input; if some or all of it fits in memory, all the better. The boundary condition is the same. The real wizard of hybrid hash has to be Goetz Graefe, who sadly has now joined the MS Borg. He demonstrated that for entire-table joins, hybrid hash completely dominates sort-merge. MSSQL now uses what he developed as an academic, but I don't know what the patent state is. "Grace hash" is the original implementation of hybrid hash: Kitsuregawa, M., Tanaka, H., and Moto-oka, T. (1984). Architecture and Performance of Relational Algebra Machine Grace. From pgsql-performance-owner@postgresql.org Tue May 10 18:40:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AA0F7536F8 for ; Tue, 10 May 2005 18:40:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72314-02 for ; Tue, 10 May 2005 21:40:22 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 8AB11533C1 for ; Tue, 10 May 2005 18:40:22 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 595BE154BE; Tue, 10 May 2005 16:40:24 -0500 (CDT) Date: Tue, 10 May 2005 16:40:24 -0500 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: Re: PGSQL Capacity Message-ID: <20050510214024.GO31103@decibel.org> References: <1115666560.427fb8803c3a6@imp1-q.free.fr> <20050509193218.GB12502@uio.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050509193218.GB12502@uio.no> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/167 X-Sequence-Number: 12331 http://stats.distributed.net has a table that's 130M rows. http://stats.distributed.net/participant/phistory.php?project_id=8&id=39622 is a page that hits that table, and as you can see it's quite fast. This is on a dual opteron with 4G of memory. Unless you're looking for sub millisecond response times, 50k rows is nothing. On Mon, May 09, 2005 at 09:32:18PM +0200, Steinar H. Gunderson wrote: > On Mon, May 09, 2005 at 09:22:40PM +0200, bouchia.nazha@free.fr wrote: > > How can i know a capacity of a pg database ? > > How many records my table can have ? > > I saw in a message that someone have 50 000 records it's possible in a table ? > > (My table have 8 string field (length 32 car)). > > Thanks for your response. > > You can have several million records in a table easily -- I've done 10 > million personally, but you can find people doing that many records a _day_. > Hitting 1 billion records should probably not be impossible either -- it all > depends on your hardware, and perhaps more importantly, what kind of queries > you're running against it. 50000 is absolutely no problem at all. > > /* Steinar */ > -- > Homepage: http://www.sesse.net/ > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings > -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue May 10 18:45:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F386F533C1 for ; Tue, 10 May 2005 18:45:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72526-06 for ; Tue, 10 May 2005 21:45:31 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 5414F53CEB for ; Tue, 10 May 2005 18:45:28 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 7E668154C3; Tue, 10 May 2005 16:45:31 -0500 (CDT) Date: Tue, 10 May 2005 16:45:31 -0500 From: "Jim C. Nasby" To: Joel Fradkin Cc: PostgreSQL Perform Subject: Re: Configing 8 gig box. Message-ID: <20050510214531.GP31103@decibel.org> References: <006c01c554d9$7d701120$797ba8c0@jfradkin> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <006c01c554d9$7d701120$797ba8c0@jfradkin> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/168 X-Sequence-Number: 12332 On Mon, May 09, 2005 at 04:55:53PM -0400, Joel Fradkin wrote: > Seems to be only using like 360 meg out of 7 gig free (odd thing is I did > see some used swap 4k out of 1.9) with a bunch of users (this may be normal, > but it is not going overly fast so thought I would ask). This is perfectly normal. Each postgresql backend will only report memory usage roughly equal to shared_buffers plus the size of the code (16M or so?). If it's in the middle of a sort or vacuum, it will use more memory. It's not uncommon for modern OS's to swap out stuff that's not being used. They would rather have the memory available for disk caching, which is normally a good trade-off. For reference, on a 4G box running FreeBSD, there's currently 18M of swap used. Postgresql processes typically show 53M of total VM, with ~22M resident. This is with shared buffers of 2000. > Items I modified per commandprompt.coma nd watching this list etc. > > > > shared_buffers = 24576 > > work_mem = 32768 > > max_fsm_pages = 100000 > > max_fsm_relations = 1500 > > fsync = true > > wal_sync_method = open_sync > > wal_buffers = 2048 > > checkpoint_segments = 100 > > effective_cache_size = 524288 > > default_statistics_target = 250 > > > > Any help is appreciated. > > > > > > > > Joel Fradkin > > > > Wazagua, Inc. > 2520 Trailmate Dr > Sarasota, Florida 34243 > Tel. 941-753-7111 ext 305 > > > > jfradkin@wazagua.com > www.wazagua.com > Powered by Wazagua > Providing you with the latest Web-based technology & advanced tools. > C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc > This email message is for the use of the intended recipient(s) and may > contain confidential and privileged information. Any unauthorized review, > use, disclosure or distribution is prohibited. If you are not the intended > recipient, please contact the sender by reply email and delete and destroy > all copies of the original message, including attachments. > > > > > > > > -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue May 10 18:50:56 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 437B653CF6 for ; Tue, 10 May 2005 18:50:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73075-06 for ; Tue, 10 May 2005 21:50:53 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id B332853C38 for ; Tue, 10 May 2005 18:50:52 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 9C993152B4; Tue, 10 May 2005 16:50:54 -0500 (CDT) Date: Tue, 10 May 2005 16:50:54 -0500 From: "Jim C. Nasby" To: PFC Cc: John A Meinel , Adam Haberlach , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering Message-ID: <20050510215054.GQ31103@decibel.org> References: <20050510150226.00E453EFF@flute.newsnipple.com> <4280D76E.3090209@arbash-meinel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/169 X-Sequence-Number: 12333 On Tue, May 10, 2005 at 07:29:59PM +0200, PFC wrote: > I wonder how Oracle does it ;) Oracle *clustering* demands shared storage. So you've shifted your money from big-iron CPUs to big-iron disk arrays. Oracle replication works similar to Slony, though it supports a lot more modes (ie: syncronous). -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue May 10 18:55:58 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 38EE953D4F for ; Tue, 10 May 2005 18:55:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74353-05 for ; Tue, 10 May 2005 21:55:54 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 0090353D04 for ; Tue, 10 May 2005 18:55:53 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050510215555.OTFD5058.priv-edtnes56.telusplanet.net@localhost> for ; Tue, 10 May 2005 15:55:55 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 14:55:55 -0700 Message-ID: <1115762155.42812deb506d7@webmail.telus.net> Date: Tue, 10 May 2005 14:55:55 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.051 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/170 X-Sequence-Number: 12334 Quoting Alex Stapleton : > This is why I mention partitioning. It solves this issue by storing > different data sets on different machines under the same schema. > These seperate chunks of the table can then be replicated as well for > data redundancy and so on. MySQL are working on these things, but PG > just has a bunch of third party extensions, I wonder why these are > not being integrated into the main trunk :/ Thanks for pointing me to > PGCluster though. It looks like it should be better than Slony at > least. Across a decade or two of projects, including creating a federated database engine for Simba, I've become rather dubious of horizontal partitions (across disks or servers), either to improve performance, or just to scale up and not lose performance. [[The one exception is for non-time-critical read-only systems, with Slony-style replication.]] The most successful high-volume systems I've seen have broken up databases functionally, like a pipeline, where different applications use different sections of the pipe. The highest-volume system I've worked on is Acxiom's gigantic data-cleansing system. This is the central clearinghouse for every scrap of demographic that can be associated with some North American, somewhere. Think of D&B for 300M people (some dead). The volumes are just beyond belief, for both updates and queries. At Acxiom, the datasets are so large, even after partitioning, that they just constantly cycle them through memory, and commands are executes in convoys --- sort of like riding a paternoster. .......... Anybody been tracking on what Mr Stonebraker's been up to, lately? Datastream management. Check it out. Like replication, everybody hand-rolled their own datastream systems until finally somebody else generalized it well enough that it didn't have to be built from scratch every time. Datastream systems require practically no locking, let alone distributed transactions. They give you some really strong guarantees on transaction elapsed-time and throughput. ....... Where is this all leading? Well, for scaling data like this, the one feature that you need is the ability of procedures/rules on one server to perform queries/procedures on another. MSSQL has linked servers and (blech) OpenQuery. This lets you do reasonably-efficient work when you only deal with one table at a time. Do NOT try anything fancy with multi-table joins; timeouts are unavoidable, and painful. Postgres has a natural advantage in such a distributed server system: all table/index stats are openly available through the SQL interface, for one server to make rational query plans involving another server's resources. God! I would have killed for that when I was writing a federated SQL engine; the kluges you need to do this at arms-length from that information are true pain. So where should I go look, to see what's been done so far, on a Postgres that can treat another PG server as a new table type? From pgsql-performance-owner@postgresql.org Tue May 10 19:16:02 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 71D6E53D71 for ; Tue, 10 May 2005 19:16:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77767-06 for ; Tue, 10 May 2005 22:15:52 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 651D153AAC for ; Tue, 10 May 2005 19:15:51 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 9D52315490; Tue, 10 May 2005 17:15:54 -0500 (CDT) Date: Tue, 10 May 2005 17:15:54 -0500 From: "Jim C. Nasby" To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering Message-ID: <20050510221554.GR31103@decibel.org> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <1115762155.42812deb506d7@webmail.telus.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1115762155.42812deb506d7@webmail.telus.net> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/171 X-Sequence-Number: 12335 On Tue, May 10, 2005 at 02:55:55PM -0700, Mischa Sandberg wrote: > just beyond belief, for both updates and queries. At Acxiom, the > datasets are so large, even after partitioning, that they just > constantly cycle them through memory, and commands are executes in > convoys --- sort of like riding a paternoster. Speaking of which... what's the status of the patch that allows seqscans to piggyback on already running seqscans on the same table? > So where should I go look, to see what's been done so far, on a Postgres > that can treat another PG server as a new table type? To the best of my knowledge no such work has been done. There is a project (who's name escapes me) that lets you run queries against a remote postgresql server from a postgresql connection to a different server, which could serve as the basis for what you're proposing. BTW, given your experience, you might want to check out Bizgres. (http://pgfoundry.org/projects/bizgres/) I'm sure your insights would be most welcome. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-general-owner@postgresql.org Tue May 10 19:47:11 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C3AAD533C1; Tue, 10 May 2005 19:47:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81137-07; Tue, 10 May 2005 22:47:09 +0000 (GMT) Received: from mir3-fs.mir3.com (unknown [216.74.11.46]) by svr1.postgresql.org (Postfix) with ESMTP id 4FAD653E55; Tue, 10 May 2005 19:47:08 -0300 (ADT) Received: from amateljan.mirlogic.com ([172.16.2.68]) by mir3-fs.mir3.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 10 May 2005 15:48:26 -0700 Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL From: Mark Lewis To: Mischa Sandberg Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <1115760957.4281293e0155b@webmail.telus.net> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <20050510153245.GA31103@decibel.org> <1115760957.4281293e0155b@webmail.telus.net> Content-Type: text/plain Organization: MIR3, Inc. Message-Id: <1115765164.13684.25.camel@amateljan.mirlogic.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 (1.4.4-3) Date: Tue, 10 May 2005 15:46:04 -0700 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 May 2005 22:48:26.0899 (UTC) FILETIME=[60F2C630:01C555B2] X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/518 X-Sequence-Number: 77866 If the original paper was published in 1984, then it's been more than 20 years. Any potential patents would already have expired, no? -- Mark Lewis On Tue, 2005-05-10 at 14:35, Mischa Sandberg wrote: > Quoting "Jim C. Nasby" : > > > Well, in a hash-join right now you normally end up feeding at least > > one > > side of the join with a seqscan. Wouldn't it speed things up > > considerably if you could look up hashes in the hash index instead? > > You might want to google on "grace hash" and "hybrid hash". > > The PG hash join is the simplest possible: build a hash table in memory, > and match an input stream against it. > > *Hybrid hash* is where you spill the hash to disk in a well-designed > way. Instead of thinking of it as building a hash table in memory, think > of it as partitioning one input; if some or all of it fits in memory, > all the better. The boundary condition is the same. > > The real wizard of hybrid hash has to be Goetz Graefe, who sadly has now > joined the MS Borg. He demonstrated that for entire-table joins, hybrid > hash completely dominates sort-merge. MSSQL now uses what he developed > as an academic, but I don't know what the patent state is. > > "Grace hash" is the original implementation of hybrid hash: > Kitsuregawa, M., Tanaka, H., and Moto-oka, T. (1984). > Architecture and Performance of Relational Algebra Machine Grace. > > > > ---------------------------(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 May 10 19:56:32 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C6E0A53754 for ; Tue, 10 May 2005 19:56:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82896-03 for ; Tue, 10 May 2005 22:56:27 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 95ADD533C1 for ; Tue, 10 May 2005 19:56:25 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4AMuLxr027800; Tue, 10 May 2005 18:56:21 -0400 (EDT) To: Mischa Sandberg Cc: "Jim C. Nasby" , Neil Conway , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <1115760957.4281293e0155b@webmail.telus.net> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <20050510153245.GA31103@decibel.org> <1115760957.4281293e0155b@webmail.telus.net> Comments: In-reply-to Mischa Sandberg message dated "Tue, 10 May 2005 14:35:58 -0700" Date: Tue, 10 May 2005 18:56:21 -0400 Message-ID: <27799.1115765781@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/519 X-Sequence-Number: 77867 Mischa Sandberg writes: > The PG hash join is the simplest possible: build a hash table in memory, > and match an input stream against it. > *Hybrid hash* is where you spill the hash to disk in a well-designed > way. Instead of thinking of it as building a hash table in memory, think > of it as partitioning one input; if some or all of it fits in memory, > all the better. The boundary condition is the same. [ raised eyebrow... ] Apparently you've not read the code. It's been hybrid hashjoin since we got it from Berkeley. Probably not the best possible implementation of the concept, but we do understand about spill to disk. regards, tom lane From pgsql-general-owner@postgresql.org Tue May 10 20:24:13 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3D42D53B12; Tue, 10 May 2005 20:24:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88754-01; Tue, 10 May 2005 23:24:01 +0000 (GMT) Received: from priv-edtnes46.telusplanet.net (defout.telus.net [199.185.220.240]) by svr1.postgresql.org (Postfix) with ESMTP id 33E96536BA; Tue, 10 May 2005 20:23:59 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes46.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050510232402.ETXF7617.priv-edtnes46.telusplanet.net@localhost>; Tue, 10 May 2005 17:24:02 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 16:24:01 -0700 Message-ID: <1115767441.4281429124b9b@webmail.telus.net> Date: Tue, 10 May 2005 16:24:01 -0700 From: Mischa Sandberg To: Tom Lane Cc: "Jim C. Nasby" , Neil Conway , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <20050510153245.GA31103@decibel.org> <1115760957.4281293e0155b@webmail.telus.net> <27799.1115765781@sss.pgh.pa.us> In-Reply-To: <27799.1115765781@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.052 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/522 X-Sequence-Number: 77870 Quoting Tom Lane : > Mischa Sandberg writes: > > The PG hash join is the simplest possible: build a hash table in > memory, and match an input stream against it. > > [ raised eyebrow... ] Apparently you've not read the code. It's > been hybrid hashjoin since we got it from Berkeley. Probably not the > best possible implementation of the concept, but we do > understand about spill to disk. Apologies. I stopped reading around line 750 (PG 8.0.1) in src/backend/executor/nodeHashjoin.c if (!node->hj_hashdone) { .... /* * execute the Hash node, to build the hash table */ hashNode->hashtable = hashtable; (void) ExecProcNode((PlanState *) hashNode); ... and missed the comment: /* * Open temp files for outer batches, */ Will quietly go and read twice, talk once. From pgsql-general-owner@postgresql.org Tue May 10 20:56:34 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6343853FA8; Tue, 10 May 2005 20:56:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91978-08; Tue, 10 May 2005 23:56:24 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 8680F53FA5; Tue, 10 May 2005 20:56:23 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DVeaF-0003Dh-00; Tue, 10 May 2005 19:56:15 -0400 To: Tom Lane Cc: Greg Stark , Neil Conway , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> <9871.1115733198@sss.pgh.pa.us> <87wtq7q8zk.fsf@stark.xeocode.com> <25690.1115754605@sss.pgh.pa.us> In-Reply-To: <25690.1115754605@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 10 May 2005 19:56:15 -0400 Message-ID: <87ll6mr5y8.fsf@stark.xeocode.com> Lines: 17 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/525 X-Sequence-Number: 77873 Tom Lane writes: > No, not at all, because searching such an index will require a tree > descent, thus negating the one true advantage of hash indexes. The hash index still has to do a tree descent, it just has a larger branching factor than the btree index. btree indexes could have a special case hack to optionally use a large branching factor for the root node, effectively turning them into hash indexes. That would be useful for cases where you know the values will be very evenly distributed and won't need to scan ranges, ie, when you're indexing a hash function. -- greg From pgsql-general-owner@postgresql.org Tue May 10 21:14:35 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5BA9A53FD3 for ; Tue, 10 May 2005 21:14:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95484-10 for ; Wed, 11 May 2005 00:14:24 +0000 (GMT) Received: from priv-edtnes46.telusplanet.net (defout.telus.net [199.185.220.240]) by svr1.postgresql.org (Postfix) with ESMTP id 156AC53FCB for ; Tue, 10 May 2005 21:14:23 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes46.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511001426.HKFB7617.priv-edtnes46.telusplanet.net@localhost> for ; Tue, 10 May 2005 18:14:26 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 17:14:26 -0700 Message-ID: <1115770466.42814e62cb0e1@webmail.telus.net> Date: Tue, 10 May 2005 17:14:26 -0700 From: Mischa Sandberg To: pgsql-general@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <20050510153245.GA31103@decibel.org> <1115760957.4281293e0155b@webmail.telus.net> <1115765164.13684.25.camel@amateljan.mirlogic.com> In-Reply-To: <1115765164.13684.25.camel@amateljan.mirlogic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.043 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/526 X-Sequence-Number: 77874 Quoting Mark Lewis : > If the original paper was published in 1984, then it's been more than > 20 years. Any potential patents would already have expired, no? Don't know, but the idea is pervasive among different vendors ... perhaps that's a clue. And having now read beyond the start of ExecHashJoin(), I can see that PG does indeed implement Grace hash; and the implementation is nice and clean. If there were room for improvement, (and I didn't see it in the source) it would be the logic to: - swap inner and outer inputs (batches) when the original inner turned out to be too large for memory, and the corresponding outer did not. If you implement that anyway (complicates the loops) then it's no trouble to just hash the smaller of the two, every time; saves some CPU. - recursively partition batches where both inner and outer input batch ends up being too large for memory, too; or where the required number of batch output buffers alone is too large for working RAM. This is only for REALLY big inputs. Note that you don't need a bad hash function to get skewed batch sizes; you only need a skew distribution of the values being hashed. From pgsql-performance-owner@postgresql.org Tue May 10 22:23:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 707B1531C6 for ; Tue, 10 May 2005 22:23:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03345-10 for ; Wed, 11 May 2005 01:23:23 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id CD764536F3 for ; Tue, 10 May 2005 22:23:19 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 3EEB024FDF; Wed, 11 May 2005 09:23:22 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 351E524FDD; Wed, 11 May 2005 09:23:22 +0800 (WST) Message-ID: <42815EBA.7010806@familyhealth.com.au> Date: Wed, 11 May 2005 09:24:10 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alex Stapleton Cc: John A Meinel , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.067 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/176 X-Sequence-Number: 12340 > This is why I mention partitioning. It solves this issue by storing > different data sets on different machines under the same schema. These > seperate chunks of the table can then be replicated as well for data > redundancy and so on. MySQL are working on these things *laff* Yeah, like they've been working on views for the last 5 years, and still haven't released them :D :D :D Chris From pgsql-performance-owner@postgresql.org Tue May 10 22:34:28 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1C9D353CEB for ; Tue, 10 May 2005 22:34:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05110-07 for ; Wed, 11 May 2005 01:34:24 +0000 (GMT) Received: from priv-edtnes51.telusplanet.net (outbound04.telus.net [199.185.220.223]) by svr1.postgresql.org (Postfix) with ESMTP id 3519A53CE5 for ; Tue, 10 May 2005 22:34:23 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes51.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511013427.BMOI25031.priv-edtnes51.telusplanet.net@localhost> for ; Tue, 10 May 2005 19:34:27 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 18:34:26 -0700 Message-ID: <1115775266.42816122ec4e3@webmail.telus.net> Date: Tue, 10 May 2005 18:34:26 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <42815EBA.7010806@familyhealth.com.au> In-Reply-To: <42815EBA.7010806@familyhealth.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.039 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/177 X-Sequence-Number: 12341 Quoting Christopher Kings-Lynne : > > This is why I mention partitioning. It solves this issue by storing > > different data sets on different machines under the same schema. > > These seperate chunks of the table can then be replicated as well for > > data redundancy and so on. MySQL are working on these things > *laff* > Yeah, like they've been working on views for the last 5 years, and > still haven't released them :D :D :D ? http://dev.mysql.com/doc/mysql/en/create-view.html ...for MySQL 5.0.1+ ? From pgsql-performance-owner@postgresql.org Tue May 10 22:48:57 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DAE6F533AA for ; Tue, 10 May 2005 22:48:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05522-09 for ; Wed, 11 May 2005 01:48:48 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id C5263531C6 for ; Tue, 10 May 2005 22:48:47 -0300 (ADT) Received: from [192.168.1.105] (clbb-248.saw.net [64.146.135.248]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id j4B1fWa3018327; Tue, 10 May 2005 18:41:35 -0700 Message-ID: <42816480.5050108@commandprompt.com> Date: Tue, 10 May 2005 18:48:48 -0700 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <42815EBA.7010806@familyhealth.com.au> <1115775266.42816122ec4e3@webmail.telus.net> In-Reply-To: <1115775266.42816122ec4e3@webmail.telus.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.028 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/178 X-Sequence-Number: 12342 Mischa Sandberg wrote: > Quoting Christopher Kings-Lynne : > > >>>This is why I mention partitioning. It solves this issue by storing >>>different data sets on different machines under the same schema. >>>These seperate chunks of the table can then be replicated as well for >>>data redundancy and so on. MySQL are working on these things >> >>*laff* >>Yeah, like they've been working on views for the last 5 years, and >>still haven't released them :D :D :D > > > ? > http://dev.mysql.com/doc/mysql/en/create-view.html > ...for MySQL 5.0.1+ ? Yes but MySQL 5 isn't out yet (considered stable). Sincerely, Joshua D. Drake > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-general-owner@postgresql.org Tue May 10 22:51:56 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 41A7353D7D for ; Tue, 10 May 2005 22:51:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08895-03 for ; Wed, 11 May 2005 01:51:50 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id C362D53CFF for ; Tue, 10 May 2005 22:51:48 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j4B1pnt16211; Tue, 10 May 2005 21:51:49 -0400 (EDT) From: Bruce Momjian Message-Id: <200505110151.j4B1pnt16211@candle.pha.pa.us> Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-Reply-To: <1115770466.42814e62cb0e1@webmail.telus.net> To: Mischa Sandberg Date: Tue, 10 May 2005 21:51:49 -0400 (EDT) Cc: pgsql-general@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/529 X-Sequence-Number: 77877 Is there a TODO anywhere in this discussion? If so, please let me know. --------------------------------------------------------------------------- Mischa Sandberg wrote: > Quoting Mark Lewis : > > > If the original paper was published in 1984, then it's been more than > > 20 years. Any potential patents would already have expired, no? > > Don't know, but the idea is pervasive among different vendors ... > perhaps that's a clue. > > And having now read beyond the start of ExecHashJoin(), I can see that > PG does indeed implement Grace hash; and the implementation is nice and > clean. > > If there were room for improvement, (and I didn't see it in the source) > it would be the logic to: > > - swap inner and outer inputs (batches) when the original inner turned > out to be too large for memory, and the corresponding outer did not. If > you implement that anyway (complicates the loops) then it's no trouble > to just hash the smaller of the two, every time; saves some CPU. > > - recursively partition batches where both inner and outer input batch > ends up being too large for memory, too; or where the required number of > batch output buffers alone is too large for working RAM. This is only > for REALLY big inputs. > > Note that you don't need a bad hash function to get skewed batch sizes; > you only need a skew distribution of the values being hashed. > > > > ---------------------------(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 > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Tue May 10 22:58:30 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 127ED53CEA for ; Tue, 10 May 2005 22:58:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09949-04 for ; Wed, 11 May 2005 01:58:21 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 0D686536F8 for ; Tue, 10 May 2005 22:58:20 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 67C5224FE0; Wed, 11 May 2005 09:58:24 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 4C24A24FDD; Wed, 11 May 2005 09:58:24 +0800 (WST) Message-ID: <428166F2.8050600@familyhealth.com.au> Date: Wed, 11 May 2005 09:59:14 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <42815EBA.7010806@familyhealth.com.au> <1115775266.42816122ec4e3@webmail.telus.net> In-Reply-To: <1115775266.42816122ec4e3@webmail.telus.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.067 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/179 X-Sequence-Number: 12343 >>*laff* >>Yeah, like they've been working on views for the last 5 years, and >>still haven't released them :D :D :D > > > ? > http://dev.mysql.com/doc/mysql/en/create-view.html > ...for MySQL 5.0.1+ ? Give me a call when it's RELEASED. Chris From pgsql-general-owner@postgresql.org Tue May 10 23:02:07 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4C37053CDB for ; Tue, 10 May 2005 23:02:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10009-09 for ; Wed, 11 May 2005 02:02:00 +0000 (GMT) Received: from priv-edtnes28.telusplanet.net (outbound04.telus.net [199.185.220.223]) by svr1.postgresql.org (Postfix) with ESMTP id 50CE7533EE for ; Tue, 10 May 2005 23:01:58 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes28.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511020202.HRKQ7458.priv-edtnes28.telusplanet.net@localhost>; Tue, 10 May 2005 20:02:02 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 19:02:02 -0700 Message-ID: <1115776922.4281679a8e67f@webmail.telus.net> Date: Tue, 10 May 2005 19:02:02 -0700 From: Mischa Sandberg To: Bruce Momjian Cc: pgsql-general@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <200505110151.j4B1pnt16211@candle.pha.pa.us> In-Reply-To: <200505110151.j4B1pnt16211@candle.pha.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.04 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/530 X-Sequence-Number: 77878 Quoting Bruce Momjian : > > Is there a TODO anywhere in this discussion? If so, please let me > know. > Umm... I don't think so. I'm not clear on what TODO means yet. 'Up for consideration'? If a "TODO" means committing to do, I would prefer to follow up on a remote-schema (federated server) project first. ... > > If there were room for improvement, (and I didn't see it in the > source) > > it would be the logic to: > > > > - swap inner and outer inputs (batches) when the original inner > turned > > out to be too large for memory, and the corresponding outer did > not. If > > you implement that anyway (complicates the loops) then it's no > trouble > > to just hash the smaller of the two, every time; saves some CPU. > > > > - recursively partition batches where both inner and outer input > batch > > ends up being too large for memory, too; or where the required > number of > > batch output buffers alone is too large for working RAM. This is > only > > for REALLY big inputs. > > > > Note that you don't need a bad hash function to get skewed batch > sizes; > > you only need a skew distribution of the values being hashed. From pgsql-general-owner@postgresql.org Tue May 10 23:03:26 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 89DF353D71 for ; Tue, 10 May 2005 23:03:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10064-06 for ; Wed, 11 May 2005 02:03:16 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id 70672531C6 for ; Tue, 10 May 2005 23:03:15 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j4B23L317839; Tue, 10 May 2005 22:03:21 -0400 (EDT) From: Bruce Momjian Message-Id: <200505110203.j4B23L317839@candle.pha.pa.us> Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-Reply-To: <1115776922.4281679a8e67f@webmail.telus.net> To: Mischa Sandberg Date: Tue, 10 May 2005 22:03:21 -0400 (EDT) Cc: pgsql-general@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/531 X-Sequence-Number: 77879 Mischa Sandberg wrote: > Quoting Bruce Momjian : > > > > > Is there a TODO anywhere in this discussion? If so, please let me > > know. > > > > Umm... I don't think so. I'm not clear on what TODO means yet. 'Up for > consideration'? If a "TODO" means committing to do, I would prefer to > follow up on a remote-schema (federated server) project first. TODO means it is a change that most people think would be a good idea. It is not a committment from anyone to actually do it. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-general-owner@postgresql.org Tue May 10 23:05:38 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B329253D75 for ; Tue, 10 May 2005 23:05:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11438-06 for ; Wed, 11 May 2005 02:05:35 +0000 (GMT) Received: from priv-edtnes46.telusplanet.net (defout.telus.net [199.185.220.240]) by svr1.postgresql.org (Postfix) with ESMTP id 0C60953D73 for ; Tue, 10 May 2005 23:05:34 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes46.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511020538.MYMX7617.priv-edtnes46.telusplanet.net@localhost> for ; Tue, 10 May 2005 20:05:38 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 19:05:38 -0700 Message-ID: <1115777138.42816872a29a7@webmail.telus.net> Date: Tue, 10 May 2005 19:05:38 -0700 From: Mischa Sandberg To: pgsql-general@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <200505110203.j4B23L317839@candle.pha.pa.us> In-Reply-To: <200505110203.j4B23L317839@candle.pha.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.046 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/532 X-Sequence-Number: 77880 Quoting Bruce Momjian : > Mischa Sandberg wrote: > > Quoting Bruce Momjian : > > > Is there a TODO anywhere in this discussion? If so, please let > me > > > know. > > > > > > > Umm... I don't think so. I'm not clear on what TODO means yet. 'Up > for > > consideration'? If a "TODO" means committing to do, I would prefer > to > > follow up on a remote-schema (federated server) project first. > > TODO means it is a change that most people think would be a good > idea. > It is not a committment from anyone to actually do it. I think there has not been enough commentary from "most people". From pgsql-performance-owner@postgresql.org Tue May 10 23:06:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B0B35533EE for ; Tue, 10 May 2005 23:06:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10715-06 for ; Wed, 11 May 2005 02:06:24 +0000 (GMT) Received: from priv-edtnes40.telusplanet.net (outbound05.telus.net [199.185.220.224]) by svr1.postgresql.org (Postfix) with ESMTP id 5178753DE0 for ; Tue, 10 May 2005 23:06:23 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes40.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511020627.DKUX9688.priv-edtnes40.telusplanet.net@localhost>; Tue, 10 May 2005 20:06:27 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 19:06:27 -0700 Message-ID: <1115777187.428168a36cd7f@webmail.telus.net> Date: Tue, 10 May 2005 19:06:27 -0700 From: Mischa Sandberg To: Christopher Kings-Lynne Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <42815EBA.7010806@familyhealth.com.au> <1115775266.42816122ec4e3@webmail.telus.net> <428166F2.8050600@familyhealth.com.au> In-Reply-To: <428166F2.8050600@familyhealth.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.052 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/180 X-Sequence-Number: 12344 Quoting Christopher Kings-Lynne : > > >>*laff* > >>Yeah, like they've been working on views for the last 5 years, and > >>still haven't released them :D :D :D > > > > ? > > http://dev.mysql.com/doc/mysql/en/create-view.html > > ...for MySQL 5.0.1+ ? > > Give me a call when it's RELEASED. :-) Touche' From pgsql-general-owner@postgresql.org Tue May 10 23:14:36 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5EC8F531C6 for ; Tue, 10 May 2005 23:14:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13178-03 for ; Wed, 11 May 2005 02:14:26 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id A8BCD53F76 for ; Tue, 10 May 2005 23:14:23 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 6CF4518CC36; Tue, 10 May 2005 22:14:28 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 62563-01; Tue, 10 May 2005 22:14:26 -0400 (EDT) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id C8A6D18CC05; Tue, 10 May 2005 22:14:25 -0400 (EDT) Message-ID: <42816A7E.3080508@samurai.com> Date: Wed, 11 May 2005 12:14:22 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruce Momjian Cc: Mischa Sandberg , pgsql-general@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <200505110151.j4B1pnt16211@candle.pha.pa.us> In-Reply-To: <200505110151.j4B1pnt16211@candle.pha.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/533 X-Sequence-Number: 77881 Bruce Momjian wrote: > Is there a TODO anywhere in this discussion? If so, please let me know. There are a couple: - consider changing hash indexes to keep the entries in a hash bucket sorted, to allow a binary search rather than a linear scan - consider changing hash indexes to store each key's hash value in addition to or instead of the key value. You should probably include a pointer to this discussion as well. (I'd like to take a look at implementing these if I get a chance.) -Neil From pgsql-general-owner@postgresql.org Tue May 10 23:18:14 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1D40F533AA; Tue, 10 May 2005 23:18:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14114-02; Wed, 11 May 2005 02:18:04 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 669CA53D7D; Tue, 10 May 2005 23:18:03 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4B2HlQc029018; Tue, 10 May 2005 22:17:48 -0400 (EDT) To: Greg Stark Cc: Neil Conway , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <87ll6mr5y8.fsf@stark.xeocode.com> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> <9871.1115733198@sss.pgh.pa.us> <87wtq7q8zk.fsf@stark.xeocode.com> <25690.1115754605@sss.pgh.pa.us> <87ll6mr5y8.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "10 May 2005 19:56:15 -0400" Date: Tue, 10 May 2005 22:17:47 -0400 Message-ID: <29017.1115777867@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/534 X-Sequence-Number: 77882 Greg Stark writes: > Tom Lane writes: >> No, not at all, because searching such an index will require a tree >> descent, thus negating the one true advantage of hash indexes. > The hash index still has to do a tree descent, it just has a larger branching > factor than the btree index. There is *no* tree descent in a hash index: you go directly to the bucket you want. If the bucket spans more than one page, you pay something, but this strikes me as being equivalent to the case of multiple equal keys spanning multiple pages in a btree. It works, but it's not the design center. > btree indexes could have a special case hack to optionally use a large > branching factor for the root node, effectively turning them into hash > indexes. No, because you'd still have to fetch and search the root node. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 10 23:19:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A8147533EE for ; Tue, 10 May 2005 23:19:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12510-07 for ; Wed, 11 May 2005 02:19:11 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 758E6533AA for ; Tue, 10 May 2005 23:19:09 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511021913.EAKY5058.priv-edtnes56.telusplanet.net@localhost> for ; Tue, 10 May 2005 20:19:13 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Tue, 10 May 2005 19:19:13 -0700 Message-ID: <1115777953.42816ba1b4618@webmail.telus.net> Date: Tue, 10 May 2005 19:19:13 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <1115762155.42812deb506d7@webmail.telus.net> <20050510221554.GR31103@decibel.org> In-Reply-To: <20050510221554.GR31103@decibel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.036 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/182 X-Sequence-Number: 12346 Quoting "Jim C. Nasby" : > To the best of my knowledge no such work has been done. There is a > project (who's name escapes me) that lets you run queries against a > remote postgresql server from a postgresql connection to a different > server, which could serve as the basis for what you're proposing. Okay, if the following looks right to the powerthatbe, I'd like to start a project. Here's the proposition: "servername.dbname.schema.object" would change RangeVar, which would affect much code. "dbname.schema.object" itself is not implemented in 8.0. So, simplicity dictates something like: table pg_remote(schemaname text, connectby text, remoteschema text) The pg_statistic info from a remote server cannot be cached in local pg_statistic, without inventing pseudo reloids as well as a pseudoschema. Probably cleaner to cache it somewhere else. I'm still reading down the path that puts pg_statistic data where costsize can get at it. First step: find out whether one can link libpq.so to postmaster :-) From pgsql-performance-owner@postgresql.org Tue May 10 23:49:09 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C3A8D53FAE for ; Tue, 10 May 2005 23:49:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17090-03 for ; Wed, 11 May 2005 02:49:07 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 8771453F8B for ; Tue, 10 May 2005 23:49:06 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 91C7F18CC0E; Tue, 10 May 2005 22:49:11 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 63441-01-10; Tue, 10 May 2005 22:49:10 -0400 (EDT) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 672FE18CC30; Tue, 10 May 2005 22:49:09 -0400 (EDT) Message-ID: <428172A2.9030503@samurai.com> Date: Wed, 11 May 2005 12:49:06 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <200505101046.25108.josh@agliodbs.com> In-Reply-To: <200505101046.25108.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.023 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/183 X-Sequence-Number: 12347 Josh Berkus wrote: > Don't hold your breath. MySQL, to judge by their first "clustering" > implementation, has a *long* way to go before they have anything usable. Oh? What's wrong with MySQL's clustering implementation? -Neil From pgsql-performance-owner@postgresql.org Wed May 11 00:11:40 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 52B3A53CD3 for ; Wed, 11 May 2005 00:11:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22623-06 for ; Wed, 11 May 2005 03:11:39 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id C45A8539E4 for ; Wed, 11 May 2005 00:11:38 -0300 (ADT) Received: from [192.168.1.105] (clbb-248.saw.net [64.146.135.248]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id j4B34Ha3026905; Tue, 10 May 2005 20:04:21 -0700 Message-ID: <428177E5.4030704@commandprompt.com> Date: Tue, 10 May 2005 20:11:33 -0700 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Neil Conway Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <200505101046.25108.josh@agliodbs.com> <428172A2.9030503@samurai.com> In-Reply-To: <428172A2.9030503@samurai.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.028 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/184 X-Sequence-Number: 12348 Neil Conway wrote: > Josh Berkus wrote: > >> Don't hold your breath. MySQL, to judge by their first "clustering" >> implementation, has a *long* way to go before they have anything usable. > > > Oh? What's wrong with MySQL's clustering implementation? Ram only tables :) > > -Neil > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly From pgsql-performance-owner@postgresql.org Wed May 11 01:10:54 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 169EF5352C for ; Wed, 11 May 2005 01:10:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31976-03 for ; Wed, 11 May 2005 04:10:44 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 08341531C6 for ; Wed, 11 May 2005 01:10:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4B4Aaal029858; Wed, 11 May 2005 00:10:36 -0400 (EDT) To: "Jim C. Nasby" Cc: Joel Fradkin , PostgreSQL Perform Subject: Re: Configing 8 gig box. In-reply-to: <20050510214531.GP31103@decibel.org> References: <006c01c554d9$7d701120$797ba8c0@jfradkin> <20050510214531.GP31103@decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Tue, 10 May 2005 16:45:31 -0500" Date: Wed, 11 May 2005 00:10:36 -0400 Message-ID: <29857.1115784636@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/186 X-Sequence-Number: 12350 "Jim C. Nasby" writes: > On Mon, May 09, 2005 at 04:55:53PM -0400, Joel Fradkin wrote: >> Seems to be only using like 360 meg out of 7 gig free (odd thing is I did >> see some used swap 4k out of 1.9) with a bunch of users (this may be normal, >> but it is not going overly fast so thought I would ask). > This is perfectly normal. Each postgresql backend will only report > memory usage roughly equal to shared_buffers plus the size of the code > (16M or so?). If it's in the middle of a sort or vacuum, it will use > more memory. One thing to note is that depending on which Unix variant you are using, top may claim that any particular backend process is using the portion of shared memory that it's actually physically touched. This means that the claimed size of a backend process will grow as it runs (and randomly needs to touch pages that are in different slots of the shared-memory buffers) regardless of any actual objective growth in memory needs. regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 11 00:52:19 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1A42053BEA for ; Wed, 11 May 2005 00:52:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28385-08 for ; Wed, 11 May 2005 03:52:09 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id EADBA53A35 for ; Wed, 11 May 2005 00:52:08 -0300 (ADT) Received: (qmail 2561 invoked by uid 500); 11 May 2005 04:12:24 -0000 Date: Tue, 10 May 2005 23:12:24 -0500 From: Bruno Wolff III To: Adam Haberlach Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering Message-ID: <20050511041224.GA1475@wolff.to> Mail-Followup-To: Bruno Wolff III , Adam Haberlach , pgsql-performance@postgresql.org References: <4280C801.80603@arbash-meinel.com> <20050510150226.00E453EFF@flute.newsnipple.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050510150226.00E453EFF@flute.newsnipple.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/185 X-Sequence-Number: 12349 On Tue, May 10, 2005 at 08:02:50 -0700, Adam Haberlach wrote: > > > With all the Opteron v. Xeon around here, and talk of $30,000 machines, > perhaps it would be worth exploring the option of buying 10 cheapass > machines for $300 each. At the moment, that $300 buys you, from Dell, a > 2.5Ghz Pentium 4 w/ 256mb of RAM and a 40Gb hard drive and gigabit ethernet. > The aggregate CPU and bandwidth is pretty stupendous, but not as easy to > harness as a single machine. That isn't going to be ECC ram. I don't think you really want to use non-ECC ram in a critical database. From pgsql-performance-owner@postgresql.org Wed May 11 01:34:18 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0E196537E6 for ; Wed, 11 May 2005 01:34:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35700-02 for ; Wed, 11 May 2005 04:34:10 +0000 (GMT) Received: from mail.utsl.gen.nz (210-54-92-184.ipnets.xtra.co.nz [210.54.92.184]) by svr1.postgresql.org (Postfix) with ESMTP id 4C3F353C46 for ; Wed, 11 May 2005 01:34:08 -0300 (ADT) Received: by mail.utsl.gen.nz (Postfix, from userid 65534) id EED3611004; Wed, 11 May 2005 16:34:01 +1200 (NZST) Received: from [127.0.0.1] (longdrop.clunker.utsl.gen.nz [192.168.255.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.utsl.gen.nz (Postfix) with ESMTP id 71DEA11002; Wed, 11 May 2005 16:33:54 +1200 (NZST) Message-ID: <42818B2E.8060403@vilain.net> Date: Wed, 11 May 2005 16:33:50 +1200 From: Sam Vilain User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: molson@oceanconsulting.com Cc: pgsql-performance@postgresql.org Subject: Re: Prefetch References: <200505100652.51401.molson@oceanconsulting.com> In-Reply-To: <200505100652.51401.molson@oceanconsulting.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.312 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/187 X-Sequence-Number: 12351 Matt Olson wrote: > Other databases like Oracle and DB2 implement some sort of row prefetch. Has > there been serious consideration of implementing something like a prefetch > subsystem? Does anyone have any opinions as to why this would be a bad idea > for postgres? > Postges is great for a multiuser environment and OLTP applications. However, > in this set up, a data warehouse, the observed performance is not what I > would hope for. Oracle doesn't pre-fetch data to get its fast results in this case. pre-fetching doesn't give you the 100 times speed increases. Bitmap indexes are very important for data mining. You might want to see http://www.it.iitb.ac.in/~rvijay/dbms/proj/ I have no idea how well developed this is, but this is often the biggest win with Data Warehousing. If it works, you'll get results back in seconds, if it doesn't you'll have plenty of time while your queries run to reflect on the possibility that commercial databases might actually have important features that haven't even penetrated the awareness of most free database developers. Another trick you can use with large data sets like this when you want results back in seconds is to have regularly updated tables that aggregate the data along each column normally aggregated against the main data set. Of couse, Pg doesn't have the nice features that make this just work and make queries against your data source faster (called "OLAP Query rewrite" in Oracle), so you'll have to put a lot of work into changing your application to figure out when to use the summary tables. As far as I know it doesn't have materialized views, either, so updating these summary tables is also a more complex task than just a single REFRESH command. Maybe some bright person will prove me wrong by posting some working information about how to get these apparently absent features working. You might also want to consider ditching RAID 5 and switching to plain mirroring. RAID 5 is a helluva performance penalty (by design). This is why they said RAID - fast, cheap, reliable - pick any two. RAID 5 ain't fast. But that's probably not your main problem. Sam. > > Regards, > > Matt Olson > Ocean Consulting > http://www.oceanconsulting.com/ > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Wed May 11 01:39:40 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1FC3B5352C for ; Wed, 11 May 2005 01:39:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36968-01 for ; Wed, 11 May 2005 04:39:31 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 0776753C8C for ; Wed, 11 May 2005 01:39:28 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 5A34718CDC3; Wed, 11 May 2005 00:39:28 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 91410-01-2; Wed, 11 May 2005 00:39:26 -0400 (EDT) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id D659718CDE3; Wed, 11 May 2005 00:39:25 -0400 (EDT) Message-ID: <42818C7A.7020207@samurai.com> Date: Wed, 11 May 2005 14:39:22 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Joshua D. Drake" Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <200505101046.25108.josh@agliodbs.com> <428172A2.9030503@samurai.com> <428177E5.4030704@commandprompt.com> In-Reply-To: <428177E5.4030704@commandprompt.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.023 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/188 X-Sequence-Number: 12352 Joshua D. Drake wrote: > Neil Conway wrote: >> Oh? What's wrong with MySQL's clustering implementation? > > Ram only tables :) Sure, but that hardly makes it not "usable". Considering the price of RAM these days, having enough RAM to hold the database (distributed over the entire cluster) is perfectly acceptable for quite a few people. (Another deficiency is in 4.0, predicates in queries would not be pushed down to storage nodes -- so you had to stream the *entire* table over the network, and then apply the WHERE clause at the frontend query node. That is fixed in 5.0, though.) -Neil From pgsql-performance-owner@postgresql.org Wed May 11 01:44:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 749E053C8B for ; Wed, 11 May 2005 01:44:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35505-07 for ; Wed, 11 May 2005 04:44:08 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id EC50653C3B for ; Wed, 11 May 2005 01:44:07 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7347691; Tue, 10 May 2005 21:46:07 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Neil Conway Subject: Re: Partitioning / Clustering Date: Tue, 10 May 2005 21:44:06 -0700 User-Agent: KMail/1.8 Cc: "Joshua D. Drake" , pgsql-performance@postgresql.org References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <428177E5.4030704@commandprompt.com> <42818C7A.7020207@samurai.com> In-Reply-To: <42818C7A.7020207@samurai.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505102144.07254.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/189 X-Sequence-Number: 12353 Neil, > Sure, but that hardly makes it not "usable". Considering the price of > RAM these days, having enough RAM to hold the database (distributed over > the entire cluster) is perfectly acceptable for quite a few people. The other problem, as I was told it at OSCON, was that these were not high-availability clusters; it's impossible to add a server to an existing cluster, and a server going down is liable to take the whole cluster down. Mind you, I've not tried that aspect of it myself; once I saw the ram-only rule, we switched to something else. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed May 11 01:52:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 263D853CD1 for ; Wed, 11 May 2005 01:52:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37589-05 for ; Wed, 11 May 2005 04:52:12 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id DA04E53CB9 for ; Wed, 11 May 2005 01:52:10 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id B788424FDF; Wed, 11 May 2005 12:52:08 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id AF5C124FDD; Wed, 11 May 2005 12:52:08 +0800 (WST) Message-ID: <42818FB1.4060403@familyhealth.com.au> Date: Wed, 11 May 2005 12:53:05 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sam Vilain Cc: molson@oceanconsulting.com, pgsql-performance@postgresql.org Subject: Re: Prefetch References: <200505100652.51401.molson@oceanconsulting.com> <42818B2E.8060403@vilain.net> In-Reply-To: <42818B2E.8060403@vilain.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.067 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/190 X-Sequence-Number: 12354 > Another trick you can use with large data sets like this when you want > results > back in seconds is to have regularly updated tables that aggregate the data > along each column normally aggregated against the main data set. > Maybe some bright person will prove me wrong by posting some working > information about how to get these apparently absent features working. Most people just use simple triggers to maintain aggregate summary tables... Chris From pgsql-performance-owner@postgresql.org Sun May 15 15:30:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 06BED54A47 for ; Wed, 11 May 2005 04:06:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55224-03 for ; Wed, 11 May 2005 07:06:11 +0000 (GMT) Received: from mailgw.dmi.dk (mailgw.dmi.dk [130.226.71.185]) by svr1.postgresql.org (Postfix) with ESMTP id A60F65295C for ; Wed, 11 May 2005 04:06:01 -0300 (ADT) Received: from localhost (localhost.dmi.dk [127.0.0.1]) by mailgw.dmi.dk (8.12.11/8.12.11/Debian-1) with ESMTP id j4B75jcV003771; Wed, 11 May 2005 07:05:45 GMT Received: from mailgw.dmi.dk ([127.0.0.1]) by localhost (mailgw.dmi.dk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 03530-10-2; Wed, 11 May 2005 07:05:29 +0000 (GMT) Received: from postoffice.dmi.dk (postoffice.dmi.dk [130.226.64.60]) by mailgw.dmi.dk (8.12.11/8.12.11/Debian-1) with ESMTP id j4B755dr003753; Wed, 11 May 2005 07:05:05 GMT Received: from [130.226.66.16] (anders [130.226.66.16]) by postoffice.dmi.dk (Postfix) with ESMTP id 6301318042; Wed, 11 May 2005 07:05:05 +0000 (GMT) Message-ID: <4281AEA1.8020600@dmi.dk> Date: Wed, 11 May 2005 09:05:05 +0200 From: Kim Bisgaard User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: full outer performance problem References: <428078E6.90007@dmi.dk> <10318.1115736342@sss.pgh.pa.us> In-Reply-To: <10318.1115736342@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------080403040502040602020306" X-Virus-Scanned: by amavisd-maia-1.0.0-rc5 (Debian) at dmi.dk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.066 tagged_above=0 required=5 tests=AWL, HTML_40_50, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: X-Archive-Number: 200505/288 X-Sequence-Number: 12452 This is a multi-part message in MIME format. --------------080403040502040602020306 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sorry for not listing the exact layout of temp_XXXX: obsdb=> \d temp_dry_at_2m Table "public.temp_dry_at_2m" Column | Type | Modifiers ----------------+-----------------------------+----------- obshist_id | integer | not null station_id | integer | not null timeobs | timestamp without time zone | not null temp_dry_at_2m | real | not null Indexes: "temp_dry_at_2m_pkey" primary key, btree (obshist_id) "temp_dry_at_2m_idx" btree (station_id, timeobs) The difference between the two queries is if a (station_id,timeobs) row is missing in one table, then the first returns one record(null,9.3) while the second return no records. Regards, Kim Bisgaard. Tom Lane wrote: >Kim Bisgaard writes: > > >>I have two BIG tables (virtually identical) with 3 NOT NULL columns >>Station_id, TimeObs, Temp_XXXX, with indexes on (Station_id, TimeObs) >>and valid ANALYSE (set statistics=100). I want to join the two tables >>with a FULL OUTER JOIN. >> >> > >I'm confused. If the columns are NOT NULL, why isn't this a valid >transformation of your original query? > > > >>select temp_max_60min,temp_dry_at_2m >>from station s natural join >>temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs) >>where s.wmo_id=6065 >>and _a.timeobs='2004-1-1 0:0:0' and b._timeobs='2004-1-1 0:0:0' >>and '2004-1-1 0:0:0' between s.startdate and s.enddate; >> >> > >Seems like it's not eliminating any rows that would otherwise succeed. > > regards, tom lane > >---------------------------(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 > > > -- Kim Bisgaard Computer Department Phone: +45 3915 7562 (direct) Danish Meteorological Institute Fax: +45 3915 7460 (division) --------------080403040502040602020306 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sorry for not listing the exact layout of temp_XXXX:
obsdb=> \d temp_dry_at_2m
              Table "public.temp_dry_at_2m"
     Column     |            Type             | Modifiers
----------------+-----------------------------+-----------
 obshist_id     | integer                     | not null
 station_id     | integer                     | not null
 timeobs        | timestamp without time zone | not null
 temp_dry_at_2m | real                        | not null
Indexes:
    "temp_dry_at_2m_pkey" primary key, btree (obshist_id)
    "temp_dry_at_2m_idx" btree (station_id, timeobs)
The difference between the two queries is if a (station_id,timeobs) row is missing in one table, then the first returns one record(null,9.3) while the second return no records.

Regards,
Kim Bisgaard.

Tom Lane wrote:
Kim Bisgaard <kib+pg@dmi.dk> writes:
  
I have two BIG tables (virtually identical) with 3 NOT NULL columns 
Station_id, TimeObs, Temp_XXXX, with indexes on (Station_id, TimeObs) 
and valid ANALYSE (set statistics=100). I want to join the two tables 
with a FULL OUTER JOIN.
    

I'm confused.  If the columns are NOT NULL, why isn't this a valid
transformation of your original query?

  
select temp_max_60min,temp_dry_at_2m
from station s natural join
temp_dry_at_2m a full outer join temp_max_60min b using (station_id, timeobs)
where s.wmo_id=6065 
and _a.timeobs='2004-1-1 0:0:0' and b._timeobs='2004-1-1 0:0:0' 
and '2004-1-1 0:0:0' between s.startdate and s.enddate;
    

Seems like it's not eliminating any rows that would otherwise succeed.

			regards, tom lane

---------------------------(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

  

-- 
Kim Bisgaard

Computer Department                  Phone: +45 3915 7562 (direct)
Danish Meteorological Institute      Fax: +45 3915 7460 (division)
--------------080403040502040602020306-- From pgsql-performance-owner@postgresql.org Wed May 11 04:20:25 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 844EE54A29 for ; Wed, 11 May 2005 04:20:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57562-03 for ; Wed, 11 May 2005 07:20:14 +0000 (GMT) Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) by svr1.postgresql.org (Postfix) with ESMTP id E7A9952954 for ; Wed, 11 May 2005 04:20:10 -0300 (ADT) Received: from modem-4066.lynx.dialup.pol.co.uk ([217.135.207.226] helo=192.168.0.102) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.41) id 1DVlVp-0006PE-M6; Wed, 11 May 2005 08:20:09 +0100 Subject: Re: Partitioning / Clustering From: Simon Riggs To: Alex Stapleton Cc: pgsql-performance@postgresql.org In-Reply-To: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> Content-Type: text/plain Organization: 2nd Quadrant Date: Wed, 11 May 2005 08:16:20 +0100 Message-Id: <1115795780.3830.264.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/191 X-Sequence-Number: 12355 On Tue, 2005-05-10 at 11:03 +0100, Alex Stapleton wrote: > So, when/is PG meant to be getting a decent partitioning system? ISTM that your question seems to confuse where code comes from. Without meaning to pick on you, or reply rudely, I'd like to explore that question. Perhaps it should be a FAQ entry. All code is written by someone, and those people need to eat. Some people are fully or partly funded to perform their tasks on this project (coding, patching, etc). Others contribute their time for a variety of reasons where involvement has a positive benefit. You should ask these questions: - Is anyone currently working on (Feature X)? - If not, Can I do it myself? - If not, and I still want it, can I fund someone else to build it for me? Asking "when is Feature X going to happen" is almost certainly going to get the answer "never" otherwise, if the initial development is large and complex. There are many TODO items that have lain untouched for years, even though adding the feature has been discussed and agreed. Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Wed May 11 04:55:25 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8FEEB54530 for ; Wed, 11 May 2005 04:55:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58493-10 for ; Wed, 11 May 2005 07:55:15 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 818FE54A1D for ; Wed, 11 May 2005 04:55:14 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 0FCCE18CDAE; Wed, 11 May 2005 03:55:16 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 99825-01-8; Wed, 11 May 2005 03:55:14 -0400 (EDT) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 8296918CD58; Wed, 11 May 2005 03:55:13 -0400 (EDT) Message-ID: <4281BA5E.9060508@samurai.com> Date: Wed, 11 May 2005 17:55:10 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: "Joshua D. Drake" , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <428177E5.4030704@commandprompt.com> <42818C7A.7020207@samurai.com> <200505102144.07254.josh@agliodbs.com> In-Reply-To: <200505102144.07254.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.023 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/192 X-Sequence-Number: 12356 Josh Berkus wrote: > The other problem, as I was told it at OSCON, was that these were not > high-availability clusters; it's impossible to add a server to an existing > cluster Yeah, that's a pretty significant problem. > a server going down is liable to take the whole cluster down. That's news to me. Do you have more information on this? -Neil From pgsql-performance-owner@postgresql.org Wed May 11 04:58:03 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9DB3854AD9 for ; Wed, 11 May 2005 04:58:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56611-10 for ; Wed, 11 May 2005 07:57:59 +0000 (GMT) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by svr1.postgresql.org (Postfix) with ESMTP id 606D854A9C for ; Wed, 11 May 2005 04:57:58 -0300 (ADT) Received: from web2.messagingengine.com (web2.internal [10.202.2.211]) by frontend1.messagingengine.com (Postfix) with ESMTP id A2468C8D819; Wed, 11 May 2005 03:57:59 -0400 (EDT) Received: by web2.messagingengine.com (Postfix, from userid 99) id B8E2D4A3; Wed, 11 May 2005 03:57:57 -0400 (EDT) Message-Id: <1115798277.29223.233869472@webmail.messagingengine.com> X-Sasl-Enc: W+JRp3SRjgZoFZA86zO1nPvZUIdyA3cMn2XSFEiq+J8Q 1115798277 From: "David Roussel" To: "Alex Stapleton" , pgsql-performance@postgresql.org Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 X-Mailer: MIME::Lite 1.5 (F2.73; T1.001; A1.64; B3.05; Q3.03) References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> Subject: Re: Partitioning / Clustering In-Reply-To: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> Date: Wed, 11 May 2005 08:57:57 +0100 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/193 X-Sequence-Number: 12357 For an interesting look at scalability, clustering, caching, etc for a large site have a look at how livejournal did it. http://www.danga.com/words/2004_lisa/lisa04.pdf They have 2.6 Million active users, posting 200 new blog entries per minute, plus many comments and countless page views. Although this system is of a different sort to the type I work on it's interesting to see how they've made it scale. They use mysql on dell hardware! And found single master replication did not scale. There's a section on multimaster replication, not sure if they use it. The main approach they use is to parition users into spefic database clusters. Caching is done using memcached at the application level to avoid hitting the db for rendered pageviews. It's interesting that the solution livejournal have arrived at is quite similar in ways to the way google is set up. David From pgsql-performance-owner@postgresql.org Sun May 15 15:30:38 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D107F54530 for ; Wed, 11 May 2005 05:20:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63314-08 for ; Wed, 11 May 2005 08:20:45 +0000 (GMT) Received: from mailgw.dmi.dk (mailgw.dmi.dk [130.226.71.185]) by svr1.postgresql.org (Postfix) with ESMTP id 364B553AAC for ; Wed, 11 May 2005 05:20:43 -0300 (ADT) Received: from localhost (localhost.dmi.dk [127.0.0.1]) by mailgw.dmi.dk (8.12.11/8.12.11/Debian-1) with ESMTP id j4B8Kbx6008222; Wed, 11 May 2005 08:20:37 GMT Received: from mailgw.dmi.dk ([127.0.0.1]) by localhost (mailgw.dmi.dk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 08024-10; Wed, 11 May 2005 08:20:27 +0000 (GMT) Received: from postoffice.dmi.dk (postoffice.dmi.dk [130.226.64.60]) by mailgw.dmi.dk (8.12.11/8.12.11/Debian-1) with ESMTP id j4B8KQbc008217; Wed, 11 May 2005 08:20:26 GMT Received: from [130.226.66.16] (anders [130.226.66.16]) by postoffice.dmi.dk (Postfix) with ESMTP id 121E91802E; Wed, 11 May 2005 08:20:26 +0000 (GMT) Message-ID: <4281C049.4080007@dmi.dk> Date: Wed, 11 May 2005 10:20:25 +0200 From: Kim Bisgaard User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: John A Meinel Cc: pgsql-performance@postgresql.org Subject: Re: full outer performance problem References: <428078E6.90007@dmi.dk> <4280C526.3070609@arbash-meinel.com> In-Reply-To: <4280C526.3070609@arbash-meinel.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-maia-1.0.0-rc5 (Debian) at dmi.dk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.033 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/287 X-Sequence-Number: 12451 Hi, Look for my comments further down... John A Meinel wrote: > Kim Bisgaard wrote: > >> Hi, >> >> I'm having problems with the query optimizer and FULL OUTER JOIN on >> PostgreSQL 7.4. I cannot get it to use my indexes with full outer joins. >> I might be naive, but I think that it should be possible? >> >> I have two BIG tables (virtually identical) with 3 NOT NULL columns >> Station_id, TimeObs, Temp_XXXX, with indexes on (Station_id, TimeObs) >> and valid ANALYSE (set statistics=100). I want to join the two tables >> with a FULL OUTER JOIN. >> >> When I specify the query as: >> >> select temp_max_60min,temp_dry_at_2m >> from station s natural join >> temp_dry_at_2m a full outer join temp_max_60min b using (station_id, >> timeobs) >> where s.wmo_id=6065 >> and timeobs='2004-1-1 0:0:0' >> and '2004-1-1 0:0:0' between s.startdate and s.enddate; >> >> I get the correct results, BUT LOUSY performance, and the following >> explain: >> >> Nested Loop Left Join (cost=5.84..163484.08 rows=1349 width=12) >> (actual time=66146.815..119005.381 rows=1 loops=1) >> Filter: (COALESCE("outer".timeobs, "inner".timeobs) = '2004-01-01 >> 00:00:00'::timestamp without time zone) >> -> Hash Join (cost=5.84..155420.24 rows=1349 width=16) (actual >> time=8644.449..110836.038 rows=109826 loops=1) > > > Well, the estimate here is quite a bit off. It thinks you will be > getting 1349 (which is probably why it picked a nested loop plan), but > then it is getting 109826 rows. > I'm guessing it is misunderstanding the selectivity of the timeobs > column. I think you are right.. > >> Hash Cond: ("outer".station_id = "inner".station_id) >> -> Seq Scan on temp_dry_at_2m a (cost=0.00..120615.94 >> rows=6956994 width=16) (actual time=0.024..104548.515 rows=6956994 >> loops=1) >> -> Hash (cost=5.84..5.84 rows=1 width=4) (actual >> time=0.114..0.114 rows=0 loops=1) >> -> Index Scan using wmo_idx on station >> (cost=0.00..5.84 rows=1 width=4) (actual time=0.105..0.108 rows=1 >> loops=1) >> Index Cond: ((wmo_id = 6065) AND ('2004-01-01 >> 00:00:00'::timestamp without time zone >= startdate) AND ('2004-01-01 >> 00:00:00'::timestamp without time zone <= enddate)) >> -> Index Scan using temp_max_60min_idx on temp_max_60min b >> (cost=0.00..5.96 rows=1 width=20) (actual time=0.071..0.071 rows=0 >> loops=109826) >> Index Cond: (("outer".station_id = b.station_id) AND >> ("outer".timeobs = b.timeobs)) >> Total runtime: 119005.499 ms >> (11 rows) > > > I think the bigger problem is that a full outer join says grab all rows, > even if they are null. > > What about this query: > SELECT temp_max_60min,temp_dry_at_2m > FROM (station s LEFT JOIN temp_dry_at_2m a USING (station_id, timeobs) > LEFT JOIN temp_max_60min b USING (station_id, timeobs) > where s.wmo_id=6065 > and timeobs='2004-1-1 0:0:0' > and '2004-1-1 0:0:0' between s.startdate and s.enddate; This works very well, and gives the correct result - thanks!! > > After that, you should probably have a multi-column index on > (station_id, timeobs), which lets postgres use just that index for the > lookup, rather than using an index and then a filter. (Looking at your > next query you might already have that index). Yes I have. > >> >> If I change the query to (and thus negates the full outer join): > > > This is the same query, I think you messed up your copy and paste. Nope. Changed "and timeobs='2004-1-1 0:0:0' " to "and a.timeobs='2004-1-1 0:0:0' and b.timeobs='2004-1-1 0:0:0' " > >> >> select temp_max_60min,temp_dry_at_2m >> from station s natural join >> temp_dry_at_2m a full outer join temp_max_60min b using (station_id, >> timeobs) >> where s.wmo_id=6065 >> and _a.timeobs='2004-1-1 0:0:0' and b._timeobs='2004-1-1 0:0:0' >> and '2004-1-1 0:0:0' between s.startdate and s.enddate; >> >> >> I get wrong results (In the case where one of the records is missing in >> one of the tables), BUT GOOD performance, and this query plan: >> >> Nested Loop (cost=0.00..17.83 rows=1 width=12) (actual >> time=79.221..79.236 rows=1 loops=1) >> -> Nested Loop (cost=0.00..11.82 rows=1 width=24) (actual >> time=65.517..65.526 rows=1 loops=1) >> -> Index Scan using wmo_idx on station (cost=0.00..5.83 >> rows=1 width=4) (actual time=0.022..0.026 rows=1 loops=1) >> Index Cond: ((wmo_id = 6065) AND ('2004-01-01 >> 00:00:00'::timestamp without time zone >= startdate) AND ('2004-01-01 >> 00:00:00'::timestamp without time zone <= enddate)) >> -> Index Scan using temp_max_60min_idx on temp_max_60min b >> (cost=0.00..5.97 rows=1 width=20) (actual time=65.483..65.486 rows=1 >> loops=1) >> Index Cond: (("outer".station_id = b.station_id) AND >> (b.timeobs = '2004-01-01 00:00:00'::timestamp without time zone)) >> -> Index Scan using temp_dry_at_2m_idx on temp_dry_at_2m a >> (cost=0.00..6.00 rows=1 width=16) (actual time=13.694..13.698 rows=1 >> loops=1) >> Index Cond: (("outer".station_id = a.station_id) AND >> (a.timeobs = '2004-01-01 00:00:00'::timestamp without time zone)) >> Total runtime: 79.340 ms >> (9 rows) >> >> >> If further info like EXPLAIN VERBOSE is useful please say so and I will >> provide it. >> >> Thanks in advance! >> Kim Bisgaard. > > > I still feel like you will have a problem with an outer join in this > circumstance, because it will have to scan all of both tables. Maybe I misunderstand outer joins but since there are no rows with NULLs, I think it is a matter of finding the rows that are there or makeing one up one if there are no rows? > > I think what you are wanting is "give me everything where station_id = > X, and there is a row in either a or b". > I think my LEFT JOIN example does that, but I also think there would be > a subselect form which would work, which might do better. Something like: > > SELECT temp_max_60min,temp_dry_at_2m > FROM (SELECT station_id, timeobs FROM station s > WHERE s.wmo_id=6065 > AND timeobs = '2004-1-1 0:0:0' > AND '2004-1-1 0:0:0' BETWEEN s.startdate AND s.enddate > ) AS s > JOIN (SELECT temp_max_60min, temp_dry_at_2m > FROM temp_dry_at_2m a > FULL OUTER JOIN temp_max_60min b > USING (station_id, timeobs) > WHERE station_id = s.station_id > AND timeobs = '2004-1-1 0:0:0' > ) > ; > > If I did this correctly, you should have a very restrictive scan done on > station, which only returns a few rows based on timeobs & station_id. > But it might be better to turn that final FULL OUTER JOIN into 2 LEFT > JOINs like I did the first time: > > SELECT temp_max_60min,temp_dry_at_2m > FROM (SELECT station_id, timeobs FROM station s > WHERE s.wmo_id=6065 > AND timeobs = '2004-1-1 0:0:0' > AND '2004-1-1 0:0:0' BETWEEN s.startdate AND s.enddate > ) AS s > LEFT JOIN temp_dry_at_2m a USING (station_id, timeobs) > LEFT JOIN temp_max_60min b USING (station_id, timeobs) > ; > > I would hope postgres could do this from just my earlier plan. And I > hope I understand what you want, such that 2 LEFT JOINS work better than > your FULL OUTER JOIN. If you only want rows where one of both temp_dry > or temp_max exist, you probably could just add the line: > > WHERE (temp_max_60_min IS NOT NULL OR temp_dry_at_2m IS NOT NULL) Thanks John. You have opened my eyes for a new way to formulate my queries! > > > John > =:-> -- Kim Bisgaard Computer Department Phone: +45 3915 7562 (direct) Danish Meteorological Institute Fax: +45 3915 7460 (division) From pgsql-performance-owner@postgresql.org Wed May 11 05:35:21 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E8C9854A31 for ; Wed, 11 May 2005 05:35:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66059-05 for ; Wed, 11 May 2005 08:35:10 +0000 (GMT) Received: from gw2.emini.dk (gw2.emini.dk [192.38.9.232]) by svr1.postgresql.org (Postfix) with ESMTP id 7DD2A5296E for ; Wed, 11 May 2005 05:35:08 -0300 (ADT) Received: from palestine (palestine.intra.emini.dk [10.0.0.18]) by gw2.emini.dk (Postfix) with SMTP id EAFBD6A12D for ; Wed, 11 May 2005 10:34:45 +0200 (CEST) Message-ID: <001f01c55604$494d2e60$1200000a@intra.emini.dk> From: "Edin Kadribasic" To: Subject: Optimizer wrongly picks Nested Loop Left Join Date: Wed, 11 May 2005 10:34:45 +0200 Organization: Emini ApS 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.1478 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/194 X-Sequence-Number: 12358 Hi, I have a query that is giving the optimizer (and me) great headache. When its in the good mood the optimizer chooses Hash Left Join and the query executes in 13ms or so, but sometimes (more and more often) it chooses Nested Loop Left Join and the execution time goes up to 2-30sec. The query: SELECT COUNT(DISTINCT a.tid) FROM axp_temp_order_match a LEFT OUTER JOIN ( SELECT ol.tid, ds.orid FROM axp_dayschedule ds JOIN axp_order_line ol ON ol.olid = ds.olid JOIN axp_order o ON ds.orid = o.orid WHERE o.status >= 100 AND ds.day between '2005-05-12' and '2005-05-12' AND ds.used = '1' ) b ON (a.tid = b.tid) WHERE b.tid IS NULL AND a.sid = 16072; Good plan: ========= Aggregate (cost=221.93..221.93 rows=1 width=4) (actual time=34.262..34.266 rows=1 loops=1) -> Hash Left Join (cost=9.07..220.86 rows=426 width=4) (actual time=34.237..34.237 rows=0 loops=1) Hash Cond: ("outer".tid = "inner".tid) Filter: ("inner".tid IS NULL) -> Index Scan using axp_temp_order_match_idx1 on axp_temp_order_match a (cost=0.00..209.65 rows=426 width=4) (actual time=0.277..0.512 rows=6 loops=1) Index Cond: (sid = 16072) -> Hash (cost=9.07..9.07 rows=1 width=4) (actual time=32.777..32.777 rows=0 loops=1) -> Nested Loop (cost=0.00..9.07 rows=1 width=4) (actual time=0.208..31.563 rows=284 loops=1) -> Nested Loop (cost=0.00..6.05 rows=1 width=4) (actual time=0.178..20.684 rows=552 loops=1) -> Index Scan using axp_dayschedule_day_idx on axp_dayschedule ds (cost=0.00..3.02 rows=1 width=8) (actual time=0.036..3.973 rows=610 loops=1) Index Cond: (("day" >= '2005-05-12'::date) AND ("day" <= '2005-05-12'::date)) Filter: (used = B'1'::"bit") -> Index Scan using axp_order_orid_key on axp_order o (cost=0.00..3.02 rows=1 width=4) (actual time=0.009..0.013 rows=1 loops=610) Index Cond: ("outer".orid = o.orid) Filter: (status >= 100) -> Index Scan using axp_order_line_pk on axp_order_line ol (cost=0.00..3.01 rows=1 width=8) (actual time=0.006..0.008 rows=1 loops=552) Index Cond: (ol.olid = "outer".olid) Total runtime: 34.581 ms Bad plan (same query different values): ======================================= Aggregate (cost=11.54..11.54 rows=1 width=4) (actual time=11969.281..11969.285 rows=1 loops=1) -> Nested Loop Left Join (cost=0.00..11.53 rows=1 width=4) (actual time=25.730..11967.180 rows=338 loops=1) Join Filter: ("outer".tid = "inner".tid) Filter: ("inner".tid IS NULL) -> Index Scan using axp_temp_order_match_idx1 on axp_temp_order_match a (cost=0.00..2.45 rows=1 width=4) (actual time=0.027..2.980 rows=471 loops=1) Index Cond: (sid = 16092) -> Nested Loop (cost=0.00..9.07 rows=1 width=4) (actual time=0.088..24.350 rows=285 loops=471) -> Nested Loop (cost=0.00..6.04 rows=1 width=8) (actual time=0.067..15.649 rows=317 loops=471) -> Index Scan using axp_dayschedule_day_idx on axp_dayschedule ds (cost=0.00..3.02 rows=1 width=8) (actual time=0.015..3.557 rows=606 loops=471) Index Cond: (("day" >= '2005-05-13'::date) AND ("day" <= '2005-05-13'::date)) Filter: (used = B'1'::"bit") -> Index Scan using axp_order_line_pk on axp_order_line ol (cost=0.00..3.01 rows=1 width=8) (actual time=0.006..0.008 rows=1 loops=285426) Index Cond: (ol.olid = "outer".olid) -> Index Scan using axp_order_orid_key on axp_order o (cost=0.00..3.02 rows=1 width=4) (actual time=0.009..0.013 rows=1 loops=149307) Index Cond: ("outer".orid = o.orid) Filter: (status >= 100) Total runtime: 11969.443 ms Please note that sometimes when I get "bad plan" in the logfile, I just re-run the query and the optimizer chooses the more efficient one. Sometime it does not. Any ideas? postgresql-8.0.2 on 2x3.2 GHz Xeon with 2GB ram Linux 2.6 shared_buffers = 15000 work_mem = 128000 effective_cache_size = 200000 random_page_cost = (tried 1.0 - 4, seemingly without effect on this particular issue). Edin From pgsql-performance-owner@postgresql.org Wed May 11 05:40:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C874052A43 for ; Wed, 11 May 2005 05:40:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67086-04 for ; Wed, 11 May 2005 08:40:04 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id 4B7895296E for ; Wed, 11 May 2005 05:40:02 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-2.tower-49.messagelabs.com!1115800802!1419549!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 8377 invoked from network); 11 May 2005 08:40:02 -0000 Received: from mail.advfn.com (212.161.99.149) by server-2.tower-49.messagelabs.com with SMTP; 11 May 2005 08:40:02 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DVml7-0008Kq-TR; Wed, 11 May 2005 09:40:01 +0100 In-Reply-To: <1115795780.3830.264.camel@localhost.localdomain> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115795780.3830.264.camel@localhost.localdomain> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Partitioning / Clustering Date: Wed, 11 May 2005 09:40:00 +0100 To: Simon Riggs X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/195 X-Sequence-Number: 12359 On 11 May 2005, at 08:16, Simon Riggs wrote: > On Tue, 2005-05-10 at 11:03 +0100, Alex Stapleton wrote: > >> So, when/is PG meant to be getting a decent partitioning system? >> > > ISTM that your question seems to confuse where code comes from. > Without > meaning to pick on you, or reply rudely, I'd like to explore that > question. Perhaps it should be a FAQ entry. > > All code is written by someone, and those people need to eat. Some > people are fully or partly funded to perform their tasks on this > project > (coding, patching, etc). Others contribute their time for a variety of > reasons where involvement has a positive benefit. > > You should ask these questions: > - Is anyone currently working on (Feature X)? > - If not, Can I do it myself? > - If not, and I still want it, can I fund someone else to build it for > me? > > Asking "when is Feature X going to happen" is almost certainly > going to > get the answer "never" otherwise, if the initial development is large > and complex. There are many TODO items that have lain untouched for > years, even though adding the feature has been discussed and agreed. > > Best Regards, Simon Riggs > Acceptable Answers to 'So, when/is PG meant to be getting a decent partitioning system?': 1. Person X is working on it I believe. 2. It's on the list, but nobody has done anything about it yet 3. Your welcome to take a stab at it, I expect the community would support your efforts as well. 4. If you have a huge pile of money you could probably buy the Moon. Thinking along those lines, you can probably pay someone to write it for you. 5. It's a stupid idea, and it's never going to work, and heres why.............. Unacceptable Answers to the same question: 1. Yours. Be more helpful, and less arrogant please. Everyone else who has contributed to this thread has been very helpful in clarifying the state of affairs and pointing out what work is and isn't being done, and alternatives to just waiting for PG do it for you. > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend > > From pgsql-performance-owner@postgresql.org Wed May 11 05:50:58 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8FC7052A6B for ; Wed, 11 May 2005 05:50:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69438-05 for ; Wed, 11 May 2005 08:50:54 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id 7481A5296E for ; Wed, 11 May 2005 05:50:53 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-11.tower-49.messagelabs.com!1115801437!1214738!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 10082 invoked from network); 11 May 2005 08:50:37 -0000 Received: from mail.advfn.com (212.161.99.149) by server-11.tower-49.messagelabs.com with SMTP; 11 May 2005 08:50:37 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DVmvN-0001Cz-1J; Wed, 11 May 2005 09:50:37 +0100 In-Reply-To: <1115798277.29223.233869472@webmail.messagingengine.com> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115798277.29223.233869472@webmail.messagingengine.com> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <3F94C2F9-29D9-46F6-A873-3681B4F3E379@advfn.com> Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Partitioning / Clustering Date: Wed, 11 May 2005 09:50:34 +0100 To: "David Roussel" X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/196 X-Sequence-Number: 12360 On 11 May 2005, at 08:57, David Roussel wrote: > For an interesting look at scalability, clustering, caching, etc for a > large site have a look at how livejournal did it. > http://www.danga.com/words/2004_lisa/lisa04.pdf I have implemented similar systems in the past, it's a pretty good technique, unfortunately it's not very "Plug-and-Play" as you have to base most of your API on memcached (I imagine MySQLs NDB tables might work as well actually) for it to work well. > They have 2.6 Million active users, posting 200 new blog entries per > minute, plus many comments and countless page views. > > Although this system is of a different sort to the type I work on it's > interesting to see how they've made it scale. > > They use mysql on dell hardware! And found single master > replication did > not scale. There's a section on multimaster replication, not sure if > they use it. The main approach they use is to parition users into > spefic database clusters. Caching is done using memcached at the > application level to avoid hitting the db for rendered pageviews I don't think they are storing pre-rendered pages (or bits of) in memcached, but are principally storing the data for the pages in it. Gluing pages together is not a hugely intensive process usually :) The only problem with memcached is that the clients clustering/ partitioning system will probably break if a node dies, and probably get confused if you add new nodes onto it as well. Easily extensible clustering (no complete redistribution of data required when you add/ remove nodes) with the data distributed across nodes seems to be nothing but a pipe dream right now. > It's interesting that the solution livejournal have arrived at is > quite > similar in ways to the way google is set up. Don't Google use indexing servers which keep track of where data is? So that you only need to update them when you add or move data, deletes don't even have to be propagated among indexes immediately really because you'll find out if data isn't there when you visit where it should be. Or am I talking crap? > David > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend > > From pgsql-performance-owner@postgresql.org Wed May 11 06:04:03 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E73A953F80 for ; Wed, 11 May 2005 06:03:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69093-06 for ; Wed, 11 May 2005 09:03:47 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id 33FD25296E for ; Wed, 11 May 2005 06:03:46 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-15.tower-49.messagelabs.com!1115802228!1196387!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 18906 invoked from network); 11 May 2005 09:03:48 -0000 Received: from mail.advfn.com (212.161.99.149) by server-15.tower-49.messagelabs.com with SMTP; 11 May 2005 09:03:48 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DVn87-0002zu-Df; Wed, 11 May 2005 10:03:47 +0100 In-Reply-To: <3F94C2F9-29D9-46F6-A873-3681B4F3E379@advfn.com> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115798277.29223.233869472@webmail.messagingengine.com> <3F94C2F9-29D9-46F6-A873-3681B4F3E379@advfn.com> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <57AE769C-381F-4757-95FB-409001758AB6@advfn.com> Cc: "David Roussel" , pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Partitioning / Clustering Date: Wed, 11 May 2005 10:03:45 +0100 To: Alex Stapleton X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/197 X-Sequence-Number: 12361 On 11 May 2005, at 09:50, Alex Stapleton wrote: > > On 11 May 2005, at 08:57, David Roussel wrote: > > >> For an interesting look at scalability, clustering, caching, etc >> for a >> large site have a look at how livejournal did it. >> http://www.danga.com/words/2004_lisa/lisa04.pdf >> > > I have implemented similar systems in the past, it's a pretty good > technique, unfortunately it's not very "Plug-and-Play" as you have > to base most of your API on memcached (I imagine MySQLs NDB tables > might work as well actually) for it to work well. > > >> They have 2.6 Million active users, posting 200 new blog entries per >> minute, plus many comments and countless page views. >> >> Although this system is of a different sort to the type I work on >> it's >> interesting to see how they've made it scale. >> >> They use mysql on dell hardware! And found single master >> replication did >> not scale. There's a section on multimaster replication, not sure if >> they use it. The main approach they use is to parition users into >> spefic database clusters. Caching is done using memcached at the >> application level to avoid hitting the db for rendered pageviews >> > > I don't think they are storing pre-rendered pages (or bits of) in > memcached, but are principally storing the data for the pages in > it. Gluing pages together is not a hugely intensive process usually :) > The only problem with memcached is that the clients clustering/ > partitioning system will probably break if a node dies, and > probably get confused if you add new nodes onto it as well. Easily > extensible clustering (no complete redistribution of data required > when you add/remove nodes) with the data distributed across nodes > seems to be nothing but a pipe dream right now. > > >> It's interesting that the solution livejournal have arrived at is >> quite >> similar in ways to the way google is set up. >> > > Don't Google use indexing servers which keep track of where data > is? So that you only need to update them when you add or move data, > deletes don't even have to be propagated among indexes immediately > really because you'll find out if data isn't there when you visit > where it should be. Or am I talking crap? That will teach me to RTFA first ;) Ok so LJ maintain an index of which cluster each user is on, kinda of like google do :) > >> David >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 8: explain analyze is your friend >> >> >> > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > > From pgsql-performance-owner@postgresql.org Wed May 11 06:12:45 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 273A753D71 for ; Wed, 11 May 2005 06:12:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69498-07 for ; Wed, 11 May 2005 09:12:41 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id CF5AD5296E for ; Wed, 11 May 2005 06:12:37 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id EB56924FE1; Wed, 11 May 2005 17:12:36 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id DD14824FE0; Wed, 11 May 2005 17:12:36 +0800 (WST) Message-ID: <4281CCC7.5050405@familyhealth.com.au> Date: Wed, 11 May 2005 17:13:43 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alex Stapleton Cc: Simon Riggs , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115795780.3830.264.camel@localhost.localdomain> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.067 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/198 X-Sequence-Number: 12362 > Acceptable Answers to 'So, when/is PG meant to be getting a decent > partitioning system?': > > 1. Person X is working on it I believe. > 2. It's on the list, but nobody has done anything about it yet > 3. Your welcome to take a stab at it, I expect the community would > support your efforts as well. > 4. If you have a huge pile of money you could probably buy the > Moon. Thinking along those lines, you can probably pay someone to write > it for you. > 5. It's a stupid idea, and it's never going to work, and heres > why.............. > > Unacceptable Answers to the same question: > > 1. Yours. > > Be more helpful, and less arrogant please. Everyone else who has > contributed to this thread has been very helpful in clarifying the > state of affairs and pointing out what work is and isn't being done, > and alternatives to just waiting for PG do it for you. Please YOU be more helpful and less arrogant. I thought your inital email was arrogant, demanding and insulting. Your followup email has done nothing to dispel my impression. Simon (one of PostgreSQL's major contributors AND one of the very few people working on partitioning in PostgreSQL, as you requested) told you all the reasons clearly and politely. Chris From pgsql-performance-owner@postgresql.org Wed May 11 09:46:09 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AF8BE54B1B for ; Wed, 11 May 2005 09:46:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02638-04 for ; Wed, 11 May 2005 12:46:04 +0000 (GMT) Received: from thor.netera.se (thor.netera.se [85.112.172.11]) by svr1.postgresql.org (Postfix) with ESMTP id 2039F54B1A for ; Wed, 11 May 2005 09:45:59 -0300 (ADT) Received: from [192.168.2.240] (1-1-1-41a.o.sth.bostream.se [81.26.246.14]) by thor.netera.se (Postfix) with ESMTP id D53D413AC07A; Wed, 11 May 2005 14:45:58 +0200 (CEST) Message-ID: <4281FEE3.6080506@relevanttraffic.se> Date: Wed, 11 May 2005 14:47:31 +0200 From: Ulrich Wisser Organization: Relevant Traffic AB User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dan Harris Cc: pgsql-performance@postgresql.org Subject: Re: Query tuning help References: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> In-Reply-To: <924ac6c029f5453c442eacdda06b132c@drivefaster.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/199 X-Sequence-Number: 12363 Hi Dan, I tried to understand your query, but I couldn't get my understanding of the query and your description in sync. Why do you use sub selects? Wouldn't a simple "recordtext like '%RED%'" do the trick too? You combine all your where conditions with and. To me this looks like you get only rows with RED and CORVETTE. From your description I would rewrite the query as explain analyze select distinct em.incidentid, ea.recordtext as retdata, eg.long, eg.lat from ea join em using(incidentid) join eg using(incidentid) where em.entrydate >= '2005-1-1 00:00'::date and em.entrydate <= '2005-5-9 00:00'::date and ( recordtext like '%RED%' or recordtext like '%CORVETTE%' ) order by em.entrydate That should give you all rows containing one of the words. Does it work? Is is faster? Is it fast enough? Ulrich From pgsql-performance-owner@postgresql.org Wed May 11 10:28:03 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 796D453699 for ; Wed, 11 May 2005 10:28:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08447-06 for ; Wed, 11 May 2005 13:27:55 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A469D53223 for ; Wed, 11 May 2005 10:27:54 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4BDRvCk003211; Wed, 11 May 2005 09:27:58 -0400 (EDT) To: Mischa Sandberg Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering In-reply-to: <1115777953.42816ba1b4618@webmail.telus.net> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <4280C801.80603@arbash-meinel.com> <1115762155.42812deb506d7@webmail.telus.net> <20050510221554.GR31103@decibel.org> <1115777953.42816ba1b4618@webmail.telus.net> Comments: In-reply-to Mischa Sandberg message dated "Tue, 10 May 2005 19:19:13 -0700" Date: Wed, 11 May 2005 09:27:57 -0400 Message-ID: <3210.1115818077@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/200 X-Sequence-Number: 12364 Mischa Sandberg writes: > So, simplicity dictates something like: > table pg_remote(schemaname text, connectby text, remoteschema text) Previous discussion of this sort of thing concluded that we wanted to follow the SQL-MED standard. regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 11 10:46:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DB55A54B61 for ; Wed, 11 May 2005 10:46:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11310-06 for ; Wed, 11 May 2005 13:46:15 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 88C9B53C62 for ; Wed, 11 May 2005 10:46:12 -0300 (ADT) Received: from 216-154-12-152.dsl.look.ca (216-154-12-152.dsl.look.ca [216.154.12.152]) by tht.net (Postfix) with ESMTP id 021B276A22; Wed, 11 May 2005 09:43:23 -0400 (EDT) Subject: Re: Prefetch From: Rod Taylor To: Christopher Kings-Lynne Cc: pgsql-performance@postgresql.org, molson@oceanconsulting.com, Sam Vilain In-Reply-To: <42818FB1.4060403@familyhealth.com.au> References: <200505100652.51401.molson@oceanconsulting.com> <42818B2E.8060403@vilain.net> <42818FB1.4060403@familyhealth.com.au> Content-Type: text/plain Date: Wed, 11 May 2005 09:42:30 -0400 Message-Id: <1115818950.725.6.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/201 X-Sequence-Number: 12365 On Wed, 2005-05-11 at 12:53 +0800, Christopher Kings-Lynne wrote: > > Another trick you can use with large data sets like this when you want > > results > > back in seconds is to have regularly updated tables that aggregate the data > > along each column normally aggregated against the main data set. > > > Maybe some bright person will prove me wrong by posting some working > > information about how to get these apparently absent features working. > > Most people just use simple triggers to maintain aggregate summary tables... Agreed. I've also got a view which calls a function that will 1) use the summary table where data exists, or 2) calculate the summary information, load it into summary table, and send a copy to the client (partial query results cache). It's not all nicely abstracted behind user friendly syntax, but most of those features can be cobbled together (with effort) in PostgreSQL. -- From pgsql-general-owner@postgresql.org Wed May 11 10:57:31 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A86254B5A; Wed, 11 May 2005 10:57:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14147-01; Wed, 11 May 2005 13:57:21 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8FC3A53225; Wed, 11 May 2005 10:57:20 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4BDv84u003486; Wed, 11 May 2005 09:57:08 -0400 (EDT) To: Neil Conway Cc: Greg Stark , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <428209BA.8070907@samurai.com> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> <428209BA.8070907@samurai.com> Comments: In-reply-to Neil Conway message dated "Wed, 11 May 2005 23:33:46 +1000" Date: Wed, 11 May 2005 09:57:07 -0400 Message-ID: <3485.1115819827@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/559 X-Sequence-Number: 77907 Neil Conway writes: > Greg Stark wrote: >> What if the hash index stored *only* the hash code? > Attached is a WIP patch that implements this. Performance? > I'm posting mainly because I wasn't sure what to do to avoid false > positives in the case of hash collisions. In the hash AM code it is > somewhat awkward to fetch the pointed-to heap tuple and recheck the > scankey.[1] I just did the first thing that came to mind -- I marked all > the hash AM opclasses as "lossy", so the index qual is rechecked. This > works, but suggestions for a better way to do things would be welcome. AFAICS that's the *only* way to do it. I disagree completely with the idea of forcing this behavior for all datatypes. It could only be sensible for fairly wide values; you don't save enough to justify the lossiness otherwise. It would be interesting to look into whether it could be driven on a per-opclass basis. Then you could have, eg, "text_lossy_hash_ops" as a non-default opclass the DBA could select if he wanted this behavior. (The code could perhaps use the amopreqcheck flag to tell it which way to behave.) If that seems unworkable, I'd prefer to see us set this up as a new index AM type, which would share a lot of code with the old. [ BTW, posting patches to pgsql-general seems pretty off-topic. ] regards, tom lane From pgsql-general-owner@postgresql.org Wed May 11 10:59:23 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8CF7D54CF8; Wed, 11 May 2005 10:59:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13853-06; Wed, 11 May 2005 13:59:20 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 0349D54CD6; Wed, 11 May 2005 10:59:19 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DVrjt-0007jS-00; Wed, 11 May 2005 09:59:05 -0400 To: Neil Conway Cc: Greg Stark , Tom Lane , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> <428209BA.8070907@samurai.com> In-Reply-To: <428209BA.8070907@samurai.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 11 May 2005 09:59:05 -0400 Message-ID: <87d5rxrhhy.fsf@stark.xeocode.com> Lines: 17 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/560 X-Sequence-Number: 77908 Neil Conway writes: > I'm posting mainly because I wasn't sure what to do to avoid false positives in > the case of hash collisions. In the hash AM code it is somewhat awkward to > fetch the pointed-to heap tuple and recheck the scankey.[1] I just did the > first thing that came to mind -- I marked all the hash AM opclasses as "lossy", > so the index qual is rechecked. This works, but suggestions for a better way to > do things would be welcome. I would have thought that would be the only way worth considering. Consider for example a query involving two or more hash indexes and the new bitmap indexscan plan. You don't want to fetch the tuples if you can eliminate them using one of the other indexes. -- greg From pgsql-performance-owner@postgresql.org Wed May 11 11:09:28 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F157A53250 for ; Wed, 11 May 2005 11:09:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15655-09 for ; Wed, 11 May 2005 14:09:18 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id DBE9054C4C for ; Wed, 11 May 2005 11:09:15 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4BE8wl5007482; (envelope-from ) Wed, 11 May 2005 09:09:14 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4BE4qT7025827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Wed, 11 May 2005 09:04:53 -0500 (CDT) Message-ID: <428210FF.4090302@arbash-meinel.com> Date: Wed, 11 May 2005 09:04:47 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Edin Kadribasic Cc: pgsql-performance@postgresql.org Subject: Re: Optimizer wrongly picks Nested Loop Left Join References: <001f01c55604$494d2e60$1200000a@intra.emini.dk> In-Reply-To: <001f01c55604$494d2e60$1200000a@intra.emini.dk> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig4F547C4B29B910CD641AF3FF" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/204 X-Sequence-Number: 12368 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig4F547C4B29B910CD641AF3FF Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Edin Kadribasic wrote: > Hi, > > > I have a query that is giving the optimizer (and me) great headache. When > its in the good mood the optimizer chooses Hash Left Join and the query > executes in 13ms or so, but sometimes (more and more often) it chooses > Nested Loop Left Join and the execution time goes up to 2-30sec. > > The query: > SELECT COUNT(DISTINCT a.tid) FROM axp_temp_order_match a LEFT OUTER JOIN ( > SELECT ol.tid, ds.orid FROM axp_dayschedule ds JOIN axp_order_line ol ON > ol.olid = ds.olid JOIN axp_order o ON ds.orid = o.orid WHERE o.status >= 100 > AND ds.day between '2005-05-12' and '2005-05-12' AND ds.used = '1' ) b ON > (a.tid = b.tid) WHERE b.tid IS NULL AND a.sid = 16072; > Unfortunately, because Hash Join doesn't report the number of rows (rows=0 always), it's hard to tell how good the estimator is. But I *can* say that the NestLoop estimation is way off. > > Good plan: > ========= > Aggregate (cost=221.93..221.93 rows=1 width=4) (actual time=34.262..34.266 > rows=1 loops=1) > -> Hash Left Join (cost=9.07..220.86 rows=426 width=4) (actual > time=34.237..34.237 rows=0 loops=1) > Hash Cond: ("outer".tid = "inner".tid) > Filter: ("inner".tid IS NULL) > -> Index Scan using axp_temp_order_match_idx1 on > axp_temp_order_match a (cost=0.00..209.65 rows=426 width=4) (actual > time=0.277..0.512 rows=6 loops=1) > Index Cond: (sid = 16072) > -> Hash (cost=9.07..9.07 rows=1 width=4) (actual > time=32.777..32.777 rows=0 loops=1) > -> Nested Loop (cost=0.00..9.07 rows=1 width=4) (actual > time=0.208..31.563 rows=284 loops=1) > -> Nested Loop (cost=0.00..6.05 rows=1 width=4) > (actual time=0.178..20.684 rows=552 loops=1) > -> Index Scan using axp_dayschedule_day_idx on > axp_dayschedule ds (cost=0.00..3.02 rows=1 width=8) (actual > time=0.036..3.973 rows=610 loops=1) > Index Cond: (("day" >= '2005-05-12'::date) > AND ("day" <= '2005-05-12'::date)) > Filter: (used = B'1'::"bit") > -> Index Scan using axp_order_orid_key on > axp_order o (cost=0.00..3.02 rows=1 width=4) (actual time=0.009..0.013 > rows=1 loops=610) > Index Cond: ("outer".orid = o.orid) > Filter: (status >= 100) > -> Index Scan using axp_order_line_pk on > axp_order_line ol (cost=0.00..3.01 rows=1 width=8) (actual > time=0.006..0.008 rows=1 loops=552) > Index Cond: (ol.olid = "outer".olid) > Total runtime: 34.581 ms > > Bad plan (same query different values): > ======================================= > Aggregate (cost=11.54..11.54 rows=1 width=4) (actual > time=11969.281..11969.285 rows=1 loops=1) > -> Nested Loop Left Join (cost=0.00..11.53 rows=1 width=4) (actual > time=25.730..11967.180 rows=338 loops=1) See here, it thinks it will only have to do 1 nestloop, which would be quite fast, but it hast to do 338. > Join Filter: ("outer".tid = "inner".tid) > Filter: ("inner".tid IS NULL) > -> Index Scan using axp_temp_order_match_idx1 on > axp_temp_order_match a (cost=0.00..2.45 rows=1 width=4) (actual > time=0.027..2.980 rows=471 loops=1) > Index Cond: (sid = 16092) > -> Nested Loop (cost=0.00..9.07 rows=1 width=4) (actual > time=0.088..24.350 rows=285 loops=471) Same thing here. > -> Nested Loop (cost=0.00..6.04 rows=1 width=8) (actual > time=0.067..15.649 rows=317 loops=471) And here. > -> Index Scan using axp_dayschedule_day_idx on > axp_dayschedule ds (cost=0.00..3.02 rows=1 width=8) (actual > time=0.015..3.557 rows=606 loops=471) This estimate is way off too, but it is off in both plans. > Index Cond: (("day" >= '2005-05-13'::date) AND > ("day" <= '2005-05-13'::date)) > Filter: (used = B'1'::"bit") > -> Index Scan using axp_order_line_pk on > axp_order_line ol (cost=0.00..3.01 rows=1 width=8) (actual > time=0.006..0.008 rows=1 loops=285426) This is probably what is killing you. It is doing a single lookup 285k times. The above plan only does it 552 times. > Index Cond: (ol.olid = "outer".olid) > -> Index Scan using axp_order_orid_key on axp_order o > (cost=0.00..3.02 rows=1 width=4) (actual time=0.009..0.013 rows=1 > loops=149307) > Index Cond: ("outer".orid = o.orid) > Filter: (status >= 100) > Total runtime: 11969.443 ms > > Please note that sometimes when I get "bad plan" in the logfile, I just > re-run the query and the optimizer chooses the more efficient one. Sometime > it does not. You work_mem is quite high relative to your total Ram, hopefully you don't have many allowed concurrent connections. But that is a side point. I assume the tables are freshly VACUUM ANALYZEd. Have you tried altering the statistics for the columns, one of them to look at is axp_dayschedule(day). That one seems to be consistently incorrect. Perhaps because a between with the same date is too restrictive in postgres? I don't really know. Also, looking at the original query, maybe I am missing something, but you are doing a COUNT(DISTINCT) with a LEFT OUTER JOIN. If it is a LEFT JOIN, isn't that the same as SELECT COUNT(DISTINCT a.tid) FROM axp_temp_order_match a WHERE a.sid = 16072; I also have to wonder about: SELECT ... a.tid FROM a LEFT JOIN (...) b ON (a.tid = b.tid) WHERE b.tid IS NULL Isn't that equivalent to SELECT COUNT(DISTINCT a.tid) FROM a WHERE a.tid IS NULL; Which is also equivalent to SELECT CASE WHEN EXISTS (SELECT a.tid FROM a WHERE a.tid IS NULL AND a.sid = 16072) THEN 1 ELSE 0 END; I could be wrong, but if a.tid IS NULL (because b.tid IS NULL, and a.tid = b.tid), DISTINCT can only return 0 or 1 rows, which is the same as using a case statement. You could also put a LIMIT in there, since you know DISTINCT can only return 1 row SELECT COUNT(a.tid) FROM a WHERE a.tid IS NULL AND a.sid = ... LIMIT 1; However, one final point, COUNT(column) where column is NULL doesn't count anything. So really your query can be replaced with: SELECT 0; Now maybe this is a generated query, and under other circumstances it gives a different query which actually is important. The biggest thing is that using a COUNT() and a DISTINCT on a column that is on the left side of a LEFT JOIN, sounds like you can get rid of the entire right side of that join. John =:-> > > Any ideas? > > postgresql-8.0.2 on 2x3.2 GHz Xeon with 2GB ram Linux 2.6 > shared_buffers = 15000 > work_mem = 128000 > effective_cache_size = 200000 > random_page_cost = (tried 1.0 - 4, seemingly without effect on this > particular issue). > > Edin > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match --------------enig4F547C4B29B910CD641AF3FF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCghECJdeBCYSNAAMRAq75AKCgojUX1gl1qjdNtljAtW0elq74GACgo/KB iDh2pGApxkKQLaTXl29SDYM= =cvs/ -----END PGP SIGNATURE----- --------------enig4F547C4B29B910CD641AF3FF-- From pgsql-general-owner@postgresql.org Wed May 11 11:15:04 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F34E854ADF; Wed, 11 May 2005 11:15:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17677-01; Wed, 11 May 2005 14:14:58 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id D536054994; Wed, 11 May 2005 11:14:57 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 2F47318CC14; Wed, 11 May 2005 10:15:02 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 37124-01; Wed, 11 May 2005 10:14:57 -0400 (EDT) Received: from [192.168.0.4] (r220-101-4-60.cpe.unwired.net.au [220.101.4.60]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 1591B18CC15; Wed, 11 May 2005 10:14:53 -0400 (EDT) Message-ID: <4282135A.8000909@samurai.com> Date: Thu, 12 May 2005 00:14:50 +1000 From: Neil Conway User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Greg Stark , "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> <428209BA.8070907@samurai.com> <3485.1115819827@sss.pgh.pa.us> In-Reply-To: <3485.1115819827@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/562 X-Sequence-Number: 77910 Tom Lane wrote: > Performance? I'll run some benchmarks tomorrow, as it's rather late in my time zone. If anyone wants to post some benchmark results, they are welcome to. > I disagree completely with the idea of forcing this behavior for all > datatypes. It could only be sensible for fairly wide values; you don't > save enough to justify the lossiness otherwise. I think it would be premature to decide about this before we see some performance numbers. I'm not fundamentally opposed, though. > [ BTW, posting patches to pgsql-general seems pretty off-topic. ] Not any more than discussing implementation details is :) But your point is well taken, I'll send future patches to -patches. -Neil From pgsql-performance-owner@postgresql.org Wed May 11 11:18:50 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8DDFF54A31 for ; Wed, 11 May 2005 11:18:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18348-02 for ; Wed, 11 May 2005 14:18:39 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7562E533A0 for ; Wed, 11 May 2005 11:18:37 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4BEIY1L003743; Wed, 11 May 2005 10:18:35 -0400 (EDT) To: "Edin Kadribasic" Cc: pgsql-performance@postgresql.org Subject: Re: Optimizer wrongly picks Nested Loop Left Join In-reply-to: <001f01c55604$494d2e60$1200000a@intra.emini.dk> References: <001f01c55604$494d2e60$1200000a@intra.emini.dk> Comments: In-reply-to "Edin Kadribasic" message dated "Wed, 11 May 2005 10:34:45 +0200" Date: Wed, 11 May 2005 10:18:34 -0400 Message-ID: <3742.1115821114@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/206 X-Sequence-Number: 12370 "Edin Kadribasic" writes: > I have a query that is giving the optimizer (and me) great headache. The main problem seems to be that the rowcount estimates for axp_temp_order_match and axp_dayschedule are way off: > -> Index Scan using axp_temp_order_match_idx1 on > axp_temp_order_match a (cost=0.00..209.65 rows=426 width=4) (actual > time=0.277..0.512 rows=6 loops=1) > Index Cond: (sid = 16072) > -> Index Scan using axp_dayschedule_day_idx on > axp_dayschedule ds (cost=0.00..3.02 rows=1 width=8) (actual > time=0.036..3.973 rows=610 loops=1) > Index Cond: (("day" >= '2005-05-12'::date) > AND ("day" <= '2005-05-12'::date)) > Filter: (used = B'1'::"bit") > -> Index Scan using axp_temp_order_match_idx1 on > axp_temp_order_match a (cost=0.00..2.45 rows=1 width=4) (actual > time=0.027..2.980 rows=471 loops=1) > Index Cond: (sid = 16092) > -> Index Scan using axp_dayschedule_day_idx on > axp_dayschedule ds (cost=0.00..3.02 rows=1 width=8) (actual > time=0.015..3.557 rows=606 loops=471) > Index Cond: (("day" >= '2005-05-13'::date) AND > ("day" <= '2005-05-13'::date)) > Filter: (used = B'1'::"bit") Do you ANALYZE these tables on a regular basis? If so, it may be necessary to increase the statistics target to the point where you get better estimates. > Please note that sometimes when I get "bad plan" in the logfile, I just > re-run the query and the optimizer chooses the more efficient one. That's fairly hard to believe, unless you've got autovacuum running in the background. regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 11 11:23:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6829353BE8 for ; Wed, 11 May 2005 11:23:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19013-01 for ; Wed, 11 May 2005 14:23:22 +0000 (GMT) Received: from presinet-main.presinet.com (unknown [209.53.156.1]) by svr1.postgresql.org (Postfix) with ESMTP id 422B453225 for ; Wed, 11 May 2005 11:23:21 -0300 (ADT) Received: from [10.10.1.151] (BRICK [10.10.1.151]) by presinet-main.presinet.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2658.3) id KJAKLXGV; Wed, 11 May 2005 07:20:11 -0700 Message-ID: <42821558.1010707@PresiNET.com> Date: Wed, 11 May 2005 07:23:20 -0700 From: Bricklen Anderson User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christopher Kings-Lynne Cc: Sam Vilain , pgsql-performance@postgresql.org Subject: Re: Prefetch References: <200505100652.51401.molson@oceanconsulting.com> <42818B2E.8060403@vilain.net> <42818FB1.4060403@familyhealth.com.au> In-Reply-To: <42818FB1.4060403@familyhealth.com.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.027 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/207 X-Sequence-Number: 12371 Christopher Kings-Lynne wrote: >> Another trick you can use with large data sets like this when you want >> results >> back in seconds is to have regularly updated tables that aggregate the >> data >> along each column normally aggregated against the main data set. > > >> Maybe some bright person will prove me wrong by posting some working >> information about how to get these apparently absent features working. > > > Most people just use simple triggers to maintain aggregate summary > tables... > > Chris However, if (insert) triggers prove to be too much of a performance hit, try cron'd functions that perform the aggregation for you. This system works well for us, using the pk's (sequence) for start and stop points. -- _______________________________ This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. _______________________________ From pgsql-performance-owner@postgresql.org Wed May 11 12:04:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 586C253BE8 for ; Wed, 11 May 2005 12:04:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25502-03 for ; Wed, 11 May 2005 15:03:52 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 01BFB54A11 for ; Wed, 11 May 2005 12:03:51 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4BF3hu6004086; Wed, 11 May 2005 11:03:43 -0400 (EDT) To: John A Meinel Cc: Edin Kadribasic , pgsql-performance@postgresql.org Subject: Re: Optimizer wrongly picks Nested Loop Left Join In-reply-to: <428210FF.4090302@arbash-meinel.com> References: <001f01c55604$494d2e60$1200000a@intra.emini.dk> <428210FF.4090302@arbash-meinel.com> Comments: In-reply-to John A Meinel message dated "Wed, 11 May 2005 09:04:47 -0500" Date: Wed, 11 May 2005 11:03:43 -0400 Message-ID: <4085.1115823823@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/208 X-Sequence-Number: 12372 John A Meinel writes: > Unfortunately, because Hash Join doesn't report the number of rows > (rows=0 always), it's hard to tell how good the estimator is. This is only a cosmetic problem because you can just look at the number of rows actually emitted by the Hash node's child; that's always exactly the number loaded into the hashtable. (But having said that, it is fixed in CVS tip.) You may be confused though --- the Hash node is not the Hash Join node. A zero report from Hash Join does actually mean that it emitted zero rows. regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 11 12:56:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC10853AD9 for ; Wed, 11 May 2005 12:56:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34808-09 for ; Wed, 11 May 2005 15:56:22 +0000 (GMT) Received: from email.aon.at (warsl404pip7.highway.telekom.at [195.3.96.91]) by svr1.postgresql.org (Postfix) with ESMTP id 5223E53428 for ; Wed, 11 May 2005 12:56:20 -0300 (ADT) Received: (qmail 19957 invoked from network); 11 May 2005 15:56:10 -0000 Received: from m148p020.dipool.highway.telekom.at (HELO PASCAL) ([62.46.8.116]) (envelope-sender ) by smarthub73.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 11 May 2005 15:56:10 -0000 From: Manfred Koizar To: "Jim C. Nasby" Cc: Tom Lane , Dave Held , pgsql-performance@postgresql.org Subject: Re: Sort and index Date: Wed, 11 May 2005 17:59:10 +0200 Message-ID: References: <49E94D0CFCD4DB43AFBA928DDD20C8F9026184B6@asg002.asg.local> <20050420004234.GX58835@decibel.org> <19631.1113966086@sss.pgh.pa.us> <20050420034041.GC58835@decibel.org> <20050423015404.GV58835@decibel.org> <4269.1114222086@sss.pgh.pa.us> <20050423030002.GY58835@decibel.org> <6536.1114232440@sss.pgh.pa.us> <20050424220146.GN58835@decibel.org> In-Reply-To: <20050424220146.GN58835@decibel.org> X-Mailer: Forte Agent 2.0/32.652 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.347 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/209 X-Sequence-Number: 12373 On Sun, 24 Apr 2005 17:01:46 -0500, "Jim C. Nasby" wrote: >> >> Feel free to propose better cost equations. I did. More than once. >estimated index scan cost for (project_id, id, date) is >0.00..100117429.34 while the estimate for work_units is >0.00..103168408.62; almost no difference, ~3% > even though project_id correlation is .657 This is divided by the number of index columns, so the index correlation is estimated to be 0.219. > while work_units correlation is .116. So csquared is 0.048 and 0.013, respectively, and you get a result not far away from the upper bound in both cases. The cost estimations differ by only 3.5% of (max_IO_cost - min_IO_cost). >you'll see that the cost of the index scan is way overestimated. Looking >at the code, the runcost is calculated as > > run_cost += max_IO_cost + csquared * (min_IO_cost - max_IO_cost); > >where csquared is indexCorrelation^2. Why is indexCorrelation squared? >The comments say a linear interpolation between min_IO and max_IO is >used, but ISTM that if it was linear then instead of csquared, >indexCorrelation would just be used. In my tests I got much more plausible results with 1 - (1 - abs(correlation))^2 Jim, are you willing to experiment with one or two small patches of mine? What version of Postgres are you running? Servus Manfred From pgsql-performance-owner@postgresql.org Wed May 11 14:12:43 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BBB2F54217 for ; Wed, 11 May 2005 14:12:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47756-08 for ; Wed, 11 May 2005 17:12:36 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id E85FE54205 for ; Wed, 11 May 2005 14:12:35 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7349909; Wed, 11 May 2005 10:14:34 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "David Roussel" Subject: Re: Partitioning / Clustering Date: Wed, 11 May 2005 10:13:51 -0700 User-Agent: KMail/1.7.1 Cc: "Alex Stapleton" , pgsql-performance@postgresql.org References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115798277.29223.233869472@webmail.messagingengine.com> In-Reply-To: <1115798277.29223.233869472@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505111013.52067.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.047 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/210 X-Sequence-Number: 12374 David, > It's interesting that the solution livejournal have arrived at is quite > similar in ways to the way google is set up. Yes, although again, they're using memcached as pseudo-clustering software, and as a result are limited to what fits in RAM (RAM on 27 machines, but it's still RAM). And due to limitations on memcached, the whole thing blows whenever a server goes out (the memcached project is working on this). But any LJ user could tell you that it's a low-availability system. However, memcached (and for us, pg_memcached) is an excellent way to improve horizontal scalability by taking disposable data (like session information) out of the database and putting it in protected RAM. On some websites, adding memcached can result is as much as a 60% decrease in database traffic. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed May 11 14:23:46 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 119695422E for ; Wed, 11 May 2005 14:23:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49740-08 for ; Wed, 11 May 2005 17:23:39 +0000 (GMT) Received: from soufre.accelance.net (soufre.accelance.net [213.162.48.15]) by svr1.postgresql.org (Postfix) with ESMTP id B0D965420B for ; Wed, 11 May 2005 14:23:37 -0300 (ADT) Received: from [82.122.171.172] (ALyon-252-1-61-172.w82-122.abo.wanadoo.fr [82.122.171.172]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by soufre.accelance.net (Postfix) with ESMTP id B29125D38 for ; Wed, 11 May 2005 19:23:34 +0200 (CEST) Message-ID: <42823F94.8050009@smet.org> Date: Wed, 11 May 2005 19:23:32 +0200 From: Guillaume Smet User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Bad plan after vacuum analyze X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/mixed; boundary="------------000900040508040804070900" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/211 X-Sequence-Number: 12375 This is a multi-part message in MIME format. --------------000900040508040804070900 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, We have some performances problem on a particular query. We reproduced the problem on a 7.4.5 and on a 7.4.7 server. * we load the dump in a new database * query: it's fast (< 1ms) * VACUUM FULL ANALYZE; * query: it's really slow (130ms) and it's another plan * set enable_seqscan=off; * query: it's fast (< 1ms) : it uses the best plan I attached the EXPLAIN ANALYZE outputs, the query and the tables description. I really can't understand why the planner chooses this plan and especially the line : -> Index Scan using acs_objects_object_id_p_hhkb1 on acs_objects t98 (cost=0.00..2554.07 rows=33510 width=81) (actual time=0.043..56.392 rows=33510 loops=1). I never saw an index scan on such a number of lines. For your information, there are 33510 lines in this table so it scans the whole table. The problem seems to be the left join on the acs_objects t98 table for the parent_application_id as if I remove it or if I change it to a subquery, it's ok. The query is automatically generated by a persistence layer so I can't really rewrite it. Thanks for any help Regards -- Guillaume --------------000900040508040804070900 Content-Type: text/plain; name="plan_after_vacuum.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="plan_after_vacuum.txt" QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Merge Right Join (cost=9.27..9.48 rows=1 width=545) (actual time=129.364..129.365 rows=1 loops=1) Merge Cond: ("outer".application_id = "inner".parent_application_id) -> Index Scan using applicati_applicati_id_p_ogstm on applications t116 (cost=0.00..5.51 rows=28 width=20) (actual time=0.030..0.073 rows=28 loops=1) -> Sort (cost=9.27..9.27 rows=1 width=529) (actual time=129.202..129.203 rows=1 loops=1) Sort Key: t22.parent_application_id -> Merge Right Join (cost=8.92..9.26 rows=1 width=529) (actual time=129.100..129.103 rows=1 loops=1) Merge Cond: ("outer".object_id = "inner".parent_application_id) -> Index Scan using acs_objects_object_id_p_hhkb1 on acs_objects t98 (cost=0.00..2554.07 rows=33510 width=81) (actual time=0.043..56.392 rows=33510 loops=1) -> Sort (cost=8.92..8.93 rows=1 width=452) (actual time=0.309..0.310 rows=1 loops=1) Sort Key: t22.parent_application_id -> Nested Loop (cost=2.44..8.91 rows=1 width=452) (actual time=0.259..0.287 rows=1 loops=1) -> Hash Join (cost=2.44..3.68 rows=1 width=339) (actual time=0.227..0.251 rows=1 loops=1) Hash Cond: ("outer".application_type_id = "inner".application_type_id) -> Seq Scan on application_types t47 (cost=0.00..1.15 rows=15 width=28) (actual time=0.009..0.025 rows=15 loops=1) -> Hash (cost=2.44..2.44 rows=1 width=315) (actual time=0.121..0.121 rows=0 loops=1) -> Hash Join (cost=1.01..2.44 rows=1 width=315) (actual time=0.073..0.112 rows=1 loops=1) Hash Cond: ("outer".application_id = "inner".section_id) -> Seq Scan on applications t22 (cost=0.00..1.28 rows=28 width=70) (actual time=0.002..0.027 rows=28 loops=1) -> Hash (cost=1.01..1.01 rows=1 width=245) (actual time=0.026..0.026 rows=0 loops=1) -> Seq Scan on content_sections t0 (cost=0.00..1.01 rows=1 width=245) (actual time=0.020..0.022 rows=1 loops=1) -> Index Scan using acs_objects_object_id_p_hhkb1 on acs_objects t7 (cost=0.00..5.22 rows=1 width=121) (actual time=0.016..0.017 rows=1 loops=1) Index Cond: ("outer".application_id = t7.object_id) Total runtime: 129.754 ms (23 lignes) --------------000900040508040804070900 Content-Type: text/plain; name="plan_after_vacuum_seqscan_off.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="plan_after_vacuum_seqscan_off.txt" SET QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Left Join (cost=17.48..18.03 rows=1 width=545) (actual time=0.653..0.656 rows=1 loops=1) Merge Cond: ("outer".parent_application_id = "inner".application_id) -> Merge Left Join (cost=17.48..17.81 rows=1 width=529) (actual time=0.616..0.618 rows=1 loops=1) Merge Cond: ("outer".parent_application_id = "inner".object_id) -> Sort (cost=17.48..17.49 rows=1 width=452) (actual time=0.587..0.588 rows=1 loops=1) Sort Key: t22.parent_application_id -> Nested Loop (cost=4.68..17.47 rows=1 width=452) (actual time=0.424..0.484 rows=1 loops=1) -> Nested Loop (cost=4.68..13.37 rows=1 width=428) (actual time=0.236..0.293 rows=1 loops=1) -> Hash Join (cost=4.68..8.14 rows=1 width=315) (actual time=0.176..0.229 rows=1 loops=1) Hash Cond: ("outer".application_id = "inner".section_id) -> Index Scan using applicati_parent_app_id_idx on applications t22 (cost=0.00..3.31 rows=28 width=70) (actual time=0.029..0.074 rows=28 loops=1) -> Hash (cost=4.68..4.68 rows=1 width=245) (actual time=0.045..0.045 rows=0 loops=1) -> Index Scan using content_sections_pk on content_sections t0 (cost=0.00..4.68 rows=1 width=245) (actual time=0.039..0.042 rows=1 loops=1) -> Index Scan using acs_objects_object_id_p_hhkb1 on acs_objects t7 (cost=0.00..5.22 rows=1 width=121) (actual time=0.049..0.050 rows=1 loops=1) Index Cond: ("outer".application_id = t7.object_id) -> Index Scan using appli_typ_appli_typ_id_p_r5e8o on application_types t47 (cost=0.00..4.09 rows=1 width=28) (actual time=0.175..0.177 rows=1 loops=1) Index Cond: ("outer".application_type_id = t47.application_type_id) -> Index Scan using acs_objects_object_id_p_hhkb1 on acs_objects t98 (cost=0.00..2554.07 rows=33510 width=81) (actual time=0.009..0.009 rows=1 loops=1) -> Index Scan using applicati_applicati_id_p_ogstm on applications t116 (cost=0.00..5.51 rows=28 width=20) (actual time=0.020..0.020 rows=1 loops=1) Total runtime: 1.001 ms (20 lignes) --------------000900040508040804070900 Content-Type: text/plain; name="plan_before_vacuum.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="plan_before_vacuum.txt" QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Nested Loop Left Join (cost=2.44..17.36 rows=1 width=5532) (actual time=0.441..0.466 rows=1 loops=1) Join Filter: ("outer".parent_application_id = "inner".application_id) -> Nested Loop Left Join (cost=2.44..15.73 rows=1 width=5214) (actual time=0.378..0.402 rows=1 loops=1) -> Nested Loop (cost=2.44..9.70 rows=1 width=4878) (actual time=0.365..0.388 rows=1 loops=1) -> Hash Join (cost=2.44..3.68 rows=1 width=4228) (actual time=0.315..0.334 rows=1 loops=1) Hash Cond: ("outer".application_type_id = "inner".application_type_id) -> Seq Scan on application_types t47 (cost=0.00..1.15 rows=15 width=326) (actual time=0.037..0.051 rows=15 loops=1) -> Hash (cost=2.44..2.44 rows=1 width=3906) (actual time=0.115..0.115 rows=0 loops=1) -> Hash Join (cost=1.01..2.44 rows=1 width=3906) (actual time=0.065..0.104 rows=1 loops=1) Hash Cond: ("outer".application_id = "inner".section_id) -> Seq Scan on applications t22 (cost=0.00..1.28 rows=28 width=1370) (actual time=0.006..0.027 rows=28 loops=1) -> Hash (cost=1.01..1.01 rows=1 width=2536) (actual time=0.028..0.028 rows=0 loops=1) -> Seq Scan on content_sections t0 (cost=0.00..1.01 rows=1 width=2536) (actual time=0.018..0.020 rows=1 loops=1) -> Index Scan using acs_objects_object_id_p_hhkb1 on acs_objects t7 (cost=0.00..6.01 rows=1 width=658) (actual time=0.037..0.039 rows=1 loops=1) Index Cond: ("outer".application_id = t7.object_id) -> Index Scan using acs_objects_object_id_p_hhkb1 on acs_objects t98 (cost=0.00..6.01 rows=1 width=340) (actual time=0.001..0.001 rows=0 loops=1) Index Cond: ("outer".parent_application_id = t98.object_id) -> Seq Scan on applications t116 (cost=0.00..1.28 rows=28 width=322) (actual time=0.002..0.024 rows=28 loops=1) Total runtime: 0.775 ms (19 lignes) --------------000900040508040804070900 Content-Type: text/x-sql; name="query_section.sql" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="query_section.sql" explain analyze select t0.section_id as "this.id", t7.object_type as "this.objectType", t7.display_name as "this.displayName", t7.default_domain_class as "this.defaultDomainClass", t22.title as "this.title", t22.description as "this.description", t22.timestamp as "this.timestamp", t22.application_type_id as "this.resourceType.id", t47.workspace_application_p as "this.resourceType.isWorkspace8", t47.has_full_page_view_p as "this.resourceType.hasFullPage9", t47.has_embedded_view_p as "this.resourceType.hasEmbedde10", t47.singleton_p as "this.resourceType.isSingleton", t47.title as "this.resourceType.title", t22.parent_application_id as "this.parentResource.id", t98.object_type as "this.parentResource.objectType", t98.default_domain_class as "this.parentResource.defaultD15", t116.title as "this.parentResource.title", t22.primary_url as "this.primaryURL", t0.pretty_name as "this.label", t0.page_resolver_class as "this.pageResolverClass", t0.item_resolver_class as "this.itemResolverClass", t0.template_resolver_class as "this.templateResolverClass", t0.xml_generator_class as "this.xmlGeneratorClass" from content_sections t0 join acs_objects t7 on t0.section_id = t7.object_id join applications t22 on t0.section_id = t22.application_id join application_types t47 on t22.application_type_id = t47.application_type_id left join acs_objects t98 on t22.parent_application_id = t98.object_id left join applications t116 on t22.parent_application_id = t116.application_id where 1 = 1; --------------000900040508040804070900 Content-Type: text/plain; name="tables.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tables.txt" Table "public.acs_objects" Column | Type | Modifiers ----------------------+------------------------+----------- object_id | integer | not null object_type | character varying(100) | not null display_name | character varying(200) | not null default_domain_class | character varying(100) | Indexes: "acs_objects_object_id_p_hhkb1" primary key, btree (object_id) Triggers: acs_object_dnm_ctx_add_trg AFTER INSERT ON acs_objects FOR EACH ROW EXECUTE PROCEDURE acs_object_dnm_ctx_add_fn() acs_object_dnm_ctx_del_trg BEFORE DELETE ON acs_objects FOR EACH ROW EXECUTE PROCEDURE acs_object_dnm_ctx_del_fn() Table "public.content_sections" Column | Type | Modifiers -------------------------+-------------------------+----------- section_id | integer | not null pretty_name | character varying(300) | not null root_folder_id | integer | not null templates_folder_id | integer | staff_group_id | integer | not null viewers_group_id | integer | not null page_resolver_class | character varying(1000) | not null item_resolver_class | character varying(1000) | not null template_resolver_class | character varying(1000) | not null xml_generator_class | character varying(1000) | not null Indexes: "content_sections_pk" primary key, btree (section_id) "csections_name_un" unique, btree (pretty_name) "content_sections_rt_folder_idx" btree (root_folder_id) "content_sections_staff_grp_idx" btree (staff_group_id) "content_sections_tp_folder_idx" btree (templates_folder_id) "content_sections_vwrs_grp_idx" btree (viewers_group_id) Foreign-key constraints: "csections_viewers_group_id_fk" FOREIGN KEY (viewers_group_id) REFERENCES groups(group_id) "csections_staff_group_id_fk" FOREIGN KEY (staff_group_id) REFERENCES groups(group_id) "csections_temps_folder_id_fk" FOREIGN KEY (templates_folder_id) REFERENCES cms_folders(folder_id) "csections_root_folder_id_fk" FOREIGN KEY (root_folder_id) REFERENCES cms_folders(folder_id) "csections_section_id_fk" FOREIGN KEY (section_id) REFERENCES applications(application_id) Table "public.applications" Column | Type | Modifiers -----------------------+--------------------------+----------- application_id | integer | not null title | character varying(200) | description | character varying(4000) | timestamp | timestamp with time zone | not null application_type_id | integer | not null parent_application_id | integer | cell_number | integer | sort_key | integer | primary_url | character varying(4000) | package_id | integer | Indexes: "applicati_applicati_id_p_ogstm" primary key, btree (application_id) "applicati_applicati_typ_id_idx" btree (application_type_id) "applicati_package_id_idx" btree (package_id) "applicati_parent_app_id_idx" btree (parent_application_id) "idx_test" btree (primary_url) Foreign-key constraints: "application_package_id_f_cdaho" FOREIGN KEY (package_id) REFERENCES apm_packages(package_id) "applicati_applicati_id_f_a35g2" FOREIGN KEY (application_id) REFERENCES acs_objects(object_id) "applica_par_applica_id_f_hvxh7" FOREIGN KEY (parent_application_id) REFERENCES applications(application_id) "applica_applica_typ_id_f_k2bi3" FOREIGN KEY (application_type_id) REFERENCES application_types(application_type_id) Table "public.application_types" Column | Type | Modifiers -------------------------+-------------------------+----------- application_type_id | integer | not null object_type | character varying(100) | not null title | character varying(200) | description | character varying(4000) | workspace_application_p | boolean | has_full_page_view_p | boolean | has_embedded_view_p | boolean | singleton_p | boolean | provider_id | integer | profile | character varying(20) | package_type_id | integer | Indexes: "appli_typ_appli_typ_id_p_r5e8o" primary key, btree (application_type_id) "applicat_typ_obje_type_u_pf2uk" unique, btree (object_type) "appli_typ_package_type_id_idx" btree (package_type_id) "appli_typ_provider_id_idx" btree (provider_id) Foreign-key constraints: "applicat_typ_provid_id_f_bm274" FOREIGN KEY (provider_id) REFERENCES application_types(application_type_id) "applica_typ_pac_typ_id_f_v80ma" FOREIGN KEY (package_type_id) REFERENCES apm_package_types(package_type_id) --------------000900040508040804070900-- From pgsql-performance-owner@postgresql.org Wed May 11 15:09:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7367A53FFC for ; Wed, 11 May 2005 15:09:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58267-03 for ; Wed, 11 May 2005 18:08:58 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 5CA825386F for ; Wed, 11 May 2005 15:08:57 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7350171; Wed, 11 May 2005 11:10:58 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Guillaume Smet Subject: Re: Bad plan after vacuum analyze Date: Wed, 11 May 2005 11:10:15 -0700 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <42823F94.8050009@smet.org> In-Reply-To: <42823F94.8050009@smet.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505111110.15983.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.047 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/212 X-Sequence-Number: 12376 Guillaume, > We reproduced the problem on a 7.4.5 and on a 7.4.7 server. > * we load the dump in a new database > * query: it's fast (< 1ms) > * VACUUM FULL ANALYZE; > * query: it's really slow (130ms) and it's another plan > * set enable_seqscan=off; > * query: it's fast (< 1ms) : it uses the best plan Looking at this, the planner seems convinced that the merge join is the easiest way to do the OUTER JOINS, but it appears to be wrong; a nested loop is faster. This isn't the only place I've encountered our optimizer doing this -- underestimating the cost of a merge join. This seems to be becuase the merge_join vs. nested_loop decision seems to be being made in the planner without taking the double-sort and index access costs into account. This query is an excellent example: "good" plan: Nested Loop Left Join (cost=2.44..17.36 rows=1 width=5532) (actual time=0.441..0.466 rows=1 loops=1) Join Filter: ("outer".parent_application_id = "inner".application_id) -> Nested Loop Left Join (cost=2.44..15.73 rows=1 width=5214) (actual time=0.378..0.402 rows=1 loops=1) See, here the planner thinks that the 2 nested loops will cost "35". "bad" plan: Merge Right Join (cost=9.27..9.48 rows=1 width=545) (actual time=129.364..129.365 rows=1 loops=1) Merge Cond: ("outer".application_id = "inner".parent_application_id) -> Index Scan using applicati_applicati_id_p_ogstm on applications t116 (cost=0.00..5.51 rows=28 width=20) (actual time=0.030..0.073 rows=28 loops=1) -> Sort (cost=9.27..9.27 rows=1 width=529) (actual time=129.202..129.203 rows=1 loops=1) Sort Key: t22.parent_application_id -> Merge Right Join (cost=8.92..9.26 rows=1 width=529) (actual time=129.100..129.103 rows=1 loops=1) Merge Cond: ("outer".object_id = "inner".parent_application_id) -> Index Scan using acs_objects_object_id_p_hhkb1 on acs_objects t98 (cost=0.00..2554.07 rows=33510 width=81) (actual time=0.043..56.392 rows=33510 loops=1) -> Sort (cost=8.92..8.93 rows=1 width=452) (actual time=0.309..0.310 rows=1 loops=1) Sort Key: t22.parent_application_id Here the planner chooses a merge right join. This decision seems to have been made entirely on the basis of the cost of the join itself (total of 17) without taking the cost of the sort and index access (total of 2600+) into account. Tom, is this a possible error in planner logic? -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed May 11 15:59:00 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 960665322F for ; Wed, 11 May 2005 15:58:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66550-03 for ; Wed, 11 May 2005 18:58:51 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6A9D85296E for ; Wed, 11 May 2005 15:58:50 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4BIwkqf013965; Wed, 11 May 2005 14:58:47 -0400 (EDT) To: josh@agliodbs.com Cc: Guillaume Smet , pgsql-performance@postgresql.org Subject: Re: Bad plan after vacuum analyze In-reply-to: <200505111110.15983.josh@agliodbs.com> References: <42823F94.8050009@smet.org> <200505111110.15983.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 11 May 2005 11:10:15 -0700" Date: Wed, 11 May 2005 14:58:46 -0400 Message-ID: <13964.1115837926@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/213 X-Sequence-Number: 12377 Josh Berkus writes: > -> Merge Right Join (cost=8.92..9.26 rows=1 width=529) (actual > time=129.100..129.103 rows=1 loops=1) > Merge Cond: ("outer".object_id = "inner".parent_application_id) > -> Index Scan using acs_objects_object_id_p_hhkb1 on > acs_objects t98 (cost=0.00..2554.07 rows=33510 width=81) (actual > time=0.043..56.392 rows=33510 loops=1) > -> Sort (cost=8.92..8.93 rows=1 width=452) (actual > time=0.309..0.310 rows=1 loops=1) > Sort Key: t22.parent_application_id > Here the planner chooses a merge right join. This decision seems to have been > made entirely on the basis of the cost of the join itself (total of 17) > without taking the cost of the sort and index access (total of 2600+) into > account. > Tom, is this a possible error in planner logic? No, it certainly hasn't forgotten to add in the costs of the inputs. There might be a bug here, but if so it's much more subtle than that. It looks to me like the planner believes that the one value of t22.parent_application_id joins to something very early in the acs_objects_object_id_p_hhkb1 sort order, and that it will therefore not be necessary to run the indexscan to completion (or indeed very far at all, considering that it's including such a small fraction of the total indexscan cost). andrew@supernews pointed out recently that this effect doesn't apply to the outer side of an outer join; releases before 7.4.8 mistakenly think it does. But unless my wires are totally crossed today, acs_objects is the nullable side here and so that error isn't applicable anyway. So, the usual questions: have these two tables been ANALYZEd lately? If so, can we see the pg_stats rows for the object_id and parent_application_id columns? regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 11 16:07:05 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ACC375337A for ; Wed, 11 May 2005 16:07:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66359-07 for ; Wed, 11 May 2005 19:06:57 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 1395853341 for ; Wed, 11 May 2005 16:06:56 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511190657.ZTJM14487.priv-edtnes56.telusplanet.net@localhost> for ; Wed, 11 May 2005 13:06:57 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Wed, 11 May 2005 12:06:56 -0700 Message-ID: <1115838416.428257d0e5bc3@webmail.telus.net> Date: Wed, 11 May 2005 12:06:56 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: Prefetch References: <200505100652.51401.molson@oceanconsulting.com> <42818B2E.8060403@vilain.net> <42818FB1.4060403@familyhealth.com.au> In-Reply-To: <42818FB1.4060403@familyhealth.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.037 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/214 X-Sequence-Number: 12378 Quoting Christopher Kings-Lynne : > > Another trick you can use with large data sets like this when you > want > > results > > back in seconds is to have regularly updated tables that aggregate > the data > > along each column normally aggregated against the main data set. > > > Maybe some bright person will prove me wrong by posting some > working > > information about how to get these apparently absent features > working. > > Most people just use simple triggers to maintain aggregate summary > tables... Don't know if this is more appropriate to bizgres, but: What the first poster is talking about is what OLAP cubes do. For big aggregating systems (OLAP), triggers perform poorly, compared to messy hand-rolled code. You may have dozens of aggregates at various levels. Consider the effect of having each detail row cascade into twenty updates. It's particularly silly-looking when data is coming in as batches of thousands of rows in a single insert, e.g. COPY temp_table FROM STDIN; UPDATE fact_table ... FROM ... temp_table INSERT INTO fact_table ...FROM...temp_table (the above pair of operations is so common, Oracle added its "MERGE" operator for it). Hence my recent post (request) for using RULES to aggregate --- given no luck with triggers "FOR EACH STATEMENT". From pgsql-performance-owner@postgresql.org Wed May 11 16:32:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3D04D52A74 for ; Wed, 11 May 2005 16:32:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72078-07 for ; Wed, 11 May 2005 19:32:21 +0000 (GMT) Received: from soufre.accelance.net (soufre.accelance.net [213.162.48.15]) by svr1.postgresql.org (Postfix) with ESMTP id 0602E53C35 for ; Wed, 11 May 2005 16:32:20 -0300 (ADT) Received: from [82.122.171.172] (ALyon-252-1-61-172.w82-122.abo.wanadoo.fr [82.122.171.172]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by soufre.accelance.net (Postfix) with ESMTP id 3E3E25D38; Wed, 11 May 2005 21:32:19 +0200 (CEST) Message-ID: <42825DBB.7000703@smet.org> Date: Wed, 11 May 2005 21:32:11 +0200 From: Guillaume Smet User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Bad plan after vacuum analyze References: <42823F94.8050009@smet.org> <200505111110.15983.josh@agliodbs.com> <13964.1115837926@sss.pgh.pa.us> In-Reply-To: <13964.1115837926@sss.pgh.pa.us> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/mixed; boundary="------------010907060909070006020000" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/215 X-Sequence-Number: 12379 This is a multi-part message in MIME format. --------------010907060909070006020000 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Tom, > So, the usual questions: have these two tables been ANALYZEd lately? Yes, of course. As I wrote in my previous mail, here is how I reproduce the problem: - we load the dump in a new database (to be sure, there is no problem on an index or something like that) - query: it's fast (< 1ms) - *VACUUM FULL ANALYZE;* - query: it's really slow (130ms) and it's another plan - set enable_seqscan=off; - query: it's fast (< 1ms) : it uses the best plan I reproduced it on two different servers exactly like that (7.4.5 and 7.4.7). I first met the problem on a production database with a VACUUM ANALYZE run every night (and we don't have too many inserts a day on this database). > If so, can we see the pg_stats rows for the object_id and > parent_application_id columns? See attached file. If you're interested in a dump of these tables, just tell me. There aren't any confidential information in them. Regards -- Guillaume --------------010907060909070006020000 Content-Type: text/plain; name="stats.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="stats.txt" schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+-------------+-----------+-----------+-----------+------------+------------------+-------------------+-----------------------------------------------------------------------------+------------- public | acs_objects | object_id | 0 | 4 | -1 | | | {1032,34143,112295,120811,285004,420038,449980,453451,457684,609292,710005} | 0.488069 (1 ligne) schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+--------------+-----------------------+-----------+-----------+------------+------------------+-------------------+------------------+------------- public | applications | parent_application_id | 0.928571 | 4 | 1 | {1031} | {0.0714286} | | 1 (1 ligne) --------------010907060909070006020000-- From pgsql-performance-owner@postgresql.org Wed May 11 16:38:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7FD2353C9D for ; Wed, 11 May 2005 16:38:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73308-06 for ; Wed, 11 May 2005 19:38:24 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 729C8538E6 for ; Wed, 11 May 2005 16:38:17 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4BJcGxQ014302; Wed, 11 May 2005 15:38:17 -0400 (EDT) To: Guillaume Smet Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Bad plan after vacuum analyze In-reply-to: <42825DBB.7000703@smet.org> References: <42823F94.8050009@smet.org> <200505111110.15983.josh@agliodbs.com> <13964.1115837926@sss.pgh.pa.us> <42825DBB.7000703@smet.org> Comments: In-reply-to Guillaume Smet message dated "Wed, 11 May 2005 21:32:11 +0200" Date: Wed, 11 May 2005 15:38:16 -0400 Message-ID: <14301.1115840296@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/216 X-Sequence-Number: 12380 Guillaume Smet writes: >> If so, can we see the pg_stats rows for the object_id and >> parent_application_id columns? > See attached file. Well, those stats certainly appear to justify the planner's belief that the indexscan needn't run very far: the one value of parent_application_id is 1031 and this is below the smallest value of object_id seen by analyze. You might have better luck if you increase the statistics target for acs_objects.object_id. (It'd be interesting to know what fraction of acs_objects actually does have object_id < 1032.) regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 11 16:57:25 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D8B6253B12 for ; Wed, 11 May 2005 16:57:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76094-10 for ; Wed, 11 May 2005 19:57:07 +0000 (GMT) Received: from soufre.accelance.net (soufre.accelance.net [213.162.48.15]) by svr1.postgresql.org (Postfix) with ESMTP id 00870538E0 for ; Wed, 11 May 2005 16:57:03 -0300 (ADT) Received: from [82.122.171.172] (ALyon-252-1-61-172.w82-122.abo.wanadoo.fr [82.122.171.172]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by soufre.accelance.net (Postfix) with ESMTP id 0C1005D38; Wed, 11 May 2005 21:57:03 +0200 (CEST) Message-ID: <4282638E.2020307@smet.org> Date: Wed, 11 May 2005 21:57:02 +0200 From: Guillaume Smet User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Bad plan after vacuum analyze References: <42823F94.8050009@smet.org> <200505111110.15983.josh@agliodbs.com> <13964.1115837926@sss.pgh.pa.us> <42825DBB.7000703@smet.org> <14301.1115840296@sss.pgh.pa.us> In-Reply-To: <14301.1115840296@sss.pgh.pa.us> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/217 X-Sequence-Number: 12381 > Well, those stats certainly appear to justify the planner's belief that > the indexscan needn't run very far: the one value of > parent_application_id is 1031 and this is below the smallest value of > object_id seen by analyze. Yes, it seems rather logical but why does it cost so much if it should be an effective way to find the row? > You might have better luck if you increase > the statistics target for acs_objects.object_id. What do you mean exactly? > (It'd be interesting > to know what fraction of acs_objects actually does have object_id < 1032.) ccm_perf=# SELECT COUNT(*) FROM acs_objects WHERE object_id<1032; count ------- 15 ccm_perf=# SELECT COUNT(*) FROM acs_objects; count ------- 33510 -- Guillaume From pgsql-performance-owner@postgresql.org Wed May 11 17:02:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 27FD353CB9 for ; Wed, 11 May 2005 17:02:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77408-08 for ; Wed, 11 May 2005 20:02:30 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 311D853C99 for ; Wed, 11 May 2005 17:02:29 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DVxP8-00040j-00; Wed, 11 May 2005 16:02:02 -0400 To: Alex Stapleton Cc: Simon Riggs , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115795780.3830.264.camel@localhost.localdomain> In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 11 May 2005 16:02:01 -0400 Message-ID: <877ji5r0p2.fsf@stark.xeocode.com> Lines: 13 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/218 X-Sequence-Number: 12382 Alex Stapleton writes: > Acceptable Answers to 'So, when/is PG meant to be getting a decent > partitioning system?': ... > 3. Your welcome to take a stab at it, I expect the community would > support your efforts as well. As long as we're being curt all around, this one's not acceptable on the basis that it's not grammatical. -- greg From pgsql-performance-owner@postgresql.org Wed May 11 17:26:12 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E75DF53E18 for ; Wed, 11 May 2005 17:26:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83615-01 for ; Wed, 11 May 2005 20:26:10 +0000 (GMT) Received: from cmailg3.svr.pol.co.uk (cmailg3.svr.pol.co.uk [195.92.195.173]) by svr1.postgresql.org (Postfix) with ESMTP id 0EBA353E14 for ; Wed, 11 May 2005 17:26:09 -0300 (ADT) Received: from modem-3948.leopard.dialup.pol.co.uk ([217.135.159.108] helo=192.168.0.102) by cmailg3.svr.pol.co.uk with esmtp (Exim 4.41) id 1DVxmO-0000f7-LC; Wed, 11 May 2005 21:26:04 +0100 Subject: Re: Partitioning / Clustering From: Simon Riggs To: Christopher Kings-Lynne Cc: Alex Stapleton , pgsql-performance@postgresql.org In-Reply-To: <4281CCC7.5050405@familyhealth.com.au> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115795780.3830.264.camel@localhost.localdomain> <4281CCC7.5050405@familyhealth.com.au> Content-Type: text/plain Organization: 2nd Quadrant Date: Wed, 11 May 2005 21:22:13 +0100 Message-Id: <1115842933.3830.309.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/219 X-Sequence-Number: 12383 On Wed, 2005-05-11 at 17:13 +0800, Christopher Kings-Lynne wrote: > > Alex Stapleton wrote > > Be more helpful, and less arrogant please. > > Simon told you all the reasons clearly and politely. Thanks Chris for your comments. PostgreSQL can always do with one more developer and my sole intent was to encourage Alex and other readers to act themselves. If my words seem arrogant, then I apologise to any and all that think so. Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Wed May 11 17:32:42 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A597D53CEB for ; Wed, 11 May 2005 17:32:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83076-10 for ; Wed, 11 May 2005 20:32:40 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 452ED53CB8 for ; Wed, 11 May 2005 17:32:37 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4BKWZHH017018; Wed, 11 May 2005 16:32:35 -0400 (EDT) To: Guillaume Smet Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Bad plan after vacuum analyze In-reply-to: <4282638E.2020307@smet.org> References: <42823F94.8050009@smet.org> <200505111110.15983.josh@agliodbs.com> <13964.1115837926@sss.pgh.pa.us> <42825DBB.7000703@smet.org> <14301.1115840296@sss.pgh.pa.us> <4282638E.2020307@smet.org> Comments: In-reply-to Guillaume Smet message dated "Wed, 11 May 2005 21:57:02 +0200" Date: Wed, 11 May 2005 16:32:35 -0400 Message-ID: <17017.1115843555@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/220 X-Sequence-Number: 12384 Ah-ha, I can replicate the problem. This example uses tenk1 from the regression database, which has a column unique2 containing just the integers 0..9999. regression=# create table t1(f1 int); CREATE TABLE regression=# insert into t1 values(5); INSERT 154632 1 regression=# insert into t1 values(7); INSERT 154633 1 regression=# analyze t1; ANALYZE regression=# explain analyze select * from tenk1 right join t1 on (unique2=f1); QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------- Merge Right Join (cost=1.03..1.37 rows=2 width=248) (actual time=0.507..0.617 rows=2 loops=1) Merge Cond: ("outer".unique2 = "inner".f1) -> Index Scan using tenk1_unique2 on tenk1 (cost=0.00..498.24 rows=10024 width=244) (actual time=0.126..0.242 rows=9 loops=1) -> Sort (cost=1.03..1.03 rows=2 width=4) (actual time=0.145..0.153 rows=2 loops=1) Sort Key: t1.f1 -> Seq Scan on t1 (cost=0.00..1.02 rows=2 width=4) (actual time=0.029..0.049 rows=2 loops=1) Total runtime: 1.497 ms (7 rows) The planner correctly perceives that only a small part of the unique2 index will need to be scanned, and hence thinks the merge is cheap --- much cheaper than if the whole index had to be scanned. And it is. Notice that only 9 rows were actually pulled from the index. Once we got to unique2 = 8, nodeMergejoin.c could see that no more matches to f1 were possible. But watch this: regression=# insert into t1 values(null); INSERT 154634 1 regression=# explain analyze select * from tenk1 right join t1 on (unique2=f1); QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Merge Right Join (cost=1.03..1.37 rows=2 width=248) (actual time=0.560..290.874 rows=3 loops=1) Merge Cond: ("outer".unique2 = "inner".f1) -> Index Scan using tenk1_unique2 on tenk1 (cost=0.00..498.24 rows=10024 width=244) (actual time=0.139..106.982 rows=10000 loops=1) -> Sort (cost=1.03..1.03 rows=2 width=4) (actual time=0.181..0.194 rows=3 loops=1) Sort Key: t1.f1 -> Seq Scan on t1 (cost=0.00..1.02 rows=2 width=4) (actual time=0.032..0.067 rows=3 loops=1) Total runtime: 291.670 ms (7 rows) See what happened to the actual costs of the indexscan? All of a sudden we had to scan the whole index because there was a null in the other input, and nulls sort high. I wonder if it is worth fixing nodeMergejoin.c to not even try to match nulls to the other input. We'd have to add a check to see if the join operator is strict or not, but it nearly always will be. The alternative would be to make the planner only believe in the short-circuit path occuring if it thinks that the other input is entirely non-null ... but this seems pretty fragile, since it only takes one null to mess things up, and ANALYZE can hardly be counted on to detect one null in a table. In the meantime it seems like the quickest answer for Guillaume might be to try to avoid keeping any NULLs in parent_application_id. regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 11 18:02:21 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DF9D552A60 for ; Wed, 11 May 2005 17:59:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89162-04 for ; Wed, 11 May 2005 20:59:45 +0000 (GMT) Received: from soufre.accelance.net (soufre.accelance.net [213.162.48.15]) by svr1.postgresql.org (Postfix) with ESMTP id 00E5D53E59 for ; Wed, 11 May 2005 17:59:43 -0300 (ADT) Received: from [82.122.171.172] (ALyon-252-1-61-172.w82-122.abo.wanadoo.fr [82.122.171.172]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by soufre.accelance.net (Postfix) with ESMTP id E5BA85D38; Wed, 11 May 2005 22:59:41 +0200 (CEST) Message-ID: <4282723C.5080903@smet.org> Date: Wed, 11 May 2005 22:59:40 +0200 From: Guillaume Smet User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Bad plan after vacuum analyze References: <42823F94.8050009@smet.org> <200505111110.15983.josh@agliodbs.com> <13964.1115837926@sss.pgh.pa.us> <42825DBB.7000703@smet.org> <14301.1115840296@sss.pgh.pa.us> <4282638E.2020307@smet.org> <17017.1115843555@sss.pgh.pa.us> In-Reply-To: <17017.1115843555@sss.pgh.pa.us> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/221 X-Sequence-Number: 12385 Josh, Tom, Thanks for your explanations. > In the meantime it seems like the quickest answer for Guillaume might > be to try to avoid keeping any NULLs in parent_application_id. I can't do that as the majority of the applications don't have any parent one. Moreover, we use a third party application and we cannot modify all its internals. Anyway, I tried to work on the statistics as you told me and here are the results: ccm_perf=# ALTER TABLE acs_objects ALTER COLUMN object_id SET STATISTICS 30; ALTER TABLE ccm_perf=# ANALYZE acs_objects; ANALYZE ccm_perf=# \i query_section.sql ... correct plan ... Total runtime: 0.555 ms So I think I will use this solution for the moment. Thanks a lot for your help. Regards -- Guillaume From pgsql-performance-owner@postgresql.org Wed May 11 18:15:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9AEDD53E25 for ; Wed, 11 May 2005 18:15:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90440-06 for ; Wed, 11 May 2005 21:15:15 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 898B853E2B for ; Wed, 11 May 2005 18:15:14 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 405A1154BF; Wed, 11 May 2005 16:15:16 -0500 (CDT) Date: Wed, 11 May 2005 16:15:16 -0500 From: "Jim C. Nasby" To: Manfred Koizar Cc: Tom Lane , Dave Held , pgsql-performance@postgresql.org Subject: Re: Sort and index Message-ID: <20050511211516.GX31103@decibel.org> References: <49E94D0CFCD4DB43AFBA928DDD20C8F9026184B6@asg002.asg.local> <20050420004234.GX58835@decibel.org> <19631.1113966086@sss.pgh.pa.us> <20050420034041.GC58835@decibel.org> <20050423015404.GV58835@decibel.org> <4269.1114222086@sss.pgh.pa.us> <20050423030002.GY58835@decibel.org> <6536.1114232440@sss.pgh.pa.us> <20050424220146.GN58835@decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/222 X-Sequence-Number: 12386 First, I've got some updated numbers up at http://stats.distributed.net/~decibel/ timing2.log shows that the planner actually under-estimates an index scan by several orders of magnitude. Granted, random_page_cost is set to an unrealistic 1.1 (otherwise I can't force the index scan), but that alone isn't enough to explain the difference. On Wed, May 11, 2005 at 05:59:10PM +0200, Manfred Koizar wrote: > On Sun, 24 Apr 2005 17:01:46 -0500, "Jim C. Nasby" > wrote: > >> >> Feel free to propose better cost equations. > > I did. More than once. > > >estimated index scan cost for (project_id, id, date) is > >0.00..100117429.34 while the estimate for work_units is > >0.00..103168408.62; almost no difference, > > ~3% > > > even though project_id correlation is .657 > > This is divided by the number of index columns, so the index correlation > is estimated to be 0.219. That seems like a pretty bad assumption to make. Is there any eta on having statistics for multi-column indexes? > >you'll see that the cost of the index scan is way overestimated. Looking > >at the code, the runcost is calculated as > > > > run_cost += max_IO_cost + csquared * (min_IO_cost - max_IO_cost); > > > >where csquared is indexCorrelation^2. Why is indexCorrelation squared? > >The comments say a linear interpolation between min_IO and max_IO is > >used, but ISTM that if it was linear then instead of csquared, > >indexCorrelation would just be used. > > In my tests I got much more plausible results with > > 1 - (1 - abs(correlation))^2 What's the theory behind that? And I'd still like to know why correlation squared is used. > Jim, are you willing to experiment with one or two small patches of > mine? What version of Postgres are you running? It depends on the patches, since this is a production machine. Currently it's running 7.4.*mumble*, though I need to upgrade to 8, which I was intending to do via slony. Perhaps the best thing would be for me to get that setup and we can experiment against version 8.0.3. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed May 11 18:21:25 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3594353E2B for ; Wed, 11 May 2005 18:21:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92206-07 for ; Wed, 11 May 2005 21:21:24 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 6150553E25 for ; Wed, 11 May 2005 18:21:22 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511212124.IORI14487.priv-edtnes56.telusplanet.net@localhost>; Wed, 11 May 2005 15:21:24 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Wed, 11 May 2005 14:21:22 -0700 Message-ID: <1115846482.428277525b64f@webmail.telus.net> Date: Wed, 11 May 2005 14:21:22 -0700 From: Mischa Sandberg To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Federated PG servers -- Was: Re: [GENERAL] "Hash index" vs. "b-tree index" (PostgreSQL References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> <6686.1115700888@sss.pgh.pa.us> <878y2nsj7i.fsf@stark.xeocode.com> <9871.1115733198@sss.pgh.pa.us> <87wtq7q8zk.fsf@stark.xeocode.com> <25690.1115754605@sss.pgh.pa.us> <87ll6mr5y8.fsf@stark.xeocode.com> <29017.1115777867@sss.pgh.pa.us> In-Reply-To: <29017.1115777867@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.038 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/223 X-Sequence-Number: 12387 Was curious why you pointed out SQL-MED as a SQL-standard approach to federated servers. Always thought of it as covering access to non-SQL data, the way the lo_* interface works; as opposed to meshing compatible (to say nothing of identical) SQL servers. Just checked Jim Melton's last word on that, to make sure, too. Is there something beyond that, that I'm missing? The approach that made first best sense to me (perhaps from having gone there before) is to leave the SQL syntactically unchanged, and to manage federated relations via pg_ tables and probably procedures. MSSQL and Sybase went that route. It won't preclude moving to a system embedded in the SQL language. The hurdles for federated SQL service are: - basic syntax (how to refer to a remote object) - connection management and delegated security - timeouts and temporary connection failures - efficient distributed queries with >1 remote table - distributed transactions - interserver integrity constraints Sometimes the lines get weird because of opportunistic implementations. For example, for the longest time, MSSQL supported server.db.user.object references WITHIN STORED PROCEDURES, since the proc engine could hide some primitive connection management. PG struck me as such a natural for cross-server queries, because it keeps everything out in the open, including statistics. PG is also well set-up to handle heterogeneous table types, and has functions that return rowsets. Nothing needs to be bent out of shape syntactically, or in the cross-server interface, to get over the hurdles above. The fact that queries hence transactions can't span multiple databases tells me, PG has a way to go before it can handle dependency on a distributed transaction monitor. My 2c. From pgsql-performance-owner@postgresql.org Wed May 11 18:27:52 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B79BE5516A for ; Wed, 11 May 2005 18:27:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93574-03 for ; Wed, 11 May 2005 21:27:44 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id C5A7F54C55 for ; Wed, 11 May 2005 18:27:43 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050511212745.IYPR14487.priv-edtnes56.telusplanet.net@localhost> for ; Wed, 11 May 2005 15:27:45 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Wed, 11 May 2005 14:27:45 -0700 Message-ID: <1115846865.428278d135357@webmail.telus.net> Date: Wed, 11 May 2005 14:27:45 -0700 From: Mischa Sandberg To: pgsql-performance@postgresql.org Subject: Re: Bad plan after vacuum analyze References: <42823F94.8050009@smet.org> In-Reply-To: <42823F94.8050009@smet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.039 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/224 X-Sequence-Number: 12388 Quoting Guillaume Smet : > Hi, > > We have some performances problem on a particular query. ... I have to say it, this was the best laid-out set of details behind a problem I've ever seen on this list; I'm going to try live up to it, the next time I have a problem of my own. From pgsql-performance-owner@postgresql.org Wed May 11 18:28:30 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 374BD5335A for ; Wed, 11 May 2005 18:28:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93861-02 for ; Wed, 11 May 2005 21:28:18 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 0745B53218 for ; Wed, 11 May 2005 18:28:17 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id C9189154C6; Wed, 11 May 2005 16:28:19 -0500 (CDT) Date: Wed, 11 May 2005 16:28:19 -0500 From: "Jim C. Nasby" To: David Roussel Cc: Alex Stapleton , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering Message-ID: <20050511212819.GY31103@decibel.org> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115798277.29223.233869472@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1115798277.29223.233869472@webmail.messagingengine.com> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/225 X-Sequence-Number: 12389 On Wed, May 11, 2005 at 08:57:57AM +0100, David Roussel wrote: > For an interesting look at scalability, clustering, caching, etc for a > large site have a look at how livejournal did it. > http://www.danga.com/words/2004_lisa/lisa04.pdf > > They have 2.6 Million active users, posting 200 new blog entries per > minute, plus many comments and countless page views. Neither of which is that horribly impressive. 200 TPM is less than 4TPS. While I haven't run high transaction rate databases under PostgreSQL, I suspect others who have will say that 4TPS isn't that big of a deal. > Although this system is of a different sort to the type I work on it's > interesting to see how they've made it scale. > > They use mysql on dell hardware! And found single master replication did > not scale. There's a section on multimaster replication, not sure if Probably didn't scale because they used to use MyISAM. > they use it. The main approach they use is to parition users into > spefic database clusters. Caching is done using memcached at the Which means they've got a huge amount of additional code complexity, not to mention how many times you can't post something because 'that cluster is down for maintenance'. > application level to avoid hitting the db for rendered pageviews. Memcached is about the only good thing I've seen come out of livejournal. > It's interesting that the solution livejournal have arrived at is quite > similar in ways to the way google is set up. Except that unlike LJ, google stays up and it's fast. Though granted, LJ is quite a bit faster than it was 6 months ago. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed May 11 19:35:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 99F085296E for ; Wed, 11 May 2005 19:35:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05634-01 for ; Wed, 11 May 2005 22:35:18 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 8C62B53BE6 for ; Wed, 11 May 2005 19:35:16 -0300 (ADT) Received: (qmail 10333 invoked from network); 12 May 2005 00:35:40 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 12 May 2005 00:35:40 +0200 To: josh@agliodbs.com, "David Roussel" Cc: "Alex Stapleton" , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115798277.29223.233869472@webmail.messagingengine.com> <200505111013.52067.josh@agliodbs.com> Message-ID: Date: Thu, 12 May 2005 00:35:16 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <1115798277.29223.233869472@webmail.messagingengine.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/226 X-Sequence-Number: 12390 > However, memcached (and for us, pg_memcached) is an excellent way to > improve > horizontal scalability by taking disposable data (like session > information) > out of the database and putting it in protected RAM. So, what is the advantage of such a system versus, say, a "sticky sessions" system where each session is assigned to ONE application server (not PHP then) which keeps it in RAM as native objects instead of serializing and deserializing it on each request ? I'd say the sticky sessions should perform a lot better, and if one machine dies, only the sessions on this one are lost. But of course you can't do it with PHP as you need an app server which can manage sessions. Potentially the savings are huge, though. On Google, their distributed system spans a huge number of PCs and it has redundancy, ie. individual PC failure is a normal thing and is a part of the system, it is handled gracefully. I read a paper on this matter, it's pretty impressive. The google filesystem has nothing to do with databases though, it's more a massive data store / streaming storage. From pgsql-performance-owner@postgresql.org Thu May 12 05:48:50 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 54CBC563D9 for ; Thu, 12 May 2005 05:48:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96903-08 for ; Thu, 12 May 2005 08:48:39 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id E1C41563D7 for ; Thu, 12 May 2005 05:48:37 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-8.tower-49.messagelabs.com!1115887716!16482921!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 1409 invoked from network); 12 May 2005 08:48:36 -0000 Received: from mail.advfn.com (212.161.99.149) by server-8.tower-49.messagelabs.com with SMTP; 12 May 2005 08:48:36 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DW9My-0006i1-1n; Thu, 12 May 2005 09:48:36 +0100 In-Reply-To: References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115798277.29223.233869472@webmail.messagingengine.com> <200505111013.52067.josh@agliodbs.com> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: josh@agliodbs.com, "David Roussel" , pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Partitioning / Clustering Date: Wed, 11 May 2005 23:56:54 +0100 To: PFC X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/230 X-Sequence-Number: 12394 On 11 May 2005, at 23:35, PFC wrote: > > > >> However, memcached (and for us, pg_memcached) is an excellent way >> to improve >> horizontal scalability by taking disposable data (like session >> information) >> out of the database and putting it in protected RAM. >> > > So, what is the advantage of such a system versus, say, a > "sticky sessions" system where each session is assigned to ONE > application server (not PHP then) which keeps it in RAM as native > objects instead of serializing and deserializing it on each request ? > I'd say the sticky sessions should perform a lot better, and if > one machine dies, only the sessions on this one are lost. > But of course you can't do it with PHP as you need an app > server which can manage sessions. Potentially the savings are huge, > though. Theres no reason it couldn't be done with PHP to be fair as long as you could ensure that the client was always routed back to the same machines. Which has it's own set of issues entirely. I am not entirely sure that memcached actually does serialize data when it's comitted into memcached either, although I could be wrong, I have not looked at the source. Certainly if you can ensure that a client always goes back to the same machine you can simplify the whole thing hugely. It's generally not that easy though, you need a proxy server of some description capable of understanding the HTTP traffic and maintaining a central session lookup table to redirect with. Which isn't really solving the problem so much as moving it somewhere else. Instead of needing huge memcached pools, you need hardcore loadbalancers. Load Balancers tend to cost $$$$$ in comparison. Distributed sticky sessions are a rather nice idea, I would like to hear a way of implementing them cheaply (and on PHP) as well. I may have to give that some thought in fact. Oh yeah, and load balancers software often sucks in annoying (if not always important) ways. > On Google, their distributed system spans a huge number of PCs > and it has redundancy, ie. individual PC failure is a normal thing > and is a part of the system, it is handled gracefully. I read a > paper on this matter, it's pretty impressive. The google filesystem > has nothing to do with databases though, it's more a massive data > store / streaming storage. > Since when did Massive Data stores have nothing to do with DBs? Isn't Oracle Cluster entirely based on forming an enormous scalable disk array to store your DB on? From pgsql-performance-owner@postgresql.org Wed May 11 20:26:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7DFDD53CD8 for ; Wed, 11 May 2005 20:26:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14164-01 for ; Wed, 11 May 2005 23:26:23 +0000 (GMT) Received: from metux.de (seven.metux.de [193.16.1.1]) by svr1.postgresql.org (Postfix) with ESMTP id 5336153CD0 for ; Wed, 11 May 2005 20:26:21 -0300 (ADT) Received: (from weigelt@localhost) by metux.de (8.12.10/8.12.10) id j4BNQNJB025288 for pgsql-performance@postgresql.org; Thu, 12 May 2005 01:26:23 +0200 Date: Thu, 12 May 2005 01:26:23 +0200 From: Enrico Weigelt To: pgsql-performance@postgresql.org Subject: Re: BLOB's bypassing the OS Filesystem for better Image loading speed? Message-ID: <20050511232623.GE6485@nibiru.borg.metux.de> Reply-To: weigelt@metux.de Mail-Followup-To: pgsql-performance@postgresql.org References: <426DFA46.8090402@yahoo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <426DFA46.8090402@yahoo.de> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/228 X-Sequence-Number: 12392 * apoc9009@yahoo.de wrote: Hi, > My next queststion is dedicated to blobs in my Webapplication (using > Tomcat 5 and JDBC > integrated a the J2EE Appserver JBoss). > > Filesystems with many Filesystem Objects can slow down the Performance > at opening and reading Data. As others already pointed out, you probably meant: overcrowded directories can make some filesystems slow. For ext2 this is the case. Instead reiserfs is designed to handle very large directories (in fact by using similar indices like an database does). If your application is an typical web app your will probably have the situation: + images get read quite often, while they get updated quite seldom. + you dont want to use image content in quries (ie. match against it) + the images will be transfered directly, without further processing + you can give the upload and the download-server access to a shared filesystem or synchronize their filesystems (ie rsync) Under this assumptions, I'd suggest directly using the filesystem. This should save some load, ie. + no transfer from postgres -> webserver and further processing (server side application) necessary, the webserver can directly fetch files from filesystem + no further processing (server side application) necessary + backup and synchronization is quite trivial (good old fs tools) + clustering (using many image webservers) is quite trivial Already mentioned that you've got to choose the right filesystem or at least the right fs organization (ie. working with a n-level hierachy to keep directory sizes small and lookups fast). An RDBMS can do this for you and so will save some implementation work, but I don't think it will be noticably faster than an good fs-side implementation. Of course there may be a lot of good reasons to put images into the database, ie. if some clients directly work on db connections and all work (including image upload) should be done over the db link. cu -- --------------------------------------------------------------------- Enrico Weigelt == metux IT service phone: +49 36207 519931 www: http://www.metux.de/ fax: +49 36207 519932 email: contact@metux.de --------------------------------------------------------------------- Realtime Forex/Stock Exchange trading powered by postgresSQL :)) http://www.fxignal.net/ --------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Wed May 11 20:25:21 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6894B53C92 for ; Wed, 11 May 2005 20:25:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12234-07 for ; Wed, 11 May 2005 23:25:18 +0000 (GMT) Received: from gw2.emini.dk (gw2.emini.dk [192.38.9.232]) by svr1.postgresql.org (Postfix) with ESMTP id A7EFF53CDB for ; Wed, 11 May 2005 20:25:16 -0300 (ADT) Received: from blaster (gw1.emini.dk [212.242.124.121]) by gw2.emini.dk (Postfix) with ESMTP id 3FCF86A56E; Thu, 12 May 2005 01:24:58 +0200 (CEST) Message-ID: <003001c55681$216ba5c0$0b00000a@blaster> From: "Edin Kadribasic" To: "Tom Lane" Cc: "John A Meinel" , References: <001f01c55604$494d2e60$1200000a@intra.emini.dk> <3742.1115821114@sss.pgh.pa.us> Subject: Re: Optimizer wrongly picks Nested Loop Left Join Date: Thu, 12 May 2005 01:28:25 +0200 Organization: Emini ApS 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.3790.224 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.224 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/227 X-Sequence-Number: 12391 From: "Tom Lane" > "Edin Kadribasic" writes: > > I have a query that is giving the optimizer (and me) great headache. > > The main problem seems to be that the rowcount estimates for > axp_temp_order_match and axp_dayschedule are way off: > > > -> Index Scan using axp_temp_order_match_idx1 on > > axp_temp_order_match a (cost=0.00..209.65 rows=426 width=4) (actual > > time=0.277..0.512 rows=6 loops=1) > > Index Cond: (sid = 16072) > > > -> Index Scan using axp_dayschedule_day_idx on > > axp_dayschedule ds (cost=0.00..3.02 rows=1 width=8) (actual > > time=0.036..3.973 rows=610 loops=1) > > Index Cond: (("day" >= '2005-05-12'::date) > > AND ("day" <= '2005-05-12'::date)) > > Filter: (used = B'1'::"bit") > > > -> Index Scan using axp_temp_order_match_idx1 on > > axp_temp_order_match a (cost=0.00..2.45 rows=1 width=4) (actual > > time=0.027..2.980 rows=471 loops=1) > > Index Cond: (sid = 16092) > > > -> Index Scan using axp_dayschedule_day_idx on > > axp_dayschedule ds (cost=0.00..3.02 rows=1 width=8) (actual > > time=0.015..3.557 rows=606 loops=471) > > Index Cond: (("day" >= '2005-05-13'::date) AND > > ("day" <= '2005-05-13'::date)) > > Filter: (used = B'1'::"bit") > > Do you ANALYZE these tables on a regular basis? If so, it may be > necessary to increase the statistics target to the point where you > get better estimates. Increasing statistics didn't seem to help, but both of you gave me an idea of what might be wrong. axp_temp_order match contains temporary matches for a search. Just before execution of that query the new matches are inserted into the table under a new search id (sid column). Since the ANALYZE was that before it it grossly underestimates the number of matches for that sid. As this table is relatively small inserting ANALYZE axp_temp_order_match just before running the query does not introduce a great perforance penalty (50ms) and it reduces the query execution time from up to 50s down to ~20ms. > > Please note that sometimes when I get "bad plan" in the logfile, I just > > re-run the query and the optimizer chooses the more efficient one. > > That's fairly hard to believe, unless you've got autovacuum running > in the background. The application had ANALYZE axp_temp_order_match placed in the "slightly" wrong location, before the large insert was done (1000 rows with a new sid). So when the app run the next search, previous search got correctly analyzed and the query execution time dropped dramatically as I was trying to EXPLAIN ANALYZE query recorded in the log file. Thanks for your help, Edin From pgsql-performance-owner@postgresql.org Wed May 11 23:26:57 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 494DC5454A for ; Wed, 11 May 2005 23:26:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44890-04 for ; Thu, 12 May 2005 02:26:54 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id 83D2153330 for ; Wed, 11 May 2005 23:26:53 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j4C2QSL07363; Wed, 11 May 2005 22:26:28 -0400 (EDT) From: Bruce Momjian Message-Id: <200505120226.j4C2QSL07363@candle.pha.pa.us> Subject: Re: Intel SRCS16 SATA raid? In-Reply-To: To: Richard_D_Levine@raytheon.com Date: Wed, 11 May 2005 22:26:28 -0400 (EDT) Cc: Greg Stark , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/229 X-Sequence-Number: 12393 Richard_D_Levine@raytheon.com wrote: > Greg, > > I posted this link under a different thread (the $7k server thread). It is > a very good read on why SCSI is better for servers than ATA. I didn't note > bias, though it is from a drive manufacturer. YMMV. There is an > interesting, though dated appendix on different manufacturers' drive > characteristics. > > http://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdf I have read this and it is an _excellent_ read about disk drives. The bottom line is that the SCSI/IDE distinctions is more of an indicator of the drive, rather than the main feature of the drive. The main feature is that certain drives are Enterprise Storage and are designed for high reliability and speed, while Personal Server drives are designed for low cost. The IDE/SCSI issue is only an indicator of this. There are a lot more variabilities between these two types of drives than I knew. I recommend it for anyone who is choosing drives for a system. -- 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 May 12 06:07:52 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0D0625294C for ; Thu, 12 May 2005 06:07:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99223-07 for ; Thu, 12 May 2005 09:07:43 +0000 (GMT) Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) by svr1.postgresql.org (Postfix) with ESMTP id EC193565C1 for ; Thu, 12 May 2005 06:07:41 -0300 (ADT) Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.44) id 1DW9fU-00068Z-FL for pgsql-performance@postgresql.org; Thu, 12 May 2005 11:07:44 +0200 Received: from e176011089.adsl.alicedsl.de ([85.176.11.89] helo=[10.0.1.6]) by emma.rox.net with esmtpa (Exim 4.44) id 1DW9fT-00067n-1e for pgsql-performance@postgresql.org; Thu, 12 May 2005 11:07:43 +0200 Mime-Version: 1.0 (Apple Message framework v622) Content-Transfer-Encoding: 7bit Message-Id: <2aeb891e99fa6313e9e3a20d48c099aa@cluster9.com> Content-Type: text/plain; charset=US-ASCII; format=flowed To: PgSQL Performance ML From: David Teran Subject: AND OR combination: index not being used Date: Thu, 12 May 2005 11:07:41 +0200 X-Mailer: Apple Mail (2.622) X-Scanned-By: rockenstein AG X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/231 X-Sequence-Number: 12395 Hi, postgres 8.0.1, mac os x 10.3.9 i have a select with multiple OR's combined with one AND: explain analyze SELECT t0.ATTRIBUTE_TYPE FROM ATTRIBUTE_VALUE t0 WHERE (((t0.ATTRIBUTE_TYPE = 'pb'::varchar(10) OR t0.ATTRIBUTE_TYPE = 'po'::varchar(10) OR t0.ATTRIBUTE_TYPE = 'pn'::varchar(10) OR t0.ATTRIBUTE_TYPE = 'ps'::varchar(10))) AND t0.ID_ATTRIBUTE = 17::int8); The result is the following. It shows that postgres does not use an index which makes the select pretty slow. Seq Scan on attribute_value t0 (cost=0.00..529.13 rows=208 width=5) (actual time=66.591..66.591 rows=0 loops=1) Filter: ((((attribute_type)::text = 'pb'::text) OR ((attribute_type)::text = 'po'::text) OR ((attribute_type)::text = 'pn'::text) OR ((attribute_type)::text = 'ps'::text)) AND (id_attribute = 17::bigint)) Total runtime: 66.664 ms (3 rows) When i remove one OR qualifier one can see that now an index is used. explain analyze SELECT t0.ATTRIBUTE_TYPE FROM ATTRIBUTE_VALUE t0 WHERE (((t0.ATTRIBUTE_TYPE = 'pb'::varchar(10) OR t0.ATTRIBUTE_TYPE = 'po'::varchar(10) OR t0.ATTRIBUTE_TYPE = 'pn'::varchar(10))) AND t0.ID_ATTRIBUTE = 17::int8); Index Scan using attribute_value__attribute_type__id_attribute, attribute_value__attribute_type__id_attribute, attribute_value__attribute_type__id_attribute on attribute_value t0 (cost=0.00..451.82 rows=137 width=5) (actual time=0.301..0.301 rows=0 loops=1) Index Cond: ((((attribute_type)::text = 'pb'::text) AND (id_attribute = 17::bigint)) OR (((attribute_type)::text = 'po'::text) AND (id_attribute = 17::bigint)) OR (((attribute_type)::text = 'pn'::text) AND (id_attribute = 17::bigint))) Filter: ((((attribute_type)::text = 'pb'::text) OR ((attribute_type)::text = 'po'::text) OR ((attribute_type)::text = 'pn'::text)) AND (id_attribute = 17::bigint)) Total runtime: 0.414 ms (4 rows) When i do 'set enable_seqscan=no' the index is used of course. Unfortunately the sql is generated on the fly and its not easy, more or less impossible to selectively enable / disable seqscan. Any hint how to force postgres to use the index even with more OR parts? regards, David From pgsql-performance-owner@postgresql.org Thu May 12 07:03:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9CF18534E4 for ; Thu, 12 May 2005 07:03:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09936-01 for ; Thu, 12 May 2005 10:03:04 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id B4B0453393 for ; Thu, 12 May 2005 07:02:58 -0300 (ADT) Received: (qmail 20173 invoked from network); 12 May 2005 12:03:20 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 12 May 2005 12:03:20 +0200 To: weigelt@metux.de, pgsql-performance@postgresql.org Subject: Re: BLOB's bypassing the OS Filesystem for better Image loading speed? References: <426DFA46.8090402@yahoo.de> <20050511232623.GE6485@nibiru.borg.metux.de> Message-ID: Date: Thu, 12 May 2005 12:02:56 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <20050511232623.GE6485@nibiru.borg.metux.de> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/232 X-Sequence-Number: 12396 >> Filesystems with many Filesystem Objects can slow down the Performance >> at opening and reading Data. On my laptop, lighttpd takes upto 15000 hits PER SECOND on static 2-3 Kb files (tested with apachebench 2). Apache is slower, of course : 3-4000 hits per second which is not that bad. Using a dynamic script with images in the database, you should account for query and transmission overhead, dynamic page overhead... mmm, I'd say using a fast application server you could maybe get 2-300 images served per second from the database, and that's very optimistic. And then the database will crawl, it will be disintegrated by the incoming flow of useless requests... scalability will be awful... Not mentioning that browsers ask the server "has this image changed since the last time ?" (HEAD request) and then they don't download it if it doesn't. The server just stat()'s the file. statting a file on any decent filesystem (ie. XFS Reiser JFS etc.) should take less than 10 microseconds if the information is in the cache. You'll have to look in the database to check the date... more queries ! If you want to control download rights on files, you can still put the files on the filesystem (which is the right choice IMHO) and use a dynamic script to serve them. Even better, you could use lighttpd's authorized file download feature. The only case I see putting files in a database as interesting is if you want them to be part of a transaction. In that case, why not... From pgsql-performance-owner@postgresql.org Thu May 12 07:09:50 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 797F65358E for ; Thu, 12 May 2005 07:09:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07672-10 for ; Thu, 12 May 2005 10:09:35 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id BDBC0534E4 for ; Thu, 12 May 2005 07:09:32 -0300 (ADT) Received: (qmail 20525 invoked from network); 12 May 2005 12:09:58 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 12 May 2005 12:09:58 +0200 Date: Thu, 12 May 2005 12:09:34 +0200 To: "Alex Stapleton" Subject: Re: Partitioning / Clustering Cc: josh@agliodbs.com, "David Roussel" , pgsql-performance@postgresql.org References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <1115798277.29223.233869472@webmail.messagingengine.com> <200505111013.52067.josh@agliodbs.com> From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <1115798277.29223.233869472@webmail.messagingengine.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/233 X-Sequence-Number: 12397 > machines. Which has it's own set of issues entirely. I am not entirely > sure that memcached actually does serialize data when it's comitted into I think it does, ie. it's a simple mapping of [string key] => [string value]. > memcached either, although I could be wrong, I have not looked at the > source. Certainly if you can ensure that a client always goes back to > the same machine you can simplify the whole thing hugely. It's generally > not that easy though, you need a proxy server of some description > capable of understanding the HTTP traffic and maintaining a central Yes... You could implement it by mapping servers to the hash of the user session id. Statistically, the servers would get the same numbers of sessions on each of them, but you have to trust statistics... It does eliminate the lookup table though. > idea, I would like to hear a way of implementing them cheaply (and on > PHP) as well. I may have to give that some thought in fact. Oh yeah, and > load balancers software often sucks in annoying (if not always > important) ways. You can use lighttpd as a load balancer, I believe it has a stick sessions plugin (or you could code one in, it's open source after all). It definitely support simple round-robin load balancing, acting as a proxy to any number of independent servers. >> matter, it's pretty impressive. The google filesystem has nothing to do >> with databases though, it's more a massive data store / streaming >> storage. > > Since when did Massive Data stores have nothing to do with DBs? Isn't > Oracle Cluster entirely based on forming an enormous scalable disk array > to store your DB on? Um, well, the Google Filesystem is (like its name implies) a filesystem designed to store huge files in a distributed and redundant manner. Files are structured as a stream of records (which are themselves big in size) and it's designed to support appending records to these stream files efficiently and without worrying about locking. It has no querying features however, that is why I said it was not a database. I wish I could find the whitepaper, I think the URL was on this list some day, maybe it's on Google's site ? From pgsql-performance-owner@postgresql.org Thu May 12 07:34:51 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5558A535ED for ; Thu, 12 May 2005 07:34:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11755-06 for ; Thu, 12 May 2005 10:34:46 +0000 (GMT) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 5FDB4533DF for ; Thu, 12 May 2005 07:34:44 -0300 (ADT) Received: (qmail 27869 invoked by uid 0); 12 May 2005 10:34:46 -0000 Received: from 217.17.202.254 by www73.gmx.net with HTTP; Thu, 12 May 2005 12:34:46 +0200 (MEST) Date: Thu, 12 May 2005 12:34:46 +0200 (MEST) From: "Marc Mamin" To: pgsql-performance@postgresql.org MIME-Version: 1.0 Subject: tuning Postgres for large data import (using Copy from) X-Priority: 3 (Normal) X-Authenticated: #3793498 Message-ID: <6428.1115894086@www73.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/234 X-Sequence-Number: 12398 Hello, I'd like to tune Postgres for large data import (using Copy from). here are a few steps already done: 1) use 3 different disks for: -1: source data -2: index tablespaces -3: data tablespaces 2) define all foreign keys as initially deferred 3) tune some parameters: max_connections =20 shared_buffers =30000 work_mem = 8192 maintenance_work_mem = 32768 checkpoint_segments = 12 (I also modified the kernel accordingly) 4) runs VACUUM regulary The server runs RedHat and has 1GB RAM In the production (which may run on a better server), I plan to: - import a few millions rows per day, - keep up to ca 100 millions rows in the db - delete older data I've seen a few posting on hash/btree indexes, which say that hash index do not work very well in Postgres; currently, I only use btree indexes. Could I gain performances whole using hash indexes as well ? How does Postgres handle concurrent copy from on: same table / different tables ? I'd be glad on any further suggestion on how to further increase my performances. Marc -- +++ Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS +++ GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail From pgsql-performance-owner@postgresql.org Thu May 12 11:08:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0396A5368C for ; Thu, 12 May 2005 11:08:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47042-01 for ; Thu, 12 May 2005 14:08:05 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) by svr1.postgresql.org (Postfix) with ESMTP id 77B2253657 for ; Thu, 12 May 2005 11:08:04 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so732582wri for ; Thu, 12 May 2005 07:08:09 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=pOrC3lvw5ZDBfR68sb/ESvwgN4rU7i9JSbe26XRYFQxbOoy40xnMRChyEfeGaMHUEKh/hy6cfhIbGBSpRVZTCEN4waCkoUjzrBi85bG0hOHaa3ecZHJO4p0buT8Fx9RLgeRxFw5AngNYEyggYdIhoCD8NcXqrE+fUgrOV6ECe4E= Received: by 10.54.26.2 with SMTP id 2mr1150896wrz; Thu, 12 May 2005 07:08:09 -0700 (PDT) Received: by 10.54.86.16 with HTTP; Thu, 12 May 2005 07:08:09 -0700 (PDT) Message-ID: <33c6269f050512070842df1af3@mail.gmail.com> Date: Thu, 12 May 2005 10:08:09 -0400 From: Alex Turner Reply-To: Alex Turner To: PFC Subject: Re: Partitioning / Clustering Cc: josh@agliodbs.com, David Roussel , Alex Stapleton , pgsql-performance@postgresql.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <200505111013.52067.josh@agliodbs.com> <1115798277.29223.233869472@webmail.messagingengine.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.286 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/235 X-Sequence-Number: 12399 Having local sessions is unnesesary, and here is my logic: Generaly most people have less than 100Mb of bandwidth to the internet. If you make the assertion that you are transferring equal or less session data between your session server (lets say an RDBMS) and the app server than you are between the app server and the client, an out of band 100Mb network for session information is plenty of bandwidth.=20 This also represents OLTP style traffic, which postgresql is pretty good at. You should easily be able to get over 100Tps. 100 hits per second is an awful lot of traffic, more than any website I've managed will ever see. Why solve the complicated clustered sessions problem, when you don't really need to? Alex Turner netEconomist On 5/11/05, PFC wrote: >=20 >=20 > > However, memcached (and for us, pg_memcached) is an excellent way to > > improve > > horizontal scalability by taking disposable data (like session > > information) > > out of the database and putting it in protected RAM. >=20 > So, what is the advantage of such a system versus, say, a "sticky > sessions" system where each session is assigned to ONE application server > (not PHP then) which keeps it in RAM as native objects instead of > serializing and deserializing it on each request ? > I'd say the sticky sessions should perform a lot better, and if o= ne > machine dies, only the sessions on this one are lost. > But of course you can't do it with PHP as you need an app server = which > can manage sessions. Potentially the savings are huge, though. >=20 > On Google, their distributed system spans a huge number of PCs an= d it has > redundancy, ie. individual PC failure is a normal thing and is a part of > the system, it is handled gracefully. I read a paper on this matter, it's > pretty impressive. The google filesystem has nothing to do with databases > though, it's more a massive data store / streaming storage. >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > From pgsql-performance-owner@postgresql.org Thu May 12 11:15:40 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 13DFE5366F for ; Thu, 12 May 2005 11:15:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46848-06 for ; Thu, 12 May 2005 14:15:26 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id F2BFB5362D for ; Thu, 12 May 2005 11:15:25 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4CEFQdX000255; Thu, 12 May 2005 10:15:26 -0400 (EDT) To: David Teran Cc: PgSQL Performance ML Subject: Re: AND OR combination: index not being used In-reply-to: <2aeb891e99fa6313e9e3a20d48c099aa@cluster9.com> References: <2aeb891e99fa6313e9e3a20d48c099aa@cluster9.com> Comments: In-reply-to David Teran message dated "Thu, 12 May 2005 11:07:41 +0200" Date: Thu, 12 May 2005 10:15:26 -0400 Message-ID: <254.1115907326@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/236 X-Sequence-Number: 12400 David Teran writes: > Any hint how > to force postgres to use the index even with more OR parts? More up-to-date statistics would evidently help; the thing is estimating hundreds of rows returned and actually finding none. regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 12 11:31:49 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC58153BE6 for ; Thu, 12 May 2005 11:31:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50787-05 for ; Thu, 12 May 2005 14:31:39 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D804D53389 for ; Thu, 12 May 2005 11:31:38 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4CEVIBN000420; Thu, 12 May 2005 10:31:19 -0400 (EDT) To: "Marc Mamin" Cc: pgsql-performance@postgresql.org Subject: Re: tuning Postgres for large data import (using Copy from) In-reply-to: <6428.1115894086@www73.gmx.net> References: <6428.1115894086@www73.gmx.net> Comments: In-reply-to "Marc Mamin" message dated "Thu, 12 May 2005 12:34:46 +0200" Date: Thu, 12 May 2005 10:31:18 -0400 Message-ID: <419.1115908278@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/237 X-Sequence-Number: 12401 "Marc Mamin" writes: > 1) use 3 different disks for: > -1: source data > -2: index tablespaces > -3: data tablespaces It's probably much more important to know where you put the WAL. regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 12 11:53:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0495D53B98 for ; Thu, 12 May 2005 11:53:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53189-09 for ; Thu, 12 May 2005 14:53:49 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id C2A0C5353B for ; Thu, 12 May 2005 11:53:47 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4CErbM8014960; (envelope-from ) Thu, 12 May 2005 09:53:37 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4CErZjM011700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Thu, 12 May 2005 09:53:36 -0500 (CDT) Message-ID: <42836DEB.30600@arbash-meinel.com> Date: Thu, 12 May 2005 09:53:31 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Marc Mamin Cc: pgsql-performance@postgresql.org Subject: Re: tuning Postgres for large data import (using Copy from) References: <6428.1115894086@www73.gmx.net> In-Reply-To: <6428.1115894086@www73.gmx.net> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig153E7A3344FAE939945CDA4F" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/238 X-Sequence-Number: 12402 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig153E7A3344FAE939945CDA4F Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Marc Mamin wrote: > Hello, > I'm not an expert, but I'll give some suggestions. > > I'd like to tune Postgres for large data import (using Copy from). > I believe that COPY FROM is supposed to be faster than COPY FROM STDIN, but must be available to the backend process. If you can do it, you should think about it, as it eliminates the communication between the client and the backend. > > here are a few steps already done: > > > > 1) use 3 different disks for: > > -1: source data > -2: index tablespaces > -3: data tablespaces > Make sure pg_xlog is on it's own filesystem. It contains the write-ahead-log, and putting it by itself keeps the number of seeks down. If you are constrained, I think pg_xlog is more important than moving the index tablespaces. > > 2) define all foreign keys as initially deferred > > > 3) tune some parameters: > > > > max_connections =20 > shared_buffers =30000 > work_mem = 8192 > maintenance_work_mem = 32768 > checkpoint_segments = 12 > > (I also modified the kernel accordingly) > Don't forget to increase your free space map if you are going to be doing deletes frequently. > > > > 4) runs VACUUM regulary > > > The server runs RedHat and has 1GB RAM > > In the production (which may run on a better server), I plan to: > > - import a few millions rows per day, > - keep up to ca 100 millions rows in the db > - delete older data > > > > > I've seen a few posting on hash/btree indexes, which say that hash index do > not work very well in Postgres; > currently, I only use btree indexes. Could I gain performances whole using > hash indexes as well ? > I doubt it. > How does Postgres handle concurrent copy from on: same table / different > tables ? > I think it is better with different tables. If using the same table, and there are indexes, it has to grab a lock for updating the index, which causes contention between 2 processes writing to the same table. > > I'd be glad on any further suggestion on how to further increase my > performances. > Since you are deleting data often, and copying often, I might recommend using a partition scheme with a view to bind everything together. That way you can just drop the old table rather than doing a delete. I don't know how this would affect foreign key references. But basically you can create a new table, and do a copy without having any indexes, then build the indexes, analyze, update the view. And when deleting you can update the view, and drop the old table. Something like this: CREATE TABLE table_2005_05_11 AS (blah); COPY FROM ... ; CREATE INDEX blah ON table_2005_05_11(blah); CREATE OR REPLACE VIEW table AS SELECT * FROM table_2005_05_10 UNION ALL SELECT * FROM table_2005_05_11; VACUUM ANALYZE table_2005_05_11; ... John =:-> > > > > Marc > > > > --------------enig153E7A3344FAE939945CDA4F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCg23uJdeBCYSNAAMRAlOPAJ44hWVGbQV6Rds/rK5VvTn2D6OnGwCgoJTJ +hDJNpE7k67zmFZmSegHbHo= =en2R -----END PGP SIGNATURE----- --------------enig153E7A3344FAE939945CDA4F-- From pgsql-performance-owner@postgresql.org Thu May 12 12:17:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 313905321B for ; Thu, 12 May 2005 12:17:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59911-06 for ; Thu, 12 May 2005 15:17:01 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id 2893652A7D for ; Thu, 12 May 2005 12:16:58 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-10.tower-49.messagelabs.com!1115911015!208772!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 14432 invoked from network); 12 May 2005 15:16:55 -0000 Received: from mail.advfn.com (212.161.99.149) by server-10.tower-49.messagelabs.com with SMTP; 12 May 2005 15:16:55 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DWFQk-0007PE-SI; Thu, 12 May 2005 16:16:54 +0100 In-Reply-To: <33c6269f050512070842df1af3@mail.gmail.com> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <200505111013.52067.josh@agliodbs.com> <1115798277.29223.233869472@webmail.messagingengine.com> <33c6269f050512070842df1af3@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <360CDE65-3FAF-428A-BA25-6F6ECCAA5689@advfn.com> Cc: PFC , josh@agliodbs.com, David Roussel , pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Partitioning / Clustering Date: Thu, 12 May 2005 16:16:53 +0100 To: Alex Turner X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/239 X-Sequence-Number: 12403 On 12 May 2005, at 15:08, Alex Turner wrote: > Having local sessions is unnesesary, and here is my logic: > > Generaly most people have less than 100Mb of bandwidth to the > internet. > > If you make the assertion that you are transferring equal or less > session data between your session server (lets say an RDBMS) and the > app server than you are between the app server and the client, an out > of band 100Mb network for session information is plenty of bandwidth. > This also represents OLTP style traffic, which postgresql is pretty > good at. You should easily be able to get over 100Tps. 100 hits per > second is an awful lot of traffic, more than any website I've managed > will ever see. > > Why solve the complicated clustered sessions problem, when you don't > really need to? 100 hits a second = 8,640,000 hits a day. I work on a site which does > 100 million dynamic pages a day. In comparison Yahoo probably does > 100,000,000,000 (100 billion) views a day if I am interpreting Alexa's charts correctly. Which is about 1,150,000 a second. Now considering the site I work on is not even in the top 1000 on Alexa, theres a lot of sites out there which need to solve this problem I would assume. There are also only so many hash table lookups a single machine can do, even if its a Quad Opteron behemoth. > Alex Turner > netEconomist > > On 5/11/05, PFC wrote: > >> >> >> >>> However, memcached (and for us, pg_memcached) is an excellent way to >>> improve >>> horizontal scalability by taking disposable data (like session >>> information) >>> out of the database and putting it in protected RAM. >>> >> >> So, what is the advantage of such a system versus, say, a >> "sticky >> sessions" system where each session is assigned to ONE application >> server >> (not PHP then) which keeps it in RAM as native objects instead of >> serializing and deserializing it on each request ? >> I'd say the sticky sessions should perform a lot better, >> and if one >> machine dies, only the sessions on this one are lost. >> But of course you can't do it with PHP as you need an app >> server which >> can manage sessions. Potentially the savings are huge, though. >> >> On Google, their distributed system spans a huge number of >> PCs and it has >> redundancy, ie. individual PC failure is a normal thing and is a >> part of >> the system, it is handled gracefully. I read a paper on this >> matter, it's >> pretty impressive. The google filesystem has nothing to do with >> databases >> though, it's more a massive data store / streaming storage. >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 1: subscribe and unsubscribe commands go to >> majordomo@postgresql.org >> >> > > From pgsql-performance-owner@postgresql.org Thu May 12 13:05:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5C8E453429 for ; Thu, 12 May 2005 13:05:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70243-08 for ; Thu, 12 May 2005 16:05:33 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by svr1.postgresql.org (Postfix) with ESMTP id 430D35294D for ; Thu, 12 May 2005 13:05:32 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so778441wri for ; Thu, 12 May 2005 09:05:33 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=iDVPA1MQRh6yIh2pMK4t5GKH7ymLH1xiemJXSAAyHWPlmuvbt8iH4kmHnalZ7fSbWqId1yfHwZYXpjmcZP3gJiGDq2OQStG9q/iJE2f9B7mdOlnjNNOEQSeeHRNMZcPNaMy43cc8gqGsYvK+JSvJiEydPvvWOXvWNFg5TfXxhHU= Received: by 10.54.51.17 with SMTP id y17mr1199196wry; Thu, 12 May 2005 09:05:32 -0700 (PDT) Received: by 10.54.86.16 with HTTP; Thu, 12 May 2005 09:05:32 -0700 (PDT) Message-ID: <33c6269f0505120905192dc723@mail.gmail.com> Date: Thu, 12 May 2005 12:05:32 -0400 From: Alex Turner Reply-To: Alex Turner To: Alex Stapleton Subject: Re: Partitioning / Clustering Cc: PFC , josh@agliodbs.com, David Roussel , pgsql-performance@postgresql.org In-Reply-To: <360CDE65-3FAF-428A-BA25-6F6ECCAA5689@advfn.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <200505111013.52067.josh@agliodbs.com> <1115798277.29223.233869472@webmail.messagingengine.com> <33c6269f050512070842df1af3@mail.gmail.com> <360CDE65-3FAF-428A-BA25-6F6ECCAA5689@advfn.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.286 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/240 X-Sequence-Number: 12404 Ok - my common sense alarm is going off here... There are only 6.446 billion people worldwide. 100 Billion page views would require every person in the world to view 18 pages of yahoo every day. Not very likely. http://www.internetworldstats.com/stats.htm suggests that there are around 1 billion people actualy on the internet. That means each and every person on the internet has to view 100 pages per day of yahoo. pretty unlikely IMHO. I for one don't even use Yahoo ;) 100 million page views per day suggests that 1 in 100 people on the internet each viewed 10 pages of a site. Thats a pretty high percentage if you ask me. If I visit 20 web sites in a day, and see an average of 10 pages per site. that means only about 2000 or so sites generate 100 million page views in a day or better. 100 million pageviews averages to 1157/sec, which we'll double for peak load to 2314. I can easily see a system doing 2314 hash lookups per second. Hell I wrote a system that could do a thousand times that four years ago on a single 1Ghz Athlon. Heck - you can get 2314 lookups/sec on a 486 ;) Given that session information doesn't _have_ to persist to storage, and can be kept in RAM. A single server could readily manage session information for even very large sites (of course over a million concurrent users could really start chewing into RAM, but if you are Yahoo, you can probably afford a box with 100GB of RAM ;). We get over 1000 tps on a dual opteron with a couple of mid size RAID arrays on 10k discs with fsync on for small transactions. I'm sure that could easily be bettered with a few more dollars. Maybe my number are off, but somehow it doesn't seem like that many people need a highly complex session solution to me. Alex Turner netEconomist On 5/12/05, Alex Stapleton wrote: >=20 > On 12 May 2005, at 15:08, Alex Turner wrote: >=20 > > Having local sessions is unnesesary, and here is my logic: > > > > Generaly most people have less than 100Mb of bandwidth to the > > internet. > > > > If you make the assertion that you are transferring equal or less > > session data between your session server (lets say an RDBMS) and the > > app server than you are between the app server and the client, an out > > of band 100Mb network for session information is plenty of bandwidth. > > This also represents OLTP style traffic, which postgresql is pretty > > good at. You should easily be able to get over 100Tps. 100 hits per > > second is an awful lot of traffic, more than any website I've managed > > will ever see. > > > > Why solve the complicated clustered sessions problem, when you don't > > really need to? >=20 > 100 hits a second =3D 8,640,000 hits a day. I work on a site which does > > 100 million dynamic pages a day. In comparison Yahoo probably does > > 100,000,000,000 (100 billion) views a day > if I am interpreting Alexa's charts correctly. Which is about > 1,150,000 a second. >=20 > Now considering the site I work on is not even in the top 1000 on > Alexa, theres a lot of sites out there which need to solve this > problem I would assume. >=20 > There are also only so many hash table lookups a single machine can > do, even if its a Quad Opteron behemoth. >=20 >=20 > > Alex Turner > > netEconomist > > > > On 5/11/05, PFC wrote: > > > >> > >> > >> > >>> However, memcached (and for us, pg_memcached) is an excellent way to > >>> improve > >>> horizontal scalability by taking disposable data (like session > >>> information) > >>> out of the database and putting it in protected RAM. > >>> > >> > >> So, what is the advantage of such a system versus, say, a > >> "sticky > >> sessions" system where each session is assigned to ONE application > >> server > >> (not PHP then) which keeps it in RAM as native objects instead of > >> serializing and deserializing it on each request ? > >> I'd say the sticky sessions should perform a lot better, > >> and if one > >> machine dies, only the sessions on this one are lost. > >> But of course you can't do it with PHP as you need an app > >> server which > >> can manage sessions. Potentially the savings are huge, though. > >> > >> On Google, their distributed system spans a huge number of > >> PCs and it has > >> redundancy, ie. individual PC failure is a normal thing and is a > >> part of > >> the system, it is handled gracefully. I read a paper on this > >> matter, it's > >> pretty impressive. The google filesystem has nothing to do with > >> databases > >> though, it's more a massive data store / streaming storage. > >> > >> ---------------------------(end of > >> broadcast)--------------------------- > >> TIP 1: subscribe and unsubscribe commands go to > >> majordomo@postgresql.org > >> > >> > > > > >=20 > From pgsql-performance-owner@postgresql.org Thu May 12 13:22:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 84BD953526 for ; Thu, 12 May 2005 13:22:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73276-09 for ; Thu, 12 May 2005 16:21:56 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 3A48E53429 for ; Thu, 12 May 2005 13:21:55 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4CGK1cB019009; (envelope-from ) Thu, 12 May 2005 11:20:01 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4CGJuiE010054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Thu, 12 May 2005 11:19:57 -0500 (CDT) Message-ID: <4283822C.5010305@arbash-meinel.com> Date: Thu, 12 May 2005 11:19:56 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alex Turner Cc: Alex Stapleton , PFC , josh@agliodbs.com, David Roussel , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <200505111013.52067.josh@agliodbs.com> <1115798277.29223.233869472@webmail.messagingengine.com> <33c6269f050512070842df1af3@mail.gmail.com> <360CDE65-3FAF-428A-BA25-6F6ECCAA5689@advfn.com> <33c6269f0505120905192dc723@mail.gmail.com> In-Reply-To: <33c6269f0505120905192dc723@mail.gmail.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigE5BADADFA3137300EDC25CE6" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/241 X-Sequence-Number: 12405 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigE5BADADFA3137300EDC25CE6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Alex Turner wrote: > Ok - my common sense alarm is going off here... > > There are only 6.446 billion people worldwide. 100 Billion page views > would require every person in the world to view 18 pages of yahoo > every day. Not very likely. > > http://www.internetworldstats.com/stats.htm > suggests that there are around 1 billion people actualy on the internet. > > That means each and every person on the internet has to view 100 pages > per day of yahoo. > > pretty unlikely IMHO. I for one don't even use Yahoo ;) > > 100 million page views per day suggests that 1 in 100 people on the > internet each viewed 10 pages of a site. Thats a pretty high > percentage if you ask me. In general I think your point is valid. Just remember that it probably also matters how you count page views. Because technically images are a separate page (and this thread did discuss serving up images). So if there are 20 graphics on a specific page, that is 20 server hits just for that one page. I could easily see an image heavy site getting 100 hits / page. Which starts meaning that if 1M users hit 10 pages, then you get 1M*10*100 = 1G. I still think 100G views on a single website is a lot, but 100M is certainly possible. John =:-> --------------enigE5BADADFA3137300EDC25CE6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCg4IsJdeBCYSNAAMRAmaRAJ4m2Dzt0AO8CvntaWhshLQs0NNN1QCfZ+rq ZRho2V4L3CgwxJtAgcUsAKg= =V13o -----END PGP SIGNATURE----- --------------enigE5BADADFA3137300EDC25CE6-- From pgsql-performance-owner@postgresql.org Thu May 12 13:27:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3624453583 for ; Thu, 12 May 2005 13:27:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74873-07 for ; Thu, 12 May 2005 16:27:06 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 7DB4853570 for ; Thu, 12 May 2005 13:27:04 -0300 (ADT) Received: (qmail 6553 invoked from network); 12 May 2005 18:27:27 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 12 May 2005 18:27:27 +0200 To: "Alex Stapleton" , "Alex Turner" Cc: josh@agliodbs.com, "David Roussel" , pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <200505111013.52067.josh@agliodbs.com> <1115798277.29223.233869472@webmail.messagingengine.com> <33c6269f050512070842df1af3@mail.gmail.com> <360CDE65-3FAF-428A-BA25-6F6ECCAA5689@advfn.com> Message-ID: From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Thu, 12 May 2005 18:25:05 +0200 In-Reply-To: <200505111013.52067.josh@agliodbs.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/242 X-Sequence-Number: 12406 > 100 hits a second = 8,640,000 hits a day. I work on a site which does > > 100 million dynamic pages a day. In comparison Yahoo probably does > > 100,000,000,000 (100 billion) views a day > if I am interpreting Alexa's charts correctly. Which is about > 1,150,000 a second. Read the help on Alexa's site... ;) From pgsql-performance-owner@postgresql.org Thu May 12 14:25:51 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0737353658 for ; Thu, 12 May 2005 14:25:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85918-06 for ; Thu, 12 May 2005 17:25:41 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 1C79453635 for ; Thu, 12 May 2005 14:25:40 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7354759; Thu, 12 May 2005 10:27:40 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: "Marc Mamin" Subject: Re: tuning Postgres for large data import (using Copy from) Date: Thu, 12 May 2005 10:25:41 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <6428.1115894086@www73.gmx.net> In-Reply-To: <6428.1115894086@www73.gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505121025.41556.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/243 X-Sequence-Number: 12407 Marc, > 1) use 3 different disks for: > > -1: source data > -2: index tablespaces > -3: data tablespaces Others have already told you about the importance of relocating WAL. If you are going to be building indexes on the imported data, you might find it beneficial to relocate pgsql_tmp for the database in question as well. Also, I generally find it more beneficial to seperate the few largest tables to their own disk resources than to put all tables on one resource and all disks on another. For example, for TPCH-like tests, I do array0: OS and pgsql_tmp array1: LINEITEM array2: LINEITEM Indexes array3: all other tables and indexes array4: pg_xlog array5: source data This allows me to load a 100G (actually 270G) TPCH-like database in < 2 hours, not counting index-building. > 2) define all foreign keys as initially deferred It would be better to drop them before import and recreate them afterwards. Same for indexes unless those indexes are over 2G in size. > max_connections =20 > shared_buffers =30000 > work_mem = 8192 Not high enough, unless you have very little RAM. On an 8G machine I'm using 256MB. You might want to use 64MB or 128MB. > maintenance_work_mem = 32768 REALLY not high enough. You're going to need to build big indexes and possibly vacuum large tables. I use the maximum of 1.98GB. Use up to 1/3 of your RAM for this. > checkpoint_segments = 12 Also way too low. Put pg_xlog on its own disk, give in 128 to 512 segments (up to 8G). > The server runs RedHat and has 1GB RAM Make sure you're running a 2.6.10+ kernel. Make sure ext3 is set noatime, data=writeback. Buy more RAM. Etc. > How does Postgres handle concurrent copy from on: same table / different > tables ? Same table is useless; the imports will effectively serialize (unless you use pseudo-partitioning). You can parallel load on multiple tables up to the lower of your number of disk channels or number of processors. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu May 12 14:33:48 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1489E53349 for ; Thu, 12 May 2005 14:33:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87823-01 for ; Thu, 12 May 2005 17:33:38 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id B53F553237 for ; Thu, 12 May 2005 14:33:38 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7354802 for pgsql-performance@postgresql.org; Thu, 12 May 2005 10:35:39 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering Date: Thu, 12 May 2005 10:33:41 -0700 User-Agent: KMail/1.8 References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <33c6269f0505120905192dc723@mail.gmail.com> <4283822C.5010305@arbash-meinel.com> In-Reply-To: <4283822C.5010305@arbash-meinel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505121033.41254.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/244 X-Sequence-Number: 12408 People, > In general I think your point is valid. Just remember that it probably > also matters how you count page views. Because technically images are a > separate page (and this thread did discuss serving up images). So if > there are 20 graphics on a specific page, that is 20 server hits just > for that one page. Also, there's bots and screen-scrapers and RSS, web e-mails, and web services and many other things which create hits but are not "people". I'm currently working on clickstream for a site which is nowhere in the top 100, and is getting 3 million real hits a day ... and we know for a fact that at least 1/4 of that is bots. Regardless, the strategy you should be employing for a high traffic site is that if your users hit the database for anything other than direct interaction (like filling out a webform) then you're lost. Use memcached, squid, lighttpd caching, ASP.NET caching, pools, etc. Keep the load off the database except for the stuff that only the database can do. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu May 12 14:45:48 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1C2F553657 for ; Thu, 12 May 2005 14:45:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91063-03 for ; Thu, 12 May 2005 17:45:37 +0000 (GMT) Received: from mail49.messagelabs.com (mail49.messagelabs.com [193.109.255.19]) by svr1.postgresql.org (Postfix) with SMTP id 846D7533A0 for ; Thu, 12 May 2005 14:45:35 -0300 (ADT) X-VirusChecked: Checked X-Env-Sender: alexs@advfn.com X-Msg-Ref: server-8.tower-49.messagelabs.com!1115919935!16497983!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [212.161.99.149] Received: (qmail 26879 invoked from network); 12 May 2005 17:45:35 -0000 Received: from mail.advfn.com (212.161.99.149) by server-8.tower-49.messagelabs.com with SMTP; 12 May 2005 17:45:35 -0000 Received: from [213.86.19.101] (helo=[192.168.0.185]) by mail.advfn.com with esmtp (Exim 4.22) id 1DWHkc-0003Zx-Rd; Thu, 12 May 2005 18:45:34 +0100 In-Reply-To: <200505121033.41254.josh@agliodbs.com> References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <33c6269f0505120905192dc723@mail.gmail.com> <4283822C.5010305@arbash-meinel.com> <200505121033.41254.josh@agliodbs.com> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Partitioning / Clustering Date: Thu, 12 May 2005 18:45:32 +0100 To: Josh Berkus X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/245 X-Sequence-Number: 12409 On 12 May 2005, at 18:33, Josh Berkus wrote: > People, > > >> In general I think your point is valid. Just remember that it >> probably >> also matters how you count page views. Because technically images >> are a >> separate page (and this thread did discuss serving up images). So if >> there are 20 graphics on a specific page, that is 20 server hits just >> for that one page. >> > > Also, there's bots and screen-scrapers and RSS, web e-mails, and > web services > and many other things which create hits but are not "people". I'm > currently > working on clickstream for a site which is nowhere in the top 100, > and is > getting 3 million real hits a day ... and we know for a fact that > at least > 1/4 of that is bots. I doubt bots are generally Alexa toolbar enabled. > Regardless, the strategy you should be employing for a high traffic > site is > that if your users hit the database for anything other than direct > interaction (like filling out a webform) then you're lost. Use > memcached, > squid, lighttpd caching, ASP.NET caching, pools, etc. Keep the > load off the > database except for the stuff that only the database can do. This is the aproach I would take as well. There is no point storing stuff in a DB, if your only doing direct lookups on it and it isn't the sort of data that you care so much about the integrity of. > -- > Josh Berkus > Aglio Database Solutions > San Francisco > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend > > From pgsql-performance-owner@postgresql.org Thu May 12 15:50:35 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 152805335D for ; Thu, 12 May 2005 15:50:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49041-05 for ; Thu, 12 May 2005 18:50:26 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 6116D53330 for ; Thu, 12 May 2005 15:50:25 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7355101; Thu, 12 May 2005 11:52:27 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Mohan, Ross" Subject: Re: Partitioning / Clustering Date: Thu, 12 May 2005 11:51:44 -0700 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505121151.45105.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.047 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/246 X-Sequence-Number: 12410 Ross, > Memcached is a PG memory store, I gather, Nope. It's a hyperfast resident-in-memory hash that allows you to stash stuff like user session information and even materialized query set results. Thanks to SeanC, we even have a plugin, pgmemcached. > but...what is squid, lighttpd? > anything directly PG-related? No. These are all related to making the web server do more. The idea is NOT to hit the database every time you have to serve up a web page, and possibly not to hit the web server either. For example, you can use squid 3 for "reverse" caching in front of your web server, and serve far more page views than you could with Apache alone. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu May 12 15:51:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8B50753657 for ; Thu, 12 May 2005 15:51:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89168-05 for ; Thu, 12 May 2005 18:51:55 +0000 (GMT) Received: from email.aon.at (warsl404pip8.highway.telekom.at [195.3.96.102]) by svr1.postgresql.org (Postfix) with ESMTP id 27541535EC for ; Thu, 12 May 2005 15:51:54 -0300 (ADT) Received: (qmail 6765 invoked from network); 12 May 2005 18:51:47 -0000 Received: from m160p027.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.251]) (envelope-sender ) by smarthub71.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 12 May 2005 18:51:47 -0000 From: Manfred Koizar To: "Jim C. Nasby" Cc: Tom Lane , Dave Held , pgsql-performance@postgresql.org Subject: Re: Sort and index Date: Thu, 12 May 2005 20:54:48 +0200 Message-ID: <45678156iqld6sd5n63baovuvqj73palmr@email.aon.at> References: <49E94D0CFCD4DB43AFBA928DDD20C8F9026184B6@asg002.asg.local> <20050420004234.GX58835@decibel.org> <19631.1113966086@sss.pgh.pa.us> <20050420034041.GC58835@decibel.org> <20050423015404.GV58835@decibel.org> <4269.1114222086@sss.pgh.pa.us> <20050423030002.GY58835@decibel.org> <6536.1114232440@sss.pgh.pa.us> <20050424220146.GN58835@decibel.org> <20050511211516.GX31103@decibel.org> In-Reply-To: <20050511211516.GX31103@decibel.org> X-Mailer: Forte Agent 2.0/32.652 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.346 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/247 X-Sequence-Number: 12411 On Wed, 11 May 2005 16:15:16 -0500, "Jim C. Nasby" wrote: >> This is divided by the number of index columns, so the index correlation >> is estimated to be 0.219. > >That seems like a pretty bad assumption to make. Any assumption we make without looking at entire index tuples has to be bad. A new GUC variable secondary_correlation introduced by my patch at least gives you a chance to manually control the effects of additional index columns. >> In my tests I got much more plausible results with >> >> 1 - (1 - abs(correlation))^2 > >What's the theory behind that? The same as for csquared -- pure intuition. But the numbers presented in http://archives.postgresql.org/pgsql-hackers/2002-10/msg00072.php seem to imply that in this case my intiution is better ;-) Actually above formula was not proposed in that mail. AFAIR it gives results between p2 and p3. >And I'd still like to know why correlation squared is used. On Wed, 02 Oct 2002 18:48:49 -0400, Tom Lane wrote: |The indexCorrelation^2 algorithm was only a quick hack with no theory |behind it :-(. >It depends on the patches, since this is a production machine. Currently >it's running 7.4.*mumble*, The patch referenced in http://archives.postgresql.org/pgsql-hackers/2003-08/msg00931.php is still available. It doesn't touch too many places and should be easy to review. I'm using it and its predecessors in production for more than two years. Let me know, if the 74b1 version does not apply cleanly to your source tree. Servus Manfred From pgsql-performance-owner@postgresql.org Thu May 12 19:31:28 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F8DE52A35 for ; Thu, 12 May 2005 19:31:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05679-02 for ; Thu, 12 May 2005 22:31:19 +0000 (GMT) Received: from dd01.profihoster.net (dd01.profihoster.net [80.86.168.71]) by svr1.postgresql.org (Postfix) with ESMTP id 9DFC35380B for ; Thu, 12 May 2005 19:31:13 -0300 (ADT) Received: from [192.168.54.3] (G17a8.g.pppool.de [80.185.23.168]) by dd01.profihoster.net (Postfix) with ESMTP id DD1572383C5 for ; Fri, 13 May 2005 00:26:57 +0200 (CEST) Message-ID: <4283D985.4080908@laliluna.de> Date: Fri, 13 May 2005 00:32:37 +0200 From: Sebastian Hennebrueder User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Optimize complex join to use where condition before join Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/248 X-Sequence-Number: 12412 Hello, I am facing a problem in optimizing the query shown below. Most queries in the application do only find about 20 to 100 matching rows. The query joins the table taufgaben_mitarbeiter to taufgaben on which a condition like the following "where clause" is frequently used. where am.fmitarbeiter_id = 54 then there is a nested join to taufgaben -> tprojekt -> tkunden_kst -> tkunden. What I would like to achieve is that before joining all the tables that the join of taufgaben_mitarbeiter (... from taufgaben left join taufgaben_mitarbeiter am on taufgaben.fid = am.faufgaben_id) is done and that the where condition is evaluated. Than an index scan to join the other data is run. What is happening at the moment (if I understood the explain analyze) is that the full join is done and at the end the where condition is done. The query with seqscan and nestloop enabled takes about 3 seconds. The query with both disabled takes 0.52 seconds The query with only nestlop disabled takes 0.6 seconds and with only sesscan disabled takes about 3 seconds. Below you can find the explain analyze from "seqscan and nestloop enabled" and from both disabled. The problem seems to be right at the beginning when the rows are badly estimated. ... Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Nested Loop (cost=1621.51..1729.28 rows=6 width=2541) (actual time=328.000..3125.000 rows=1118 loops=1)" ... I am using PostgreSQL 8.0 on Windows Thank you for any idea -- Kind Regards / Viele Gr��e Sebastian Hennebrueder ----- http://www.laliluna.de/tutorials.html Tutorials for Java, Struts, JavaServer Faces, JSP, Hibernate, EJB and more. enabled seqscan and nested_loop explain analyze SELECT taufgaben.fid AS taufgaben_fid, taufgaben.fprojekt_id AS taufgaben_fprojekt_id, taufgaben.fnummer AS taufgaben_fnummer, taufgaben.fbudget AS taufgaben_fbudget, taufgaben.ftyp AS taufgaben_ftyp, taufgaben.fberechnungsart AS taufgaben_fberechnungsart, taufgaben.fverrechnung_extern AS taufgaben_fverrechnung_extern, taufgaben.fverrechnungsbasis AS taufgaben_fverrechnungsbasis, taufgaben.fstatus AS taufgaben_fstatus, taufgaben.fkurzbeschreibung AS taufgaben_fkurzbeschreibung, taufgaben.fansprechpartner AS taufgaben_fansprechpartner, taufgaben.fanforderer AS taufgaben_fanforderer, taufgaben.fstandort_id AS taufgaben_fstandort_id, taufgaben.fwunschtermin AS taufgaben_fwunschtermin, taufgaben.fstarttermin AS taufgaben_fstarttermin, taufgaben.fgesamtaufwand AS taufgaben_fgesamtaufwand, taufgaben.fistaufwand AS taufgaben_fistaufwand, taufgaben.fprio AS taufgaben_fprio, taufgaben.ftester AS taufgaben_ftester, taufgaben.ffaellig AS taufgaben_ffaellig, taufgaben.flevel AS taufgaben_flevel, taufgaben.fkategorie AS taufgaben_fkategorie, taufgaben.feintragbearbeitung AS taufgaben_feintragbearbeitung, taufgaben.fbearbeitungsstatus AS taufgaben_fbearbeitungsstatus, taufgaben.fsolllimit AS taufgaben_fsolllimit, taufgaben.fistlimit AS taufgaben_fistlimit, taufgaben.fpauschalbetrag AS taufgaben_fpauschalbetrag, taufgaben.frechnungslaeufe_id AS taufgaben_frechnungslaeufe_id, taufgaben.fzuberechnen AS taufgaben_fzuberechnen, tprojekte.fid AS tprojekte_fid, tprojekte.fbezeichnung AS tprojekte_fbezeichnung, tprojekte.fprojektnummer AS tprojekte_fprojektnummer, tprojekte.fbudget AS tprojekte_fbudget, tprojekte.fverrechnung_extern AS tprojekte_fverrechnung_extern, tprojekte.fstatus AS tprojekte_fstatus, tprojekte.fkunden_kst_id AS tprojekte_fkunden_kst_id, tprojekte.fverrechnungsbasis AS tprojekte_fverrechnungsbasis, tprojekte.fberechnungsart AS tprojekte_fberechnungsart, tprojekte.fprojekttyp AS tprojekte_fprojekttyp, tprojekte.fkostentraeger_id AS tprojekte_fkostentraeger_id, tprojekte.fprojektleiter_id AS tprojekte_fprojektleiter_id, tprojekte.fpauschalsatz AS tprojekte_fpauschalsatz, tprojekte.frechnungslaeufe_id AS tprojekte_frechnungslaeufe_id, tprojekte.fzuberechnen AS tprojekte_fzuberechnen, tprojekte.faufschlagrel AS tprojekte_faufschlagrel, tprojekte.faufschlagabs AS tprojekte_faufschlagabs, tprojekte.fbearbeitungsstatus AS tprojekte_fbearbeitungsstatus, tuser.fusername AS tuser_fusername, tuser.fpassword AS tuser_fpassword, tuser.fvorname AS tuser_fvorname, tuser.fnachname AS tuser_fnachname, tuser.fismitarbeiter AS tuser_fismitarbeiter, tuser.flevel AS tuser_flevel, tuser.fkuerzel AS tuser_fkuerzel, taufgaben.floesungsbeschreibung AS taufgaben_floesungsbeschreibung, taufgaben.ffehlerbeschreibung AS taufgaben_ffehlerbeschreibung, taufgaben.faufgabenstellung AS taufgaben_faufgabenstellung, taufgaben.fkritischeaenderungen AS taufgaben_fkritischeaenderungen, taufgaben.fbdeaufgabenersteller_id AS taufgaben_fbdeaufgabenersteller_id, taufgaben.fzufaktorieren AS taufgaben_fzufaktorieren, tprojekte.fzufaktorieren AS tprojekte_fzufaktorieren, taufgaben.fisdirty AS taufgaben_fisdirty, taufgaben.fnf_kunde_stunden AS taufgaben_fnf_kunde_stunden, taufgaben.fzf_kunde_stunden AS taufgaben_fzf_kunde_stunden, taufgaben.fbf_kunde_stunden AS taufgaben_fbf_kunde_stunden, taufgaben.fnf_kunde_betrag AS taufgaben_fnf_kunde_betrag, taufgaben.fzf_kunde_betrag AS taufgaben_fzf_kunde_betrag, taufgaben.fbf_kunde_betrag AS taufgaben_fbf_kunde_betrag, tprojekte.feurobudget AS tprojekte_feurobudget, tprojekte.fnf_kunde_stunden AS tprojekte_fnf_kunde_stunden, tprojekte.fzf_kunde_stunden AS tprojekte_fzf_kunde_stunden, tprojekte.fbf_kunde_stunden AS tprojekte_fbf_kunde_stunden, tprojekte.fnf_kunde_betrag AS tprojekte_fnf_kunde_betrag, tprojekte.fzf_kunde_betrag AS tprojekte_fzf_kunde_betrag, tprojekte.fbf_kunde_betrag AS tprojekte_fbf_kunde_betrag, tprojekte.fisdirty AS tprojekte_fisdirty, tprojekte.fgesamt_brutto_betrag AS tprojekte_fgesamt_brutto_betrag, tprojekte.fgesamt_brutto_stunden AS tprojekte_fgesamt_brutto_stunden, tprojekte.fgesamt_netto_stunden AS tprojekte_fgesamt_netto_stunden, taufgaben.fgesamt_brutto_stunden AS taufgaben_fgesamt_brutto_stunden, taufgaben.fgesamt_brutto_betrag AS taufgaben_fgesamt_brutto_betrag, taufgaben.fhinweisgesendet AS taufgaben_fhinweisgesendet, taufgaben.fwarnunggesendet AS taufgaben_fwarnunggesendet, tprojekte.fhinweisgesendet AS tprojekte_fhinweisgesendet, tprojekte.fwarnunggesendet AS tprojekte_fwarnunggesendet, tuser.femailadresse AS tuser_femailadresse, taufgaben.fnfgesamtaufwand AS taufgaben_fnfgesamtaufwand, taufgaben.fnf_netto_stunden AS taufgaben_fnf_netto_stunden, taufgaben.fnf_brutto_stunden AS taufgaben_fnf_brutto_stunden, taufgaben.fnfhinweisgesendet AS taufgaben_fnfhinweisgesendet, taufgaben.fnfwarnunggesendet AS taufgaben_fnfwarnunggesendet, tprojekte.fnfgesamtaufwand AS tprojekte_fnfgesamtaufwand, tprojekte.fnf_netto_stunden AS tprojekte_fnf_netto_stunden, tprojekte.fnf_brutto_stunden AS tprojekte_fnf_brutto_stunden, tprojekte.fnfhinweisgesendet AS tprojekte_fnfhinweisgesendet, tprojekte.fnfwarnunggesendet AS tprojekte_fnfwarnunggesendet, taufgaben.fhatzeiten AS taufgaben_fhatzeiten, tprojekte.fhatzeiten AS tprojekte_fhatzeiten, taufgaben.fnichtpublicrechnungsfaehig AS taufgaben_fnichtpublicrechnungsfaehig, taufgaben.fnichtpublicrechnungsfaehigbetrag AS taufgaben_fnichtpublicrechnungsfaehigbetrag, taufgaben.fnichtberechenbar AS taufgaben_fnichtberechenbar, taufgaben.fnichtberechenbarbetrag AS taufgaben_fnichtberechenbarbetrag, tprojekte.fnichtpublicrechnungsfaehig AS tprojekte_fnichtpublicrechnungsfaehig, tprojekte.fnichtpublicrechnungsfaehigbetrag AS tprojekte_fnichtpublicrechnungsfaehigbetrag, tprojekte.fnichtberechenbar AS tprojekte_fnichtberechenbar, tprojekte.fnichtberechenbarbetrag AS tprojekte_fnichtberechenbarbetrag, taufgaben.finternertester AS taufgaben_finternertester, taufgaben.finterngetestet AS taufgaben_finterngetestet, tkunden_kst.fbezeichnung AS tkunden_kst_name, tkunden.fname AS tkunden_name, tabteilungen.fname AS tabteilungen_fname, tkostenstellen.fnummer AS tkostenstellen_fnummer, tkostentraeger.fnummer AS tkostentraeger_fnummer, taufgaben.fanzahlbearbeiter AS taufgaben_fanzahlbearbeiter, patchdaten.faufgaben_id AS pataid FROM taufgaben_mitarbeiter am left join ((((((((taufgaben LEFT JOIN ( SELECT DISTINCT taufgaben_patches.faufgaben_id FROM taufgaben_patches ORDER BY taufgaben_patches.faufgaben_id ) patchdaten ON ((taufgaben.fid = patchdaten.faufgaben_id))) JOIN tprojekte ON ((taufgaben.fprojekt_id = tprojekte.fid))) JOIN tuser ON ((tprojekte.fprojektleiter_id = tuser.fid))) JOIN tkunden_kst ON ((tprojekte.fkunden_kst_id = tkunden_kst.fid))) JOIN tkunden ON ((tkunden_kst.fkunden_id = tkunden.fid))) JOIN tkostentraeger ON ((tprojekte.fkostentraeger_id = tkostentraeger.fid))) JOIN tkostenstellen ON ((tkostentraeger.fkostenstellen_id = tkostenstellen.fid))) JOIN tabteilungen ON ((tkostenstellen.fabteilungen_id = tabteilungen.fid))) on taufgaben.fid = am.faufgaben_id where am.fmitarbeiter_id = 54 and taufgaben.fbearbeitungsstatus <> 2 "Merge Join (cost=1729.11..1837.08 rows=1 width=2541) (actual time=531.000..3125.000 rows=62 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Nested Loop (cost=1621.51..1729.28 rows=6 width=2541) (actual time=328.000..3125.000 rows=1118 loops=1)" " Join Filter: ("outer".fprojekt_id = "inner".fid)" " -> Merge Left Join (cost=1490.70..1497.67 rows=1120 width=1047) (actual time=172.000..220.000 rows=1118 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Sort (cost=1211.46..1214.26 rows=1120 width=1043) (actual time=109.000..109.000 rows=1118 loops=1)" " Sort Key: taufgaben.fid" " -> Seq Scan on taufgaben (cost=0.00..853.88 rows=1120 width=1043) (actual time=0.000..109.000 rows=1120 loops=1)" " Filter: (fbearbeitungsstatus <> 2)" " -> Sort (cost=279.23..279.73 rows=200 width=4) (actual time=63.000..63.000 rows=4773 loops=1)" " Sort Key: patchdaten.faufgaben_id" " -> Subquery Scan patchdaten (cost=0.00..271.59 rows=200 width=4) (actual time=0.000..31.000 rows=4773 loops=1)" " -> Unique (cost=0.00..269.59 rows=200 width=4) (actual time=0.000..31.000 rows=4773 loops=1)" " -> Index Scan using idx_aufpa_aufgabeid on taufgaben_patches (cost=0.00..253.74 rows=6340 width=4) (actual time=0.000..0.000 rows=6340 loops=1)" " -> Materialize (cost=130.81..130.85 rows=4 width=1494) (actual time=0.140..0.877 rows=876 loops=1118)" " -> Merge Join (cost=130.53..130.81 rows=4 width=1494) (actual time=156.000..203.000 rows=876 loops=1)" " Merge Cond: ("outer".fkunden_id = "inner".fid)" " -> Sort (cost=127.06..127.08 rows=6 width=1455) (actual time=156.000..156.000 rows=876 loops=1)" " Sort Key: tkunden_kst.fkunden_id" " -> Merge Join (cost=126.35..126.99 rows=6 width=1455) (actual time=109.000..140.000 rows=876 loops=1)" " Merge Cond: ("outer".fprojektleiter_id = "inner".fid)" " -> Sort (cost=118.57..118.59 rows=9 width=580) (actual time=109.000..109.000 rows=876 loops=1)" " Sort Key: tprojekte.fprojektleiter_id" " -> Merge Join (cost=117.89..118.43 rows=9 width=580) (actual time=62.000..93.000 rows=876 loops=1)" " Merge Cond: ("outer".fkunden_kst_id = "inner".fid)" " -> Sort (cost=114.61..114.69 rows=31 width=508) (actual time=62.000..62.000 rows=876 loops=1)" " Sort Key: tprojekte.fkunden_kst_id" " -> Merge Join (cost=109.11..113.84 rows=31 width=508) (actual time=31.000..62.000 rows=876 loops=1)" " Merge Cond: ("outer".fid = "inner".fkostentraeger_id)" " -> Sort (cost=13.40..13.42 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostentraeger.fid" " -> Merge Join (cost=12.41..13.31 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Merge Cond: ("outer".fid = "inner".fkostenstellen_id)" " -> Sort (cost=3.06..3.08 rows=7 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tkostenstellen.fid" " -> Merge Join (cost=2.76..2.96 rows=7 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Merge Cond: ("outer".fabteilungen_id = "inner".fid)" " -> Sort (cost=1.59..1.64 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tkostenstellen.fabteilungen_id" " -> Seq Scan on tkostenstellen (cost=0.00..1.19 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " -> Sort (cost=1.17..1.19 rows=7 width=76) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tabteilungen.fid" " -> Seq Scan on tabteilungen (cost=0.00..1.07 rows=7 width=76) (actual time=0.000..0.000 rows=7 loops=1)" " -> Sort (cost=9.35..9.74 rows=158 width=55) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostentraeger.fkostenstellen_id" " -> Seq Scan on tkostentraeger (cost=0.00..3.58 rows=158 width=55) (actual time=0.000..0.000 rows=158 loops=1)" " -> Sort (cost=95.71..97.90 rows=878 width=354) (actual time=31.000..31.000 rows=877 loops=1)" " Sort Key: tprojekte.fkostentraeger_id" " -> Seq Scan on tprojekte (cost=0.00..52.78 rows=878 width=354) (actual time=0.000..31.000 rows=878 loops=1)" " -> Sort (cost=3.28..3.42 rows=58 width=80) (actual time=0.000..0.000 rows=892 loops=1)" " Sort Key: tkunden_kst.fid" " -> Seq Scan on tkunden_kst (cost=0.00..1.58 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " -> Sort (cost=7.78..8.05 rows=109 width=883) (actual time=0.000..0.000 rows=950 loops=1)" " Sort Key: tuser.fid" " -> Seq Scan on tuser (cost=0.00..4.09 rows=109 width=883) (actual time=0.000..0.000 rows=109 loops=1)" " -> Sort (cost=3.46..3.56 rows=40 width=51) (actual time=0.000..0.000 rows=887 loops=1)" " Sort Key: tkunden.fid" " -> Seq Scan on tkunden (cost=0.00..2.40 rows=40 width=51) (actual time=0.000..0.000 rows=40 loops=1)" " -> Sort (cost=107.60..107.69 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Sort Key: am.faufgaben_id" " -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am (cost=0.00..106.70 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Index Cond: (fmitarbeiter_id = 54)" "Total runtime: 3125.000 ms" ############################################################################ set enable_nestloop to off; set enable_seqscan to off; "Merge Join (cost=4230.83..4231.04 rows=1 width=2541) (actual time=485.000..500.000 rows=62 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Sort (cost=4123.23..4123.24 rows=6 width=2541) (actual time=469.000..485.000 rows=1118 loops=1)" " Sort Key: taufgaben.fid" " -> Merge Join (cost=4117.47..4123.15 rows=6 width=2541) (actual time=297.000..406.000 rows=1120 loops=1)" " Merge Cond: ("outer".fid = "inner".fprojekt_id)" " -> Sort (cost=263.53..263.54 rows=4 width=1494) (actual time=141.000..141.000 rows=876 loops=1)" " Sort Key: tprojekte.fid" " -> Merge Join (cost=247.95..263.49 rows=4 width=1494) (actual time=94.000..109.000 rows=876 loops=1)" " Merge Cond: ("outer".fprojektleiter_id = "inner".fid)" " -> Sort (cost=247.95..247.96 rows=7 width=619) (actual time=94.000..94.000 rows=876 loops=1)" " Sort Key: tprojekte.fprojektleiter_id" " -> Merge Join (cost=246.86..247.85 rows=7 width=619) (actual time=47.000..78.000 rows=876 loops=1)" " Merge Cond: ("outer".fkostentraeger_id = "inner".fid)" " -> Sort (cost=222.01..222.45 rows=176 width=465) (actual time=47.000..47.000 rows=878 loops=1)" " Sort Key: tprojekte.fkostentraeger_id" " -> Merge Join (cost=20.63..215.44 rows=176 width=465) (actual time=0.000..32.000 rows=878 loops=1)" " Merge Cond: ("outer".fid = "inner".fkunden_kst_id)" " -> Sort (cost=20.63..20.73 rows=40 width=119) (actual time=0.000..0.000 rows=58 loops=1)" " Sort Key: tkunden_kst.fid" " -> Merge Join (cost=8.34..19.57 rows=40 width=119) (actual time=0.000..0.000 rows=58 loops=1)" " Merge Cond: ("outer".fkunden_id = "inner".fid)" " -> Sort (cost=8.34..8.48 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " Sort Key: tkunden_kst.fkunden_id" " -> Index Scan using pk__kunden_kst__30c33ec3 on tkunden_kst (cost=0.00..6.64 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " -> Index Scan using tkunden_tbl_kunden_pk on tkunden (cost=0.00..10.44 rows=40 width=51) (actual time=0.000..0.000 rows=59 loops=1)" " -> Index Scan using idx_kunden_kst_id on tprojekte (cost=0.00..190.66 rows=878 width=354) (actual time=0.000..0.000 rows=878 loops=1)" " -> Sort (cost=24.86..24.87 rows=7 width=162) (actual time=0.000..0.000 rows=923 loops=1)" " Sort Key: tkostentraeger.fid" " -> Merge Join (cost=12.52..24.76 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Merge Cond: ("outer".fid = "inner".fkostenstellen_id)" " -> Sort (cost=12.52..12.54 rows=7 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tkostenstellen.fid" " -> Merge Join (cost=0.00..12.42 rows=7 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Merge Cond: ("outer".fabteilungen_id = "inner".fid)" " -> Index Scan using abteilungkostenstellen on tkostenstellen (cost=0.00..6.21 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " -> Index Scan using fld_id on tabteilungen (cost=0.00..6.08 rows=7 width=76) (actual time=0.000..0.000 rows=19 loops=1)" " -> Index Scan using idx_kostenstellen_id on tkostentraeger (cost=0.00..11.74 rows=158 width=55) (actual time=0.000..0.000 rows=158 loops=1)" " -> Index Scan using pk_tuser on tuser (cost=0.00..15.20 rows=109 width=883) (actual time=0.000..0.000 rows=950 loops=1)" " -> Sort (cost=3853.94..3856.74 rows=1120 width=1047) (actual time=156.000..156.000 rows=1120 loops=1)" " Sort Key: taufgaben.fprojekt_id" " -> Merge Left Join (cost=279.23..3496.35 rows=1120 width=1047) (actual time=47.000..156.000 rows=1120 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Index Scan using idx_taufgaben_fid on taufgaben (cost=0.00..3212.95 rows=1120 width=1043) (actual time=0.000..31.000 rows=1120 loops=1)" " Filter: (fbearbeitungsstatus <> 2)" " -> Sort (cost=279.23..279.73 rows=200 width=4) (actual time=47.000..47.000 rows=4773 loops=1)" " Sort Key: patchdaten.faufgaben_id" " -> Subquery Scan patchdaten (cost=0.00..271.59 rows=200 width=4) (actual time=0.000..31.000 rows=4773 loops=1)" " -> Unique (cost=0.00..269.59 rows=200 width=4) (actual time=0.000..31.000 rows=4773 loops=1)" " -> Index Scan using idx_aufpa_aufgabeid on taufgaben_patches (cost=0.00..253.74 rows=6340 width=4) (actual time=0.000..16.000 rows=6340 loops=1)" " -> Sort (cost=107.60..107.69 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Sort Key: am.faufgaben_id" " -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am (cost=0.00..106.70 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Index Cond: (fmitarbeiter_id = 54)" "Total runtime: 500.000 ms" From pgsql-performance-owner@postgresql.org Thu May 12 19:38:38 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 814AA53824 for ; Thu, 12 May 2005 19:38:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05344-08 for ; Thu, 12 May 2005 22:38:27 +0000 (GMT) Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) by svr1.postgresql.org (Postfix) with ESMTP id 63FBF533A2 for ; Thu, 12 May 2005 19:38:25 -0300 (ADT) Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.44) id 1DWMK5-0006CI-B1; Fri, 13 May 2005 00:38:29 +0200 Received: from d192101.adsl.hansenet.de ([80.171.192.101] helo=[10.0.1.6]) by emma.rox.net with esmtpa (Exim 4.44) id 1DWMK3-000684-Sx; Fri, 13 May 2005 00:38:27 +0200 In-Reply-To: <254.1115907326@sss.pgh.pa.us> References: <2aeb891e99fa6313e9e3a20d48c099aa@cluster9.com> <254.1115907326@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v622) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <5989cd23aa4942c871aba9cdcd7c4262@cluster9.com> Content-Transfer-Encoding: 7bit Cc: PgSQL Performance ML From: David Teran Subject: Re: AND OR combination: index not being used Date: Fri, 13 May 2005 00:38:22 +0200 To: Tom Lane X-Mailer: Apple Mail (2.622) X-Scanned-By: rockenstein AG X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/249 X-Sequence-Number: 12413 On 12.05.2005, at 16:15, Tom Lane wrote: > David Teran writes: >> Any hint how >> to force postgres to use the index even with more OR parts? > > More up-to-date statistics would evidently help; the thing is > estimating > hundreds of rows returned and actually finding none. > I always do a 'vacuum analyze' if something does not work as expected. But this did not help. Any other tip? regards, David From pgsql-performance-owner@postgresql.org Thu May 12 23:13:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EDDFA53FC9 for ; Thu, 12 May 2005 23:13:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38602-07 for ; Fri, 13 May 2005 02:13:20 +0000 (GMT) Received: from dd01.profihoster.net (dd01.profihoster.net [80.86.168.71]) by svr1.postgresql.org (Postfix) with ESMTP id A75C153771 for ; Thu, 12 May 2005 23:13:17 -0300 (ADT) Received: from [192.168.54.3] (G17a8.g.pppool.de [80.185.23.168]) by dd01.profihoster.net (Postfix) with ESMTP id B882B2383C5 for ; Fri, 13 May 2005 04:09:01 +0200 (CEST) Message-ID: <42840D91.4000400@laliluna.de> Date: Fri, 13 May 2005 04:14:41 +0200 From: Sebastian Hennebrueder User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Optimize complex join to use where condition before References: <4283D985.4080908@laliluna.de> In-Reply-To: <4283D985.4080908@laliluna.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/250 X-Sequence-Number: 12414 Solution to my problem. I added indexes to each foreign_key (there had been some missing). I will try tomorrow by daylight what influence this had actually. Only the indexes did not change anything! Even with lower random_page_costs and higher shared mem. The big change was the following I created a view which holds a part of the query. The part is the nested join I am doing from rpojekt, tkunden_kst, .... See below Than I changed my query to include the view which improved the performance from 3000 to 450 ms which is quite good now. But I am having two more question a) ############### I estimated the theoretical speed a little bit higher. The query without joining the view takes about 220 ms. A query to the view with a condition projekt_id in ( x,y,z), beeing x,y,z all the projekt I got with the first query, takes 32 ms. So my calculation is query a 220 query b to view with project in ... 32 = 252 ms + some time to add the adequate row from query b to one of the 62 rows from query a This sometime seems to be quite high with 200 ms or alternative query a 220 ms for each of the 62 rows a query to the view with project_id = x 220 62*2 ms = 344 ms + some time to assemble all this. => 100 ms for assembling. This is quite a lot or am I wrong b) ################### My query does take about 200 ms. Most of the time is taken by the following part LEFT JOIN ( SELECT DISTINCT taufgaben_patches.faufgaben_id FROM taufgaben_patches ORDER BY taufgaben_patches.faufgaben_id ) patchdaten ON taufgaben.fid = patchdaten.faufgaben_id What I want to achieve is one column in my query beeing null or not null and indicating if there is a patch which includes the aufgabe (engl.: task) Is there a better way? -- Kind Regards / Viele Gr��e Sebastian Hennebrueder ----- http://www.laliluna.de/tutorials.html Tutorials for Java, Struts, JavaServer Faces, JSP, Hibernate, EJB and more. ################## Below you can find query solution I found explain analyze of the complete query (my solution) explain analyze of query a explain analyze of view with one project_id as condition explain analyze SELECT taufgaben.fid AS taufgaben_fid, taufgaben.fprojekt_id AS taufgaben_fprojekt_id, taufgaben.fnummer AS taufgaben_fnummer, taufgaben.fbudget AS taufgaben_fbudget, taufgaben.ftyp AS taufgaben_ftyp, taufgaben.fberechnungsart AS taufgaben_fberechnungsart, taufgaben.fverrechnung_extern AS taufgaben_fverrechnung_extern, taufgaben.fverrechnungsbasis AS taufgaben_fverrechnungsbasis, taufgaben.fstatus AS taufgaben_fstatus, taufgaben.fkurzbeschreibung AS taufgaben_fkurzbeschreibung, taufgaben.fansprechpartner AS taufgaben_fansprechpartner, taufgaben.fanforderer AS taufgaben_fanforderer, taufgaben.fstandort_id AS taufgaben_fstandort_id, taufgaben.fwunschtermin AS taufgaben_fwunschtermin, taufgaben.fstarttermin AS taufgaben_fstarttermin, taufgaben.fgesamtaufwand AS taufgaben_fgesamtaufwand, taufgaben.fistaufwand AS taufgaben_fistaufwand, taufgaben.fprio AS taufgaben_fprio, taufgaben.ftester AS taufgaben_ftester, taufgaben.ffaellig AS taufgaben_ffaellig, taufgaben.flevel AS taufgaben_flevel, taufgaben.fkategorie AS taufgaben_fkategorie, taufgaben.feintragbearbeitung AS taufgaben_feintragbearbeitung, taufgaben.fbearbeitungsstatus AS taufgaben_fbearbeitungsstatus, taufgaben.fsolllimit AS taufgaben_fsolllimit, taufgaben.fistlimit AS taufgaben_fistlimit, taufgaben.fpauschalbetrag AS taufgaben_fpauschalbetrag, taufgaben.frechnungslaeufe_id AS taufgaben_frechnungslaeufe_id, taufgaben.fzuberechnen AS taufgaben_fzuberechnen, taufgaben.floesungsbeschreibung AS taufgaben_floesungsbeschreibung, taufgaben.ffehlerbeschreibung AS taufgaben_ffehlerbeschreibung, taufgaben.faufgabenstellung AS taufgaben_faufgabenstellung, taufgaben.fkritischeaenderungen AS taufgaben_fkritischeaenderungen, taufgaben.fbdeaufgabenersteller_id AS taufgaben_fbdeaufgabenersteller_id, taufgaben.fzufaktorieren AS taufgaben_fzufaktorieren, taufgaben.fisdirty AS taufgaben_fisdirty, taufgaben.fnf_kunde_stunden AS taufgaben_fnf_kunde_stunden, taufgaben.fzf_kunde_stunden AS taufgaben_fzf_kunde_stunden, taufgaben.fbf_kunde_stunden AS taufgaben_fbf_kunde_stunden, taufgaben.fnf_kunde_betrag AS taufgaben_fnf_kunde_betrag, taufgaben.fzf_kunde_betrag AS taufgaben_fzf_kunde_betrag, taufgaben.fbf_kunde_betrag AS taufgaben_fbf_kunde_betrag, taufgaben.fgesamt_brutto_stunden AS taufgaben_fgesamt_brutto_stunden, taufgaben.fgesamt_brutto_betrag AS taufgaben_fgesamt_brutto_betrag, taufgaben.fhinweisgesendet AS taufgaben_fhinweisgesendet, taufgaben.fwarnunggesendet AS taufgaben_fwarnunggesendet, taufgaben.fnfgesamtaufwand AS taufgaben_fnfgesamtaufwand, taufgaben.fnf_netto_stunden AS taufgaben_fnf_netto_stunden, taufgaben.fnf_brutto_stunden AS taufgaben_fnf_brutto_stunden, taufgaben.fnfhinweisgesendet AS taufgaben_fnfhinweisgesendet, taufgaben.fnfwarnunggesendet AS taufgaben_fnfwarnunggesendet, taufgaben.fhatzeiten AS taufgaben_fhatzeiten, taufgaben.fnichtpublicrechnungsfaehig AS taufgaben_fnichtpublicrechnungsfaehig, taufgaben.fnichtpublicrechnungsfaehigbetrag AS taufgaben_fnichtpublicrechnungsfaehigbetrag, taufgaben.fnichtberechenbar AS taufgaben_fnichtberechenbar, taufgaben.fnichtberechenbarbetrag AS taufgaben_fnichtberechenbarbetrag, taufgaben.finternertester AS taufgaben_finternertester, taufgaben.finterngetestet AS taufgaben_finterngetestet, taufgaben.fanzahlbearbeiter AS taufgaben_fanzahlbearbeiter, patchdaten.faufgaben_id AS pataid , vprojekt.* FROM taufgaben LEFT JOIN ( SELECT DISTINCT taufgaben_patches.faufgaben_id FROM taufgaben_patches ORDER BY taufgaben_patches.faufgaben_id ) patchdaten ON taufgaben.fid = patchdaten.faufgaben_id left join taufgaben_mitarbeiter am on taufgaben.fid = am.faufgaben_id join vprojekt on taufgaben.fprojekt_id = vprojekt.tprojekte_fid where am.fmitarbeiter_id = 54 and taufgaben.fbearbeitungsstatus <> 2 ; and got the following: "Merge Join (cost=1739.31..1739.38 rows=1 width=2541) (actual time=438.000..454.000 rows=62 loops=1)" " Merge Cond: ("outer".fprojekt_id = "inner".fid)" " -> Sort (cost=1608.41..1608.43 rows=7 width=1047) (actual time=235.000..235.000 rows=62 loops=1)" " Sort Key: taufgaben.fprojekt_id" " -> Merge Join (cost=1598.30..1608.31 rows=7 width=1047) (actual time=172.000..235.000 rows=62 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Merge Left Join (cost=1490.70..1497.67 rows=1120 width=1047) (actual time=157.000..235.000 rows=1118 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Sort (cost=1211.46..1214.26 rows=1120 width=1043) (actual time=94.000..94.000 rows=1118 loops=1)" " Sort Key: taufgaben.fid" " -> Seq Scan on taufgaben (cost=0.00..853.88 rows=1120 width=1043) (actual time=0.000..94.000 rows=1120 loops=1)" " Filter: (fbearbeitungsstatus <> 2)" " -> Sort (cost=279.23..279.73 rows=200 width=4) (actual time=63.000..63.000 rows=4773 loops=1)" " Sort Key: patchdaten.faufgaben_id" " -> Subquery Scan patchdaten (cost=0.00..271.59 rows=200 width=4) (actual time=0.000..16.000 rows=4773 loops=1)" " -> Unique (cost=0.00..269.59 rows=200 width=4) (actual time=0.000..16.000 rows=4773 loops=1)" " -> Index Scan using idx_aufpa_aufgabeid on taufgaben_patches (cost=0.00..253.74 rows=6340 width=4) (actual time=0.000..16.000 rows=6340 loops=1)" " -> Sort (cost=107.60..107.69 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Sort Key: am.faufgaben_id" " -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am (cost=0.00..106.70 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Index Cond: (fmitarbeiter_id = 54)" " -> Sort (cost=130.90..130.91 rows=6 width=1494) (actual time=203.000..203.000 rows=916 loops=1)" " Sort Key: tprojekte.fid" " -> Merge Join (cost=130.53..130.82 rows=6 width=1494) (actual time=156.000..203.000 rows=876 loops=1)" " Merge Cond: ("outer".fkunden_id = "inner".fid)" " -> Sort (cost=127.06..127.08 rows=6 width=1455) (actual time=156.000..156.000 rows=876 loops=1)" " Sort Key: tkunden_kst.fkunden_id" " -> Merge Join (cost=126.35..126.99 rows=6 width=1455) (actual time=125.000..156.000 rows=876 loops=1)" " Merge Cond: ("outer".fprojektleiter_id = "inner".fid)" " -> Sort (cost=118.57..118.59 rows=9 width=580) (actual time=109.000..109.000 rows=876 loops=1)" " Sort Key: tprojekte.fprojektleiter_id" " -> Merge Join (cost=117.89..118.43 rows=9 width=580) (actual time=62.000..94.000 rows=876 loops=1)" " Merge Cond: ("outer".fkunden_kst_id = "inner".fid)" " -> Sort (cost=114.61..114.69 rows=31 width=508) (actual time=62.000..62.000 rows=876 loops=1)" " Sort Key: tprojekte.fkunden_kst_id" " -> Merge Join (cost=109.11..113.84 rows=31 width=508) (actual time=31.000..62.000 rows=876 loops=1)" " Merge Cond: ("outer".fid = "inner".fkostentraeger_id)" " -> Sort (cost=13.40..13.42 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostentraeger.fid" " -> Merge Join (cost=12.41..13.31 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Merge Cond: ("outer".fid = "inner".fkostenstellen_id)" " -> Sort (cost=3.06..3.08 rows=7 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tkostenstellen.fid" " -> Merge Join (cost=2.76..2.96 rows=7 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Merge Cond: ("outer".fabteilungen_id = "inner".fid)" " -> Sort (cost=1.59..1.64 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tkostenstellen.fabteilungen_id" " -> Seq Scan on tkostenstellen (cost=0.00..1.19 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " -> Sort (cost=1.17..1.19 rows=7 width=76) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tabteilungen.fid" " -> Seq Scan on tabteilungen (cost=0.00..1.07 rows=7 width=76) (actual time=0.000..0.000 rows=7 loops=1)" " -> Sort (cost=9.35..9.74 rows=158 width=55) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostentraeger.fkostenstellen_id" " -> Seq Scan on tkostentraeger (cost=0.00..3.58 rows=158 width=55) (actual time=0.000..0.000 rows=158 loops=1)" " -> Sort (cost=95.71..97.90 rows=878 width=354) (actual time=31.000..46.000 rows=877 loops=1)" " Sort Key: tprojekte.fkostentraeger_id" " -> Seq Scan on tprojekte (cost=0.00..52.78 rows=878 width=354) (actual time=0.000..31.000 rows=878 loops=1)" " -> Sort (cost=3.28..3.42 rows=58 width=80) (actual time=0.000..0.000 rows=892 loops=1)" " Sort Key: tkunden_kst.fid" " -> Seq Scan on tkunden_kst (cost=0.00..1.58 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " -> Sort (cost=7.78..8.05 rows=109 width=883) (actual time=16.000..16.000 rows=950 loops=1)" " Sort Key: tuser.fid" " -> Seq Scan on tuser (cost=0.00..4.09 rows=109 width=883) (actual time=0.000..0.000 rows=109 loops=1)" " -> Sort (cost=3.46..3.56 rows=40 width=51) (actual time=0.000..0.000 rows=887 loops=1)" " Sort Key: tkunden.fid" " -> Seq Scan on tkunden (cost=0.00..2.40 rows=40 width=51) (actual time=0.000..0.000 rows=40 loops=1)" "Total runtime: 454.000 ms" CREATE OR REPLACE VIEW "public"."vprojekt" AS SELECT tprojekte.fid AS tprojekte_fid, tprojekte.fbezeichnung AS tprojekte_fbezeichnung, tprojekte.fprojektnummer AS tprojekte_fprojektnummer, tprojekte.fbudget AS tprojekte_fbudget, tprojekte.fverrechnung_extern AS tprojekte_fverrechnung_extern, tprojekte.fstatus AS tprojekte_fstatus, tprojekte.fkunden_kst_id AS tprojekte_fkunden_kst_id, tprojekte.fverrechnungsbasis AS tprojekte_fverrechnungsbasis, tprojekte.fberechnungsart AS tprojekte_fberechnungsart, tprojekte.fprojekttyp AS tprojekte_fprojekttyp, tprojekte.fkostentraeger_id AS tprojekte_fkostentraeger_id, tprojekte.fprojektleiter_id AS tprojekte_fprojektleiter_id, tprojekte.fpauschalsatz AS tprojekte_fpauschalsatz, tprojekte.frechnungslaeufe_id AS tprojekte_frechnungslaeufe_id, tprojekte.fzuberechnen AS tprojekte_fzuberechnen, tprojekte.faufschlagrel AS tprojekte_faufschlagrel, tprojekte.faufschlagabs AS tprojekte_faufschlagabs, tprojekte.fbearbeitungsstatus AS tprojekte_fbearbeitungsstatus, tprojekte.fzufaktorieren AS tprojekte_fzufaktorieren, tprojekte.feurobudget AS tprojekte_feurobudget, tprojekte.fnf_kunde_stunden AS tprojekte_fnf_kunde_stunden, tprojekte.fzf_kunde_stunden AS tprojekte_fzf_kunde_stunden, tprojekte.fbf_kunde_stunden AS tprojekte_fbf_kunde_stunden, tprojekte.fnf_kunde_betrag AS tprojekte_fnf_kunde_betrag, tprojekte.fzf_kunde_betrag AS tprojekte_fzf_kunde_betrag, tprojekte.fbf_kunde_betrag AS tprojekte_fbf_kunde_betrag, tprojekte.fisdirty AS tprojekte_fisdirty, tprojekte.fgesamt_brutto_betrag AS tprojekte_fgesamt_brutto_betrag, tprojekte.fgesamt_brutto_stunden AS tprojekte_fgesamt_brutto_stunden, tprojekte.fgesamt_netto_stunden AS tprojekte_fgesamt_netto_stunden, tprojekte.fhinweisgesendet AS tprojekte_fhinweisgesendet, tprojekte.fwarnunggesendet AS tprojekte_fwarnunggesendet, tprojekte.fnfgesamtaufwand AS tprojekte_fnfgesamtaufwand, tprojekte.fnf_netto_stunden AS tprojekte_fnf_netto_stunden, tprojekte.fnf_brutto_stunden AS tprojekte_fnf_brutto_stunden, tprojekte.fnfhinweisgesendet AS tprojekte_fnfhinweisgesendet, tprojekte.fnfwarnunggesendet AS tprojekte_fnfwarnunggesendet, tprojekte.fhatzeiten AS tprojekte_fhatzeiten, tprojekte.fnichtpublicrechnungsfaehig AS tprojekte_fnichtpublicrechnungsfaehig, tprojekte.fnichtpublicrechnungsfaehigbetrag AS tprojekte_fnichtpublicrechnungsfaehigbetrag, tprojekte.fnichtberechenbar AS tprojekte_fnichtberechenbar, tprojekte.fnichtberechenbarbetrag AS tprojekte_fnichtberechenbarbetrag, tuser.fusername AS tuser_fusername, tuser.fpassword AS tuser_fpassword, tuser.fvorname AS tuser_fvorname, tuser.fnachname AS tuser_fnachname, tuser.fismitarbeiter AS tuser_fismitarbeiter, tuser.flevel AS tuser_flevel, tuser.fkuerzel AS tuser_fkuerzel, tuser.femailadresse AS tuser_femailadresse, tkunden_kst.fbezeichnung AS tkunden_kst_name, tkunden.fname AS tkunden_name, tabteilungen.fname AS tabteilungen_fname, tkostenstellen.fnummer AS tkostenstellen_fnummer, tkostentraeger.fnummer AS tkostentraeger_fnummer FROM ((((((tprojekte JOIN tuser ON ((tprojekte.fprojektleiter_id = tuser.fid))) JOIN tkunden_kst ON ((tprojekte.fkunden_kst_id = tkunden_kst.fid))) JOIN tkunden ON ((tkunden_kst.fkunden_id = tkunden.fid))) JOIN tkostentraeger ON ((tprojekte.fkostentraeger_id = tkostentraeger.fid))) JOIN tkostenstellen ON ((tkostentraeger.fkostenstellen_id = tkostenstellen.fid))) JOIN tabteilungen ON ((tkostenstellen.fabteilungen_id = tabteilungen.fid))); query a "Merge Join (cost=1598.30..1608.31 rows=7 width=1047) (actual time=140.000..218.000 rows=62 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Merge Left Join (cost=1490.70..1497.67 rows=1120 width=1047) (actual time=140.000..218.000 rows=1118 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Sort (cost=1211.46..1214.26 rows=1120 width=1043) (actual time=78.000..78.000 rows=1118 loops=1)" " Sort Key: taufgaben.fid" " -> Seq Scan on taufgaben (cost=0.00..853.88 rows=1120 width=1043) (actual time=0.000..78.000 rows=1120 loops=1)" " Filter: (fbearbeitungsstatus <> 2)" " -> Sort (cost=279.23..279.73 rows=200 width=4) (actual time=62.000..62.000 rows=4773 loops=1)" " Sort Key: patchdaten.faufgaben_id" " -> Subquery Scan patchdaten (cost=0.00..271.59 rows=200 width=4) (actual time=0.000..32.000 rows=4773 loops=1)" " -> Unique (cost=0.00..269.59 rows=200 width=4) (actual time=0.000..16.000 rows=4773 loops=1)" " -> Index Scan using idx_aufpa_aufgabeid on taufgaben_patches (cost=0.00..253.74 rows=6340 width=4) (actual time=0.000..0.000 rows=6340 loops=1)" " -> Sort (cost=107.60..107.69 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Sort Key: am.faufgaben_id" " -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am (cost=0.00..106.70 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Index Cond: (fmitarbeiter_id = 54)" "Total runtime: 218.000 ms" explain analyze SELECT taufgaben.fid AS taufgaben_fid, taufgaben.fprojekt_id AS taufgaben_fprojekt_id, taufgaben.fnummer AS taufgaben_fnummer, taufgaben.fbudget AS taufgaben_fbudget, taufgaben.ftyp AS taufgaben_ftyp, taufgaben.fberechnungsart AS taufgaben_fberechnungsart, taufgaben.fverrechnung_extern AS taufgaben_fverrechnung_extern, taufgaben.fverrechnungsbasis AS taufgaben_fverrechnungsbasis, taufgaben.fstatus AS taufgaben_fstatus, taufgaben.fkurzbeschreibung AS taufgaben_fkurzbeschreibung, taufgaben.fansprechpartner AS taufgaben_fansprechpartner, taufgaben.fanforderer AS taufgaben_fanforderer, taufgaben.fstandort_id AS taufgaben_fstandort_id, taufgaben.fwunschtermin AS taufgaben_fwunschtermin, taufgaben.fstarttermin AS taufgaben_fstarttermin, taufgaben.fgesamtaufwand AS taufgaben_fgesamtaufwand, taufgaben.fistaufwand AS taufgaben_fistaufwand, taufgaben.fprio AS taufgaben_fprio, taufgaben.ftester AS taufgaben_ftester, taufgaben.ffaellig AS taufgaben_ffaellig, taufgaben.flevel AS taufgaben_flevel, taufgaben.fkategorie AS taufgaben_fkategorie, taufgaben.feintragbearbeitung AS taufgaben_feintragbearbeitung, taufgaben.fbearbeitungsstatus AS taufgaben_fbearbeitungsstatus, taufgaben.fsolllimit AS taufgaben_fsolllimit, taufgaben.fistlimit AS taufgaben_fistlimit, taufgaben.fpauschalbetrag AS taufgaben_fpauschalbetrag, taufgaben.frechnungslaeufe_id AS taufgaben_frechnungslaeufe_id, taufgaben.fzuberechnen AS taufgaben_fzuberechnen, taufgaben.floesungsbeschreibung AS taufgaben_floesungsbeschreibung, taufgaben.ffehlerbeschreibung AS taufgaben_ffehlerbeschreibung, taufgaben.faufgabenstellung AS taufgaben_faufgabenstellung, taufgaben.fkritischeaenderungen AS taufgaben_fkritischeaenderungen, taufgaben.fbdeaufgabenersteller_id AS taufgaben_fbdeaufgabenersteller_id, taufgaben.fzufaktorieren AS taufgaben_fzufaktorieren, taufgaben.fisdirty AS taufgaben_fisdirty, taufgaben.fnf_kunde_stunden AS taufgaben_fnf_kunde_stunden, taufgaben.fzf_kunde_stunden AS taufgaben_fzf_kunde_stunden, taufgaben.fbf_kunde_stunden AS taufgaben_fbf_kunde_stunden, taufgaben.fnf_kunde_betrag AS taufgaben_fnf_kunde_betrag, taufgaben.fzf_kunde_betrag AS taufgaben_fzf_kunde_betrag, taufgaben.fbf_kunde_betrag AS taufgaben_fbf_kunde_betrag, taufgaben.fgesamt_brutto_stunden AS taufgaben_fgesamt_brutto_stunden, taufgaben.fgesamt_brutto_betrag AS taufgaben_fgesamt_brutto_betrag, taufgaben.fhinweisgesendet AS taufgaben_fhinweisgesendet, taufgaben.fwarnunggesendet AS taufgaben_fwarnunggesendet, taufgaben.fnfgesamtaufwand AS taufgaben_fnfgesamtaufwand, taufgaben.fnf_netto_stunden AS taufgaben_fnf_netto_stunden, taufgaben.fnf_brutto_stunden AS taufgaben_fnf_brutto_stunden, taufgaben.fnfhinweisgesendet AS taufgaben_fnfhinweisgesendet, taufgaben.fnfwarnunggesendet AS taufgaben_fnfwarnunggesendet, taufgaben.fhatzeiten AS taufgaben_fhatzeiten, taufgaben.fnichtpublicrechnungsfaehig AS taufgaben_fnichtpublicrechnungsfaehig, taufgaben.fnichtpublicrechnungsfaehigbetrag AS taufgaben_fnichtpublicrechnungsfaehigbetrag, taufgaben.fnichtberechenbar AS taufgaben_fnichtberechenbar, taufgaben.fnichtberechenbarbetrag AS taufgaben_fnichtberechenbarbetrag, taufgaben.finternertester AS taufgaben_finternertester, taufgaben.finterngetestet AS taufgaben_finterngetestet, taufgaben.fanzahlbearbeiter AS taufgaben_fanzahlbearbeiter , patchdaten.faufgaben_id AS pataid -- , vprojekt.* FROM taufgaben LEFT JOIN ( SELECT DISTINCT taufgaben_patches.faufgaben_id FROM taufgaben_patches ) patchdaten ON taufgaben.fid = patchdaten.faufgaben_id left join taufgaben_mitarbeiter am on taufgaben.fid = am.faufgaben_id --join vprojekt on taufgaben.fprojekt_id = vprojekt.tprojekte_fid where am.fmitarbeiter_id = 54 and taufgaben.fbearbeitungsstatus <> 2 ; ########################################################## query b using the select from the view "Nested Loop (cost=0.00..24.44 rows=1 width=1494) (actual time=0.000..0.000 rows=1 loops=1)" " Join Filter: ("outer".fprojektleiter_id = "inner".fid)" " -> Nested Loop (cost=0.00..18.98 rows=1 width=619) (actual time=0.000..0.000 rows=1 loops=1)" " Join Filter: ("outer".fabteilungen_id = "inner".fid)" " -> Nested Loop (cost=0.00..17.83 rows=1 width=555) (actual time=0.000..0.000 rows=1 loops=1)" " Join Filter: ("outer".fkostenstellen_id = "inner".fid)" " -> Nested Loop (cost=0.00..16.40 rows=1 width=512) (actual time=0.000..0.000 rows=1 loops=1)" " -> Nested Loop (cost=0.00..11.17 rows=1 width=465) (actual time=0.000..0.000 rows=1 loops=1)" " Join Filter: ("outer".fkunden_id = "inner".fid)" " -> Nested Loop (cost=0.00..8.27 rows=1 width=426) (actual time=0.000..0.000 rows=1 loops=1)" " Join Filter: ("outer".fkunden_kst_id = "inner".fid)" " -> Index Scan using aaaaaprojekte_pk on tprojekte (cost=0.00..5.97 rows=1 width=354) (actual time=0.000..0.000 rows=1 loops=1)" " Index Cond: (fid = 2153)" " -> Seq Scan on tkunden_kst (cost=0.00..1.58 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " -> Seq Scan on tkunden (cost=0.00..2.40 rows=40 width=51) (actual time=0.000..0.000 rows=40 loops=1)" " -> Index Scan using aaaaakostentraeger_pk on tkostentraeger (cost=0.00..5.21 rows=1 width=55) (actual time=0.000..0.000 rows=1 loops=1)" " Index Cond: ("outer".fkostentraeger_id = tkostentraeger.fid)" " -> Seq Scan on tkostenstellen (cost=0.00..1.19 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " -> Seq Scan on tabteilungen (cost=0.00..1.07 rows=7 width=76) (actual time=0.000..0.000 rows=7 loops=1)" " -> Seq Scan on tuser (cost=0.00..4.09 rows=109 width=883) (actual time=0.000..0.000 rows=109 loops=1)" "Total runtime: 0.000 ms" explain analyze SELECT tprojekte.fid AS tprojekte_fid, tprojekte.fbezeichnung AS tprojekte_fbezeichnung, tprojekte.fprojektnummer AS tprojekte_fprojektnummer, tprojekte.fbudget AS tprojekte_fbudget, tprojekte.fverrechnung_extern AS tprojekte_fverrechnung_extern, tprojekte.fstatus AS tprojekte_fstatus, tprojekte.fkunden_kst_id AS tprojekte_fkunden_kst_id, tprojekte.fverrechnungsbasis AS tprojekte_fverrechnungsbasis, tprojekte.fberechnungsart AS tprojekte_fberechnungsart, tprojekte.fprojekttyp AS tprojekte_fprojekttyp, tprojekte.fkostentraeger_id AS tprojekte_fkostentraeger_id, tprojekte.fprojektleiter_id AS tprojekte_fprojektleiter_id, tprojekte.fpauschalsatz AS tprojekte_fpauschalsatz, tprojekte.frechnungslaeufe_id AS tprojekte_frechnungslaeufe_id, tprojekte.fzuberechnen AS tprojekte_fzuberechnen, tprojekte.faufschlagrel AS tprojekte_faufschlagrel, tprojekte.faufschlagabs AS tprojekte_faufschlagabs, tprojekte.fbearbeitungsstatus AS tprojekte_fbearbeitungsstatus, tprojekte.fzufaktorieren AS tprojekte_fzufaktorieren, tprojekte.feurobudget AS tprojekte_feurobudget, tprojekte.fnf_kunde_stunden AS tprojekte_fnf_kunde_stunden, tprojekte.fzf_kunde_stunden AS tprojekte_fzf_kunde_stunden, tprojekte.fbf_kunde_stunden AS tprojekte_fbf_kunde_stunden, tprojekte.fnf_kunde_betrag AS tprojekte_fnf_kunde_betrag, tprojekte.fzf_kunde_betrag AS tprojekte_fzf_kunde_betrag, tprojekte.fbf_kunde_betrag AS tprojekte_fbf_kunde_betrag, tprojekte.fisdirty AS tprojekte_fisdirty, tprojekte.fgesamt_brutto_betrag AS tprojekte_fgesamt_brutto_betrag, tprojekte.fgesamt_brutto_stunden AS tprojekte_fgesamt_brutto_stunden, tprojekte.fgesamt_netto_stunden AS tprojekte_fgesamt_netto_stunden, tprojekte.fhinweisgesendet AS tprojekte_fhinweisgesendet, tprojekte.fwarnunggesendet AS tprojekte_fwarnunggesendet, tprojekte.fnfgesamtaufwand AS tprojekte_fnfgesamtaufwand, tprojekte.fnf_netto_stunden AS tprojekte_fnf_netto_stunden, tprojekte.fnf_brutto_stunden AS tprojekte_fnf_brutto_stunden, tprojekte.fnfhinweisgesendet AS tprojekte_fnfhinweisgesendet, tprojekte.fnfwarnunggesendet AS tprojekte_fnfwarnunggesendet, tprojekte.fhatzeiten AS tprojekte_fhatzeiten, tprojekte.fnichtpublicrechnungsfaehig AS tprojekte_fnichtpublicrechnungsfaehig, tprojekte.fnichtpublicrechnungsfaehigbetrag AS tprojekte_fnichtpublicrechnungsfaehigbetrag, tprojekte.fnichtberechenbar AS tprojekte_fnichtberechenbar, tprojekte.fnichtberechenbarbetrag AS tprojekte_fnichtberechenbarbetrag, tuser.fusername AS tuser_fusername, tuser.fpassword AS tuser_fpassword, tuser.fvorname AS tuser_fvorname, tuser.fnachname AS tuser_fnachname, tuser.fismitarbeiter AS tuser_fismitarbeiter, tuser.flevel AS tuser_flevel, tuser.fkuerzel AS tuser_fkuerzel, tuser.femailadresse AS tuser_femailadresse, tkunden_kst.fbezeichnung AS tkunden_kst_name, tkunden.fname AS tkunden_name, tabteilungen.fname AS tabteilungen_fname, tkostenstellen.fnummer AS tkostenstellen_fnummer, tkostentraeger.fnummer AS tkostentraeger_fnummer FROM ((((((tprojekte JOIN tuser ON ((tprojekte.fprojektleiter_id = tuser.fid))) JOIN tkunden_kst ON ((tprojekte.fkunden_kst_id = tkunden_kst.fid))) JOIN tkunden ON ((tkunden_kst.fkunden_id = tkunden.fid))) JOIN tkostentraeger ON ((tprojekte.fkostentraeger_id = tkostentraeger.fid))) JOIN tkostenstellen ON ((tkostentraeger.fkostenstellen_id = tkostenstellen.fid))) JOIN tabteilungen ON ((tkostenstellen.fabteilungen_id = tabteilungen.fid))) where tprojekte.fid = 2153 From pgsql-performance-owner@postgresql.org Thu May 12 23:44:30 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1E66856374 for ; Thu, 12 May 2005 23:44:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43255-03 for ; Fri, 13 May 2005 02:44:27 +0000 (GMT) Received: from dd01.profihoster.net (dd01.profihoster.net [80.86.168.71]) by svr1.postgresql.org (Postfix) with ESMTP id E76015632F for ; Thu, 12 May 2005 23:44:24 -0300 (ADT) Received: from [192.168.54.3] (G17a8.g.pppool.de [80.185.23.168]) by dd01.profihoster.net (Postfix) with ESMTP id B4D1E2383C5 for ; Fri, 13 May 2005 04:40:11 +0200 (CEST) Message-ID: <428414DE.8030904@laliluna.de> Date: Fri, 13 May 2005 04:45:50 +0200 From: Sebastian Hennebrueder User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 Cc: pgsql-performance@postgresql.org Subject: Re: Optimize complex join to use where condition before References: <4283D985.4080908@laliluna.de> In-Reply-To: <4283D985.4080908@laliluna.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/251 X-Sequence-Number: 12415 Solution not found as I thought. I integrated the query in a view and the query plan became very bad once again. The reason is that when I am using the view I have the joins in a differerent order. Does anyone have an idea to solve this. Sebastian a) bad order but the one I have in my application explain analyze SELECT taufgaben.fid AS taufgaben_fid, taufgaben.fprojekt_id AS taufgaben_fprojekt_id, taufgaben.fnummer AS taufgaben_fnummer, taufgaben.fbudget AS taufgaben_fbudget, taufgaben.ftyp AS taufgaben_ftyp, taufgaben.fberechnungsart AS taufgaben_fberechnungsart, taufgaben.fverrechnung_extern AS taufgaben_fverrechnung_extern, taufgaben.fverrechnungsbasis AS taufgaben_fverrechnungsbasis, taufgaben.fstatus AS taufgaben_fstatus, taufgaben.fkurzbeschreibung AS taufgaben_fkurzbeschreibung, taufgaben.fansprechpartner AS taufgaben_fansprechpartner, taufgaben.fanforderer AS taufgaben_fanforderer, taufgaben.fstandort_id AS taufgaben_fstandort_id, taufgaben.fwunschtermin AS taufgaben_fwunschtermin, taufgaben.fstarttermin AS taufgaben_fstarttermin, taufgaben.fgesamtaufwand AS taufgaben_fgesamtaufwand, taufgaben.fistaufwand AS taufgaben_fistaufwand, taufgaben.fprio AS taufgaben_fprio, taufgaben.ftester AS taufgaben_ftester, taufgaben.ffaellig AS taufgaben_ffaellig, taufgaben.flevel AS taufgaben_flevel, taufgaben.fkategorie AS taufgaben_fkategorie, taufgaben.feintragbearbeitung AS taufgaben_feintragbearbeitung, taufgaben.fbearbeitungsstatus AS taufgaben_fbearbeitungsstatus, taufgaben.fsolllimit AS taufgaben_fsolllimit, taufgaben.fistlimit AS taufgaben_fistlimit, taufgaben.fpauschalbetrag AS taufgaben_fpauschalbetrag, taufgaben.frechnungslaeufe_id AS taufgaben_frechnungslaeufe_id, taufgaben.fzuberechnen AS taufgaben_fzuberechnen, taufgaben.floesungsbeschreibung AS taufgaben_floesungsbeschreibung, taufgaben.ffehlerbeschreibung AS taufgaben_ffehlerbeschreibung, taufgaben.faufgabenstellung AS taufgaben_faufgabenstellung, taufgaben.fkritischeaenderungen AS taufgaben_fkritischeaenderungen, taufgaben.fbdeaufgabenersteller_id AS taufgaben_fbdeaufgabenersteller_id, taufgaben.fzufaktorieren AS taufgaben_fzufaktorieren, taufgaben.fisdirty AS taufgaben_fisdirty, taufgaben.fnf_kunde_stunden AS taufgaben_fnf_kunde_stunden, taufgaben.fzf_kunde_stunden AS taufgaben_fzf_kunde_stunden, taufgaben.fbf_kunde_stunden AS taufgaben_fbf_kunde_stunden, taufgaben.fnf_kunde_betrag AS taufgaben_fnf_kunde_betrag, taufgaben.fzf_kunde_betrag AS taufgaben_fzf_kunde_betrag, taufgaben.fbf_kunde_betrag AS taufgaben_fbf_kunde_betrag, taufgaben.fgesamt_brutto_stunden AS taufgaben_fgesamt_brutto_stunden, taufgaben.fgesamt_brutto_betrag AS taufgaben_fgesamt_brutto_betrag, taufgaben.fhinweisgesendet AS taufgaben_fhinweisgesendet, taufgaben.fwarnunggesendet AS taufgaben_fwarnunggesendet, taufgaben.fnfgesamtaufwand AS taufgaben_fnfgesamtaufwand, taufgaben.fnf_netto_stunden AS taufgaben_fnf_netto_stunden, taufgaben.fnf_brutto_stunden AS taufgaben_fnf_brutto_stunden, taufgaben.fnfhinweisgesendet AS taufgaben_fnfhinweisgesendet, taufgaben.fnfwarnunggesendet AS taufgaben_fnfwarnunggesendet, taufgaben.fhatzeiten AS taufgaben_fhatzeiten, taufgaben.fnichtpublicrechnungsfaehig AS taufgaben_fnichtpublicrechnungsfaehig, taufgaben.fnichtpublicrechnungsfaehigbetrag AS taufgaben_fnichtpublicrechnungsfaehigbetrag, taufgaben.fnichtberechenbar AS taufgaben_fnichtberechenbar, taufgaben.fnichtberechenbarbetrag AS taufgaben_fnichtberechenbarbetrag, taufgaben.finternertester AS taufgaben_finternertester, taufgaben.finterngetestet AS taufgaben_finterngetestet, taufgaben.fanzahlbearbeiter AS taufgaben_fanzahlbearbeiter, patchdaten.faufgaben_id AS pataid ,vprojekt.* FROM taufgaben LEFT JOIN ( SELECT DISTINCT taufgaben_patches.faufgaben_id FROM taufgaben_patches ) patchdaten ON taufgaben.fid = patchdaten.faufgaben_id JOIN vprojekt ON taufgaben.fprojekt_id = vprojekt.tprojekte_fid join taufgaben_mitarbeiter am on taufgaben.fid = am.faufgaben_id where am.fmitarbeiter_id = 54 and taufgaben.fbearbeitungsstatus <> 2 "Nested Loop (cost=1349.13..1435.29 rows=1 width=2541) (actual time=1640.000..3687.000 rows=62 loops=1)" " Join Filter: ("inner".fid = "outer".faufgaben_id)" " -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am (cost=0.00..80.65 rows=35 width=4) (actual time=0.000..0.000 rows=765 loops=1)" " Index Cond: (fmitarbeiter_id = 54)" " -> Materialize (cost=1349.13..1349.20 rows=7 width=2541) (actual time=0.531..1.570 rows=1120 loops=765)" " -> Merge Join (cost=1343.42..1349.13 rows=7 width=2541) (actual time=406.000..515.000 rows=1120 loops=1)" " Merge Cond: ("outer".fid = "inner".fprojekt_id)" " -> Sort (cost=130.89..130.90 rows=6 width=1494) (actual time=203.000..203.000 rows=876 loops=1)" " Sort Key: tprojekte.fid" " -> Merge Join (cost=130.52..130.81 rows=6 width=1494) (actual time=156.000..187.000 rows=876 loops=1)" " Merge Cond: ("outer".fkunden_id = "inner".fid)" " -> Sort (cost=127.06..127.07 rows=6 width=1455) (actual time=156.000..156.000 rows=876 loops=1)" " Sort Key: tkunden_kst.fkunden_id" " -> Merge Join (cost=126.34..126.98 rows=6 width=1455) (actual time=109.000..125.000 rows=876 loops=1)" " Merge Cond: ("outer".fprojektleiter_id = "inner".fid)" " -> Sort (cost=118.56..118.58 rows=9 width=580) (actual time=109.000..109.000 rows=876 loops=1)" " Sort Key: tprojekte.fprojektleiter_id" " -> Merge Join (cost=117.88..118.42 rows=9 width=580) (actual time=62.000..93.000 rows=876 loops=1)" " Merge Cond: ("outer".fkunden_kst_id = "inner".fid)" " -> Sort (cost=114.60..114.68 rows=31 width=508) (actual time=62.000..62.000 rows=876 loops=1)" " Sort Key: tprojekte.fkunden_kst_id" " -> Merge Join (cost=109.10..113.84 rows=31 width=508) (actual time=31.000..62.000 rows=876 loops=1)" " Merge Cond: ("outer".fid = "inner".fkostentraeger_id)" " -> Sort (cost=13.40..13.41 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostentraeger.fid" " -> Merge Join (cost=3.06..13.30 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Merge Cond: ("outer".fkostenstellen_id = "inner".fid)" " -> Index Scan using idx_kostenstellen_id on tkostentraeger (cost=0.00..9.74 rows=158 width=55) (actual time=0.000..0.000 rows=158 loops=1)" " -> Sort (cost=3.06..3.08 rows=7 width=119) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostenstellen.fid" " -> Merge Join (cost=2.76..2.96 rows=7 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Merge Cond: ("outer".fabteilungen_id = "inner".fid)" " -> Sort (cost=1.59..1.64 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tkostenstellen.fabteilungen_id" " -> Seq Scan on tkostenstellen (cost=0.00..1.19 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " -> Sort (cost=1.17..1.19 rows=7 width=76) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tabteilungen.fid" " -> Seq Scan on tabteilungen (cost=0.00..1.07 rows=7 width=76) (actual time=0.000..0.000 rows=7 loops=1)" " -> Sort (cost=95.71..97.90 rows=878 width=354) (actual time=31.000..46.000 rows=877 loops=1)" " Sort Key: tprojekte.fkostentraeger_id" " -> Seq Scan on tprojekte (cost=0.00..52.78 rows=878 width=354) (actual time=0.000..15.000 rows=878 loops=1)" " -> Sort (cost=3.28..3.42 rows=58 width=80) (actual time=0.000..0.000 rows=892 loops=1)" " Sort Key: tkunden_kst.fid" " -> Seq Scan on tkunden_kst (cost=0.00..1.58 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " -> Sort (cost=7.78..8.05 rows=109 width=883) (actual time=0.000..0.000 rows=950 loops=1)" " Sort Key: tuser.fid" " -> Seq Scan on tuser (cost=0.00..4.09 rows=109 width=883) (actual time=0.000..0.000 rows=109 loops=1)" " -> Sort (cost=3.46..3.56 rows=40 width=51) (actual time=0.000..0.000 rows=887 loops=1)" " Sort Key: tkunden.fid" " -> Seq Scan on tkunden (cost=0.00..2.40 rows=40 width=51) (actual time=0.000..0.000 rows=40 loops=1)" " -> Sort (cost=1212.53..1215.33 rows=1120 width=1047) (actual time=203.000..203.000 rows=1120 loops=1)" " Sort Key: taufgaben.fprojekt_id" " -> Merge Left Join (cost=1148.83..1155.80 rows=1120 width=1047) (actual time=140.000..203.000 rows=1120 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Sort (cost=910.60..913.40 rows=1120 width=1043) (actual time=78.000..78.000 rows=1120 loops=1)" " Sort Key: taufgaben.fid" " -> Seq Scan on taufgaben (cost=0.00..853.88 rows=1120 width=1043) (actual time=0.000..78.000 rows=1120 loops=1)" " Filter: (fbearbeitungsstatus <> 2)" " -> Sort (cost=238.23..238.73 rows=200 width=4) (actual time=62.000..93.000 rows=4773 loops=1)" " Sort Key: patchdaten.faufgaben_id" " -> Subquery Scan patchdaten (cost=0.00..230.59 rows=200 width=4) (actual time=0.000..47.000 rows=4773 loops=1)" " -> Unique (cost=0.00..228.59 rows=200 width=4) (actual time=0.000..0.000 rows=4773 loops=1)" " -> Index Scan using idx_aufpa_aufgabeid on taufgaben_patches (cost=0.00..212.74 rows=6340 width=4) (actual time=0.000..0.000 rows=6340 loops=1)" "Total runtime: 3703.000 ms" good order explain analyze SELECT taufgaben.fid AS taufgaben_fid, taufgaben.fprojekt_id AS taufgaben_fprojekt_id, taufgaben.fnummer AS taufgaben_fnummer, taufgaben.fbudget AS taufgaben_fbudget, taufgaben.ftyp AS taufgaben_ftyp, taufgaben.fberechnungsart AS taufgaben_fberechnungsart, taufgaben.fverrechnung_extern AS taufgaben_fverrechnung_extern, taufgaben.fverrechnungsbasis AS taufgaben_fverrechnungsbasis, taufgaben.fstatus AS taufgaben_fstatus, taufgaben.fkurzbeschreibung AS taufgaben_fkurzbeschreibung, taufgaben.fansprechpartner AS taufgaben_fansprechpartner, taufgaben.fanforderer AS taufgaben_fanforderer, taufgaben.fstandort_id AS taufgaben_fstandort_id, taufgaben.fwunschtermin AS taufgaben_fwunschtermin, taufgaben.fstarttermin AS taufgaben_fstarttermin, taufgaben.fgesamtaufwand AS taufgaben_fgesamtaufwand, taufgaben.fistaufwand AS taufgaben_fistaufwand, taufgaben.fprio AS taufgaben_fprio, taufgaben.ftester AS taufgaben_ftester, taufgaben.ffaellig AS taufgaben_ffaellig, taufgaben.flevel AS taufgaben_flevel, taufgaben.fkategorie AS taufgaben_fkategorie, taufgaben.feintragbearbeitung AS taufgaben_feintragbearbeitung, taufgaben.fbearbeitungsstatus AS taufgaben_fbearbeitungsstatus, taufgaben.fsolllimit AS taufgaben_fsolllimit, taufgaben.fistlimit AS taufgaben_fistlimit, taufgaben.fpauschalbetrag AS taufgaben_fpauschalbetrag, taufgaben.frechnungslaeufe_id AS taufgaben_frechnungslaeufe_id, taufgaben.fzuberechnen AS taufgaben_fzuberechnen, taufgaben.floesungsbeschreibung AS taufgaben_floesungsbeschreibung, taufgaben.ffehlerbeschreibung AS taufgaben_ffehlerbeschreibung, taufgaben.faufgabenstellung AS taufgaben_faufgabenstellung, taufgaben.fkritischeaenderungen AS taufgaben_fkritischeaenderungen, taufgaben.fbdeaufgabenersteller_id AS taufgaben_fbdeaufgabenersteller_id, taufgaben.fzufaktorieren AS taufgaben_fzufaktorieren, taufgaben.fisdirty AS taufgaben_fisdirty, taufgaben.fnf_kunde_stunden AS taufgaben_fnf_kunde_stunden, taufgaben.fzf_kunde_stunden AS taufgaben_fzf_kunde_stunden, taufgaben.fbf_kunde_stunden AS taufgaben_fbf_kunde_stunden, taufgaben.fnf_kunde_betrag AS taufgaben_fnf_kunde_betrag, taufgaben.fzf_kunde_betrag AS taufgaben_fzf_kunde_betrag, taufgaben.fbf_kunde_betrag AS taufgaben_fbf_kunde_betrag, taufgaben.fgesamt_brutto_stunden AS taufgaben_fgesamt_brutto_stunden, taufgaben.fgesamt_brutto_betrag AS taufgaben_fgesamt_brutto_betrag, taufgaben.fhinweisgesendet AS taufgaben_fhinweisgesendet, taufgaben.fwarnunggesendet AS taufgaben_fwarnunggesendet, taufgaben.fnfgesamtaufwand AS taufgaben_fnfgesamtaufwand, taufgaben.fnf_netto_stunden AS taufgaben_fnf_netto_stunden, taufgaben.fnf_brutto_stunden AS taufgaben_fnf_brutto_stunden, taufgaben.fnfhinweisgesendet AS taufgaben_fnfhinweisgesendet, taufgaben.fnfwarnunggesendet AS taufgaben_fnfwarnunggesendet, taufgaben.fhatzeiten AS taufgaben_fhatzeiten, taufgaben.fnichtpublicrechnungsfaehig AS taufgaben_fnichtpublicrechnungsfaehig, taufgaben.fnichtpublicrechnungsfaehigbetrag AS taufgaben_fnichtpublicrechnungsfaehigbetrag, taufgaben.fnichtberechenbar AS taufgaben_fnichtberechenbar, taufgaben.fnichtberechenbarbetrag AS taufgaben_fnichtberechenbarbetrag, taufgaben.finternertester AS taufgaben_finternertester, taufgaben.finterngetestet AS taufgaben_finterngetestet, taufgaben.fanzahlbearbeiter AS taufgaben_fanzahlbearbeiter, patchdaten.faufgaben_id AS pataid ,vprojekt.* FROM taufgaben LEFT JOIN ( SELECT DISTINCT taufgaben_patches.faufgaben_id FROM taufgaben_patches ) patchdaten ON taufgaben.fid = patchdaten.faufgaben_id join taufgaben_mitarbeiter am on taufgaben.fid = am.faufgaben_id JOIN vprojekt ON taufgaben.fprojekt_id = vprojekt.tprojekte_fid where am.fmitarbeiter_id = 54 and taufgaben.fbearbeitungsstatus <> 2 "Merge Join (cost=1371.38..1371.45 rows=1 width=2541) (actual time=422.000..438.000 rows=62 loops=1)" " Merge Cond: ("outer".fprojekt_id = "inner".fid)" " -> Sort (cost=1240.49..1240.51 rows=7 width=1047) (actual time=219.000..219.000 rows=62 loops=1)" " Sort Key: taufgaben.fprojekt_id" " -> Merge Join (cost=1230.38..1240.39 rows=7 width=1047) (actual time=157.000..219.000 rows=62 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Merge Left Join (cost=1148.83..1155.80 rows=1120 width=1047) (actual time=141.000..203.000 rows=1118 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Sort (cost=910.60..913.40 rows=1120 width=1043) (actual time=94.000..94.000 rows=1118 loops=1)" " Sort Key: taufgaben.fid" " -> Seq Scan on taufgaben (cost=0.00..853.88 rows=1120 width=1043) (actual time=0.000..94.000 rows=1120 loops=1)" " Filter: (fbearbeitungsstatus <> 2)" " -> Sort (cost=238.23..238.73 rows=200 width=4) (actual time=47.000..47.000 rows=4773 loops=1)" " Sort Key: patchdaten.faufgaben_id" " -> Subquery Scan patchdaten (cost=0.00..230.59 rows=200 width=4) (actual time=0.000..47.000 rows=4773 loops=1)" " -> Unique (cost=0.00..228.59 rows=200 width=4) (actual time=0.000..31.000 rows=4773 loops=1)" " -> Index Scan using idx_aufpa_aufgabeid on taufgaben_patches (cost=0.00..212.74 rows=6340 width=4) (actual time=0.000..15.000 rows=6340 loops=1)" " -> Sort (cost=81.54..81.63 rows=35 width=4) (actual time=16.000..16.000 rows=765 loops=1)" " Sort Key: am.faufgaben_id" " -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am (cost=0.00..80.65 rows=35 width=4) (actual time=0.000..16.000 rows=765 loops=1)" " Index Cond: (fmitarbeiter_id = 54)" " -> Sort (cost=130.89..130.90 rows=6 width=1494) (actual time=203.000..203.000 rows=916 loops=1)" " Sort Key: tprojekte.fid" " -> Merge Join (cost=130.52..130.81 rows=6 width=1494) (actual time=156.000..203.000 rows=876 loops=1)" " Merge Cond: ("outer".fkunden_id = "inner".fid)" " -> Sort (cost=127.06..127.07 rows=6 width=1455) (actual time=156.000..156.000 rows=876 loops=1)" " Sort Key: tkunden_kst.fkunden_id" " -> Merge Join (cost=126.34..126.98 rows=6 width=1455) (actual time=110.000..141.000 rows=876 loops=1)" " Merge Cond: ("outer".fprojektleiter_id = "inner".fid)" " -> Sort (cost=118.56..118.58 rows=9 width=580) (actual time=110.000..110.000 rows=876 loops=1)" " Sort Key: tprojekte.fprojektleiter_id" " -> Merge Join (cost=117.88..118.42 rows=9 width=580) (actual time=63.000..94.000 rows=876 loops=1)" " Merge Cond: ("outer".fkunden_kst_id = "inner".fid)" " -> Sort (cost=114.60..114.68 rows=31 width=508) (actual time=63.000..63.000 rows=876 loops=1)" " Sort Key: tprojekte.fkunden_kst_id" " -> Merge Join (cost=109.10..113.84 rows=31 width=508) (actual time=31.000..63.000 rows=876 loops=1)" " Merge Cond: ("outer".fid = "inner".fkostentraeger_id)" " -> Sort (cost=13.40..13.41 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostentraeger.fid" " -> Merge Join (cost=3.06..13.30 rows=7 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Merge Cond: ("outer".fkostenstellen_id = "inner".fid)" " -> Index Scan using idx_kostenstellen_id on tkostentraeger (cost=0.00..9.74 rows=158 width=55) (actual time=0.000..0.000 rows=158 loops=1)" " -> Sort (cost=3.06..3.08 rows=7 width=119) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostenstellen.fid" " -> Merge Join (cost=2.76..2.96 rows=7 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Merge Cond: ("outer".fabteilungen_id = "inner".fid)" " -> Sort (cost=1.59..1.64 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tkostenstellen.fabteilungen_id" " -> Seq Scan on tkostenstellen (cost=0.00..1.19 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " -> Sort (cost=1.17..1.19 rows=7 width=76) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tabteilungen.fid" " -> Seq Scan on tabteilungen (cost=0.00..1.07 rows=7 width=76) (actual time=0.000..0.000 rows=7 loops=1)" " -> Sort (cost=95.71..97.90 rows=878 width=354) (actual time=31.000..31.000 rows=877 loops=1)" " Sort Key: tprojekte.fkostentraeger_id" " -> Seq Scan on tprojekte (cost=0.00..52.78 rows=878 width=354) (actual time=0.000..31.000 rows=878 loops=1)" " -> Sort (cost=3.28..3.42 rows=58 width=80) (actual time=0.000..0.000 rows=892 loops=1)" " Sort Key: tkunden_kst.fid" " -> Seq Scan on tkunden_kst (cost=0.00..1.58 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " -> Sort (cost=7.78..8.05 rows=109 width=883) (actual time=0.000..0.000 rows=950 loops=1)" " Sort Key: tuser.fid" " -> Seq Scan on tuser (cost=0.00..4.09 rows=109 width=883) (actual time=0.000..0.000 rows=109 loops=1)" " -> Sort (cost=3.46..3.56 rows=40 width=51) (actual time=0.000..0.000 rows=887 loops=1)" " Sort Key: tkunden.fid" " -> Seq Scan on tkunden (cost=0.00..2.40 rows=40 width=51) (actual time=0.000..0.000 rows=40 loops=1)" "Total runtime: 438.000 ms" From pgsql-performance-owner@postgresql.org Thu May 12 23:52:55 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B6718537A6 for ; Thu, 12 May 2005 23:52:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43912-07 for ; Fri, 13 May 2005 02:52:47 +0000 (GMT) Received: from dd01.profihoster.net (dd01.profihoster.net [80.86.168.71]) by svr1.postgresql.org (Postfix) with ESMTP id 9CF7A54021 for ; Thu, 12 May 2005 23:52:46 -0300 (ADT) Received: from [192.168.54.3] (G17a8.g.pppool.de [80.185.23.168]) by dd01.profihoster.net (Postfix) with ESMTP id 4C3BB2383C5 for ; Fri, 13 May 2005 04:48:36 +0200 (CEST) Message-ID: <428416D8.8060303@laliluna.de> Date: Fri, 13 May 2005 04:54:16 +0200 From: Sebastian Hennebrueder User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Recommendations for set statistics Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/252 X-Sequence-Number: 12416 Hello, I could not find any recommandations for the level of set statistics and what a specific level does actually mean. What is the difference between 1, 50 and 100? What is recommanded for a table or column? -- Kind Regards / Viele Gr��e Sebastian Hennebrueder ----- http://www.laliluna.de/tutorials.html Tutorials for Java, Struts, JavaServer Faces, JSP, Hibernate, EJB and more. From pgsql-performance-owner@postgresql.org Fri May 13 00:36:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7DA4C5372C for ; Fri, 13 May 2005 00:36:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54261-06 for ; Fri, 13 May 2005 03:36:23 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 86E0453577 for ; Fri, 13 May 2005 00:36:22 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4D3aGDW014577; (envelope-from ) Thu, 12 May 2005 22:36:16 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4D3aC11012629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Thu, 12 May 2005 22:36:13 -0500 (CDT) Message-ID: <428420A1.9090707@arbash-meinel.com> Date: Thu, 12 May 2005 22:36:01 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sebastian Hennebrueder Cc: pgsql-performance@postgresql.org Subject: Re: Recommendations for set statistics References: <428416D8.8060303@laliluna.de> In-Reply-To: <428416D8.8060303@laliluna.de> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig503BE9990A3B7576AFF93DA5" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/253 X-Sequence-Number: 12417 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig503BE9990A3B7576AFF93DA5 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Sebastian Hennebrueder wrote: > Hello, > > I could not find any recommandations for the level of set statistics and > what a specific level does actually mean. > What is the difference between 1, 50 and 100? What is recommanded for a > table or column? > Default I believe is 10. The higher the number, the more statistics are kept, with a maximum of 1000. The default is a little bit low for columns used in foreign keys, though frequently it is okay. When problems start, try setting them to 100 or 200. Higher is more accurate, but takes longer to compute, *and* takes longer when planning the optimal query method. It can be worth it, though. John =:-> --------------enig503BE9990A3B7576AFF93DA5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFChCClJdeBCYSNAAMRAi8XAJ9G0bvNzT98YSjoJYv7RmYFCOD0mQCfXZdd mL5e8q9Sjm+TwzCSOqUyY0E= =W1Mu -----END PGP SIGNATURE----- --------------enig503BE9990A3B7576AFF93DA5-- From pgsql-performance-owner@postgresql.org Fri May 13 01:50:19 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A7EA53BF8 for ; Fri, 13 May 2005 01:50:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64104-01 for ; Fri, 13 May 2005 04:50:09 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 37435538BD for ; Fri, 13 May 2005 01:50:08 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 8DE4530952; Fri, 13 May 2005 06:47:46 +0200 (MET DST) From: Christopher Browne X-Newsgroups: pgsql.performance Subject: Re: Recommendations for set statistics Date: Fri, 13 May 2005 00:16:24 -0400 Organization: cbbrowne Computing Inc Lines: 45 Message-ID: References: <428416D8.8060303@laliluna.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:Ef57pbKuR7bFY5ERRIXIvI2frUE= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.392 tagged_above=0 required=5 tests=AWL, INFO_TLD X-Spam-Level: X-Archive-Number: 200505/254 X-Sequence-Number: 12418 After a long battle with technology, usenet@laliluna.de (Sebastian Hennebrueder), an earthling, wrote: > I could not find any recommandations for the level of set statistics > and what a specific level does actually mean. > What is the difference between 1, 50 and 100? What is recommanded for > a table or column? The numbers represent the numbers of "bins" used to establish histograms that estimate how the data looks. The default is to have 10 bins, and 300 items are sampled at ANALYZE time per bin. 1 would probably be rather bad, having very little ability to express the distribution of data. 100 bins would be 10x as expensive to store than 10, but would provide a much distribution. It is widely believed that a somewhat larger default than 10 would be a "good thing," as it seems to be fairly common for 10 to be too small to allow statistics to be stable. But nobody has done any formal evaluation as to whether it would make sense to jump from 10 to: - 15? - 20? - 50? - 100? - More than that? If we could show that 90% of the present "wrong results" that come from the default of 10 could be addressed by an increase to 20 bins, and the remainder could be left to individual tuning, well, getting rid of 90% of the "query plan errors" would seem worthwhile. I'd hope that a moderate (e.g. - from 10 to 20) increase, which would be pretty cheap, would help a fair bit, but there is no evidence one way or the other. Unfortunately, nobody has come up with a decent way of evaluating how much good a change to the default would actually do. If you can discover an evaluation scheme, your results are likely to get an ear. -- "cbbrowne","@","gmail.com" http://linuxdatabases.info/info/lsf.html "In 1555, Nostradamus wrote: 'Come the millennium, month 12, in the home of greatest power, the village idiot will come forth to be acclaimed the leader.'" From pgsql-performance-owner@postgresql.org Fri May 13 02:57:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AABCE54310 for ; Fri, 13 May 2005 02:57:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72111-02 for ; Fri, 13 May 2005 05:56:52 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id BE7D0538B4 for ; Fri, 13 May 2005 02:56:51 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DWTAC-000221-00; Fri, 13 May 2005 01:56:44 -0400 To: pgsql-performance@postgresql.org Subject: Re: Optimize complex join to use where condition before References: <4283D985.4080908@laliluna.de> <428414DE.8030904@laliluna.de> In-Reply-To: <428414DE.8030904@laliluna.de> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 13 May 2005 01:56:44 -0400 Message-ID: <8764xnoehv.fsf@stark.xeocode.com> Lines: 21 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/255 X-Sequence-Number: 12419 Sebastian Hennebrueder writes: > User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) > ... > > "Nested Loop (cost=1349.13..1435.29 rows=1 width=2541) (actual > time=1640.000..3687.000 rows=62 loops=1)" > " Join Filter: ("inner".fid = "outer".faufgaben_id)" > " -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am > (cost=0.00..80.65 rows=35 width=4) (actual time=0.000..0.000 rows=765 > loops=1)" Is it really Mozilla Thunderbird that's causing this new craptastic mangling of plans in people's mails? I was assuming it was some new idea of how to mess up people's mail coming out of Exchange or Lotus or some other such "corporate messaging" software that only handled SMTP mail as an afterthought. This is, uh, disappointing. -- greg From pgsql-performance-owner@postgresql.org Fri May 13 09:52:50 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 83E685294D for ; Fri, 13 May 2005 09:52:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30002-01 for ; Fri, 13 May 2005 12:52:42 +0000 (GMT) Received: from ns1.bi.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 090515351C for ; Fri, 13 May 2005 09:52:40 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bi.lt (8.12.11/8.12.11) with SMTP id j4DCqdH6015800 for ; Fri, 13 May 2005 15:52:39 +0300 Message-ID: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> From: "Mindaugas Riauba" To: Subject: PostgreSQL strugling during high load Date: Fri, 13 May 2005 15:52:38 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.442 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/256 X-Sequence-Number: 12420 Hello, We have problems with one postgresql database with high data change rate. Actually we are already under pressure to change postgresql to Oracle. I cannot post schema and queries to list but can do this privately. Tables are not big (20000-150000 rows each) but have very high turnover rate - 100+ updates/inserts/deletes/selects per second. So contents of database changes very fast. Problem is that when pg_autovacuum does vacuum those changes slows down too much. And we keep autovacuum quite aggressive (-v 1000 -V 0.5 -a 1000 -A 0.1 -s 10) to not bloat database and to avoid bigger impact. analyze seems not to impact performance too much. Tables have 2-3 indexes each and one table have foreign key contraint. Postgresql is 8.0.1. vmstat shows that IO and CPU are not saturated. DB is on RAID1+0 controller with battery backed write cache. What can we tune to improve performance in our case? Please help to defend PostgreSQL against Oracle in this case :). Thanks, Mindaugas From pgsql-performance-owner@postgresql.org Fri May 13 10:00:51 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 246455345F for ; Fri, 13 May 2005 10:00:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30902-05 for ; Fri, 13 May 2005 13:00:38 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id EBDAC533A6 for ; Fri, 13 May 2005 10:00:37 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DWZmP-0004am-Nv for pgsql-performance@postgresql.org; Fri, 13 May 2005 15:00:39 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1DWZmP-0000Wo-00 for ; Fri, 13 May 2005 15:00:37 +0200 Date: Fri, 13 May 2005 15:00:37 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load Message-ID: <20050513130037.GB31454@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.016 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/257 X-Sequence-Number: 12421 On Fri, May 13, 2005 at 03:52:38PM +0300, Mindaugas Riauba wrote: > Tables are not big (20000-150000 rows each) but have very high > turnover rate - 100+ updates/inserts/deletes/selects per second. > So contents of database changes very fast. Problem is that when > pg_autovacuum does vacuum those changes slows down too much. > And we keep autovacuum quite aggressive (-v 1000 -V 0.5 -a 1000 > -A 0.1 -s 10) to not bloat database and to avoid bigger impact. > analyze seems not to impact performance too much. Are you using the bgwriter? See http://developer.postgresql.org/~wieck/vacuum_cost/ for details. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Fri May 13 10:43:01 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1D03F53771 for ; Fri, 13 May 2005 10:42:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38593-10 for ; Fri, 13 May 2005 13:42:47 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3F9E95401A for ; Fri, 13 May 2005 10:42:46 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4DDghhA023218; Fri, 13 May 2005 09:42:43 -0400 (EDT) To: "Mindaugas Riauba" Cc: pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load In-reply-to: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> Comments: In-reply-to "Mindaugas Riauba" message dated "Fri, 13 May 2005 15:52:38 +0300" Date: Fri, 13 May 2005 09:42:43 -0400 Message-ID: <23217.1115991763@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/258 X-Sequence-Number: 12422 "Mindaugas Riauba" writes: > ... So contents of database changes very fast. Problem is that when > pg_autovacuum does vacuum those changes slows down too much. The "vacuum cost" parameters can be adjusted to make vacuums fired by pg_autovacuum less of a burden. I haven't got any specific numbers to suggest, but perhaps someone else does. regards, tom lane From pgsql-performance-owner@postgresql.org Fri May 13 11:10:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DA9E253771 for ; Fri, 13 May 2005 11:10:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43448-08 for ; Fri, 13 May 2005 14:10:00 +0000 (GMT) Received: from ns1.bi.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 547D05374C for ; Fri, 13 May 2005 11:09:57 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bi.lt (8.12.11/8.12.11) with SMTP id j4DEA1Zg016095; Fri, 13 May 2005 17:10:01 +0300 Message-ID: <022901c557c5$73df1220$f20214ac@bite.lt> From: "Mindaugas Riauba" To: "Tom Lane" Cc: References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> Subject: Re: PostgreSQL strugling during high load Date: Fri, 13 May 2005 17:10:01 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.312 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/259 X-Sequence-Number: 12423 > > ... So contents of database changes very fast. Problem is that when > > pg_autovacuum does vacuum those changes slows down too much. > > The "vacuum cost" parameters can be adjusted to make vacuums fired > by pg_autovacuum less of a burden. I haven't got any specific numbers > to suggest, but perhaps someone else does. It looks like that not only vacuum causes our problems. vacuum_cost seems to lower vacuum impact but we are still noticing slow queries "storm". We are logging queries that takes >2000ms to process. And there is quiet periods and then suddenly 30+ slow queries appears in log within the same second. What else could cause such behaviour? WAL log switch? One WAL file seems to last <1 minute. And also in slow queries log only function call is shown. Maybe it is possible to get exact query which slows everything down in the serverlog? Thanks, Mindaugas From pgsql-performance-owner@postgresql.org Fri May 13 11:12:45 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 900BF5383F for ; Fri, 13 May 2005 11:12:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44765-07 for ; Fri, 13 May 2005 14:12:41 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6812453771 for ; Fri, 13 May 2005 11:12:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4DECfjv023518; Fri, 13 May 2005 10:12:42 -0400 (EDT) To: "Mindaugas Riauba" Cc: pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load In-reply-to: <022901c557c5$73df1220$f20214ac@bite.lt> References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> Comments: In-reply-to "Mindaugas Riauba" message dated "Fri, 13 May 2005 17:10:01 +0300" Date: Fri, 13 May 2005 10:12:41 -0400 Message-ID: <23517.1115993561@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/260 X-Sequence-Number: 12424 "Mindaugas Riauba" writes: > It looks like that not only vacuum causes our problems. vacuum_cost > seems to lower vacuum impact but we are still noticing slow queries "storm". > We are logging queries that takes >2000ms to process. > And there is quiet periods and then suddenly 30+ slow queries appears in > log within the same second. What else could cause such behaviour? Checkpoints? You should ensure that the checkpoint settings are such that checkpoints don't happen too often (certainly not oftener than every five minutes or so), and make sure the bgwriter is configured to dribble out dirty pages at a reasonable rate, so that the next checkpoint doesn't have a whole load of stuff to write. regards, tom lane From pgsql-performance-owner@postgresql.org Fri May 13 11:45:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C270956604 for ; Fri, 13 May 2005 11:45:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51763-04 for ; Fri, 13 May 2005 14:45:42 +0000 (GMT) Received: from ns1.bi.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 0D0A45660E for ; Fri, 13 May 2005 11:45:41 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bi.lt (8.12.11/8.12.11) with SMTP id j4DEjjdL016463; Fri, 13 May 2005 17:45:45 +0300 Message-ID: <026b01c557ca$71c5b5c0$f20214ac@bite.lt> From: "Mindaugas Riauba" To: "Tom Lane" Cc: References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> <23517.1115993561@sss.pgh.pa.us> Subject: Re: PostgreSQL strugling during high load Date: Fri, 13 May 2005 17:45:45 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.246 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/261 X-Sequence-Number: 12425 > > It looks like that not only vacuum causes our problems. vacuum_cost > > seems to lower vacuum impact but we are still noticing slow queries "storm". > > We are logging queries that takes >2000ms to process. > > And there is quiet periods and then suddenly 30+ slow queries appears in > > log within the same second. What else could cause such behaviour? > > Checkpoints? You should ensure that the checkpoint settings are such > that checkpoints don't happen too often (certainly not oftener than > every five minutes or so), and make sure the bgwriter is configured > to dribble out dirty pages at a reasonable rate, so that the next > checkpoint doesn't have a whole load of stuff to write. bgwriter settings are default. bgwriter_delay=200, bgwriter_maxpages=100, bgwriter_percent=1. checkpoint_segments=8, checkpoint_timeout=300, checkpoint_warning=30. But there's no checkpoint warnings in serverlog. And btw we are running with fsync=off (yes I know the consequences). Database from the viewpoint of disk is practically write only since amount of data is smaller than memory available. I also added some 'vmstat 1' output. How to get more even load. As you see neither disk nor cpu looks too busy. Thanks, Mindaugas procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 1 0 0 194724 12140 10220 1045356 0 1 33 24 60 20 13 3 83 2 0 0 194724 11988 10228 1045464 0 0 12 0 1147 6107 13 4 82 0 2 0 194724 12172 10284 1046076 0 0 244 20692 2067 3117 8 8 84 1 0 0 194724 12164 10280 1045912 0 0 0 4 876 8831 15 11 74 3 0 0 194724 11704 10328 1045952 0 0 24 2116 928 5122 13 12 75 1 0 0 194724 11444 10236 1046264 0 0 340 0 1048 6538 19 10 71 1 0 0 194724 11924 10236 1045816 0 0 0 0 885 7616 14 20 66 0 0 0 194724 11408 10252 1044824 0 0 28 5488 959 4749 11 14 75 1 0 0 194724 11736 10296 1042992 0 0 460 2868 1001 4116 12 12 75 0 0 0 194724 12024 10296 1043064 0 0 36 0 903 5081 13 12 76 1 0 0 194724 12404 10240 1043440 0 0 280 0 899 4246 12 12 75 1 0 0 194724 13128 10236 1043472 0 0 0 0 1016 5394 12 10 78 0 4 0 194724 13064 10244 1043652 0 0 0 14736 1882 9290 10 15 74 0 4 0 194724 13056 10252 1043660 0 0 0 6012 1355 2378 2 3 95 12 21 0 194724 13140 10220 1043640 0 0 8 4 723 2984 5 3 92 1 0 0 194724 13712 10228 1043956 0 0 200 0 1144 10310 30 21 50 0 0 0 194724 13100 10220 1043992 0 0 4 0 840 4676 15 14 71 0 0 0 194724 13048 10296 1041212 0 0 4 6132 918 4074 10 10 80 0 0 0 194724 12688 10324 1041508 0 0 240 1864 849 3873 12 11 77 2 0 0 194724 12544 10240 1041944 0 0 32 0 1171 4844 14 7 78 1 0 0 194724 12384 10232 1041756 0 0 4 0 973 6063 16 9 75 1 0 0 194724 12904 10244 1042116 0 0 264 6052 1049 4762 15 14 71 0 0 0 194724 12616 10236 1042164 0 0 8 0 883 4748 13 8 79 2 0 0 194724 12576 10288 1042460 0 0 252 3136 857 3929 13 15 73 2 0 0 194724 12156 10284 1042504 0 0 0 0 858 8832 13 6 81 2 0 0 194724 12024 10284 1042556 0 0 0 0 834 4229 16 10 74 3 1 0 194724 12024 10364 1043096 0 0 316 10328 1024 5686 14 7 80 0 5 0 194724 12024 10352 1043116 0 0 4 7996 2156 2816 4 5 90 0 4 0 194724 12024 10360 1043124 0 0 4 8560 1369 2700 6 5 90 3 0 0 194724 12024 10264 1043124 0 0 0 4 1037 5132 14 15 71 1 1 0 194724 11876 10264 1043176 0 0 4 0 932 7761 20 20 6 From pgsql-performance-owner@postgresql.org Fri May 13 12:23:33 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 75FE6534C4 for ; Fri, 13 May 2005 12:23:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58750-02 for ; Fri, 13 May 2005 15:23:27 +0000 (GMT) Received: from ebrsrv01.ebravo.it (host53-205.pool8534.interbusiness.it [85.34.205.53]) by svr1.postgresql.org (Postfix) with ESMTP id E3CB55339C for ; Fri, 13 May 2005 12:23:25 -0300 (ADT) Received: from [192.168.11.103] ([192.168.11.103]) (authenticated) by ebrsrv01.ebravo.it (8.11.6/8.12.5) with ESMTP id j4DFNJY01682; Fri, 13 May 2005 17:23:19 +0200 Message-ID: <4284C661.4050406@streppone.it> Date: Fri, 13 May 2005 17:23:13 +0200 From: Cosimo Streppone User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: it, it-it, en-us, en MIME-Version: 1.0 To: Mindaugas Riauba Cc: pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> In-Reply-To: <022901c557c5$73df1220$f20214ac@bite.lt> Content-Type: text/plain; charset=windows-1257; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/262 X-Sequence-Number: 12426 Mindaugas Riauba wrote: >>The "vacuum cost" parameters can be adjusted to make vacuums fired >>by pg_autovacuum less of a burden. I haven't got any specific numbers >>to suggest, but perhaps someone else does. > > It looks like that not only vacuum causes our problems. vacuum_cost > seems to lower vacuum impact but we are still noticing slow queries "storm". > We are logging queries that takes >2000ms to process. > And there is quiet periods and then suddenly 30+ slow queries appears in > log within the same second. What else could cause such behaviour? I've seen that happen when you're placing (explicitly or *implicitly*) locks on the records you're trying to update/delete. If you're willing to investigate, `pg_locks' system view holds information about db locks. -- Cosimo From pgsql-performance-owner@postgresql.org Fri May 13 12:41:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3925653323 for ; Fri, 13 May 2005 12:41:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60959-09 for ; Fri, 13 May 2005 15:41:45 +0000 (GMT) Received: from ns1.bi.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 029EB52A55 for ; Fri, 13 May 2005 12:41:44 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bi.lt (8.12.11/8.12.11) with SMTP id j4DFfhTV016654; Fri, 13 May 2005 18:41:43 +0300 Message-ID: <02f901c557d2$43517e10$f20214ac@bite.lt> From: "Mindaugas Riauba" To: "Cosimo Streppone" Cc: References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> <4284C661.4050406@streppone.it> Subject: Re: PostgreSQL strugling during high load Date: Fri, 13 May 2005 18:41:43 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.207 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/263 X-Sequence-Number: 12427 > >>The "vacuum cost" parameters can be adjusted to make vacuums fired > >>by pg_autovacuum less of a burden. I haven't got any specific numbers > >>to suggest, but perhaps someone else does. > > > > It looks like that not only vacuum causes our problems. vacuum_cost > > seems to lower vacuum impact but we are still noticing slow queries "storm". > > We are logging queries that takes >2000ms to process. > > And there is quiet periods and then suddenly 30+ slow queries appears in > > log within the same second. What else could cause such behaviour? > > I've seen that happen when you're placing (explicitly or > *implicitly*) locks on the records you're trying to update/delete. > > If you're willing to investigate, `pg_locks' system view holds > information about db locks. Hm. Yes. Number of locks varies quite alot (10-600). Now what to investigate further? We do not use explicit locks in our functions. We use quite simple update/delete where key=something; Some sample (select * from pg_locks order by pid) is below. Thanks, Mindaugas | | 584302172 | 11836 | ExclusiveLock | t 17236 | 17230 | | 11836 | AccessShareLock | t 17236 | 17230 | | 11836 | RowExclusiveLock | t 127103 | 17230 | | 11836 | RowExclusiveLock | t 127106 | 17230 | | 11836 | RowExclusiveLock | t 127109 | 17230 | | 11836 | AccessShareLock | t 127109 | 17230 | | 11836 | RowExclusiveLock | t 127109 | 17230 | | 11837 | AccessShareLock | t 127109 | 17230 | | 11837 | RowExclusiveLock | t 17236 | 17230 | | 11837 | AccessShareLock | t 17236 | 17230 | | 11837 | RowExclusiveLock | t 127106 | 17230 | | 11837 | RowExclusiveLock | t 127103 | 17230 | | 11837 | RowExclusiveLock | t | | 584302173 | 11837 | ExclusiveLock | t 127103 | 17230 | | 11838 | RowExclusiveLock | t 17236 | 17230 | | 11838 | RowExclusiveLock | t 127109 | 17230 | | 11838 | RowExclusiveLock | t | | 584302174 | 11838 | ExclusiveLock | t 17285 | 17230 | | 11838 | AccessShareLock | t 17251 | 17230 | | 11838 | AccessShareLock | t 130516 | 17230 | | 11838 | AccessShareLock | t 127106 | 17230 | | 11838 | RowExclusiveLock | t 17278 | 17230 | | 11838 | AccessShareLock | t From pgsql-performance-owner@postgresql.org Fri May 13 13:12:24 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9510D53492 for ; Fri, 13 May 2005 13:12:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69049-01 for ; Fri, 13 May 2005 16:12:17 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id 74F565331C for ; Fri, 13 May 2005 13:12:16 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DWclq-0008SG-BG for pgsql-performance@postgresql.org; Fri, 13 May 2005 18:12:14 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1DWclq-0007VH-00 for ; Fri, 13 May 2005 18:12:14 +0200 Date: Fri, 13 May 2005 18:12:14 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load Message-ID: <20050513161214.GD28043@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> <23517.1115993561@sss.pgh.pa.us> <026b01c557ca$71c5b5c0$f20214ac@bite.lt> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <026b01c557ca$71c5b5c0$f20214ac@bite.lt> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.016 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/264 X-Sequence-Number: 12428 On Fri, May 13, 2005 at 05:45:45PM +0300, Mindaugas Riauba wrote: > But there's no checkpoint warnings in serverlog. And btw we are running > with fsync=off (yes I know the consequences). Just a note here; since you have battery-backed hardware cache, you probably won't notice that much of a slowdown with fsync=on. However, you are already pushed, so... :-) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Fri May 13 13:22:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A0CE95365B for ; Fri, 13 May 2005 13:22:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69944-07 for ; Fri, 13 May 2005 16:22:10 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 408E15350F for ; Fri, 13 May 2005 13:22:09 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7358973; Fri, 13 May 2005 09:24:10 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Christopher Browne Subject: Re: Recommendations for set statistics Date: Fri, 13 May 2005 09:22:11 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <428416D8.8060303@laliluna.de> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200505130922.11582.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/265 X-Sequence-Number: 12429 Chris, > It is widely believed that a somewhat larger default than 10 would be > a "good thing," as it seems to be fairly common for 10 to be too small > to allow statistics to be stable. =A0But nobody has done any formal > evaluation as to whether it would make sense to jump from 10 to: > > =A0- 15? > =A0- 20? > =A0- 50? > =A0- 100? > =A0- More than that? My anecdotal experience is that if more than 10 is required, you generally= =20 need to jump to at least 100, and more often 250. On the other end, I've= =20 generally not found any difference between 400 and 1000 when it comes to=20 "bad" queries. I have an unfinished patch in the works which goes through and increases th= e=20 stats_target for all *indexed* columns to 100 or so. However, I've needed= =20 to work up a test case to prove the utility of it. =2D-=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri May 13 13:42:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 95D075337D for ; Fri, 13 May 2005 13:42:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73457-09 for ; Fri, 13 May 2005 16:42:46 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4F89853AB5 for ; Fri, 13 May 2005 13:42:46 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4DGgilO024734; Fri, 13 May 2005 12:42:44 -0400 (EDT) To: "Mindaugas Riauba" Cc: "Cosimo Streppone" , pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load In-reply-to: <02f901c557d2$43517e10$f20214ac@bite.lt> References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> <4284C661.4050406@streppone.it> <02f901c557d2$43517e10$f20214ac@bite.lt> Comments: In-reply-to "Mindaugas Riauba" message dated "Fri, 13 May 2005 18:41:43 +0300" Date: Fri, 13 May 2005 12:42:44 -0400 Message-ID: <24733.1116002564@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/266 X-Sequence-Number: 12430 "Mindaugas Riauba" writes: > Hm. Yes. Number of locks varies quite alot (10-600). Now what to > investigate > further? We do not use explicit locks in our functions. We use quite simple > update/delete where key=something; > Some sample (select * from pg_locks order by pid) is below. The sample doesn't show any lock issues (there are no processes waiting for ungranted locks). The thing that typically burns people is foreign key conflicts. In current releases, if you have a foreign key reference then an insert in the referencing table takes an exclusive row lock on the referenced (master) row --- which means that two inserts using the same foreign key value block each other. You can alleviate the issue by making all your foreign key checks deferred, but that just shortens the period of time the lock is held. There will be a real solution in PG 8.1, which has sharable row locks. regards, tom lane From pgsql-performance-owner@postgresql.org Fri May 13 14:33:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9122353A9B for ; Fri, 13 May 2005 14:33:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82331-09 for ; Fri, 13 May 2005 17:33:24 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id E2EAA53A36 for ; Fri, 13 May 2005 14:33:22 -0300 (ADT) Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050513173323.QOMD21244.priv-edtnes56.telusplanet.net@localhost>; Fri, 13 May 2005 11:33:23 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; Fri, 13 May 2005 10:33:22 -0700 Message-ID: <1116005602.4284e4e28869e@webmail.telus.net> Date: Fri, 13 May 2005 10:33:22 -0700 From: Mischa Sandberg To: Tom Lane Cc: Mindaugas Riauba , pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> In-Reply-To: <23217.1115991763@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.04 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/267 X-Sequence-Number: 12431 Quoting Tom Lane : > "Mindaugas Riauba" writes: > > ... So contents of database changes very fast. Problem is that > when > > pg_autovacuum does vacuum those changes slows down too much. > > The "vacuum cost" parameters can be adjusted to make vacuums fired > by pg_autovacuum less of a burden. I haven't got any specific > numbers > to suggest, but perhaps someone else does. I solved one problem by cranking sleep scaling to -S 20. It made pg_autovacuum back off longer during extended periods of heavy disk-intensive query activity. Our update activity is near-constant insert rate, then once or twice a day, massive deletes. -- Dreams come true, not free. From pgsql-performance-owner@postgresql.org Fri May 13 15:33:12 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E25575331C for ; Fri, 13 May 2005 15:33:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95555-04 for ; Fri, 13 May 2005 18:33:05 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 32BA352A9A for ; Fri, 13 May 2005 15:33:00 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4DIWjWP009823; (envelope-from ) Fri, 13 May 2005 13:32:45 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4DIWhH1015587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Fri, 13 May 2005 13:32:44 -0500 (CDT) Message-ID: <4284F2CA.1070107@arbash-meinel.com> Date: Fri, 13 May 2005 13:32:42 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Greg Stark Cc: pgsql-performance@postgresql.org Subject: Re: Optimize complex join to use where condition before References: <4283D985.4080908@laliluna.de> <428414DE.8030904@laliluna.de> <8764xnoehv.fsf@stark.xeocode.com> In-Reply-To: <8764xnoehv.fsf@stark.xeocode.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC04E1A06AA0EDCE529417086" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/268 X-Sequence-Number: 12432 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC04E1A06AA0EDCE529417086 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Greg Stark wrote: > Sebastian Hennebrueder writes: > > >>User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) >>... >> >>"Nested Loop (cost=1349.13..1435.29 rows=1 width=2541) (actual >>time=1640.000..3687.000 rows=62 loops=1)" >>" Join Filter: ("inner".fid = "outer".faufgaben_id)" >>" -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am >>(cost=0.00..80.65 rows=35 width=4) (actual time=0.000..0.000 rows=765 >>loops=1)" > > > Is it really Mozilla Thunderbird that's causing this new craptastic mangling > of plans in people's mails? I was assuming it was some new idea of how to mess > up people's mail coming out of Exchange or Lotus or some other such "corporate > messaging" software that only handled SMTP mail as an afterthought. This is, > uh, disappointing. > Are you talking about the quotes, or just the fact that it is wrapped? I don't know where the quotes came from, but in Thunderbird if you are writing in text mode (not html) it defaults to wrapping the text at something like 78 characters. That includes copy/paste text. If you want it to *not* wrap, it turns out that "Paste as quotation" will not wrap, but then you have to remove the "> " from the beginning of every line. In html mode, it also defaults to wrapping, but if you switch to PREFORMAT text first, it doesn't wrap. At least, those are the tricks that I've found. Safest bet is to just use an attachment, though. John =:-> --------------enigC04E1A06AA0EDCE529417086 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFChPLKJdeBCYSNAAMRAseEAJ4zToMRzPIGLbEjdwhavYn6m/nUlwCffOEQ 87d8L6vPhq1MGMg4mhyfEwE= =AoYd -----END PGP SIGNATURE----- --------------enigC04E1A06AA0EDCE529417086-- From pgsql-performance-owner@postgresql.org Fri May 13 15:35:58 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B53DE5331C for ; Fri, 13 May 2005 15:35:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96026-08 for ; Fri, 13 May 2005 18:35:51 +0000 (GMT) Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) by svr1.postgresql.org (Postfix) with ESMTP id 7DFCA5339C for ; Fri, 13 May 2005 15:35:47 -0300 (ADT) Received: from tschibtschibojtschitsch (dsl-082-082-199-114.arcor-ip.net [82.82.199.114]) (authenticated) by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id j4DIZdv20047; Fri, 13 May 2005 20:35:39 +0200 Subject: Re: Bad plan after vacuum analyze From: Markus Bertheau To: Guillaume Smet Cc: Tom Lane , josh@agliodbs.com, pgsql-performance@postgresql.org In-Reply-To: <4282723C.5080903@smet.org> References: <42823F94.8050009@smet.org> <200505111110.15983.josh@agliodbs.com> <13964.1115837926@sss.pgh.pa.us> <42825DBB.7000703@smet.org> <14301.1115840296@sss.pgh.pa.us> <4282638E.2020307@smet.org> <17017.1115843555@sss.pgh.pa.us> <4282723C.5080903@smet.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-tuFi4bR4cl1+vr6p9K4h" Date: Fri, 13 May 2005 20:35:35 +0200 Message-Id: <1116009335.7327.0.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.102 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/269 X-Sequence-Number: 12433 --=-tuFi4bR4cl1+vr6p9K4h Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =D0=92 =D0=A1=D1=80=D0=B4, 11/05/2005 =D0=B2 22:59 +0200, Guillaume Smet = =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > Anyway, I tried to work on the statistics as you told me and here are=20 > the results: > ccm_perf=3D# ALTER TABLE acs_objects ALTER COLUMN object_id SET STATISTIC= S 30; > ALTER TABLE > ccm_perf=3D# ANALYZE acs_objects; > ANALYZE >=20 > ccm_perf=3D# \i query_section.sql > ... correct plan ... > Total runtime: 0.555 ms Given Tom's analysis, how can increasing the stats target change which plan is chosen? --=20 Markus Bertheau --=-tuFi4bR4cl1+vr6p9K4h Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBChPN22RUnMPztcykRAna1AJ9xA1Ag6Q+n0bTXQ+RG+LkE4u2WKQCfR13I GQXdW/oiKk8FpS2l0k8mvB0= =PC0S -----END PGP SIGNATURE----- --=-tuFi4bR4cl1+vr6p9K4h-- From pgsql-performance-owner@postgresql.org Fri May 13 16:27:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5FEDE5335C for ; Fri, 13 May 2005 16:27:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04645-05 for ; Fri, 13 May 2005 19:27:32 +0000 (GMT) Received: from mta10.nationwireless.net (mta10.nationwireless.net [63.163.128.10]) by svr1.postgresql.org (Postfix) with ESMTP id 9815E52968 for ; Fri, 13 May 2005 16:27:30 -0300 (ADT) Received: from jfradkin [63.162.100.127] by mta10.nationwireless.net with ESMTP (SMTPD-8.20) id AFA3055C; Fri, 13 May 2005 15:27:31 -0400 From: "Joel Fradkin" To: "PostgreSQL Perform" Subject: ok you all win what is best opteron (I dont want a hosed system again) Date: Fri, 13 May 2005 15:27:55 -0400 Message-ID: <009601c557f1$dd2f5a10$797ba8c0@jfradkin> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0097_01C557D0.561DBA10" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.871 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE, MSGID_DOLLARS X-Spam-Level: * X-Archive-Number: 200505/270 X-Sequence-Number: 12434 This is a multi-part message in MIME format. ------=_NextPart_000_0097_01C557D0.561DBA10 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable We are up and somewhat happy. =20 I have been following threads (in case you don't know I bought a 4 proc = Dell recently) and the Opteron seems the way to go. I just called HP for a quote, but don't want to make any mistakes. =20 Is the battery backed cache good or bad for Postgres? =20 They are telling me I can only get a duel channel card if I want = hardware raid 10 on the 14 drives. I can get two cards but it has to be 7 and 7 (software raid?) which does = not sound like it fixes my single point of failure (one of the listers = mentioned my current system has 3 such single points). =20 Any of you hardware gurus spell out the optimal machine (I am hoping to = be around 15K, might be able to go more if it's a huge difference, I spent = 30k on the Dell). I do not have to go HP, and after seeing the fail ratio from Monarch = from one lister I am bit scared shopping there. Was there a conclusion on where is best to get one (I really want two = one for development too). =20 =20 Joel Fradkin =20 Wazagua, Inc. 2520 Trailmate Dr Sarasota, Florida 34243 Tel. 941-753-7111 ext 305 =20 jfradkin@wazagua.com www.wazagua.com Powered by Wazagua Providing you with the latest Web-based technology & advanced tools. C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc This email message is for the use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized = review, use, disclosure or distribution is prohibited. If you are not the = intended recipient, please contact the sender by reply email and delete and = destroy all copies of the original message, including attachments. =20 =20 =20 ------=_NextPart_000_0097_01C557D0.561DBA10 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

We are up and somewhat happy.

 

I have been following threads (in case you = don’t know I bought a 4 proc Dell recently) and the Opteron seems the way to = go.

I just called HP for a quote, but don’t want to = make any mistakes.

 

Is the battery backed cache good or bad for = Postgres?

 

They are telling me I can only get a duel channel = card if I want hardware raid 10 on the 14 drives.

I can get two cards but it has to be 7 and 7 = (software raid?) which does not sound like it fixes my single point of failure = (one of the listers mentioned my current system has 3 such single = points).

 

Any of you hardware gurus spell out the optimal = machine (I am hoping to be around 15K, might be able to go more if it’s a = huge difference, I spent 30k on the Dell).

I do not have to go HP, and after seeing the fail = ratio from Monarch from one lister I am bit scared shopping = there.

Was there a conclusion on where is best to get one (I = really want two one for development too).

 

 

Joel Fradkin

 

Wazagua, Inc.
2520 Trailmate Dr
Sarasota, Florida = 34243
Tel.  941-753-7111 ext 305

 

jfradkin@wazagua.com
www.wazagua.com
Powered by Wazagua
Providing you with the latest Web-based technology & advanced = tools.
© 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
 This email message is for the use of the intended recipient(s) and = may contain confidential and privileged information.  Any unauthorized = review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and delete = and destroy all copies of the original message, including = attachments.

 


 

 

------=_NextPart_000_0097_01C557D0.561DBA10-- From pgsql-performance-owner@postgresql.org Fri May 13 16:56:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5EB915337D for ; Fri, 13 May 2005 16:56:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07211-10 for ; Fri, 13 May 2005 19:56:46 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 7A8F753631 for ; Fri, 13 May 2005 16:56:43 -0300 (ADT) Content-class: urn:content-classes:message Subject: Re: ok you all win what is best opteron (I dont want a hosed system again) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Fri, 13 May 2005 15:55:16 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3415C2855@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] ok you all win what is best opteron (I dont want a hosed system again) thread-index: AcVX8iAXX+uEqGuUQNCRCak+Y0kRywAAr/Ig From: "Merlin Moncure" To: "Joel Fradkin" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/271 X-Sequence-Number: 12435 Joel wrote: I have been following threads (in case you don't know I bought a 4 proc Dell recently) and the Opteron seems the way to go. I just called HP for a quote, but don't want to make any mistakes. [snip] At your level of play it's the DL585. Have you checked out http://www.swt.com?=20 Merlin From pgsql-performance-owner@postgresql.org Fri May 13 18:07:49 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3227C53853 for ; Fri, 13 May 2005 18:07:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19824-08 for ; Fri, 13 May 2005 21:07:45 +0000 (GMT) Received: from smtp100.rog.mail.re2.yahoo.com (smtp100.rog.mail.re2.yahoo.com [206.190.36.78]) by svr1.postgresql.org (Postfix) with SMTP id DAB3D53835 for ; Fri, 13 May 2005 18:07:41 -0300 (ADT) Received: from unknown (HELO phlogiston.dydns.org) (a.sullivan@rogers.com@216.75.167.195 with login) by smtp100.rog.mail.re2.yahoo.com with SMTP; 13 May 2005 21:07:36 -0000 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 2AD073D2F; Fri, 13 May 2005 17:07:35 -0400 (EDT) Date: Fri, 13 May 2005 17:07:35 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Whence the Opterons? Message-ID: <20050513210735.GE31659@phlogiston.dyndns.org> References: <1115415551.427be3ffe44c8@webmail.telus.net> <20050507145746.GB15586@phlogiston.dyndns.org> <200505071400.35282.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200505071400.35282.josh@agliodbs.com> User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.043 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/272 X-Sequence-Number: 12436 On Sat, May 07, 2005 at 02:00:34PM -0700, Josh Berkus wrote: > > Question, though: is HP still using their proprietary RAID card? And, if so, > have they fixed its performance problems? According to my folks here, we're using the CCISS controllers, so I guess they are. The systems are nevertheless performing very well -- we did a load test that was pretty impressive. Also, Chris Browne pointed me to this for the drivers: http://sourceforge.net/projects/cciss/ A -- Andrew Sullivan | ajs@crankycanuck.ca A certain description of men are for getting out of debt, yet are against all taxes for raising money to pay it off. --Alexander Hamilton From pgsql-performance-owner@postgresql.org Fri May 13 18:22:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 520D1534BE for ; Fri, 13 May 2005 18:22:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21341-09 for ; Fri, 13 May 2005 21:22:15 +0000 (GMT) Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) by svr1.postgresql.org (Postfix) with ESMTP id D252A53871 for ; Fri, 13 May 2005 18:22:13 -0300 (ADT) Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) by mx-2.sollentuna.net (Postfix) with ESMTP id 8DB198F28C; Fri, 13 May 2005 23:22:14 +0200 (CEST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Subject: Re: Whence the Opterons? Date: Fri, 13 May 2005 23:22:13 +0200 Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE6C74A9@algol.sollentuna.se> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Whence the Opterons? Thread-Index: AcVYAUoWHCzKE+LzTS25ARnOyKcurQAAEr3A From: "Magnus Hagander" To: "Andrew Sullivan" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/273 X-Sequence-Number: 12437 >> Question, though: is HP still using their proprietary RAID=20 >card? And, if so,=20 >> have they fixed its performance problems? > >According to my folks here, we're using the CCISS controllers, so I >guess they are. The systems are nevertheless performing very well -- >we did a load test that was pretty impressive. Also, Chris Browne >pointed me to this for the drivers: > >http://sourceforge.net/projects/cciss/ That driver is for all the remotely modern HP cards. I think the one with performance problems was the builtin one they user to have (SmartArray 5i). AFAIK, the new builtins (6i) are a lot better. And the high-end add-on cards I've never had any performance problems with - linux and windows both. //Magnus From pgsql-performance-owner@postgresql.org Fri May 13 19:05:45 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7DAC6533FE for ; Fri, 13 May 2005 19:05:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30791-04 for ; Fri, 13 May 2005 22:05:43 +0000 (GMT) Received: from dd01.profihoster.net (dd01.profihoster.net [80.86.168.71]) by svr1.postgresql.org (Postfix) with ESMTP id 9F030533F2 for ; Fri, 13 May 2005 19:05:41 -0300 (ADT) Received: from [192.168.54.3] (G07a1.g.pppool.de [80.185.7.161]) by dd01.profihoster.net (Postfix) with ESMTP id 046672383C3 for ; Sat, 14 May 2005 00:01:20 +0200 (CEST) Message-ID: <42852509.6060206@laliluna.de> Date: Sat, 14 May 2005 00:07:05 +0200 From: Sebastian Hennebrueder User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Optimize complex join to use where condition before References: <4283D985.4080908@laliluna.de> <428414DE.8030904@laliluna.de> In-Reply-To: <428414DE.8030904@laliluna.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/274 X-Sequence-Number: 12438 I found a solution to improve my query. I do not know why but the statistics for all column has been 0. I changed this to 10 for index columns and to 20 for all foreign key columns. and to 100 for foreign key columns. I set the random page cost to 2 and now the query runs as expected. Many thanks to all of the posts in my and in other threads which helped a lot. Sebastian "Merge Join (cost=1325.06..1329.96 rows=6 width=2558) (actual time=344.000..344.000 rows=6 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Sort (cost=1269.57..1271.91 rows=934 width=2541) (actual time=344.000..344.000 rows=773 loops=1)" " Sort Key: taufgaben.fid" " -> Merge Join (cost=1205.09..1223.49 rows=934 width=2541) (actual time=219.000..313.000 rows=936 loops=1)" " Merge Cond: ("outer".fid = "inner".fprojekt_id)" " -> Sort (cost=302.08..304.27 rows=876 width=1494) (actual time=156.000..156.000 rows=876 loops=1)" " Sort Key: tprojekte.fid" " -> Merge Join (cost=237.42..259.27 rows=876 width=1494) (actual time=109.000..141.000 rows=876 loops=1)" " Merge Cond: ("outer".fid = "inner".fprojektleiter_id)" " -> Index Scan using pk_tuser on tuser (cost=0.00..9.13 rows=109 width=883) (actual time=0.000..0.000 rows=101 loops=1)" " -> Sort (cost=237.42..239.61 rows=876 width=619) (actual time=109.000..109.000 rows=876 loops=1)" " Sort Key: tprojekte.fprojektleiter_id" " -> Merge Join (cost=181.17..194.60 rows=876 width=619) (actual time=63.000..94.000 rows=876 loops=1)" " Merge Cond: ("outer".fid = "inner".fkunden_kst_id)" " -> Sort (cost=9.51..9.66 rows=58 width=119) (actual time=0.000..0.000 rows=58 loops=1)" " Sort Key: tkunden_kst.fid" " -> Merge Join (cost=6.74..7.81 rows=58 width=119) (actual time=0.000..0.000 rows=58 loops=1)" " Merge Cond: ("outer".fid = "inner".fkunden_id)" " -> Sort (cost=3.46..3.56 rows=40 width=51) (actual time=0.000..0.000 rows=40 loops=1)" " Sort Key: tkunden.fid" " -> Seq Scan on tkunden (cost=0.00..2.40 rows=40 width=51) (actual time=0.000..0.000 rows=40 loops=1)" " -> Sort (cost=3.28..3.42 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " Sort Key: tkunden_kst.fkunden_id" " -> Seq Scan on tkunden_kst (cost=0.00..1.58 rows=58 width=80) (actual time=0.000..0.000 rows=58 loops=1)" " -> Sort (cost=171.66..173.85 rows=876 width=508) (actual time=63.000..63.000 rows=876 loops=1)" " Sort Key: tprojekte.fkunden_kst_id" " -> Merge Join (cost=114.91..128.85 rows=876 width=508) (actual time=31.000..47.000 rows=876 loops=1)" " Merge Cond: ("outer".fid = "inner".fkostentraeger_id)" " -> Sort (cost=19.20..19.60 rows=158 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostentraeger.fid" " -> Merge Join (cost=3.49..13.43 rows=158 width=162) (actual time=0.000..0.000 rows=158 loops=1)" " Merge Cond: ("outer".fkostenstellen_id = "inner".fid)" " -> Index Scan using idx_kostenstellen_id on tkostentraeger (cost=0.00..7.18 rows=158 width=55) (actual time=0.000..0.000 rows=158 loops=1)" " -> Sort (cost=3.49..3.53 rows=19 width=119) (actual time=0.000..0.000 rows=158 loops=1)" " Sort Key: tkostenstellen.fid" " -> Merge Join (cost=2.76..3.08 rows=19 width=119) (actual time=0.000..0.000 rows=19 loops=1)" " Merge Cond: ("outer".fid = "inner".fabteilungen_id)" " -> Sort (cost=1.17..1.19 rows=7 width=76) (actual time=0.000..0.000 rows=7 loops=1)" " Sort Key: tabteilungen.fid" " -> Seq Scan on tabteilungen (cost=0.00..1.07 rows=7 width=76) (actual time=0.000..0.000 rows=7 loops=1)" " -> Sort (cost=1.59..1.64 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " Sort Key: tkostenstellen.fabteilungen_id" " -> Seq Scan on tkostenstellen (cost=0.00..1.19 rows=19 width=55) (actual time=0.000..0.000 rows=19 loops=1)" " -> Sort (cost=95.71..97.90 rows=878 width=354) (actual time=31.000..31.000 rows=877 loops=1)" " Sort Key: tprojekte.fkostentraeger_id" " -> Seq Scan on tprojekte (cost=0.00..52.78 rows=878 width=354) (actual time=0.000..31.000 rows=878 loops=1)" " -> Sort (cost=903.01..905.35 rows=936 width=1047) (actual time=63.000..63.000 rows=936 loops=1)" " Sort Key: taufgaben.fprojekt_id" " -> Nested Loop Left Join (cost=0.28..856.82 rows=936 width=1047) (actual time=0.000..63.000 rows=936 loops=1)" " Join Filter: ("outer".fid = "inner".faufgaben_id)" " -> Index Scan using idx_taufgaben_bstatus on taufgaben (cost=0.00..835.47 rows=936 width=1043) (actual time=0.000..0.000 rows=936 loops=1)" " Index Cond: (fbearbeitungsstatus < 2)" " -> Materialize (cost=0.28..0.29 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=936)" " -> Subquery Scan patchdaten (cost=0.00..0.28 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1)" " -> Limit (cost=0.00..0.27 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1)" " -> Merge Join (cost=0.00..1706.77 rows=6340 width=4) (actual time=0.000..0.000 rows=1 loops=1)" " Merge Cond: ("outer".fid = "inner".faufgaben_id)" " -> Index Scan using idx_taufgaben_fid on taufgaben (cost=0.00..1440.61 rows=6070 width=8) (actual time=0.000..0.000 rows=1 loops=1)" " -> Index Scan using idx_aufpa_aufgabeid on taufgaben_patches (cost=0.00..171.74 rows=6340 width=4) (actual time=0.000..0.000 rows=1 loops=1)" " -> Sort (cost=55.49..55.57 rows=35 width=17) (actual time=0.000..0.000 rows=270 loops=1)" " Sort Key: am.faufgaben_id" " -> Index Scan using idx_tauf_mit_mitid on taufgaben_mitarbeiter am (cost=0.00..54.59 rows=35 width=17) (actual time=0.000..0.000 rows=270 loops=1)" " Index Cond: (fmitarbeiter_id = 58)" "Total runtime: 344.000 ms" From pgsql-performance-owner@postgresql.org Fri May 13 19:15:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 26006533AE for ; Fri, 13 May 2005 19:15:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32694-05 for ; Fri, 13 May 2005 22:15:39 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id B514A52A4D for ; Fri, 13 May 2005 19:15:37 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4DMFaSv018328; (envelope-from ) Fri, 13 May 2005 17:15:36 -0500 (CDT) Received: from [192.168.1.13] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4DMFJfK007910 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Fri, 13 May 2005 17:15:36 -0500 (CDT) Message-ID: <428526FD.7010208@arbash-meinel.com> Date: Fri, 13 May 2005 17:15:25 -0500 From: John Arbash Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sebastian Hennebrueder Cc: pgsql-performance@postgresql.org Subject: Re: Optimize complex join to use where condition before References: <4283D985.4080908@laliluna.de> <428414DE.8030904@laliluna.de> <42852509.6060206@laliluna.de> In-Reply-To: <42852509.6060206@laliluna.de> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig866AFF3AC4D1F6BC88DA2F6C" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/275 X-Sequence-Number: 12439 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig866AFF3AC4D1F6BC88DA2F6C Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Sebastian Hennebrueder wrote: > I found a solution to improve my query. I do not know why but the > statistics for all column has been 0. > I changed this to 10 for index columns and to 20 for all foreign key > columns. > and to 100 for foreign key columns. > I set the random page cost to 2 > and now the query runs as expected. > > Many thanks to all of the posts in my and in other threads which > helped a lot. > > Sebastian I think 0 = use default. But still, changing to 20 and 100 probably fixes your problems. John =:-> --------------enig866AFF3AC4D1F6BC88DA2F6C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFChSb9JdeBCYSNAAMRAsFyAKDU/neACCDvUBxrQEqdFPJ5bNvk8wCeO3WC QLyFSaGJK7DliPQoyzssnrw= =5Rei -----END PGP SIGNATURE----- --------------enig866AFF3AC4D1F6BC88DA2F6C-- From pgsql-performance-owner@postgresql.org Fri May 13 21:02:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D557F549FB for ; Fri, 13 May 2005 21:02:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51570-06 for ; Sat, 14 May 2005 00:02:20 +0000 (GMT) Received: from omta01sl.mx.bigpond.com (omta01sl.mx.bigpond.com [144.140.92.153]) by svr1.postgresql.org (Postfix) with ESMTP id DDE37549A3 for ; Fri, 13 May 2005 21:02:18 -0300 (ADT) Received: from [192.168.248.100] (really [203.45.204.25]) by omta01sl.mx.bigpond.com with ESMTP id <20050514000217.TAIE25106.omta01sl.mx.bigpond.com@[192.168.248.100]>; Sat, 14 May 2005 00:02:17 +0000 Message-ID: <4285403A.50206@bigpond.net.au> Date: Sat, 14 May 2005 10:03:06 +1000 From: David Brown User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joel Fradkin Cc: pgsql-performance@postgresql.org Subject: Re: ok you all win what is best opteron (I dont want a References: <009601c557f1$dd2f5a10$797ba8c0@jfradkin> In-Reply-To: <009601c557f1$dd2f5a10$797ba8c0@jfradkin> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.723 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS X-Spam-Level: X-Archive-Number: 200505/276 X-Sequence-Number: 12440 Joel Fradkin wrote: > Is the battery backed cache good or bad for Postgres? > Battery-backed avoids corruption if you have an unexpected power loss. It's considered mandatory with large-cache write-back controllers if you can't afford to lose any data. > They are telling me I can only get a duel channel card if I want > hardware raid 10 on the 14 drives. > > I can get two cards but it has to be 7 and 7 (software raid?) which > does not sound like it fixes my single point of failure (one of the > listers mentioned my current system has 3 such single points). > Sounds like you need to try another vendor. Are you aiming for two RAID 10 arrays or one RAID 10 and one RAID 5? > Any of you hardware gurus spell out the optimal machine (I am hoping > to be around 15K, might be able to go more if it�s a huge difference, > I spent 30k on the Dell). > > I do not have to go HP, and after seeing the fail ratio from Monarch > from one lister I am bit scared shopping there. > There's unlikely to be many common components between their workstation and server offerings. You would expect case, power, graphics, motherboard, storage controller and drives to all be different. But I'd challenge that 50% failure stat anyway. Which components exactly? Hard drives? Power supplies? > Was there a conclusion on where is best to get one (I really want two > one for development too). > Almost anyone can build a workstation or tower server, and almost anyone else can service it for you. It gets trickier when you're talking 2U and especially 1U. But really, these too can be maintained by anyone competent. So I wonder about some people's obsession with vendor-provided service. Realistically, most Opteron solutions will use a Tyan motherboard (no idea if this includes HP). For 4-way systems, there's currently only the S4882, which includes an LSI dual channel SCSI controller. Different vendors get to use different cases and cooling solutions and pick a different brand/model of hard drive, but that's about it. Tyan now also sells complete servers - hardly a stretch seeing they already make the most important bit (after the CPU). Given the level of interest in this forum, here's their list of US resellers: http://www.tyan.com/products/html/us_alwa.html If it's a tower server, build it yourself or pay someone to do it. It really isn't challenging for anyone knowledgeable about hardware. From pgsql-performance-owner@postgresql.org Fri May 13 21:17:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 78CC85294F for ; Fri, 13 May 2005 21:17:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51433-09 for ; Sat, 14 May 2005 00:17:04 +0000 (GMT) Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net [66.238.115.135]) by svr1.postgresql.org (Postfix) with ESMTP id 100DF54DF8 for ; Fri, 13 May 2005 21:17:03 -0300 (ADT) Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; Fri, 13 May 2005 17:20:17 -0700 Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with Microsoft SMTPSVC(6.0.3790.0); Fri, 13 May 2005 17:20:12 -0700 Received: from barracuda.tecarta.com ([192.168.160.200]) by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id M2005051317201216121 for ; Fri, 13 May 2005 17:20:12 -0700 X-ASG-Debug-ID: 1116029821-13093-4-0 X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi Received: from mail1 (mail1.hq.corp [192.168.160.5]) by barracuda.tecarta.com (Spam Firewall) with SMTP id 282432016CA7 for ; Fri, 13 May 2005 17:17:01 -0700 (PDT) Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 13 May 2005 17:20:11 -0700 Message-ID: <42854341.6030702@sfnet.cc> Date: Fri, 13 May 2005 17:16:01 -0700 From: Steve Poe User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org X-ASG-Orig-Subj: Postgresql Performance via the LSI MegaRAID 2x Card Subject: Postgresql Performance via the LSI MegaRAID 2x Card Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 14 May 2005 00:20:11.0243 (UTC) FILETIME=[B10843B0:01C5581A] X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=4.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_50 X-Barracuda-Spam-Report: Code version 3.02, rules version 3.0.981 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BAYES_50 BODY: Bayesian spam probability is 40 to 60% [score: 0.5076] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.167 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/277 X-Sequence-Number: 12441 Past recommendations for a good RAID card (for SCSI) have been the LSI MegaRAID 2x. This unit comes with 128MB of RAM on-board. Has anyone found by increasing the on-board RAM, did Postgresql performed better? Thanks. Steve Poe From pgsql-performance-owner@postgresql.org Fri May 13 21:27:25 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3769254C55 for ; Fri, 13 May 2005 21:27:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53227-06 for ; Sat, 14 May 2005 00:27:24 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id E8DEE549FA for ; Fri, 13 May 2005 21:27:23 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7360614; Fri, 13 May 2005 17:29:26 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Steve Poe Subject: Re: Postgresql Performance via the LSI MegaRAID 2x Card Date: Fri, 13 May 2005 17:28:46 -0700 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <42854341.6030702@sfnet.cc> In-Reply-To: <42854341.6030702@sfnet.cc> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505131728.46276.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/278 X-Sequence-Number: 12442 Steve, > Past recommendations for a good RAID card (for SCSI) have been the LSI > MegaRAID 2x. This unit comes with 128MB of RAM on-board. Has anyone > found by increasing the on-board RAM, did Postgresql performed better? My informal tests showed no difference between 64MB and 256MB. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat May 14 10:00:51 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1369B5331C for ; Sat, 14 May 2005 10:00:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73363-03 for ; Sat, 14 May 2005 13:00:50 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 287B452968 for ; Sat, 14 May 2005 10:00:48 -0300 (ADT) Received: (qmail 28660 invoked from network); 14 May 2005 15:01:13 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 14 May 2005 15:01:13 +0200 To: "Alex Turner" Cc: pgsql-performance@postgresql.org Subject: Re: Partitioning / Clustering References: <5F94B6EB-3925-4CD3-A67F-4310890B438A@advfn.com> <200505111013.52067.josh@agliodbs.com> <1115798277.29223.233869472@webmail.messagingengine.com> <33c6269f050512070842df1af3@mail.gmail.com> Message-ID: Date: Sat, 14 May 2005 15:00:47 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <200505111013.52067.josh@agliodbs.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/279 X-Sequence-Number: 12443 > If you make the assertion that you are transferring equal or less > session data between your session server (lets say an RDBMS) and the > app server than you are between the app server and the client, an out > of band 100Mb network for session information is plenty of bandwidth. So if you count on a mean page size of 6-8 kbytes gzipped, that will prevent you from caching the N first results of the Big Slow Search Query in a native object in the user session state (say, a list of integers indicating which rows match), so you will have to redo the Big Slow Search Query everytime the user clicks on Next Page instead of grabbing a set of cached row id's and doing a fast SELECT WHERE id IN ... This is the worst case ... I'd gzip() the row id's and stuff them in the session, that's always better than blowing up the database with the Big Slow Search Query everytime someone does Next Page... > This also represents OLTP style traffic, which postgresql is pretty > good at. You should easily be able to get over 100Tps. 100 hits per > second is an awful lot of traffic, more than any website I've managed > will ever see. On the latest anandtech benchmarks, 100 hits per second on a blog/forum software is a big bi-opteron server running dotNET, at 99% load... it's a lot if you count only dynamic page hits. From pgsql-performance-owner@postgresql.org Sat May 14 10:37:32 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6067B533F2 for ; Sat, 14 May 2005 10:37:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76403-06 for ; Sat, 14 May 2005 13:37:22 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id C91825373D for ; Sat, 14 May 2005 10:37:21 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id D7F3F15493; Sat, 14 May 2005 08:37:22 -0500 (CDT) Date: Sat, 14 May 2005 08:37:22 -0500 From: "Jim C. Nasby" To: Manfred Koizar Cc: Tom Lane , Dave Held , pgsql-performance@postgresql.org Subject: Re: Sort and index Message-ID: <20050514133722.GO49630@decibel.org> References: <19631.1113966086@sss.pgh.pa.us> <20050420034041.GC58835@decibel.org> <20050423015404.GV58835@decibel.org> <4269.1114222086@sss.pgh.pa.us> <20050423030002.GY58835@decibel.org> <6536.1114232440@sss.pgh.pa.us> <20050424220146.GN58835@decibel.org> <20050511211516.GX31103@decibel.org> <45678156iqld6sd5n63baovuvqj73palmr@email.aon.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45678156iqld6sd5n63baovuvqj73palmr@email.aon.at> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/280 X-Sequence-Number: 12444 On Thu, May 12, 2005 at 08:54:48PM +0200, Manfred Koizar wrote: > On Wed, 11 May 2005 16:15:16 -0500, "Jim C. Nasby" > wrote: > >> This is divided by the number of index columns, so the index correlation > >> is estimated to be 0.219. > > > >That seems like a pretty bad assumption to make. > > Any assumption we make without looking at entire index tuples has to be > bad. A new GUC variable secondary_correlation introduced by my patch at > least gives you a chance to manually control the effects of additional > index columns. It seems it would be much better to gather statistics on any multi-column indexes, but I know that's probably beyond what's reasonable for your patch. Also, my data (http://stats.distributed.net/~decibel) indicates that max_io isn't high enough. Look specifically at timing2.log compared to timing.log. Thouggh, it is possibile that this is because of having random_page_cost set to 1.1 (if I set it much higher I can't force the index scan because the index estimate actually exceeds the cost of the seqscan with the disable cost added in). > >It depends on the patches, since this is a production machine. Currently > >it's running 7.4.*mumble*, > > The patch referenced in > http://archives.postgresql.org/pgsql-hackers/2003-08/msg00931.php is > still available. It doesn't touch too many places and should be easy to > review. I'm using it and its predecessors in production for more than > two years. Let me know, if the 74b1 version does not apply cleanly to > your source tree. Looks reasonable; I'll give it a shot on 8.0 once I have replication happening. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Sat May 14 15:19:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E936D5353D for ; Sat, 14 May 2005 15:19:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28982-07 for ; Sat, 14 May 2005 18:19:00 +0000 (GMT) Received: from mta10.nationwireless.net (mta10.nationwireless.net [63.163.128.10]) by svr1.postgresql.org (Postfix) with ESMTP id E11C15340F for ; Sat, 14 May 2005 15:18:58 -0300 (ADT) Received: from jfradkin [63.162.100.127] by mta10.nationwireless.net with ESMTP (SMTPD-8.20) id A10F07B4; Sat, 14 May 2005 14:18:55 -0400 From: "Joel Fradkin" To: "'David Brown'" Cc: Subject: Re: ok you all win what is best opteron (I dont want a hosed system again) Date: Sat, 14 May 2005 14:19:20 -0400 Message-ID: <00e201c558b1$730ffb10$797ba8c0@jfradkin> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In-Reply-To: <4285403A.50206@bigpond.net.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.893 tagged_above=0 required=5 tests=AWL, MSGID_DOLLARS X-Spam-Level: * X-Archive-Number: 200505/281 X-Sequence-Number: 12445 Thank you much for the info. I will take a look. I think the prices I have been seeing may exclude us getting another 4 proc box this soon. My boss asked me to get something in the 15K range (I spent 30 on the Dell). The HP seemed to run around 30 but it had a lot more drives then the dell (speced it with 14 10k drives). I can and will most likely build it myself to try getting a bit more bang for the buck and it is a second server so if it dies it should not be a catastrophie. FYI everyone using our system (after a week of dealing with many bugs) have been saying how much they like the speed. I did have to do a lot of creative ideas to get it working in a way that appears faster to the client. Stuff like the queries default to limit 50 and as they hit next I up the limit (also a flag to just show all records and a count, it used to default to that). The two worst queries (our case and audit applications) I created denormalized files and maintain them through code. All reporting comes off those and it is lightning fast. I just want to say again thanks to everyone who has helped me in the past few months. Joel Fradkin Wazagua, Inc. 2520 Trailmate Dr Sarasota, Florida 34243 Tel. 941-753-7111 ext 305 jfradkin@wazagua.com www.wazagua.com Powered by Wazagua Providing you with the latest Web-based technology & advanced tools. C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc This email message is for the use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and delete and destroy all copies of the original message, including attachments. -----Original Message----- From: David Brown [mailto:time@bigpond.net.au] Sent: Friday, May 13, 2005 7:03 PM To: Joel Fradkin Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] ok you all win what is best opteron (I dont want a hosed system again) Joel Fradkin wrote: > Is the battery backed cache good or bad for Postgres? > Battery-backed avoids corruption if you have an unexpected power loss. It's considered mandatory with large-cache write-back controllers if you can't afford to lose any data. > They are telling me I can only get a duel channel card if I want > hardware raid 10 on the 14 drives. > > I can get two cards but it has to be 7 and 7 (software raid?) which > does not sound like it fixes my single point of failure (one of the > listers mentioned my current system has 3 such single points). > Sounds like you need to try another vendor. Are you aiming for two RAID 10 arrays or one RAID 10 and one RAID 5? > Any of you hardware gurus spell out the optimal machine (I am hoping > to be around 15K, might be able to go more if it's a huge difference, > I spent 30k on the Dell). > > I do not have to go HP, and after seeing the fail ratio from Monarch > from one lister I am bit scared shopping there. > There's unlikely to be many common components between their workstation and server offerings. You would expect case, power, graphics, motherboard, storage controller and drives to all be different. But I'd challenge that 50% failure stat anyway. Which components exactly? Hard drives? Power supplies? > Was there a conclusion on where is best to get one (I really want two > one for development too). > Almost anyone can build a workstation or tower server, and almost anyone else can service it for you. It gets trickier when you're talking 2U and especially 1U. But really, these too can be maintained by anyone competent. So I wonder about some people's obsession with vendor-provided service. Realistically, most Opteron solutions will use a Tyan motherboard (no idea if this includes HP). For 4-way systems, there's currently only the S4882, which includes an LSI dual channel SCSI controller. Different vendors get to use different cases and cooling solutions and pick a different brand/model of hard drive, but that's about it. Tyan now also sells complete servers - hardly a stretch seeing they already make the most important bit (after the CPU). Given the level of interest in this forum, here's their list of US resellers: http://www.tyan.com/products/html/us_alwa.html If it's a tower server, build it yourself or pay someone to do it. It really isn't challenging for anyone knowledgeable about hardware. From pgsql-performance-owner@postgresql.org Sat May 14 18:18:06 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F5535391E for ; Sat, 14 May 2005 18:18:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51848-09 for ; Sat, 14 May 2005 21:17:56 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 7DA5C53AC2 for ; Sat, 14 May 2005 18:17:53 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7363074; Sat, 14 May 2005 14:19:57 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Joel Fradkin" Subject: Re: ok you all win what is best opteron (I dont want a hosed system again) Date: Sat, 14 May 2005 14:19:15 -0700 User-Agent: KMail/1.7.1 Cc: "'David Brown'" , pgsql-performance@postgresql.org References: <00e201c558b1$730ffb10$797ba8c0@jfradkin> In-Reply-To: <00e201c558b1$730ffb10$797ba8c0@jfradkin> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505141419.15810.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/282 X-Sequence-Number: 12446 Joel, > The two worst queries (our case and audit applications) I created > denormalized files and maintain them through code. All reporting comes off > those and it is lightning fast. This can often be called for. I'm working on a 400GB data warehouse right now, and almost *all* of our queries run from materialized aggregate tables. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat May 14 19:16:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DC32752A62 for ; Sat, 14 May 2005 19:16:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61988-02 for ; Sat, 14 May 2005 22:16:48 +0000 (GMT) Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) by svr1.postgresql.org (Postfix) with ESMTP id 3802F52A3C for ; Sat, 14 May 2005 19:16:47 -0300 (ADT) Received: from gw.tssi.com (nolan@gw.tssi.com [127.0.0.1] (may be forged)) by gw.tssi.com (8.12.6/8.12.6) with ESMTP id j4EMGsZE021083; Sat, 14 May 2005 17:16:55 -0500 Received: (from nolan@localhost) by gw.tssi.com (8.12.6/8.12.6/Submit) id j4EMGqGU021081; Sat, 14 May 2005 17:16:52 -0500 From: Mike Nolan Message-Id: <200505142216.j4EMGqGU021081@gw.tssi.com> Subject: Re: ok you all win what is best opteron (I dont want a hosed system again) To: josh@agliodbs.com Date: Sat, 14 May 2005 17:16:52 -0500 (CDT) Cc: jfradkin@wazagua.com (Joel Fradkin), time@bigpond.net.au ('David Brown'), pgsql-performance@postgresql.org In-Reply-To: <200505141419.15810.josh@agliodbs.com> from "Josh Berkus" at May 14, 2005 02:19:15 PM X-Mailer: ELM [version 2.5 PL3] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/283 X-Sequence-Number: 12447 > This can often be called for. I'm working on a 400GB data warehouse right > now, and almost *all* of our queries run from materialized aggregate tables. I thought that was pretty much the definition of data warehousing! :-) -- Mike Nolan From pgsql-performance-owner@postgresql.org Sat May 14 21:44:03 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87E7C52A6F for ; Sat, 14 May 2005 21:44:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97564-03 for ; Sun, 15 May 2005 00:43:51 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0E98153AAF for ; Sat, 14 May 2005 21:43:50 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id B561B30952; Sun, 15 May 2005 02:41:24 +0200 (MET DST) From: William Yu X-Newsgroups: pgsql.performance Subject: Re: ok you all win what is best opteron (I dont want a hosed system Date: Sat, 14 May 2005 17:43:48 -0700 Organization: Hub.Org Networking Services Lines: 65 Message-ID: References: <4285403A.50206@bigpond.net.au> <00e201c558b1$730ffb10$797ba8c0@jfradkin> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en In-Reply-To: <00e201c558b1$730ffb10$797ba8c0@jfradkin> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/284 X-Sequence-Number: 12448 4-way SMP Opteron system is actually pretty damn cheap -- if you get 2xDual Core versus 4xSingle. I just ordered a 2x265 (4x1.8ghz) system and the price was about $1300 more than a 2x244 (2x1.8ghz). Now you might ask, is a 2xDC comparable to 4x1? Here's some benchmarks I've found that showing DC versus Single @ the same clock rates/same # cores. SpecIntRate Windows: 4x846 = 56.7 2x270 = 62.6 SpecFPRate Windows: 4x846 = 52.5 2x270 = 55.3 SpecWeb99SSL: 4x846 = 3399 2x270 = 4100 (2 870s were used) Specjbb2000 IBM JVM: 4x848 = 146385 4x275 = 157432 What it looks like is a DC system is about 1 clock blip faster than a corresponding single core SMP system. E.g. if you have a 2xDC @ 1.8ghz, you need a 4x1 @ 2ghz to match the speed. (In some benchmarks, the difference is 2 clock steps up.) On the surface, it looks pretty amazing that a 4x1 Opteron with twice the memory bandwidth is slower than a corresponding 2xDC. (DC Opterons use the same socket as plain jane Opterons so they use the same 2xDDR memory setup.) It turns out the latency in a 2xDC setup is just so much lower and most apps like lower latency than higher bandwidth. Look at the diagram of the following Tyan 4-processor MB: ftp://ftp.tyan.com/datasheets/d_s4882_100.pdf Take particular note of the lack of diagonal lines connecting CPUs. What this means is if a process running on CPU0 needs memory attached to CPU3, it must request either CPU1 or CPU2 to forward the request for it. Without NUMA support, we're looking at 25% of memory access runs @ 50ns, 50% 110ns, 25% 170ns. (Rough numbers, I'd have to do a lot of googling to the find the exact latencies but I'm just too lazy now.) Now consider a 2xDC system. The 2 cores inside a single package are connected by an immensely fast internal SRQ connection. As long as there's no bandwidth limitation, both cores have fullspeed access to memory while core-to-core snooping on each respective cache is roughly 10ns. So memory access speeds look like so: 50% 50ns, 50% 110ns. If the memory locations you are need to access happen to be contained in the L1/L2 cache, this makes the difference even more pronounced. You then get memory access patterns for 4x1: 25% 5ns, 50% 65ns, 25% 125ns versus 2xDC: 25% 5ns, 25% 15ns, 50% 65ns. Joel Fradkin wrote: > Thank you much for the info. > I will take a look. I think the prices I have been seeing may exclude us > getting another 4 proc box this soon. My boss asked me to get something in > the 15K range (I spent 30 on the Dell). > The HP seemed to run around 30 but it had a lot more drives then the dell > (speced it with 14 10k drives). From pgsql-benchmarks-owner@postgresql.org Tue May 17 13:35:42 2005 X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CCCEC535EB for ; Sun, 15 May 2005 06:37:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58591-03 for ; Sun, 15 May 2005 09:37:06 +0000 (GMT) Received: from web32011.mail.mud.yahoo.com (web32011.mail.mud.yahoo.com [68.142.207.108]) by svr1.postgresql.org (Postfix) with SMTP id 11645535E3 for ; Sun, 15 May 2005 06:37:05 -0300 (ADT) Received: (qmail 24007 invoked by uid 60001); 15 May 2005 09:37:07 -0000 Message-ID: <20050515093707.24005.qmail@web32011.mail.mud.yahoo.com> Received: from [61.94.212.103] by web32011.mail.mud.yahoo.com via HTTP; Sun, 15 May 2005 19:37:07 EST Date: Sun, 15 May 2005 19:37:07 +1000 (EST) From: Andre Nas Subject: Error when try installing pgbench ? To: pgsql-benchmarks@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-610318917-1116149827=:23911" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.375 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/1 X-Sequence-Number: 45 --0-610318917-1116149827=:23911 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello � Im using source postgresql 8.0.3 under FreeBSD and already install, the database is running well. I want to install a pgbench, but I can�t install it, coz an error occur. I try to �make all� in directory ~/src/interfaces/lipq/ The messages are : . . . . . . . . . . "../../../src/Makefile.global", line 546: Need an operator "../../../src/Makefile.global", line 553: Missing dependency operator "../../../src/Makefile.global", line 554: Missing dependency operator "/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 29: Need an operator "/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 31: Need an operator "/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 33: Need an operator "/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 38: Need an operator "/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 40: Need an operator Error expanding embedded variable. Any body can help me J Sorry Im newbie Thanks --------------------------------- Find local movie times and trailers on Yahoo! Movies. --0-610318917-1116149827=:23911 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit

Hello �

Im using source  postgresql 8.0.3 under FreeBSD and already install, the database is running well.

 

I want to install a pgbench, but I can�t install it, coz an error occur.

I try to �make all� in directory ~/src/interfaces/lipq/

The messages are :

. . . . .

. . . . .

"../../../src/Makefile.global", line 546: Need an operator

"../../../src/Makefile.global", line 553: Missing dependency operator

"../../../src/Makefile.global", line 554: Missing dependency operator

"/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 29: Need an operator

"/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 31: Need an operator

"/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 33: Need an operator

"/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 38: Need an operator

"/home/postgres/postgresql-8.0.3/src/nls-global.mk", line 40: Need an operator

Error expanding embedded variable.

 

Any body can help me J

Sorry Im newbie

Thanks

 



Find local movie times and trailers on Yahoo! Movies.
--0-610318917-1116149827=:23911-- From pgsql-performance-owner@postgresql.org Sun May 15 16:36:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 56C4B536BB for ; Sun, 15 May 2005 16:36:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69509-07 for ; Sun, 15 May 2005 19:36:17 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 4F07B5378A for ; Sun, 15 May 2005 16:36:16 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DXOuI-00083m-00; Sun, 15 May 2005 15:36:10 -0400 To: William Yu Cc: pgsql-performance@postgresql.org Subject: Re: ok you all win what is best opteron (I dont want a hosed system References: <4285403A.50206@bigpond.net.au> <00e201c558b1$730ffb10$797ba8c0@jfradkin> In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 15 May 2005 15:36:10 -0400 Message-ID: <871x8846z9.fsf@stark.xeocode.com> Lines: 16 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/289 X-Sequence-Number: 12453 William Yu writes: > It turns out the latency in a 2xDC setup is just so much lower and most apps > like lower latency than higher bandwidth. You haven't tested anything about "most apps". You tested what the SpecFoo apps prefer. If you're curious about which Postgres prefers you'll have to test with Postgres. I'm not sure whether it will change the conclusion but I expect Postgres will like bandwidth better than random benchmarks do. -- greg From pgsql-performance-owner@postgresql.org Sun May 15 17:40:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3B2E1534FC for ; Sun, 15 May 2005 17:39:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80322-05 for ; Sun, 15 May 2005 20:39:50 +0000 (GMT) Received: from primary.talisys.com (mail.talisys.com [129.250.133.62]) by svr1.postgresql.org (Postfix) with ESMTP id 2336952A3D for ; Sun, 15 May 2005 17:39:45 -0300 (ADT) Received: from mephisto.talisys.com ([172.17.36.209]) by primary.talisys.com with esmtp (Exim 4.30) id 1DXPtl-0003vs-R0; Sun, 15 May 2005 16:39:41 -0400 Message-ID: <4287B38B.506@talisys.com> Date: Sun, 15 May 2005 13:39:39 -0700 From: William Yu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Greg Stark Cc: pgsql-performance@postgresql.org Subject: Re: ok you all win what is best opteron (I dont want a References: <4285403A.50206@bigpond.net.au> <00e201c558b1$730ffb10$797ba8c0@jfradkin> <871x8846z9.fsf@stark.xeocode.com> In-Reply-To: <871x8846z9.fsf@stark.xeocode.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/290 X-Sequence-Number: 12454 I say most apps because it's true. :) I would suggest that pretty much every app (other than video/audio streaming) people think are bandwidth-limited are actually latency-limited. Take the SpecFoo tests. Sure I would have rather seen SAP/TPC/etc that would be more relevant to Postgres but there aren't any apples-to-apples comparisons available yet. But there's something to consider here. What people in the past have believed is that memory bandwidth is the key to Spec numbers -- SpecFP isn't a test of floating point performance, it's a test of memory bandwidth. Or is it? Numbers for DC Opterons show lower latency/lower bandwith beating higher latency/higher bandwidth in what was supposedly bandwidth limited. What may actually be happening is extra bandwidth isn't actually used directly by the app itself -- instead the CPU uses it for prefetching to hide latency. Scrounging around for more numbers, I've found benchmarks at Anandtech that relate better to Postgres. He has a "Order Entry" OLTP app running on MS-SQL. 1xDC beats 2x1 -- 2xDC beats 4x1. order entry reads 2x248 - 235113 1x175 - 257192 4x848 - 360014 2x275 - 392643 order entry writes 2x248 - 235107 1x175 - 257184 4x848 - 360008 2x275 - 392634 order entry stored procedures 2x248 - 2939 1x175 - 3215 4x848 - 4500 2x275 - 4908 Greg Stark wrote: >William Yu writes: > > > >>It turns out the latency in a 2xDC setup is just so much lower and most apps >>like lower latency than higher bandwidth. >> >> > >You haven't tested anything about "most apps". You tested what the SpecFoo >apps prefer. If you're curious about which Postgres prefers you'll have to >test with Postgres. > >I'm not sure whether it will change the conclusion but I expect Postgres will >like bandwidth better than random benchmarks do. > > > > From pgsql-performance-owner@postgresql.org Sun May 15 18:15:40 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88E61539C3 for ; Sun, 15 May 2005 18:15:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88981-04 for ; Sun, 15 May 2005 21:15:35 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id E21DA53761 for ; Sun, 15 May 2005 18:15:34 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 6884330952; Sun, 15 May 2005 23:13:05 +0200 (MET DST) From: William Yu X-Newsgroups: pgsql.performance Subject: Re: Postgresql Performance via the LSI MegaRAID 2x Card Date: Sun, 15 May 2005 14:15:28 -0700 Organization: Hub.Org Networking Services Lines: 17 Message-ID: References: <42854341.6030702@sfnet.cc> <200505131728.46276.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en In-Reply-To: <200505131728.46276.josh@agliodbs.com> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/291 X-Sequence-Number: 12455 I'm sure there's some corner case where more memory helps. If you consider that 1GB of RAM is about $100, I'd max out memory on the controller just for the hell of it. Josh Berkus wrote: > Steve, > > >>Past recommendations for a good RAID card (for SCSI) have been the LSI >>MegaRAID 2x. This unit comes with 128MB of RAM on-board. Has anyone >>found by increasing the on-board RAM, did Postgresql performed better? > > > My informal tests showed no difference between 64MB and 256MB. > From pgsql-performance-owner@postgresql.org Sun May 15 18:56:57 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 17A4B539BA for ; Sun, 15 May 2005 18:56:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95336-05 for ; Sun, 15 May 2005 21:56:51 +0000 (GMT) Received: from p0f.net (p0f.net [193.77.154.190]) by svr1.postgresql.org (Postfix) with ESMTP id ED55153985 for ; Sun, 15 May 2005 18:56:49 -0300 (ADT) Received: from [192.168.51.157] (aspirinix.p0f.net [192.168.51.157]) (authenticated bits=0) by p0f.net (8.13.3/8.13.3) with ESMTP id j4FLUcYA022464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 15 May 2005 23:30:40 +0200 Message-ID: <4287C5C7.3060301@p0f.net> Date: Sun, 15 May 2005 23:57:27 +0200 From: Grega Bremec Organization: P0F.NET User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Guillaume Nobiron Cc: pgsql-performance@postgresql.org Subject: Re: Swapping and Kernel 2.6 References: <001001c55560$58765aa0$72010180@Guillaumen> In-Reply-To: <001001c55560$58765aa0$72010180@Guillaumen> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.354 tagged_above=0 required=5 tests=AWL, RCVD_IN_NJABL_DUL X-Spam-Level: * X-Archive-Number: 200505/292 X-Sequence-Number: 12456 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Guillaume Nobiron wrote: | Hi, | | Environment : | - Fedora Core 2 (kernel 2.6.10) | - postgresql 7.4.7 | | I am running a huge query with several joins that needs around 900 | Mbytes of Memory (System RAM is 512 Mbytes). | | When the system starts to swap the postgres process, CPU consumed drops | to around 2% (instead of around 50% on another system with kernel 2.4). | The query was still working after more than 4 hours, spending the time | with 98% if IO wait. | | So I tried to run the postmaster with the environment variable | LD_ASSUME_KERNEL=2.4.1. With this, the query last 7 minutes !!! | | Why swapping is so bad with the new kernel ? | Hello, Guillaume. Your swapping issue may not necessarily have to do with bad, perhaps just slightly mistuned for your usage profile, virtual memory management. I think /proc/sys/vm/swappiness only appeared in the 2.6 series of kernels (or late in 2.4), but it has rather significant effect on the way kernel handles pages that are swapped out to disk, and most importantly, those that have been swapped back in again, yet still occupy the swap space - this new mechanism usually results in a certain amount of memory being reserved swap cache, which leaves less where it's more important to have it. You might want to read more about it in this (rather lengthy) kerneltrap articles: http://kerneltrap.org/node/3000 and http://kerneltrap.org/node/3828 What we'd probably need here though (after you've verified playing with swappiness doesn't help), is a couple of minutes worth of typical memory manager behaviour while this transaction of yours is taking place, especially where swapin/swapout goes mad. Try running "vmstat 5" while it's running and see if there are any interesting patterns, also, be sure to include enough context before and after such events (up to half a minute on each side should do). My guess is, you'd do well with an extra gigabyte or so of memory - 512MB really isn't much nowadays. Why make I/O even worse bottleneck than it needs to be by forcing pages of active memory in and out? :) Kind regards, - -- ~ Grega Bremec ~ gregab at p0f dot net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFCh8XHfu4IwuB3+XoRAicxAJwI0FzZIpXpxlJlZMXVJUJaqdj0EgCfRNuw Dr58jtIgHDtjq/LCjd2Kr1s= =iLle -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Sun May 15 21:22:20 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 53AF5533A3 for ; Sun, 15 May 2005 21:22:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22983-07 for ; Mon, 16 May 2005 00:22:14 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 9F0D253392 for ; Sun, 15 May 2005 21:22:12 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C559AD.4EC25CB9" Subject: checkpoint segments Date: Sun, 15 May 2005 20:22:13 -0400 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: checkpoint segments Thread-Index: AcVZrU7ieHAuncliQ1m8/DK7hCdaZA== From: "David Parker" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.174 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_40_50, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/293 X-Sequence-Number: 12457 This is a multi-part message in MIME format. ------_=_NextPart_001_01C559AD.4EC25CB9 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I was recently running a test with multiple client shell processes running psql commands (inserts) when all the client processes appeared to hang simultaneously. I assumed that I had an application deadlock somewhere, but after a few seconds - less than a minute, but certainly noticeable - all the clients picked up again and went on their way. =20 In the database log at that time there was a "recycling transaction log" message which seems to correspond to the time when the clients were paused, though I don't have it concretely correlated.=20 =20 I've seen these messages in the log before, and am aware of the need to increase checkpoint_segments, but I wasn't aware that recycling a transaction log could be that damaging to performance. There may have been some local hiccup in this case, but I'm wondering if recycling is known to be a big hit in general, and if I should strive to tune so that it never happens (if that's possible)? =20 Thanks. - DAP ------------------------------------------------------------------------ ---------- David Parker Tazz Networks (401) 709-5130 =20 =20 ------_=_NextPart_001_01C559AD.4EC25CB9 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
I was = recently=20 running a test with multiple client shell processes running psql = commands=20 (inserts) when all the client processes appeared to hang simultaneously. = I=20 assumed that I had an application deadlock somewhere, but after a few = seconds -=20 less than a minute, but certainly noticeable - all the clients picked up = again=20 and went on their way.
 
In the = database log=20 at that time there was a "recycling transaction log" message which = seems to=20 correspond to the time when the clients were paused, though I don't have = it=20 concretely correlated.
 
I've = seen these=20 messages in the log before, and am aware of the need to increase=20 checkpoint_segments, but I wasn't aware that recycling a transaction log = could=20 be that damaging to performance. There may have been some local hiccup = in this=20 case, but I'm wondering if recycling is known to be a big hit in = general, and if=20 I should strive to tune so that it never happens (if that's=20 possible)?
 
Thanks.

-=20 DAP
------------------------------------------------------------------= ----------------
David=20 Parker    Tazz Networks    (401)=20 709-5130
 

 
------_=_NextPart_001_01C559AD.4EC25CB9-- From pgsql-performance-owner@postgresql.org Sun May 15 23:26:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 514B852A6F for ; Sun, 15 May 2005 23:26:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50223-01 for ; Mon, 16 May 2005 02:26:17 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id 4B49652A3D for ; Sun, 15 May 2005 23:26:16 -0300 (ADT) Received: from ool-44c11fd8.dyn.optonline.net ([68.193.31.216] helo=[192.168.1.66]) by outbound.mailhop.org with esmtpa (Exim 4.51) id 1DXVJ9-000Kat-2h; Sun, 15 May 2005 22:26:15 -0400 Message-ID: <428804EA.6080609@zeut.net> Date: Sun, 15 May 2005 22:26:50 -0400 From: "Matthew T. O'Connor" User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mindaugas Riauba Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: PostgreSQL strugling during high load References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> In-Reply-To: <022901c557c5$73df1220$f20214ac@bite.lt> Content-Type: text/plain; charset=windows-1257; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 68.193.31.216 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/294 X-Sequence-Number: 12458 Mindaugas Riauba wrote: >>The "vacuum cost" parameters can be adjusted to make vacuums fired >>by pg_autovacuum less of a burden. I haven't got any specific numbers >>to suggest, but perhaps someone else does. >> >> > > It looks like that not only vacuum causes our problems. vacuum_cost >seems to lower vacuum impact but we are still noticing slow queries "storm". >We are logging queries that takes >2000ms to process. > And there is quiet periods and then suddenly 30+ slow queries appears in >log within the same second. What else could cause such behaviour? WAL log >switch? One WAL file seems to last <1 minute. > > How long are these quite periods? Do the "strom" periods correspond to pg_autovacuum loops? I have heard from one person who had LOTS of databases and tables that caused the pg_autovacuum to create a noticable load just updateing all its stats. The solution in that case was to add a small delay insidet the inner pg_autovacuum loop. From pgsql-performance-owner@postgresql.org Sun May 15 23:45:56 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E7FE253833 for ; Sun, 15 May 2005 23:45:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51763-07 for ; Mon, 16 May 2005 02:45:53 +0000 (GMT) Received: from window.monsterlabs.com (window.monsterlabs.com [216.183.105.176]) by svr1.postgresql.org (Postfix) with SMTP id 72B9353A6C for ; Sun, 15 May 2005 23:45:52 -0300 (ADT) Received: (qmail 6031 invoked from network); 16 May 2005 02:45:56 -0000 Received: from host-209.149.56.238.nashville.net (HELO ?10.0.1.2?) (209.149.56.238) by 0 with SMTP; 16 May 2005 02:45:56 -0000 In-Reply-To: <428804EA.6080609@zeut.net> References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> <428804EA.6080609@zeut.net> Mime-Version: 1.0 (Apple Message framework v728) Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed Message-Id: Cc: Mindaugas Riauba , Tom Lane , pgsql-performance@postgresql.org Content-Transfer-Encoding: quoted-printable From: "Thomas F. O'Connell" Subject: Re: PostgreSQL strugling during high load Date: Sun, 15 May 2005 21:45:54 -0500 To: "Matthew T. O'Connor" X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/295 X-Sequence-Number: 12459 Actually, that solution didn't work so well. Even very small delays =20 in the loop caused the entire loop to perform too slowly to be useful =20= in the production environment. I ended up producing a small patch out =20= of it :P, but we ended up using pgpool to reduce connections from =20 another part of the app, which made the pg_autovacuum spikes less =20 troublesome overall. -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i=99 http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On May 15, 2005, at 9:26 PM, Matthew T. O'Connor wrote: > Mindaugas Riauba wrote: > > >>> The "vacuum cost" parameters can be adjusted to make vacuums fired >>> by pg_autovacuum less of a burden. I haven't got any specific =20 >>> numbers >>> to suggest, but perhaps someone else does. >>> >>> >> >> It looks like that not only vacuum causes our problems. vacuum_cost >> seems to lower vacuum impact but we are still noticing slow =20 >> queries "storm". >> We are logging queries that takes >2000ms to process. >> And there is quiet periods and then suddenly 30+ slow queries =20 >> appears in >> log within the same second. What else could cause such behaviour? =20 >> WAL log >> switch? One WAL file seems to last <1 minute. >> >> > > How long are these quite periods? Do the "strom" periods =20 > correspond to pg_autovacuum loops? I have heard from one person =20 > who had LOTS of databases and tables that caused the pg_autovacuum =20 > to create a noticable load just updateing all its stats. The =20 > solution in that case was to add a small delay insidet the inner =20 > pg_autovacuum loop. From pgsql-performance-owner@postgresql.org Mon May 16 00:26:11 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E64B5294F for ; Mon, 16 May 2005 00:26:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70176-04 for ; Mon, 16 May 2005 03:26:01 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id EA5485294E for ; Mon, 16 May 2005 00:26:00 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7366870; Sun, 15 May 2005 20:27:59 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: "David Parker" Subject: Re: checkpoint segments Date: Sun, 15 May 2005 20:26:02 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505152026.02262.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/296 X-Sequence-Number: 12460 David, > I've seen these messages in the log before, and am aware of the need to > increase checkpoint_segments, but I wasn't aware that recycling a > transaction log could be that damaging to performance. There may have > been some local hiccup in this case, but I'm wondering if recycling is > known to be a big hit in general, and if I should strive to tune so that > it never happens (if that's possible)? Yes, and yes. Simply allocating more checkpoint segments (which can eat a lot of disk space -- requirements are 16mb*(2 * segments +1) ) will prevent this problem. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon May 16 00:27:32 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4C82D52955 for ; Mon, 16 May 2005 00:27:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70473-07 for ; Mon, 16 May 2005 03:27:22 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 840F952A43 for ; Mon, 16 May 2005 00:27:22 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7366878; Sun, 15 May 2005 20:29:22 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: William Yu Subject: Re: Postgresql Performance via the LSI MegaRAID 2x Card Date: Sun, 15 May 2005 20:27:24 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <42854341.6030702@sfnet.cc> <200505131728.46276.josh@agliodbs.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505152027.24945.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/297 X-Sequence-Number: 12461 William, > I'm sure there's some corner case where more memory helps. QUite possibly. These were not scientific tests. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon May 16 01:34:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E9EE5533AD for ; Mon, 16 May 2005 01:34:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03976-04 for ; Mon, 16 May 2005 04:34:22 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7BFB8533AB for ; Mon, 16 May 2005 01:34:21 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4G4YL8K008843; Mon, 16 May 2005 00:34:21 -0400 (EDT) To: "David Parker" Cc: pgsql-performance@postgresql.org Subject: Re: checkpoint segments In-reply-to: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> References: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> Comments: In-reply-to "David Parker" message dated "Sun, 15 May 2005 20:22:13 -0400" Date: Mon, 16 May 2005 00:34:21 -0400 Message-ID: <8842.1116218061@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/298 X-Sequence-Number: 12462 "David Parker" writes: > I was recently running a test with multiple client shell processes > running psql commands (inserts) when all the client processes appeared > to hang simultaneously. I assumed that I had an application deadlock > somewhere, but after a few seconds - less than a minute, but certainly > noticeable - all the clients picked up again and went on their way. > > In the database log at that time there was a "recycling transaction log" > message which seems to correspond to the time when the clients were > paused, though I don't have it concretely correlated. I think what you saw was the disk being hogged by checkpoint writes. "Recycling transaction log" is a routine operation, and by itself is a reasonably cheap operation, but it's only done as the last step in a checkpoint (in fact, from a technical point of view, it's done after the checkpoint finishes). My guess is that the actual performance hit occurred while the checkpoint was pushing out dirty buffers. What you want is to reduce the amount of deferred I/O that has to happen when a checkpoint occurs. There is not any way to do that before PG 8.0 (the obvious idea of reducing the interval between checkpoints is counterproductive, IMHO). In 8.0 you can fool around with the bgwriter parameters with an eye to "dribbling out" writes of dirty pages between checkpoints. regards, tom lane From pgsql-performance-owner@postgresql.org Mon May 16 01:39:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 417895337B for ; Mon, 16 May 2005 01:39:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01479-09 for ; Mon, 16 May 2005 04:39:15 +0000 (GMT) Received: from mr2.surnet.cl (smtp2.surnet.cl [216.155.73.163]) by svr1.postgresql.org (Postfix) with ESMTP id B16E653323 for ; Mon, 16 May 2005 01:39:14 -0300 (ADT) Received: from smtp2.surnet.cl (216.155.73.169) by mr2.surnet.cl (7.0.031.3) id 4259ADFA007A66DE; Mon, 16 May 2005 00:39:49 -0400 Received: from smtp1.surnet.cl (smtp1.surnet.cl []) by mr2.surnet.cl ([216.155.73.169]); Mon, 16 May 2005 04:39:48 +0000 Received: from cluster.surnet.cl (216.155.73.164) by smtp1.surnet.cl (7.0.031.3) id 42587C6E00648D5B; Mon, 16 May 2005 00:38:44 -0400 Received: from localhost (200.85.219.173) by cluster.surnet.cl (7.0.024) id 4276578F001DF245; Mon, 16 May 2005 00:39:13 -0400 Received: by localhost (Postfix, from userid 1000) id 8C0FEC32DDE; Mon, 16 May 2005 00:39:20 -0400 (CLT) Date: Mon, 16 May 2005 00:39:20 -0400 From: Alvaro Herrera To: David Parker Cc: pgsql-performance@postgresql.org Subject: Re: checkpoint segments Message-ID: <20050516043920.GA9292@surnet.cl> References: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=3.233 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_NJABL_PROXY X-Spam-Level: *** X-Archive-Number: 200505/299 X-Sequence-Number: 12463 On Sun, May 15, 2005 at 08:22:13PM -0400, David Parker wrote: > In the database log at that time there was a "recycling transaction log" > message which seems to correspond to the time when the clients were > paused, though I don't have it concretely correlated. Maybe what you need is make the bgwriter more aggressive, so that I/O is more evenly spread between checkpoint intervals -- that way, at checkpoint there's less work to do. > I've seen these messages in the log before, and am aware of the need to > increase checkpoint_segments, but I wasn't aware that recycling a > transaction log could be that damaging to performance. There may have > been some local hiccup in this case, but I'm wondering if recycling is > known to be a big hit in general, and if I should strive to tune so that > it never happens (if that's possible)? Well, recycling is actually a *good* thing -- it saves you from having to remove WAL segment files and allocate new files for the new logs. So what you really want doesn't have anything to do with the recycling itself, but rather with the simultaneous checkpoint that's going on at the same time. -- Alvaro Herrera () Licensee shall have no right to use the Licensed Software for productive or commercial use. (Licencia de StarOffice 6.0 beta) From pgsql-performance-owner@postgresql.org Mon May 16 01:41:00 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 63928533B2 for ; Mon, 16 May 2005 01:40:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08519-01 for ; Mon, 16 May 2005 04:40:49 +0000 (GMT) Received: from mr2.surnet.cl (smtp2.surnet.cl [216.155.73.163]) by svr1.postgresql.org (Postfix) with ESMTP id 54981533AB for ; Mon, 16 May 2005 01:40:49 -0300 (ADT) Received: from smtp2.surnet.cl (216.155.73.169) by mr2.surnet.cl (7.0.031.3) id 4259ADFA007A6764; Mon, 16 May 2005 00:41:22 -0400 Received: from smtp2.surnet.cl (mr2.surnet.cl []) by mr2.surnet.cl ([216.155.73.169]); Mon, 16 May 2005 04:41:22 +0000 Received: from cluster.surnet.cl (216.155.73.164) by smtp2.surnet.cl (7.0.031.3) id 4259ADE3004A387B; Mon, 16 May 2005 00:41:21 -0400 Received: from localhost (200.85.219.173) by cluster.surnet.cl (7.0.024) id 4276578F001DF284; Mon, 16 May 2005 00:40:46 -0400 Received: by localhost (Postfix, from userid 1000) id A508AC32DDE; Mon, 16 May 2005 00:40:53 -0400 (CLT) Date: Mon, 16 May 2005 00:40:53 -0400 From: Alvaro Herrera To: Josh Berkus Cc: David Parker , pgsql-performance@postgresql.org Subject: Re: checkpoint segments Message-ID: <20050516044053.GB9292@surnet.cl> References: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> <200505152026.02262.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200505152026.02262.josh@agliodbs.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=3.25 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_NJABL_PROXY X-Spam-Level: *** X-Archive-Number: 200505/300 X-Sequence-Number: 12464 On Sun, May 15, 2005 at 08:26:02PM -0700, Josh Berkus wrote: > David, > > > I've seen these messages in the log before, and am aware of the need to > > increase checkpoint_segments, but I wasn't aware that recycling a > > transaction log could be that damaging to performance. There may have > > been some local hiccup in this case, but I'm wondering if recycling is > > known to be a big hit in general, and if I should strive to tune so that > > it never happens (if that's possible)? > > Yes, and yes. Simply allocating more checkpoint segments (which can eat a > lot of disk space -- requirements are 16mb*(2 * segments +1) ) will prevent > this problem. Hmm? I disagree -- it will only make things worse when the checkpoint does occur. -- Alvaro Herrera () "Lo esencial es invisible para los ojos" (A. de Saint Ex�pery) From pgsql-performance-owner@postgresql.org Mon May 16 07:05:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1222853238 for ; Mon, 16 May 2005 07:05:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65066-01 for ; Mon, 16 May 2005 10:05:06 +0000 (GMT) Received: from ns1.bi.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 9419452A62 for ; Mon, 16 May 2005 07:05:03 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bi.lt (8.12.11/8.12.11) with SMTP id j4GA54qY027498; Mon, 16 May 2005 13:05:04 +0300 Message-ID: <025401c559fe$bb852e80$f20214ac@bite.lt> From: "Mindaugas Riauba" To: "Tom Lane" Cc: "Cosimo Streppone" , References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> <4284C661.4050406@streppone.it> <02f901c557d2$43517e10$f20214ac@bite.lt> <24733.1116002564@sss.pgh.pa.us> Subject: Re: PostgreSQL strugling during high load Date: Mon, 16 May 2005 13:05:04 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.181 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/301 X-Sequence-Number: 12465 > > Hm. Yes. Number of locks varies quite alot (10-600). Now what to > > investigate > > further? We do not use explicit locks in our functions. We use quite simple > > update/delete where key=something; > > Some sample (select * from pg_locks order by pid) is below. > > The sample doesn't show any lock issues (there are no processes waiting > for ungranted locks). The thing that typically burns people is foreign > key conflicts. In current releases, if you have a foreign key reference > then an insert in the referencing table takes an exclusive row lock on > the referenced (master) row --- which means that two inserts using the > same foreign key value block each other. > > You can alleviate the issue by making all your foreign key checks > deferred, but that just shortens the period of time the lock is held. > There will be a real solution in PG 8.1, which has sharable row locks. In such case our foreign key contraint should not be an issue since it is on msg_id which is pretty much unique among concurrent transactions. And I noticed that "storms" happens along with higher write activity. If bo in vmstat shows 25+MB in 2s then most likely I will get "storm" of slow queries in serverlog. How to even write activity? fsync=off, bgwriter settings are default. And is it possible to log which query in function takes the longest time to complete? Also do not know if it matters but PG database is on ext3 partition with data=journal option. Thanks, Mindaugas From pgsql-performance-owner@postgresql.org Mon May 16 14:41:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A61565280F for ; Mon, 16 May 2005 14:38:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07072-10 for ; Mon, 16 May 2005 17:38:46 +0000 (GMT) Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id E1E9552883 for ; Mon, 16 May 2005 14:38:15 -0300 (ADT) Received: from mta10.nationwireless.net (mta10.nationwireless.net [63.163.128.10]) by svr2.postgresql.org (Postfix) with ESMTP id E21C2F0DF3 for ; Mon, 16 May 2005 15:21:03 +0100 (BST) Received: from jfradkin [63.162.100.127] by mta10.nationwireless.net with ESMTP (SMTPD-8.20) id A5B006E4; Mon, 16 May 2005 08:44:32 -0400 From: "Joel Fradkin" To: , Subject: Re: Prefetch Date: Mon, 16 May 2005 08:45:01 -0400 Message-ID: <001301c55a15$13647190$797ba8c0@jfradkin> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable In-Reply-To: <200505091910.26407.molson@oceanconsulting.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.913 tagged_above=0 required=5 tests=AWL, MSGID_DOLLARS X-Spam-Level: * X-Archive-Number: 200505/303 X-Sequence-Number: 12467 My only comment is what is the layout of your data (just one table with indexes?). I found on my date with dozens of joins my view speed was not good for = me to use, so I made a flat file with no joins and it flies. Joel Fradkin =20 Wazagua, Inc. 2520 Trailmate Dr Sarasota, Florida 34243 Tel. 941-753-7111 ext 305 =20 jfradkin@wazagua.com www.wazagua.com Powered by Wazagua Providing you with the latest Web-based technology & advanced tools. C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc This email message is for the use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized = review, use, disclosure or distribution is prohibited. If you are not the = intended recipient, please contact the sender by reply email and delete and = destroy all copies of the original message, including attachments. =20 =20 -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Matt Olson Sent: Monday, May 09, 2005 9:10 PM To: pgsql-performance@postgresql.org Subject: [PERFORM] Prefetch I wanted to get some opinions about row prefetching. AFAIK, there is no = prefetching done by PostgreSQL; all prefetching is delegated to the operating=20 system. =20 The hardware (can't say enough good things about it): Athlon 64, dual channel 4GB ram 240GB usable 4 disk raid5 (ATA133) Fedora Core 3 PostgreSQL 7.4.7 I have what is essentially a data warehouse of stock data. Each day has = around 30,000 records (tickers). A typical operation is to get the 200 = day=20 simple moving average (of price) for each ticker and write the result to = a=20 summary table. In running this process (Perl/DBI), it is typical to see = 70-80% I/O wait time with postgres running a about 8-9%. If I run the = next day's date, the postgres cache and file cache is now populated with 199 = days of the needed data, postgres runs 80-90% of CPU and total run time is greatly=20 reduced. My conclusion is that this is a high cache hit rate in action. = =20 I've done other things that make sense, like using indexes, playing with = the planner constants and turning up the postgres cache buffers. =20 Even playing with extream hdparm read-ahead numbers (i.e. 64738), there = is no=20 apparent difference in database performance. The random nature of the = I/O=20 drops disk reads down to about 1MB/sec for the array. A linear table = scan=20 can easily yield 70-80MB/sec on this system. Total table size is = usually=20 around 1GB and with indexes should be able to fit completely in main = memory. Other databases like Oracle and DB2 implement some sort of row prefetch. Has=20 there been serious consideration of implementing something like a = prefetch=20 subsystem? Does anyone have any opinions as to why this would be a bad = idea for postgres? =20 Postges is great for a multiuser environment and OLTP applications. However,=20 in this set up, a data warehouse, the observed performance is not what I = would hope for. =20 Regards, Matt Olson Ocean Consulting http://www.oceanconsulting.com/ ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Tue May 17 13:55:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ACE7F528FF for ; Mon, 16 May 2005 16:35:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25932-06 for ; Mon, 16 May 2005 19:35:09 +0000 (GMT) Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id C686E52934 for ; Mon, 16 May 2005 16:34:54 -0300 (ADT) Received: from exchange.ticinocom.com (exchange.ticinocom.com [195.190.166.70]) by svr2.postgresql.org (Postfix) with ESMTP id BEA90F0CB0 for ; Mon, 16 May 2005 14:06:47 +0100 (BST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Subject: Trigger performance problem Date: Mon, 16 May 2005 15:06:49 +0200 Message-ID: <5A838EC3CE99804991EF9D37875C5A6F3343@exchange.ticinocom.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Trigger performance problem Thread-Index: AcVaGJV/pm5upb3FTFa0emtDyjHiGQ== From: "Manuel Wenger" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.376 tagged_above=0 required=5 tests=DNS_FROM_RFC_POST X-Spam-Level: * X-Archive-Number: 200505/305 X-Sequence-Number: 12469 We're having a performance problem with PostgresQL 8.0.2 running on RHEL3 Update 4. There is a frequently updated table logging all our ADSL customer logins which has 2 related triggers. An INSERT on that table, "calls", takes about 300ms to execute according to the logs, and the process takes up to 30% of the server CPU. When removing the triggers it drops to 10-20ms. I am posting the table structure of all the tables involved, the triggers and the indexes. This also happens when the "calls" table is empty. The "currentip" and "basicbytes" tables contain about 8000 records each. The "newest" table is always being emptied by a cron process. I am vacuuming the database daily. I really don't understand what I am missing here - what else can be optimized or indexed? Is it normal that the INSERT is taking so long? We're running PostgreSQL on a pretty fast server, so it's not a problem of old/slow hardware either. As you can see, this is pretty basic stuff when compared to what others are doing, so it shouldn't cause such an issue. Apparently I'm really missing something here... :-) Thank you everyone for your help -Manuel CREATE TABLE calls ( nasidentifier varchar(16) NOT NULL, nasport int4 NOT NULL, acctsessionid varchar(10) NOT NULL, acctstatustype int2 NOT NULL, username varchar(32) NOT NULL, acctdelaytime int4, acctsessiontime int4, framedaddress varchar(16), acctterminatecause int2, accountid int4, serverid int4, callerid varchar(15), connectinfo varchar(32), acctinputoctets int4, acctoutputoctets int4, ascendfilter varchar(50), ascendtelnetprofile varchar(15), framedprotocol int2, acctauthentic int2, ciscoavpair varchar(50), userservice int2, "class" varchar(15), nasportdnis varchar(255), nasporttype int2, cisconasport varchar(50), acctinputpackets int4, acctoutputpackets int4, calldate timestamp )=20 CREATE INDEX i_ip ON calls USING btree (framedaddress); CREATE INDEX i_username ON calls USING btree (username); CREATE TRIGGER trigger_update_bytes AFTER INSERT ON calls FOR EACH ROW EXECUTE PROCEDURE update_basic_bytes(); CREATE OR REPLACE FUNCTION update_basic_bytes() RETURNS "trigger" AS $BODY$ begin if (new.acctstatustype=3D2) then if exists(select username from basicbytes where username=3Dnew.username) then update basicbytes set inbytes=3Dinbytes+new.acctinputoctets, outbytes=3Doutbytes+new.acctoutputoctets, lastupdate=3Dnew.calldate = where username=3Dnew.username; else insert into basicbytes (username,inbytes,outbytes,lastupdate) values (new.username,new.acctinputoctets,new.acctoutputoctets,new.calldate); end if; end if; return null; end $BODY$ LANGUAGE 'plpgsql' VOLATILE; CREATE TRIGGER trigger_update_ip AFTER INSERT ON calls FOR EACH ROW EXECUTE PROCEDURE update_ip(); CREATE OR REPLACE FUNCTION update_ip() RETURNS "trigger" AS $BODY$ begin delete from currentip where ip is null; delete from currentip where ip=3Dnew.framedaddress; if (new.acctstatustype=3D1) then delete from currentip where username=3Dnew.username; delete from newest where username=3Dnew.username; insert into currentip (ip,username) values (new.framedaddress,new.username); insert into newest (ip,username) values (new.framedaddress,new.username); end if; return null; end; $BODY$ LANGUAGE 'plpgsql' VOLATILE; CREATE TABLE basicbytes ( username varchar(32) NOT NULL, inbytes int8, outbytes int8, lastupdate timestamp, lastreset timestamp )=20 CREATE INDEX i_basic_username ON basicbytes USING btree (username); CREATE TABLE currentip ( ip varchar(50), username varchar(50) )=20 CREATE INDEX i_currentip_username ON currentip USING btree (username); CREATE TABLE newest ( ip varchar(50), username varchar(50) )=20 CREATE INDEX i_newest_username ON newest USING btree (username); From pgsql-performance-owner@postgresql.org Mon May 16 13:19:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2B5C529D1 for ; Mon, 16 May 2005 13:18:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37113-09 for ; Mon, 16 May 2005 16:18:11 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 5CE9252E31 for ; Mon, 16 May 2005 13:17:21 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7368714 for pgsql-performance@postgresql.org; Mon, 16 May 2005 09:19:19 -0700 From: Josh Berkus Organization: Aglio Database Solutions Subject: Re: checkpoint segments Date: Mon, 16 May 2005 09:17:20 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <07FDEE0ED7455A48AC42AC2070EDFF7C74609A@corpsrv2.tazznetworks.com> <200505152026.02262.josh@agliodbs.com> <20050516044053.GB9292@surnet.cl> In-Reply-To: <20050516044053.GB9292@surnet.cl> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline To: Undisclosed.Recipients: ; Message-Id: <200505160917.20367.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/302 X-Sequence-Number: 12466 Alvaro, > > Yes, and yes. Simply allocating more checkpoint segments (which can eat > > a lot of disk space -- requirements are 16mb*(2 * segments +1) ) will > > prevent this problem. > > Hmm? I disagree -- it will only make things worse when the checkpoint > does occur. Unless you allocate enough logs that you don't need to checkpoint until the load is over with. In multiple data tests involving large quantities of data loading, increasing the number of checkpoints and the checkpoint interval has been an overall benefit to overall load speed. It's possible that the checkpoints which do occur are worse, but they're not enough worse to counterbalance their infrequency. I have not yet been able to do a full scalability series on bgwriter. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue May 17 14:47:36 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC8CE52803 for ; Tue, 17 May 2005 14:47:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50561-10 for ; Tue, 17 May 2005 17:47:24 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9041152813 for ; Tue, 17 May 2005 14:47:23 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4HHlOd7000707; Tue, 17 May 2005 13:47:24 -0400 (EDT) To: "Manuel Wenger" Cc: pgsql-performance@postgresql.org Subject: Re: Trigger performance problem In-reply-to: <5A838EC3CE99804991EF9D37875C5A6F3343@exchange.ticinocom.com> References: <5A838EC3CE99804991EF9D37875C5A6F3343@exchange.ticinocom.com> Comments: In-reply-to "Manuel Wenger" message dated "Mon, 16 May 2005 15:06:49 +0200" Date: Tue, 17 May 2005 13:47:23 -0400 Message-ID: <705.1116352043@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/306 X-Sequence-Number: 12470 "Manuel Wenger" writes: > We're having a performance problem with PostgresQL 8.0.2 running on > RHEL3 Update 4. There is a frequently updated table logging all our ADSL > customer logins which has 2 related triggers. An INSERT on that table, > "calls", takes about 300ms to execute according to the logs, and the > process takes up to 30% of the server CPU. When removing the triggers it > drops to 10-20ms. You need to figure out exactly which operation(s) inside the triggers is so expensive. You could try removing commands one at a time and timing the modified triggers. Just on general principles, I'd guess that this might be the problem: > delete from currentip where ip is null; Since an IS NULL test isn't indexable by a normal index, this is going to cause a full scan of the currentip table every time. I don't really understand why you need that executed every time anyway ... why is it this trigger's responsibility to clean out null IPs? But if you really do need to make that run quickly, you could create a partial index with a WHERE clause of "ip is null". regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 17 14:55:24 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2026752813 for ; Tue, 17 May 2005 14:55:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55111-09 for ; Tue, 17 May 2005 17:55:23 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id B623952840 for ; Tue, 17 May 2005 14:55:21 -0300 (ADT) Received: (qmail 16113 invoked from network); 17 May 2005 19:55:49 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 17 May 2005 19:55:49 +0200 Date: Tue, 17 May 2005 19:53:39 +0200 To: "Manuel Wenger" , pgsql-performance@postgresql.org Subject: Re: Trigger performance problem Message-Id: <20050517175521.B623952840@svr1.postgresql.org> From: lists@boutiquenumerique.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.945 tagged_above=0 required=5 tests=AWL, MSGID_FROM_MTA_ID, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200505/307 X-Sequence-Number: 12471 From pgsql-performance-owner@postgresql.org Tue May 17 19:57:37 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DF2EB52824 for ; Tue, 17 May 2005 19:57:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36098-08 for ; Tue, 17 May 2005 22:57:27 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id B566B5287B for ; Tue, 17 May 2005 19:57:25 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DYB0A-0005kY-Io for pgsql-performance@postgresql.org; Wed, 18 May 2005 00:57:27 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1DYB0A-0006N0-00 for ; Wed, 18 May 2005 00:57:26 +0200 Date: Wed, 18 May 2005 00:57:26 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Is there any other way to do this? Message-ID: <20050517225726.GA24185@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <428A770C.1030107@kencast.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <428A770C.1030107@kencast.com> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/309 X-Sequence-Number: 12473 On Tue, May 17, 2005 at 06:58:20PM -0400, Wei Weng wrote: > This time it worked! But VACUUM FULL requires an exclusive lock on the > table which I don't really want to grant. So my question is: why is VACUUM > ANALYZE didn't do the job? Is there any setting I can tweak to make a > VACUUM without granting a exclusive lock? You just didn't vacuum often enough. Plain VACUUM (with ANALYZE or not) only deletes dead rows, it does not reclaim the space used for them (and thus does not compress the remaining ones into fewer pages, so they take less time to scan). If you simply VACUUM regularily (try autovacuum from contrib, it will probably be useful) the problem simply will never be as bad as you describe here, and you won't need to VACUUM FULL. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Tue May 17 19:51:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9EE9A5280E for ; Tue, 17 May 2005 19:51:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42638-05 for ; Tue, 17 May 2005 22:51:04 +0000 (GMT) Received: from ylpvm43.prodigy.net (ylpvm43-ext.prodigy.net [207.115.57.74]) by svr1.postgresql.org (Postfix) with ESMTP id 0A3B952828 for ; Tue, 17 May 2005 19:51:03 -0300 (ADT) Received: from pimout6-ext.prodigy.net (pimout6-int.prodigy.net [207.115.4.22]) by ylpvm43.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id j4HMpD9Q011181 for ; Tue, 17 May 2005 18:51:13 -0400 X-ORBL: [69.177.163.214] Received: from [192.168.1.207] (214.adsl.snet.net [69.177.163.214] (may be forged)) by pimout6-ext.prodigy.net (8.12.10 milter /8.12.10) with ESMTP id j4HMp5K8468112 for ; Tue, 17 May 2005 18:51:06 -0400 Message-ID: <428A770C.1030107@kencast.com> Date: Tue, 17 May 2005 18:58:20 -0400 From: Wei Weng User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Is there any other way to do this? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.075 tagged_above=0 required=5 tests=AWL, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL X-Spam-Level: * X-Archive-Number: 200505/308 X-Sequence-Number: 12472 Hi, I have a small table that has only 23 rows, but I do frequent updates( every second ) on it. After running the updates for a while, the performance of SELECT from that table has deteriated into something like 30 seconds. So, natually, I did a VACUUM ANALYZE first. Here is the VERBOSE output. Test=> VACUUM VERBOSE analyze schedule ; INFO: vacuuming "public.schedule" INFO: index "schedule_pkey" now contains 23 row versions in 2519 pages DETAIL: 2499 index pages have been deleted, 2499 are currently reusable. CPU 0.27s/0.04u sec elapsed 12.49 sec. INFO: "schedule": found 0 removable, 23 nonremovable row versions in 37638 pages DETAIL: 0 dead row versions cannot be removed yet. There were 974282 unused item pointers. 0 pages are entirely empty. CPU 3.64s/0.48u sec elapsed 76.15 sec. INFO: vacuuming "pg_toast.pg_toast_22460" INFO: index "pg_toast_22460_index" now contains 0 row versions in 1 pages DETAIL: 0 index pages have been deleted, 0 are currently reusable. CPU 0.01s/0.00u sec elapsed 0.03 sec. INFO: "pg_toast_22460": found 0 removable, 0 nonremovable row versions in 0 pages DETAIL: 0 dead row versions cannot be removed yet. There were 0 unused item pointers. 0 pages are entirely empty. CPU 0.01s/0.00u sec elapsed 0.03 sec. INFO: analyzing "public.schedule" INFO: "schedule": 37638 pages, 23 rows sampled, 23 estimated total rows VACUUM And it didn't help at all. The explain of the query still shows up as: Test=> explain select id from schedule; QUERY PLAN ------------------------------------------------------------- Seq Scan on schedule (cost=0.00..37638.23 rows=23 width=4) (1 row) It still takes 30 seconds to finish a simple query. ugh. So I then tried VACUUM FULL schedule. Here is the output: fazzt=> VACUUM FULL VERBOSE schedule ; INFO: vacuuming "public.schedule" INFO: "schedule": found 0 removable, 23 nonremovable row versions in 37638 pages DETAIL: 0 dead row versions cannot be removed yet. Nonremovable row versions range from 253 to 418 bytes long. There were 974282 unused item pointers. Total free space (including removable row versions) is 303672968 bytes. 37629 pages are or will become empty, including 0 at the end of the table. 37638 pages containing 303672968 free bytes are potential move destinations. CPU 3.08s/0.50u sec elapsed 28.64 sec. INFO: index "schedule_pkey" now contains 23 row versions in 2182 pages DETAIL: 0 index row versions were removed. 2162 index pages have been deleted, 2162 are currently reusable. CPU 0.28s/0.02u sec elapsed 10.90 sec. INFO: "schedule": moved 13 row versions, truncated 37638 to 1 pages DETAIL: CPU 10.83s/10.96u sec elapsed 370.42 sec. INFO: index "schedule_pkey" now contains 23 row versions in 2182 pages DETAIL: 13 index row versions were removed. 2162 index pages have been deleted, 2162 are currently reusable. CPU 0.20s/0.05u sec elapsed 10.33 sec. INFO: vacuuming "pg_toast.pg_toast_22460" INFO: "pg_toast_22460": found 0 removable, 0 nonremovable row versions in 0 pages DETAIL: 0 dead row versions cannot be removed yet. Nonremovable row versions range from 0 to 0 bytes long. There were 0 unused item pointers. Total free space (including removable row versions) is 0 bytes. 0 pages are or will become empty, including 0 at the end of the table. 0 pages containing 0 free bytes are potential move destinations. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: index "pg_toast_22460_index" now contains 0 row versions in 1 pages DETAIL: 0 index pages have been deleted, 0 are currently reusable. CPU 0.00s/0.00u sec elapsed 0.00 sec. VACUUM This time it worked! But VACUUM FULL requires an exclusive lock on the table which I don't really want to grant. So my question is: why is VACUUM ANALYZE didn't do the job? Is there any setting I can tweak to make a VACUUM without granting a exclusive lock? Thanks! Wei From pgsql-performance-owner@postgresql.org Tue May 17 21:22:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 15FC852802 for ; Tue, 17 May 2005 21:22:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07410-04 for ; Wed, 18 May 2005 00:22:34 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 0BB6E52824 for ; Tue, 17 May 2005 21:22:33 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id ABA571522B; Tue, 17 May 2005 19:22:36 -0500 (CDT) Date: Tue, 17 May 2005 19:22:36 -0500 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: Tuning planner cost estimates Message-ID: <20050518002236.GU30902@decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/310 X-Sequence-Number: 12474 I've been doing some work to try and identify the actual costs associated with an index scan with some limited sucess. What's been run so far can be seen at http://stats.distributed.net/~decibel. But there's a couple problems. First, I can't use the box exclusively for this testing, which results in some result inconsistencies. Second, I've been using a dataset that I can't make public, which means no one else can run these tests on different hardware. So what I think would be useful is some way to generate a known dataset, and then be able to run tests against it on different machines. In the case of testing index scans, we need to be able to vary correlation, which so far I've been doing by ordering by different columns. I suspect it will also be important to test with different tuple sizes. There's also the question of whether or not the cache should be flushed for each run or not. Does this sound like a good way to determine actual costs for index scans (and hopefully other access methods in the future)? If so, what would be a good way to implement this? -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue May 17 23:11:20 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 307F1528B4 for ; Tue, 17 May 2005 23:11:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78863-05 for ; Wed, 18 May 2005 02:11:10 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 1D1C452811 for ; Tue, 17 May 2005 23:11:09 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 058AD24FE0; Wed, 18 May 2005 10:11:14 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id D4FEA24FDF; Wed, 18 May 2005 10:11:13 +0800 (WST) Message-ID: <428AA493.4000806@familyhealth.com.au> Date: Wed, 18 May 2005 10:12:35 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Wei Weng Cc: pgsql-performance@postgresql.org Subject: Re: Is there any other way to do this? References: <428A770C.1030107@kencast.com> In-Reply-To: <428A770C.1030107@kencast.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.066 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/311 X-Sequence-Number: 12475 > This time it worked! But VACUUM FULL requires an exclusive lock on the > table which I don't really want to grant. So my question is: why is > VACUUM ANALYZE didn't do the job? Is there any setting I can tweak to > make a VACUUM without granting a exclusive lock? You need to run normal vacuum analyze every few minutes or so, to stop it growing. I suggest pg_autovacuum. Chris From pgsql-performance-owner@postgresql.org Wed May 18 11:31:55 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7069B528AB for ; Wed, 18 May 2005 11:31:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37169-02 for ; Wed, 18 May 2005 14:31:15 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.205]) by svr1.postgresql.org (Postfix) with ESMTP id BF7A95283E for ; Wed, 18 May 2005 11:31:13 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so226222wri for ; Wed, 18 May 2005 07:31:18 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:content-type:content-transfer-encoding; b=nuK4ZQziQzYmIcFrOBbNBtidg8L9BMd2MkPTzE8NOg3O/3tannQyF6GtViUnK4eAgAeQ1REGvNaJDpzMFnIsp80c8rkmO1C3C5oKVUjWTDtpAFGypYRL3YL+njR5FXBGnBQOarZtjtZbqYrnCmLbLcVXOkLF40vSa4vmcCLLAi0= Received: by 10.54.32.4 with SMTP id f4mr347708wrf; Wed, 18 May 2005 07:31:18 -0700 (PDT) Received: from ?192.168.3.4? ([81.182.248.121]) by mx.gmail.com with ESMTP id 26sm232190wrl.2005.05.18.07.31.18; Wed, 18 May 2005 07:31:18 -0700 (PDT) Message-ID: <428B5179.6060202@gmail.com> Date: Wed, 18 May 2005 16:30:17 +0200 From: =?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "pgsql-performance@postgresql.org" Subject: where+orderby+limit not (always) using appropriate index? Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.608 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP, TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200505/312 X-Sequence-Number: 12476 Dear Gurus, I don't think it's a bug, I just don't understand what's behind this. If there's a paper or something on this, please point me there. Version: 7.4.6 Locale: hu_HU (in case that matters) Dump: see below sig. Abstract: Create a table with (at least) two fields, say i and o. Create three indexes on (i), (o), (i,o) Insert enough rows to test. Try to replace min/max aggregates with indexable queries such as: SELECT o FROM t WHERE i = 1 ORDER BY o LIMIT 1; Problem #1: This tends to use one of the single-column indexes (depending on the frequency of the indexed element), not the two-column index. Also, I'm not perfectly sure but maybe the planner is right. Why? Problem #2: If I drop the problematic 1-col index, it uses the 2-col index, but sorts after that. (and probably that's why the planner was right in #1) Why? Below is an example that isn't perfect; also, IRL I use a second field of type date. Problem #3: It seems that an opposite index (o, i) works differently but still not always. Why? In case it matters, I may be able to reproduce the original problem with original data. TIA, -- G. # CREATE TABLE t(i int, o int); CREATE TABLE # CREATE INDEX t_i on t (i); CREATE INDEX # CREATE INDEX t_o on t (o); CREATE INDEX # CREATE INDEX t_io on t (i, o); CREATE INDEX # INSERT INTO t SELECT 1, p.oid::int FROM pg_proc p WHERE Pronamespace=11; INSERT 0 1651 # explain analyze select * from t where i=1 order by o limit 1; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Limit (cost=0.00..3.37 rows=1 width=8) (actual time=0.028..0.029 rows=1 loops=1) -> Index Scan using t_o on t (cost=0.00..20.20 rows=6 width=8) (actual time=0.025..0.025 rows=1 loops=1) Filter: (i = 1) Total runtime: 0.082 ms (4 rows) # drop index t_o; DROP INDEX # explain analyze select * from t where i=1 order by o limit 1; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- Limit (cost=6.14..6.14 rows=1 width=8) (actual time=4.624..4.625 rows=1 loops=1) -> Sort (cost=6.14..6.15 rows=6 width=8) (actual time=4.619..4.619 rows=1 loops=1) Sort Key: o -> Index Scan using t_io on t (cost=0.00..6.11 rows=6 width=8) (actual time=0.026..2.605 rows=1651 loops=1) Index Cond: (i = 1) Total runtime: 4.768 ms (6 rows) [local]:tir=# From pgsql-performance-owner@postgresql.org Wed May 18 12:07:07 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C817E528AB for ; Wed, 18 May 2005 12:07:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47488-10 for ; Wed, 18 May 2005 15:06:56 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id ABF94528C1 for ; Wed, 18 May 2005 12:06:54 -0300 (ADT) Received: (qmail 32481 invoked from network); 18 May 2005 17:07:18 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 18 May 2005 17:07:18 +0200 To: =?utf-8?B?U3rFsWNzIEfDoWJvcg==?= , "pgsql-performance@postgresql.org" Subject: Re: where+orderby+limit not (always) using appropriate index? References: <428B5179.6060202@gmail.com> Message-ID: Date: Wed, 18 May 2005 17:06:51 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <428B5179.6060202@gmail.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/313 X-Sequence-Number: 12477 > SELECT o FROM t WHERE i = 1 ORDER BY o LIMIT 1; use : ORDER BY i, o If you have a multicol index and want to order on it, you should help the planner by ORDERing BY all of the columns in the index... It bit me a few times ;) From pgsql-performance-owner@postgresql.org Wed May 18 12:14:50 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1B68D52808 for ; Wed, 18 May 2005 12:14:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56176-04 for ; Wed, 18 May 2005 15:14:46 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id F195352802 for ; Wed, 18 May 2005 12:14:45 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4IFEeuD021958; Wed, 18 May 2005 11:14:40 -0400 (EDT) To: =?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= Cc: "pgsql-performance@postgresql.org" Subject: Re: where+orderby+limit not (always) using appropriate index? In-reply-to: <428B5179.6060202@gmail.com> References: <428B5179.6060202@gmail.com> Comments: In-reply-to =?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= message dated "Wed, 18 May 2005 16:30:17 +0200" Date: Wed, 18 May 2005 11:14:39 -0400 Message-ID: <21957.1116429279@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/314 X-Sequence-Number: 12478 =?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= writes: > Create a table with (at least) two fields, say i and o. > Create three indexes on (i), (o), (i,o) > Insert enough rows to test. > Try to replace min/max aggregates with indexable queries such as: > SELECT o FROM t WHERE i = 1 ORDER BY o LIMIT 1; > Problem #1: This tends to use one of the single-column indexes (depending on > the frequency of the indexed element), not the two-column index. Also, I'm > not perfectly sure but maybe the planner is right. Why? To get the planner to use the double-column index, you have to use an ORDER BY that matches the index, eg SELECT o FROM t WHERE i = 1 ORDER BY i,o LIMIT 1; regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 18 16:08:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1C99F52805 for ; Wed, 18 May 2005 16:08:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41043-05 for ; Wed, 18 May 2005 19:08:22 +0000 (GMT) Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) by svr1.postgresql.org (Postfix) with ESMTP id 2482B528A2 for ; Wed, 18 May 2005 16:08:18 -0300 (ADT) Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) by yertle.kcilink.com (Postfix) with ESMTP id A72FEB862 for ; Wed, 18 May 2005 15:08:18 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v728) In-Reply-To: <20050515093707.24005.qmail@web32011.mail.mud.yahoo.com> References: <20050515093707.24005.qmail@web32011.mail.mud.yahoo.com> Content-Type: multipart/alternative; boundary=Apple-Mail-21-697144398 Message-Id: From: Vivek Khera Subject: Re: [pgsql-benchmarks] Error when try installing pgbench ? Date: Wed, 18 May 2005 15:08:17 -0400 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.728) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.151 tagged_above=0 required=5 tests=AWL, HTML_FONT_BIG, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/315 X-Sequence-Number: 12479 --Apple-Mail-21-697144398 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed On May 15, 2005, at 5:37 AM, Andre Nas wrote: > Hello =85 > Im using source postgresql 8.0.3 under FreeBSD and already =20 > install, the database is running well. > Not that this has much to do with performance, but the problem is =20 that you need to use gmake to build postgres stuff. The BSD make =20 doesn't know about the GNU extensions/changes to Makefile syntax. Vivek Khera, Ph.D. +1-301-869-4449 x806 --Apple-Mail-21-697144398 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=WINDOWS-1252
On May 15, 2005, = at 5:37 AM, Andre Nas wrote:

Hello = =85
Im using source=A0 = postgresql 8.0.3 under FreeBSD and already install, the database = is running well.


Not that this has much to do with performance, but the problem is that = you need to use gmake to build postgres stuff.=A0 The BSD make doesn't = know about the GNU extensions/changes to Makefile syntax.


Vivek Khera, Ph.D.

+1-301-869-4449 x806



= --Apple-Mail-21-697144398-- From pgsql-performance-owner@postgresql.org Thu May 19 13:31:42 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1D40252822 for ; Thu, 19 May 2005 13:31:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98752-03 for ; Thu, 19 May 2005 16:31:32 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 7EAAF52882 for ; Thu, 19 May 2005 13:31:31 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7381908; Thu, 19 May 2005 09:33:45 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: "Jim C. Nasby" Subject: Re: Tuning planner cost estimates Date: Thu, 19 May 2005 09:31:47 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <20050518002236.GU30902@decibel.org> In-Reply-To: <20050518002236.GU30902@decibel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505190931.47662.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/316 X-Sequence-Number: 12480 Jim, > I've been doing some work to try and identify the actual costs > associated with an index scan with some limited sucess. What's been run > so far can be seen at http://stats.distributed.net/~decibel. But there's > a couple problems. First, I can't use the box exclusively for this > testing, which results in some result inconsistencies. I can get you access to boxes. Chat on IRC? > Second, I've been > using a dataset that I can't make public, which means no one else can > run these tests on different hardware. Then use one of the DBT databases. > In the > case of testing index scans, we need to be able to vary correlation, > which so far I've been doing by ordering by different columns. I suspect > it will also be important to test with different tuple sizes. There's > also the question of whether or not the cache should be flushed for each > run or not. > > Does this sound like a good way to determine actual costs for index > scans (and hopefully other access methods in the future)? If so, what > would be a good way to implement this? Well, the problem is that what we need to index scans is a formula, rather than a graph. The usefulness of benchmarking index scan cost is so that we can test our formula for accuracy and precision. However, such a formula *does* need to take into account concurrent activity, updates, etc ... that is, it needs to approximately estimate the relative cost on a live database, not a test one. This is also going to be a moving target because Tom's in-memory-bitmapping changes relative cost equations. I think a first step would be, in fact, to develop a tool that allows us to put EXPLAIN ANALYZE results in a database table. Without that, there is no possibility of statistical-scale analysis. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu May 19 13:55:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5111F52828 for ; Thu, 19 May 2005 13:55:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01368-03 for ; Thu, 19 May 2005 16:55:32 +0000 (GMT) Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) by svr1.postgresql.org (Postfix) with ESMTP id 8770C52802 for ; Thu, 19 May 2005 13:55:30 -0300 (ADT) Received: from phys-bur-2 ([129.148.9.73]) by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id j4JGtejO005069 for ; Thu, 19 May 2005 10:55:40 -0600 (MDT) Received: from conversion-daemon.bur-mail1.east.sun.com by bur-mail1.east.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IGQ00E01XMQO2@bur-mail1.east.sun.com> (original mail from Donald.Courtney@Sun.COM) for pgsql-performance@postgresql.org; Thu, 19 May 2005 12:55:40 -0400 (EDT) Received: from [129.148.184.34] (gyama.East.Sun.COM [129.148.184.34]) by bur-mail1.east.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTPA id <0IGQ00CN0XOSB5@bur-mail1.east.sun.com>; Thu, 19 May 2005 12:55:40 -0400 (EDT) Date: Thu, 19 May 2005 12:54:03 -0400 From: Donald Courtney Subject: Re: PostgreSQL strugling during high load In-reply-to: <23517.1115993561@sss.pgh.pa.us> To: Tom Lane Cc: pgsql-performance@postgresql.org Message-id: <428CC4AB.50906@sun.com> Organization: Sun Microsystems 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; SunOS i86pc; en-US; rv:1.7) Gecko/20041221 References: <01cc01c557ba$a4fdb0b0$f20214ac@bite.lt> <23217.1115991763@sss.pgh.pa.us> <022901c557c5$73df1220$f20214ac@bite.lt> <23517.1115993561@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/317 X-Sequence-Number: 12481 Tom Thanks for the post - I think I am getting this problem for a synthetic workload at high connection loads. The whole system seems to stop. Can you give some examples on what to try out in the .conf file? I tried bgwriter_all_percent = 30, 10, and 3 Which I understand to mean 30%, 10% and 3% of the dirty pages should be written out *between* checkpoints. I didn't see any change in effect. /regards Don C. Tom Lane wrote: >"Mindaugas Riauba" writes: > > >> It looks like that not only vacuum causes our problems. vacuum_cost >>seems to lower vacuum impact but we are still noticing slow queries "storm". >>We are logging queries that takes >2000ms to process. >> And there is quiet periods and then suddenly 30+ slow queries appears in >>log within the same second. What else could cause such behaviour? >> >> > >Checkpoints? You should ensure that the checkpoint settings are such >that checkpoints don't happen too often (certainly not oftener than >every five minutes or so), and make sure the bgwriter is configured >to dribble out dirty pages at a reasonable rate, so that the next >checkpoint doesn't have a whole load of stuff to write. > > regards, tom lane > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > From pgsql-performance-owner@postgresql.org Thu May 19 14:16:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8C78E52897 for ; Thu, 19 May 2005 14:16:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13629-04 for ; Thu, 19 May 2005 17:16:13 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3A9DC5288C for ; Thu, 19 May 2005 14:16:12 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4JHGLF7005515; Thu, 19 May 2005 13:16:21 -0400 (EDT) To: Josh Berkus Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org Subject: Re: Tuning planner cost estimates In-reply-to: <200505190931.47662.josh@agliodbs.com> References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Thu, 19 May 2005 09:31:47 -0700" Date: Thu, 19 May 2005 13:16:21 -0400 Message-ID: <5514.1116522981@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/318 X-Sequence-Number: 12482 Josh Berkus writes: > I think a first step would be, in fact, to develop a tool that allows us to > put EXPLAIN ANALYZE results in a database table. Without that, there is no > possibility of statistical-scale analysis. AFAIK you can do that today using, eg, plpgsql: for rec in explain analyze ... loop insert into table values(rec."QUERY PLAN"); end loop; regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 19 14:20:55 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 311F752824 for ; Thu, 19 May 2005 14:20:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17296-03 for ; Thu, 19 May 2005 17:20:49 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 0B5E452807 for ; Thu, 19 May 2005 14:20:48 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7382181; Thu, 19 May 2005 10:23:02 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Tom Lane Subject: Re: Tuning planner cost estimates Date: Thu, 19 May 2005 10:21:05 -0700 User-Agent: KMail/1.8 Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> <5514.1116522981@sss.pgh.pa.us> In-Reply-To: <5514.1116522981@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505191021.05407.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/319 X-Sequence-Number: 12483 Tom, > for rec in explain analyze ... loop > insert into table values(rec."QUERY PLAN"); > end loop; I need to go further than that and parse the results as well. And preserve relationships and nesting levels. Hmmmm ... what's the indenting formula for nesting levels? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu May 19 15:12:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F9D95286D for ; Thu, 19 May 2005 15:12:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28097-04 for ; Thu, 19 May 2005 18:12:23 +0000 (GMT) Received: from vt-pe2550-001.VANTAGE.vantage.com (vt-pe2550-001.vantage.com [64.80.203.244]) by svr1.postgresql.org (Postfix) with ESMTP id 4FE4E52824 for ; Thu, 19 May 2005 15:12:21 -0300 (ADT) 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="utf-8" Content-Transfer-Encoding: base64 Subject: Re: PostgreSQL strugling during high load Date: Thu, 19 May 2005 14:12:29 -0400 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A32@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] PostgreSQL strugling during high load Thread-Index: AcVck/XQxjNcnSkzQUW1IhkhQkSfJwACeLRX From: "Anjan Dave" To: "Donald Courtney" , "Tom Lane" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/320 X-Sequence-Number: 12484 V2hhdCBwbGF0Zm9ybSBpcyB0aGlzPw0KIA0KV2UgaGFkIHNpbWlsYXIgaXNzdWUgKFBHIDcuNC43 KS4gUmFpc2luZyBudW1iZXIgb2YgY2hlY2twb2ludCBzZWdtZW50cyB0byAxMjUsIHNlcGVyYXRp bmcgdGhlIFdBTCB0byBhIGRpZmZlcmVudCBMVU4gaGVscGVkLCBidXQgaXQncyBzdGlsbCBub3Qg Y29tcGxldGVseSBnb25lLg0KIA0KQXMgZmFyIGFzIGRpc2sgSS9PIGlzIGNvbmNlcm5lZCBmb3Ig Zmx1c2hpbmcgdGhlIGJ1ZmZlcnMgb3V0LCBJIGFtIG5vdCBydWxpbmcgb3V0IHRoZSBjb21iaW5h dGlvbiBvZiBEZWxsIFBFUkM0IFJBSUQgY2FyZCwgYW5kIHRoZSBSSCBBUyAzLjAgVXBkYXRlMyBi ZWluZyBhIHByb2JsZW0uDQogDQpUaGFua3MsDQpBbmphbg0KDQoJLS0tLS1PcmlnaW5hbCBNZXNz YWdlLS0tLS0gDQoJRnJvbTogRG9uYWxkIENvdXJ0bmV5IFttYWlsdG86RG9uYWxkLkNvdXJ0bmV5 QFN1bi5DT01dIA0KCVNlbnQ6IFRodSA1LzE5LzIwMDUgMTI6NTQgUE0gDQoJVG86IFRvbSBMYW5l IA0KCUNjOiBwZ3NxbC1wZXJmb3JtYW5jZUBwb3N0Z3Jlc3FsLm9yZyANCglTdWJqZWN0OiBSZTog W1BFUkZPUk1dIFBvc3RncmVTUUwgc3RydWdsaW5nIGR1cmluZyBoaWdoIGxvYWQNCgkNCgkNCg0K CVRvbSANCg0KCVRoYW5rcyBmb3IgdGhlIHBvc3QgLSBJIHRoaW5rIEkgYW0gZ2V0dGluZyB0aGlz IHByb2JsZW0gZm9yIA0KCWEgc3ludGhldGljIHdvcmtsb2FkIGF0IGhpZ2ggY29ubmVjdGlvbiBs b2Fkcy4gIFRoZSB3aG9sZSANCglzeXN0ZW0gc2VlbXMgdG8gc3RvcC4gDQoNCglDYW4geW91IGdp dmUgc29tZSBleGFtcGxlcyBvbiB3aGF0IHRvIHRyeSBvdXQgaW4gdGhlIC5jb25mIGZpbGU/IA0K DQoJSSB0cmllZCANCgliZ3dyaXRlcl9hbGxfcGVyY2VudCA9ICAzMCwgMTAsIGFuZCAzIA0KDQoJ V2hpY2ggSSB1bmRlcnN0YW5kIHRvIG1lYW4gMzAlLCAxMCUgYW5kIDMlIG9mIHRoZSBkaXJ0eSBw YWdlcyBzaG91bGQgYmUgDQoJd3JpdHRlbiBvdXQgKmJldHdlZW4qIGNoZWNrcG9pbnRzLiANCg0K CUkgZGlkbid0IHNlZSBhbnkgY2hhbmdlIGluIGVmZmVjdC4gDQoNCgkvcmVnYXJkcyANCglEb24g Qy4gDQoNCglUb20gTGFuZSB3cm90ZTogDQoNCgk+Ik1pbmRhdWdhcyBSaWF1YmEiIDxtaW5kQGJp Lmx0PiB3cml0ZXM6IA0KCT4gIA0KCT4gDQoJPj4gIEl0IGxvb2tzIGxpa2UgdGhhdCBub3Qgb25s eSB2YWN1dW0gY2F1c2VzIG91ciBwcm9ibGVtcy4gdmFjdXVtX2Nvc3QgDQoJPj5zZWVtcyB0byBs b3dlciB2YWN1dW0gaW1wYWN0IGJ1dCB3ZSBhcmUgc3RpbGwgbm90aWNpbmcgc2xvdyBxdWVyaWVz ICJzdG9ybSIuIA0KCT4+V2UgYXJlIGxvZ2dpbmcgcXVlcmllcyB0aGF0IHRha2VzID4yMDAwbXMg dG8gcHJvY2Vzcy4gDQoJPj4gIEFuZCB0aGVyZSBpcyBxdWlldCBwZXJpb2RzIGFuZCB0aGVuIHN1 ZGRlbmx5IDMwKyBzbG93IHF1ZXJpZXMgYXBwZWFycyBpbiANCgk+PmxvZyB3aXRoaW4gdGhlIHNh bWUgc2Vjb25kLiBXaGF0IGVsc2UgY291bGQgY2F1c2Ugc3VjaCBiZWhhdmlvdXI/IA0KCT4+ICAg IA0KCT4+IA0KCT4gDQoJPkNoZWNrcG9pbnRzPyAgWW91IHNob3VsZCBlbnN1cmUgdGhhdCB0aGUg Y2hlY2twb2ludCBzZXR0aW5ncyBhcmUgc3VjaCANCgk+dGhhdCBjaGVja3BvaW50cyBkb24ndCBo YXBwZW4gdG9vIG9mdGVuIChjZXJ0YWlubHkgbm90IG9mdGVuZXIgdGhhbiANCgk+ZXZlcnkgZml2 ZSBtaW51dGVzIG9yIHNvKSwgYW5kIG1ha2Ugc3VyZSB0aGUgYmd3cml0ZXIgaXMgY29uZmlndXJl ZCANCgk+dG8gZHJpYmJsZSBvdXQgZGlydHkgcGFnZXMgYXQgYSByZWFzb25hYmxlIHJhdGUsIHNv IHRoYXQgdGhlIG5leHQgDQoJPmNoZWNrcG9pbnQgZG9lc24ndCBoYXZlIGEgd2hvbGUgbG9hZCBv ZiBzdHVmZiB0byB3cml0ZS4gDQoJPiANCgk+ICAgICAgICAgICAgICAgICAgICAgICByZWdhcmRz LCB0b20gbGFuZSANCgk+IA0KCT4tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0oZW5kIG9mIGJy b2FkY2FzdCktLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0gDQoJPlRJUCAxOiBzdWJzY3JpYmUg YW5kIHVuc3Vic2NyaWJlIGNvbW1hbmRzIGdvIHRvIG1ham9yZG9tb0Bwb3N0Z3Jlc3FsLm9yZyAN Cgk+ICANCgk+IA0KDQoNCgktLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0oZW5kIG9mIGJyb2Fk Y2FzdCktLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0gDQoJVElQIDc6IGRvbid0IGZvcmdldCB0 byBpbmNyZWFzZSB5b3VyIGZyZWUgc3BhY2UgbWFwIHNldHRpbmdzIA0KDQo= From pgsql-performance-owner@postgresql.org Thu May 19 15:30:57 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B79FC5282B for ; Thu, 19 May 2005 15:30:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29161-09 for ; Thu, 19 May 2005 18:30:54 +0000 (GMT) Received: from brmea-mail-4.sun.com (brmea-mail-4.Sun.COM [192.18.98.36]) by svr1.postgresql.org (Postfix) with ESMTP id 890825282E for ; Thu, 19 May 2005 15:30:52 -0300 (ADT) Received: from phys-bur-2 ([129.148.9.73]) by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id j4JIV40R021478 for ; Thu, 19 May 2005 12:31:04 -0600 (MDT) Received: from conversion-daemon.bur-mail1.east.sun.com by bur-mail1.east.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IGR00C011YU3G@bur-mail1.east.sun.com> (original mail from Donald.Courtney@Sun.COM) for pgsql-performance@postgresql.org; Thu, 19 May 2005 14:31:04 -0400 (EDT) Received: from [129.148.184.34] (gyama.East.Sun.COM [129.148.184.34]) by bur-mail1.east.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTPA id <0IGR00F8523S9B@bur-mail1.east.sun.com>; Thu, 19 May 2005 14:31:04 -0400 (EDT) Date: Thu, 19 May 2005 14:29:27 -0400 From: Donald Courtney Subject: Re: PostgreSQL strugling during high load In-reply-to: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A32@vt-pe2550-001.vantage.vantage.com> To: Anjan Dave Cc: Tom Lane , pgsql-performance@postgresql.org Message-id: <428CDB07.2030503@sun.com> Organization: Sun Microsystems MIME-version: 1.0 Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7) Gecko/20041221 References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A32@vt-pe2550-001.vantage.vantage.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/321 X-Sequence-Number: 12485 Anjan Dave wrote: >What platform is this? > > > Its a DELL RH 4 with the xlog on a seperate external mounted file system. The data directory is on a external mounted file system as well. >We had similar issue (PG 7.4.7). Raising number of checkpoint segments to 125, seperating the WAL to a different LUN helped, but it's still not completely gone. > > > I'll try raising the number. I guess the bg* config variables don't do much? thanks >As far as disk I/O is concerned for flushing the buffers out, I am not ruling out the combination of Dell PERC4 RAID card, and the RH AS 3.0 Update3 being a problem. > >Thanks, >Anjan > > -----Original Message----- > From: Donald Courtney [mailto:Donald.Courtney@Sun.COM] > Sent: Thu 5/19/2005 12:54 PM > To: Tom Lane > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] PostgreSQL strugling during high load > > > > Tom > > Thanks for the post - I think I am getting this problem for > a synthetic workload at high connection loads. The whole > system seems to stop. > > Can you give some examples on what to try out in the .conf file? > > I tried > bgwriter_all_percent = 30, 10, and 3 > > Which I understand to mean 30%, 10% and 3% of the dirty pages should be > written out *between* checkpoints. > > I didn't see any change in effect. > > /regards > Don C. > > Tom Lane wrote: > > >"Mindaugas Riauba" writes: > > > > > >> It looks like that not only vacuum causes our problems. vacuum_cost > >>seems to lower vacuum impact but we are still noticing slow queries "storm". > >>We are logging queries that takes >2000ms to process. > >> And there is quiet periods and then suddenly 30+ slow queries appears in > >>log within the same second. What else could cause such behaviour? > >> > >> > > > >Checkpoints? You should ensure that the checkpoint settings are such > >that checkpoints don't happen too often (certainly not oftener than > >every five minutes or so), and make sure the bgwriter is configured > >to dribble out dirty pages at a reasonable rate, so that the next > >checkpoint doesn't have a whole load of stuff to write. > > > > regards, tom lane > > > >---------------------------(end of broadcast)--------------------------- > >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings > > >---------------------------(end of broadcast)--------------------------- >TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > > From pgsql-performance-owner@postgresql.org Thu May 19 16:43:02 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E1D752861 for ; Thu, 19 May 2005 16:43:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49930-08 for ; Thu, 19 May 2005 19:42:58 +0000 (GMT) Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) by svr1.postgresql.org (Postfix) with ESMTP id 8D2D85285F for ; Thu, 19 May 2005 16:42:52 -0300 (ADT) Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) by yertle.kcilink.com (Postfix) with ESMTP id 3C24BB85A for ; Thu, 19 May 2005 15:43:04 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v730) In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A32@vt-pe2550-001.vantage.vantage.com> References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A32@vt-pe2550-001.vantage.vantage.com> Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-16-785630598; protocol="application/pkcs7-signature" Message-Id: <58D043B8-185F-4964-BF12-C932CF7CBDB0@khera.org> From: Vivek Khera Subject: Re: PostgreSQL strugling during high load Date: Thu, 19 May 2005 15:43:03 -0400 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.730) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.038 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/322 X-Sequence-Number: 12486 --Apple-Mail-16-785630598 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On May 19, 2005, at 2:12 PM, Anjan Dave wrote: > As far as disk I/O is concerned for flushing the buffers out, I am > not ruling out the combination of Dell PERC4 RAID card > That'd be my first guess as to I/O speed issues. I have some dell hardware that by all means should be totally blowing out my other boxes in speed, but the I/O sucks out the wazoo. I'm migrating to opteron based DB servers with LSI branded cards (not the Dell re- branded ones). Vivek Khera, Ph.D. +1-301-869-4449 x806 --Apple-Mail-16-785630598 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGhzCCAz8w ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A 9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNAMIICqaADAgECAgMOah8wDQYJKoZI hvcNAQEEBQAwYjELMAkGA1UEBhMCWkExJTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkp IEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA1 MDQwNTIwMzEzMloXDTA2MDQwNTIwMzEzMlowgYoxHzAdBgNVBAMTFlRoYXd0ZSBGcmVlbWFpbCBN ZW1iZXIxHjAcBgkqhkiG9w0BCQEWD3ZpdmVrQGtoZXJhLm9yZzEgMB4GCSqGSIb3DQEJARYRa2hl cmFAa2NpbGluay5jb20xJTAjBgkqhkiG9w0BCQEWFnZpdmVrQG1haWxlcm1haWxlci5jb20wggEi MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDdo7hywGcY0VvK6WqqXXV77MS/t/4X3WkCaCXo RSl2W58GP4P21hodPn7hlIxUoDOW7x9O+FbqTgE2Ejqr6yA00Mm90tGPFgjFjqPGAqg7xk6IDcv9 uTyMia/FKEHSIynM6zqokXY8JklvdbJOiByE/8VeyEXOANWiflo8o4+GHnhMKpA9982YTXUqeKU6 mMQVaLCBRjTDc7j2XkMC/UNcp2HMyDQdTqYVnhLxbvbLX8CNDBY/7OWFlB9evru46SpGWhe4lhv5 DSgE2RdCKvDytzxRDvP49L8V0TnFjAVeC1C1Pj0/KQsoL/AP4APplROiD4QaUhshQl28pXxJtfbl AgMBAAGjVzBVMEUGA1UdEQQ+MDyBD3ZpdmVrQGtoZXJhLm9yZ4ERa2hlcmFAa2NpbGluay5jb22B FnZpdmVrQG1haWxlcm1haWxlci5jb20wDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQQFAAOBgQAr CWop3h28qPwofzLrkoT410J4d7Bqk6FLeVlKZfg/wXlS1MTqYMNcCm4x+JsJbjwsO0fb2elFIuGq 1razoSzPpgi89itydvUT0U0U/u+AkZA5rW4AptTpMZ70YW5u9wzkcvmifqZmcfbaaeGdZfruzUXZ 6qvdXDpNb3ZHeQw6PjGCAucwggLjAgEBMGkwYjELMAkGA1UEBhMCWkExJTAjBgNVBAoTHFRoYXd0 ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFp bCBJc3N1aW5nIENBAgMOah8wCQYFKw4DAhoFAKCCAVMwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEH ATAcBgkqhkiG9w0BCQUxDxcNMDUwNTE5MTk0MzA0WjAjBgkqhkiG9w0BCQQxFgQUdtx3U0QSSy7p 4w+/uTWdmmjAcowweAYJKwYBBAGCNxAEMWswaTBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt YWlsIElzc3VpbmcgQ0ECAw5qHzB6BgsqhkiG9w0BCRACCzFroGkwYjELMAkGA1UEBhMCWkExJTAj BgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQZXJz b25hbCBGcmVlbWFpbCBJc3N1aW5nIENBAgMOah8wDQYJKoZIhvcNAQEBBQAEggEAy5gePlFq1+Zv JiiIzFQZ2n95aRXFEYIPj9N13PvGYrMmrHN3jrAOa0sePawEbhvXj2BT7CkjZZ/RcbblsENY5GvU CwrQ356G7LfX+cJtQZY7S7z39I62cU20AfSVX17pgEYHgqmUmbkk2S0WgogILsdZnrUvogGXoGFa cQkEAJUWVWjSah6xBq1YsuNo7DWAJKxrxFnQQ/FB4stzLHn7p6zl04+FTBY0cMx01zCz/NYUnhER E9zL6KfLM6KFUteCtxnntFInc65SqKgmgeIaoSFv9RlP/N9wgtUZcliY4jPYVxQmYcqKZNXiSjgn h+pq6JZyN3sCpZ/tBNUI8+ExLgAAAAAAAA== --Apple-Mail-16-785630598-- From pgsql-performance-owner@postgresql.org Thu May 19 16:56:19 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7B16E5281E for ; Thu, 19 May 2005 16:56:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56621-01 for ; Thu, 19 May 2005 19:56:09 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id CF00F52807 for ; Thu, 19 May 2005 16:56:07 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7382786; Thu, 19 May 2005 12:58:22 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Anjan Dave" Subject: Re: PostgreSQL strugling during high load Date: Thu, 19 May 2005 12:57:44 -0700 User-Agent: KMail/1.7.1 Cc: "Donald Courtney" , "Tom Lane" , pgsql-performance@postgresql.org References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A32@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A32@vt-pe2550-001.vantage.vantage.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505191257.44874.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/323 X-Sequence-Number: 12487 Anjan, > As far as disk I/O is concerned for flushing the buffers out, I am not > ruling out the combination of Dell PERC4 RAID card, and the RH AS 3.0 > Update3 being a problem. You know that Update4 is out, yes? Update3 is currenly throttling your I/O by about 50%. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu May 19 17:11:47 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 24C1E52863 for ; Thu, 19 May 2005 17:11:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60974-06 for ; Thu, 19 May 2005 20:11:36 +0000 (GMT) Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net [66.238.115.135]) by svr1.postgresql.org (Postfix) with ESMTP id 77BB15285F for ; Thu, 19 May 2005 17:11:35 -0300 (ADT) Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; Thu, 19 May 2005 13:15:00 -0700 Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with Microsoft SMTPSVC(6.0.3790.0); Thu, 19 May 2005 13:14:58 -0700 Received: from barracuda.tecarta.com ([192.168.160.200]) by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id M2005051913145732253 for ; Thu, 19 May 2005 13:14:57 -0700 X-ASG-Debug-ID: 1116533504-7399-15-0 X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi Received: from mail1 (mail1.hq.corp [192.168.160.5]) by barracuda.tecarta.com (Spam Firewall) with SMTP id C9D4B20189E5 for ; Thu, 19 May 2005 13:11:44 -0700 (PDT) Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 19 May 2005 13:14:55 -0700 Message-ID: <428CF2A8.20602@sfnet.cc> Date: Thu, 19 May 2005 13:10:16 -0700 From: Steve Poe User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050516) X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org X-ASG-Orig-Subj: Re: [PERFORM] PostgreSQL strugling during high load Subject: Re: PostgreSQL strugling during high load References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A32@vt-pe2550-001.vantage.vantage.com> <200505191257.44874.josh@agliodbs.com> In-Reply-To: <200505191257.44874.josh@agliodbs.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 May 2005 20:14:55.0982 (UTC) FILETIME=[6C8820E0:01C55CAF] X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=4.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_50 X-Barracuda-Spam-Report: Code version 3.02, rules version 3.0.1123 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BAYES_50 BODY: Bayesian spam probability is 40 to 60% [score: 0.5529] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.163 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/324 X-Sequence-Number: 12488 Josh Berkus wrote: >Anjan, > > > >>As far as disk I/O is concerned for flushing the buffers out, I am not >>ruling out the combination of Dell PERC4 RAID card, and the RH AS 3.0 >>Update3 being a problem. >> >> > >You know that Update4 is out, yes? >Update3 is currenly throttling your I/O by about 50%. > > Is that 50% just for the Dell PERC4 RAID on RH AS 3.0? Sound like severe context switching. Steve Poe From pgsql-performance-owner@postgresql.org Thu May 19 17:19:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 820FD5282E for ; Thu, 19 May 2005 17:19:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63093-10 for ; Thu, 19 May 2005 20:19:50 +0000 (GMT) Received: from vt-pe2550-001.VANTAGE.vantage.com (vt-pe2550-001.vantage.com [64.80.203.244]) by svr1.postgresql.org (Postfix) with ESMTP id 4B1BF5282D for ; Thu, 19 May 2005 17:19:46 -0300 (ADT) 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: PostgreSQL strugling during high load Date: Thu, 19 May 2005 16:19:58 -0400 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785026FF87E@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] PostgreSQL strugling during high load Thread-Index: AcVcrNXUtBL8DHKDRvK/VU7tkNT6jQAAuFLA From: "Anjan Dave" To: Cc: "Donald Courtney" , "Tom Lane" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.042 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/325 X-Sequence-Number: 12489 Yes, I am using it another DB/application. Few more days and I'll have a free hand on this box as well. Thanks, Anjan -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Thursday, May 19, 2005 3:58 PM To: Anjan Dave Cc: Donald Courtney; Tom Lane; pgsql-performance@postgresql.org Subject: Re: [PERFORM] PostgreSQL strugling during high load Anjan, > As far as disk I/O is concerned for flushing the buffers out, I am not > ruling out the combination of Dell PERC4 RAID card, and the RH AS 3.0 > Update3 being a problem. You know that Update4 is out, yes? =20 Update3 is currenly throttling your I/O by about 50%. --=20 --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu May 19 18:50:07 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6C34052828 for ; Thu, 19 May 2005 18:50:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97765-06 for ; Thu, 19 May 2005 21:50:02 +0000 (GMT) Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) by svr1.postgresql.org (Postfix) with ESMTP id D79045280C for ; Thu, 19 May 2005 18:50:00 -0300 (ADT) Received: from [192.168.1.52] (c-24-60-119-214.hsd1.ma.comcast.net[24.60.119.214]) by comcast.net (sccrmhc12) with ESMTP id <200505192150130120063lshe>; Thu, 19 May 2005 21:50:14 +0000 Message-ID: <428D0A16.2010709@comcast.net> Date: Thu, 19 May 2005 17:50:14 -0400 From: Jeffrey Tenny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Which is better, correlated subqueries or joins? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.249 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST X-Spam-Level: * X-Archive-Number: 200505/326 X-Sequence-Number: 12490 Looking for some general advice on correlated subqueries vs. joins. Which of these plans is likely to perform better. One table is a master record table for entities and their IDs (nv_products), the other represents a transitive closure of parent/child relationships (for a tree) of ID's in the master record table (and so is larger) (ssv_product_children). The query is, in english: for direct children of an ID, return the ones for which isrel is true. I have only a tiny demo table set for which there is only one record matched by the queries below, it's hard to guess at how deep or branchy a production table might be, so I'm trying to develop a general query strategy and learn a thing or two about pgsql. Here's the join: # explain select child_pid from ssv_product_children, nv_products where nv_products.id = ssv_product_children.child_pid and ssv_product_children.pid = 1 and nv_products.isrel = 't'; QUERY PLAN -------------------------------------------------------------------------- Hash Join (cost=1.22..2.47 rows=2 width=8) Hash Cond: ("outer".child_pid = "inner".id) -> Seq Scan on ssv_product_children (cost=0.00..1.18 rows=9 width=4) Filter: (pid = 1) -> Hash (cost=1.21..1.21 rows=4 width=4) -> Seq Scan on nv_products (cost=0.00..1.21 rows=4 width=4) Filter: (isrel = true) (7 rows) Here's the correlated subquery: # explain select child_pid from ssv_product_children where pid = 1 and child_pid = (select nv_products.id from nv_products where nv_products.id = child_pid and isrel = 't'); QUERY PLAN --------------------------------------------------------------------- Seq Scan on ssv_product_children (cost=0.00..18.78 rows=1 width=4) Filter: ((pid = 1) AND (child_pid = (subplan))) SubPlan -> Seq Scan on nv_products (cost=0.00..1.26 rows=1 width=4) Filter: ((id = $0) AND (isrel = true)) (5 rows) Thanks for any advice. From pgsql-performance-owner@postgresql.org Thu May 19 18:53:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5639052827 for ; Thu, 19 May 2005 18:53:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02525-04 for ; Thu, 19 May 2005 21:53:40 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 9AFE85281E for ; Thu, 19 May 2005 18:53:39 -0300 (ADT) Received: from [192.168.1.52] (fc1smp [66.93.38.87]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id j4JLjla3023179; Thu, 19 May 2005 14:45:47 -0700 Message-ID: <428D0AF0.4020001@commandprompt.com> Date: Thu, 19 May 2005 14:53:52 -0700 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeffrey Tenny Cc: pgsql-performance@postgresql.org Subject: Re: Which is better, correlated subqueries or joins? References: <428D0A16.2010709@comcast.net> In-Reply-To: <428D0A16.2010709@comcast.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.016 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/327 X-Sequence-Number: 12491 Hello, It always depends on the dataset but you should try an explain analyze on each query. It will tell you which one is more efficient for your particular data. Sincerely, Joshua D. Drake > > Here's the join: > > # explain select child_pid from ssv_product_children, nv_products where > nv_products.id = ssv_product_children.child_pid and > ssv_product_children.pid = 1 and nv_products.isrel = 't'; > QUERY PLAN > -------------------------------------------------------------------------- > Hash Join (cost=1.22..2.47 rows=2 width=8) > Hash Cond: ("outer".child_pid = "inner".id) > -> Seq Scan on ssv_product_children (cost=0.00..1.18 rows=9 width=4) > Filter: (pid = 1) > -> Hash (cost=1.21..1.21 rows=4 width=4) > -> Seq Scan on nv_products (cost=0.00..1.21 rows=4 width=4) > Filter: (isrel = true) > (7 rows) > > > Here's the correlated subquery: > > > # explain select child_pid from ssv_product_children where pid = 1 and > child_pid = (select nv_products.id from nv_products where nv_products.id > = child_pid and isrel = 't'); > QUERY PLAN > --------------------------------------------------------------------- > Seq Scan on ssv_product_children (cost=0.00..18.78 rows=1 width=4) > Filter: ((pid = 1) AND (child_pid = (subplan))) > SubPlan > -> Seq Scan on nv_products (cost=0.00..1.26 rows=1 width=4) > Filter: ((id = $0) AND (isrel = true)) > (5 rows) > > > Thanks for any advice. > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match -- Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 PostgreSQL Replication, Consulting, Custom Programming, 24x7 support Managed Services, Shared and Dedicated Hosting Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ From pgsql-performance-owner@postgresql.org Thu May 19 19:21:15 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7EE2B52828 for ; Thu, 19 May 2005 19:21:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08069-07 for ; Thu, 19 May 2005 22:21:05 +0000 (GMT) Received: from lakermmtao07.cox.net (lakermmtao07.cox.net [68.230.240.32]) by svr1.postgresql.org (Postfix) with ESMTP id 1118252846 for ; Thu, 19 May 2005 19:21:04 -0300 (ADT) Received: from [192.168.3.2] (really [68.12.186.82]) by lakermmtao07.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050519222118.FZGM28809.lakermmtao07.cox.net@[192.168.3.2]> for ; Thu, 19 May 2005 18:21:18 -0400 Message-ID: <428D1153.1020109@rueb.com> Date: Thu, 19 May 2005 17:21:07 -0500 From: Steve Bergman User-Agent: Mozilla Thunderbird 1.0.2-1.3.3 (X11/20050513) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Optimizing for writes. Data integrity not critical Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/328 X-Sequence-Number: 12492 Hi, I am using postgresql in small (almost trivial) application in which I pull some data out of a Cobol C/ISAM file and write it into a pgsl table. My users can then use the data however they want by interfacing to the data from OpenOffice.org. The amount of data written is about 60MB and takes a few minutes on a 1200Mhz Athlon with a single 60MB IDE drive running Fedora Core 3 with pgsql 7.4.7. I'd like to speed up the DB writes a bit if possible. Data integrity is not at all critical as the database gets dropped, created, and populated immediately before each use. Filesystem is ext3, data=ordered and I need to keep it that way as there is other data in the filesystem that I do care about. I have not done any tuning in the config file yet, and was wondering what things would likely speed up writes in this situation. I'm doing the writes individually. Is there a better way? Combining them all into a transaction or something? Thanks, Steve Bergman From pgsql-performance-owner@postgresql.org Thu May 19 19:27:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC5F55286C for ; Thu, 19 May 2005 19:27:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07688-10 for ; Thu, 19 May 2005 22:27:24 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id 8D47E52856 for ; Thu, 19 May 2005 19:27:22 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DYtUK-0008B0-Et for pgsql-performance@postgresql.org; Fri, 20 May 2005 00:27:32 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1DYtUJ-0005Jy-00 for ; Fri, 20 May 2005 00:27:31 +0200 Date: Fri, 20 May 2005 00:27:31 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Optimizing for writes. Data integrity not critical Message-ID: <20050519222731.GB20142@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <428D1153.1020109@rueb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <428D1153.1020109@rueb.com> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/329 X-Sequence-Number: 12493 On Thu, May 19, 2005 at 05:21:07PM -0500, Steve Bergman wrote: > I'm doing the writes individually. Is there a better way? Combining > them all into a transaction or something? Batching them all in one or a few transactions will speed it up a _lot_. Using COPY would help a bit more on top of that. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Thu May 19 20:44:58 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B04235284C for ; Thu, 19 May 2005 20:44:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27941-07 for ; Thu, 19 May 2005 23:44:47 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 50BFA52823 for ; Thu, 19 May 2005 20:44:46 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4JNj1NE010302; Thu, 19 May 2005 19:45:01 -0400 (EDT) To: Steve Bergman Cc: pgsql-performance@postgresql.org Subject: Re: Optimizing for writes. Data integrity not critical In-reply-to: <20050519222731.GB20142@uio.no> References: <428D1153.1020109@rueb.com> <20050519222731.GB20142@uio.no> Comments: In-reply-to "Steinar H. Gunderson" message dated "Fri, 20 May 2005 00:27:31 +0200" Date: Thu, 19 May 2005 19:45:01 -0400 Message-ID: <10301.1116546301@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/330 X-Sequence-Number: 12494 "Steinar H. Gunderson" writes: > On Thu, May 19, 2005 at 05:21:07PM -0500, Steve Bergman wrote: >> I'm doing the writes individually. Is there a better way? Combining >> them all into a transaction or something? > Batching them all in one or a few transactions will speed it up a _lot_. > Using COPY would help a bit more on top of that. Also, if you really don't need to worry about data integrity, turning off fsync in the config file will probably help. (Though since it's an IDE drive, maybe not, as the drive may be lying about write complete anyway.) Increasing checkpoint_segments will help too, at the cost of disk space (about 32MB per increment in the value, IIRC). I'd suggest pushing it up enough so you don't incur a checkpoint while the time-critical operation runs. checkpoint_timeout may be too small too. regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 19 22:42:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EBAF752868 for ; Thu, 19 May 2005 22:42:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65827-02 for ; Fri, 20 May 2005 01:42:50 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 9B2BF5280A for ; Thu, 19 May 2005 22:42:46 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 9C9DD24FDD; Fri, 20 May 2005 09:42:58 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 81B5D24FCE; Fri, 20 May 2005 09:42:58 +0800 (WST) Message-ID: <428D4146.6000203@familyhealth.com.au> Date: Fri, 20 May 2005 09:45:42 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Steve Bergman Cc: pgsql-performance@postgresql.org Subject: Re: Optimizing for writes. Data integrity not critical References: <428D1153.1020109@rueb.com> In-Reply-To: <428D1153.1020109@rueb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.066 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/331 X-Sequence-Number: 12495 > I'm doing the writes individually. Is there a better way? Combining > them all into a transaction or something? Use COPY of course :) Or at worst bundle 1000 inserts at a time in a transation... And if you seriously do not care about your data at all, set fsync = off in you postgresql.conf for a mega speedup. Chris From pgsql-performance-owner@postgresql.org Fri May 20 16:46:28 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EF9C75284E for ; Fri, 20 May 2005 16:46:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72418-06 for ; Fri, 20 May 2005 19:46:22 +0000 (GMT) Received: from mta10.nationwireless.net (mta10.nationwireless.net [63.163.128.10]) by svr1.postgresql.org (Postfix) with ESMTP id EA8815283B for ; Fri, 20 May 2005 16:46:21 -0300 (ADT) Received: from jfradkin [63.162.100.127] by mta10.nationwireless.net with ESMTP (SMTPD-8.20) id AEA50714; Fri, 20 May 2005 15:46:45 -0400 From: "Joel Fradkin" To: "PostgreSQL Perform" Subject: performance on a querry with many group by's any way to speed it up? Date: Fri, 20 May 2005 15:47:21 -0400 Message-ID: <005c01c55d74$bcd0b0b0$797ba8c0@jfradkin> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_005D_01C55D53.35BF10B0" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.039 tagged_above=0 required=5 tests=AWL, HTML_60_70, HTML_MESSAGE, MSGID_DOLLARS X-Spam-Level: ** X-Archive-Number: 200505/332 X-Sequence-Number: 12496 This is a multi-part message in MIME format. ------=_NextPart_000_005D_01C55D53.35BF10B0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable explain analyze SELECT audit , store , question , month , year , week , weekday , myaudittotalscore , active , auditnum , answer , quarter , y_n = , region , district , audittype , status , keyedby , questiondisplay , = qtext , qdescr , answerdisplay , answertext , customauditnum , dateaudittaken , datecompleted , dateauditkeyed , datekeyingcomplete , section , = createdby , division , auditscoredesc , locationnum , text_response , Sum(questionpointsavailable) , Sum(pointsscored)=20 from viwAuditCube where clientnum =3D'RSI'=20 GROUP BY audit, store, question, month, year, week, weekday, myaudittotalscore, active, auditnum, answer, quarter, y_n, region, = district, audittype, status, keyedby, questiondisplay, qtext, qdescr, = answerdisplay, answertext, customauditnum, dateaudittaken, datecompleted, = dateauditkeyed, datekeyingcomplete, section, createdby, division, auditscoredesc, locationnum, text_response ORDER BY audit, store, question, month, year, week, weekday, myaudittotalscore, active, auditnum, answer, quarter, = y_n, region, district, audittype, status, keyedby, questiondisplay, qtext, qdescr, answerdisplay, answertext, customauditnum, dateaudittaken, datecompleted, dateauditkeyed, datekeyingcomplete, section, createdby, division, auditscoredesc, locationnum, text_response =20 =20 Joel Fradkin =20 Wazagua, Inc. 2520 Trailmate Dr Sarasota, Florida 34243 Tel. 941-753-7111 ext 305 =20 jfradkin@wazagua.com www.wazagua.com Powered by Wazagua Providing you with the latest Web-based technology & advanced tools. C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc This email message is for the use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized = review, use, disclosure or distribution is prohibited. If you are not the = intended recipient, please contact the sender by reply email and delete and = destroy all copies of the original message, including attachments. =20 =20 =20 ------=_NextPart_000_005D_01C55D53.35BF10B0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

explain analyze SELECT audit , store , question , = month , year , week , weekday , myaudittotalscore , active , auditnum , answer , quarter , y_n , region , district , audittype , status , keyedby , = questiondisplay , qtext , qdescr , answerdisplay , answertext , customauditnum , = dateaudittaken , datecompleted , dateauditkeyed , datekeyingcomplete , section , = createdby , division , auditscoredesc , locationnum , text_response , = Sum(questionpointsavailable) , Sum(pointsscored)

from viwAuditCube where clientnum =3D'RSI' =

GROUP BY audit, store, question, month, year, week, = weekday, myaudittotalscore, active, auditnum, answer, quarter, y_n, region, = district, audittype, status, keyedby, questiondisplay, qtext, qdescr, answerdisplay, = answertext, customauditnum, dateaudittaken, datecompleted, dateauditkeyed, datekeyingcomplete, = section, createdby, division, auditscoredesc, locationnum, text_response ORDER BY audit, = store, question, month, year, week, weekday, myaudittotalscore, active, = auditnum, answer, quarter, y_n, region, district, audittype, status, keyedby, = questiondisplay, qtext, qdescr, answerdisplay, answertext, customauditnum, = dateaudittaken, datecompleted, dateauditkeyed, datekeyingcomplete, section, createdby, division, = auditscoredesc, locationnum, text_response

 

 

Joel Fradkin

 

Wazagua, Inc.
2520 Trailmate Dr
Sarasota, Florida = 34243
Tel.  941-753-7111 ext 305

 

jfradkin@wazagua.com
www.wazagua.com
Powered by Wazagua
Providing you with the latest Web-based technology & advanced = tools.
© 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
 This email message is for the use of the intended recipient(s) and = may contain confidential and privileged information.  Any unauthorized = review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and delete = and destroy all copies of the original message, including = attachments.

 


 

 

------=_NextPart_000_005D_01C55D53.35BF10B0-- From pgsql-performance-owner@postgresql.org Fri May 20 16:57:42 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 21F1552854 for ; Fri, 20 May 2005 16:57:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72919-10 for ; Fri, 20 May 2005 19:57:32 +0000 (GMT) Received: from mta10.nationwireless.net (mta10.nationwireless.net [63.163.128.10]) by svr1.postgresql.org (Postfix) with ESMTP id 910FF52844 for ; Fri, 20 May 2005 16:57:31 -0300 (ADT) Received: from jfradkin [63.162.100.127] by mta10.nationwireless.net with ESMTP (SMTPD-8.20) id A14002B4; Fri, 20 May 2005 15:57:52 -0400 From: "Joel Fradkin" To: "PostgreSQL Perform" Subject: cant seem to post the explain Date: Fri, 20 May 2005 15:58:29 -0400 Message-ID: <006e01c55d76$4adf27f0$797ba8c0@jfradkin> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_006F_01C55D54.C3CD87F0" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.051 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE, MSGID_DOLLARS X-Spam-Level: ** X-Archive-Number: 200505/333 X-Sequence-Number: 12497 This is a multi-part message in MIME format. ------=_NextPart_000_006F_01C55D54.C3CD87F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Sorry I tried a few times to break this email up (guess there must be a = size limit?). Any one interested in seeing the explain for the speed of many group = by's question just email me. =20 Basically the sql is built by a dynamic cube product from data dynamics. I can edit it prior to it running, but it runs very slow even off the flattened file. I am guessing the product needs the data from the sql I supplied in = previous post. =20 I don't have any ideas to speed it up as I cant store an aggregate flat table without updating it when updates and inserts are made and that = would be too time consuming. Any ideas for how to approach getting the same data set in a faster = manner are greatly appreciated. =20 Joel Fradkin =20 =20 ------=_NextPart_000_006F_01C55D54.C3CD87F0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Sorry I tried a few times to break this email up = (guess there must be a size limit?).

Any one interested in seeing the explain for the = speed of many group by’s question just email me.

 

Basically the sql is built by a dynamic cube product = from data dynamics.

I can edit it prior to it running, but it runs very = slow even off the flattened file.

I am guessing the product needs the data from the sql = I supplied in previous post.

 

I don’t have any ideas to speed it up as I cant = store an aggregate flat table without updating it when updates and inserts are = made and that would be too time consuming.

Any ideas for how to approach getting the same data = set in a faster manner are greatly appreciated.

 

Joel Fradkin

 

 

------=_NextPart_000_006F_01C55D54.C3CD87F0-- From pgsql-performance-owner@postgresql.org Fri May 20 17:20:02 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 16B125284C for ; Fri, 20 May 2005 17:19:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82875-09 for ; Fri, 20 May 2005 20:19:56 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 0E19152844 for ; Fri, 20 May 2005 17:19:53 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id A88D71522D; Fri, 20 May 2005 15:20:17 -0500 (CDT) Date: Fri, 20 May 2005 15:20:17 -0500 From: "Jim C. Nasby" To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: Tuning planner cost estimates Message-ID: <20050520202017.GK44623@decibel.org> References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200505190931.47662.josh@agliodbs.com> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/334 X-Sequence-Number: 12498 On Thu, May 19, 2005 at 09:31:47AM -0700, Josh Berkus wrote: > > In the > > case of testing index scans, we need to be able to vary correlation, > > which so far I've been doing by ordering by different columns. I suspect > > it will also be important to test with different tuple sizes. There's > > also the question of whether or not the cache should be flushed for each > > run or not. > > > > Does this sound like a good way to determine actual costs for index > > scans (and hopefully other access methods in the future)? If so, what > > would be a good way to implement this? > > Well, the problem is that what we need to index scans is a formula, rather > than a graph. The usefulness of benchmarking index scan cost is so that we True, but having a graphical representation of how different input variables (such as correlation) affect runtime is a good way to derive such a formula, or at least point you in the right direction. > can test our formula for accuracy and precision. However, such a formula > *does* need to take into account concurrent activity, updates, etc ... that > is, it needs to approximately estimate the relative cost on a live database, > not a test one. Well, that raises an interesting issue, because AFAIK none of the cost estimate functions currently do that. Heck, AFAIK even the piggyback seqscan code doesn't take other seqscans into account. Another issue is: what state should the buffers/disk cache be in? In the thread that kicked all this off Tom noted that my results were skewed because of caching, so I changed my tests to flush the disk cache as effectively as I could (by running a program that would consume enough available memory to just start the box swapping), but I don't think that's necessarily realistic. Though at least it should preclude the need to run tests multiple times on an otherwise idle box in order to 'pre-seed' the cache (not that that's any more realistic). If you don't use one of these techniques you end up with results that depend on what test was run before the current one... > This is also going to be a moving target because Tom's in-memory-bitmapping > changes relative cost equations. I thought those all had seperate costing functions...? In any case, if we have a cost estimation tool it will make it much easier to derive cost estimation functions. > I think a first step would be, in fact, to develop a tool that allows us to > put EXPLAIN ANALYZE results in a database table. Without that, there is no > possibility of statistical-scale analysis. Rather than trying to parse all possible output, ISTM it would be much better if there was a way to access the info directly. Would it be difficult to have an option that produces output that is a set of different fields? I'm thinking something like: Level (basically how far something's indented) Parent node (what node a child node is feeding) node_id (some kind of identifier for each step) operation (estimate|actual)_(startup|total|rows|width|loops) other (something to hold index condition, filter, etc) But ultimately, I'm not sure if this is really required or not, because I don't see that we need to use explain when running queries. In fact, it's possibly desireable that we don't, because of the overhead it incurs. We would want to log an explain (maybe analyze) just to make sure we knew what the optimizer was doing, but I think we shouldn't need the info to produce cost estimates. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Fri May 20 17:47:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8D2C352844 for ; Fri, 20 May 2005 17:47:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90267-03 for ; Fri, 20 May 2005 20:47:19 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D3C305282B for ; Fri, 20 May 2005 17:47:18 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4KKldbT028983; Fri, 20 May 2005 16:47:39 -0400 (EDT) To: "Jim C. Nasby" Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: Tuning planner cost estimates In-reply-to: <20050520202017.GK44623@decibel.org> References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> <20050520202017.GK44623@decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Fri, 20 May 2005 15:20:17 -0500" Date: Fri, 20 May 2005 16:47:38 -0400 Message-ID: <28982.1116622058@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/335 X-Sequence-Number: 12499 "Jim C. Nasby" writes: > On Thu, May 19, 2005 at 09:31:47AM -0700, Josh Berkus wrote: >> can test our formula for accuracy and precision. However, such a formula >> *does* need to take into account concurrent activity, updates, etc ... that >> is, it needs to approximately estimate the relative cost on a live database, >> not a test one. > Well, that raises an interesting issue, because AFAIK none of the cost > estimate functions currently do that. I'm unconvinced that it'd be a good idea, either. People already complain that the planner's choices change when they ANALYZE; if the current load factor or something like that were to be taken into account then you'd *really* have a problem with irreproducible behavior. It might make sense to have something a bit more static, perhaps a GUC variable that says "plan on the assumption that there's X amount of concurrent activity". I'm not sure what scale to measure X on, nor exactly how this would factor into the estimates anyway --- but at least this approach would maintain reproducibility of behavior. > Another issue is: what state should the buffers/disk cache be in? The current cost models are all based on the assumption that every query starts from ground zero: nothing in cache. Which is pretty bogus in most real-world scenarios. We need to think about ways to tune that assumption, too. Maybe this is actually the same discussion, because certainly one of the main impacts of a concurrent environment is on what you can expect to find in cache. regards, tom lane From pgsql-performance-owner@postgresql.org Fri May 20 19:21:35 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 318B052830 for ; Fri, 20 May 2005 19:21:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08370-09 for ; Fri, 20 May 2005 22:21:28 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 8407452819 for ; Fri, 20 May 2005 19:21:26 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7387764; Fri, 20 May 2005 15:23:52 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Jim C. Nasby" Subject: Re: Tuning planner cost estimates Date: Fri, 20 May 2005 15:23:16 -0700 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> <20050520202017.GK44623@decibel.org> In-Reply-To: <20050520202017.GK44623@decibel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505201523.16437.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/336 X-Sequence-Number: 12500 Jim, > Well, that raises an interesting issue, because AFAIK none of the cost > estimate functions currently do that. Heck, AFAIK even the piggyback > seqscan code doesn't take other seqscans into account. Sure. But you're striving for greater accuracy, no? Actually, all that's really needed in the way of concurrent activity is a calculated factor that lets us know how likely a particular object is to be cached, either in the fs cache or the pg cache (with different factors for each presumably) based on history. Right now, that's based on estimated_cache_size, which is rather innacurate: a table which is queried once a month has the exact same cost factors as one which is queried every 2.1 seconds. This would mean an extra column in pg_stats I suppose. > But ultimately, I'm not sure if this is really required or not, because > I don't see that we need to use explain when running queries. In fact, > it's possibly desireable that we don't, because of the overhead it > incurs. We would want to log an explain (maybe analyze) just to make > sure we knew what the optimizer was doing, but I think we shouldn't need > the info to produce cost estimates. Well, the problem is that you need to know how much time the index scan took vs. other query steps. I don't see a way to do this other than an anayze. -- __Aglio Database Solutions_______________ Josh Berkus Consultant josh@agliodbs.com www.agliodbs.com Ph: 415-752-2500 Fax: 415-752-2387 2166 Hayes Suite 200 San Francisco, CA From pgsql-performance-owner@postgresql.org Fri May 20 19:40:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4AB8952867 for ; Fri, 20 May 2005 19:40:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13863-10 for ; Fri, 20 May 2005 22:40:33 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 8A8FB5285B for ; Fri, 20 May 2005 19:40:30 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id B1F041522D; Fri, 20 May 2005 17:40:55 -0500 (CDT) Date: Fri, 20 May 2005 17:40:55 -0500 From: "Jim C. Nasby" To: Tom Lane Cc: Josh Berkus , pgsql-performance@postgresql.org, testperf-general@pgfoundry.org Subject: Re: Tuning planner cost estimates Message-ID: <20050520224055.GM44623@decibel.org> References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> <20050520202017.GK44623@decibel.org> <28982.1116622058@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28982.1116622058@sss.pgh.pa.us> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/337 X-Sequence-Number: 12501 On Fri, May 20, 2005 at 04:47:38PM -0400, Tom Lane wrote: > "Jim C. Nasby" writes: > > On Thu, May 19, 2005 at 09:31:47AM -0700, Josh Berkus wrote: > >> can test our formula for accuracy and precision. However, such a formula > >> *does* need to take into account concurrent activity, updates, etc ... that > >> is, it needs to approximately estimate the relative cost on a live database, > >> not a test one. > > > Well, that raises an interesting issue, because AFAIK none of the cost > > estimate functions currently do that. > > I'm unconvinced that it'd be a good idea, either. People already > complain that the planner's choices change when they ANALYZE; if the > current load factor or something like that were to be taken into account > then you'd *really* have a problem with irreproducible behavior. > > It might make sense to have something a bit more static, perhaps a GUC > variable that says "plan on the assumption that there's X amount of > concurrent activity". I'm not sure what scale to measure X on, nor > exactly how this would factor into the estimates anyway --- but at least > this approach would maintain reproducibility of behavior. Or allowing the load of the machine to affect query plans dynamically is something that could be disabled by default, so presumably if you turn it on it means you know what you're doing. Of course this is all academic until we have a means to actually measure how much system load affects the different things we estimate cost for, and I don't see that happening until we have a system for measuring how changing different input variables affects costs. > > Another issue is: what state should the buffers/disk cache be in? > > The current cost models are all based on the assumption that every query > starts from ground zero: nothing in cache. Which is pretty bogus in > most real-world scenarios. We need to think about ways to tune that > assumption, too. Maybe this is actually the same discussion, because > certainly one of the main impacts of a concurrent environment is on what > you can expect to find in cache. Well, load doesn't directly effect cache efficiency; it's really a question of the ratios of how often different things in the database are accessed. If you wanted to get a crude idea of how likely pages from some relation are to be in cache, you could take periodic snapshots of io stats and see what percentage of the IO done in a given time period was on the relation you're interested in as compared to the rest of the database. But I think this is probably still a 2nd order effect. In terms of a testing system, here's what I'm thinking of. For each cost estimate, there will be a number of input variables we want to vary, and then check to see how changes in them effect run time. Using index scan as a simple example, 1st order variables will likely be index and table size (especially in relation to cache size), and correlation. So, we need some kind of a test harness that can vary these variables (prefferably one at a time), and run a test case after each change. It would then need to store the timing info, possibly along with other information (such as explain output). If I'm the one to write this it'll end up in perl, since that's the only language I know that would be able to accomplish this. DBT seems to be a reasonable test database to do this testing with, especially since it would provide a ready means to provide external load. Does this sound like a reasonable approach? Also, how important do people think it is to use explain analyze output instead of just doing SELECT count(*) FROM (query you actually want to test)? (The select count(*) wrapper is just a means to throw away the results since we don't really want to worry about data transfer times, etc). The testing I've done (http://stats.distributed.net/~decibel/base.log) shows explain analyze to be almost 5x slower than select count(*), so it seems a big gain if we can avoid that. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Fri May 20 19:48:55 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 931FE52867 for ; Fri, 20 May 2005 19:48:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15031-05 for ; Fri, 20 May 2005 22:48:52 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 2650652819 for ; Fri, 20 May 2005 19:48:51 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 948481522D; Fri, 20 May 2005 17:49:17 -0500 (CDT) Date: Fri, 20 May 2005 17:49:17 -0500 From: "Jim C. Nasby" To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: Tuning planner cost estimates Message-ID: <20050520224917.GN44623@decibel.org> References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> <20050520202017.GK44623@decibel.org> <200505201523.16437.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200505201523.16437.josh@agliodbs.com> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/338 X-Sequence-Number: 12502 On Fri, May 20, 2005 at 03:23:16PM -0700, Josh Berkus wrote: > Jim, > > > Well, that raises an interesting issue, because AFAIK none of the cost > > estimate functions currently do that. Heck, AFAIK even the piggyback > > seqscan code doesn't take other seqscans into account. > > Sure. But you're striving for greater accuracy, no? > > Actually, all that's really needed in the way of concurrent activity is a > calculated factor that lets us know how likely a particular object is to be > cached, either in the fs cache or the pg cache (with different factors for > each presumably) based on history. Right now, that's based on > estimated_cache_size, which is rather innacurate: a table which is queried > once a month has the exact same cost factors as one which is queried every > 2.1 seconds. This would mean an extra column in pg_stats I suppose. True, though that's a somewhat different issue that what the load on the box is (see the reply I just posted). Load on the box (particuarly IO load) will also play a factor for things; for example, it probably means seqscans end up costing a lot more than random IO does, because the disk heads are being sent all over the place anyway. > > But ultimately, I'm not sure if this is really required or not, because > > I don't see that we need to use explain when running queries. In fact, > > it's possibly desireable that we don't, because of the overhead it > > incurs. We would want to log an explain (maybe analyze) just to make > > sure we knew what the optimizer was doing, but I think we shouldn't need > > the info to produce cost estimates. > > Well, the problem is that you need to know how much time the index scan took > vs. other query steps. I don't see a way to do this other than an anayze. True, but that can be done by a seperate seqscan step. I would argue that doing it that way is actually more accurate, because the overhead of explain analyze is huge and tends to swamp other factors out. As I mentioned in my other email, my tests show explain analyze select * from table is 5x slower than select count(*) from table. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Fri May 20 20:06:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5270352868 for ; Fri, 20 May 2005 20:06:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20885-07 for ; Fri, 20 May 2005 23:06:32 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id AAD3852859 for ; Fri, 20 May 2005 20:06:30 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4KN6pMx004416; Fri, 20 May 2005 19:06:51 -0400 (EDT) To: "Jim C. Nasby" Cc: Josh Berkus , pgsql-performance@postgresql.org, testperf-general@pgfoundry.org Subject: Re: Tuning planner cost estimates In-reply-to: <20050520224055.GM44623@decibel.org> References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> <20050520202017.GK44623@decibel.org> <28982.1116622058@sss.pgh.pa.us> <20050520224055.GM44623@decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Fri, 20 May 2005 17:40:55 -0500" Date: Fri, 20 May 2005 19:06:51 -0400 Message-ID: <4415.1116630411@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/339 X-Sequence-Number: 12503 "Jim C. Nasby" writes: > Does this sound like a reasonable approach? Also, how important do > people think it is to use explain analyze output instead of just doing > SELECT count(*) FROM (query you actually want to test)? (The select > count(*) wrapper is just a means to throw away the results since we > don't really want to worry about data transfer times, etc). The testing > I've done (http://stats.distributed.net/~decibel/base.log) shows explain > analyze to be almost 5x slower than select count(*), so it seems a big > gain if we can avoid that. I'd go with the select count(*) --- I can't imagine that we will be trying to model the behavior of anything so complex that we really need explain analyze output. (On the other hand, recording explain output is a good idea to make sure you are testing what you think you are testing.) Actually, it might be worth using "select count(null)", which should avoid the calls to int8inc. I think this doesn't matter so much in CVS tip, but certainly in existing releases the palloc overhead involved is noticeable. BTW, 5x is an awful lot; I've not noticed overheads more than about 2x. regards, tom lane From pgsql-benchmarks-owner@postgresql.org Sat May 21 04:41:37 2005 X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BD38E52876 for ; Sat, 21 May 2005 04:41:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75216-02 for ; Sat, 21 May 2005 07:41:28 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id D70835289D for ; Sat, 21 May 2005 04:41:27 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 3F93930952; Sat, 21 May 2005 09:39:08 +0200 (MET DST) From: Tomaz Borstnar X-Newsgroups: pgsql.benchmarks Subject: Re: Error when try installing pgbench ? Date: Sat, 21 May 2005 09:42:00 +0200 Organization: Hub.Org Networking Services Lines: 1 Message-ID: References: <20050515093707.24005.qmail@web32011.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en In-Reply-To: <20050515093707.24005.qmail@web32011.mail.mud.yahoo.com> To: pgsql-benchmarks@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/2 X-Sequence-Number: 46 you need to use gmake perhaps? From pgsql-performance-owner@postgresql.org Sat May 21 12:16:09 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F2BE52861 for ; Sat, 21 May 2005 12:16:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64919-10 for ; Sat, 21 May 2005 15:16:01 +0000 (GMT) Received: from smtp-out3.blueyonder.co.uk (smtp-out3.blueyonder.co.uk [195.188.213.6]) by svr1.postgresql.org (Postfix) with ESMTP id 4A3B752859 for ; Sat, 21 May 2005 12:15:59 -0300 (ADT) Received: from [192.168.1.10] ([82.43.93.192]) by smtp-out3.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Sat, 21 May 2005 16:17:10 +0100 In-Reply-To: <428D4146.6000203@familyhealth.com.au> References: <428D1153.1020109@rueb.com> <428D4146.6000203@familyhealth.com.au> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <803159ED-9B03-43E0-ACE6-DC40E73D55C1@advfn.com> Cc: Steve Bergman , pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Optimizing for writes. Data integrity not critical Date: Sat, 21 May 2005 16:16:30 +0100 To: Christopher Kings-Lynne X-Mailer: Apple Mail (2.730) X-OriginalArrivalTime: 21 May 2005 15:17:11.0015 (UTC) FILETIME=[2901FF70:01C55E18] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/340 X-Sequence-Number: 12504 Is using a ramdisk in situations like this entirely ill-advised then? When data integrity isn't a huge issue and you really need good write performance it seems like it wouldn't hurt too much. Unless I am missing something? On 20 May 2005, at 02:45, Christopher Kings-Lynne wrote: >> I'm doing the writes individually. Is there a better way? >> Combining them all into a transaction or something? >> > > Use COPY of course :) > > Or at worst bundle 1000 inserts at a time in a transation... > > And if you seriously do not care about your data at all, set fsync > = off in you postgresql.conf for a mega speedup. > > Chris > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to > majordomo@postgresql.org > > From pgsql-performance-owner@postgresql.org Sat May 21 14:26:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1862352854 for ; Sat, 21 May 2005 14:26:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02221-05 for ; Sat, 21 May 2005 17:26:51 +0000 (GMT) Received: from smtp-out1.blueyonder.co.uk (smtp-out1.blueyonder.co.uk [195.188.213.4]) by svr1.postgresql.org (Postfix) with ESMTP id C878A52844 for ; Sat, 21 May 2005 14:26:48 -0300 (ADT) Received: from [192.168.1.10] ([82.43.93.192]) by smtp-out1.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Sat, 21 May 2005 18:28:00 +0100 In-Reply-To: <428D1153.1020109@rueb.com> References: <428D1153.1020109@rueb.com> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <9040B971-3565-40F8-9CEC-62995B70052C@advfn.com> Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Alex Stapleton Subject: Re: Optimizing for writes. Data integrity not critical Date: Sat, 21 May 2005 18:27:18 +0100 To: Steve Bergman X-Mailer: Apple Mail (2.730) X-OriginalArrivalTime: 21 May 2005 17:28:01.0600 (UTC) FILETIME=[70523400:01C55E2A] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/341 X-Sequence-Number: 12505 I am interested in optimising write performance as well, the machine I am testing on is maxing out around 450 UPDATEs a second which is quite quick I suppose. I haven't tried turning fsync off yet. The table has...a lot of indices as well. They are mostly pretty simple partial indexes though. I would usually just shuv stuff into memcached, but I need to store and sort (in realtime) 10's of thousands of rows. (I am experimenting with replacing some in house toplist generating stuff with a PG database.) The partial indexes are basically the only thing which makes the table usable btw. The read performance is pretty damn good, but for some reason I chose to wrote the benchmark script in PHP, which can totally destroy the accuracy of your results if you decide to call pg_fetch_*(), even pg_affected_rows() can skew things significantly. So any ideas how to improve the number of writes I can do a second? The existing system sorts everything by the desired column when a request is made, and the data it sorts is updated in realtime (whilst it isn't being sorted.) And it can sustain the read/write load (to memory) just fine. If I PG had heap tables this would probably not be a problem at all, but it does, so it is. Running it in a ramdisk would be acceptable, it's just annoying to create the db everytime the machine goes down. And having to run the entire PG instance off of the ramdisk isn't great either. On 19 May 2005, at 23:21, Steve Bergman wrote: > Hi, > > I am using postgresql in small (almost trivial) application in > which I pull some data out of a Cobol C/ISAM file and write it into > a pgsl table. My users can then use the data however they want by > interfacing to the data from OpenOffice.org. > > The amount of data written is about 60MB and takes a few minutes on > a 1200Mhz Athlon with a single 60MB IDE drive running Fedora Core 3 > with pgsql 7.4.7. I'd like to speed up the DB writes a bit if > possible. Data integrity is not at all critical as the database > gets dropped, created, and populated immediately before each use. > Filesystem is ext3, data=ordered and I need to keep it that way as > there is other data in the filesystem that I do care about. I have > not done any tuning in the config file yet, and was wondering what > things would likely speed up writes in this situation. > > I'm doing the writes individually. Is there a better way? > Combining them all into a transaction or something? > > Thanks, > Steve Bergman > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend > > From pgsql-performance-owner@postgresql.org Mon May 23 14:41:52 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5B937528B6 for ; Mon, 23 May 2005 14:41:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54789-09 for ; Mon, 23 May 2005 17:41:32 +0000 (GMT) Received: from apate.telenet-ops.be (apate.telenet-ops.be [195.130.132.57]) by svr1.postgresql.org (Postfix) with ESMTP id 4C45852879 for ; Mon, 23 May 2005 14:41:30 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by apate.telenet-ops.be (Postfix) with SMTP id BBE8E3828D for ; Mon, 23 May 2005 19:41:30 +0200 (CEST) Received: from [10.0.1.11] (d5152B1F3.access.telenet.be [81.82.177.243]) by apate.telenet-ops.be (Postfix) with ESMTP id E9D7C38460 for ; Mon, 23 May 2005 19:41:27 +0200 (CEST) Mime-Version: 1.0 (Apple Message framework v622) To: pgsql-performance@postgresql.org Message-Id: <6d31bed04ab35cbbe2df37af979d9882@implements.be> Content-Type: multipart/mixed; boundary=Apple-Mail-152--1023557083 From: Yves Vindevogel Subject: Fwd: Index on table when using DESC clause Date: Mon, 23 May 2005 19:41:19 +0200 X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/342 X-Sequence-Number: 12506 --Apple-Mail-152--1023557083 Content-Type: multipart/alternative; boundary=Apple-Mail-153--1023557083 --Apple-Mail-153--1023557083 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed Begin forwarded message: > From: Yves Vindevogel > Date: Mon 23 May 2005 19:23:16 CEST > To: pgsql-performance-owner@postgresql.org > Subject: Index on table when using DESC clause > > Hi, > > I have a table with multiple fields. Two of them are documentname and=20= > pages > I have indexes on documentname and on pages, and one extra on=20 > documentname + pages > > However, when I query my db using for instance order by pages,=20 > documentname, it is very fast. > If I use order by pages desc, documentname, it is not fast at all,=20= > like it is not using the index properly at all. > > How can I avoid this ? > > Met vriendelijke groeten, > Bien =E0 vous, > Kind regards, > > Yves Vindevogel > Implements > --Apple-Mail-153--1023557083 Content-Transfer-Encoding: quoted-printable Content-Type: text/enriched; charset=ISO-8859-1 Begin forwarded message: 0000,0000,0000From: Yves Vindevogel < 0000,0000,0000Date: Mon 23 May 2005 19:23:16 CEST 0000,0000,0000To: pgsql-performance-owner@postgresql.org 0000,0000,0000Subject: Index on table when using DESC clause Hi, I have a table with multiple fields. Two of them are documentname and pages I have indexes on documentname and on pages, and one extra on documentname + pages However, when I query my db using for instance order by pages, documentname, it is very fast. If I use order by pages desc, documentname, it is not fast at all, like it is not using the index properly at all. How can I avoid this ? Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements = --Apple-Mail-153--1023557083-- --Apple-Mail-152--1023557083 Content-Transfer-Encoding: base64 Content-Type: image/tiff; x-unix-mode=0666; name="Pasted Graphic 2.tiff" Content-Disposition: inline; filename="Pasted Graphic 2.tiff" TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+FP5+v9rOh5P9IMBuP8zK9tP8fJNlP8QoNjP8FndhP 8MnyVjJHSMrqFnv9BL1vP9ett2v98PuJxChUOiUWGQOCUalUujOV4PZ/qBluR/mdVtJ/jVHst/ho 9MF/g08WABHJfv8AWa0WoAHFfWuzgg6sB/hY9ysUohjv8qqVqv9LMZxv9ouV40zEYmHUjFY2HPx+ RNtOl4Rhftt/phiRs6LC/iA5LewnJeWg46W22+02cAHOwa26bC0HPY7TZ7G2G9dv8EHFdP8Om9YP 8rKJov9UtFzv9Dzh/sRvu5/vZ9PzHdeF4zsUqgQRlOR5v9DMBwv8uqe/jZIVwNHu6B0/WAKHvWGr RAA1ra0G1c/vfgANrdraXrTQIAA6JW2TUrQNz/ja0oAjO4YAjSWS0DOWawjys4RkIk4Lj2sAWEUZ B/ieUJqH+PZdnAf5aG06R5nsfLtqW7UaoWZJwukwLyi4VRsn+F5HGYf8QJWBQ7JWAI5tYti2Dm1T bQHAq0De1Q2FwtA1Fof4AjVDIBDQV0vDQWK0DY/oADYWsrNQN81NOuDZtYOM6ycs4Cjq+Q9JWE5D pGJpOpqP5dMwW5sHUf53xlHCExupjqoIbh3Hu55vp6ch3Hof4wlMrAdEWYh/gmP1RtXK0DDi2rXy nVzXjpVs8NM1g1vuNU2gANEugGMBRwu4YADTNsvwyAA3v+0k6LRWLb2dBUpjk2I4NVOx/gYPC6BU QiwCgSsSlWZpxH+ahzsOaBzvCe7qoMpKlUghd1n2f5oHId5/lQaJ0n+RBf3GLpUGwf4iksrg0FVF ICzlXT9QBB0tWO/+FjlKVWtfijTNRBsvDbhrdP3NUAwY38KFfkc0PuNjRWLLz8ytiTUVdVlnjlA2 MWPAWRAAM8LAAMjhhuR5ir4ULjigT5pn+P5co2T6pn+YBup6dp6xoh6kHie95modNOFkah0H+Qhd pyKBNmcf68r2Bo9GGtdpwIAUotM1Q4QMNzUDZhuVZbLsvy7KkqZZCnAb4AFcQY1C3LW1Wb5lOa2t ZvUt78NNjcMN83wEOMDczvuTzXNQ3QEN01WRL2b8XBYEDuugQEFUYgkpIo5FjIJTmhfZkHG8J0nm fB/sifp/EQYLBioUKsBkRKVgWPLX7stA4VnaDa+tZlZel0j+gCMpWS8MRULQNeIDY/4zTIAIyFX0 GFybZnr+rZ8p2a1s6tUNfADXXI1Yb8jLX+MNQk+1Az7zWqwVa/FaJrHpvSLeAQOhdE/l7CSJwrAb BXDXH+PkyA/gUiPGaftASWW6JeDgnGAsCmLNvcYqlz5+FchnZMrqGbeE3JoYhAMAKbEvOGeigtaE CDZwJcgxtiML0uMgQYzllKt2GhtP/EaH6cgAm+fnCtVEVXFOKNU54AC1B/tyLfBx4YJBGwhAAG5m yUoGH/TgxlZ7nGXw3YdEpYTPWOvaSq/JVEX28rEDQsGKDoGPx+QYnE1URg2paZY4dy7EHTx9cc41 upqIfwkjSgJWyW0MgBdK9I1DGAAwnS8G8+4cGYyUWWbKMg/gSiOjQG+FMQ44qqlmgBNUSYYMohKW 2ULFZaR8NdMFucoz/w/ZcAAMzgH+j/AKGV8QAZkhmWNM0AJ/I5zCiJEGYjF1qoGmxI5MqwT7JVlG buLULJhPXlbK+WMt3HwHmIbF8xaA0n6mvPgN7EJhx9Vcax+hsX6wGZuldNDnTSgQDoloGohS6BYE 62gPQqyRhlFE2gIYkCRgdD4WcAUsnxvlYklKgUCn4upi29JkkpG/pbYgtKbr86TLOnbLCF066ZLP kGsI+7NY9rRjZHB+0ew4M5S0AKT4FA8l0BaIUk4XHkj/EYLwzAtVyj/GwRYf49B8D6H+OMdw9R/j DG8vcTgx1xhpFTBoHYilRgaDygQAobXCynVVSSVdRYTLJls5CcIaqX0zpw/Kms76c2DSnTsNNPaA TbpggqOSCg4MkQwcAPiBAzimJqI4Xg3R/itX0P8bY66xD7MiYkgg5h4vAF2NgdY/xNGCH+HQVMIQ WiCNVM2L6Ap4s3ShFixMubA2HnjcUulhab3GuIbGxVjLlxXZoawMKFgsCiaSOUd6nB6XbH+PofKN LtqcH7eMf5AyimQOtegf4/TIEFvYP8dyjTm2eV1KdmNgrlIKr/cOxF+LjmRldTZY88L/U6P/YtyF +b82PDAhkOQsyNkHu8jS76NB4YXH+PvDUG7v3lIFeu8mFbuj6q8PXE2HEaXqIEUEgxnh2T2YhD/B WBZcUunVjO59yMB3PsHc3BONLemxwaP8NwsTMEPvVeMieJKvXmHZk8f48h5GHyYP8e+V3g3tvMQs VY01FLCxjgTHk8b943yBTOVoJEiXJzPgae1zr+2HwYhnIuRzrjczwP8eY8zDmKy7l8NOYcx40zKW nNswizytg+kXHc/qS48x9o7QbNMhZ0yMdvPBG7wmNz/jB6WYs436uFmbHhbFrAFgjhl4Y/g5IvH+ 0EkYFw+NuAHqmoet9bWJwPnDHEfM55E0udjTNW7uZ+y9p6L+oNe3Bxtoa4lACzgQee2kQ5Jwo1RK QPQfK8xejaJ6FG6w/wEh1NZJ+L6ydoH+zfqTUK0dK7AzsY7Yem9jaA0Fu2wVf9eJObqW+TxuwbCS K4JEYVnh2O/vWQM5K+wtCehCCAP5YABybV035xCAJIJqnrTyFqB9H8e1Lu/OumM870MTp3MGn9J8 g5Zsxhk2ZURLfGmrBAEg5m/CISIf4jRekblaCgRoyS0BjWNZVw6uZ70hnsrkND/Fbn3kWWtmz1ID a5NxyLYJ1xujdI3iZTm9dkYy4/P9yFKIcFoDQsbtKW4nT2YbLrpr450V6zTGem7N+YzXVzDZ0PSl ddIb8GQVrlD9sQjy4FKHVy0ZDDeLHCPWuuD/68Y0Vg1LX8c0bQSBiAq9JrVv2pYwZkzq6mqxDi8y XJgBkjZGftMMdUgm5PKyCBnogBI72hYgZlgrD6WWgMzPZkxGdUzfIfIzsdb66PXr/Jxp+XwRGlOL GnuJm2b0l7vo/dJeDL4N7qwWN+qn5CqedNMATuzZmObaad1s4dBMl/6wmG/Pt1+oAAYk2hToiuQc 5FxyjyRoHqH0xYKE+Q8k+UIgH0KAH+HSHqXmGwHSIuEGF0I25eWE8A96/g2akwhIk8Puf25mpi3w /IeG/M8y0O10/WgM3cpUS8l0mS+ocOYgDQS0ASDUTOB6EaJWDkXyXwFyL+GqGkPKHQHMOkxIXmIO HAHAJyyuKgvGIIHgU2H+G0GuHKH+FwF6KwEAtAH+CUEcLOAiNC2QnKcOZSZCmO9ongNep2sA3Y2W nY/KwE9hDazc8w8Sug9mh6cAZ0/UAEC0FKH+AOCOEoJQBeD8H+A2A+DYYGBuD2H+D6DmFCH+F0Fq hDB+PKGcGaaSGsGmJyGOGGg0EuEgP0CqCOEOH+BIA+DQH+AgBSDrD+CAEcH+AICwFNA+pamupfDQ /G1E2asfDksJDesNBCv012x+5WDmQSseeiAaCGEiH+BEAmC0H+A8AcCyH+A4AXGqAqAOCsLqAQCw H+BMAuDIH+CJEWPMCpFKCaCEEASEBFESA2AaC2H+AoAOCqK6AVGqA8AYCvGcAiC9HmBlHZBglBDt F80LF7BNDdBHDg2U0JGI0lGEseWsAgB6EYH+BUAkC4H+BKAuDDGcArH+BCAnH+A8AeC6K7HjG7H4 AoANHtG1G4A1GxGkAfHkBAAjJOBCAqC/FMAuDAH+BOApJ8A0BYDy2aWtGEzI1G2dKRIUwDGDF9BP DooBISnVImB9IsBRJHI2AuDHK3HHI4DFK3K6BGArI8BAAlJ8A8AhJqAlJxJBK3LDLBK9LmBNKCH+ AwBZEZIGcjGM3zKVIRL7BEH8zVKfKojrKlMCQVIk2jKuH/KzH/I5K7MjLFMpMnI5HGBIAvG/I5J9 MvMrK5M/K7LrJ9LxL1DXL5KYp1L/MM80g2wABMzWAGjVDZIc/XDrIiNjKtKxK1MtNBN7MlN9HFJ5 M3J7NDONMnNHLvLzKNKnMS5dNPMAsGpgLKLoAQNswAH8EAGAXGB0EobQAwEEJOblOa1uzJIfNvF9 MXFVMbMfOPODOBOBMxM1K3M7PfPdNFLtNLOZOcfjIOgVPIfeAaD2VGBUEY6ECyFQL+awXWH+HCHa KgW+KoAqDsPu3Mt8rxMO+fOjPTNzMZN3MhPtN/M/PlOJPrPhPvHBPzOXL3KPKhP69Mv4SmYWWs4m QyDGFUGsH+GeHEOkHW204SIED6FmaSBqeZHmQ3Fikw7iPwZWkCSs40Yg0CwTQAxpPUAhPZN5RDS1 PjOHPpRRRFOTP1RZSo5W1skw6MDa6g5omYZW94AYDkN+BOD+NKCoE6SKHy1WA8EOL2Z8cuhGTU/f SlArAu95L2cmiO1xSrQ7PXQ/S/S1RJS9RFUlNBTDRXNPRavw3St25kTXBiQsADBfUFNO/fUC6K+A N+9fTI2SkOfG6YmY9MZWDEFS+0TInFUQSfPI1NQ9MdSzRPUnS5MzRLUdRPUqD02RRaeoseDdSaQn ScQi9G/kPu+e/o+E8UQUoGv/IXMKsOfqZu8O/eV2S89E7QZ7XG8w/edGQYxiTeoSB3FKBQAlRBV9 S3LnWDUjXpN7LCBOAnJ8AyBXKKV0Z7KPKO6i764rXI9wS8DJVq6TAw+hP5MFBJDi0Ofq0i86mQPv XMDRWlBi6QVy6iAYCUEuJIBDESBGA0DNI2AxLjRCAxS4BGAvH5I5J2BLZdZVV9ZtZqDKJIA+DUH+ AiB4ES2a4pDFDE+fVIkg84ZylyTUn7RdYjIZYhQy14fipY9SDTWhSjRg6UAEC+fZGWEfEMBCDbFM AtJ9MzI9LlM8BFZjJ5ZpNBMzLCBJLKH+A+A3ZSAiByEMmcC0FO7Q7eTVSW+ectBY9HQ2oFDTNXak Ns9fIa0hPPVUfqfq5i3OjohIAEC6fYAWB6ERFUBSDxLuAtZSA7JSA/JoH/LPH+BIAtK7bZG4BGAt JCApH+A+AhJPGnJOA0AfH+AiBIDoWuBzc6AICvD8PxUAWJWWj2sfWwsPP9cXWzKc/PGE0jPQvwiE 9kWsAeB+EVI2AaCpdQAbGjGnHkA4AbJPHhI0A2AZI0A6AdI1drG+A6AfG/HhGjfVI1fLfJGpfBGq BGAZHsAvKJA+j7eZencVNSlZGBelINchalStIqbTV7J5I8BDLtdrJPfLfSAZHkA2AXfPfXENJTfl JrK0BFdjMoBOArX7UsYhUxaledgRcZgVBLMTepVU17StSxXlMrZzbgAtLDgrdoAlGiBBK1dhZZLi AxK/OFORRVNNhbhu0PhhafgTW1gXilgbgRhzUbV/OOAwDPFMAxe/ZrPriXXnWJidP3hiuZgPiphk eGA8EUJGWEc3MNhtgdUXSvi5XxS1Z3Zhe/MzbfjNRRUrieVpeejtOg0OseDeNYQexAIEE4GcX2B4 EkRKAMDsNjXSTWcVVVjvi1jzh1WHM/j8AvkAAvkFlHkLjVjdjZF4pPk0nANKLKQIBCESL2D6F6XG XgvWqwHQMqEsGIRaL6RSAgD6bcQAbyNRBkLQDCWNhdNxkPj1V5h3i7N7lLlPlTmtUpjTTHak1tUE DHDyQMDWN+ggQIByEiJOEGOcGIG8Okq7CMXay2KMG8HaU4rcMGCIE8aSBcEWL2Ci4ccggbKXhxlD j3jPPdmxbdLnm3PxNJhZkO1CseseDUNKBIEMJWB8EqhCBqEuGgH+DiFiL+GXQcINAEIhl4McIkXc IICurWWuDulCNiDW85VVi3mplHmuH/j/oZM9odRTohkNNQnjYIc6QIAILmH+BgEOLOtabCUcIPpV qiIOHMKeOQGoJ6C+FaMwAuEJT474DYTfliJQrbgjmrj5OBoXkDobrTJ/LsArX+LQDI72nBlkJQLv C2FBpAEoGOMGGhqsvKH7nlqpqlnpsKKMHgJ+tgGQPKCmFIaSAwD8LOA4EGJWBiCdEFH1G/iPp0Av rXlRrboTdXLDdrI0BSBkD4H/n8JOAkD7o0EwhCECF+PKG6HceBsQRtsPtyOuq4/+22RcFYJGBkBK Ddp4AtI8A2AdHkA/H9uPZZrVp5lNp9OFMzK7iLJ9HhHlgrJ8BSA3FSEWECe+vNsVnkXdt4MVqnvR qiHmHkKgF+F0JqEMD8fECQB4D7uPI8AyAZGjubJ8BAAqClbqAng4AbfZdsKyBTuMDiDOE2H+FmFe JGHMU1vXwrvVwrwxCKagF3pADyDiFEH+CWCAEHJ+A3G4B+BmDmH+DQC7EEFGE4NKHYHUXvwxxqIj t3xtxyIaw0ImGwGus8HgUZx1yGavxxyJyPyRySKIKQFuFibQGOGEYFyVynypymKQCaB/xIDkDOE8 IQFSFEVGE+EsQIIWGEF4L+EwEeP6IOE4EoN2DOC0ErpCDLy6DYDAEyH+FiFU6EHyq6H+DqDUFAH+ G4GwOWIWw0IIEMD68HzsE0H+DgDIE4H+DaDD0cG8G4X2FgFS6EFGE2LAIWG0GsHMH+EoEWTaIOFn uEH+DKCzzkDjzoH+DJ1aH+FuFgbRsGIIEKD2fZyCrEIOGUGMI2E8EqNLz6XmDsDXEgDUC6EwH+DW C9zx1ZzkF4FuOOHUq0D8Dnb8DeDHwd0h0kEeEKQsKQCkCLFKDv2SIQD6DkFJENg2H/ygYFxkPCBu BQDkH+CwCXIsIOCiCJb2CQB0D+H+FEE0LoEYEGTOCgCGEKH/2uMrGfI8GEF7RyIWHwOoH+CEBptU EaEITOFCEyLOF0FoJr16aUDpb9fbH+GAF0RSz2KgCABjdACSB4ED3V3YH+C8CjbCFAEwLP006EG8 G2X35LbnK6B/5iH+GcGSs8FoFehCC0CYEavXAT5WRSDyDdxACKBtvwFwFkJqHEHAUVxeLACSB3HZ 2GNKEyEgP6EsEaNEKQCn3MH+DuDZEgIOEUEAZMDuDbxB7jFL5zbCDQC2Et2cC/zwIP8AH+BoBKDf 1iCxEEC4CfFgEqEYNFCeU4BWA2DSXIGgXGIWu+XmCQB35r2R0EEgEOQyIWEOD88GECDvVmCyCZIs DACpGaE0EkN+DP8GIQEGDyFUH/3LFL0Ue+HkHh18IMHPwoCqCRe54ILoCMBvEKC6Cl8CC18IIWFa FKL2DGCtEEIXE0MH2+H+EKD4fZ10fZ374Z7h7l7p7sIMEF9eRd6d1p1t4H4L/ohCDECsEkIQIAVC MiX+dTUoH++n0/X++4W/4hEHe7Xo/xQGTO/zQXEu/0Cd1S/0Yglg/3g73q/yWPUE/zsa1C/0IeVW /0GeFU/3G4Xa/0MfVY/1or2bQlbRUiiVpJpQ/y+U0jEYggzzOSkRUM/0KfJqfzop3+p1Aw3+53I7 n+UCJWak3m26H+OxYdX+Xiij6leVRY3+YKheaks1Yy3+VCPBEIe5zM5qOxbdICAADgEAAAMAAAAB ADgAAAEBAAMAAAABAEAAAAECAAMAAAAEAAAWdgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQA AAABAAAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA CAAK/IAAACcQAAr8gAAAJxA= --Apple-Mail-152--1023557083 Content-Type: multipart/alternative; boundary=Apple-Mail-154--1023557082 --Apple-Mail-154--1023557082 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > > Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 > > Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 > > Web: http://www.implements.be > > First they ignore you. Then they laugh at you. Then they fight you. =20= > Then you win. > Mahatma Ghandi. Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements --Apple-Mail-154--1023557082 Content-Transfer-Encoding: quoted-printable Content-Type: text/enriched; charset=ISO-8859-1 Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you.=20 Then you win. Mahatma Ghandi. Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements = --Apple-Mail-154--1023557082-- --Apple-Mail-152--1023557083 Content-Transfer-Encoding: base64 Content-Type: image/tiff; x-unix-mode=0666; name="Pasted Graphic 2.tiff" Content-Disposition: inline; filename="Pasted Graphic 2.tiff" TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+FP5+v9rOh5P9IMBuP8zK9tP8fJNlP8QoNjP8FndhP 8MnyVjJHSMrqFnv9BL1vP9ett2v98PuJxChUOiUWGQOCUalUujOV4PZ/qBluR/mdVtJ/jVHst/ho 9MF/g08WABHJfv8AWa0WoAHFfWuzgg6sB/hY9ysUohjv8qqVqv9LMZxv9ouV40zEYmHUjFY2HPx+ RNtOl4Rhftt/phiRs6LC/iA5LewnJeWg46W22+02cAHOwa26bC0HPY7TZ7G2G9dv8EHFdP8Om9YP 8rKJov9UtFzv9Dzh/sRvu5/vZ9PzHdeF4zsUqgQRlOR5v9DMBwv8uqe/jZIVwNHu6B0/WAKHvWGr RAA1ra0G1c/vfgANrdraXrTQIAA6JW2TUrQNz/ja0oAjO4YAjSWS0DOWawjys4RkIk4Lj2sAWEUZ B/ieUJqH+PZdnAf5aG06R5nsfLtqW7UaoWZJwukwLyi4VRsn+F5HGYf8QJWBQ7JWAI5tYti2Dm1T bQHAq0De1Q2FwtA1Fof4AjVDIBDQV0vDQWK0DY/oADYWsrNQN81NOuDZtYOM6ycs4Cjq+Q9JWE5D pGJpOpqP5dMwW5sHUf53xlHCExupjqoIbh3Hu55vp6ch3Hof4wlMrAdEWYh/gmP1RtXK0DDi2rXy nVzXjpVs8NM1g1vuNU2gANEugGMBRwu4YADTNsvwyAA3v+0k6LRWLb2dBUpjk2I4NVOx/gYPC6BU QiwCgSsSlWZpxH+ahzsOaBzvCe7qoMpKlUghd1n2f5oHId5/lQaJ0n+RBf3GLpUGwf4iksrg0FVF ICzlXT9QBB0tWO/+FjlKVWtfijTNRBsvDbhrdP3NUAwY38KFfkc0PuNjRWLLz8ytiTUVdVlnjlA2 MWPAWRAAM8LAAMjhhuR5ir4ULjigT5pn+P5co2T6pn+YBup6dp6xoh6kHie95modNOFkah0H+Qhd pyKBNmcf68r2Bo9GGtdpwIAUotM1Q4QMNzUDZhuVZbLsvy7KkqZZCnAb4AFcQY1C3LW1Wb5lOa2t ZvUt78NNjcMN83wEOMDczvuTzXNQ3QEN01WRL2b8XBYEDuugQEFUYgkpIo5FjIJTmhfZkHG8J0nm fB/sifp/EQYLBioUKsBkRKVgWPLX7stA4VnaDa+tZlZel0j+gCMpWS8MRULQNeIDY/4zTIAIyFX0 GFybZnr+rZ8p2a1s6tUNfADXXI1Yb8jLX+MNQk+1Az7zWqwVa/FaJrHpvSLeAQOhdE/l7CSJwrAb BXDXH+PkyA/gUiPGaftASWW6JeDgnGAsCmLNvcYqlz5+FchnZMrqGbeE3JoYhAMAKbEvOGeigtaE CDZwJcgxtiML0uMgQYzllKt2GhtP/EaH6cgAm+fnCtVEVXFOKNU54AC1B/tyLfBx4YJBGwhAAG5m yUoGH/TgxlZ7nGXw3YdEpYTPWOvaSq/JVEX28rEDQsGKDoGPx+QYnE1URg2paZY4dy7EHTx9cc41 upqIfwkjSgJWyW0MgBdK9I1DGAAwnS8G8+4cGYyUWWbKMg/gSiOjQG+FMQ44qqlmgBNUSYYMohKW 2ULFZaR8NdMFucoz/w/ZcAAMzgH+j/AKGV8QAZkhmWNM0AJ/I5zCiJEGYjF1qoGmxI5MqwT7JVlG buLULJhPXlbK+WMt3HwHmIbF8xaA0n6mvPgN7EJhx9Vcax+hsX6wGZuldNDnTSgQDoloGohS6BYE 62gPQqyRhlFE2gIYkCRgdD4WcAUsnxvlYklKgUCn4upi29JkkpG/pbYgtKbr86TLOnbLCF066ZLP kGsI+7NY9rRjZHB+0ew4M5S0AKT4FA8l0BaIUk4XHkj/EYLwzAtVyj/GwRYf49B8D6H+OMdw9R/j DG8vcTgx1xhpFTBoHYilRgaDygQAobXCynVVSSVdRYTLJls5CcIaqX0zpw/Kms76c2DSnTsNNPaA TbpggqOSCg4MkQwcAPiBAzimJqI4Xg3R/itX0P8bY66xD7MiYkgg5h4vAF2NgdY/xNGCH+HQVMIQ WiCNVM2L6Ap4s3ShFixMubA2HnjcUulhab3GuIbGxVjLlxXZoawMKFgsCiaSOUd6nB6XbH+PofKN LtqcH7eMf5AyimQOtegf4/TIEFvYP8dyjTm2eV1KdmNgrlIKr/cOxF+LjmRldTZY88L/U6P/YtyF +b82PDAhkOQsyNkHu8jS76NB4YXH+PvDUG7v3lIFeu8mFbuj6q8PXE2HEaXqIEUEgxnh2T2YhD/B WBZcUunVjO59yMB3PsHc3BONLemxwaP8NwsTMEPvVeMieJKvXmHZk8f48h5GHyYP8e+V3g3tvMQs VY01FLCxjgTHk8b943yBTOVoJEiXJzPgae1zr+2HwYhnIuRzrjczwP8eY8zDmKy7l8NOYcx40zKW nNswizytg+kXHc/qS48x9o7QbNMhZ0yMdvPBG7wmNz/jB6WYs436uFmbHhbFrAFgjhl4Y/g5IvH+ 0EkYFw+NuAHqmoet9bWJwPnDHEfM55E0udjTNW7uZ+y9p6L+oNe3Bxtoa4lACzgQee2kQ5Jwo1RK QPQfK8xejaJ6FG6w/wEh1NZJ+L6ydoH+zfqTUK0dK7AzsY7Yem9jaA0Fu2wVf9eJObqW+TxuwbCS K4JEYVnh2O/vWQM5K+wtCehCCAP5YABybV035xCAJIJqnrTyFqB9H8e1Lu/OumM870MTp3MGn9J8 g5Zsxhk2ZURLfGmrBAEg5m/CISIf4jRekblaCgRoyS0BjWNZVw6uZ70hnsrkND/Fbn3kWWtmz1ID a5NxyLYJ1xujdI3iZTm9dkYy4/P9yFKIcFoDQsbtKW4nT2YbLrpr450V6zTGem7N+YzXVzDZ0PSl ddIb8GQVrlD9sQjy4FKHVy0ZDDeLHCPWuuD/68Y0Vg1LX8c0bQSBiAq9JrVv2pYwZkzq6mqxDi8y XJgBkjZGftMMdUgm5PKyCBnogBI72hYgZlgrD6WWgMzPZkxGdUzfIfIzsdb66PXr/Jxp+XwRGlOL GnuJm2b0l7vo/dJeDL4N7qwWN+qn5CqedNMATuzZmObaad1s4dBMl/6wmG/Pt1+oAAYk2hToiuQc 5FxyjyRoHqH0xYKE+Q8k+UIgH0KAH+HSHqXmGwHSIuEGF0I25eWE8A96/g2akwhIk8Puf25mpi3w /IeG/M8y0O10/WgM3cpUS8l0mS+ocOYgDQS0ASDUTOB6EaJWDkXyXwFyL+GqGkPKHQHMOkxIXmIO HAHAJyyuKgvGIIHgU2H+G0GuHKH+FwF6KwEAtAH+CUEcLOAiNC2QnKcOZSZCmO9ongNep2sA3Y2W nY/KwE9hDazc8w8Sug9mh6cAZ0/UAEC0FKH+AOCOEoJQBeD8H+A2A+DYYGBuD2H+D6DmFCH+F0Fq hDB+PKGcGaaSGsGmJyGOGGg0EuEgP0CqCOEOH+BIA+DQH+AgBSDrD+CAEcH+AICwFNA+pamupfDQ /G1E2asfDksJDesNBCv012x+5WDmQSseeiAaCGEiH+BEAmC0H+A8AcCyH+A4AXGqAqAOCsLqAQCw H+BMAuDIH+CJEWPMCpFKCaCEEASEBFESA2AaC2H+AoAOCqK6AVGqA8AYCvGcAiC9HmBlHZBglBDt F80LF7BNDdBHDg2U0JGI0lGEseWsAgB6EYH+BUAkC4H+BKAuDDGcArH+BCAnH+A8AeC6K7HjG7H4 AoANHtG1G4A1GxGkAfHkBAAjJOBCAqC/FMAuDAH+BOApJ8A0BYDy2aWtGEzI1G2dKRIUwDGDF9BP DooBISnVImB9IsBRJHI2AuDHK3HHI4DFK3K6BGArI8BAAlJ8A8AhJqAlJxJBK3LDLBK9LmBNKCH+ AwBZEZIGcjGM3zKVIRL7BEH8zVKfKojrKlMCQVIk2jKuH/KzH/I5K7MjLFMpMnI5HGBIAvG/I5J9 MvMrK5M/K7LrJ9LxL1DXL5KYp1L/MM80g2wABMzWAGjVDZIc/XDrIiNjKtKxK1MtNBN7MlN9HFJ5 M3J7NDONMnNHLvLzKNKnMS5dNPMAsGpgLKLoAQNswAH8EAGAXGB0EobQAwEEJOblOa1uzJIfNvF9 MXFVMbMfOPODOBOBMxM1K3M7PfPdNFLtNLOZOcfjIOgVPIfeAaD2VGBUEY6ECyFQL+awXWH+HCHa KgW+KoAqDsPu3Mt8rxMO+fOjPTNzMZN3MhPtN/M/PlOJPrPhPvHBPzOXL3KPKhP69Mv4SmYWWs4m QyDGFUGsH+GeHEOkHW204SIED6FmaSBqeZHmQ3Fikw7iPwZWkCSs40Yg0CwTQAxpPUAhPZN5RDS1 PjOHPpRRRFOTP1RZSo5W1skw6MDa6g5omYZW94AYDkN+BOD+NKCoE6SKHy1WA8EOL2Z8cuhGTU/f SlArAu95L2cmiO1xSrQ7PXQ/S/S1RJS9RFUlNBTDRXNPRavw3St25kTXBiQsADBfUFNO/fUC6K+A N+9fTI2SkOfG6YmY9MZWDEFS+0TInFUQSfPI1NQ9MdSzRPUnS5MzRLUdRPUqD02RRaeoseDdSaQn ScQi9G/kPu+e/o+E8UQUoGv/IXMKsOfqZu8O/eV2S89E7QZ7XG8w/edGQYxiTeoSB3FKBQAlRBV9 S3LnWDUjXpN7LCBOAnJ8AyBXKKV0Z7KPKO6i764rXI9wS8DJVq6TAw+hP5MFBJDi0Ofq0i86mQPv XMDRWlBi6QVy6iAYCUEuJIBDESBGA0DNI2AxLjRCAxS4BGAvH5I5J2BLZdZVV9ZtZqDKJIA+DUH+ AiB4ES2a4pDFDE+fVIkg84ZylyTUn7RdYjIZYhQy14fipY9SDTWhSjRg6UAEC+fZGWEfEMBCDbFM AtJ9MzI9LlM8BFZjJ5ZpNBMzLCBJLKH+A+A3ZSAiByEMmcC0FO7Q7eTVSW+ectBY9HQ2oFDTNXak Ns9fIa0hPPVUfqfq5i3OjohIAEC6fYAWB6ERFUBSDxLuAtZSA7JSA/JoH/LPH+BIAtK7bZG4BGAt JCApH+A+AhJPGnJOA0AfH+AiBIDoWuBzc6AICvD8PxUAWJWWj2sfWwsPP9cXWzKc/PGE0jPQvwiE 9kWsAeB+EVI2AaCpdQAbGjGnHkA4AbJPHhI0A2AZI0A6AdI1drG+A6AfG/HhGjfVI1fLfJGpfBGq BGAZHsAvKJA+j7eZencVNSlZGBelINchalStIqbTV7J5I8BDLtdrJPfLfSAZHkA2AXfPfXENJTfl JrK0BFdjMoBOArX7UsYhUxaledgRcZgVBLMTepVU17StSxXlMrZzbgAtLDgrdoAlGiBBK1dhZZLi AxK/OFORRVNNhbhu0PhhafgTW1gXilgbgRhzUbV/OOAwDPFMAxe/ZrPriXXnWJidP3hiuZgPiphk eGA8EUJGWEc3MNhtgdUXSvi5XxS1Z3Zhe/MzbfjNRRUrieVpeejtOg0OseDeNYQexAIEE4GcX2B4 EkRKAMDsNjXSTWcVVVjvi1jzh1WHM/j8AvkAAvkFlHkLjVjdjZF4pPk0nANKLKQIBCESL2D6F6XG XgvWqwHQMqEsGIRaL6RSAgD6bcQAbyNRBkLQDCWNhdNxkPj1V5h3i7N7lLlPlTmtUpjTTHak1tUE DHDyQMDWN+ggQIByEiJOEGOcGIG8Okq7CMXay2KMG8HaU4rcMGCIE8aSBcEWL2Ci4ccggbKXhxlD j3jPPdmxbdLnm3PxNJhZkO1CseseDUNKBIEMJWB8EqhCBqEuGgH+DiFiL+GXQcINAEIhl4McIkXc IICurWWuDulCNiDW85VVi3mplHmuH/j/oZM9odRTohkNNQnjYIc6QIAILmH+BgEOLOtabCUcIPpV qiIOHMKeOQGoJ6C+FaMwAuEJT474DYTfliJQrbgjmrj5OBoXkDobrTJ/LsArX+LQDI72nBlkJQLv C2FBpAEoGOMGGhqsvKH7nlqpqlnpsKKMHgJ+tgGQPKCmFIaSAwD8LOA4EGJWBiCdEFH1G/iPp0Av rXlRrboTdXLDdrI0BSBkD4H/n8JOAkD7o0EwhCECF+PKG6HceBsQRtsPtyOuq4/+22RcFYJGBkBK Ddp4AtI8A2AdHkA/H9uPZZrVp5lNp9OFMzK7iLJ9HhHlgrJ8BSA3FSEWECe+vNsVnkXdt4MVqnvR qiHmHkKgF+F0JqEMD8fECQB4D7uPI8AyAZGjubJ8BAAqClbqAng4AbfZdsKyBTuMDiDOE2H+FmFe JGHMU1vXwrvVwrwxCKagF3pADyDiFEH+CWCAEHJ+A3G4B+BmDmH+DQC7EEFGE4NKHYHUXvwxxqIj t3xtxyIaw0ImGwGus8HgUZx1yGavxxyJyPyRySKIKQFuFibQGOGEYFyVynypymKQCaB/xIDkDOE8 IQFSFEVGE+EsQIIWGEF4L+EwEeP6IOE4EoN2DOC0ErpCDLy6DYDAEyH+FiFU6EHyq6H+DqDUFAH+ G4GwOWIWw0IIEMD68HzsE0H+DgDIE4H+DaDD0cG8G4X2FgFS6EFGE2LAIWG0GsHMH+EoEWTaIOFn uEH+DKCzzkDjzoH+DJ1aH+FuFgbRsGIIEKD2fZyCrEIOGUGMI2E8EqNLz6XmDsDXEgDUC6EwH+DW C9zx1ZzkF4FuOOHUq0D8Dnb8DeDHwd0h0kEeEKQsKQCkCLFKDv2SIQD6DkFJENg2H/ygYFxkPCBu BQDkH+CwCXIsIOCiCJb2CQB0D+H+FEE0LoEYEGTOCgCGEKH/2uMrGfI8GEF7RyIWHwOoH+CEBptU EaEITOFCEyLOF0FoJr16aUDpb9fbH+GAF0RSz2KgCABjdACSB4ED3V3YH+C8CjbCFAEwLP006EG8 G2X35LbnK6B/5iH+GcGSs8FoFehCC0CYEavXAT5WRSDyDdxACKBtvwFwFkJqHEHAUVxeLACSB3HZ 2GNKEyEgP6EsEaNEKQCn3MH+DuDZEgIOEUEAZMDuDbxB7jFL5zbCDQC2Et2cC/zwIP8AH+BoBKDf 1iCxEEC4CfFgEqEYNFCeU4BWA2DSXIGgXGIWu+XmCQB35r2R0EEgEOQyIWEOD88GECDvVmCyCZIs DACpGaE0EkN+DP8GIQEGDyFUH/3LFL0Ue+HkHh18IMHPwoCqCRe54ILoCMBvEKC6Cl8CC18IIWFa FKL2DGCtEEIXE0MH2+H+EKD4fZ10fZ374Z7h7l7p7sIMEF9eRd6d1p1t4H4L/ohCDECsEkIQIAVC MiX+dTUoH++n0/X++4W/4hEHe7Xo/xQGTO/zQXEu/0Cd1S/0Yglg/3g73q/yWPUE/zsa1C/0IeVW /0GeFU/3G4Xa/0MfVY/1or2bQlbRUiiVpJpQ/y+U0jEYggzzOSkRUM/0KfJqfzop3+p1Aw3+53I7 n+UCJWak3m26H+OxYdX+Xiij6leVRY3+YKheaks1Yy3+VCPBEIe5zM5qOxbdICAADgEAAAMAAAAB ADgAAAEBAAMAAAABAEAAAAECAAMAAAAEAAAWdgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQA AAABAAAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA CAAK/IAAACcQAAr8gAAAJxA= --Apple-Mail-152--1023557083 Content-Type: multipart/alternative; boundary=Apple-Mail-155--1023557080 --Apple-Mail-155--1023557080 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Ghandi. --Apple-Mail-155--1023557080 Content-Transfer-Encoding: 7bit Content-Type: text/enriched; charset=US-ASCII Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Ghandi. --Apple-Mail-155--1023557080-- --Apple-Mail-152--1023557083-- From pgsql-performance-owner@postgresql.org Mon May 23 15:04:02 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0D2CC52836 for ; Mon, 23 May 2005 15:04:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59916-06 for ; Mon, 23 May 2005 18:03:55 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id 5F43E52879 for ; Mon, 23 May 2005 15:03:54 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DaHHM-0003RO-Ip for pgsql-performance@postgresql.org; Mon, 23 May 2005 20:03:53 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1DaHHM-0006Cm-00 for ; Mon, 23 May 2005 20:03:52 +0200 Date: Mon, 23 May 2005 20:03:52 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Fwd: Index on table when using DESC clause Message-ID: <20050523180352.GA23486@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <6d31bed04ab35cbbe2df37af979d9882@implements.be> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6d31bed04ab35cbbe2df37af979d9882@implements.be> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/343 X-Sequence-Number: 12507 On Mon, May 23, 2005 at 07:41:19PM +0200, Yves Vindevogel wrote: > However, when I query my db using for instance order by pages, > documentname, it is very fast. > If I use order by pages desc, documentname, it is not fast at > all, like it is not using the index properly at all. Make an index on "pages desc, documentname asc". /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Mon May 23 16:02:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B22515288A for ; Mon, 23 May 2005 16:02:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76617-09 for ; Mon, 23 May 2005 19:02:29 +0000 (GMT) Received: from apate.telenet-ops.be (apate.telenet-ops.be [195.130.132.57]) by svr1.postgresql.org (Postfix) with ESMTP id 8F1F352879 for ; Mon, 23 May 2005 16:02:27 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by apate.telenet-ops.be (Postfix) with SMTP id 93F8A3806E for ; Mon, 23 May 2005 21:02:28 +0200 (CEST) Received: from [10.0.1.11] (d5152B1F3.access.telenet.be [81.82.177.243]) by apate.telenet-ops.be (Postfix) with ESMTP id 6C43D386ED for ; Mon, 23 May 2005 21:02:27 +0200 (CEST) Mime-Version: 1.0 (Apple Message framework v622) In-Reply-To: <20050523180352.GA23486@uio.no> References: <6d31bed04ab35cbbe2df37af979d9882@implements.be> <20050523180352.GA23486@uio.no> Content-Type: multipart/mixed; boundary=Apple-Mail-156--1018699311 Message-Id: From: Yves Vindevogel Subject: Re: Fwd: Index on table when using DESC clause Date: Mon, 23 May 2005 21:02:17 +0200 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/344 X-Sequence-Number: 12508 --Apple-Mail-156--1018699311 Content-Type: multipart/alternative; boundary=Apple-Mail-157--1018699310 --Apple-Mail-157--1018699310 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed I tried that, but create index ixTest on table1 (pages desc, documentname) gives me a syntax error On 23 May 2005, at 20:03, Steinar H. Gunderson wrote: > On Mon, May 23, 2005 at 07:41:19PM +0200, Yves Vindevogel wrote: >> However, when I query my db using for instance order by pages, >> documentname, it is very fast. >> If I use order by pages desc, documentname, it is not fast at >> all, like it is not using the index properly at all. > > Make an index on "pages desc, documentname asc". > > /* Steinar */ > --=20 > Homepage: http://www.sesse.net/ > > ---------------------------(end of=20 > broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if=20= > your > joining column's datatypes do not match > > Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements --Apple-Mail-157--1018699310 Content-Transfer-Encoding: quoted-printable Content-Type: text/enriched; charset=ISO-8859-1 I tried that, but create index ixTest on table1 (pages desc, documentname)=20 gives me a syntax error On 23 May 2005, at 20:03, Steinar H. Gunderson wrote: On Mon, May 23, 2005 at 07:41:19PM +0200, Yves Vindevogel wrote: However, when I query my db using for instance order by pages,=20 documentname, it is very fast.=20 If I use order by pages desc, documentname, it is not fast at=20 all, like it is not using the index properly at all.=20 Make an index on "pages desc, documentname asc". /* Steinar */ --=20 Homepage: http://www.sesse.net/ ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements = --Apple-Mail-157--1018699310-- --Apple-Mail-156--1018699311 Content-Transfer-Encoding: base64 Content-Type: image/tiff; x-unix-mode=0666; name="Pasted Graphic 2.tiff" Content-Disposition: inline; filename="Pasted Graphic 2.tiff" TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+FP5+v9rOh5P9IMBuP8zK9tP8fJNlP8QoNjP8FndhP 8MnyVjJHSMrqFnv9BL1vP9ett2v98PuJxChUOiUWGQOCUalUujOV4PZ/qBluR/mdVtJ/jVHst/ho 9MF/g08WABHJfv8AWa0WoAHFfWuzgg6sB/hY9ysUohjv8qqVqv9LMZxv9ouV40zEYmHUjFY2HPx+ RNtOl4Rhftt/phiRs6LC/iA5LewnJeWg46W22+02cAHOwa26bC0HPY7TZ7G2G9dv8EHFdP8Om9YP 8rKJov9UtFzv9Dzh/sRvu5/vZ9PzHdeF4zsUqgQRlOR5v9DMBwv8uqe/jZIVwNHu6B0/WAKHvWGr RAA1ra0G1c/vfgANrdraXrTQIAA6JW2TUrQNz/ja0oAjO4YAjSWS0DOWawjys4RkIk4Lj2sAWEUZ B/ieUJqH+PZdnAf5aG06R5nsfLtqW7UaoWZJwukwLyi4VRsn+F5HGYf8QJWBQ7JWAI5tYti2Dm1T bQHAq0De1Q2FwtA1Fof4AjVDIBDQV0vDQWK0DY/oADYWsrNQN81NOuDZtYOM6ycs4Cjq+Q9JWE5D pGJpOpqP5dMwW5sHUf53xlHCExupjqoIbh3Hu55vp6ch3Hof4wlMrAdEWYh/gmP1RtXK0DDi2rXy nVzXjpVs8NM1g1vuNU2gANEugGMBRwu4YADTNsvwyAA3v+0k6LRWLb2dBUpjk2I4NVOx/gYPC6BU QiwCgSsSlWZpxH+ahzsOaBzvCe7qoMpKlUghd1n2f5oHId5/lQaJ0n+RBf3GLpUGwf4iksrg0FVF ICzlXT9QBB0tWO/+FjlKVWtfijTNRBsvDbhrdP3NUAwY38KFfkc0PuNjRWLLz8ytiTUVdVlnjlA2 MWPAWRAAM8LAAMjhhuR5ir4ULjigT5pn+P5co2T6pn+YBup6dp6xoh6kHie95modNOFkah0H+Qhd pyKBNmcf68r2Bo9GGtdpwIAUotM1Q4QMNzUDZhuVZbLsvy7KkqZZCnAb4AFcQY1C3LW1Wb5lOa2t ZvUt78NNjcMN83wEOMDczvuTzXNQ3QEN01WRL2b8XBYEDuugQEFUYgkpIo5FjIJTmhfZkHG8J0nm fB/sifp/EQYLBioUKsBkRKVgWPLX7stA4VnaDa+tZlZel0j+gCMpWS8MRULQNeIDY/4zTIAIyFX0 GFybZnr+rZ8p2a1s6tUNfADXXI1Yb8jLX+MNQk+1Az7zWqwVa/FaJrHpvSLeAQOhdE/l7CSJwrAb BXDXH+PkyA/gUiPGaftASWW6JeDgnGAsCmLNvcYqlz5+FchnZMrqGbeE3JoYhAMAKbEvOGeigtaE CDZwJcgxtiML0uMgQYzllKt2GhtP/EaH6cgAm+fnCtVEVXFOKNU54AC1B/tyLfBx4YJBGwhAAG5m yUoGH/TgxlZ7nGXw3YdEpYTPWOvaSq/JVEX28rEDQsGKDoGPx+QYnE1URg2paZY4dy7EHTx9cc41 upqIfwkjSgJWyW0MgBdK9I1DGAAwnS8G8+4cGYyUWWbKMg/gSiOjQG+FMQ44qqlmgBNUSYYMohKW 2ULFZaR8NdMFucoz/w/ZcAAMzgH+j/AKGV8QAZkhmWNM0AJ/I5zCiJEGYjF1qoGmxI5MqwT7JVlG buLULJhPXlbK+WMt3HwHmIbF8xaA0n6mvPgN7EJhx9Vcax+hsX6wGZuldNDnTSgQDoloGohS6BYE 62gPQqyRhlFE2gIYkCRgdD4WcAUsnxvlYklKgUCn4upi29JkkpG/pbYgtKbr86TLOnbLCF066ZLP kGsI+7NY9rRjZHB+0ew4M5S0AKT4FA8l0BaIUk4XHkj/EYLwzAtVyj/GwRYf49B8D6H+OMdw9R/j DG8vcTgx1xhpFTBoHYilRgaDygQAobXCynVVSSVdRYTLJls5CcIaqX0zpw/Kms76c2DSnTsNNPaA TbpggqOSCg4MkQwcAPiBAzimJqI4Xg3R/itX0P8bY66xD7MiYkgg5h4vAF2NgdY/xNGCH+HQVMIQ WiCNVM2L6Ap4s3ShFixMubA2HnjcUulhab3GuIbGxVjLlxXZoawMKFgsCiaSOUd6nB6XbH+PofKN LtqcH7eMf5AyimQOtegf4/TIEFvYP8dyjTm2eV1KdmNgrlIKr/cOxF+LjmRldTZY88L/U6P/YtyF +b82PDAhkOQsyNkHu8jS76NB4YXH+PvDUG7v3lIFeu8mFbuj6q8PXE2HEaXqIEUEgxnh2T2YhD/B WBZcUunVjO59yMB3PsHc3BONLemxwaP8NwsTMEPvVeMieJKvXmHZk8f48h5GHyYP8e+V3g3tvMQs VY01FLCxjgTHk8b943yBTOVoJEiXJzPgae1zr+2HwYhnIuRzrjczwP8eY8zDmKy7l8NOYcx40zKW nNswizytg+kXHc/qS48x9o7QbNMhZ0yMdvPBG7wmNz/jB6WYs436uFmbHhbFrAFgjhl4Y/g5IvH+ 0EkYFw+NuAHqmoet9bWJwPnDHEfM55E0udjTNW7uZ+y9p6L+oNe3Bxtoa4lACzgQee2kQ5Jwo1RK QPQfK8xejaJ6FG6w/wEh1NZJ+L6ydoH+zfqTUK0dK7AzsY7Yem9jaA0Fu2wVf9eJObqW+TxuwbCS K4JEYVnh2O/vWQM5K+wtCehCCAP5YABybV035xCAJIJqnrTyFqB9H8e1Lu/OumM870MTp3MGn9J8 g5Zsxhk2ZURLfGmrBAEg5m/CISIf4jRekblaCgRoyS0BjWNZVw6uZ70hnsrkND/Fbn3kWWtmz1ID a5NxyLYJ1xujdI3iZTm9dkYy4/P9yFKIcFoDQsbtKW4nT2YbLrpr450V6zTGem7N+YzXVzDZ0PSl ddIb8GQVrlD9sQjy4FKHVy0ZDDeLHCPWuuD/68Y0Vg1LX8c0bQSBiAq9JrVv2pYwZkzq6mqxDi8y XJgBkjZGftMMdUgm5PKyCBnogBI72hYgZlgrD6WWgMzPZkxGdUzfIfIzsdb66PXr/Jxp+XwRGlOL GnuJm2b0l7vo/dJeDL4N7qwWN+qn5CqedNMATuzZmObaad1s4dBMl/6wmG/Pt1+oAAYk2hToiuQc 5FxyjyRoHqH0xYKE+Q8k+UIgH0KAH+HSHqXmGwHSIuEGF0I25eWE8A96/g2akwhIk8Puf25mpi3w /IeG/M8y0O10/WgM3cpUS8l0mS+ocOYgDQS0ASDUTOB6EaJWDkXyXwFyL+GqGkPKHQHMOkxIXmIO HAHAJyyuKgvGIIHgU2H+G0GuHKH+FwF6KwEAtAH+CUEcLOAiNC2QnKcOZSZCmO9ongNep2sA3Y2W nY/KwE9hDazc8w8Sug9mh6cAZ0/UAEC0FKH+AOCOEoJQBeD8H+A2A+DYYGBuD2H+D6DmFCH+F0Fq hDB+PKGcGaaSGsGmJyGOGGg0EuEgP0CqCOEOH+BIA+DQH+AgBSDrD+CAEcH+AICwFNA+pamupfDQ /G1E2asfDksJDesNBCv012x+5WDmQSseeiAaCGEiH+BEAmC0H+A8AcCyH+A4AXGqAqAOCsLqAQCw H+BMAuDIH+CJEWPMCpFKCaCEEASEBFESA2AaC2H+AoAOCqK6AVGqA8AYCvGcAiC9HmBlHZBglBDt F80LF7BNDdBHDg2U0JGI0lGEseWsAgB6EYH+BUAkC4H+BKAuDDGcArH+BCAnH+A8AeC6K7HjG7H4 AoANHtG1G4A1GxGkAfHkBAAjJOBCAqC/FMAuDAH+BOApJ8A0BYDy2aWtGEzI1G2dKRIUwDGDF9BP DooBISnVImB9IsBRJHI2AuDHK3HHI4DFK3K6BGArI8BAAlJ8A8AhJqAlJxJBK3LDLBK9LmBNKCH+ AwBZEZIGcjGM3zKVIRL7BEH8zVKfKojrKlMCQVIk2jKuH/KzH/I5K7MjLFMpMnI5HGBIAvG/I5J9 MvMrK5M/K7LrJ9LxL1DXL5KYp1L/MM80g2wABMzWAGjVDZIc/XDrIiNjKtKxK1MtNBN7MlN9HFJ5 M3J7NDONMnNHLvLzKNKnMS5dNPMAsGpgLKLoAQNswAH8EAGAXGB0EobQAwEEJOblOa1uzJIfNvF9 MXFVMbMfOPODOBOBMxM1K3M7PfPdNFLtNLOZOcfjIOgVPIfeAaD2VGBUEY6ECyFQL+awXWH+HCHa KgW+KoAqDsPu3Mt8rxMO+fOjPTNzMZN3MhPtN/M/PlOJPrPhPvHBPzOXL3KPKhP69Mv4SmYWWs4m QyDGFUGsH+GeHEOkHW204SIED6FmaSBqeZHmQ3Fikw7iPwZWkCSs40Yg0CwTQAxpPUAhPZN5RDS1 PjOHPpRRRFOTP1RZSo5W1skw6MDa6g5omYZW94AYDkN+BOD+NKCoE6SKHy1WA8EOL2Z8cuhGTU/f SlArAu95L2cmiO1xSrQ7PXQ/S/S1RJS9RFUlNBTDRXNPRavw3St25kTXBiQsADBfUFNO/fUC6K+A N+9fTI2SkOfG6YmY9MZWDEFS+0TInFUQSfPI1NQ9MdSzRPUnS5MzRLUdRPUqD02RRaeoseDdSaQn ScQi9G/kPu+e/o+E8UQUoGv/IXMKsOfqZu8O/eV2S89E7QZ7XG8w/edGQYxiTeoSB3FKBQAlRBV9 S3LnWDUjXpN7LCBOAnJ8AyBXKKV0Z7KPKO6i764rXI9wS8DJVq6TAw+hP5MFBJDi0Ofq0i86mQPv XMDRWlBi6QVy6iAYCUEuJIBDESBGA0DNI2AxLjRCAxS4BGAvH5I5J2BLZdZVV9ZtZqDKJIA+DUH+ AiB4ES2a4pDFDE+fVIkg84ZylyTUn7RdYjIZYhQy14fipY9SDTWhSjRg6UAEC+fZGWEfEMBCDbFM AtJ9MzI9LlM8BFZjJ5ZpNBMzLCBJLKH+A+A3ZSAiByEMmcC0FO7Q7eTVSW+ectBY9HQ2oFDTNXak Ns9fIa0hPPVUfqfq5i3OjohIAEC6fYAWB6ERFUBSDxLuAtZSA7JSA/JoH/LPH+BIAtK7bZG4BGAt JCApH+A+AhJPGnJOA0AfH+AiBIDoWuBzc6AICvD8PxUAWJWWj2sfWwsPP9cXWzKc/PGE0jPQvwiE 9kWsAeB+EVI2AaCpdQAbGjGnHkA4AbJPHhI0A2AZI0A6AdI1drG+A6AfG/HhGjfVI1fLfJGpfBGq BGAZHsAvKJA+j7eZencVNSlZGBelINchalStIqbTV7J5I8BDLtdrJPfLfSAZHkA2AXfPfXENJTfl JrK0BFdjMoBOArX7UsYhUxaledgRcZgVBLMTepVU17StSxXlMrZzbgAtLDgrdoAlGiBBK1dhZZLi AxK/OFORRVNNhbhu0PhhafgTW1gXilgbgRhzUbV/OOAwDPFMAxe/ZrPriXXnWJidP3hiuZgPiphk eGA8EUJGWEc3MNhtgdUXSvi5XxS1Z3Zhe/MzbfjNRRUrieVpeejtOg0OseDeNYQexAIEE4GcX2B4 EkRKAMDsNjXSTWcVVVjvi1jzh1WHM/j8AvkAAvkFlHkLjVjdjZF4pPk0nANKLKQIBCESL2D6F6XG XgvWqwHQMqEsGIRaL6RSAgD6bcQAbyNRBkLQDCWNhdNxkPj1V5h3i7N7lLlPlTmtUpjTTHak1tUE DHDyQMDWN+ggQIByEiJOEGOcGIG8Okq7CMXay2KMG8HaU4rcMGCIE8aSBcEWL2Ci4ccggbKXhxlD j3jPPdmxbdLnm3PxNJhZkO1CseseDUNKBIEMJWB8EqhCBqEuGgH+DiFiL+GXQcINAEIhl4McIkXc IICurWWuDulCNiDW85VVi3mplHmuH/j/oZM9odRTohkNNQnjYIc6QIAILmH+BgEOLOtabCUcIPpV qiIOHMKeOQGoJ6C+FaMwAuEJT474DYTfliJQrbgjmrj5OBoXkDobrTJ/LsArX+LQDI72nBlkJQLv C2FBpAEoGOMGGhqsvKH7nlqpqlnpsKKMHgJ+tgGQPKCmFIaSAwD8LOA4EGJWBiCdEFH1G/iPp0Av rXlRrboTdXLDdrI0BSBkD4H/n8JOAkD7o0EwhCECF+PKG6HceBsQRtsPtyOuq4/+22RcFYJGBkBK Ddp4AtI8A2AdHkA/H9uPZZrVp5lNp9OFMzK7iLJ9HhHlgrJ8BSA3FSEWECe+vNsVnkXdt4MVqnvR qiHmHkKgF+F0JqEMD8fECQB4D7uPI8AyAZGjubJ8BAAqClbqAng4AbfZdsKyBTuMDiDOE2H+FmFe JGHMU1vXwrvVwrwxCKagF3pADyDiFEH+CWCAEHJ+A3G4B+BmDmH+DQC7EEFGE4NKHYHUXvwxxqIj t3xtxyIaw0ImGwGus8HgUZx1yGavxxyJyPyRySKIKQFuFibQGOGEYFyVynypymKQCaB/xIDkDOE8 IQFSFEVGE+EsQIIWGEF4L+EwEeP6IOE4EoN2DOC0ErpCDLy6DYDAEyH+FiFU6EHyq6H+DqDUFAH+ G4GwOWIWw0IIEMD68HzsE0H+DgDIE4H+DaDD0cG8G4X2FgFS6EFGE2LAIWG0GsHMH+EoEWTaIOFn uEH+DKCzzkDjzoH+DJ1aH+FuFgbRsGIIEKD2fZyCrEIOGUGMI2E8EqNLz6XmDsDXEgDUC6EwH+DW C9zx1ZzkF4FuOOHUq0D8Dnb8DeDHwd0h0kEeEKQsKQCkCLFKDv2SIQD6DkFJENg2H/ygYFxkPCBu BQDkH+CwCXIsIOCiCJb2CQB0D+H+FEE0LoEYEGTOCgCGEKH/2uMrGfI8GEF7RyIWHwOoH+CEBptU EaEITOFCEyLOF0FoJr16aUDpb9fbH+GAF0RSz2KgCABjdACSB4ED3V3YH+C8CjbCFAEwLP006EG8 G2X35LbnK6B/5iH+GcGSs8FoFehCC0CYEavXAT5WRSDyDdxACKBtvwFwFkJqHEHAUVxeLACSB3HZ 2GNKEyEgP6EsEaNEKQCn3MH+DuDZEgIOEUEAZMDuDbxB7jFL5zbCDQC2Et2cC/zwIP8AH+BoBKDf 1iCxEEC4CfFgEqEYNFCeU4BWA2DSXIGgXGIWu+XmCQB35r2R0EEgEOQyIWEOD88GECDvVmCyCZIs DACpGaE0EkN+DP8GIQEGDyFUH/3LFL0Ue+HkHh18IMHPwoCqCRe54ILoCMBvEKC6Cl8CC18IIWFa FKL2DGCtEEIXE0MH2+H+EKD4fZ10fZ374Z7h7l7p7sIMEF9eRd6d1p1t4H4L/ohCDECsEkIQIAVC MiX+dTUoH++n0/X++4W/4hEHe7Xo/xQGTO/zQXEu/0Cd1S/0Yglg/3g73q/yWPUE/zsa1C/0IeVW /0GeFU/3G4Xa/0MfVY/1or2bQlbRUiiVpJpQ/y+U0jEYggzzOSkRUM/0KfJqfzop3+p1Aw3+53I7 n+UCJWak3m26H+OxYdX+Xiij6leVRY3+YKheaks1Yy3+VCPBEIe5zM5qOxbdICAADgEAAAMAAAAB ADgAAAEBAAMAAAABAEAAAAECAAMAAAAEAAAWdgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQA AAABAAAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA CAAK/IAAACcQAAr8gAAAJxA= --Apple-Mail-156--1018699311 Content-Type: multipart/alternative; boundary=Apple-Mail-158--1018699308 --Apple-Mail-158--1018699308 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Ghandi. --Apple-Mail-158--1018699308 Content-Transfer-Encoding: 7bit Content-Type: text/enriched; charset=US-ASCII Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Ghandi. --Apple-Mail-158--1018699308-- --Apple-Mail-156--1018699311-- From pgsql-performance-owner@postgresql.org Mon May 23 16:47:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B859C52887 for ; Mon, 23 May 2005 16:47:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90201-08 for ; Mon, 23 May 2005 19:47:10 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id CDF0952837 for ; Mon, 23 May 2005 16:47:00 -0300 (ADT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j4NJkcpO020660; Mon, 23 May 2005 23:46:39 +0400 (MSD) Date: Mon, 23 May 2005 23:46:38 +0400 (MSD) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: Yves Vindevogel Cc: pgsql-performance@postgresql.org Subject: Re: Fwd: Index on table when using DESC clause In-Reply-To: Message-ID: References: <6d31bed04ab35cbbe2df37af979d9882@implements.be> <20050523180352.GA23486@uio.no> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.331 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200505/345 X-Sequence-Number: 12509 You didn't say what version of PostgreSQL you're trying. I recall old version doesn't used index for backward pagination. Oleg On Mon, 23 May 2005, Yves Vindevogel wrote: > I tried that, but > > create index ixTest on table1 (pages desc, documentname) > > gives me a syntax error > > > On 23 May 2005, at 20:03, Steinar H. Gunderson wrote: > >> On Mon, May 23, 2005 at 07:41:19PM +0200, Yves Vindevogel wrote: >>> However, when I query my db using for instance order by pages, >>> documentname, it is very fast. >>> If I use order by pages desc, documentname, it is not fast at >>> all, like it is not using the index properly at all. >> >> Make an index on "pages desc, documentname asc". >> >> /* Steinar */ >> -- >> Homepage: http://www.sesse.net/ >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 9: the planner will ignore your desire to choose an index scan if your >> joining column's datatypes do not match >> >> > Met vriendelijke groeten, > Bien ? vous, > Kind regards, > > Yves Vindevogel > Implements > > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 From pgsql-performance-owner@postgresql.org Mon May 23 17:19:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 97DEE52894 for ; Mon, 23 May 2005 17:19:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97810-10 for ; Mon, 23 May 2005 20:18:57 +0000 (GMT) Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net [67.119.5.202]) by svr1.postgresql.org (Postfix) with ESMTP id 2AC3A528AF for ; Mon, 23 May 2005 17:18:55 -0300 (ADT) Received: from [192.168.1.202] (dhcp202.pillette.com [192.168.1.202]) by pillette.com (8.11.6/8.11.6) with ESMTP id j4NKIma31583; Mon, 23 May 2005 13:18:48 -0700 Message-ID: <42923CA3.1040306@pillette.com> Date: Mon, 23 May 2005 13:27:15 -0700 From: Andrew Lazarus Reply-To: andrew@pillette.com Organization: Pillette Investment Management User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Yves Vindevogel Cc: pgsql-performance@postgresql.org Subject: Re: Fwd: Index on table when using DESC clause References: <6d31bed04ab35cbbe2df37af979d9882@implements.be> In-Reply-To: <6d31bed04ab35cbbe2df37af979d9882@implements.be> Content-Type: multipart/mixed; boundary="------------030207000207030307050007" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.122 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/346 X-Sequence-Number: 12510 This is a multi-part message in MIME format. --------------030207000207030307050007 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit As far as I know, to use a straight index Postgres requires either ORDER BY pages, description -- or -- ORDER BY pages DESC, description DESC. If you want the results by pages DESC, description ASC, then you have to make an index on an expression or define your own operator or something esoteric like that. I would think the ability to have an index where the columns don't all collate in the same direction would be an easy feature to add. --------------030207000207030307050007 Content-Type: text/x-vcard; charset=utf-8; name="andrew.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="andrew.vcf" begin:vcard fn:Andrew Lazarus n:Lazarus;Andrew org:Pillette Investment Management;Research and Development adr;dom:;;3028 Fillmore;San Francisco;CA;94123 email;internet:andrew@pillette.com title:Director tel;work:800-366-0688 tel;fax:415-440-4093 url:http://www.pillette.com version:2.1 end:vcard --------------030207000207030307050007-- From pgsql-performance-owner@postgresql.org Mon May 23 17:50:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3CCCA52960 for ; Mon, 23 May 2005 17:50:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07591-03 for ; Mon, 23 May 2005 20:50:16 +0000 (GMT) Received: from cmailm2.svr.pol.co.uk (cmailm2.svr.pol.co.uk [195.92.193.210]) by svr1.postgresql.org (Postfix) with ESMTP id 3E79052837 for ; Mon, 23 May 2005 17:50:15 -0300 (ADT) Received: from modem-4024.llama.dialup.pol.co.uk ([217.135.191.184] helo=192.168.0.102) by cmailm2.svr.pol.co.uk with esmtp (Exim 4.41) id 1DaJsM-0002B1-IX; Mon, 23 May 2005 21:50:14 +0100 Subject: Re: Tuning planner cost estimates From: Simon Riggs To: josh@agliodbs.com Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org In-Reply-To: <200505201523.16437.josh@agliodbs.com> References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> <20050520202017.GK44623@decibel.org> <200505201523.16437.josh@agliodbs.com> Content-Type: text/plain Organization: 2nd Quadrant Date: Mon, 23 May 2005 21:46:21 +0100 Message-Id: <1116881181.3844.430.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/347 X-Sequence-Number: 12511 On Fri, 2005-05-20 at 15:23 -0700, Josh Berkus wrote: > > Well, that raises an interesting issue, because AFAIK none of the cost > > estimate functions currently do that. Heck, AFAIK even the piggyback > > seqscan code doesn't take other seqscans into account. > > Sure. But you're striving for greater accuracy, no? > > Actually, all that's really needed in the way of concurrent activity is a > calculated factor that lets us know how likely a particular object is to be > cached, either in the fs cache or the pg cache (with different factors for > each presumably) based on history. Right now, that's based on > estimated_cache_size, which is rather innacurate: a table which is queried > once a month has the exact same cost factors as one which is queried every > 2.1 seconds. This would mean an extra column in pg_stats I suppose. Hmmm...not sure that would be a good thing. effective_cache_size isn't supposed to be set according to how much of a table is in cache when the query starts. The setting is supposed to reflect how much cache is *available* for the current index scan, when performing an index scan on a table that is not in clustered sequence. The more out of sequence the table is, the more memory is required to avoid doing any repeated I/Os during the scan. Of course, if there are many users, the available cache may be much reduced. Best regards, Simon Riggs From pgsql-performance-owner@postgresql.org Mon May 23 17:58:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E5DC752897 for ; Mon, 23 May 2005 17:58:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09612-05 for ; Mon, 23 May 2005 20:58:26 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 6721552895 for ; Mon, 23 May 2005 17:58:25 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C55FDA.283C7FF5" Subject: seqential vs random io Date: Mon, 23 May 2005 16:58:22 -0400 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C746598@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: seqential vs random io Thread-Index: AcVf2ifxPsn5CStxRoKCT3mP9nUGCA== From: "David Parker" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.167 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_40_50, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/348 X-Sequence-Number: 12512 This is a multi-part message in MIME format. ------_=_NextPart_001_01C55FDA.283C7FF5 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I just got a question from one our QA guys who is configuring a RAID 10 disk that is destined to hold a postgresql database. The disk configuration procedure is asking him if he wants to optimize for sequential or random access. My first thought is that random is what we would want, but then I started wondering if it's not that simple, and my knowledge of stuff at the hardware level is, well, limited..... =20 If it were your QA guy, what would you tell him? - DAP ------------------------------------------------------------------------ ---------- David Parker Tazz Networks (401) 709-5130 =20 =20 ------_=_NextPart_001_01C55FDA.283C7FF5 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
I just = got a=20 question from one our QA guys who is configuring a RAID 10 disk that is = destined=20 to hold a postgresql database. The disk configuration procedure is = asking him if=20 he wants to optimize for sequential or random access. My first thought = is that=20 random is what we would want, but then I started wondering if it's not = that=20 simple, and my knowledge of stuff at the hardware level is, well,=20 limited.....
 
If it = were your QA=20 guy, what would you tell him?

-=20 DAP
------------------------------------------------------------------= ----------------
David=20 Parker    Tazz Networks    (401)=20 709-5130
 

 
------_=_NextPart_001_01C55FDA.283C7FF5-- From pgsql-performance-owner@postgresql.org Mon May 23 18:19:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 518DC5281A for ; Mon, 23 May 2005 18:19:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15265-02 for ; Mon, 23 May 2005 21:19:03 +0000 (GMT) Received: from apate.telenet-ops.be (apate.telenet-ops.be [195.130.132.57]) by svr1.postgresql.org (Postfix) with ESMTP id 5ECCD5280B for ; Mon, 23 May 2005 18:19:01 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by apate.telenet-ops.be (Postfix) with SMTP id C0DBF38BFE; Mon, 23 May 2005 23:19:03 +0200 (CEST) Received: from [10.0.1.11] (d5152B1F3.access.telenet.be [81.82.177.243]) by apate.telenet-ops.be (Postfix) with ESMTP id 095B13895D; Mon, 23 May 2005 23:19:03 +0200 (CEST) In-Reply-To: <42924803.3020101@pillette.com> References: <6d31bed04ab35cbbe2df37af979d9882@implements.be> <42923CA3.1040306@pillette.com> <3513c801b1c6c11559b50ddf24dbb2be@implements.be> <42924803.3020101@pillette.com> Mime-Version: 1.0 (Apple Message framework v622) Content-Type: multipart/mixed; boundary=Apple-Mail-179--1010507509 Message-Id: Cc: Hendrik De Hertogh From: Yves Vindevogel Subject: Re: Fwd: Index on table when using DESC clause Date: Mon, 23 May 2005 23:18:49 +0200 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/349 X-Sequence-Number: 12513 --Apple-Mail-179--1010507509 Content-Type: multipart/alternative; boundary=Apple-Mail-180--1010507509 --Apple-Mail-180--1010507509 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed God I love the sheer brilliance of that minus trick :-)) Tnx a lot BTW: Are there any plans to change this kind of indexing behaviour ? It makes no sense at all, and, it makes databases slow when you don't=20 know about this. On 23 May 2005, at 23:15, Andrew Lazarus wrote: > What you are trying to do makes perfect sense, but for some strange=20 > reason, Postgres doesn't like to do it. In a PG index, all of the=20 > columns are always stored in ascending order. So if you have an ORDER=20= > BY that is all ASC, it can start from the start of the index. And if=20= > you have an ORDER BY that is all DESC, it can start from the end. But=20= > if you want one column (like pages) DESC and the other (description)=20= > ASC, then PG will use a sequential scan or something else slow and=20 > stupid. > > Other RDBMS know how to do this, by supporting the > > CREATE INDEX foo ON bar(baz DESC, baz2 ASC) > > syntax. For PG, you need to fool it with an index on an expression, or=20= > a custom operator, or something. I once just made an extra column and=20= > used a trigger to be sure that -myvariable was in it at all times=20 > (-pages for you) and then made my index on the extra column. Since the=20= > extra column in ASC order is the same as the original in DESC, it=20 > works. > Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements --Apple-Mail-180--1010507509 Content-Transfer-Encoding: quoted-printable Content-Type: text/enriched; charset=ISO-8859-1 God I love the sheer brilliance of that minus trick :-)) Tnx a lot BTW: Are there any plans to change this kind of indexing behaviour ? It makes no sense at all, and, it makes databases slow when you don't know about this. On 23 May 2005, at 23:15, Andrew Lazarus wrote: What you are trying to do makes perfect sense, but for some strange reason, Postgres doesn't like to do it. In a PG index, all of the columns are always stored in ascending order. So if you have an ORDER BY that is all ASC, it can start from the start of the index. And if you have an ORDER BY that is all DESC, it can start from the end. But if you want one column (like pages) DESC and the other (description) ASC, then PG will use a sequential scan or something else slow and stupid. Other RDBMS know how to do this, by supporting the CREATE INDEX foo ON bar(baz DESC, baz2 ASC) syntax. For PG, you need to fool it with an index on an expression, or a custom operator, or something. I once just made an extra column and used a trigger to be sure that -myvariable was in it at all times (-pages for you) and then made my index on the extra column. Since the extra column in ASC order is the same as the original in DESC, it works. < Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements = --Apple-Mail-180--1010507509-- --Apple-Mail-179--1010507509 Content-Transfer-Encoding: base64 Content-Type: image/tiff; x-unix-mode=0666; name="Pasted Graphic 2.tiff" Content-Disposition: inline; filename="Pasted Graphic 2.tiff" TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+FP5+v9rOh5P9IMBuP8zK9tP8fJNlP8QoNjP8FndhP 8MnyVjJHSMrqFnv9BL1vP9ett2v98PuJxChUOiUWGQOCUalUujOV4PZ/qBluR/mdVtJ/jVHst/ho 9MF/g08WABHJfv8AWa0WoAHFfWuzgg6sB/hY9ysUohjv8qqVqv9LMZxv9ouV40zEYmHUjFY2HPx+ RNtOl4Rhftt/phiRs6LC/iA5LewnJeWg46W22+02cAHOwa26bC0HPY7TZ7G2G9dv8EHFdP8Om9YP 8rKJov9UtFzv9Dzh/sRvu5/vZ9PzHdeF4zsUqgQRlOR5v9DMBwv8uqe/jZIVwNHu6B0/WAKHvWGr RAA1ra0G1c/vfgANrdraXrTQIAA6JW2TUrQNz/ja0oAjO4YAjSWS0DOWawjys4RkIk4Lj2sAWEUZ B/ieUJqH+PZdnAf5aG06R5nsfLtqW7UaoWZJwukwLyi4VRsn+F5HGYf8QJWBQ7JWAI5tYti2Dm1T bQHAq0De1Q2FwtA1Fof4AjVDIBDQV0vDQWK0DY/oADYWsrNQN81NOuDZtYOM6ycs4Cjq+Q9JWE5D pGJpOpqP5dMwW5sHUf53xlHCExupjqoIbh3Hu55vp6ch3Hof4wlMrAdEWYh/gmP1RtXK0DDi2rXy nVzXjpVs8NM1g1vuNU2gANEugGMBRwu4YADTNsvwyAA3v+0k6LRWLb2dBUpjk2I4NVOx/gYPC6BU QiwCgSsSlWZpxH+ahzsOaBzvCe7qoMpKlUghd1n2f5oHId5/lQaJ0n+RBf3GLpUGwf4iksrg0FVF ICzlXT9QBB0tWO/+FjlKVWtfijTNRBsvDbhrdP3NUAwY38KFfkc0PuNjRWLLz8ytiTUVdVlnjlA2 MWPAWRAAM8LAAMjhhuR5ir4ULjigT5pn+P5co2T6pn+YBup6dp6xoh6kHie95modNOFkah0H+Qhd pyKBNmcf68r2Bo9GGtdpwIAUotM1Q4QMNzUDZhuVZbLsvy7KkqZZCnAb4AFcQY1C3LW1Wb5lOa2t ZvUt78NNjcMN83wEOMDczvuTzXNQ3QEN01WRL2b8XBYEDuugQEFUYgkpIo5FjIJTmhfZkHG8J0nm fB/sifp/EQYLBioUKsBkRKVgWPLX7stA4VnaDa+tZlZel0j+gCMpWS8MRULQNeIDY/4zTIAIyFX0 GFybZnr+rZ8p2a1s6tUNfADXXI1Yb8jLX+MNQk+1Az7zWqwVa/FaJrHpvSLeAQOhdE/l7CSJwrAb BXDXH+PkyA/gUiPGaftASWW6JeDgnGAsCmLNvcYqlz5+FchnZMrqGbeE3JoYhAMAKbEvOGeigtaE CDZwJcgxtiML0uMgQYzllKt2GhtP/EaH6cgAm+fnCtVEVXFOKNU54AC1B/tyLfBx4YJBGwhAAG5m yUoGH/TgxlZ7nGXw3YdEpYTPWOvaSq/JVEX28rEDQsGKDoGPx+QYnE1URg2paZY4dy7EHTx9cc41 upqIfwkjSgJWyW0MgBdK9I1DGAAwnS8G8+4cGYyUWWbKMg/gSiOjQG+FMQ44qqlmgBNUSYYMohKW 2ULFZaR8NdMFucoz/w/ZcAAMzgH+j/AKGV8QAZkhmWNM0AJ/I5zCiJEGYjF1qoGmxI5MqwT7JVlG buLULJhPXlbK+WMt3HwHmIbF8xaA0n6mvPgN7EJhx9Vcax+hsX6wGZuldNDnTSgQDoloGohS6BYE 62gPQqyRhlFE2gIYkCRgdD4WcAUsnxvlYklKgUCn4upi29JkkpG/pbYgtKbr86TLOnbLCF066ZLP kGsI+7NY9rRjZHB+0ew4M5S0AKT4FA8l0BaIUk4XHkj/EYLwzAtVyj/GwRYf49B8D6H+OMdw9R/j DG8vcTgx1xhpFTBoHYilRgaDygQAobXCynVVSSVdRYTLJls5CcIaqX0zpw/Kms76c2DSnTsNNPaA TbpggqOSCg4MkQwcAPiBAzimJqI4Xg3R/itX0P8bY66xD7MiYkgg5h4vAF2NgdY/xNGCH+HQVMIQ WiCNVM2L6Ap4s3ShFixMubA2HnjcUulhab3GuIbGxVjLlxXZoawMKFgsCiaSOUd6nB6XbH+PofKN LtqcH7eMf5AyimQOtegf4/TIEFvYP8dyjTm2eV1KdmNgrlIKr/cOxF+LjmRldTZY88L/U6P/YtyF +b82PDAhkOQsyNkHu8jS76NB4YXH+PvDUG7v3lIFeu8mFbuj6q8PXE2HEaXqIEUEgxnh2T2YhD/B WBZcUunVjO59yMB3PsHc3BONLemxwaP8NwsTMEPvVeMieJKvXmHZk8f48h5GHyYP8e+V3g3tvMQs VY01FLCxjgTHk8b943yBTOVoJEiXJzPgae1zr+2HwYhnIuRzrjczwP8eY8zDmKy7l8NOYcx40zKW nNswizytg+kXHc/qS48x9o7QbNMhZ0yMdvPBG7wmNz/jB6WYs436uFmbHhbFrAFgjhl4Y/g5IvH+ 0EkYFw+NuAHqmoet9bWJwPnDHEfM55E0udjTNW7uZ+y9p6L+oNe3Bxtoa4lACzgQee2kQ5Jwo1RK QPQfK8xejaJ6FG6w/wEh1NZJ+L6ydoH+zfqTUK0dK7AzsY7Yem9jaA0Fu2wVf9eJObqW+TxuwbCS K4JEYVnh2O/vWQM5K+wtCehCCAP5YABybV035xCAJIJqnrTyFqB9H8e1Lu/OumM870MTp3MGn9J8 g5Zsxhk2ZURLfGmrBAEg5m/CISIf4jRekblaCgRoyS0BjWNZVw6uZ70hnsrkND/Fbn3kWWtmz1ID a5NxyLYJ1xujdI3iZTm9dkYy4/P9yFKIcFoDQsbtKW4nT2YbLrpr450V6zTGem7N+YzXVzDZ0PSl ddIb8GQVrlD9sQjy4FKHVy0ZDDeLHCPWuuD/68Y0Vg1LX8c0bQSBiAq9JrVv2pYwZkzq6mqxDi8y XJgBkjZGftMMdUgm5PKyCBnogBI72hYgZlgrD6WWgMzPZkxGdUzfIfIzsdb66PXr/Jxp+XwRGlOL GnuJm2b0l7vo/dJeDL4N7qwWN+qn5CqedNMATuzZmObaad1s4dBMl/6wmG/Pt1+oAAYk2hToiuQc 5FxyjyRoHqH0xYKE+Q8k+UIgH0KAH+HSHqXmGwHSIuEGF0I25eWE8A96/g2akwhIk8Puf25mpi3w /IeG/M8y0O10/WgM3cpUS8l0mS+ocOYgDQS0ASDUTOB6EaJWDkXyXwFyL+GqGkPKHQHMOkxIXmIO HAHAJyyuKgvGIIHgU2H+G0GuHKH+FwF6KwEAtAH+CUEcLOAiNC2QnKcOZSZCmO9ongNep2sA3Y2W nY/KwE9hDazc8w8Sug9mh6cAZ0/UAEC0FKH+AOCOEoJQBeD8H+A2A+DYYGBuD2H+D6DmFCH+F0Fq hDB+PKGcGaaSGsGmJyGOGGg0EuEgP0CqCOEOH+BIA+DQH+AgBSDrD+CAEcH+AICwFNA+pamupfDQ /G1E2asfDksJDesNBCv012x+5WDmQSseeiAaCGEiH+BEAmC0H+A8AcCyH+A4AXGqAqAOCsLqAQCw H+BMAuDIH+CJEWPMCpFKCaCEEASEBFESA2AaC2H+AoAOCqK6AVGqA8AYCvGcAiC9HmBlHZBglBDt F80LF7BNDdBHDg2U0JGI0lGEseWsAgB6EYH+BUAkC4H+BKAuDDGcArH+BCAnH+A8AeC6K7HjG7H4 AoANHtG1G4A1GxGkAfHkBAAjJOBCAqC/FMAuDAH+BOApJ8A0BYDy2aWtGEzI1G2dKRIUwDGDF9BP DooBISnVImB9IsBRJHI2AuDHK3HHI4DFK3K6BGArI8BAAlJ8A8AhJqAlJxJBK3LDLBK9LmBNKCH+ AwBZEZIGcjGM3zKVIRL7BEH8zVKfKojrKlMCQVIk2jKuH/KzH/I5K7MjLFMpMnI5HGBIAvG/I5J9 MvMrK5M/K7LrJ9LxL1DXL5KYp1L/MM80g2wABMzWAGjVDZIc/XDrIiNjKtKxK1MtNBN7MlN9HFJ5 M3J7NDONMnNHLvLzKNKnMS5dNPMAsGpgLKLoAQNswAH8EAGAXGB0EobQAwEEJOblOa1uzJIfNvF9 MXFVMbMfOPODOBOBMxM1K3M7PfPdNFLtNLOZOcfjIOgVPIfeAaD2VGBUEY6ECyFQL+awXWH+HCHa KgW+KoAqDsPu3Mt8rxMO+fOjPTNzMZN3MhPtN/M/PlOJPrPhPvHBPzOXL3KPKhP69Mv4SmYWWs4m QyDGFUGsH+GeHEOkHW204SIED6FmaSBqeZHmQ3Fikw7iPwZWkCSs40Yg0CwTQAxpPUAhPZN5RDS1 PjOHPpRRRFOTP1RZSo5W1skw6MDa6g5omYZW94AYDkN+BOD+NKCoE6SKHy1WA8EOL2Z8cuhGTU/f SlArAu95L2cmiO1xSrQ7PXQ/S/S1RJS9RFUlNBTDRXNPRavw3St25kTXBiQsADBfUFNO/fUC6K+A N+9fTI2SkOfG6YmY9MZWDEFS+0TInFUQSfPI1NQ9MdSzRPUnS5MzRLUdRPUqD02RRaeoseDdSaQn ScQi9G/kPu+e/o+E8UQUoGv/IXMKsOfqZu8O/eV2S89E7QZ7XG8w/edGQYxiTeoSB3FKBQAlRBV9 S3LnWDUjXpN7LCBOAnJ8AyBXKKV0Z7KPKO6i764rXI9wS8DJVq6TAw+hP5MFBJDi0Ofq0i86mQPv XMDRWlBi6QVy6iAYCUEuJIBDESBGA0DNI2AxLjRCAxS4BGAvH5I5J2BLZdZVV9ZtZqDKJIA+DUH+ AiB4ES2a4pDFDE+fVIkg84ZylyTUn7RdYjIZYhQy14fipY9SDTWhSjRg6UAEC+fZGWEfEMBCDbFM AtJ9MzI9LlM8BFZjJ5ZpNBMzLCBJLKH+A+A3ZSAiByEMmcC0FO7Q7eTVSW+ectBY9HQ2oFDTNXak Ns9fIa0hPPVUfqfq5i3OjohIAEC6fYAWB6ERFUBSDxLuAtZSA7JSA/JoH/LPH+BIAtK7bZG4BGAt JCApH+A+AhJPGnJOA0AfH+AiBIDoWuBzc6AICvD8PxUAWJWWj2sfWwsPP9cXWzKc/PGE0jPQvwiE 9kWsAeB+EVI2AaCpdQAbGjGnHkA4AbJPHhI0A2AZI0A6AdI1drG+A6AfG/HhGjfVI1fLfJGpfBGq BGAZHsAvKJA+j7eZencVNSlZGBelINchalStIqbTV7J5I8BDLtdrJPfLfSAZHkA2AXfPfXENJTfl JrK0BFdjMoBOArX7UsYhUxaledgRcZgVBLMTepVU17StSxXlMrZzbgAtLDgrdoAlGiBBK1dhZZLi AxK/OFORRVNNhbhu0PhhafgTW1gXilgbgRhzUbV/OOAwDPFMAxe/ZrPriXXnWJidP3hiuZgPiphk eGA8EUJGWEc3MNhtgdUXSvi5XxS1Z3Zhe/MzbfjNRRUrieVpeejtOg0OseDeNYQexAIEE4GcX2B4 EkRKAMDsNjXSTWcVVVjvi1jzh1WHM/j8AvkAAvkFlHkLjVjdjZF4pPk0nANKLKQIBCESL2D6F6XG XgvWqwHQMqEsGIRaL6RSAgD6bcQAbyNRBkLQDCWNhdNxkPj1V5h3i7N7lLlPlTmtUpjTTHak1tUE DHDyQMDWN+ggQIByEiJOEGOcGIG8Okq7CMXay2KMG8HaU4rcMGCIE8aSBcEWL2Ci4ccggbKXhxlD j3jPPdmxbdLnm3PxNJhZkO1CseseDUNKBIEMJWB8EqhCBqEuGgH+DiFiL+GXQcINAEIhl4McIkXc IICurWWuDulCNiDW85VVi3mplHmuH/j/oZM9odRTohkNNQnjYIc6QIAILmH+BgEOLOtabCUcIPpV qiIOHMKeOQGoJ6C+FaMwAuEJT474DYTfliJQrbgjmrj5OBoXkDobrTJ/LsArX+LQDI72nBlkJQLv C2FBpAEoGOMGGhqsvKH7nlqpqlnpsKKMHgJ+tgGQPKCmFIaSAwD8LOA4EGJWBiCdEFH1G/iPp0Av rXlRrboTdXLDdrI0BSBkD4H/n8JOAkD7o0EwhCECF+PKG6HceBsQRtsPtyOuq4/+22RcFYJGBkBK Ddp4AtI8A2AdHkA/H9uPZZrVp5lNp9OFMzK7iLJ9HhHlgrJ8BSA3FSEWECe+vNsVnkXdt4MVqnvR qiHmHkKgF+F0JqEMD8fECQB4D7uPI8AyAZGjubJ8BAAqClbqAng4AbfZdsKyBTuMDiDOE2H+FmFe JGHMU1vXwrvVwrwxCKagF3pADyDiFEH+CWCAEHJ+A3G4B+BmDmH+DQC7EEFGE4NKHYHUXvwxxqIj t3xtxyIaw0ImGwGus8HgUZx1yGavxxyJyPyRySKIKQFuFibQGOGEYFyVynypymKQCaB/xIDkDOE8 IQFSFEVGE+EsQIIWGEF4L+EwEeP6IOE4EoN2DOC0ErpCDLy6DYDAEyH+FiFU6EHyq6H+DqDUFAH+ G4GwOWIWw0IIEMD68HzsE0H+DgDIE4H+DaDD0cG8G4X2FgFS6EFGE2LAIWG0GsHMH+EoEWTaIOFn uEH+DKCzzkDjzoH+DJ1aH+FuFgbRsGIIEKD2fZyCrEIOGUGMI2E8EqNLz6XmDsDXEgDUC6EwH+DW C9zx1ZzkF4FuOOHUq0D8Dnb8DeDHwd0h0kEeEKQsKQCkCLFKDv2SIQD6DkFJENg2H/ygYFxkPCBu BQDkH+CwCXIsIOCiCJb2CQB0D+H+FEE0LoEYEGTOCgCGEKH/2uMrGfI8GEF7RyIWHwOoH+CEBptU EaEITOFCEyLOF0FoJr16aUDpb9fbH+GAF0RSz2KgCABjdACSB4ED3V3YH+C8CjbCFAEwLP006EG8 G2X35LbnK6B/5iH+GcGSs8FoFehCC0CYEavXAT5WRSDyDdxACKBtvwFwFkJqHEHAUVxeLACSB3HZ 2GNKEyEgP6EsEaNEKQCn3MH+DuDZEgIOEUEAZMDuDbxB7jFL5zbCDQC2Et2cC/zwIP8AH+BoBKDf 1iCxEEC4CfFgEqEYNFCeU4BWA2DSXIGgXGIWu+XmCQB35r2R0EEgEOQyIWEOD88GECDvVmCyCZIs DACpGaE0EkN+DP8GIQEGDyFUH/3LFL0Ue+HkHh18IMHPwoCqCRe54ILoCMBvEKC6Cl8CC18IIWFa FKL2DGCtEEIXE0MH2+H+EKD4fZ10fZ374Z7h7l7p7sIMEF9eRd6d1p1t4H4L/ohCDECsEkIQIAVC MiX+dTUoH++n0/X++4W/4hEHe7Xo/xQGTO/zQXEu/0Cd1S/0Yglg/3g73q/yWPUE/zsa1C/0IeVW /0GeFU/3G4Xa/0MfVY/1or2bQlbRUiiVpJpQ/y+U0jEYggzzOSkRUM/0KfJqfzop3+p1Aw3+53I7 n+UCJWak3m26H+OxYdX+Xiij6leVRY3+YKheaks1Yy3+VCPBEIe5zM5qOxbdICAADgEAAAMAAAAB ADgAAAEBAAMAAAABAEAAAAECAAMAAAAEAAAWdgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQA AAABAAAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA CAAK/IAAACcQAAr8gAAAJxA= --Apple-Mail-179--1010507509 Content-Type: multipart/alternative; boundary=Apple-Mail-181--1010507507 --Apple-Mail-181--1010507507 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Ghandi. --Apple-Mail-181--1010507507 Content-Transfer-Encoding: 7bit Content-Type: text/enriched; charset=US-ASCII Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Ghandi. --Apple-Mail-181--1010507507-- --Apple-Mail-179--1010507509-- From pgsql-performance-owner@postgresql.org Mon May 23 19:23:51 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1B3DC52862 for ; Mon, 23 May 2005 19:23:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28747-10 for ; Mon, 23 May 2005 22:23:48 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 8E2FC52812 for ; Mon, 23 May 2005 19:23:47 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4NMNk5l004989; (envelope-from ) Mon, 23 May 2005 17:23:46 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4NMNjI7010569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Mon, 23 May 2005 17:23:46 -0500 (CDT) Message-ID: <429257ED.6020004@arbash-meinel.com> Date: Mon, 23 May 2005 17:23:41 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2-1.3.3 (X11/20050513) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Parker Cc: pgsql-performance@postgresql.org Subject: Re: seqential vs random io References: <07FDEE0ED7455A48AC42AC2070EDFF7C746598@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C746598@corpsrv2.tazznetworks.com> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigA506A3286E2A046E328BFC44" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/350 X-Sequence-Number: 12514 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA506A3286E2A046E328BFC44 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit David Parker wrote: > I just got a question from one our QA guys who is configuring a RAID 10 > disk that is destined to hold a postgresql database. The disk > configuration procedure is asking him if he wants to optimize for > sequential or random access. My first thought is that random is what we > would want, but then I started wondering if it's not that simple, and my > knowledge of stuff at the hardware level is, well, limited..... > > If it were your QA guy, what would you tell him? > > - DAP Random. Sequential is always pretty fast, it is random that hurts. The only time I would say sequential is if you were planning on streaming large files (like iso images) with low load. But for a DB, even a sequential scan will probably not be that much data. At least, that's my 2c. John =:-> --------------enigA506A3286E2A046E328BFC44 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFCklfvJdeBCYSNAAMRAn2WAJ41931HS6qX76S/d6ZdfEv5MyC+QwCeJC6R Kwt2q1dJb0ykrw9oJwuxW00= =qS7/ -----END PGP SIGNATURE----- --------------enigA506A3286E2A046E328BFC44-- From pgsql-performance-owner@postgresql.org Mon May 23 19:31:09 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A0AB65280A for ; Mon, 23 May 2005 19:31:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30218-08 for ; Mon, 23 May 2005 22:31:07 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 0778B5288B for ; Mon, 23 May 2005 19:31:06 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7397904; Mon, 23 May 2005 15:33:11 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: John A Meinel Subject: Re: seqential vs random io Date: Mon, 23 May 2005 15:32:35 -0700 User-Agent: KMail/1.8 Cc: David Parker , pgsql-performance@postgresql.org References: <07FDEE0ED7455A48AC42AC2070EDFF7C746598@corpsrv2.tazznetworks.com> <429257ED.6020004@arbash-meinel.com> In-Reply-To: <429257ED.6020004@arbash-meinel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505231532.35532.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/351 X-Sequence-Number: 12515 David, > > I just got a question from one our QA guys who is configuring a RAID 10 > > disk that is destined to hold a postgresql database. The disk > > configuration procedure is asking him if he wants to optimize for > > sequential or random access. My first thought is that random is what we > > would want, but then I started wondering if it's not that simple, and my > > knowledge of stuff at the hardware level is, well, limited..... > > > > If it were your QA guy, what would you tell him? Depends on the type of database. OLTP or Web == random access. Data Warehouse == sequential access. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon May 23 19:35:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7BEA85289B for ; Mon, 23 May 2005 19:35:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32074-07 for ; Mon, 23 May 2005 22:35:44 +0000 (GMT) Received: from vt-pe2550-001.VANTAGE.vantage.com (vt-pe2550-001.vantage.com [64.80.203.244]) by svr1.postgresql.org (Postfix) with ESMTP id C04EA52862 for ; Mon, 23 May 2005 19:35:42 -0300 (ADT) 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="utf-8" Content-Transfer-Encoding: base64 Subject: Re: seqential vs random io Date: Mon, 23 May 2005 18:35:44 -0400 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098A4B@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: seqential vs random io Thread-Index: AcVf2ifxPsn5CStxRoKCT3mP9nUGCAADSEgl From: "Anjan Dave" To: "David Parker" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.04 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/352 X-Sequence-Number: 12516 SSB3b3VsZCB0ZWxsIGhpbSB0byBnbyBmb3IgdGhlIHJhbmRvbSwgd2hpY2ggaXMgd2hhdCBtb3N0 IERCcyB3b3VsZCBiZSBieSBuYXR1cmUuIFdoYXQgeW91IG5lZWQgdG8gdW5kZXJzdGFuZCB3aWxs IGJlIHRoZSBjYWNoZSBwYXJhbWV0ZXJzLCByZWFkL3dyaXRlIGNhY2hlIGFtb3VudCwgYW5kIHN0 cmlwZSBzaXplLCBkZXBlbmRpbmcgb24geW91ciBjb250cm9sbGVyIHR5cGUgYW5kIHdoYXRldmVy IGl0IGRlZmF1bHRzIHRvIG9uIHRoZXNlIHRoaW5ncy4NCiANClRoYW5rcywNCkFuamFuDQoNCgkt LS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLSANCglGcm9tOiBEYXZpZCBQYXJrZXIgW21haWx0bzpk cGFya2VyQHRhenpuZXR3b3Jrcy5jb21dIA0KCVNlbnQ6IE1vbiA1LzIzLzIwMDUgNDo1OCBQTSAN CglUbzogcGdzcWwtcGVyZm9ybWFuY2VAcG9zdGdyZXNxbC5vcmcgDQoJQ2M6IA0KCVN1YmplY3Q6 IFtQRVJGT1JNXSBzZXFlbnRpYWwgdnMgcmFuZG9tIGlvDQoJDQoJDQoJSSBqdXN0IGdvdCBhIHF1 ZXN0aW9uIGZyb20gb25lIG91ciBRQSBndXlzIHdobyBpcyBjb25maWd1cmluZyBhIFJBSUQgMTAg ZGlzayB0aGF0IGlzIGRlc3RpbmVkIHRvIGhvbGQgYSBwb3N0Z3Jlc3FsIGRhdGFiYXNlLiBUaGUg ZGlzayBjb25maWd1cmF0aW9uIHByb2NlZHVyZSBpcyBhc2tpbmcgaGltIGlmIGhlIHdhbnRzIHRv IG9wdGltaXplIGZvciBzZXF1ZW50aWFsIG9yIHJhbmRvbSBhY2Nlc3MuIE15IGZpcnN0IHRob3Vn aHQgaXMgdGhhdCByYW5kb20gaXMgd2hhdCB3ZSB3b3VsZCB3YW50LCBidXQgdGhlbiBJIHN0YXJ0 ZWQgd29uZGVyaW5nIGlmIGl0J3Mgbm90IHRoYXQgc2ltcGxlLCBhbmQgbXkga25vd2xlZGdlIG9m IHN0dWZmIGF0IHRoZSBoYXJkd2FyZSBsZXZlbCBpcywgd2VsbCwgbGltaXRlZC4uLi4uDQoJIA0K CUlmIGl0IHdlcmUgeW91ciBRQSBndXksIHdoYXQgd291bGQgeW91IHRlbGwgaGltPw0KDQoJLSBE QVANCgktLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQoJRGF2aWQgUGFya2VyICAgIFRhenogTmV0 d29ya3MgICAgKDQwMSkgNzA5LTUxMzANCgkgDQoJDQoNCgkgDQoNCg== From pgsql-performance-owner@postgresql.org Tue May 24 02:47:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 34A355288B for ; Tue, 24 May 2005 02:47:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34224-03 for ; Tue, 24 May 2005 05:47:21 +0000 (GMT) Received: from web53106.mail.yahoo.com (web53106.mail.yahoo.com [206.190.39.209]) by svr1.postgresql.org (Postfix) with SMTP id 8298152849 for ; Tue, 24 May 2005 02:47:19 -0300 (ADT) Received: (qmail 3990 invoked by uid 60001); 24 May 2005 05:47:15 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=1lpNa5tHopoAPuYspEXPbKmsomJu7TjZMTb6YQ7/qkIqx3pJCnmOUTncBoNMF+CA80Hi2dwVwhitzCRnVTQm+VapVWGVWYiYDYPk5YwRwFAtqiv7K4UOHaeuhIkLptaK2kyypTwXGp9I3bDQvsN/ZnEhb1e75XdkF7EZMwXElUU= ; Message-ID: <20050524054715.3988.qmail@web53106.mail.yahoo.com> Received: from [68.70.32.45] by web53106.mail.yahoo.com via HTTP; Mon, 23 May 2005 22:47:15 PDT Date: Mon, 23 May 2005 22:47:15 -0700 (PDT) From: mark durrant Subject: Select performance vs. mssql To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.266 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FROM_ENDS_IN_NUMS X-Spam-Level: ** X-Archive-Number: 200505/353 X-Sequence-Number: 12517 Hi, I have some experience with MSSQL and am examining PostgreSQL. I'm running under Windows. I like what I see so far, but I'm hoping for some performance advice: 1. My test database has 7 million records. 2. There are two columns - an integer and a char column called Day which has a random value of Mon or Tues, etc. in it. 3. I made an index on Day. My query is: select count(*) from mtable where day='Mon' Results: 1. P3 600 512MB RAM MSSQL. It takes about 4-5 secs to run. If I run a few queries and everything is cached, it is sometimes just 1 second. 2. Athlon 1.3 Ghz 1GB RAM. PostgreSQL takes 7 seconds. I have played with the buffers setting and currently have it at 7500. At 20000 it took over 20 seconds to run. 5 seconds vs 7 isn't that big of a deal, but 1 second vs 7 seconds is. Also, the slower performance is with much lesser hardware. Any ideas to try? Thanks much, Mark __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From pgsql-performance-owner@postgresql.org Tue May 24 03:18:45 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 64293528AD for ; Tue, 24 May 2005 03:18:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37734-07 for ; Tue, 24 May 2005 06:18:34 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 1FBB152875 for ; Tue, 24 May 2005 03:18:30 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id B980A24FE0; Tue, 24 May 2005 14:18:28 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 9580224FCE; Tue, 24 May 2005 14:18:28 +0800 (WST) Message-ID: <4292C73C.60006@familyhealth.com.au> Date: Tue, 24 May 2005 14:18:36 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mark durrant Cc: pgsql-performance@postgresql.org Subject: Re: Select performance vs. mssql References: <20050524054715.3988.qmail@web53106.mail.yahoo.com> In-Reply-To: <20050524054715.3988.qmail@web53106.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/354 X-Sequence-Number: 12518 > select count(*) from mtable where day='Mon' > > Results: > > 1. P3 600 512MB RAM MSSQL. It takes about 4-5 secs to > run. If I run a few queries and everything is cached, > it is sometimes just 1 second. > > 2. Athlon 1.3 Ghz 1GB RAM. PostgreSQL takes 7 seconds. > I have played with the buffers setting and currently > have it at 7500. At 20000 it took over 20 seconds to > run. > > 5 seconds vs 7 isn't that big of a deal, but 1 second > vs 7 seconds is. Also, the slower performance is with > much lesser hardware. Post the result of this for us: explain analyze select count(*) from mtable where day='Mon'; On both machines. Chris From pgsql-performance-owner@postgresql.org Tue May 24 03:40:48 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 72CBB5287C for ; Tue, 24 May 2005 03:40:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41655-09 for ; Tue, 24 May 2005 06:40:38 +0000 (GMT) Received: from web53105.mail.yahoo.com (web53105.mail.yahoo.com [206.190.39.208]) by svr1.postgresql.org (Postfix) with SMTP id CF00E5280A for ; Tue, 24 May 2005 03:40:37 -0300 (ADT) Received: (qmail 18215 invoked by uid 60001); 24 May 2005 06:40:34 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=rEU/IaSJ/+lMm/XIvFerIsrhM7LtxHeL9b3XGF4lDHcn6wmH+y6+X+Tvg1n21rMKDVFGORgfeFt7qZo/K/oSpXHmofQL0pfQmRdxlTFVvz81VrYs7OlSCvW6S+ZJzvVadzQ67TwAKlV43/9769UoEMn0kNHbYR1ARqie+iveIdI= ; Message-ID: <20050524064034.18213.qmail@web53105.mail.yahoo.com> Received: from [68.70.32.45] by web53105.mail.yahoo.com via HTTP; Mon, 23 May 2005 23:40:34 PDT Date: Mon, 23 May 2005 23:40:34 -0700 (PDT) From: mark durrant Subject: Re: Select performance vs. mssql To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.829 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FROM_ENDS_IN_NUMS X-Spam-Level: * X-Archive-Number: 200505/355 X-Sequence-Number: 12519 > Post the result of this for us: > > explain analyze select count(*) from mtable where > day='Mon'; > > On both machines. Hi Chris -- PostgreSQL Machine: "Aggregate (cost=140122.56..140122.56 rows=1 width=0) (actual time=24516.000..24516.000 rows=1 loops=1)" " -> Index Scan using "day" on mtable (cost=0.00..140035.06 rows=35000 width=0) (actual time=47.000..21841.000 rows=1166025 loops=1)" " Index Cond: ("day" = 'Mon'::bpchar)" "Total runtime: 24516.000 ms" (Note this took 24 seconds after fresh reboot, next execution was 11, and execution without explain analyze was 6.7 seconds) MSSQL Machine: That "Explain Analyze" command doesn't work for MSSQL, but I did view the Query plan. 97% of it was "Scanning a particular range of rows from a nonclustered index" Thanks for your help --Mark __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From pgsql-performance-owner@postgresql.org Tue May 24 03:47:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 94DA2528BC for ; Tue, 24 May 2005 03:47:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45695-02 for ; Tue, 24 May 2005 06:47:38 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 0335C528A7 for ; Tue, 24 May 2005 03:47:38 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 23F9818D141; Tue, 24 May 2005 02:47:39 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 57047-01; Tue, 24 May 2005 02:47:37 -0400 (EDT) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 871A618D091; Tue, 24 May 2005 02:47:36 -0400 (EDT) Message-ID: <4292CE03.1070605@samurai.com> Date: Tue, 24 May 2005 16:47:31 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mark durrant Cc: pgsql-performance@postgresql.org Subject: Re: Select performance vs. mssql References: <20050524064034.18213.qmail@web53105.mail.yahoo.com> In-Reply-To: <20050524064034.18213.qmail@web53105.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.021 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/356 X-Sequence-Number: 12520 mark durrant wrote: > PostgreSQL Machine: > "Aggregate (cost=140122.56..140122.56 rows=1 width=0) > (actual time=24516.000..24516.000 rows=1 loops=1)" > " -> Index Scan using "day" on mtable > (cost=0.00..140035.06 rows=35000 width=0) (actual > time=47.000..21841.000 rows=1166025 loops=1)" > " Index Cond: ("day" = 'Mon'::bpchar)" > "Total runtime: 24516.000 ms" Have you run ANALYZE? Clustering the table on the "day" index (via the CLUSTER command) would be worth trying. -Neil From pgsql-performance-owner@postgresql.org Tue May 24 05:47:03 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E83D5280A for ; Tue, 24 May 2005 05:47:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70224-09 for ; Tue, 24 May 2005 08:46:59 +0000 (GMT) Received: from pc7.berlin.powerweb.de (pc7.berlin.powerweb.de [62.67.228.13]) by svr1.postgresql.org (Postfix) with ESMTP id 32E9E528A7 for ; Tue, 24 May 2005 05:46:57 -0300 (ADT) Received: from spock (pD9ED0646.dip0.t-ipconnect.de [217.237.6.70]) by pc7.berlin.powerweb.de (8.9.3p3/8.9.3) with SMTP id KAA12677 for ; Tue, 24 May 2005 10:46:57 +0200 Message-ID: <005b01c5603d$7163bac0$6602a8c0@spock.nostromo> From: "Harald Lau (Sector-X)" To: References: <20050524064034.18213.qmail@web53105.mail.yahoo.com> Subject: Re: Select performance vs. mssql Date: Tue, 24 May 2005 10:49:05 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/357 X-Sequence-Number: 12521 Mark, > MSSQL Machine: > That "Explain Analyze" command doesn't work for MSSQL, try this: set showplan_all on go select ... go Harald From pgsql-performance-owner@postgresql.org Tue May 24 12:36:45 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 769E852862 for ; Tue, 24 May 2005 12:36:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55312-03 for ; Tue, 24 May 2005 15:36:42 +0000 (GMT) Received: from web53101.mail.yahoo.com (web53101.mail.yahoo.com [206.190.39.204]) by svr1.postgresql.org (Postfix) with SMTP id 552F75281A for ; Tue, 24 May 2005 12:36:41 -0300 (ADT) Received: (qmail 64527 invoked by uid 60001); 24 May 2005 15:36:37 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=Smiefwxt6Qi3jYwnxHphhO2gVI2HsJaJtwlyodGvdjVat6mWqLphDZtPoeeaS+QFwzSJzeMBv8SwSXdwvZHZc1eGYMEcM0qi+cSOLSlVLZB3qmieDYlEIQR32p+/ryyUsXA1SGV2eIDhMBVLrLuHxDHvLh4CAvPv63jIXbbNg28= ; Message-ID: <20050524153637.64525.qmail@web53101.mail.yahoo.com> Received: from [68.70.32.45] by web53101.mail.yahoo.com via HTTP; Tue, 24 May 2005 08:36:36 PDT Date: Tue, 24 May 2005 08:36:36 -0700 (PDT) From: mark durrant Subject: Re: Select performance vs. mssql To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.829 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FROM_ENDS_IN_NUMS X-Spam-Level: * X-Archive-Number: 200505/358 X-Sequence-Number: 12522 First, thanks for all the helpful replies. I've listened to the suggestions and done some more digging and have results: I did show_plan_all in MSSQL and found that it was doing an Index Scan. I've read someplace that if the data you need is all in the index, then MSSQL has a feature/hack where it does not have to go to the table, it can do my COUNT using the index alone. I think this explains the 1 second query performance. I changed the query to also include the other column which is not indexed. The results were MSSQL now used a TableScan and was MUCH slower than PostgreSQL. I clustered the index on MSSQL and PostgreSQL and increased buffers to 15000 on PGSQL. I saw a noticeable performance increase on both. On the more complicated query, PostgreSQL is now 3.5 seconds. MSSQL is faster again doing an index scan and is at 2 seconds. Remember the MSSQL machine has a slower CPU as well. My interpretations: --Given having to do a table scan, PostgreSQL seems to be faster. The hardware on my PostrgreSQL machine is nicer than the MSSQL one, so perhaps they are just about the same speed with speed determined by the disk. --Tuning helps. Clustered index cut my query time down. More buffers helped. --As Chris pointed out, how real-world is this test? His point is valid. The database we're planning will have a lot of rows and require a lot of summarization (hence my attempt at a "test"), but we shouldn't be pulling a million rows at a time. --MSSQL's ability to hit the index only and not having to go to the table itself results in a _big_ performance/efficiency gain. If someone who's in development wants to pass this along, it would be a nice addition to PostgreSQL sometime in the future. I'd suspect that as well as making one query faster, it would make everything else faster/more scalable as the server load is so much less. Thanks again, Mark __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new Resources site http://smallbusiness.yahoo.com/resources/ From pgsql-performance-owner@postgresql.org Tue May 24 14:06:06 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9B04152888 for ; Tue, 24 May 2005 14:06:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71249-09 for ; Tue, 24 May 2005 17:06:04 +0000 (GMT) Received: from mail-relay1.tagaudit.com (unknown [69.64.214.4]) by svr1.postgresql.org (Postfix) with ESMTP id 309705280D for ; Tue, 24 May 2005 14:06:03 -0300 (ADT) Received: from mail-hub.tagaudit.com (dns2.tagaudit.com [192.168.3.32]) by mail-relay1.tagaudit.com (Postfix) with ESMTP id 3605C200000B0 for ; Tue, 24 May 2005 13:06:03 -0400 (EDT) Received: by mail-hub.tagaudit.com (Postfix, from userid 8) id 2AFB4202EB; Tue, 24 May 2005 13:06:03 -0400 (EDT) Received: from xeon400.tagaudit.com (vpn.tagaudit.com [192.168.3.17]) by mail-hub.tagaudit.com (Postfix) with ESMTP id 11E4C202A6 for ; Tue, 24 May 2005 13:06:03 -0400 (EDT) Received: by xeon400.tagaudit.com with Internet Mail Service (5.5.2656.59) id <2C4CQYQ9>; Tue, 24 May 2005 13:06:02 -0400 Message-ID: <0C072E7CC947D511AC9600A0CC7341200256CF03@xeon400.tagaudit.com> From: Amit V Shah To: "'pgsql-performance@postgresql.org'" Subject: Need help to decide Mysql vs Postgres Date: Tue, 24 May 2005 13:05:53 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.8 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/359 X-Sequence-Number: 12523 Hi all, From whatever reading and surfing I have done, I have found that postgres is good. Actually I myself am a fan of postgres as compared to mysql. However I want to have some frank opinions before I decide something. Following are some of the aspects of my schema, and our concerns -- - We have around 150 tables on the DB - We have lot of foreign keys between the tables - Couple of tables are going to have around couple of hundereds of millions of records (300 Million right now and would grow). Few of this tables are fairly wide with around 32 columns, and have around 3-4 columns which are foreign keys and refer to other tables - Most of the DB usage is Selects. We would have some inserts but that would be like a nightly or a monthly process Our only concern with going with postgres is speed. I haven't done a speed test yet so I can't speak. But the major concern is that the selects and inserts are going to be much much slower on postgres than on mysql. I dont know how true this is. I know this is a postgres forum so everyone will say postgres is better but I am just looking for some help and advise I guess !!! I am not trying to start a mysql vs postgres war so please dont misunderstand me .... I tried to look around for mysql vs postgres articles, but most of them said mysql is better in speed. However those articles were very old so I dont know about recent stage. Please comment !!! Thanks, Amit From pgsql-performance-owner@postgresql.org Tue May 24 14:14:48 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8044752886 for ; Tue, 24 May 2005 14:14:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73644-08 for ; Tue, 24 May 2005 17:14:36 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 455E552888 for ; Tue, 24 May 2005 14:14:36 -0300 (ADT) Received: from [192.168.1.52] (fc1smp [66.93.38.87]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id j4OH63a3016422; Tue, 24 May 2005 10:06:04 -0700 Message-ID: <429360FB.1040106@commandprompt.com> Date: Tue, 24 May 2005 10:14:35 -0700 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Amit V Shah Cc: "'pgsql-performance@postgresql.org'" Subject: Re: Need help to decide Mysql vs Postgres References: <0C072E7CC947D511AC9600A0CC7341200256CF03@xeon400.tagaudit.com> In-Reply-To: <0C072E7CC947D511AC9600A0CC7341200256CF03@xeon400.tagaudit.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.016 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/360 X-Sequence-Number: 12524 > > I am not trying to start a mysql vs postgres war so please dont > misunderstand me .... I tried to look around for mysql vs postgres articles, > but most of them said mysql is better in speed. However those articles were > very old so I dont know about recent stage. Please comment !!! It is my experience that MySQL is faster under smaller load scenarios. Say 5 - 10 connections only doing simple SELECTS. E.g; a dymanic website. It is also my experience that PostgreSQL is faster and more stable under consistent and heavy load. I have customers you regularly are using up to 500 connections. Note that alot of this depends on how your database is designed. Foreign keys slow things down. I think it would be important for you to look at your overall goal of migration. MySQL is really not a bad product "IF" you are willing to work within its limitations. PostgreSQL is a real RDMS, it is like Oracle or DB2 and comes with a comparable feature set. Only you can decide if that is what you need. Sincerely, Joshua D. Drake Command Prompt, Inc. -- Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 PostgreSQL Replication, Consulting, Custom Programming, 24x7 support Managed Services, Shared and Dedicated Hosting Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ From pgsql-performance-owner@postgresql.org Tue May 24 14:22:20 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0767552886 for ; Tue, 24 May 2005 14:22:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78034-01 for ; Tue, 24 May 2005 17:22:17 +0000 (GMT) Received: from mail-relay1.tagaudit.com (unknown [69.64.214.4]) by svr1.postgresql.org (Postfix) with ESMTP id 49CA5528AC for ; Tue, 24 May 2005 14:22:13 -0300 (ADT) Received: from mail-hub.tagaudit.com (dns2.tagaudit.com [192.168.3.32]) by mail-relay1.tagaudit.com (Postfix) with ESMTP id 485DA200000AD for ; Tue, 24 May 2005 13:22:13 -0400 (EDT) Received: by mail-hub.tagaudit.com (Postfix, from userid 8) id 3B37C202EF; Tue, 24 May 2005 13:22:13 -0400 (EDT) Received: from xeon400.tagaudit.com (vpn.tagaudit.com [192.168.3.17]) by mail-hub.tagaudit.com (Postfix) with ESMTP id 17803202A6; Tue, 24 May 2005 13:22:13 -0400 (EDT) Received: by xeon400.tagaudit.com with Internet Mail Service (5.5.2656.59) id <2C4CQYSP>; Tue, 24 May 2005 13:22:12 -0400 Message-ID: <0C072E7CC947D511AC9600A0CC7341200256CF04@xeon400.tagaudit.com> From: Amit V Shah To: "'Joshua D. Drake'" Cc: "'pgsql-performance@postgresql.org'" Subject: Re: Need help to decide Mysql vs Postgres Date: Tue, 24 May 2005 13:22:08 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.35 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/361 X-Sequence-Number: 12525 Hi Josh, Thanks for the prompt reply !! Actually migration is inevitable. We have a totally messed up schema, not normalized and stuff like that. So the goal of the migration is to get a new and better normalized schema. That part is done already. Now the decision point is, should we go with postgres or mysql. Thanks, Amit -----Original Message----- From: Joshua D. Drake [mailto:jd@commandprompt.com] Sent: Tuesday, May 24, 2005 1:15 PM To: Amit V Shah Cc: 'pgsql-performance@postgresql.org' Subject: Re: [PERFORM] Need help to decide Mysql vs Postgres > > I am not trying to start a mysql vs postgres war so please dont > misunderstand me .... I tried to look around for mysql vs postgres articles, > but most of them said mysql is better in speed. However those articles were > very old so I dont know about recent stage. Please comment !!! It is my experience that MySQL is faster under smaller load scenarios. Say 5 - 10 connections only doing simple SELECTS. E.g; a dymanic website. It is also my experience that PostgreSQL is faster and more stable under consistent and heavy load. I have customers you regularly are using up to 500 connections. Note that alot of this depends on how your database is designed. Foreign keys slow things down. I think it would be important for you to look at your overall goal of migration. MySQL is really not a bad product "IF" you are willing to work within its limitations. PostgreSQL is a real RDMS, it is like Oracle or DB2 and comes with a comparable feature set. Only you can decide if that is what you need. Sincerely, Joshua D. Drake Command Prompt, Inc. -- Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 PostgreSQL Replication, Consulting, Custom Programming, 24x7 support Managed Services, Shared and Dedicated Hosting Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ From pgsql-performance-owner@postgresql.org Tue May 24 14:28:32 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88EF9528AD for ; Tue, 24 May 2005 14:28:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76872-09 for ; Tue, 24 May 2005 17:28:30 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id A7A6752896 for ; Tue, 24 May 2005 14:28:29 -0300 (ADT) Received: (qmail 10008 invoked by uid 500); 24 May 2005 17:27:13 -0000 Date: Tue, 24 May 2005 12:27:13 -0500 From: Bruno Wolff III To: mark durrant Cc: pgsql-performance@postgresql.org Subject: Re: Select performance vs. mssql Message-ID: <20050524172713.GC8129@wolff.to> Mail-Followup-To: Bruno Wolff III , mark durrant , pgsql-performance@postgresql.org References: <20050524153637.64525.qmail@web53101.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050524153637.64525.qmail@web53101.mail.yahoo.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/362 X-Sequence-Number: 12526 On Tue, May 24, 2005 at 08:36:36 -0700, mark durrant wrote: > > --MSSQL's ability to hit the index only and not having > to go to the table itself results in a _big_ > performance/efficiency gain. If someone who's in > development wants to pass this along, it would be a > nice addition to PostgreSQL sometime in the future. > I'd suspect that as well as making one query faster, > it would make everything else faster/more scalable as > the server load is so much less. This gets brought up a lot. The problem is that the index doesn't include information about whether the current transaction can see the referenced row. Putting this information in the index will add significant overhead to every update and the opinion of the developers is that this would be a net loss overall. From pgsql-performance-owner@postgresql.org Tue May 24 14:36:32 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DA38C52888 for ; Tue, 24 May 2005 14:36:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79798-07 for ; Tue, 24 May 2005 17:36:22 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id C5F83528B7 for ; Tue, 24 May 2005 14:36:21 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7401361; Tue, 24 May 2005 10:38:23 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Amit V Shah Subject: Re: Need help to decide Mysql vs Postgres Date: Tue, 24 May 2005 10:37:48 -0700 User-Agent: KMail/1.8 Cc: "'pgsql-performance@postgresql.org'" References: <0C072E7CC947D511AC9600A0CC7341200256CF03@xeon400.tagaudit.com> In-Reply-To: <0C072E7CC947D511AC9600A0CC7341200256CF03@xeon400.tagaudit.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505241037.49050.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/364 X-Sequence-Number: 12528 Amit, > - We have lot of foreign keys between the tables Do you need these keys to be enforced? Last I checked, MySQL was still having trouble with foriegn keys. > - Most of the DB usage is Selects. We would have some inserts but that > would be like a nightly or a monthly process So transaction integrity is not a real concern? This sounds like a data warehouse; wanna try Bizgres? (www.bizgres.org) > Our only concern with going with postgres is speed. I haven't done a speed > test yet so I can't speak. But the major concern is that the selects and > inserts are going to be much much slower on postgres than on mysql. I dont > know how true this is. I know this is a postgres forum so everyone will say > postgres is better but I am just looking for some help and advise I guess Well, the relative speed depends on what you're doing. You want slow, try a transaction rollback on a large InnoDB table ;-) PostgreSQL/Bizgres will also be implementing bitmapped indexes and table partitioning very soon, so we're liable to pull way ahead of MySQL on very large databases. > I am not trying to start a mysql vs postgres war so please dont > misunderstand me .... I tried to look around for mysql vs postgres > articles, but most of them said mysql is better in speed. Also I'll bet most of those articles were based on either website use or single-threaded simple-sql tests. Not a read data warehousing situatiion. It's been my personal experience that MySQL does not scale well beyond about 75GB without extensive support from MySQL AB. PostgreSQL more easily scales up to 200GB, and to as much as 1TB with tuning expertise. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue May 24 14:57:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 82A5F5288B for ; Tue, 24 May 2005 14:57:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83654-03 for ; Tue, 24 May 2005 17:57:03 +0000 (GMT) Received: from mail-relay1.tagaudit.com (unknown [69.64.214.4]) by svr1.postgresql.org (Postfix) with ESMTP id 8FF4B52888 for ; Tue, 24 May 2005 14:57:02 -0300 (ADT) Received: from mail-hub.tagaudit.com (dns2.tagaudit.com [192.168.3.32]) by mail-relay1.tagaudit.com (Postfix) with ESMTP id 6E650200000B0 for ; Tue, 24 May 2005 13:57:03 -0400 (EDT) Received: by mail-hub.tagaudit.com (Postfix, from userid 8) id 60AAB202A6; Tue, 24 May 2005 13:57:03 -0400 (EDT) Received: from xeon400.tagaudit.com (vpn.tagaudit.com [192.168.3.17]) by mail-hub.tagaudit.com (Postfix) with ESMTP id 36AB6202A6; Tue, 24 May 2005 13:57:03 -0400 (EDT) Received: by xeon400.tagaudit.com with Internet Mail Service (5.5.2656.59) id <2C4CQYWF>; Tue, 24 May 2005 13:57:03 -0400 Message-ID: <0C072E7CC947D511AC9600A0CC7341200256CF05@xeon400.tagaudit.com> From: Amit V Shah To: "'josh@agliodbs.com'" , Amit V Shah Cc: "'pgsql-performance@postgresql.org'" Subject: Re: Need help to decide Mysql vs Postgres Date: Tue, 24 May 2005 13:56:54 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.35 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/365 X-Sequence-Number: 12529 > - Most of the DB usage is Selects. We would have some inserts but that > would be like a nightly or a monthly process So transaction integrity is not a real concern? This sounds like a data warehouse; wanna try Bizgres? (www.bizgres.org) I took a look at this. I have a few concerns with bizgres though -- I am using jetspeed portal engine and Hibernate as my O/R Mapping layer. I know for sure that they dont support bizgres. Now the question is what difference is there between bizgres and postgres ... I guess I will try to look around the website more and find out, but if there is something you would like to comment, that would be very helpful ... Thanks, Amit From pgsql-performance-owner@postgresql.org Tue May 24 15:02:03 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87182528C9 for ; Tue, 24 May 2005 15:02:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82322-09 for ; Tue, 24 May 2005 18:01:59 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id A07C8528A7 for ; Tue, 24 May 2005 15:01:58 -0300 (ADT) Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] helo=trofast.sesse.net) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1Dadj3-0007WI-Fu for pgsql-performance@postgresql.org; Tue, 24 May 2005 20:01:58 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1Dadj3-0001U0-00 for ; Tue, 24 May 2005 20:01:57 +0200 Date: Tue, 24 May 2005 20:01:57 +0200 From: "Steinar H. Gunderson" To: "'pgsql-performance@postgresql.org'" Subject: Re: Need help to decide Mysql vs Postgres Message-ID: <20050524180157.GA5092@uio.no> Mail-Followup-To: "'pgsql-performance@postgresql.org'" References: <0C072E7CC947D511AC9600A0CC7341200256CF05@xeon400.tagaudit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <0C072E7CC947D511AC9600A0CC7341200256CF05@xeon400.tagaudit.com> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/366 X-Sequence-Number: 12530 On Tue, May 24, 2005 at 01:56:54PM -0400, Amit V Shah wrote: > I took a look at this. I have a few concerns with bizgres though -- I am > using jetspeed portal engine and Hibernate as my O/R Mapping layer. If you have problems with performance, you might want to look into using JDBC directly instead of using Hibernate. I know groups of people who are rather less-than-happy with it performance-wise :-) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Tue May 24 15:19:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 78E0852896 for ; Tue, 24 May 2005 15:16:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86616-04 for ; Tue, 24 May 2005 18:16:05 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 36FA8528AD for ; Tue, 24 May 2005 15:16:04 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7401584 for pgsql-performance@postgresql.org; Tue, 24 May 2005 11:18:06 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Need help to decide Mysql vs Postgres Date: Tue, 24 May 2005 11:17:32 -0700 User-Agent: KMail/1.8 References: <0C072E7CC947D511AC9600A0CC7341200256CF05@xeon400.tagaudit.com> In-Reply-To: <0C072E7CC947D511AC9600A0CC7341200256CF05@xeon400.tagaudit.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505241117.32171.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/367 X-Sequence-Number: 12531 Amit, > I took a look at this. I have a few concerns with bizgres though -- I am > using jetspeed portal engine and Hibernate as my O/R Mapping layer. I know > for sure that they dont support bizgres. Now the question is what > difference is there between bizgres and postgres ... I guess I will try to > look around the website more and find out, but if there is something you > would like to comment, that would be very helpful ... Bizgres is PostgreSQL. Just a different packaging of it, with some patches which are not yet in the main PostgreSQL. Also, it's currently beta. --Josh -- __Aglio Database Solutions_______________ Josh Berkus Consultant josh@agliodbs.com www.agliodbs.com Ph: 415-752-2500 Fax: 415-752-2387 2166 Hayes Suite 200 San Francisco, CA From pgsql-performance-owner@postgresql.org Tue May 24 16:15:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C6D9252809 for ; Tue, 24 May 2005 16:13:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97485-08 for ; Tue, 24 May 2005 19:13:28 +0000 (GMT) Received: from web53110.mail.yahoo.com (web53110.mail.yahoo.com [206.190.39.213]) by svr1.postgresql.org (Postfix) with SMTP id 478BA52800 for ; Tue, 24 May 2005 16:13:27 -0300 (ADT) Received: (qmail 58245 invoked by uid 60001); 24 May 2005 19:13:28 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=2xJRiLpttIWZ5+YH6ittqUvJ9N4SKiapHoi5VVqn2mxfhmA0rjeGcjFahLNaprL4KmCtGbQ53pnX5XXXO1Gga+fX2zm9HLn1yX6jC2PdR7O6BhSlBqMPOKW4mE8ebWi8/Or1piYPudEmg3OVSWSTTSoned1h72tGcPZ944Tui4E= ; Message-ID: <20050524191328.58243.qmail@web53110.mail.yahoo.com> Received: from [68.70.32.45] by web53110.mail.yahoo.com via HTTP; Tue, 24 May 2005 12:13:27 PDT Date: Tue, 24 May 2005 12:13:27 -0700 (PDT) From: mark durrant Subject: Re: Select performance vs. mssql To: Bruno Wolff III Cc: pgsql-performance@postgresql.org In-Reply-To: 6667 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.829 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FROM_ENDS_IN_NUMS X-Spam-Level: * X-Archive-Number: 200505/368 X-Sequence-Number: 12532 I'm far from an expert, so this may be off-base... but perhaps a suggestion would be to allow a hint to be sent to the optimizer if the user doesn't care that the result is "approximate" maybe then this wouldn't require adding more overhead to the indexes. MSSQL has something like this with (nolock) i.e. select count(*) from customers (nolock) where name like 'Mark%' Regardless, I'm very impressed with PostgreSQL and I think we're moving ahead with it. Mark --- Bruno Wolff III wrote: > On Tue, May 24, 2005 at 08:36:36 -0700, > mark durrant wrote: > > > > --MSSQL's ability to hit the index only and not > having > > to go to the table itself results in a _big_ > > performance/efficiency gain. If someone who's in > > development wants to pass this along, it would be > a > > nice addition to PostgreSQL sometime in the > future. > > I'd suspect that as well as making one query > faster, > > it would make everything else faster/more scalable > as > > the server load is so much less. > > This gets brought up a lot. The problem is that the > index doesn't include > information about whether the current transaction > can see the referenced > row. Putting this information in the index will add > significant overhead > to every update and the opinion of the developers is > that this would be > a net loss overall. __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new Resources site http://smallbusiness.yahoo.com/resources/ From pgsql-performance-owner@postgresql.org Tue May 24 18:18:05 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 015595283A for ; Tue, 24 May 2005 18:18:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25948-06 for ; Tue, 24 May 2005 21:17:56 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 638C652875 for ; Tue, 24 May 2005 18:17:54 -0300 (ADT) Received: (qmail 11409 invoked from network); 24 May 2005 23:18:19 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 24 May 2005 23:18:19 +0200 To: "Amit V Shah" , "'pgsql-performance@postgresql.org'" Subject: Re: Need help to decide Mysql vs Postgres References: <0C072E7CC947D511AC9600A0CC7341200256CF03@xeon400.tagaudit.com> Message-ID: Date: Tue, 24 May 2005 23:17:46 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <0C072E7CC947D511AC9600A0CC7341200256CF03@xeon400.tagaudit.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/369 X-Sequence-Number: 12533 It's common knowledge, it seems, that MySQL without transactions will be a lot faster than Postgres on Inserts. And on Updates too, that is, unless you have more than a few concurrent concurrent connections, at which point the MySQL full table lock will just kill everything. And you don't have transactions, of course, and if something goes wrong, bye bye data, or funky stuff happens, like half-commited transactions if a constraint is violated in an INSERT SELECT, or you get 0 January 0000 or 31 February, etc. I heard it said that MySQL with transactions (InnoDB) is slower than postgres. I'd believe it... and you still get 00-00-0000 as a date for free. But from your use case postgres doesn't sound like a problem, yours sounds like a few big batched COPY's which are really really fast. And about SELECTs, this is really from an experience I had a few months ago, from a e-commerce site... well, to put it nicely, MySQL's planner don't know shit when it comes to doing anything a bit complicated. I had this query to show the "also purchased" products on a page, and also a few other queries, best buys in this category, related products, etc..., nothing very complicated really, at worst they were 4-table joins... and with 50K products MySQL planned it horrendously and it took half a second ! Seq scans every times... I had to split the query in two, one to get the product id's, another one to get the products. I took the sql, put it in postgres with the usual changes (typenames, etc...) but same indexes, same data... the query took half a millisecond. Well... what can I say ? Also when you sit in front of the psql or mysql command line, it's an entirely different experience. One is a pleasure to work with... the other one is just a pain. From pgsql-performance-owner@postgresql.org Tue May 24 18:36:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A87525280A for ; Tue, 24 May 2005 18:36:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91541-05 for ; Tue, 24 May 2005 21:36:05 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 7DEFA52860 for ; Tue, 24 May 2005 18:36:05 -0300 (ADT) Received: from [192.168.1.52] (fc1smp [66.93.38.87]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id j4OLRYa3005129; Tue, 24 May 2005 14:27:34 -0700 Message-ID: <42939E47.8030201@commandprompt.com> Date: Tue, 24 May 2005 14:36:07 -0700 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Amit V Shah Cc: "'pgsql-performance@postgresql.org'" Subject: Re: Need help to decide Mysql vs Postgres References: <0C072E7CC947D511AC9600A0CC7341200256CF04@xeon400.tagaudit.com> In-Reply-To: <0C072E7CC947D511AC9600A0CC7341200256CF04@xeon400.tagaudit.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.016 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/370 X-Sequence-Number: 12534 Amit V Shah wrote: > Hi Josh, > > Thanks for the prompt reply !! Actually migration is inevitable. We have a > totally messed up schema, not normalized and stuff like that. So the goal of > the migration is to get a new and better normalized schema. That part is > done already. Now the decision point is, should we go with postgres or > mysql. O.k. then I would ask myself this: Would I trust my brand new data that I have put all this effort into, that finally looks the way that I want it to look, to a database that truncates information? PostgreSQL is truly ACID compliant. Even if it is a little slower (which under normal use I don't find to be the case) wouldn't the reliability of PostgreSQL make up for say the 10% net difference in performance? Sincerely, Joshua D. Drake > > Thanks, > Amit > > -----Original Message----- > From: Joshua D. Drake [mailto:jd@commandprompt.com] > Sent: Tuesday, May 24, 2005 1:15 PM > To: Amit V Shah > Cc: 'pgsql-performance@postgresql.org' > Subject: Re: [PERFORM] Need help to decide Mysql vs Postgres > > > >>I am not trying to start a mysql vs postgres war so please dont >>misunderstand me .... I tried to look around for mysql vs postgres > > articles, > >>but most of them said mysql is better in speed. However those articles > > were > >>very old so I dont know about recent stage. Please comment !!! > > > It is my experience that MySQL is faster under smaller load scenarios. > Say 5 - 10 connections only doing simple SELECTS. E.g; a dymanic website. > > It is also my experience that PostgreSQL is faster and more stable under > consistent and heavy load. I have customers you regularly are using up > to 500 connections. > > Note that alot of this depends on how your database is designed. Foreign > keys slow things down. > > I think it would be important for you to look at your overall goal of > migration. MySQL is really not a bad product "IF" you are willing to > work within its limitations. > > PostgreSQL is a real RDMS, it is like Oracle or DB2 and comes with a > comparable feature set. Only you can decide if that is what you need. > > Sincerely, > > Joshua D. Drake > Command Prompt, Inc. > > -- Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240 PostgreSQL Replication, Consulting, Custom Programming, 24x7 support Managed Services, Shared and Dedicated Hosting Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ From pgsql-performance-owner@postgresql.org Tue May 24 20:12:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DDA91528D6 for ; Tue, 24 May 2005 20:12:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12970-01 for ; Tue, 24 May 2005 23:12:11 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by svr1.postgresql.org (Postfix) with ESMTP id 9B26E528D1 for ; Tue, 24 May 2005 20:12:10 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so2882560wri for ; Tue, 24 May 2005 16:12:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:references; b=mrb9/0oG1NCZc2DJOCLy9AksyybPbasjMY42cD+OqZ2AswjjXEpjqQgh0YO0Cz1+2nDblEwsf2vcd2c9hqFcV6lsDZIsX4J5BFzT7p8NvFgMWNHY6k5xKYcawVDay1qdiOSOMlQ1oIkdW7wZvZURi6gIa2FvfvAW2YaKdydm7es= Received: by 10.54.33.73 with SMTP id g73mr3914320wrg; Tue, 24 May 2005 16:12:14 -0700 (PDT) Received: by 10.54.86.15 with HTTP; Tue, 24 May 2005 16:12:13 -0700 (PDT) Message-ID: <33c6269f05052416122096eb1e@mail.gmail.com> Date: Tue, 24 May 2005 19:12:14 -0400 From: Alex Turner Reply-To: Alex Turner To: Bruno Wolff III , mark durrant , pgsql-performance@postgresql.org Subject: Re: Select performance vs. mssql In-Reply-To: <20050524172713.GC8129@wolff.to> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_20880_1845234.1116976334007" References: <20050524153637.64525.qmail@web53101.mail.yahoo.com> <20050524172713.GC8129@wolff.to> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.539 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, HTML_20_30, HTML_MESSAGE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/371 X-Sequence-Number: 12535 ------=_Part_20880_1845234.1116976334007 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Until you start worrying about MVC - we have had problems with the MSSQL=20 implementation of read consistency because of this 'feature'. Alex Turner NetEconomist On 5/24/05, Bruno Wolff III wrote: >=20 > On Tue, May 24, 2005 at 08:36:36 -0700, > mark durrant wrote: > > > > --MSSQL's ability to hit the index only and not having > > to go to the table itself results in a _big_ > > performance/efficiency gain. If someone who's in > > development wants to pass this along, it would be a > > nice addition to PostgreSQL sometime in the future. > > I'd suspect that as well as making one query faster, > > it would make everything else faster/more scalable as > > the server load is so much less. >=20 > This gets brought up a lot. The problem is that the index doesn't include > information about whether the current transaction can see the referenced > row. Putting this information in the index will add significant overhead > to every update and the opinion of the developers is that this would be > a net loss overall. >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > ------=_Part_20880_1845234.1116976334007 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Until you start worrying about MVC - we have had problems with the MSSQL implementation of read consistency because of this 'feature'.

Alex Turner
NetEconomist

On 5/24/05, Bruno Wolff III <bruno@wolff.to> wrote:
On Tue, May 24, 2005 at 08:36:36 -0700,
  mark durrant <markd89@yahoo.com> wrote:
><= br>> --MSSQL's ability to hit the index only and not having
> to g= o to the table itself results in a _big_
> performance/efficiency gain. If someone who's in
> developme= nt wants to pass this along, it would be a
> nice addition to Postgre= SQL sometime in the future.
> I'd suspect that as well as making one = query faster,
> it would make everything else faster/more scalable as
> the = server load is so much less.

This gets brought up a lot. The problem= is that the index doesn't include
information about whether the current= transaction can see the referenced
row. Putting this information in the index will add significant overhea= d
to every update and the opinion of the developers is that this would b= e
a net loss overall.

---------------------------(end of broadcas= t)---------------------------
TIP 4: Don't 'kill -9' the postmaster

------=_Part_20880_1845234.1116976334007-- From pgsql-performance-owner@postgresql.org Tue May 24 20:33:57 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E42E15287E for ; Tue, 24 May 2005 20:33:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12720-09 for ; Tue, 24 May 2005 23:33:46 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id F216B5286C for ; Tue, 24 May 2005 20:33:45 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7402737; Tue, 24 May 2005 16:35:50 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: mark durrant Subject: Re: Select performance vs. mssql Date: Tue, 24 May 2005 16:35:14 -0700 User-Agent: KMail/1.8 Cc: Bruno Wolff III , pgsql-performance@postgresql.org References: <20050524191328.58243.qmail@web53110.mail.yahoo.com> In-Reply-To: <20050524191328.58243.qmail@web53110.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505241635.14558.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.046 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/372 X-Sequence-Number: 12536 Folks, > > This gets brought up a lot. The problem is that the > > index doesn't include > > information about whether the current transaction > > can see the referenced > > row. Putting this information in the index will add > > significant overhead > > to every update and the opinion of the developers is > > that this would be > > a net loss overall. Pretty much. There has been discussion about allowing index-only access to "frozen" tables, i.e. archive partitions. But it all sort of hinges on someone implementing it and testing .... -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue May 24 21:14:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B06605288A for ; Tue, 24 May 2005 21:14:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26086-02 for ; Wed, 25 May 2005 00:13:59 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 99A00528D3 for ; Tue, 24 May 2005 21:13:57 -0300 (ADT) Received: (qmail 20117 invoked from network); 25 May 2005 02:14:33 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 25 May 2005 02:14:33 +0200 To: pgsql-performance@postgresql.org Subject: Re: Select performance vs. mssql References: <20050524191328.58243.qmail@web53110.mail.yahoo.com> <200505241635.14558.josh@agliodbs.com> Message-ID: Date: Wed, 25 May 2005 02:14:01 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <200505241635.14558.josh@agliodbs.com> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/373 X-Sequence-Number: 12537 > Pretty much. There has been discussion about allowing index-only access > to > "frozen" tables, i.e. archive partitions. But it all sort of hinges on > someone implementing it and testing .... Would be interesting as a parameter to set at index creation (ie. if you know this table will have a lot of reads and few writes)... like create an index on columns X,Y keeping data on columns X,Y and Z... But in this case do you still need the table ? Or even create a table type where the table and the index are one, like an auto-clustered table... I don't know if it would be used that often, though ;) From pgsql-performance-owner@postgresql.org Tue May 24 21:20:48 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0B33652809 for ; Tue, 24 May 2005 21:20:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25272-10 for ; Wed, 25 May 2005 00:20:39 +0000 (GMT) Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) by svr1.postgresql.org (Postfix) with ESMTP id E5D3D5288A for ; Tue, 24 May 2005 21:20:37 -0300 (ADT) Received: from osgiliath.mathom.us ([70.108.87.79]) by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IH000HYJRMG6FH5@vms042.mailsrvcs.net> for pgsql-performance@postgresql.org; Tue, 24 May 2005 19:20:40 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by osgiliath.mathom.us (Postfix) with ESMTP id E053261407F for ; Tue, 24 May 2005 20:20:39 -0400 (EDT) Received: from osgiliath.mathom.us ([127.0.0.1]) by localhost (osgiliath [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 17656-03 for ; Tue, 24 May 2005 20:20:39 -0400 (EDT) Received: by osgiliath.mathom.us (Postfix, from userid 1000) id B97CD60043F; Tue, 24 May 2005 20:20:39 -0400 (EDT) Date: Tue, 24 May 2005 20:20:39 -0400 From: Michael Stone Subject: Re: Select performance vs. mssql In-reply-to: <200505241635.14558.josh@agliodbs.com> To: pgsql-performance@postgresql.org Mail-Followup-To: pgsql-performance@postgresql.org Message-id: <20050525002039.GA27519@mathom.us> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-disposition: inline X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mathom.us References: <20050524191328.58243.qmail@web53110.mail.yahoo.com> <200505241635.14558.josh@agliodbs.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/374 X-Sequence-Number: 12538 On Tue, May 24, 2005 at 04:35:14PM -0700, Josh Berkus wrote: >Pretty much. There has been discussion about allowing index-only access to >"frozen" tables, i.e. archive partitions. But it all sort of hinges on >someone implementing it and testing .... Is there any way to expose the planner estimate? For some purposes it's enough to just give a rough ballpark (e.g., a google-esque "results 1-10 of approximately 10000000") so a user knows whether its worth even starting to page through. Mike Stone From pgsql-performance-owner@postgresql.org Tue May 24 21:38:19 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D2E7B52840 for ; Tue, 24 May 2005 21:38:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26086-10 for ; Wed, 25 May 2005 00:38:09 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 73EE85283F for ; Tue, 24 May 2005 21:38:08 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4P0cAPX020880; (envelope-from ) Tue, 24 May 2005 19:38:11 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4P0c9Vw022007 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 24 May 2005 19:38:10 -0500 (CDT) Message-ID: <4293C8F0.7000909@arbash-meinel.com> Date: Tue, 24 May 2005 19:38:08 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Michael Stone Cc: pgsql-performance@postgresql.org Subject: Re: Select performance vs. mssql References: <20050524191328.58243.qmail@web53110.mail.yahoo.com> <200505241635.14558.josh@agliodbs.com> <20050525002039.GA27519@mathom.us> In-Reply-To: <20050525002039.GA27519@mathom.us> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig76FB9CDF9426CE71A3EBE91F" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/375 X-Sequence-Number: 12539 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig76FB9CDF9426CE71A3EBE91F Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Michael Stone wrote: > On Tue, May 24, 2005 at 04:35:14PM -0700, Josh Berkus wrote: > >> Pretty much. There has been discussion about allowing index-only >> access to "frozen" tables, i.e. archive partitions. But it all sort >> of hinges on someone implementing it and testing .... > > > Is there any way to expose the planner estimate? For some purposes it's > enough to just give a rough ballpark (e.g., a google-esque "results 1-10 > of approximately 10000000") so a user knows whether its worth even > starting to page through. > > Mike Stone > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster Well, you could always do: EXPLAIN SELECT ... And then parse out the rows= in the first line. John =:-> --------------enig76FB9CDF9426CE71A3EBE91F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCk8jwJdeBCYSNAAMRAt3BAKDVHzLw/aWp+X1lJ2uFo3e5qNoJFACgozLj PI6Vo9151U09gncRXoDT/Xc= =Nq48 -----END PGP SIGNATURE----- --------------enig76FB9CDF9426CE71A3EBE91F-- From pgsql-performance-owner@postgresql.org Tue May 24 22:29:20 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C0D04528AC for ; Tue, 24 May 2005 22:29:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39352-02 for ; Wed, 25 May 2005 01:29:10 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 858EA52830 for ; Tue, 24 May 2005 22:29:03 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 49C2D24FE1; Wed, 25 May 2005 09:28:55 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 2F93924FDF; Wed, 25 May 2005 09:28:55 +0800 (WST) Message-ID: <4293D500.8010908@familyhealth.com.au> Date: Wed, 25 May 2005 09:29:36 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mark durrant Cc: pgsql-performance@postgresql.org Subject: Re: Select performance vs. mssql References: <20050524153637.64525.qmail@web53101.mail.yahoo.com> In-Reply-To: <20050524153637.64525.qmail@web53101.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/376 X-Sequence-Number: 12540 > --As Chris pointed out, how real-world is this test? > His point is valid. The database we're planning will > have a lot of rows and require a lot of summarization > (hence my attempt at a "test"), but we shouldn't be > pulling a million rows at a time. If you want to do lots of aggregate analysis, I suggest you create a sepearate summary table, and create triggers on the main table to maintain your summaries in the other table... > --MSSQL's ability to hit the index only and not having > to go to the table itself results in a _big_ > performance/efficiency gain. If someone who's in > development wants to pass this along, it would be a > nice addition to PostgreSQL sometime in the future. > I'd suspect that as well as making one query faster, > it would make everything else faster/more scalable as > the server load is so much less. This is well-known and many databases do it. However, due to MVCC considerations in PostgreSQL, it's not feasible for us to implement it... Chris From pgsql-performance-owner@postgresql.org Tue May 24 23:07:36 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7FB02528B3 for ; Tue, 24 May 2005 23:07:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49631-03 for ; Wed, 25 May 2005 02:07:32 +0000 (GMT) Received: from hotmail.com (bay14-dav3.bay14.hotmail.com [64.4.48.107]) by svr1.postgresql.org (Postfix) with ESMTP id E4A6852860 for ; Tue, 24 May 2005 23:07:31 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 24 May 2005 19:07:35 -0700 Message-ID: Received: from 147.10.236.76 by BAY14-DAV3.phx.gbl with DAV; Wed, 25 May 2005 02:07:35 +0000 X-Originating-IP: [147.10.236.76] X-Originating-Email: [space_ball_one@hotmail.com] X-Sender: space_ball_one@hotmail.com From: "SpaceBallOne" To: Subject: Can anyone explain this: duplicate dbs. Date: Wed, 25 May 2005 10:07:49 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0037_01C56111.9B6C6E00" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-OriginalArrivalTime: 25 May 2005 02:07:35.0647 (UTC) FILETIME=[84BD86F0:01C560CE] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=4.874 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_MUA_OUTLOOK, HTML_40_50, HTML_MESSAGE, MSGID_FROM_MTA_HEADER X-Spam-Level: **** X-Archive-Number: 200505/377 X-Sequence-Number: 12541 This is a multi-part message in MIME format. ------=_NextPart_000_0037_01C56111.9B6C6E00 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Wondering if someone could explain a pecularity for me: We have a database which takes 1000ms to perform a certain query on. If I pg_dump that database then create a new database (e.g. "tempdb") = and upload the dump file (thus making a duplicate) then the same query = only takes 190ms !! Vacuum, vacuum analyse, and vacuum full analyse does not seem to have an = impact on these times. Can anyone explain why this may be occurring and how I might be able to = keep the original database running at the same speed as "tempdb"? Thanks in advance, Dave. ------=_NextPart_000_0037_01C56111.9B6C6E00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Wondering if someone could explain a = pecularity for=20 me:

We have a database which takes 1000ms to perform a certain = query=20 on.

If I pg_dump that database then create a new database (e.g. = "tempdb")=20 and upload the dump file (thus making a duplicate) then the same query = only=20 takes 190ms !!
Vacuum, vacuum analyse, and vacuum full = analyse=20 does not seem to have an impact on these times.

Can anyone = explain why=20 this may be occurring and how I might be able to keep the original = database=20 running at the same speed as "tempdb"?

Thanks in=20 advance,

Dave.
------=_NextPart_000_0037_01C56111.9B6C6E00-- From pgsql-performance-owner@postgresql.org Tue May 24 23:21:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EBBF2528CC for ; Tue, 24 May 2005 23:21:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49241-08 for ; Wed, 25 May 2005 02:21:06 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 3E1C8528C9 for ; Tue, 24 May 2005 23:21:02 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 785BE24FDD; Wed, 25 May 2005 10:21:03 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 5BB8A24FCE; Wed, 25 May 2005 10:21:03 +0800 (WST) Message-ID: <4293E13A.5050901@familyhealth.com.au> Date: Wed, 25 May 2005 10:21:46 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: SpaceBallOne Cc: pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/378 X-Sequence-Number: 12542 > Can anyone explain why this may be occurring and how I might be able to > keep the original database running at the same speed as "tempdb"? You're not vacuuming anywhere near often enough. Read up the database maintenance section of the manual. Then, set up contrib/pg_autovacuum to vacuum your database regularly, or make a cron job to run "vacuumdb -a -z -q" once an hour, say. You can fix for the case when you haven't been vacuuming enough by a once off VACUUM FULL ANALYZE command, but this will lock tables exclusively as it does its work. Chris From pgsql-performance-owner@postgresql.org Tue May 24 23:22:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5787152860 for ; Tue, 24 May 2005 23:22:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53266-01 for ; Wed, 25 May 2005 02:22:11 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 19D7F528DA for ; Tue, 24 May 2005 23:22:08 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id BCF9524FDD; Wed, 25 May 2005 10:22:10 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 9DED724FCE; Wed, 25 May 2005 10:22:10 +0800 (WST) Message-ID: <4293E17D.8090706@familyhealth.com.au> Date: Wed, 25 May 2005 10:22:53 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: SpaceBallOne Cc: pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/379 X-Sequence-Number: 12543 > If I pg_dump that database then create a new database (e.g. "tempdb") > and upload the dump file (thus making a duplicate) then the same query > only takes 190ms !! > Vacuum, vacuum analyse, and vacuum full analyse does not seem to have an > impact on these times. Damn, for some reason I didn't read that you had already tried vacuum full. In that case, I can't explain it except perhaps you aren't vacuuming properly, or the right thing, or it's a disk cache thing. Chris From pgsql-performance-owner@postgresql.org Tue May 24 23:39:29 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3AD76528C9 for ; Tue, 24 May 2005 23:39:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53879-08 for ; Wed, 25 May 2005 02:39:19 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id C6E48528CC for ; Tue, 24 May 2005 23:39:14 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4P2dH2D023270; (envelope-from ) Tue, 24 May 2005 21:39:17 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4P2dFhn002032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 24 May 2005 21:39:16 -0500 (CDT) Message-ID: <4293E553.6070400@arbash-meinel.com> Date: Tue, 24 May 2005 21:39:15 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: SpaceBallOne Cc: pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. References: In-Reply-To: X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigED7884077674065F15DD39B9" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/380 X-Sequence-Number: 12544 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigED7884077674065F15DD39B9 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit SpaceBallOne wrote: > Wondering if someone could explain a pecularity for me: > > We have a database which takes 1000ms to perform a certain query on. > > If I pg_dump that database then create a new database (e.g. "tempdb") > and upload the dump file (thus making a duplicate) then the same query > only takes 190ms !! > Vacuum, vacuum analyse, and vacuum full analyse does not seem to have > an impact on these times. > > Can anyone explain why this may be occurring and how I might be able > to keep the original database running at the same speed as "tempdb"? > > Thanks in advance, > > Dave. What version of postgres? There are a few possibilities. If you are having a lot of updates to the table, you can get index bloat. And vacuum doesn't fix indexes. You have to "REINDEX" to do that. Though REINDEX has the same lock that VACUUM FULL has, so you need to be a little careful with it. Probably better is to do CLUSTER, as it does a REINDEX and a sort, so your table ends up nicer when you are done. Also, older versions of postgres had a worse time with index bloat. One thing that caused a lot of problem is a table that you insert into over time, so that all the values are incrementing. If you are deleting older entries, that area won't be re-used because they fall at the back end. I believe newer versions have been fixed. By the way, I think doing: CREATE DATABASE tempdb WITH TEMPLATE = originaldb; Is a much faster way of doing dump and load. I *think* it would recreate indexes, etc. If it just does a copy it may not show the dump/restore improvement. John =:-> --------------enigED7884077674065F15DD39B9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCk+VTJdeBCYSNAAMRAiw1AKDI0lX0lcNbKRhISBsKsuX44PlMKACgw7HL GZx7dCOTb0xRh+lzhx5b0ds= =WYPz -----END PGP SIGNATURE----- --------------enigED7884077674065F15DD39B9-- From pgsql-performance-owner@postgresql.org Tue May 24 23:52:56 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B755D528AC for ; Tue, 24 May 2005 23:52:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57267-04 for ; Wed, 25 May 2005 02:52:47 +0000 (GMT) Received: from hotmail.com (bay14-dav16.bay14.hotmail.com [64.4.48.120]) by svr1.postgresql.org (Postfix) with ESMTP id C7ED652860 for ; Tue, 24 May 2005 23:52:46 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 24 May 2005 19:52:51 -0700 Message-ID: Received: from 147.10.236.76 by BAY14-DAV16.phx.gbl with DAV; Wed, 25 May 2005 02:52:50 +0000 X-Originating-IP: [147.10.236.76] X-Originating-Email: [space_ball_one@hotmail.com] X-Sender: space_ball_one@hotmail.com From: "SpaceBallOne" To: "John A Meinel" Cc: References: <4293E553.6070400@arbash-meinel.com> Subject: Re: Can anyone explain this: duplicate dbs. Date: Wed, 25 May 2005 10:53:07 +0800 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-OriginalArrivalTime: 25 May 2005 02:52:51.0090 (UTC) FILETIME=[D7453F20:01C560D4] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=4.393 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_MUA_OUTLOOK, MSGID_FROM_MTA_HEADER X-Spam-Level: **** X-Archive-Number: 200505/381 X-Sequence-Number: 12545 > What version of postgres? 8.0.2 ... but I think I've seen this before on 7.3 ... > There are a few possibilities. If you are having a lot of updates to the > table, you can get index bloat. And vacuum doesn't fix indexes. You have > to "REINDEX" to do that. Though REINDEX has the same lock that VACUUM > FULL has, so you need to be a little careful with it. > Probably better is to do CLUSTER, as it does a REINDEX and a sort, so > your table ends up nicer when you are done. Thanks, will try those next time this problem crops up (i just deleted / recreated the database to speed things for its users in the office ... probably should have held off to see if I could find a solution first!). Yes, the database / table-in-question does have a lot of updates, deletes, and new rows (relatively speaking for a small business). Would CLUSTER / REINDEX still have an effect if our queries were done via sequential scan? This is a old database (as in built by me when i was just starting to learn unix / postgres) so the database design is pretty horrible (little normalisation, no indexes). Have taken Chris's advice onboard too and setup cron to do a vacuumdb hourly instead of my weekly vacuum. Cheers, Dave. From pgsql-performance-owner@postgresql.org Wed May 25 00:00:42 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2897B528C8 for ; Wed, 25 May 2005 00:00:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60431-01 for ; Wed, 25 May 2005 03:00:39 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id C77AF528C2 for ; Wed, 25 May 2005 00:00:37 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4P30a9R023779; (envelope-from ) Tue, 24 May 2005 22:00:36 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4P30XbM003824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 24 May 2005 22:00:35 -0500 (CDT) Message-ID: <4293EA52.20005@arbash-meinel.com> Date: Tue, 24 May 2005 22:00:34 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: SpaceBallOne Cc: pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. References: <4293E553.6070400@arbash-meinel.com> In-Reply-To: X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig44F58C7791E1887BD94AC986" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/383 X-Sequence-Number: 12547 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig44F58C7791E1887BD94AC986 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit SpaceBallOne wrote: >> What version of postgres? > > > 8.0.2 ... but I think I've seen this before on 7.3 ... > >> There are a few possibilities. If you are having a lot of updates to the >> table, you can get index bloat. And vacuum doesn't fix indexes. You have >> to "REINDEX" to do that. Though REINDEX has the same lock that VACUUM >> FULL has, so you need to be a little careful with it. > > >> Probably better is to do CLUSTER, as it does a REINDEX and a sort, so >> your table ends up nicer when you are done. > > > Thanks, will try those next time this problem crops up (i just deleted > / recreated the database to speed things for its users in the office > ... probably should have held off to see if I could find a solution > first!). > > Yes, the database / table-in-question does have a lot of updates, > deletes, and new rows (relatively speaking for a small business). > > Would CLUSTER / REINDEX still have an effect if our queries were done > via sequential scan? This is a old database (as in built by me when i > was just starting to learn unix / postgres) so the database design is > pretty horrible (little normalisation, no indexes). Well, my first recommendation is to put in some indexes. :) They are relatively easy to setup and can drastically improve select performance. What version of postgres are you using? What does it say at the end of "VACUUM FULL ANALYZE VERBOSE", that should tell you how many free pages were reclaimed and how big your free space map should be. If you only did 1 VACUUM FULL, you might try another, as it sounds like your tables aren't properly filled. I'm pretty sure vacuum only removes empty pages/marks locations for the free space map so they can be re-used, while vacuum full will move entries around to create free pages. It sounds like it didn't do it properly. But even so, CLUSTER is still your friend, as it allows you to "presort" the rows in your tables. > > Have taken Chris's advice onboard too and setup cron to do a vacuumdb > hourly instead of my weekly vacuum. > > Cheers, > > Dave. > > John =:-> --------------enig44F58C7791E1887BD94AC986 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCk+pSJdeBCYSNAAMRAq1LAJ9wtuOuGBxaVGPZ47cie/X0l/N+6QCggXA9 xZ911qobTXG6JwsejW531u8= =nJGz -----END PGP SIGNATURE----- --------------enig44F58C7791E1887BD94AC986-- From pgsql-performance-owner@postgresql.org Wed May 25 00:00:25 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4A759528C2 for ; Wed, 25 May 2005 00:00:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59232-04 for ; Wed, 25 May 2005 03:00:15 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 20974528AC for ; Wed, 25 May 2005 00:00:11 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 8E05124FDD; Wed, 25 May 2005 11:00:10 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 68C9424FCE; Wed, 25 May 2005 11:00:10 +0800 (WST) Message-ID: <4293EA66.3070401@familyhealth.com.au> Date: Wed, 25 May 2005 11:00:54 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: SpaceBallOne Cc: John A Meinel , pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. References: <4293E553.6070400@arbash-meinel.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/382 X-Sequence-Number: 12546 > Would CLUSTER / REINDEX still have an effect if our queries were done > via sequential scan? SELECTS don't write to the database, so they have no effect at all on vacuuming/analyzing. You only need to worry about that with writes. > This is a old database (as in built by me when i > was just starting to learn unix / postgres) so the database design is > pretty horrible (little normalisation, no indexes). No indexes? Bloody hell :D Use EXPLAIN ANALYZE SELECT ... ; on all of your selects to see where they are slow and where you can add indexes... Chris From pgsql-performance-owner@postgresql.org Wed May 25 00:02:00 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6926C52830 for ; Wed, 25 May 2005 00:01:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58816-08 for ; Wed, 25 May 2005 03:01:47 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id ECEB4528AC for ; Wed, 25 May 2005 00:01:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4P31SNB007666; Tue, 24 May 2005 23:01:29 -0400 (EDT) To: Christopher Kings-Lynne Cc: SpaceBallOne , pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. In-reply-to: <4293E17D.8090706@familyhealth.com.au> References: <4293E17D.8090706@familyhealth.com.au> Comments: In-reply-to Christopher Kings-Lynne message dated "Wed, 25 May 2005 10:22:53 +0800" Date: Tue, 24 May 2005 23:01:28 -0400 Message-ID: <7665.1116990088@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/384 X-Sequence-Number: 12548 Christopher Kings-Lynne writes: >> If I pg_dump that database then create a new database (e.g. "tempdb") >> and upload the dump file (thus making a duplicate) then the same query >> only takes 190ms !! >> Vacuum, vacuum analyse, and vacuum full analyse does not seem to have an >> impact on these times. > Damn, for some reason I didn't read that you had already tried vacuum > full. I'm thinking index bloat, and a PG version too old for vacuum full to recover any index space. But without any information about PG version or EXPLAIN ANALYZE results, we're all just guessing. regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 25 00:04:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DFAA0528C2 for ; Wed, 25 May 2005 00:04:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60214-10 for ; Wed, 25 May 2005 03:04:00 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4E656528A9 for ; Wed, 25 May 2005 00:03:59 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4P32fK7007691; Tue, 24 May 2005 23:02:41 -0400 (EDT) To: John A Meinel Cc: SpaceBallOne , pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. In-reply-to: <4293E553.6070400@arbash-meinel.com> References: <4293E553.6070400@arbash-meinel.com> Comments: In-reply-to John A Meinel message dated "Tue, 24 May 2005 21:39:15 -0500" Date: Tue, 24 May 2005 23:02:41 -0400 Message-ID: <7690.1116990161@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/385 X-Sequence-Number: 12549 John A Meinel writes: > By the way, I think doing: > CREATE DATABASE tempdb WITH TEMPLATE = originaldb; > Is a much faster way of doing dump and load. I *think* it would recreate > indexes, etc. If it just does a copy it may not show the dump/restore > improvement. CREATE DATABASE just does a physical copy, so it won't do anything at all for bloat issues. regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 25 00:34:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8C89B5285C for ; Wed, 25 May 2005 00:34:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72566-06 for ; Wed, 25 May 2005 03:34:03 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id BF2315282B for ; Wed, 25 May 2005 00:34:02 -0300 (ADT) Received: (qmail 16889 invoked by uid 500); 25 May 2005 03:32:46 -0000 Date: Tue, 24 May 2005 22:32:46 -0500 From: Bruno Wolff III To: John A Meinel Cc: SpaceBallOne , pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. Message-ID: <20050525033246.GB15626@wolff.to> Mail-Followup-To: Bruno Wolff III , John A Meinel , SpaceBallOne , pgsql-performance@postgresql.org References: <4293E553.6070400@arbash-meinel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4293E553.6070400@arbash-meinel.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/386 X-Sequence-Number: 12550 On Tue, May 24, 2005 at 21:39:15 -0500, John A Meinel wrote: > > By the way, I think doing: > > CREATE DATABASE tempdb WITH TEMPLATE = originaldb; > > Is a much faster way of doing dump and load. I *think* it would recreate > indexes, etc. If it just does a copy it may not show the dump/restore > improvement. You need to be careful when doing this. See section 18.3 of the 8.0 docs for caveats. From pgsql-performance-owner@postgresql.org Wed May 25 12:52:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D24CA52803 for ; Wed, 25 May 2005 12:52:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28450-08 for ; Wed, 25 May 2005 15:52:31 +0000 (GMT) Received: from zhonka1.zhonka.net (zhonka1.zhonka.net [66.228.195.5]) by svr1.postgresql.org (Postfix) with ESMTP id 6980152888 for ; Wed, 25 May 2005 12:52:30 -0300 (ADT) Received: from wolf.pjkh.com ([66.228.196.74]) by zhonka1.zhonka.net (Post.Office MTA v3.5.3 release 223 ID# 0-58414U4500L450S0V35) with ESMTP id net; Wed, 25 May 2005 08:52:29 -0700 Received: from localhost (localhost [127.0.0.1]) by wolf.pjkh.com (Postfix) with ESMTP id 2665458C9; Wed, 25 May 2005 08:52:25 -0700 (PDT) Received: from wolf.pjkh.com ([127.0.0.1]) by localhost (wolf.pjkh.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 65145-08; Wed, 25 May 2005 08:52:25 -0700 (PDT) Received: by wolf.pjkh.com (Postfix, from userid 1000) id E86E958C8; Wed, 25 May 2005 08:52:24 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by wolf.pjkh.com (Postfix) with ESMTP id E2A3458C7; Wed, 25 May 2005 08:52:24 -0700 (PDT) Date: Wed, 25 May 2005 08:52:24 -0700 (PDT) From: Philip Hallstrom To: Amit V Shah Cc: "'pgsql-performance@postgresql.org'" Subject: Re: Need help to decide Mysql vs Postgres In-Reply-To: <42939E47.8030201@commandprompt.com> Message-ID: <20050525085111.G65597@wolf.pjkh.com> References: <0C072E7CC947D511AC9600A0CC7341200256CF04@xeon400.tagaudit.com> <42939E47.8030201@commandprompt.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at pjkh.com X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200505/387 X-Sequence-Number: 12551 >> Thanks for the prompt reply !! Actually migration is inevitable. We have a >> totally messed up schema, not normalized and stuff like that. So the goal >> of >> the migration is to get a new and better normalized schema. That part is >> done already. Now the decision point is, should we go with postgres or >> mysql. Coming in a little late, but you might find these links interesting... not sure how up to date and/or accurate they are, but might give you some things to look into. http://sql-info.de/mysql/gotchas.html http://sql-info.de/postgresql/postgres-gotchas.html From pgsql-performance-owner@postgresql.org Wed May 25 15:07:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9872052875 for ; Wed, 25 May 2005 15:07:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61514-10 for ; Wed, 25 May 2005 18:07:40 +0000 (GMT) Received: from imail01.arbinet.com (imail.arbinet.com [64.74.47.121]) by svr1.postgresql.org (Postfix) with ESMTP id A0EA452851 for ; Wed, 25 May 2005 15:07:40 -0300 (ADT) Received: from imail01.arbinet.com (localhost [127.0.0.1]) by imail01.arbinet.com (8.12.10/8.12.2) with ESMTP id j4PHJ6AM017016 for ; Wed, 25 May 2005 17:19:12 GMT Received: from vamail01.TheXchange.com (mailbox.arbinet.com [64.74.47.120]) by imail01.arbinet.com (8.12.2/8.12.2) with SMTP id j4PHHmvv016988; Wed, 25 May 2005 17:17:50 GMT content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C56154.6B3A0AD2" X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Subject: Re: [PORTS] Which library has these symbols? -- Eureka Date: Wed, 25 May 2005 18:06:05 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PORTS] Which library has these symbols? -- Eureka Thread-Index: AcVg1NjbV0sSWrnGTzWmEduFyG6yjAAbHJ4AAASXKTA= From: "Mohan, Ross" To: X-Spam-Details: Hits=-104.7, Required=2, Tests=BAYES_00, HTML_FONTCOLOR_BLUE, HTML_MESSAGE, USER_IN_WHITELIST X-Scanned-By: MIMEDefang 2.39 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.117 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/388 X-Sequence-Number: 12552 This is a multi-part message in MIME format. ------_=_NextPart_001_01C56154.6B3A0AD2 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 64-bit PG 8.0.2. is up and running on AIX5.3/power5 YES! ! ! The major thing: setting some quirky LDFLAGS.=20 Anyone interested in details, please ping.=20 Thanks to Nick Addington, Vincent Vanwynsberghe, my SA, Sergey,=20 and Tom Lane (for good-natured nudging) My Next Task: Finding a Stress Test Harness to Load, and Query Data.=20 Anyone have ideas?=20 I am eagerly awaiting the DESTRUCTION of Oracle around here, and "yes" I am an oracle DBA and think it's very good technology.=20 Smiling,=20 Ross Mohan -----Original Message----- From: pgsql-ports-owner@postgresql.org = [mailto:pgsql-ports-owner@postgresql.org] On Behalf Of Mohan, Ross Sent: Wednesday, May 25, 2005 1:11 PM To: pgsql-ports@postgresql.org Subject: Re: [PORTS] Which library has these symbols?=20 Tom,=20 they're all over the place, repeated in different libraries, kind of a pain. Didn't realize that. I'll just give linker a bunch of LIBPATH and LIBNAME directives and have it run around.=20 # ar -t ./postgresql-8.0.2/src/interfaces/ecpg/ecpglib/libecpg.a | egrep = 'dirmod|path|pgstr|pgsleep' =20 path.o # ar -t ./postgresql-8.0.2/src/interfaces/ecpg/pgtypeslib/libpgtypes.a | = egrep 'dirmod|path|pgstr|pgsleep' pgstrcasecmp.o # ar -t ./postgresql-8.0.2/src/interfaces/libpq/libpq.a | egrep = 'dirmod|path|pgstr|pgsleep' =20 pgstrcasecmp.o =20 # ar -t ./postgresql-8.0.2/src/port/libpgport.a | egrep = 'dirmod|path|pgstr|pgsleep' =20 dirmod.o path.o =20 pgsleep.o pgstrcasecmp.o # ar -t ./postgresql-8.0.2/src/port/libpgport_srv.a | egrep = 'dirmod|path|pgstr|pgsleep' dirmod_srv.o path.o pgsleep.o pgstrcasecmp.o I **really** want this in 64bit......funny this problem only shows up in = 64, not 32 mode. =20 Thanks for commenting --- That's ALWAYS welcome! -- Ross -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Tuesday, May 24, 2005 10:53 PM To: Mohan, Ross Cc: pgsql-ports@postgresql.org Subject: Re: [PORTS] Which library has these symbols?=20 "Mohan, Ross" writes: > So Close, Yet So Far! The specific symbols being complained of should be in libpgport_srv (see = src/port). Dunno why your platform is ignoring that library. When you = find out, let us know ;-) regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq ------_=_NextPart_001_01C56154.6B3A0AD2 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PORTS] Which library has these symbols? -- Eureka

64-bit PG 8.0.2. = is up and running on AIX5.3/power5

YES! ! = !

The major = thing:  setting some quirky LDFLAGS.

Anyone interested = in details, please ping.

Thanks to Nick = Addington, Vincent Vanwynsberghe, my SA, Sergey,
and Tom Lane = (for good-natured nudging)


My Next Task: = Finding a Stress Test Harness to Load, and Query Data.

Anyone have = ideas?

I am eagerly = awaiting the DESTRUCTION of Oracle around here, = and
"yes" = I am an oracle DBA and think it's very good = technology.

Smiling, =

Ross = Mohan

-----Original = Message-----
From: = pgsql-ports-owner@postgresql.org [mailto:pgsql-ports-owner@postgresql.org] On Behalf Of Mohan, = Ross
Sent: Wednesday, = May 25, 2005 1:11 PM
To: = pgsql-ports@postgresql.org
Subject: Re: = [PORTS] Which library has these symbols?


Tom, =

they're all over = the place, repeated in different
libraries, kind = of a pain. Didn't realize that. I'll
just give linker = a bunch of LIBPATH and LIBNAME directives
and have it run = around.


# ar -t = ./postgresql-8.0.2/src/interfaces/ecpg/ecpglib/libecpg.a | egrep = 'dirmod|path|pgstr|pgsleep'       &nbs= p;
path.o

# ar -t = ./postgresql-8.0.2/src/interfaces/ecpg/pgtypeslib/libpgtypes.a | egrep = 'dirmod|path|pgstr|pgsleep' pgstrcasecmp.o

# ar -t = ./postgresql-8.0.2/src/interfaces/libpq/libpq.a | egrep = 'dirmod|path|pgstr|pgsleep'       &nbs= p;      
pgstrcasecmp.o    

# ar -t = ./postgresql-8.0.2/src/port/libpgport.a | egrep = 'dirmod|path|pgstr|pgsleep'       &nbs= p;  
dirmod.o
path.o     
pgsleep.o
pgstrcasecmp.o

# ar -t = ./postgresql-8.0.2/src/port/libpgport_srv.a | egrep = 'dirmod|path|pgstr|pgsleep' dirmod_srv.o path.o pgsleep.o = pgstrcasecmp.o



I **really** want = this in 64bit......funny this problem only shows up in 64, not 32 mode. = <sigh>


Thanks for = commenting --- That's ALWAYS welcome!

-- = Ross

-----Original = Message-----
From: Tom Lane = [mailto:tgl@sss.pgh.pa.us]
Sent: Tuesday, = May 24, 2005 10:53 PM
To: Mohan, = Ross
Cc: = pgsql-ports@postgresql.org
Subject: Re: = [PORTS] Which library has these symbols?


"Mohan, = Ross" <RMohan@arbinet.com> writes:
> So Close, = Yet So Far!

The specific = symbols being complained of should be in libpgport_srv (see = src/port).  Dunno why your platform is ignoring that library.  = When you find out, let us know ;-)

        =         =         regards, tom lane

---------------------------(end of = broadcast)---------------------------
TIP 5: Have you = checked our extensive FAQ?

           =     http://www.postgresql.org/docs/faq

------_=_NextPart_001_01C56154.6B3A0AD2-- From pgsql-performance-owner@postgresql.org Wed May 25 17:12:04 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D823F52806 for ; Wed, 25 May 2005 17:12:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96095-02 for ; Wed, 25 May 2005 20:12:00 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.204]) by svr1.postgresql.org (Postfix) with ESMTP id EEAC152803 for ; Wed, 25 May 2005 17:11:58 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so906376wra for ; Wed, 25 May 2005 13:12:00 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=nfn/q4j/+HqWNjy03YSTG9Xnn95jmglUkVE33tS9Jf5HKdO7uKfA0q4BPQpQlD5ntX38t5vzRhPOcMgBDQXm216lYPOrIrP2Sl+jVnYY8fk9whcTo910d9qXiUzHgH++0muu7T2xd8VuRIQHVcDS8q0aAMOJJXXLwGqS7Im42f8= Received: by 10.54.83.5 with SMTP id g5mr1476148wrb; Wed, 25 May 2005 13:12:00 -0700 (PDT) Received: by 10.54.128.17 with HTTP; Wed, 25 May 2005 13:12:00 -0700 (PDT) Message-ID: <688c0b7505052513127df47894@mail.gmail.com> Date: Wed, 25 May 2005 16:12:00 -0400 From: Jocelyn Turcotte Reply-To: Jocelyn Turcotte To: pgsql-performance@postgresql.org Subject: Inner join on two OR conditions dont use index Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.398 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/389 X-Sequence-Number: 12553 Hi all i dont know if this is normal, but if yes i would like to know why and how I could do it another way other than using unions. (I tried on postgresql 7.4 and 8.0.3, made my vacuum analyse just before) Here is my simple query: select *=20 from rt_node n, rt_edge e where node_id =3D 2=20 and e.start_node_id =3D n.node_id; which give me the following query plan: Nested Loop (cost=3D0.00..79.46 rows=3D24 width=3D60) -> Index Scan using rt_node_pkey on rt_node n (cost=3D0.00..5.94 rows=3D1 width=3D36) Index Cond: (node_id =3D 2) -> Index Scan using rt_edge_start_node on rt_edge e=20 (cost=3D0.00..73.28 rows=3D24 width=3D24) Index Cond: (start_node_id =3D 2) But if I plug another condition with a OR like this: select *=20 from rt_node n, rt_edge e where node_id =3D 2=20 and (e.start_node_id =3D n.node_id or e.end_node_id =3D n.node_id); I get this plan, it stop using the index!: Nested Loop (cost=3D0.00..158.94 rows=3D4 width=3D60) Join Filter: (("inner".start_node_id =3D "outer".node_id) OR ("inner".end_node_id =3D "outer".node_id)) -> Index Scan using rt_node_pkey on rt_node n (cost=3D0.00..5.94 rows=3D1 width=3D36) Index Cond: (node_id =3D 2) -> Seq Scan on rt_edge e (cost=3D0.00..81.60 rows=3D4760 width=3D24) I tried SET enable_seqscan =3D OFF and it give me this (woah) : Nested Loop (cost=3D100000000.00..100000158.94 rows=3D4 width=3D60) Join Filter: (("inner".start_node_id =3D "outer".node_id) OR ("inner".end_node_id =3D "outer".node_id)) -> Index Scan using rt_node_pkey on rt_node n (cost=3D0.00..5.94 rows=3D1 width=3D36) Index Cond: (node_id =3D 2) -> Seq Scan on rt_edge e (cost=3D100000000.00..100000081.60 rows=3D4760 width=3D24) These are my tables definitions: CREATE TABLE rt_node ( node_id INTEGER PRIMARY KEY ); CREATE TABLE rt_edge ( edge_id INTEGER PRIMARY KEY, start_node_id INTEGER NOT NULL, end_node_id INTEGER NOT NULL, CONSTRAINT start_node_ref FOREIGN KEY (start_node_id) REFERENCES rt_node(node_id), CONSTRAINT end_node_ref FOREIGN KEY (end_node_id) REFERENCES rt_node(node_id) ); =20 CREATE INDEX rt_edge_start_node ON rt_edge(start_node_id); CREATE INDEX rt_edge_end_node ON rt_edge(end_node_id); I cant figure why it cant use my index I know I can use a UNION instead on two query like the first one only different on "start_node_id"/"end_node_id", and it works, but this is a part of a bigger query which is already ugly and I hate using 5 lines for something I could in 5 words. thank you! From pgsql-performance-owner@postgresql.org Wed May 25 17:19:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C511452806 for ; Wed, 25 May 2005 17:19:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97607-03 for ; Wed, 25 May 2005 20:18:56 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 9336152803 for ; Wed, 25 May 2005 17:18:54 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4PKIr0H024065; (envelope-from ) Wed, 25 May 2005 15:18:53 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4PKIqlJ005509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Wed, 25 May 2005 15:18:52 -0500 (CDT) Message-ID: <4294DDAC.1060908@arbash-meinel.com> Date: Wed, 25 May 2005 15:18:52 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jocelyn Turcotte Cc: pgsql-performance@postgresql.org Subject: Re: Inner join on two OR conditions dont use index References: <688c0b7505052513127df47894@mail.gmail.com> In-Reply-To: <688c0b7505052513127df47894@mail.gmail.com> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigBA2C45A3BD41EF23FF6EC9B5" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/390 X-Sequence-Number: 12554 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigBA2C45A3BD41EF23FF6EC9B5 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jocelyn Turcotte wrote: >Hi all >i dont know if this is normal, but if yes i would like to know why and >how I could do it another way other than using unions. > > The only thing that *might* work is if you used an index on both keys. So if you did: CREATE INDEX rt_edge_start_end_node ON rt_edge(start_node_id,end_node_id); The reason is that in an "OR" construct, you have to check both for being true. So in the general case where you don't know the correlation between the columns, you have to check all of the entries, because even if you know the status of one side of the OR, you don't know the other. Another possibility would be to try this index: CREATE INDEX rt_edge_stare_or_end ON rt_edge(start_node_id OR end_node_id); I'm not sure how smart the planner can be, though. John =:-> --------------enigBA2C45A3BD41EF23FF6EC9B5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFClN2sJdeBCYSNAAMRAkE2AJ98+ARuCFZwm8ndvmzXAgJcVi8SOgCfUTN+ p+XUzT34SFKm2f3JjUiyCnU= =imqt -----END PGP SIGNATURE----- --------------enigBA2C45A3BD41EF23FF6EC9B5-- From pgsql-performance-owner@postgresql.org Wed May 25 17:37:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 418A552841 for ; Wed, 25 May 2005 17:37:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96000-10 for ; Wed, 25 May 2005 20:37:52 +0000 (GMT) Received: from imail02.thexchange.com (imail.arbinet.com [64.74.47.121]) by svr1.postgresql.org (Postfix) with ESMTP id C6F515280C for ; Wed, 25 May 2005 17:37:51 -0300 (ADT) Received: from imail02.thexchange.com (localhost [127.0.0.1]) by imail02.thexchange.com (8.12.10/8.12.2) with ESMTP id j4PKsYBs008258 for ; Wed, 25 May 2005 20:54:34 GMT Received: from vamail01.TheXchange.com (mailbox.arbinet.com [64.74.47.120]) by imail02.thexchange.com (8.12.2/8.12.2) with SMTP id j4PKsXdA008255 for ; Wed, 25 May 2005 20:54:33 GMT content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Subject: test - pls delete and ignore Date: Wed, 25 May 2005 20:36:54 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: test - pls delete and ignore Thread-Index: AcVhZ1i0LMJrtzuvQNGLpaQBSz2IhQAAgpGQ From: "Mohan, Ross" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.102 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/391 X-Sequence-Number: 12555 You just couldn't help yourself, could you? :-) From pgsql-performance-owner@postgresql.org Wed May 25 18:22:20 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C7EFB52877 for ; Wed, 25 May 2005 18:22:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10742-05 for ; Wed, 25 May 2005 21:22:10 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) by svr1.postgresql.org (Postfix) with ESMTP id 4C6D152825 for ; Wed, 25 May 2005 18:22:08 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so938825wra for ; Wed, 25 May 2005 14:22:10 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=XgKTXcdeUgsk/yNSYMYWHdmF7m9UM5WIw3m1meh5oen6fxA39HVvxnUxZO75mP32nlb+tI9A6VVHo54LPFFjfrJTlqeJSeCF52n248J4banlwv2FwtNdVaBDZAJrwvws8siT6uHl4iQ5Q6bONAyj8IoR3Kl9/tXRbCHDrhhCCWM= Received: by 10.54.34.77 with SMTP id h77mr1486155wrh; Wed, 25 May 2005 14:22:10 -0700 (PDT) Received: by 10.54.128.17 with HTTP; Wed, 25 May 2005 14:22:10 -0700 (PDT) Message-ID: <688c0b7505052514227ee968ce@mail.gmail.com> Date: Wed, 25 May 2005 17:22:10 -0400 From: Jocelyn Turcotte Reply-To: Jocelyn Turcotte To: John A Meinel Subject: Re: Inner join on two OR conditions dont use index Cc: pgsql-performance@postgresql.org In-Reply-To: <4294DDAC.1060908@arbash-meinel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <688c0b7505052513127df47894@mail.gmail.com> <4294DDAC.1060908@arbash-meinel.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/392 X-Sequence-Number: 12556 Thanks John it dont seems to work, but in my context I only needed data from the rt_node table so I tried this: select * from rt_node n where node_id =3D 2 and exists (select edge_id from rt_edge where start_node_id =3D n.node_id or end_node_id =3D n.node_id) and it gave me this plan (even if I remove the stupid node_id =3D 2 conditi= on): Index Scan using rt_node_pkey on rt_node n (cost=3D0.00..6.15 rows=3D1 wi= dth=3D25) Index Cond: (node_id =3D 2) Filter: (subplan) SubPlan -> Index Scan using rt_edge_start_node, rt_edge_end_node on rt_edge (cost=3D0.00..12.56 rows=3D4 width=3D4) Index Cond: ((start_node_id =3D $0) OR (end_node_id =3D $0)) this time it use my two indexes, maybe because he know that the same value is compared in the two condition... I should ask my mother if she got an idea, mothers know a lot of stuff! On 5/25/05, John A Meinel wrote: > Jocelyn Turcotte wrote: >=20 > >Hi all > >i dont know if this is normal, but if yes i would like to know why and > >how I could do it another way other than using unions. > > > > >=20 > The only thing that *might* work is if you used an index on both keys. > So if you did: >=20 > CREATE INDEX rt_edge_start_end_node ON rt_edge(start_node_id,end_node_id)= ; >=20 > The reason is that in an "OR" construct, you have to check both for being= true. So in the general case where you don't know the correlation between = the columns, you have to check all of the entries, because even if you know= the status of one side of the OR, you don't know the other. >=20 > Another possibility would be to try this index: >=20 > CREATE INDEX rt_edge_stare_or_end ON rt_edge(start_node_id OR end_node_id= ); >=20 > I'm not sure how smart the planner can be, though. >=20 > John > =3D:-> >=20 >=20 >=20 >=20 > From pgsql-ports-owner@postgresql.org Tue May 31 14:55:37 2005 X-Original-To: pgsql-ports-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F41352860 for ; Wed, 25 May 2005 18:50:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19026-04 for ; Wed, 25 May 2005 21:50:05 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 88CF352880 for ; Wed, 25 May 2005 18:50:03 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id D7D2530952; Wed, 25 May 2005 23:47:01 +0200 (MET DST) From: Christopher Browne X-Newsgroups: pgsql.ports Subject: Re: Which library has these symbols? -- Eureka Date: Wed, 25 May 2005 17:30:41 -0400 Organization: cbbrowne Computing Inc Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:7LrfkP/eh98TVyF99+lfK5ASCHo= To: pgsql-ports@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.149 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/78 X-Sequence-Number: 2071 Oops! RMohan@arbinet.com ("Mohan, Ross") was seen spray-painting on a wall: > 64-bit PG 8.0.2. is up and running on AIX5.3/power5 > > YES! ! ! > > The major thing:� setting some quirky LDFLAGS. > > Anyone interested in details, please ping. This is definitely a matter worthy of interest. It would be well worth taking a peek at $PG_SOURCE_HOME/doc/FAQ_AIX and seeing if there are notes worth adding to it. Alternatively, bounce the details over to myself and/or Andrew Hammond, and we can see about submitting the documentation patch ;-). -- "cbbrowne","@","gmail.com" http://cbbrowne.com/info/spreadsheets.html "I visited a company that was doing programming in BASIC in Panama City and I asked them if they resented that the BASIC keywords were in English. The answer was: ``Do you resent that the keywords for control of actions in music are in Italian?''" -- Kent M Pitman From pgsql-performance-owner@postgresql.org Wed May 25 18:43:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2AEB5287C for ; Wed, 25 May 2005 18:43:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15449-10 for ; Wed, 25 May 2005 21:43:19 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1FF9C52877 for ; Wed, 25 May 2005 18:43:18 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4PLhJu0002680; Wed, 25 May 2005 17:43:19 -0400 (EDT) To: Jocelyn Turcotte Cc: pgsql-performance@postgresql.org Subject: Re: Inner join on two OR conditions dont use index In-reply-to: <688c0b7505052513127df47894@mail.gmail.com> References: <688c0b7505052513127df47894@mail.gmail.com> Comments: In-reply-to Jocelyn Turcotte message dated "Wed, 25 May 2005 16:12:00 -0400" Date: Wed, 25 May 2005 17:43:19 -0400 Message-ID: <2679.1117057399@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/393 X-Sequence-Number: 12557 Jocelyn Turcotte writes: > But if I plug another condition with a OR like this: > select * > from rt_node n, rt_edge e > where node_id = 2 > and (e.start_node_id = n.node_id or e.end_node_id = n.node_id); > I get this plan, it stop using the index!: I'm afraid you're stuck with faking it with a UNION for now; the current planner is incapable of recognizing that a join OR condition can be handled with OR indexscans. FWIW, this is fixed for 8.1 --- in CVS tip, I get this from your example: QUERY PLAN -------------------------------------------------------------------------------------------------- Nested Loop (cost=2.06..17.57 rows=2 width=16) -> Index Scan using rt_node_pkey on rt_node n (cost=0.00..4.82 rows=1 width=4) Index Cond: (node_id = 2) -> Bitmap Heap Scan on rt_edge e (cost=2.06..12.47 rows=18 width=12) Recheck Cond: ((e.start_node_id = "outer".node_id) OR (e.end_node_id = "outer".node_id)) -> BitmapOr (cost=2.06..2.06 rows=18 width=0) -> Bitmap Index Scan on rt_edge_start_node (cost=0.00..1.03 rows=9 width=0) Index Cond: (e.start_node_id = "outer".node_id) -> Bitmap Index Scan on rt_edge_end_node (cost=0.00..1.03 rows=9 width=0) Index Cond: (e.end_node_id = "outer".node_id) (10 rows) (This is with no data in the tables, so the cost estimates are small, but it does show that the planner knows how to generate this kind of query plan now.) regards, tom lane From pgsql-performance-owner@postgresql.org Wed May 25 22:39:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E4D4E52839 for ; Wed, 25 May 2005 22:39:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72152-01 for ; Thu, 26 May 2005 01:39:03 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 15A8B52819 for ; Wed, 25 May 2005 22:39:00 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id BAEA024FE1; Thu, 26 May 2005 09:38:46 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 5718524FE0; Thu, 26 May 2005 09:38:46 +0800 (WST) Message-ID: <429528F8.4070609@familyhealth.com.au> Date: Thu, 26 May 2005 09:40:08 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Mohan, Ross" Cc: pgsql-performance@postgresql.org Subject: Re: [PORTS] Which library has these symbols? -- Eureka References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/394 X-Sequence-Number: 12558 > My Next Task: Finding a Stress Test Harness to Load, and Query Data. > > Anyone have ideas? > > I am eagerly awaiting the * DESTRUCTION* ** of Oracle around here, and > "yes" I am an oracle DBA and think it's */ very /*// good technology. Have you tried the simple 'gmake test'? Other than that, try http://osdb.sourceforge.net/ perhaps... Chris From pgsql-performance-owner@postgresql.org Mon May 30 18:52:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8868952818 for ; Thu, 26 May 2005 11:57:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48794-09 for ; Thu, 26 May 2005 14:57:51 +0000 (GMT) Received: from klutz.cs.utk.edu (klutz.cs.utk.edu [160.36.56.50]) by svr1.postgresql.org (Postfix) with ESMTP id 7DC2052813 for ; Thu, 26 May 2005 11:57:50 -0300 (ADT) Received: from localhost (klutz [127.0.0.1]) by klutz.cs.utk.edu (Postfix) with ESMTP id 9747F400E3 for ; Thu, 26 May 2005 10:57:55 -0400 (EDT) Received: from klutz.cs.utk.edu ([127.0.0.1]) by localhost (klutz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12626-05 for ; Thu, 26 May 2005 10:57:54 -0400 (EDT) Received: from hydra3.cs.utk.edu (hydra3.cs.utk.edu [160.36.56.165]) by klutz.cs.utk.edu (Postfix) with ESMTP id 3A77E400B6 for ; Thu, 26 May 2005 10:57:54 -0400 (EDT) Received: by hydra3.cs.utk.edu (Postfix, from userid 2805) id A5BEE8F9E; Thu, 26 May 2005 10:57:53 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by hydra3.cs.utk.edu (Postfix) with ESMTP id 71CA68673 for ; Thu, 26 May 2005 10:57:53 -0400 (EDT) Date: Thu, 26 May 2005 10:57:53 -0400 (EDT) From: Colton A Smith X-X-Sender: smith@hydra3 To: pgsql-performance@postgresql.org Subject: poor performance involving a small table Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at cs.utk.edu by ClamAV and McAfee X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/443 X-Sequence-Number: 12607 Hi: I have a table called sensors: Table "public.sensor" Column | Type | Modifiers -----------------+--------------------------+------------------------------------------------- sensor_id | integer | not null default nextval('sensor_id_seq'::text) sensor_model_id | integer | not null serial_number | character varying(50) | not null purchase_date | timestamp with time zone | not null variable_id | integer | not null datalink_id | integer | not null commentary | text | Indexes: "sensor_pkey" PRIMARY KEY, btree (sensor_id) Foreign-key constraints: "datalink_id_exists" FOREIGN KEY (datalink_id) REFERENCES datalink(datalink_id) ON DELETE RESTRICT "sensor_model_id_exists" FOREIGN KEY (sensor_model_id) REFERENCES sensor_model(sensor_model_id) ON DELETE RESTRICT "variable_id_exists" FOREIGN KEY (variable_id) REFERENCES variable(variable_id) ON DELETE RESTRICT Currently, it has only 19 rows. But when I try to delete a row, it takes forever. I tried restarting the server. I tried a full vacuum to no avail. I tried the following: explain analyze delete from sensor where sensor_id = 12; QUERY PLAN ------------------------------------------------------------------------------------------------ Seq Scan on sensor (cost=0.00..1.25 rows=1 width=6) (actual time=0.055..0.068 rows=1 loops=1) Filter: (sensor_id = 12) Total runtime: 801641.333 ms (3 rows) Can anybody help me out? Thanks so much! From pgsql-performance-owner@postgresql.org Thu May 26 12:22:07 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 70B0C5281C for ; Thu, 26 May 2005 12:22:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54687-10 for ; Thu, 26 May 2005 15:22:05 +0000 (GMT) Received: from colo.samason.me.uk (unknown [69.55.228.22]) by svr1.postgresql.org (Postfix) with ESMTP id B428652818 for ; Thu, 26 May 2005 12:22:03 -0300 (ADT) Received: from colo.samason.me.uk (colo [69.55.228.22]) by colo.samason.me.uk (8.12.11/8.12.11) with ESMTP id j4QFM3aY002022 for ; Thu, 26 May 2005 16:22:03 +0100 (BST) (envelope-from sam@colo.samason.me.uk) Received: (from sam@localhost) by colo.samason.me.uk (8.12.11/8.12.11/Submit) id j4QFM31c002021 for pgsql-performance@postgresql.org; Thu, 26 May 2005 16:22:03 +0100 (BST) (envelope-from sam) Date: Thu, 26 May 2005 16:22:03 +0100 From: Sam Mason To: pgsql-performance@postgresql.org Subject: Optimising queries involving unions Message-ID: <20050526152203.GI15205@colo.samason.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/395 X-Sequence-Number: 12559 Hi, I've got a query that I think the query optimiser should be able to work it's magic on but it doesn't! I've had a look around and asked on the IRC channel and found that the current code doesn't attempt to optimise for what I'm asking it to do at the moment. Here's a bad example: SELECT u.txt FROM smalltable t, ( SELECT id, txt FROM largetable1 UNION ALL SELECT id, txt FROM largetable2) u WHERE t.id = u.id AND t.foo = 'bar'; I was hoping that "smalltable" would get moved up into the union, but it doesn't at the moment and the database does a LOT of extra work. In this case, I can manually do quite a couple of transforms to move things around and it does the right thing: SELECT txt FROM ( SELECT l.id as lid, r.id as rid, r.foo, l.txt FROM largetable1 l, smalltable r UNION ALL SELECT l.id as lid, r.id as rid, r.foo, l.txt FROM largetable1 l, smalltable r) WHERE foo = 'bar'; AND lid = rid The optimiser is intelligent enough to move the where clauses up into the union and end end up with a reasonably optimal query. Unfortunatly, in real life, the query is much larger and reorganising everything manually isn't really feasible! Is this a good place to ask about this or is it more in the realm of the hackers mailing list? Thanks, Sam From pgsql-performance-owner@postgresql.org Mon May 30 18:53:07 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 78D5952824 for ; Thu, 26 May 2005 14:14:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79557-10 for ; Thu, 26 May 2005 17:14:41 +0000 (GMT) Received: from hub.org (hub.org [200.46.204.220]) by svr1.postgresql.org (Postfix) with ESMTP id B1B4A52802 for ; Thu, 26 May 2005 14:14:41 -0300 (ADT) Received: from localhost (unknown [200.46.204.144]) by hub.org (Postfix) with ESMTP id AAA5E64B8C6 for ; Thu, 26 May 2005 14:14:42 -0300 (ADT) Received: from hub.org ([200.46.204.220]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82169-03 for ; Thu, 26 May 2005 17:14:32 +0000 (GMT) Received: from ganymede.hub.org (blk-224-176-51.eastlink.ca [24.224.176.51]) by hub.org (Postfix) with ESMTP id AD2D264B889 for ; Thu, 26 May 2005 14:14:32 -0300 (ADT) Received: by ganymede.hub.org (Postfix, from userid 1000) id 5955A381F5; Thu, 26 May 2005 14:14:31 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 55D1B36180 for ; Thu, 26 May 2005 14:14:31 -0300 (ADT) X-Return-Path: X-Received: from ganymede.hub.org ([unix socket]) by ganymede.hub.org (Cyrus v2.2.12) with LMTPA; Thu, 26 May 2005 12:40:23 -0300 X-Sieve: CMU Sieve 2.2 X-Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 67DBA3DFD4 for ; Thu, 26 May 2005 12:40:23 -0300 (ADT) X-Received: from mail.postgresql.org [200.46.204.71] by localhost with IMAP (fetchmail-6.2.5) for scrappy@localhost (single-drop); Thu, 26 May 2005 12:40:23 -0300 (ADT) X-Received: from svr1.postgresql.org ([unix socket]) by svr1.postgresql.org (Cyrus v2.2.12) with LMTPA; Thu, 26 May 2005 12:36:57 -0300 X-Sieve: CMU Sieve 2.2 X-Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4754352808 for ; Thu, 26 May 2005 12:36:57 -0300 (ADT) X-Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62124-01 for ; Thu, 26 May 2005 15:36:53 +0000 (GMT) X-Received: from blanco.deepfile.com (66-194-80-196.gen.twtelecom.net [66.194.80.196]) by svr1.postgresql.org (Postfix) with ESMTP id 0519F52869 for ; Thu, 26 May 2005 12:36:52 -0300 (ADT) X-Received: from dc1.storediq.com (dc1.deepfile.com [192.168.123.7]) by blanco.deepfile.com (8.12.8/8.12.8) with ESMTP id j4QFZihX032099 for ; Thu, 26 May 2005 10:35:44 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Specific query performance problem help requested - postgresql 7.4 Date: Thu, 26 May 2005 10:36:51 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Specific query performance problem help requested - postgresql 7.4 Thread-Index: AcViCMBlpvcQM8r6St6Pvd0YNVLu7g== From: "Brad Might" To: X-Virus-Scanned: by amavisd-new at hub.org ReSent-Date: Thu, 26 May 2005 14:14:27 -0300 (ADT) Resent-From: "Marc G. Fournier" Resent-To: pgsql-performance@postgresql.org ReSent-Subject: Specific query performance problem help requested - postgresql 7.4 ReSent-Message-ID: <20050526141426.H61528@ganymede.hub.org> X-Virus-Scanned: by amavisd-new at hub.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.946 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/444 X-Sequence-Number: 12608 I am seeing vastly different performance characteristics for almost the exact same query.=20 Can someone help me break this down and figure out why the one query takes so much longer than the other? Looking at the explain analyze output, I see that the loops value on the innermost index scan when bucket =3D 3 is way out of wack with the = others. Here's the query...the only thing that changes from run to run is the bucket number. For some strange reason the id and bucket types are bigint although they do not need to be.=20 Shared buffers is 48000=20 sort_mem is 32767 This is on 7.4.2 I'm seeing the same thing on 7.4.7 as well. explain analyze select=20 t0.filename, t2.filename as parentname, t0.st_atime, t0.size, t0.ownernameid, t0.filetypeid, t0.groupnameid, t0.groupnameid, t0.id, t0.filename=20 from Nodes_215335885080_1114059806 as t0 inner join=20 fileftypebkt_215335885080_1114059806 as t1 on t0.id=3Dt1.fileid inner = join dirs_215335885080_1114059806 as t2 on t0.parentnameid=3Dt2.filenameid=20 where t1.bucket=3D3 order by t0.filename asc offset 0 limit 25 Here's the bucket distribution..i have clustered the index on the bucket value. bucket | count =20 --------+--------- 9 | 13420 8 | 274053 7 | 2187261 6 | 1395 5 | 45570 4 | 2218830 3 | 16940 2 | 818405 1 | 4092 (9 rows) And the explain analyzes for bucket values of 3 7 and 8 =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ -------------------------------------------------------------------- Limit (cost=3D0.00..18730.19 rows=3D25 width=3D112) (actual time=3D89995.190..400863.350 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..48333634.41 rows=3D64513 width=3D112) (actual time=3D89995.172..400863.043 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..47944899.32 rows=3D64513 = width=3D69) (actual time=3D89971.894..400484.701 rows=3D25 loops=3D1) -> Index Scan using xnodes_215335885080_1114059806_filename on nodes_215335885080_1114059806 t0 (cost=3D0.00..19090075.03 rows=3D4790475 width=3D69) (actual time=3D0.074..319084.540 rows=3D713193 loops=3D1) -> Index Scan using xfileftypebkt_215335885080_1114059806_fileid on fileftypebkt_215335885080_1114059806 t1 (cost=3D0.00..6.01 rows=3D1 width=3D8) (actual time=3D0.101..0.101 rows=3D0 loops=3D713193) Index Cond: ("outer".id =3D t1.fileid) Filter: (bucket =3D 3) -> Index Scan using xdirs_215335885080_1114059806_filenameid on dirs_215335885080_1114059806 t2 (cost=3D0.00..6.01 rows=3D1 = width=3D59) (actual time=3D15.096..15.103 rows=3D1 loops=3D25) Index Cond: ("outer".parentnameid =3D t2.filenameid) Total runtime: 400863.747 ms (10 rows) =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ -------------------------------------------------------------- Limit (cost=3D0.00..785.15 rows=3D25 width=3D112) (actual time=3D173.935..552.075 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..59327691.44 rows=3D1889045 = width=3D112) (actual time=3D173.917..551.763 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..47944899.32 rows=3D1889045 = width=3D69) (actual time=3D151.198..303.463 rows=3D25 loops=3D1) -> Index Scan using xnodes_215335885080_1114059806_filename on nodes_215335885080_1114059806 t0 (cost=3D0.00..19090075.03 rows=3D4790475 width=3D69) (actual time=3D0.225..82.328 rows=3D6930 loops=3D1) -> Index Scan using xfileftypebkt_215335885080_1114059806_fileid on fileftypebkt_215335885080_1114059806 t1 (cost=3D0.00..6.01 rows=3D1 width=3D8) (actual time=3D0.019..0.019 rows=3D0 loops=3D6930) Index Cond: ("outer".id =3D t1.fileid) Filter: (bucket =3D 7) -> Index Scan using xdirs_215335885080_1114059806_filenameid on dirs_215335885080_1114059806 t2 (cost=3D0.00..6.01 rows=3D1 = width=3D59) (actual time=3D9.894..9.901 rows=3D1 loops=3D25) Index Cond: ("outer".parentnameid =3D t2.filenameid) Total runtime: 552.519 ms (10 rows) =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ----------------------------------------------------------- Limit (cost=3D0.00..18730.19 rows=3D25 width=3D112) (actual time=3D81.271..330.404 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..48333634.41 rows=3D64513 width=3D112) (actual time=3D81.254..330.107 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..47944899.32 rows=3D64513 = width=3D69) (actual time=3D4.863..8.164 rows=3D25 loops=3D1) -> Index Scan using xnodes_215335885080_1114059806_filename on nodes_215335885080_1114059806 t0 (cost=3D0.00..19090075.03 rows=3D4790475 width=3D69) (actual time=3D0.204..2.576 rows=3D75 loops=3D1) -> Index Scan using xfileftypebkt_215335885080_1114059806_fileid on fileftypebkt_215335885080_1114059806 t1 (cost=3D0.00..6.01 rows=3D1 width=3D8) (actual time=3D0.054..0.057 rows=3D0 loops=3D75) Index Cond: ("outer".id =3D t1.fileid) Filter: (bucket =3D 8) -> Index Scan using xdirs_215335885080_1114059806_filenameid on dirs_215335885080_1114059806 t2 (cost=3D0.00..6.01 rows=3D1 = width=3D59) (actual time=3D12.841..12.847 rows=3D1 loops=3D25) Index Cond: ("outer".parentnameid =3D t2.filenameid) Total runtime: 330.835 ms (10 rows) Thanks, brad From pgsql-performance-owner@postgresql.org Thu May 26 13:53:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3032752824 for ; Thu, 26 May 2005 13:53:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77858-04 for ; Thu, 26 May 2005 16:53:55 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 558E152802 for ; Thu, 26 May 2005 13:53:54 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4QGrsCm003340; Thu, 26 May 2005 12:53:54 -0400 (EDT) To: Sam Mason Cc: pgsql-performance@postgresql.org Subject: Re: Optimising queries involving unions In-reply-to: <20050526152203.GI15205@colo.samason.me.uk> References: <20050526152203.GI15205@colo.samason.me.uk> Comments: In-reply-to Sam Mason message dated "Thu, 26 May 2005 16:22:03 +0100" Date: Thu, 26 May 2005 12:53:54 -0400 Message-ID: <3339.1117126434@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/396 X-Sequence-Number: 12560 Sam Mason writes: > Here's a bad example: > SELECT u.txt > FROM smalltable t, ( > SELECT id, txt FROM largetable1 > UNION ALL > SELECT id, txt FROM largetable2) u > WHERE t.id = u.id > AND t.foo = 'bar'; > I was hoping that "smalltable" would get moved up into the union, > but it doesn't at the moment and the database does a LOT of extra > work. I'm afraid we're a long way away from being able to do that; the parse/plan representation of UNION wasn't chosen with an eye to being able to optimize it at all :-(. We can push restriction clauses down into a union, but we can't do much with join clauses, because they necessarily refer to tables that don't even exist within the sub-query formed by the UNION. It'd be nice to fix this someday, but don't hold your breath ... regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 26 14:42:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CE0DB52824 for ; Thu, 26 May 2005 14:42:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90386-03 for ; Thu, 26 May 2005 17:42:04 +0000 (GMT) Received: from colo.samason.me.uk (unknown [69.55.228.22]) by svr1.postgresql.org (Postfix) with ESMTP id F101F52848 for ; Thu, 26 May 2005 14:42:03 -0300 (ADT) Received: from colo.samason.me.uk (colo [69.55.228.22]) by colo.samason.me.uk (8.12.11/8.12.11) with ESMTP id j4QHg3Ud002834 for ; Thu, 26 May 2005 18:42:03 +0100 (BST) (envelope-from sam@colo.samason.me.uk) Received: (from sam@localhost) by colo.samason.me.uk (8.12.11/8.12.11/Submit) id j4QHg30R002832 for pgsql-performance@postgresql.org; Thu, 26 May 2005 18:42:03 +0100 (BST) (envelope-from sam) Date: Thu, 26 May 2005 18:42:03 +0100 From: Sam Mason To: pgsql-performance@postgresql.org Subject: Re: Optimising queries involving unions Message-ID: <20050526174203.GK15205@colo.samason.me.uk> Mail-Followup-To: Sam Mason , pgsql-performance@postgresql.org References: <20050526152203.GI15205@colo.samason.me.uk> <3339.1117126434@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3339.1117126434@sss.pgh.pa.us> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/397 X-Sequence-Number: 12561 Tom Lane wrote: >It'd be nice to fix this someday, but don't hold your breath ... Thanks for the response! Is it even worth me thinking about trying to figure out how to make the current code do this sort of thing? or is it just not going to happen with the code as it is? Sam From pgsql-performance-owner@postgresql.org Thu May 26 14:55:43 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 868F252824 for ; Thu, 26 May 2005 14:55:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94557-02 for ; Thu, 26 May 2005 17:55:33 +0000 (GMT) Received: from blanco.deepfile.com (66-194-80-196.gen.twtelecom.net [66.194.80.196]) by svr1.postgresql.org (Postfix) with ESMTP id 24F6C52802 for ; Thu, 26 May 2005 14:55:31 -0300 (ADT) Received: from dc1.storediq.com (dc1.deepfile.com [192.168.123.7]) by blanco.deepfile.com (8.12.8/8.12.8) with ESMTP id j4QHsPhX000801 for ; Thu, 26 May 2005 12:54:25 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Specific query performance problem help requested - postgresql 7.4 Date: Thu, 26 May 2005 12:55:32 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Specific query performance problem help requested - postgresql 7.4 Thread-Index: AcViCMBlpvcQM8r6St6Pvd0YNVLu7gAE0d4w From: "Brad Might" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/398 X-Sequence-Number: 12562 I am seeing vastly different performance characteristics for almost the exact same query.=20 Can someone help me break this down and figure out why the one query takes so much longer than the other? Looking at the explain analyze output, I see that the loops value on the innermost index scan when bucket =3D 3 is way out of wack with the = others. Here's the query...the only thing that changes from run to run is the bucket number. For some strange reason the id and bucket types are bigint although they do not need to be.=20 Shared buffers is 48000 sort_mem is 32767 This is on 7.4.2 I'm seeing the same thing on 7.4.7 as well. explain analyze select t0.filename, t2.filename as parentname, t0.st_atime, t0.size, t0.ownernameid, t0.filetypeid, t0.groupnameid, t0.groupnameid, t0.id, t0.filename from Nodes_215335885080_1114059806 as t0 inner join fileftypebkt_215335885080_1114059806 as t1 on t0.id=3Dt1.fileid inner = join dirs_215335885080_1114059806 as t2 on t0.parentnameid=3Dt2.filenameid where t1.bucket=3D3 order by t0.filename asc offset 0 limit 25 Here's the bucket distribution..i have clustered the index on the bucket value. bucket | count =20 --------+--------- 9 | 13420 8 | 274053 7 | 2187261 6 | 1395 5 | 45570 4 | 2218830 3 | 16940 2 | 818405 1 | 4092 (9 rows) And the explain analyzes for bucket values of 3 7 and 8 =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ -------------------------------------------------------------------- Limit (cost=3D0.00..18730.19 rows=3D25 width=3D112) (actual time=3D89995.190..400863.350 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..48333634.41 rows=3D64513 width=3D112) (actual time=3D89995.172..400863.043 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..47944899.32 rows=3D64513 = width=3D69) (actual time=3D89971.894..400484.701 rows=3D25 loops=3D1) -> Index Scan using xnodes_215335885080_1114059806_filename on nodes_215335885080_1114059806 t0 (cost=3D0.00..19090075.03 rows=3D4790475 width=3D69) (actual time=3D0.074..319084.540 rows=3D713193 loops=3D1) -> Index Scan using xfileftypebkt_215335885080_1114059806_fileid on fileftypebkt_215335885080_1114059806 t1 (cost=3D0.00..6.01 rows=3D1 width=3D8) (actual time=3D0.101..0.101 rows=3D0 loops=3D713193) Index Cond: ("outer".id =3D t1.fileid) Filter: (bucket =3D 3) -> Index Scan using xdirs_215335885080_1114059806_filenameid on dirs_215335885080_1114059806 t2 (cost=3D0.00..6.01 rows=3D1 = width=3D59) (actual time=3D15.096..15.103 rows=3D1 loops=3D25) Index Cond: ("outer".parentnameid =3D t2.filenameid) = Total runtime: 400863.747 ms (10 rows) =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ -------------------------------------------------------------- Limit (cost=3D0.00..785.15 rows=3D25 width=3D112) (actual time=3D173.935..552.075 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..59327691.44 rows=3D1889045 = width=3D112) (actual time=3D173.917..551.763 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..47944899.32 rows=3D1889045 = width=3D69) (actual time=3D151.198..303.463 rows=3D25 loops=3D1) -> Index Scan using xnodes_215335885080_1114059806_filename on nodes_215335885080_1114059806 t0 (cost=3D0.00..19090075.03 rows=3D4790475 width=3D69) (actual time=3D0.225..82.328 rows=3D6930 loops=3D1) -> Index Scan using xfileftypebkt_215335885080_1114059806_fileid on fileftypebkt_215335885080_1114059806 t1 (cost=3D0.00..6.01 rows=3D1 width=3D8) (actual time=3D0.019..0.019 rows=3D0 loops=3D6930) Index Cond: ("outer".id =3D t1.fileid) Filter: (bucket =3D 7) -> Index Scan using xdirs_215335885080_1114059806_filenameid on dirs_215335885080_1114059806 t2 (cost=3D0.00..6.01 rows=3D1 = width=3D59) (actual time=3D9.894..9.901 rows=3D1 loops=3D25) Index Cond: ("outer".parentnameid =3D t2.filenameid) = Total runtime: 552.519 ms (10 rows) =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ----------------------------------------------------------- Limit (cost=3D0.00..18730.19 rows=3D25 width=3D112) (actual time=3D81.271..330.404 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..48333634.41 rows=3D64513 width=3D112) (actual time=3D81.254..330.107 rows=3D25 loops=3D1) -> Nested Loop (cost=3D0.00..47944899.32 rows=3D64513 = width=3D69) (actual time=3D4.863..8.164 rows=3D25 loops=3D1) -> Index Scan using xnodes_215335885080_1114059806_filename on nodes_215335885080_1114059806 t0 (cost=3D0.00..19090075.03 rows=3D4790475 width=3D69) (actual time=3D0.204..2.576 rows=3D75 loops=3D1) -> Index Scan using xfileftypebkt_215335885080_1114059806_fileid on fileftypebkt_215335885080_1114059806 t1 (cost=3D0.00..6.01 rows=3D1 width=3D8) (actual time=3D0.054..0.057 rows=3D0 loops=3D75) Index Cond: ("outer".id =3D t1.fileid) Filter: (bucket =3D 8) -> Index Scan using xdirs_215335885080_1114059806_filenameid on dirs_215335885080_1114059806 t2 (cost=3D0.00..6.01 rows=3D1 = width=3D59) (actual time=3D12.841..12.847 rows=3D1 loops=3D25) Index Cond: ("outer".parentnameid =3D t2.filenameid) = Total runtime: 330.835 ms (10 rows) Thanks, brad From pgsql-performance-owner@postgresql.org Thu May 26 15:02:46 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 433DB52844 for ; Thu, 26 May 2005 15:02:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95723-03 for ; Thu, 26 May 2005 18:02:36 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CB69452824 for ; Thu, 26 May 2005 15:02:35 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4QI2aWG003884; Thu, 26 May 2005 14:02:36 -0400 (EDT) To: Sam Mason Cc: pgsql-performance@postgresql.org Subject: Re: Optimising queries involving unions In-reply-to: <20050526174203.GK15205@colo.samason.me.uk> References: <20050526152203.GI15205@colo.samason.me.uk> <3339.1117126434@sss.pgh.pa.us> <20050526174203.GK15205@colo.samason.me.uk> Comments: In-reply-to Sam Mason message dated "Thu, 26 May 2005 18:42:03 +0100" Date: Thu, 26 May 2005 14:02:36 -0400 Message-ID: <3883.1117130556@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/399 X-Sequence-Number: 12563 Sam Mason writes: > Tom Lane wrote: >> It'd be nice to fix this someday, but don't hold your breath ... > Is it even worth me thinking about trying to figure out how to make > the current code do this sort of thing? Probably not :-(. What we need is to integrate UNION (and the other set-ops) into the normal querytree structure so that the planner can consider alternative plans within its existing framework. That requires some fundamental changes in the Query structure --- in particular, we have to get rid of the current situation that there is exactly one targetlist per rangetable. Decoupling targetlists and rangetables would have some other benefits too (INSERT ... SELECT would get a lot cleaner) but it's a wide-ranging change, and I think could only usefully be tackled by someone who is already pretty familiar with the code. regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 26 15:32:00 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A69E352837 for ; Thu, 26 May 2005 15:31:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00619-08 for ; Thu, 26 May 2005 18:31:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 99C4C52824 for ; Thu, 26 May 2005 15:31:56 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4QIVvW4004063; Thu, 26 May 2005 14:31:57 -0400 (EDT) To: "Brad Might" Cc: pgsql-performance@postgresql.org Subject: Re: Specific query performance problem help requested - postgresql 7.4 In-reply-to: References: Comments: In-reply-to "Brad Might" message dated "Thu, 26 May 2005 12:55:32 -0500" Date: Thu, 26 May 2005 14:31:57 -0400 Message-ID: <4062.1117132317@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/400 X-Sequence-Number: 12564 "Brad Might" writes: > Can someone help me break this down and figure out why the one query > takes so much longer than the other? It looks to me like there's a correlation between filename and bucket, such that the indexscan in filename order takes much longer to run across the first 25 rows with bucket = 3 than it does to run across the first 25 with bucket = 7 or bucket = 8. It's not just a matter of there being fewer rows with bucket = 3 ... the cost differential is much larger than is explained by the count ratios. The bucket = 3 rows have to be lurking further to the back of the filename order than the others. > Here's the bucket distribution..i have clustered the index on the bucket > value. If you have an index on bucket, it's not doing you any good here anyway, since you wrote the constraint as a crosstype operator ("3" is int4 not int8). It might help to explicitly cast the constant to int8. regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 26 15:41:56 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0D96452837 for ; Thu, 26 May 2005 15:41:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07843-02 for ; Thu, 26 May 2005 18:41:44 +0000 (GMT) Received: from blanco.deepfile.com (66-194-80-196.gen.twtelecom.net [66.194.80.196]) by svr1.postgresql.org (Postfix) with ESMTP id 7B9985283A for ; Thu, 26 May 2005 15:41:43 -0300 (ADT) Received: from dc1.storediq.com (dc1.deepfile.com [192.168.123.7]) by blanco.deepfile.com (8.12.8/8.12.8) with ESMTP id j4QIebhX000889; Thu, 26 May 2005 13:40:37 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message Subject: Re: Specific query performance problem help requested - postgresql 7.4 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Thu, 26 May 2005 13:41:44 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Specific query performance problem help requested - postgresql 7.4 Thread-Index: AcViITSceL7atpQ9SROXk3qlChz8FwAAD1Xg From: "Brad Might" To: "Tom Lane" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/401 X-Sequence-Number: 12565 Looks like I modified that constraint since the original has '3' and explaining that shows the one I ended up running and posting has 3.=20 Whn I explain on the original version it shows filter: (bucket =3D 3::bigint) Can you elaborate on what you mean by: > The bucket =3D 3 rows have to be lurking further to the back of the filename order than the others How does this apply to the index on filename? It is possible that the data values are skewed, is there any way I can gracefully handle this condition? This query is being used to extract data for interactive display and the time for bucket 3 is so out of=20 whack with all the others (I've run this across all buckets and only bucket 3 has the horrendous excecution times) Any suggestions for working around this problem to speed up execution? Thanks for the help brad -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Thursday, May 26, 2005 1:32 PM To: Brad Might Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Specific query performance problem help requested - postgresql 7.4=20 "Brad Might" writes: > Can someone help me break this down and figure out why the one query=20 > takes so much longer than the other? It looks to me like there's a correlation between filename and bucket, such that the indexscan in filename order takes much longer to run across the first 25 rows with bucket =3D 3 than it does to run across = the first 25 with bucket =3D 7 or bucket =3D 8. It's not just a matter of = there being fewer rows with bucket =3D 3 ... the cost differential is much larger than is explained by the count ratios. The bucket =3D 3 rows = have to be lurking further to the back of the filename order than the others. > Here's the bucket distribution..i have clustered the index on the=20 > bucket value. If you have an index on bucket, it's not doing you any good here anyway, since you wrote the constraint as a crosstype operator ("3" is int4 not int8). It might help to explicitly cast the constant to int8. regards, tom lane From pgsql-performance-owner@postgresql.org Thu May 26 17:24:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9E58452837 for ; Thu, 26 May 2005 17:24:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47004-04 for ; Thu, 26 May 2005 20:24:15 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) by svr1.postgresql.org (Postfix) with ESMTP id 225EB52816 for ; Thu, 26 May 2005 17:24:14 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1471014wra for ; Thu, 26 May 2005 13:24:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=im4iP1GvYHYIrqe/Sjb9I+iaJxVIaFYMsy0QYAQ0CkHWpx5ZTGQo9Ub0YsRBSrFpc62Mn10bpO2HQNCisSMAoDMUTx72N4L+Iu14c7s6yIjZlhrlG8IAmjgLIzcEEJK0nDbhuiOSzvGrkHb67i3PgiY74m90gwMHxvDamK+A4cY= Received: by 10.54.54.56 with SMTP id c56mr2097412wra; Thu, 26 May 2005 13:24:16 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Thu, 26 May 2005 13:24:16 -0700 (PDT) Message-ID: <4a0cafe205052613242e0d4d10@mail.gmail.com> Date: Thu, 26 May 2005 15:24:16 -0500 From: Josh Close Reply-To: Josh Close To: pgsql-performance@postgresql.org Subject: slow queries, possibly disk io Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.398 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/402 X-Sequence-Number: 12566 I have some queries that have significan't slowed down in the last couple days. It's gone from 10 seconds to over 2 mins. The cpu has never gone over 35% in the servers lifetime, but the load average is over 8.0 right now. I'm assuming this is probably due to disk io. I need some help setting up postgres so that it doesn't need to go to disk. I think the shared_buffers and effective_cache_size values are the one's I need to look at. Would setting shmmax and smmall to 90% or so of available mem and putting a lot for postgres be helpful? Effective cach size says this:=20 Sets the planner's assumption about the effective size of the disk cache (that is, the portion of the kernel's disk cache that will be used for PostgreSQL data files). Does that mean the total available ram? Or what's left over from shared_buf= fers? I've tried different things and not much has been working. Is there a good way to ensure that most of the tables accessed in postgres will be cached in mem and not have to go to disk? If I'm joining a lot of tables, should the sort_mem be set high also? Do shared_buffers, effective_cache_size, and sort_mem all use different mem? Or are they seperate? I've looked for information and haven't found any useful pages about this. Any help would be greatly appreciated. Thanks. -Josh From pgsql-performance-owner@postgresql.org Mon May 30 18:53:37 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A443452837 for ; Thu, 26 May 2005 17:54:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52175-08 for ; Thu, 26 May 2005 20:54:47 +0000 (GMT) Received: from vbp2.vbp2.com (vbp2.com [66.207.137.158]) by svr1.postgresql.org (Postfix) with ESMTP id 742DC52824 for ; Thu, 26 May 2005 17:54:46 -0300 (ADT) Received: from vbp2.vbp2.com (localhost [127.0.0.1]) by vbp2.vbp2.com (8.13.1/8.13.1) with ESMTP id j4QKsjjF011643 for ; Thu, 26 May 2005 16:54:45 -0400 (EDT) (envelope-from list@vbp2.vbp2.com) Received: from localhost (list@localhost) by vbp2.vbp2.com (8.13.1/8.13.1/Submit) with ESMTP id j4QKsjEI011640 for ; Thu, 26 May 2005 16:54:45 -0400 (EDT) (envelope-from list@vbp2.vbp2.com) Date: Thu, 26 May 2005 16:54:45 -0400 (EDT) From: list To: pgsql-performance@postgresql.org Subject: tuning Message-ID: <20050526164228.S10655@vbp2.vbp2.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/445 X-Sequence-Number: 12609 hi- i would like to see if someone could recommend something to make my query run faster. System specs: PostgreSQL 7.4.2 on RedHat 9 dual AMD Athlon 2GHz processors 1 gig memory mirrored 7200 RPM IDE disks Values in postgresql.conf: shared_buffers = 1000 sort_mem is commented out effective_cache_size is commented out random_page_cost is commented out Relevant tables: product ------- id serial productlistid integer vendorid integer item varchar(32) descrip varchar(256) price double vendor ------ id serial vendorname varchar(64) A view i made in order to easily retrieve the vendor name: create view productvendorview as select p.id, p.productlistid, v.vendorname, p.item, p.descrip, p.price from product p, vendor v where p.vendorid = v.id; Here are some indices i have created: create index product_plid on product (productlistid); create index product_plidloweritem on product (productlistid, lower(item) varchar_pattern_ops); create index product_plidlowerdescrip on product (productlistid, lower(descrip) varchar_pattern_ops); Here is the query in question: select * from productvendorview where (productlistid=3 or productlistid=5 or productlistid=4) and (lower(item) like '9229%' or lower(descrip) like 'toner%') order by vendorname,item limit 100; This query scans 412,457 records. Here is the EXPLAIN ANALYZE for the query: Limit (cost=45718.83..45719.08 rows=100 width=108) (actual time=39093.636..39093.708 rows=100 loops=1) -> Sort (cost=45718.83..45727.48 rows=3458 width=108) (actual time=39093.629..39093.655 rows=100 loops=1) Sort Key: v.vendorname, p.item -> Hash Join (cost=22.50..45515.57 rows=3458 width=108) (actual time=95.490..39062.927 rows=2440 loops=1) Hash Cond: ("outer".vendorid = "inner".id) -> Seq Scan on test p (cost=0.00..45432.57 rows=3457 width=62) (actual time=89.066..39041.654 rows=2444 loops=1) Filter: (((productlistid = 3) OR (productlistid = 5) OR (productlistid = 4)) AND ((lower((item)::text) ~~ '9229%'::text) OR (lower((descrip)::text) ~~ 'toner%'::text))) -> Hash (cost=20.00..20.00 rows=1000 width=54) (actual time=6.289..6.289 rows=0 loops=1) -> Seq Scan on vendor v (cost=0.00..20.00 rows=1000 width=54) (actual time=0.060..3.653 rows=2797 loops=1) Total runtime: 39094.713 ms (10 rows) Thanks! -Clark From pgsql-performance-owner@postgresql.org Thu May 26 18:14:52 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EAE4752816 for ; Thu, 26 May 2005 18:14:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56653-07 for ; Thu, 26 May 2005 21:14:41 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 7AA7952851 for ; Thu, 26 May 2005 18:14:40 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4QLEbeZ011685; (envelope-from ) Thu, 26 May 2005 16:14:37 -0500 (CDT) Received: from [192.168.1.13] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4QLEZSJ028530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Thu, 26 May 2005 16:14:36 -0500 (CDT) Message-ID: <42963C3F.4000905@arbash-meinel.com> Date: Thu, 26 May 2005 16:14:39 -0500 From: John Arbash Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Close Cc: pgsql-performance@postgresql.org Subject: Re: slow queries, possibly disk io References: <4a0cafe205052613242e0d4d10@mail.gmail.com> In-Reply-To: <4a0cafe205052613242e0d4d10@mail.gmail.com> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig38D8EBB5F435572FB2B6B607" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/403 X-Sequence-Number: 12567 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig38D8EBB5F435572FB2B6B607 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Josh Close wrote: >I have some queries that have significan't slowed down in the last >couple days. It's gone from 10 seconds to over 2 mins. > >The cpu has never gone over 35% in the servers lifetime, but the load >average is over 8.0 right now. I'm assuming this is probably due to >disk io. > >I need some help setting up postgres so that it doesn't need to go to >disk. I think the shared_buffers and effective_cache_size values are >the one's I need to look at. > >Would setting shmmax and smmall to 90% or so of available mem and >putting a lot for postgres be helpful? > > Setting shared buffers above something like 10-30% of memory is counter productive. >Effective cach size says this: >Sets the planner's assumption about the effective size of the disk >cache (that is, the portion of the kernel's disk cache that will be >used for PostgreSQL data files). > >Does that mean the total available ram? Or what's left over from shared_buffers? > >I've tried different things and not much has been working. Is there a >good way to ensure that most of the tables accessed in postgres will >be cached in mem and not have to go to disk? > >If I'm joining a lot of tables, should the sort_mem be set high also? >Do shared_buffers, effective_cache_size, and sort_mem all use >different mem? Or are they seperate? > > > Increasing sort_mem can help with various activities, but increasing it too much can cause you to swap, which kills performance. The caution is that you will likely use at least 1 sort_mem per connection, and can likely use more than one if the query is complicated. effective_cache_size changes how Postgres plans queries, but given the same query plan, it doesn't change performance at all. >I've looked for information and haven't found any useful pages about this. > >Any help would be greatly appreciated. > >Thanks. > >-Josh > > John =:-> --------------enig38D8EBB5F435572FB2B6B607 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCljw/JdeBCYSNAAMRAsdIAJ455/psugrOOp5AduN8YTvCuxmBawCgrXv5 YLtuRwtiRKGt+rSJkM4T3/c= =pyku -----END PGP SIGNATURE----- --------------enig38D8EBB5F435572FB2B6B607-- From pgsql-performance-owner@postgresql.org Thu May 26 18:23:24 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EF2B552838 for ; Thu, 26 May 2005 18:23:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56959-07 for ; Thu, 26 May 2005 21:23:14 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.196]) by svr1.postgresql.org (Postfix) with ESMTP id CE0F352851 for ; Thu, 26 May 2005 18:23:13 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id 12so81374nzp for ; Thu, 26 May 2005 14:23:15 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TFucyox5OfhRleb/G16U2oPWBVD0ooLC71E9xIQ4TLQbR/+CX4xqR19V+vYASD8L7b8UqL1pzr4/OaennEYUQV+qf/phlgQtwT2aGfQUZHX6MfhVaB5tBhj5FcJVR4mn9D1hc9GLYyPI88sKkFXx13ighrUSQeC1gUQZ32fGXfA= Received: by 10.36.68.2 with SMTP id q2mr844397nza; Thu, 26 May 2005 14:23:15 -0700 (PDT) Received: by 10.36.22.20 with HTTP; Thu, 26 May 2005 14:23:15 -0700 (PDT) Message-ID: <758d5e7f05052614232f6c9164@mail.gmail.com> Date: Thu, 26 May 2005 23:23:15 +0200 From: Dawid Kuroczko Reply-To: Dawid Kuroczko To: Josh Close Subject: Re: slow queries, possibly disk io Cc: pgsql-performance@postgresql.org In-Reply-To: <4a0cafe205052613242e0d4d10@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe205052613242e0d4d10@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.823 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FROM_ENDS_IN_NUMS, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/404 X-Sequence-Number: 12568 On 5/26/05, Josh Close wrote: > I have some queries that have significan't slowed down in the last > couple days. It's gone from 10 seconds to over 2 mins. >=20 > The cpu has never gone over 35% in the servers lifetime, but the load > average is over 8.0 right now. I'm assuming this is probably due to > disk io. >=20 > I need some help setting up postgres so that it doesn't need to go to > disk. I think the shared_buffers and effective_cache_size values are > the one's I need to look at. Few "mandatory" questions: 1. Do you vacuum your db on regular basis? :) 2. Perhaps statistics for tables in question are out of date, did you try alter table set statistics? 3. explain analyze of the slow query? 4. if you for some reason cannot give explain analyze, please try to describe the type of query (what kind of join(s)) and amount of data found in the tables. 2 minutes from 10 seconds is a huge leap, and it may mean that PostgreSQL for some reason is not planning as well as it could. Throwing more RAM at the problem can help, but it would be better to hint the planner to do the right thing. It may be a good time to play with planner variables. :) Regards, Dawid From pgsql-performance-owner@postgresql.org Thu May 26 22:28:10 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 59DF152848 for ; Thu, 26 May 2005 22:28:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64042-02 for ; Fri, 27 May 2005 01:28:00 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id A3FB452851 for ; Thu, 26 May 2005 22:27:52 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id D542D24FDD; Fri, 27 May 2005 09:27:50 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id B91A024FCE; Fri, 27 May 2005 09:27:50 +0800 (WST) Message-ID: <42967810.8040700@familyhealth.com.au> Date: Fri, 27 May 2005 09:29:52 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Close Cc: pgsql-performance@postgresql.org Subject: Re: slow queries, possibly disk io References: <4a0cafe205052613242e0d4d10@mail.gmail.com> In-Reply-To: <4a0cafe205052613242e0d4d10@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/405 X-Sequence-Number: 12569 > I have some queries that have significan't slowed down in the last > couple days. It's gone from 10 seconds to over 2 mins. > > The cpu has never gone over 35% in the servers lifetime, but the load > average is over 8.0 right now. I'm assuming this is probably due to > disk io. You sure it's not a severe lack of vacuuming that's the problem? Chris From pgsql-performance-owner@postgresql.org Fri May 27 04:40:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA4CA52800 for ; Fri, 27 May 2005 04:40:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82129-02 for ; Fri, 27 May 2005 07:40:33 +0000 (GMT) Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 8C64C52859 for ; Fri, 27 May 2005 04:40:31 -0300 (ADT) Received: (qmail 9903 invoked by uid 0); 27 May 2005 07:40:31 -0000 Received: from 217.17.202.254 by www51.gmx.net with HTTP; Fri, 27 May 2005 09:40:31 +0200 (MEST) Date: Fri, 27 May 2005 09:40:31 +0200 (MEST) From: "Marc Mamin" To: Sam Mason Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 References: <20050526152203.GI15205@colo.samason.me.uk> Subject: Re: Optimising queries involving unions X-Priority: 3 (Normal) X-Authenticated: #3793498 Message-ID: <22933.1117179631@www51.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/406 X-Sequence-Number: 12570 Hi, I'm using a workaround for this kind of issues: consider: select A from (select B from T1 where C union select B from T2 where C union select B from T3 where C ) foo where D in your case: SELECT u.txt FROM ( SELECT id, txt FROM largetable1,smalltable t WHERE t.id = u.id AND t.foo = 'bar' UNION ALL SELECT id, txt FROM largetable2,smalltable t WHERE t.id = u.id AND t.foo = 'bar' ) u and select A from foo where C and D (A, B, C, D being everything you want, C and D may also include "GROUP BY,ORDER...) The first version will be handled correctly by the optimiser, whereas in the second version, Postgres will first build the UNION and then run the query on it. I'm having large tables with identical structure, one per day. Instead of defining a view on all tables, I' using functions that "distribute" my query on all tables. The only issue if that I need to define a type that match the result structure and each return type needs its own function. Example: (The first parameter is a schema name, the four next corresponds to A, B, C, D --------------------- create type T_i2_vc1 as (int_1 int,int_2 int,vc_1 varchar); CREATE OR REPLACE FUNCTION vq_T_i2_vc1(varchar,varchar,varchar,varchar,varchar) RETURNS setof T_i2_vc1 AS $$ DECLARE result T_i2_vc1%rowtype; mviews RECORD; sql varchar; counter int; BEGIN select into counter 1; -- loop on all daily tables FOR mviews IN SELECT distinct this_day FROM daylist order by plainday desc LOOP IF counter =1 THEN select INTO sql 'SELECT '||mviews.this_day||' AS plainday, '||$2||' FROM '||$3||'_'||mviews.plainday||' WHERE '||$4; ELSE select INTO sql sql||' UNION ALL SELECT '||mviews.this_day||' AS plainday, '||$2||' FROM '||$3||'_'||mviews.plainday||' WHERE '||$4; END IF; select into counter counter+1; END LOOP; select INTO sql 'SELECT '||$1||' FROM ('||sql||')foo '||$5; for result in EXECUTE (sql) LOOP return NEXT result; end loop; return ; END; $$ LANGUAGE plpgsql; Note: in your case the function shoud have a further parameter to join largetable(n) to smalltable in the "sub queries" HTH, Marc > I've got a query that I think the query optimiser should be able > to work it's magic on but it doesn't! I've had a look around and > asked on the IRC channel and found that the current code doesn't > attempt to optimise for what I'm asking it to do at the moment. > Here's a bad example: > > SELECT u.txt > FROM smalltable t, ( > SELECT id, txt FROM largetable1 > UNION ALL > SELECT id, txt FROM largetable2) u > WHERE t.id = u.id > AND t.foo = 'bar'; > > I was hoping that "smalltable" would get moved up into the union, > but it doesn't at the moment and the database does a LOT of extra > work. In this case, I can manually do quite a couple of transforms > to move things around and it does the right thing: > > SELECT txt > FROM ( > SELECT l.id as lid, r.id as rid, r.foo, l.txt > FROM largetable1 l, smalltable r > UNION ALL > SELECT l.id as lid, r.id as rid, r.foo, l.txt > FROM largetable1 l, smalltable r) > WHERE foo = 'bar'; > AND lid = rid > > The optimiser is intelligent enough to move the where clauses up > into the union and end end up with a reasonably optimal query. > Unfortunatly, in real life, the query is much larger and reorganising > everything manually isn't really feasible! -- Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie! Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl From pgsql-performance-owner@postgresql.org Fri May 27 09:52:24 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 03A5F52809 for ; Fri, 27 May 2005 09:52:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50238-05 for ; Fri, 27 May 2005 12:52:15 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) by svr1.postgresql.org (Postfix) with ESMTP id 80C4C5280B for ; Fri, 27 May 2005 09:52:14 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1775441wra for ; Fri, 27 May 2005 05:52:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=h/UUua+5+mvEX0S5ooLaELEGf0U51mGrMqe+X407+6X/sfQbLj2/DV1KnkKhq3ImSeij/P/0FW7+SWokIYmldsDvkNO9rL4LVdCuFTzs5Jg8B7zKxN6xK4Ivfnaq+wsohqXJ1U9HDqgNmV3XpdUHMP7sKdNODlF3tIGsmwHrG8A= Received: by 10.54.47.1 with SMTP id u1mr2516521wru; Fri, 27 May 2005 05:52:16 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Fri, 27 May 2005 05:52:16 -0700 (PDT) Message-ID: <4a0cafe205052705526fccfe75@mail.gmail.com> Date: Fri, 27 May 2005 07:52:16 -0500 From: Josh Close Reply-To: Josh Close To: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-Reply-To: <42963C3F.4000905@arbash-meinel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <42963C3F.4000905@arbash-meinel.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/407 X-Sequence-Number: 12571 > Setting shared buffers above something like 10-30% of memory is counter > productive. What is the reason behind it being counter productive? If shared buffers are at 30%, should effective cache size be at 70%? How do those two relate? >=20 > Increasing sort_mem can help with various activities, but increasing it > too much can cause you to swap, which kills performance. The caution is > that you will likely use at least 1 sort_mem per connection, and can > likely use more than one if the query is complicated. I have a max of 100 connections and 2 gigs of mem. Right now the sort mem is a 4 megs. How much higher could I put that? -Josh From pgsql-performance-owner@postgresql.org Fri May 27 10:04:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A09A052806 for ; Fri, 27 May 2005 10:04:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52685-08 for ; Fri, 27 May 2005 13:04:36 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) by svr1.postgresql.org (Postfix) with ESMTP id 1DB7F52834 for ; Fri, 27 May 2005 10:04:35 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1780170wra for ; Fri, 27 May 2005 06:04:40 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=eUnCzTilxCM5xdQoMS+4eP7CVq0AwuZzTvuhJy5oAfKIkLQAn87h5t5CHBFMSP9gBGatGjEPPL/ZEKdXCTIN7+xNXUsE3YNflpO80HIee6x6YRbXWUPHFnKt1S/MFaxOiMrlvUWVQbmUJxJu90sJoVgZqIDuoONn4CApA1wCizU= Received: by 10.54.139.7 with SMTP id m7mr2546800wrd; Fri, 27 May 2005 06:04:39 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Fri, 27 May 2005 06:04:39 -0700 (PDT) Message-ID: <4a0cafe205052706042d4e60e5@mail.gmail.com> Date: Fri, 27 May 2005 08:04:39 -0500 From: Josh Close Reply-To: Josh Close To: POSTGRES-PERFORMANCE Subject: slow queries, possibly disk io In-Reply-To: <4a0cafe205052706043ef8f53f@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <758d5e7f05052614232f6c9164@mail.gmail.com> <4a0cafe205052706043ef8f53f@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/408 X-Sequence-Number: 12572 > Few "mandatory" questions: > > 1. Do you vacuum your db on regular basis? :) It's vacuumed once every hour. The table sizes and data are constantly chan= ging. > > 2. Perhaps statistics for tables in question are out of date, did you > try alter table set statistics? No I haven't. What would that do for me? > > 3. explain analyze of the slow query? Here is the function that is ran: CREATE OR REPLACE FUNCTION adaption.funmsgspermin() RETURNS int4 AS ' DECLARE this_rServerIds RECORD; this_sQuery TEXT; this_iMsgsPerMin INT; this_rNumSent RECORD; BEGIN this_iMsgsPerMin :=3D 0; FOR this_rServerIds IN SELECT iId FROM adaption.tblServers LOOP this_sQuery :=3D \' SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent FROM adaption.tblBatchHistory_\' || this_rServerIds.iId || \' WHERE tStamp > now() - interval \'\'5 mins\'\'; \'; FOR this_rNumSent IN EXECUTE this_sQuery LOOP this_iMsgsPerMin :=3D this_iMsgsPerMin + this_rNumSent.iNumSent= ; END LOOP; END LOOP; this_iMsgsPerMin :=3D this_iMsgsPerMin / 5; RETURN this_iMsgsPerMin; END; ' LANGUAGE 'plpgsql' VOLATILE; Here is the explain analyze of one loops of the sum: Aggregate (cost=3D31038.04..31038.04 rows=3D1 width=3D4) (actual time=3D14649.602..14649.604 rows=3D1 loops=3D1) -> Seq Scan on tblbatchhistory_1 (cost=3D0.00..30907.03 rows=3D52401 width=3D4) (actual time=3D6339.223..14648.433 rows=3D919 loops=3D1) Filter: (tstamp > (now() - '00:05:00'::interval)) Total runtime: 14649.709 ms > > 4. if you for some reason cannot give explain analyze, please try to > describe the type of query (what kind of join(s)) and amount of data > found in the tables. > > 2 minutes from 10 seconds is a huge leap, and it may mean that > PostgreSQL for some reason is not planning as well as it could. > Throwing more RAM at the problem can help, but it would be better > to hint the planner to do the right thing. It may be a good time to > play with planner variables. :) Is there any documentation on planner vars? And how would I throw more ram at it? It has 2 gigs right now. How do I know if postgres is using that? -Josh From pgsql-performance-owner@postgresql.org Fri May 27 10:05:52 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC73252860 for ; Fri, 27 May 2005 10:05:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58446-02 for ; Fri, 27 May 2005 13:05:45 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) by svr1.postgresql.org (Postfix) with ESMTP id 770A352834 for ; Fri, 27 May 2005 10:05:44 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 69so1577302wri for ; Fri, 27 May 2005 06:05:47 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FK5ticXGm0sTnWbRSo+PGvLV+dqUBxKez3yxIzHjMndvfliHBTSf75eFTwQWiQl3FGs3+dwD1qMoqd5lndxgd03oklcx81U4eSgPk+BAXemYCEHHxGUUYN5eA3Grq5gGlzLwP7go8OMtXnnSAAI3yfM/BodNtRrn6FUyi5L86Uw= Received: by 10.54.8.8 with SMTP id 8mr2537109wrh; Fri, 27 May 2005 06:05:47 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Fri, 27 May 2005 06:05:47 -0700 (PDT) Message-ID: <4a0cafe2050527060533d3c4e9@mail.gmail.com> Date: Fri, 27 May 2005 08:05:47 -0500 From: Josh Close Reply-To: Josh Close To: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-Reply-To: <42967810.8040700@familyhealth.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <42967810.8040700@familyhealth.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.323 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/409 X-Sequence-Number: 12573 On 5/26/05, Christopher Kings-Lynne wrote: > > I have some queries that have significan't slowed down in the last > > couple days. It's gone from 10 seconds to over 2 mins. > > > > The cpu has never gone over 35% in the servers lifetime, but the load > > average is over 8.0 right now. I'm assuming this is probably due to > > disk io. >=20 > You sure it's not a severe lack of vacuuming that's the problem? >=20 It's vacuumed hourly. If it needs to be more than that I could do it I guess. But from everything I've been told, hourly should be enough. -Josh From pgsql-performance-owner@postgresql.org Fri May 27 10:43:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 16CE652809 for ; Fri, 27 May 2005 10:43:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64873-06 for ; Fri, 27 May 2005 13:43:19 +0000 (GMT) Received: from titan.ecommit.de (titan.ecommit.de [195.145.58.245]) by svr1.postgresql.org (Postfix) with ESMTP id A8BD25285F for ; Fri, 27 May 2005 10:43:15 -0300 (ADT) Received: from titan.ecommit.de (localhost [127.0.0.1]) by titan.ecommit.de (8.12.6/8.12.6/SuSE Linux 0.6) with ESMTP id j4RDhI0A004976 for ; Fri, 27 May 2005 15:43:18 +0200 Received: from titan.ecommit.de (root@localhost) by titan.ecommit.de (8.12.6/8.12.6/Submit) with ESMTP id j4RDhImQ004975 for ; Fri, 27 May 2005 15:43:18 +0200 Received: from fandelm.ecommit.de (fandelm.tc.de 192.168.252.51) by titan.ecommit.de (Scalix SMTP Relay 9.0.0.26) via ESMTP; Fri, 27 May 2005 15:43:16 +0200 (CEST) Date: Fri, 27 May 2005 15:41:52 +0200 From: "Martin Fandel" To: pgsql-performance@postgresql.org Message-ID: <1117201312.7060.6.camel@fandelm.ecommit.de> Subject: postgresql-8.0.1 performance tuning x-scalix-Hops: 1 X-Mailer: Evolution 2.0.1 Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-+JiXHr8v6YjeDVhOEhoF" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.028 tagged_above=0 required=5 tests=HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/410 X-Sequence-Number: 12574 --=-+JiXHr8v6YjeDVhOEhoF Content-Type: text/plain Content-Disposition: inline Hi @ all, i'm trying to tune my postgresql-db but i don't know if the values are right set. I use the following environment for the postgres-db: ######### Hardware ############ cpu: 2x P4 3Ghz ram: 1024MB DDR 266Mhz partitions: /dev/sda3 23G 9,6G 13G 44% / /dev/sda1 11G 156M 9,9G 2% /var /dev/sdb1 69G 13G 57G 19% /var/lib/pgsql /dev/sda is in raid 1 (2x 35GB / 10000upm / sca) /dev/sdb is in raid 10 (4x 35GB / 10000upm / sca) ######### /Hardware ############ ######### Config ############ /etc/sysctl.conf: kernel.shmall = 786432000 kernel.shmmax = 786432000 /etc/fstab: /dev/sdb1 /var/lib/pgsql reiserfs acl,user_xattr,noatime,data=writeback 1 2 /var/lib/pgsql/data/postgresql.conf superuser_reserved_connections = 2 shared_buffers = 3000 work_mem = 131072 maintenance_work_mem = 131072 max_stack_depth = 2048 max_fsm_pages = 20000 max_fsm_relations = 1000 max_files_per_process = 1000 vacuum_cost_delay = 10 vacuum_cost_page_hit = 1 vacuum_cost_page_miss = 10 vacuum_cost_page_dirty = 20 vacuum_cost_limit = 200 bgwriter_delay = 200 bgwriter_percent = 1 bgwriter_maxpages = 100 fsync = true wal_sync_method = fsync wal_buffers = 64 commit_delay = 0 commit_siblings = 5 checkpoint_segments = 256 checkpoint_timeout = 900 checkpoint_warning = 30 effective_cache_size = 10000 random_page_cost = 4 cpu_tuple_cost = 0.01 cpu_index_tuple_cost = 0.001 cpu_operator_cost = 0.0025 geqo = true geqo_threshold = 12 geqo_effort = 5 geqo_pool_size = 0 geqo_generations = 0 geqo_selection_bias = 2.0 deadlock_timeout = 1000 max_locks_per_transaction = 64 ######### /Config ############ ######### Transactions ############ we have about 115-300 transactions/min in about 65 tables. ######### /Transactions ############ I'm really new at using postgres. So i need some experience to set this parameters in the postgresql- and the system-config. I can't find standard calculations for this. :/ The postgresql-documentation doesn't help me to set the best values for this. The database must be high-availble. I configured rsync to sync the complete /var/lib/pgsql-directory to my hot-standby. On the hotstandby i will make the dumps of the database to improve the performance of the master-db. In my tests the synchronization works fine. I synchronised the hole directory and restarted the database of the hotstandby. While restarting, postgresql turned back the old (not archived) wals and the database of my hotstandby was consistent. Is this solution recommended? Or must i use archived wal's with real system-snapshots? best regards, Martin Fandel --=-+JiXHr8v6YjeDVhOEhoF Content-Type: text/html; charset="utf-8" Content-Disposition: inline Hi @ all,

i'm trying to tune my postgresql-db but i don't know if the values are right
set.

I use the following environment for the postgres-db:

######### Hardware ############
cpu: 2x P4 3Ghz
ram: 1024MB DDR 266Mhz

partitions:
/dev/sda3              23G  9,6G   13G  44% /
/dev/sda1              11G  156M  9,9G   2% /var
/dev/sdb1              69G   13G   57G  19% /var/lib/pgsql

/dev/sda is in raid 1  (2x 35GB / 10000upm / sca)
/dev/sdb is in raid 10 (4x 35GB / 10000upm / sca)
######### /Hardware ############

######### Config ############
/etc/sysctl.conf:
kernel.shmall = 786432000
kernel.shmmax = 786432000

/etc/fstab:
/dev/sdb1 /var/lib/pgsql reiserfs acl,user_xattr,noatime,data=writeback 1 2

/var/lib/pgsql/data/postgresql.conf
superuser_reserved_connections  = 2
shared_buffers                  = 3000
work_mem                        = 131072
maintenance_work_mem            = 131072
max_stack_depth                 = 2048
max_fsm_pages                   = 20000
max_fsm_relations               = 1000
max_files_per_process           = 1000
vacuum_cost_delay               = 10
vacuum_cost_page_hit            = 1
vacuum_cost_page_miss           = 10
vacuum_cost_page_dirty          = 20
vacuum_cost_limit               = 200
bgwriter_delay                  = 200
bgwriter_percent                = 1
bgwriter_maxpages               = 100
fsync                           = true
wal_sync_method                 = fsync
wal_buffers                     = 64
commit_delay                    = 0
commit_siblings                 = 5
checkpoint_segments             = 256
checkpoint_timeout              = 900
checkpoint_warning              = 30
effective_cache_size            = 10000
random_page_cost                = 4
cpu_tuple_cost                  = 0.01
cpu_index_tuple_cost            = 0.001
cpu_operator_cost               = 0.0025
geqo                            = true
geqo_threshold                  = 12
geqo_effort                     = 5
geqo_pool_size                  = 0
geqo_generations                = 0
geqo_selection_bias             = 2.0
deadlock_timeout                = 1000
max_locks_per_transaction       = 64
######### /Config ############

######### Transactions ############
we have about 115-300 transactions/min in about 65 tables.
######### /Transactions ############

I'm really new at using postgres. So i need some experience to set this
parameters in the postgresql- and the system-config. I can't find standard
calculations for this. :/ The postgresql-documentation doesn't help me to
set the best values for this.

The database must be high-availble. I configured rsync to sync the complete
/var/lib/pgsql-directory to my hot-standby. On the hotstandby i will make the
dumps of the database to improve the performance of the master-db.

In my tests the synchronization works fine. I synchronised the hole directory
and restarted the database of the hotstandby. While restarting, postgresql turned
back the old (not archived) wals and the database of my hotstandby was
consistent. Is this solution recommended? Or must i use archived wal's with
real system-snapshots?

best regards,

Martin Fandel --=-+JiXHr8v6YjeDVhOEhoF-- From pgsql-performance-owner@postgresql.org Fri May 27 11:29:23 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C1B325285F for ; Fri, 27 May 2005 11:29:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73106-07 for ; Fri, 27 May 2005 14:29:17 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id ACDE85281C for ; Fri, 27 May 2005 11:29:16 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4RETImU014585; Fri, 27 May 2005 10:29:18 -0400 (EDT) To: Josh Close Cc: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-reply-to: <4a0cafe205052706042d4e60e5@mail.gmail.com> References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <758d5e7f05052614232f6c9164@mail.gmail.com> <4a0cafe205052706043ef8f53f@mail.gmail.com> <4a0cafe205052706042d4e60e5@mail.gmail.com> Comments: In-reply-to Josh Close message dated "Fri, 27 May 2005 08:04:39 -0500" Date: Fri, 27 May 2005 10:29:18 -0400 Message-ID: <14584.1117204158@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/411 X-Sequence-Number: 12575 Josh Close writes: > this_sQuery := \' > SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent > FROM adaption.tblBatchHistory_\' || this_rServerIds.iId || \' > WHERE tStamp > now() - interval \'\'5 mins\'\'; > \'; > Here is the explain analyze of one loops of the sum: > Aggregate (cost=31038.04..31038.04 rows=1 width=4) (actual > time=14649.602..14649.604 rows=1 loops=1) > -> Seq Scan on tblbatchhistory_1 (cost=0.00..30907.03 rows=52401 > width=4) (actual time=6339.223..14648.433 rows=919 loops=1) > Filter: (tstamp > (now() - '00:05:00'::interval)) > Total runtime: 14649.709 ms I think you really want that seqscan to be an indexscan, instead. I'm betting this is PG 7.4.something? If so, probably the only way to make it happen is to simplify the now() expression to a constant: SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent FROM adaption.tblBatchHistory_\' || this_rServerIds.iId || \' WHERE tStamp > \\\'' || (now() - interval \'5 mins\')::text || \'\\\'\'; because pre-8.0 the planner won't realize that the inequality is selective enough to favor an indexscan, unless it's comparing to a simple constant. (BTW, 8.0's dollar quoting makes this sort of thing a lot less painful) regards, tom lane From pgsql-performance-owner@postgresql.org Fri May 27 11:54:55 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 25C5E5281C for ; Fri, 27 May 2005 11:54:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83574-01 for ; Fri, 27 May 2005 14:54:48 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.206]) by svr1.postgresql.org (Postfix) with ESMTP id 5EAE552866 for ; Fri, 27 May 2005 11:54:47 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1831503wra for ; Fri, 27 May 2005 07:54:52 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YBmy3eVF7PbZWoCOCjUO3w2telGakS3mpmF/4NPLG7D5ujZQwUHCEoeXXvQwv4PxL5BLA1pyVLE+BrIEjwwvKHdsUiyVt5pppuyDCZa2tnRh8XQColP1DIaRLZwx1PrnO53NaeAACEOyDwKbbR/XsgFoychIL3OMKghAdmT+q8s= Received: by 10.54.8.41 with SMTP id 41mr2575876wrh; Fri, 27 May 2005 07:54:52 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Fri, 27 May 2005 07:54:52 -0700 (PDT) Message-ID: <4a0cafe205052707541373ab8a@mail.gmail.com> Date: Fri, 27 May 2005 09:54:52 -0500 From: Josh Close Reply-To: Josh Close To: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-Reply-To: <14584.1117204158@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <758d5e7f05052614232f6c9164@mail.gmail.com> <4a0cafe205052706043ef8f53f@mail.gmail.com> <4a0cafe205052706042d4e60e5@mail.gmail.com> <14584.1117204158@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/412 X-Sequence-Number: 12576 > I think you really want that seqscan to be an indexscan, instead. > I'm betting this is PG 7.4.something? If so, probably the only > way to make it happen is to simplify the now() expression to a constant: >=20 > SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent > FROM adaption.tblBatchHistory_\' || this_rServerIds.iId || \' > WHERE tStamp > \\\'' || (now() - interval \'5 mins\')::text |= | > \'\\\'\'; The dollar sign thing would be a lot easier. I can't get this to work. I'm using a db manager where I can just use ' instead of \'. How would it look for that? In other words, it doesn't have the "create or replace function as ' --stuff ' language 'plpgsql'" it just has the actual function. Makes things a little easier. I'm getting an error at or near "5". >=20 > because pre-8.0 the planner won't realize that the inequality is > selective enough to favor an indexscan, unless it's comparing to > a simple constant. >=20 > (BTW, 8.0's dollar quoting makes this sort of thing a lot less painful) >=20 > regards, tom lane >=20 --=20 -Josh From pgsql-performance-owner@postgresql.org Fri May 27 12:00:31 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CBF5252809 for ; Fri, 27 May 2005 12:00:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79633-09 for ; Fri, 27 May 2005 15:00:25 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) by svr1.postgresql.org (Postfix) with ESMTP id 135B65280B for ; Fri, 27 May 2005 12:00:24 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1833983wra for ; Fri, 27 May 2005 08:00:24 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Q5OBq0r02Z/XewwfBUVefHmIx/fzQ0KsRL4oqu4LXrCAM96SDoQf4VsZFh9gR0yRZK5xv3RIQdfSDDVdl9ooi1K1/rb05JxYFvx4bknmDAnAYwJZms5x8MJrhk4cQb8rZSlR9V9d+LpA80BZDhs9c4J+Lmlao1Y1DM3MMwg1V3c= Received: by 10.54.34.62 with SMTP id h62mr241123wrh; Fri, 27 May 2005 08:00:23 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Fri, 27 May 2005 08:00:23 -0700 (PDT) Message-ID: <4a0cafe2050527080038616a2f@mail.gmail.com> Date: Fri, 27 May 2005 10:00:23 -0500 From: Josh Close Reply-To: Josh Close To: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-Reply-To: <14584.1117204158@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <758d5e7f05052614232f6c9164@mail.gmail.com> <4a0cafe205052706043ef8f53f@mail.gmail.com> <4a0cafe205052706042d4e60e5@mail.gmail.com> <14584.1117204158@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/413 X-Sequence-Number: 12577 Doing the query explain SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent FROM adaption.tblBatchHistory_1 WHERE tStamp > ( now() - interval '5 mins' )::text gives me this: Aggregate (cost=3D32138.33..32138.33 rows=3D1 width=3D4) -> Seq Scan on tblbatchhistory_1 (cost=3D0.00..31996.10 rows=3D56891 widt= h=3D4) Filter: ((tstamp)::text > ((now() - '00:05:00'::interval))::text) Still not an index scan. On 5/27/05, Tom Lane wrote: > Josh Close writes: > > this_sQuery :=3D \' > > SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent > > FROM adaption.tblBatchHistory_\' || this_rServerIds.iId || = \' > > WHERE tStamp > now() - interval \'\'5 mins\'\'; > > \'; >=20 > > Here is the explain analyze of one loops of the sum: >=20 > > Aggregate (cost=3D31038.04..31038.04 rows=3D1 width=3D4) (actual > > time=3D14649.602..14649.604 rows=3D1 loops=3D1) > > -> Seq Scan on tblbatchhistory_1 (cost=3D0.00..30907.03 rows=3D5240= 1 > > width=3D4) (actual time=3D6339.223..14648.433 rows=3D919 loops=3D1) > > Filter: (tstamp > (now() - '00:05:00'::interval)) > > Total runtime: 14649.709 ms >=20 > I think you really want that seqscan to be an indexscan, instead. > I'm betting this is PG 7.4.something? If so, probably the only > way to make it happen is to simplify the now() expression to a constant: >=20 > SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent > FROM adaption.tblBatchHistory_\' || this_rServerIds.iId || \' > WHERE tStamp > \\\'' || (now() - interval \'5 mins\')::text |= | > \'\\\'\'; >=20 > because pre-8.0 the planner won't realize that the inequality is > selective enough to favor an indexscan, unless it's comparing to > a simple constant. >=20 > (BTW, 8.0's dollar quoting makes this sort of thing a lot less painful) >=20 > regards, tom lane >=20 --=20 -Josh From pgsql-performance-owner@postgresql.org Fri May 27 14:06:02 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E7E7F52806 for ; Fri, 27 May 2005 14:06:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62902-05 for ; Fri, 27 May 2005 17:05:59 +0000 (GMT) Received: from asmail001.abovesecurity.com (asmail001.abovesecurity.com [206.162.148.235]) by svr1.postgresql.org (Postfix) with ESMTP id 877CE52820 for ; Fri, 27 May 2005 14:05:57 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: OID vs overall system performances on high load databases. Date: Fri, 27 May 2005 13:05:57 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: OID vs overall system performances on high load databases. Thread-Index: AcVi3l8WZrLGWc8fR5CjJ4NMwTPaEA== From: "Eric Lauzon" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/414 X-Sequence-Number: 12578 What are the effect of having a table with arround 500 = insert/update/delete on two to eight table in a time frame of 2 minutes = 24/24h, when you have oid enabled versus the same setup when you dont = have oid? That deployment is done on a postgres with 8 to 9 databases, each having = those 2 to 8 high load tables with oid enabled. Would the oid colum slow down table scan when you have over 20 millions = row? Would the cost of maintaining the oid column inside thoses high load = tables when there is no oid reference used for data seeking costy for = postgres ressources!? Eric Lauzon [Recherche & D=E9veloppement] Above S=E9curit=E9 / Above Security T=E9l : (450) 430-8166 Fax : (450) 430-1858=20 From pgsql-performance-owner@postgresql.org Fri May 27 18:28:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 831CB528A7 for ; Fri, 27 May 2005 18:28:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18940-10 for ; Fri, 27 May 2005 21:27:58 +0000 (GMT) Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by svr1.postgresql.org (Postfix) with ESMTP id 30F96528A5 for ; Fri, 27 May 2005 18:27:57 -0300 (ADT) Received: from [192.168.1.52] (c-24-60-119-214.hsd1.ma.comcast.net[24.60.119.214]) by comcast.net (sccrmhc11) with ESMTP id <2005052721275801100mk0ome>; Fri, 27 May 2005 21:27:58 +0000 Message-ID: <429790E1.5040308@comcast.net> Date: Fri, 27 May 2005 17:28:01 -0400 From: Jeffrey Tenny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Redundant indexes? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.274 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST X-Spam-Level: * X-Archive-Number: 200505/415 X-Sequence-Number: 12579 Would I be correct in assuming that the following two indexes are completely redundant except for the fact that one complains about uniqueness constraint violations and the other does not? Or is there are legitimate use for having BOTH indexes? I'm trying to figure out if it's okay to delete the non-unique index. (I have a bunch of tables suffering this malady from some problematic application code). Table "public.erf" Column | Type | Modifiers --------+---------+----------- rid | integer | not null cid | integer | not null Indexes: erf_rid_key unique btree (rid), erf_rid_idx btree (rid) Index "public.erf_rid_idx" Column | Type --------+--------- rid | integer btree, for table "public.erf" Index "public.erf_rid_key" Column | Type --------+--------- rid | integer unique, btree, for table "public.erf" From pgsql-general-owner@postgresql.org Fri May 27 19:07:49 2005 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 49EC15283A for ; Fri, 27 May 2005 19:07:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31288-07 for ; Fri, 27 May 2005 22:07:37 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id 17E3152800 for ; Fri, 27 May 2005 19:07:36 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j4RM7cP26096; Fri, 27 May 2005 18:07:38 -0400 (EDT) From: Bruce Momjian Message-Id: <200505272207.j4RM7cP26096@candle.pha.pa.us> Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-Reply-To: <42816A7E.3080508@samurai.com> To: Neil Conway Date: Fri, 27 May 2005 18:07:38 -0400 (EDT) Cc: Mischa Sandberg , pgsql-general@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/1262 X-Sequence-Number: 78610 Added to TODO: * Consider sorting hash buckets so entries can be found using a binary search, rather than a linear scan * In hash indexes, consider storing the hash value with or instead of the key itself --------------------------------------------------------------------------- Neil Conway wrote: > Bruce Momjian wrote: > > Is there a TODO anywhere in this discussion? If so, please let me know. > > There are a couple: > > - consider changing hash indexes to keep the entries in a hash bucket > sorted, to allow a binary search rather than a linear scan > > - consider changing hash indexes to store each key's hash value in > addition to or instead of the key value. > > You should probably include a pointer to this discussion as well. > > (I'd like to take a look at implementing these if I get a chance.) > > -Neil > -- 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 May 27 21:09:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E207F5283B for ; Fri, 27 May 2005 21:09:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59011-03 for ; Sat, 28 May 2005 00:09:41 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 321435288C for ; Fri, 27 May 2005 21:09:41 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4S09iSa001738; Fri, 27 May 2005 20:09:44 -0400 (EDT) To: Jeffrey Tenny Cc: pgsql-performance@postgresql.org Subject: Re: Redundant indexes? In-reply-to: <429790E1.5040308@comcast.net> References: <429790E1.5040308@comcast.net> Comments: In-reply-to Jeffrey Tenny message dated "Fri, 27 May 2005 17:28:01 -0400" Date: Fri, 27 May 2005 20:09:44 -0400 Message-ID: <1737.1117238984@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/416 X-Sequence-Number: 12580 Jeffrey Tenny writes: > Would I be correct in assuming that the following two indexes are > completely redundant except for the fact that one complains about > uniqueness constraint violations and the other does not? Yup ... regards, tom lane From pgsql-performance-owner@postgresql.org Sat May 28 02:08:54 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3E80F52836 for ; Sat, 28 May 2005 02:08:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27512-04 for ; Sat, 28 May 2005 05:08:44 +0000 (GMT) Received: from mail1.catalyst.net.nz (godel.catalyst.net.nz [202.49.159.12]) by svr1.postgresql.org (Postfix) with ESMTP id AFFB252831 for ; Sat, 28 May 2005 02:08:43 -0300 (ADT) Received: from 222-152-143-241.jetstream.xtra.co.nz ([222.152.143.241] helo=lamb.mcmillan.net.nz) by mail1.catalyst.net.nz with asmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DbtYw-0000RR-6F; Sat, 28 May 2005 17:08:42 +1200 Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) by lamb.mcmillan.net.nz (Postfix) with ESMTP id 4BC8FAD98581; Sat, 28 May 2005 17:08:11 +1200 (NZST) Subject: Re: OID vs overall system performances on high load From: Andrew McMillan To: Eric Lauzon Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-0dAiZ1Xl+RlUXZ6eSYU+" Date: Sat, 28 May 2005 17:08:10 +1200 Message-Id: <1117256890.30150.179.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/417 X-Sequence-Number: 12581 --=-0dAiZ1Xl+RlUXZ6eSYU+ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2005-05-27 at 13:05 -0400, Eric Lauzon wrote: > What are the effect of having a table with arround 500 > insert/update/delete on two to eight table in a time frame of 2 > minutes 24/24h, when you have oid enabled versus the same setup when > you dont have oid? >=20 > That deployment is done on a postgres with 8 to 9 databases, each > having those 2 to 8 high load tables with oid enabled. >=20 > Would the oid colum slow down table scan when you have over 20 > millions row? >=20 > Would the cost of maintaining the oid column inside thoses high load > tables when there is no oid reference used for data seeking costy for > postgres ressources!? The OID column is an extra few bytes on each row. If you don't have any use for it (and let's face it: most of us don't), then create your tables "without OID". The amount of impact that it makes will depend on what the general row size is. If they are rows with a couple of integers then the size of an OID column will be a significant portion of the size of each row, and removing it will make the physical on-disk data size significantly smaller. If the size of the average row is (e.g.) 2k then the OID will only be a very small fraction of the data, and removing it will only make a small difference. Regards, Andrew McMillan. ------------------------------------------------------------------------- Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 ... I want a COLOR T.V. and a VIBRATING BED!!! ------------------------------------------------------------------------- --=-0dAiZ1Xl+RlUXZ6eSYU+ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBCl/y6jJA0f48GgBIRApOMAJ4h+RGChXRuqxEcgCEnz8QhikY+VgCfU67Q fephNiHFDOQ9vD4PITC5Xz0= =iHof -----END PGP SIGNATURE----- --=-0dAiZ1Xl+RlUXZ6eSYU+-- From pgsql-performance-owner@postgresql.org Sat May 28 14:47:30 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B748E52945 for ; Sat, 28 May 2005 14:42:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95852-02 for ; Sat, 28 May 2005 17:42:19 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 58DD85292F for ; Sat, 28 May 2005 14:36:49 -0300 (ADT) Received: (qmail 10889 invoked from network); 28 May 2005 19:37:19 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 28 May 2005 19:37:19 +0200 To: "Andrew McMillan" , "Eric Lauzon" Cc: pgsql-performance@postgresql.org Subject: Re: OID vs overall system performances on high load References: <1117256890.30150.179.camel@lamb.mcmillan.net.nz> Message-ID: Date: Sat, 28 May 2005 19:36:42 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <1117256890.30150.179.camel@lamb.mcmillan.net.nz> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/418 X-Sequence-Number: 12582 > The OID column is an extra few bytes on each row. If you don't have any > use for it (and let's face it: most of us don't), then create your > tables "without OID". Also there are some useful hacks using the oid which don't work if it wraps around, thus preventing it from wrapping around by not using on every table could be useful in some cases... From pgsql-performance-owner@postgresql.org Mon May 30 18:54:13 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1317652820 for ; Sun, 29 May 2005 01:30:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62366-07 for ; Sun, 29 May 2005 04:30:10 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id A420B5281C for ; Sun, 29 May 2005 01:30:09 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id BE7A330952; Sun, 29 May 2005 06:26:54 +0200 (MET DST) From: ellis@no.spam () X-Newsgroups: pgsql.performance Subject: Re: Need help to decide Mysql vs Postgres Date: Sun, 29 May 2005 04:28:25 -0000 Organization: S.P.C.A.A. Message-ID: <1117340905.839566@localhost.localdomain> References: <0C072E7CC947D511AC9600A0CC7341200256CF03@xeon400.tagaudit.com> <200505241037.49050.josh@agliodbs.com> X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Originator: ellis@no.spam () Cache-Post-Path: localhost.localdomain!unknown@localhost.localdomain X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) X-Complaints-To: abuse@supernews.com Lines: 11 To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/446 X-Sequence-Number: 12610 In article <200505241037.49050.josh@agliodbs.com>, Josh Berkus wrote: >So transaction integrity is not a real concern? I know of all too many people that consider that to be true. They simply don't understand the problem. -- http://www.spinics.net/linux/ From pgsql-performance-owner@postgresql.org Sun May 29 10:27:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 271BB5284B for ; Sun, 29 May 2005 10:27:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57337-07 for ; Sun, 29 May 2005 13:27:19 +0000 (GMT) Received: from smtp835.mail.sc5.yahoo.com (smtp835.mail.sc5.yahoo.com [66.163.171.22]) by svr1.postgresql.org (Postfix) with SMTP id 4645552809 for ; Sun, 29 May 2005 10:27:18 -0300 (ADT) Received: from unknown (HELO ?10.0.1.2?) (mengelhart@sbcglobal.net@68.90.147.67 with plain) by smtp835.mail.sc5.yahoo.com with SMTP; 29 May 2005 13:27:22 -0000 Mime-Version: 1.0 (Apple Message framework v730) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: pgsql-performance@postgresql.org From: Michael Engelhart Subject: sequential scan performance Date: Sun, 29 May 2005 08:27:26 -0500 X-Mailer: Apple Mail (2.730) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/419 X-Sequence-Number: 12583 Hi - I have a table of about 3 million rows of city "aliases" that I need to query using LIKE - for example: select * from city_alias where city_name like '%FRANCISCO' When I do an EXPLAIN ANALYZE on the above query, the result is: Seq Scan on city_alias (cost=0.00..59282.31 rows=2 width=42) (actual time=73.369..3330.281 rows=407 loops=1) Filter: ((name)::text ~~ '%FRANCISCO'::text) Total runtime: 3330.524 ms (3 rows) this is a query that our system needs to do a LOT. Is there any way to improve the performance on this either with changes to our query or by configuring the database deployment? We have an index on city_name but when using the % operator on the front of the query string postgresql can't use the index . Thanks for any help. Mike From pgsql-performance-owner@postgresql.org Sun May 29 10:47:18 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2C3AA5284F for ; Sun, 29 May 2005 10:47:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66221-04 for ; Sun, 29 May 2005 13:47:13 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id 7B59F5284B for ; Sun, 29 May 2005 10:47:12 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DcO8H-0000mq-W3 for pgsql-performance@postgresql.org; Sun, 29 May 2005 15:47:15 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1DcO8H-0000rB-00 for ; Sun, 29 May 2005 15:47:13 +0200 Date: Sun, 29 May 2005 15:47:13 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: sequential scan performance Message-ID: <20050529134712.GA2987@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/420 X-Sequence-Number: 12584 On Sun, May 29, 2005 at 08:27:26AM -0500, Michael Engelhart wrote: > this is a query that our system needs to do a LOT. Is there any way > to improve the performance on this either with changes to our query > or by configuring the database deployment? We have an index on > city_name but when using the % operator on the front of the query > string postgresql can't use the index . Try tsearch2 from contrib, it might help you. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Sun May 29 11:43:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 382D65284F for ; Sun, 29 May 2005 11:43:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74300-04 for ; Sun, 29 May 2005 14:43:11 +0000 (GMT) Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) by svr1.postgresql.org (Postfix) with ESMTP id B81C85284D for ; Sun, 29 May 2005 11:43:07 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with ESMTP id 6CFD51193BB; Sun, 29 May 2005 22:43:10 +0800 (WST) Received: from vscan02.westnet.com.au ([127.0.0.1]) by localhost (vscan02.westnet.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13843-12; Sun, 29 May 2005 22:43:10 +0800 (WST) Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au [202.72.133.22]) by vscan02.westnet.com.au (Postfix) with ESMTP id EC5E01193B3; Sun, 29 May 2005 22:43:09 +0800 (WST) Message-ID: <4299D4FC.5050505@familyhealth.com.au> Date: Sun, 29 May 2005 22:43:08 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Michael Engelhart Cc: pgsql-performance@postgresql.org Subject: Re: sequential scan performance References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/421 X-Sequence-Number: 12585 > When I do an EXPLAIN ANALYZE on the above query, the result is: > > Seq Scan on city_alias (cost=0.00..59282.31 rows=2 width=42) (actual > time=73.369..3330.281 rows=407 loops=1) > Filter: ((name)::text ~~ '%FRANCISCO'::text) > Total runtime: 3330.524 ms > (3 rows) > > > this is a query that our system needs to do a LOT. Is there any way > to improve the performance on this either with changes to our query or > by configuring the database deployment? We have an index on city_name > but when using the % operator on the front of the query string > postgresql can't use the index . Of course not. There really is now way to make your literal query above fast. You could try making a functional index on the reverse() of the string and querying for the reverse() of 'francisco'. Or, if you want a general full text index, you should absolutely be using contrib/tsearch2. Chris From pgsql-performance-owner@postgresql.org Sun May 29 13:33:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B6944528B1 for ; Sun, 29 May 2005 13:33:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97075-06 for ; Sun, 29 May 2005 16:33:19 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 17FA05284F for ; Sun, 29 May 2005 13:33:13 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 5A72115232; Sun, 29 May 2005 11:33:12 -0500 (CDT) Date: Sun, 29 May 2005 11:33:12 -0500 From: "Jim C. Nasby" To: Christopher Kings-Lynne Cc: mark durrant , pgsql-performance@postgresql.org Subject: Re: Select performance vs. mssql Message-ID: <20050529163312.GK44623@decibel.org> References: <20050524153637.64525.qmail@web53101.mail.yahoo.com> <4293D500.8010908@familyhealth.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4293D500.8010908@familyhealth.com.au> X-Operating-System: FreeBSD 4.11-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/422 X-Sequence-Number: 12586 On Wed, May 25, 2005 at 09:29:36AM +0800, Christopher Kings-Lynne wrote: > >--MSSQL's ability to hit the index only and not having > >to go to the table itself results in a _big_ > >performance/efficiency gain. If someone who's in > >development wants to pass this along, it would be a > >nice addition to PostgreSQL sometime in the future. > >I'd suspect that as well as making one query faster, > >it would make everything else faster/more scalable as > >the server load is so much less. > > This is well-known and many databases do it. However, due to MVCC > considerations in PostgreSQL, it's not feasible for us to implement it... Wasn't there a plan to store some visibility info in indexes? IIRC the idea was that a bit would be set in the index tuple indicating that all transactions that wouldn't be able to see that index value were complete, meaning that there was no reason to hit the heap for that tuple. I looked on the TODO but didn't see this, maybe it fell through the cracks? -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Sun May 29 16:44:57 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5FA4C5282B for ; Sun, 29 May 2005 16:44:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98791-01 for ; Sun, 29 May 2005 19:44:49 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id B411C52815 for ; Sun, 29 May 2005 16:44:41 -0300 (ADT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j4TJiWJl026121; Sun, 29 May 2005 23:44:33 +0400 (MSD) Date: Sun, 29 May 2005 23:44:32 +0400 (MSD) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: Michael Engelhart Cc: pgsql-performance@postgresql.org Subject: Re: sequential scan performance In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.331 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200505/423 X-Sequence-Number: 12587 Michael, I'd recommend our contrib/pg_trgm module, which provides trigram based fuzzy search and return results ordered by similarity to your query. Read http://www.sai.msu.su/~megera/postgres/gist/pg_trgm/README.pg_trgm for more details. Oleg On Sun, 29 May 2005, Michael Engelhart wrote: > Hi - > > I have a table of about 3 million rows of city "aliases" that I need to query > using LIKE - for example: > > select * from city_alias where city_name like '%FRANCISCO' > > > When I do an EXPLAIN ANALYZE on the above query, the result is: > > Seq Scan on city_alias (cost=0.00..59282.31 rows=2 width=42) (actual > time=73.369..3330.281 rows=407 loops=1) > Filter: ((name)::text ~~ '%FRANCISCO'::text) > Total runtime: 3330.524 ms > (3 rows) > > > this is a query that our system needs to do a LOT. Is there any way to > improve the performance on this either with changes to our query or by > configuring the database deployment? We have an index on city_name but when > using the % operator on the front of the query string postgresql can't use > the index . > > Thanks for any help. > > Mike > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 From pgsql-performance-owner@postgresql.org Sun May 29 17:17:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 29E1752824 for ; Sun, 29 May 2005 17:17:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68070-08 for ; Sun, 29 May 2005 20:17:13 +0000 (GMT) Received: from asmail001.abovesecurity.com (asmail001.abovesecurity.com [206.162.148.235]) by svr1.postgresql.org (Postfix) with ESMTP id AE0E952820 for ; Sun, 29 May 2005 17:17:11 -0300 (ADT) Content-class: urn:content-classes:message Subject: OID vs overall system performances on high load MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Sun, 29 May 2005 16:17:11 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: OID vs overall system performances on high load thread-index: AcVki2V14fl7q/fHR9epnkLMRlW8+g== From: "Eric Lauzon" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/424 X-Sequence-Number: 12588 I am still in the dark due to my lack of knowledge on internal OID = management,but i would presume that a table with OID enable and that has high load = would require some more work from pgsql internal to maintain the OID index for the = database. =20 So OID can be beneficial on static tables, or tables that you want to be = able to manipulate with pgadmin X , but can a table without OID increase performances on = insert,delete,update,COPY? =20 I am not really worried about disk space that an OID collumn can take, = but i was wandering if an=20 insert in a table of 20 millions and more that has oid would slow the = insert process. Since OID seem to act as a global index mabey maintaning that index can become costy = over high table load by postgresql backend. =20 -Eric Lauzon =20 =20 =20 =20 =20 =20 From pgsql-performance-owner@postgresql.org Sun May 29 18:47:01 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8F70B5293D for ; Sun, 29 May 2005 18:46:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41332-03 for ; Sun, 29 May 2005 21:46:54 +0000 (GMT) Received: from mail1.catalyst.net.nz (godel.catalyst.net.nz [202.49.159.12]) by svr1.postgresql.org (Postfix) with ESMTP id B19C0528C5 for ; Sun, 29 May 2005 18:46:45 -0300 (ADT) Received: from leibniz.catalyst.net.nz ([202.49.159.7] helo=lamb.mcmillan.net.nz) by mail1.catalyst.net.nz with asmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DcVcL-0006um-5I; Mon, 30 May 2005 09:46:45 +1200 Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) by lamb.mcmillan.net.nz (Postfix) with ESMTP id 3D8FDAD98581; Mon, 30 May 2005 09:46:43 +1200 (NZST) Subject: Re: OID vs overall system performances on high load From: Andrew McMillan To: Eric Lauzon Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-GovVMaTAy3jtklj3CzlR" Date: Mon, 30 May 2005 09:46:43 +1200 Message-Id: <1117403203.30150.206.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/425 X-Sequence-Number: 12589 --=-GovVMaTAy3jtklj3CzlR Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sun, 2005-05-29 at 16:17 -0400, Eric Lauzon wrote: > I am still in the dark due to my lack of knowledge on internal OID manage= ment,but > i would presume that a table with OID enable and that has high load would= require > some more work from pgsql internal to maintain the OID index for the data= base. > =20 > So OID can be beneficial on static tables, or tables that you want to be = able to manipulate > with pgadmin X , but can a table without OID increase performances on ins= ert,delete,update,COPY? > =20 > I am not really worried about disk space that an OID collumn can take, bu= t i was wandering if an=20 > insert in a table of 20 millions and more that has oid would slow the ins= ert process. Since OID seem > to act as a global index mabey maintaning that index can become costy ove= r high table load by postgresql > backend. There is no OID index, unless you create one. The disk space that an OID column can take has an effect on performance: reducing the amount of physical disk reads will mean that more of your real data is cached, and so forth. How much effect it will have will depend on the relative size of the OID column and the other columns in your data. Regards, Andrew McMillan. ------------------------------------------------------------------------- Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 http://survey.net.nz/ - any more questions? ------------------------------------------------------------------------- --=-GovVMaTAy3jtklj3CzlR Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBCmjhCjJA0f48GgBIRAsNvAJ4k9hsLUrlSfYFtu0Zevcy1SyiUIgCdGcOL UnB1QivvEsV3KZqWntZPRB4= =EpBo -----END PGP SIGNATURE----- --=-GovVMaTAy3jtklj3CzlR-- From pgsql-performance-owner@postgresql.org Sun May 29 18:47:30 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B21D852837 for ; Sun, 29 May 2005 18:47:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73764-05 for ; Sun, 29 May 2005 21:47:20 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id B869D52932 for ; Sun, 29 May 2005 18:47:17 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4TLlI5e018635; Sun, 29 May 2005 17:47:18 -0400 (EDT) To: "Eric Lauzon" Cc: pgsql-performance@postgresql.org Subject: Re: OID vs overall system performances on high load In-reply-to: References: Comments: In-reply-to "Eric Lauzon" message dated "Sun, 29 May 2005 16:17:11 -0400" Date: Sun, 29 May 2005 17:47:18 -0400 Message-ID: <18634.1117403238@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/426 X-Sequence-Number: 12590 "Eric Lauzon" writes: > I am still in the dark due to my lack of knowledge on internal OID management,but > i would presume that a table with OID enable and that has high load would require > some more work from pgsql internal to maintain the OID index for the database. There is no "OID index"; at least not unless you choose to create one for a given table. The only thing particularly special about OID is that there is an internal database-wide sequence generator for assigning new values. Otherwise it works a whole lot like a serial column. regards, tom lane From pgsql-performance-owner@postgresql.org Mon May 30 01:03:01 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E4D1E5292D for ; Mon, 30 May 2005 01:02:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18585-02 for ; Mon, 30 May 2005 04:02:55 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 5882E528F7 for ; Mon, 30 May 2005 01:02:54 -0300 (ADT) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id 16AAD18CDC3; Mon, 30 May 2005 00:02:54 -0400 (EDT) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 63648-01; Mon, 30 May 2005 00:02:51 -0400 (EDT) Received: from fjgateway (unknown [61.88.101.19]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id 811C318CDC8; Mon, 30 May 2005 00:02:50 -0400 (EDT) Subject: Re: OID vs overall system performances on high load From: Neil Conway To: Eric Lauzon Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Date: Mon, 30 May 2005 14:02:44 +1000 Message-Id: <1117425764.23266.12.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.02 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/427 X-Sequence-Number: 12591 On Sun, 2005-05-29 at 16:17 -0400, Eric Lauzon wrote: > So OID can be beneficial on static tables OIDs aren't beneficial on "static tables"; unless you have unusual requirements[1], there is no benefit to having OIDs on user-created tables (see the default_with_oids GUC var, which will default to "false" in 8.1) -Neil [1] Such as a column that references a column in the system catalogs. From pgsql-performance-owner@postgresql.org Mon May 30 06:26:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 467FB5281C for ; Mon, 30 May 2005 06:26:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71095-03 for ; Mon, 30 May 2005 09:26:12 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id 855ED52819 for ; Mon, 30 May 2005 06:26:05 -0300 (ADT) Received: (qmail 7864 invoked from network); 30 May 2005 09:19:51 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 30 May 2005 09:19:51 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id 4C6756F76D; Mon, 30 May 2005 17:19:51 +0800 (CST) Date: Mon, 30 May 2005 17:19:51 +0800 From: Tobias Brox To: pgsql-performance@postgresql.org Subject: timestamp indexing Message-ID: <20050530091951.GO26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/429 X-Sequence-Number: 12593 We have a production database with transaction-style data, in most of the tables we have a timestamp attribute "created" telling the creation time of the table row. Naturally, this attribute is always increasing. By now we are hitting the limit where the table data does not fit in caches anymore. We have a report section where there are constantly requests for things like "sum up all transactions for the last two weeks", and those requests seem to do a full table scan, even though only the last parts of the table is needed - so by now those reports have started to cause lots of iowait. Is there any way to avoid this, apart from adding memory linearly with database growth, make adjunct tables for historical rows, or build a separate data warehousing system? There must be some simpler solutions, right? -- Tobias Brox, Beijing From pgsql-performance-owner@postgresql.org Mon May 30 10:43:24 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 750C152805 for ; Mon, 30 May 2005 10:43:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98672-03 for ; Mon, 30 May 2005 13:43:11 +0000 (GMT) Received: from asmail001.abovesecurity.com (asmail001.abovesecurity.com [206.162.148.235]) by svr1.postgresql.org (Postfix) with ESMTP id E4A7952819 for ; Mon, 30 May 2005 10:43:09 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Postgresql and xeon. X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Mon, 30 May 2005 09:43:12 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Postgresql and xeon. thread-index: AcVlHYWfkU15yjPgRTWqcgnKc3BXvw== From: "Eric Lauzon" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/430 X-Sequence-Number: 12594 What about xeon and postgresql, i have been told that=20 postgresql wouldn't perform as well when running under xeon processors due to some cache trick that postgresql uses?=20 Why? Any fix? Rumors? AMD Advocates? Problems with HT?? Would that problems only be true for 7.4.x? I didin't found any comprehensive analysis/explanation for this matters beside people saying , stop using xeon and postgresql. Enlightment please... Eric Lauzon [Recherche & D=E9veloppement] Above S=E9curit=E9 / Above Security T=E9l : (450) 430-8166 Fax : (450) 430-1858=20 From pgsql-performance-owner@postgresql.org Mon May 30 10:54:53 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C513E528B2 for ; Mon, 30 May 2005 10:54:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48309-07 for ; Mon, 30 May 2005 13:54:49 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 0EF8C52894 for ; Mon, 30 May 2005 10:54:48 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j4UDsUng045052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 30 May 2005 07:54:33 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j4UDsU1r078252; Mon, 30 May 2005 07:54:30 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j4UDsTvi078251; Mon, 30 May 2005 07:54:30 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 30 May 2005 07:54:29 -0600 From: Michael Fuhr To: Tobias Brox Cc: pgsql-performance@postgresql.org Subject: Re: timestamp indexing Message-ID: <20050530135429.GA78082@winnie.fuhr.org> References: <20050530091951.GO26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050530091951.GO26100@tobias.exoweb.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/431 X-Sequence-Number: 12595 On Mon, May 30, 2005 at 05:19:51PM +0800, Tobias Brox wrote: > > We have a production database with transaction-style data, in most of the > tables we have a timestamp attribute "created" telling the creation time of > the table row. Naturally, this attribute is always increasing. The message subject is "timestamp indexing" but you don't mention whether you have an index on the timestamp column. Do you? > By now we are hitting the limit where the table data does not fit in caches > anymore. We have a report section where there are constantly requests for > things like "sum up all transactions for the last two weeks", and those > requests seem to do a full table scan, even though only the last parts of > the table is needed - so by now those reports have started to cause lots of > iowait. Could you post an example query and its EXPLAIN ANALYZE output? If the query uses a sequential scan then it might also be useful to see the EXPLAIN ANALYZE output with enable_seqscan turned off. Since caching can cause a query to be significantly faster after being run several times, it might be a good idea to run EXPLAIN ANALYZE three times and post the output of the last run -- that should put the queries under comparison on a somewhat equal footing (i.e., we don't want to be misled about how much faster one query is than another simply because one query happened to use more cached data on a particular run). How many records are in the tables you're querying? Are you regularly vacuuming and analyzing the database or the individual tables? Are any of the tables clustered? If so, on what indexes and how often are you re-clustering them? What version of PostgreSQL are you using? -- Michael Fuhr http://www.fuhr.org/~mfuhr/ From pgsql-performance-owner@postgresql.org Mon May 30 13:01:10 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F152852815 for ; Mon, 30 May 2005 13:01:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05697-03 for ; Mon, 30 May 2005 16:01:01 +0000 (GMT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by svr1.postgresql.org (Postfix) with ESMTP id B399652809 for ; Mon, 30 May 2005 13:00:58 -0300 (ADT) Received: from p549C256D.dip0.t-ipconnect.de [84.156.37.109] (helo=p4.local) by mrelayeu.kundenserver.de with ESMTP (Nemesis), id 0MKwh2-1Dcmas28VV-0000zB; Mon, 30 May 2005 17:54:22 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by p4.local (Postfix) with ESMTP id D892C40C0 for ; Mon, 30 May 2005 17:54:28 +0200 (CEST) Message-ID: <429B3734.2020609@freenet.de> Date: Mon, 30 May 2005 17:54:28 +0200 From: =?ISO-8859-1?Q?Sebastian_B=F6ck?= User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.8) Gecko/20050512 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Index not used on join with inherited tables Content-Type: multipart/mixed; boundary="------------080806010405030002040702" X-Provags-ID: kundenserver.de abuse@kundenserver.de login:9060023f140952ea5098d12d38573a7d X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.529 tagged_above=0 required=5 tests=AWL, UPPERCASE_50_75 X-Spam-Level: X-Archive-Number: 200505/432 X-Sequence-Number: 12596 This is a multi-part message in MIME format. --------------080806010405030002040702 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi all, I'm having another problem with a query that takes to long, because the appropriate index is not used. I found some solutions to this problem, but I think Postgres should do an index scan in all cases. To show the problem I've attached a small script with a testcase. Thanks in advance Sebastian --------------080806010405030002040702 Content-Type: text/plain; name="bug.sql" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="bug.sql" /* tables */ CREATE TABLE test ( id SERIAL PRIMARY KEY, test TEXT ); CREATE TABLE test1 ( id INTEGER PRIMARY KEY ) INHERITS (test); CREATE TABLE test2 ( id INTEGER PRIMARY KEY ) INHERITS (test); CREATE TABLE test3 ( id INTEGER PRIMARY KEY ) INHERITS (test); CREATE TABLE bug ( id INTEGER PRIMARY KEY ); /* views */ CREATE OR REPLACE VIEW working_fast AS SELECT * FROM test WHERE id = 1; CREATE OR REPLACE VIEW working_fast_2 AS SELECT test1.* FROM test1 JOIN bug AS bug1 ON TRUE WHERE test1.id = bug1.id UNION ALL SELECT test2.* FROM test2 JOIN bug AS bug2 ON TRUE WHERE test2.id = bug2.id UNION ALL SELECT test3.* FROM test3 JOIN bug AS bug3 ON TRUE WHERE test3.id = bug3.id; CREATE OR REPLACE VIEW working_slow AS SELECT test.* FROM test JOIN bug ON TRUE WHERE test.id = bug.id; /* data */ CREATE OR REPLACE FUNCTION data () RETURNS BOOLEAN AS $$ BEGIN FOR i IN 1..10000 LOOP INSERT INTO test1 (id,test) VALUES (DEFAULT,i); INSERT INTO test2 (id,test) VALUES (DEFAULT,i); INSERT INTO test3 (id,test) VALUES (DEFAULT,i); END LOOP; RETURN TRUE; END; $$ LANGUAGE plpgsql; SELECT data(); INSERT INTO bug VALUES ('1'); ANALYZE; EXPLAIN ANALYZE SELECT * from working_fast; EXPLAIN ANALYZE SELECT * from working_fast_2; EXPLAIN ANALYZE SELECT * from working_slow; --------------080806010405030002040702-- From pgsql-performance-owner@postgresql.org Mon May 30 13:19:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0F95352944 for ; Mon, 30 May 2005 13:19:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59178-08 for ; Mon, 30 May 2005 16:19:32 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id E232C5293D for ; Mon, 30 May 2005 13:19:30 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7421691; Mon, 30 May 2005 09:21:34 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: "Eric Lauzon" Subject: Re: Postgresql and xeon. Date: Mon, 30 May 2005 09:19:40 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505300919.40827.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.327 tagged_above=0 required=5 tests=AWL, URIBL_SBL X-Spam-Level: X-Archive-Number: 200505/433 X-Sequence-Number: 12597 Eric, > What about xeon and postgresql, i have been told that > postgresql wouldn't perform as well when running > under xeon processors due to some cache trick that postgresql > uses? Search the archives of this list. This has been discussed ad nauseum. www.pgsql.ru -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon May 30 13:21:46 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 65D5052800 for ; Mon, 30 May 2005 13:21:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59178-09 for ; Mon, 30 May 2005 16:21:36 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 79B2E52838 for ; Mon, 30 May 2005 13:21:36 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7421706; Mon, 30 May 2005 09:23:40 -0700 From: Josh Berkus Organization: Aglio Database Solutions To: Sebastian =?utf-8?q?B=C3=B6ck?= Subject: Re: Index not used on join with inherited tables Date: Mon, 30 May 2005 09:21:46 -0700 User-Agent: KMail/1.8 Cc: pgsql-performance@postgresql.org References: <429B3734.2020609@freenet.de> In-Reply-To: <429B3734.2020609@freenet.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505300921.46460.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/434 X-Sequence-Number: 12598 Sebastian, > I'm having another problem with a query that takes to long, because > the appropriate index is not used. PostgreSQL is not currently able to push down join criteria into UNIONed subselects. It's a TODO. Also, if you're using inherited tables, it's unnecessary to use UNION; just select from the parent. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon May 30 13:33:45 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3EEA3528C5 for ; Mon, 30 May 2005 13:33:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84712-10 for ; Mon, 30 May 2005 16:33:32 +0000 (GMT) Received: from smtp817.mail.sc5.yahoo.com (smtp817.mail.sc5.yahoo.com [66.163.170.3]) by svr1.postgresql.org (Postfix) with SMTP id 7F08A528B2 for ; Mon, 30 May 2005 13:33:29 -0300 (ADT) Received: from unknown (HELO ?10.0.1.2?) (mengelhart@sbcglobal.net@68.90.147.67 with plain) by smtp817.mail.sc5.yahoo.com with SMTP; 30 May 2005 16:33:24 -0000 Mime-Version: 1.0 (Apple Message framework v730) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Michael Engelhart Subject: Re: sequential scan performance Date: Mon, 30 May 2005 11:33:28 -0500 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.730) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/435 X-Sequence-Number: 12599 Thanks everyone for all the suggestions. I'll check into those contrib modules. Michael On May 29, 2005, at 2:44 PM, Oleg Bartunov wrote: > Michael, > > I'd recommend our contrib/pg_trgm module, which provides > trigram based fuzzy search and return results ordered by similarity > to your query. Read http://www.sai.msu.su/~megera/postgres/gist/ > pg_trgm/README.pg_trgm > for more details. > > Oleg > On Sun, 29 May 2005, Michael Engelhart wrote: > > >> Hi - >> >> I have a table of about 3 million rows of city "aliases" that I >> need to query using LIKE - for example: >> >> select * from city_alias where city_name like '%FRANCISCO' >> >> >> When I do an EXPLAIN ANALYZE on the above query, the result is: >> >> Seq Scan on city_alias (cost=0.00..59282.31 rows=2 width=42) >> (actual time=73.369..3330.281 rows=407 loops=1) >> Filter: ((name)::text ~~ '%FRANCISCO'::text) >> Total runtime: 3330.524 ms >> (3 rows) >> >> >> this is a query that our system needs to do a LOT. Is there any >> way to improve the performance on this either with changes to our >> query or by configuring the database deployment? We have an >> index on city_name but when using the % operator on the front of >> the query string postgresql can't use the index . >> >> Thanks for any help. >> >> Mike >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to >> majordomo@postgresql.org) >> >> > > Regards, > Oleg > _____________________________________________________________ > Oleg Bartunov, sci.researcher, hostmaster of AstroNet, > Sternberg Astronomical Institute, Moscow University (Russia) > Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ > phone: +007(095)939-16-83, +007(095)939-23-83 > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > From pgsql-performance-owner@postgresql.org Mon May 30 13:36:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 18E365292F for ; Mon, 30 May 2005 13:36:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96423-07 for ; Mon, 30 May 2005 16:36:37 +0000 (GMT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by svr1.postgresql.org (Postfix) with ESMTP id 47531528C5 for ; Mon, 30 May 2005 13:36:35 -0300 (ADT) Received: from p549C256D.dip0.t-ipconnect.de [84.156.37.109] (helo=p4.local) by mrelayeu.kundenserver.de with ESMTP (Nemesis), id 0ML21M-1DcnFi0GG1-0007QM; Mon, 30 May 2005 18:36:34 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by p4.local (Postfix) with ESMTP id 3146240BA; Mon, 30 May 2005 18:36:39 +0200 (CEST) Message-ID: <429B4117.1050103@freenet.de> Date: Mon, 30 May 2005 18:36:39 +0200 From: =?UTF-8?B?U2ViYXN0aWFuIELDtmNr?= User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.8) Gecko/20050512 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: Index not used on join with inherited tables References: <429B3734.2020609@freenet.de> <200505300921.46460.josh@agliodbs.com> In-Reply-To: <200505300921.46460.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de login:9060023f140952ea5098d12d38573a7d X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.119 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/436 X-Sequence-Number: 12600 Josh Berkus wrote: > Sebastian, > > >>I'm having another problem with a query that takes to long, because >>the appropriate index is not used. > > > PostgreSQL is not currently able to push down join criteria into UNIONed > subselects. It's a TODO. And the appends in a "SELECT * from parent" are UNIONs, aren't they? > Also, if you're using inherited tables, it's unnecessary to use UNION; just > select from the parent. Yes, but then no index is used... Sebastian From pgsql-performance-owner@postgresql.org Mon May 30 13:53:02 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 99BC45292D for ; Mon, 30 May 2005 13:53:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90449-03 for ; Mon, 30 May 2005 16:52:59 +0000 (GMT) Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com [64.71.176.18]) by svr1.postgresql.org (Postfix) with ESMTP id 562525292B for ; Mon, 30 May 2005 13:52:58 -0300 (ADT) Received: by gp.word-to-the-wise.com (Postfix, from userid 500) id DBACA900010; Mon, 30 May 2005 09:53:40 -0700 (PDT) Date: Mon, 30 May 2005 09:53:40 -0700 From: Steve Atkins To: pgsql-performance@postgresql.org Subject: Re: sequential scan performance Message-ID: <20050530165340.GA21210@gp.word-to-the-wise.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.781 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST X-Spam-Level: X-Archive-Number: 200505/437 X-Sequence-Number: 12601 On Sun, May 29, 2005 at 08:27:26AM -0500, Michael Engelhart wrote: > Hi - > > I have a table of about 3 million rows of city "aliases" that I need > to query using LIKE - for example: > > select * from city_alias where city_name like '%FRANCISCO' > > > When I do an EXPLAIN ANALYZE on the above query, the result is: > > Seq Scan on city_alias (cost=0.00..59282.31 rows=2 width=42) > (actual time=73.369..3330.281 rows=407 loops=1) > Filter: ((name)::text ~~ '%FRANCISCO'::text) > Total runtime: 3330.524 ms > (3 rows) > > > this is a query that our system needs to do a LOT. Is there any way > to improve the performance on this either with changes to our query > or by configuring the database deployment? We have an index on > city_name but when using the % operator on the front of the query > string postgresql can't use the index . If that's really what you're doing (the wildcard is always at the beginning) then something like this create index city_name_idx on foo (reverse(city_name)); select * from city_alias where reverse(city_name) like reverse('%FRANCISCO'); should do just what you need. I use this, with a plpgsql implementation of reverse, and it works nicely. CREATE OR REPLACE FUNCTION reverse(text) RETURNS text AS ' DECLARE original alias for $1; reverse_str text; i int4; BEGIN reverse_str = ''''; FOR i IN REVERSE LENGTH(original)..1 LOOP reverse_str = reverse_str || substr(original,i,1); END LOOP; return reverse_str; END;' LANGUAGE 'plpgsql' IMMUTABLE; Someone will no doubt suggest using tsearch2, and you might want to take a look at it if you actually need full-text search, but my experience has been that it's too slow to be useful in production, and it's not needed for the simple "leading wildcard" case. Cheers, Steve From pgsql-performance-owner@postgresql.org Mon May 30 13:54:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F3A2E528AE for ; Mon, 30 May 2005 13:54:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65585-04 for ; Mon, 30 May 2005 16:54:53 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id 20E7352816 for ; Mon, 30 May 2005 13:54:52 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DcnXL-0003ck-GE for pgsql-performance@postgresql.org; Mon, 30 May 2005 18:54:48 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1DcnXL-0002ek-00 for ; Mon, 30 May 2005 18:54:47 +0200 Date: Mon, 30 May 2005 18:54:47 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Postgresql and xeon. Message-ID: <20050530165447.GA9708@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <200505300919.40827.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <200505300919.40827.josh@agliodbs.com> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.327 tagged_above=0 required=5 tests=AWL, URIBL_SBL X-Spam-Level: X-Archive-Number: 200505/438 X-Sequence-Number: 12602 On Mon, May 30, 2005 at 09:19:40AM -0700, Josh Berkus wrote: > Search the archives of this list. This has been discussed ad nauseum. > www.pgsql.ru I must admit I still haven't really understood it -- I know that it appears on multiple operating systems, on multiple architectures, but most with Xeon CPUs, and that it's probably related to the poor memory bandwidth between the CPUs, but that's about it. I've read the threads I could find on the list archives, but I've yet to see somebody pinpoint exactly what in PostgreSQL is causing this. Last time someone claimed this was bascially understood and "just a lot of work to fix", I asked for pointers to a more detailed analysis, but nobody answered. Care to explain? :-) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Mon May 30 14:02:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4171D52816 for ; Mon, 30 May 2005 14:02:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89909-08 for ; Mon, 30 May 2005 17:02:15 +0000 (GMT) Received: from asmail001.abovesecurity.com (asmail001.abovesecurity.com [206.162.148.235]) by svr1.postgresql.org (Postfix) with ESMTP id E39F952809 for ; Mon, 30 May 2005 14:02:13 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: Postgresql and xeon. X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Mon, 30 May 2005 13:02:12 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Postgresql and xeon. thread-index: AcVlOMfuWskecjh9TeGepnURGvZsqwAADshQ From: "Eric Lauzon" To: "Steinar H. Gunderson" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.315 tagged_above=0 required=5 tests=AWL, URIBL_SBL X-Spam-Level: X-Archive-Number: 200505/439 X-Sequence-Number: 12603 > -----Original Message----- > From: pgsql-performance-owner@postgresql.org=20 > [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 > Steinar H. Gunderson > Sent: 30 mai 2005 12:55 > To: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Postgresql and xeon. >=20 > On Mon, May 30, 2005 at 09:19:40AM -0700, Josh Berkus wrote: > > Search the archives of this list. This has been discussed=20 > ad nauseum. > > www.pgsql.ru >=20 > I must admit I still haven't really understood it -- I know=20 > that it appears on multiple operating systems, on multiple=20 > architectures, but most with Xeon CPUs, and that it's=20 > probably related to the poor memory bandwidth between the=20 > CPUs, but that's about it. I've read the threads I could find=20 > on the list archives, but I've yet to see somebody pinpoint=20 > exactly what in PostgreSQL is causing this. >=20 > Last time someone claimed this was bascially understood and=20 > "just a lot of work to fix", I asked for pointers to a more=20 > detailed analysis, but nobody answered. Care to explain? :-) Same here archives references are just overview but no real data.... to where and why, i would state pg 7.4.8 and kernel 2.6 with preemptive = scheduler and dual xeon 3.2 ghz 6 gig of ram. Eric Lauzon [Recherche & D=E9veloppement] Above S=E9curit=E9 / Above Security T=E9l : (450) 430-8166 Fax : (450) 430-1858=20 From pgsql-performance-owner@postgresql.org Mon May 30 14:02:57 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CA7F452806 for ; Mon, 30 May 2005 14:02:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33648-03 for ; Mon, 30 May 2005 17:02:45 +0000 (GMT) Received: from lynet.oppetid.no (oppetid.no [80.65.51.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5F46052809 for ; Mon, 30 May 2005 14:02:44 -0300 (ADT) Received: by lynet.oppetid.no (Postfix, from userid 1019) id 89D6111A2AA; Mon, 30 May 2005 19:08:16 +0200 (CEST) Date: Mon, 30 May 2005 19:08:16 +0200 From: Tobias Brox To: Michael Fuhr Cc: Tobias Brox , pgsql-performance@postgresql.org Subject: Re: timestamp indexing Message-ID: <20050530170816.GA9222@oppetid.no> References: <20050530091951.GO26100@tobias.exoweb.net> <20050530135429.GA78082@winnie.fuhr.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050530135429.GA78082@winnie.fuhr.org> User-Agent: Mutt/1.3.28i Organization: Group Nordicbet X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/440 X-Sequence-Number: 12604 [Michael Fuhr - Mon at 07:54:29AM -0600] > The message subject is "timestamp indexing" but you don't mention > whether you have an index on the timestamp column. Do you? Yes. Sorry for not beeing explicit on that. > Could you post an example query and its EXPLAIN ANALYZE output? If > the query uses a sequential scan then it might also be useful to see > the EXPLAIN ANALYZE output with enable_seqscan turned off. Since > caching can cause a query to be significantly faster after being run > several times, it might be a good idea to run EXPLAIN ANALYZE three > times and post the output of the last run -- that should put the > queries under comparison on a somewhat equal footing (i.e., we don't > want to be misled about how much faster one query is than another > simply because one query happened to use more cached data on a > particular run). The actual statement was with 6 or 7 joins and very lengthy. I reduced it to a simple single join query which still did a sequential scan rather than an index scan (as expected), and I believe I already did a follow-up mail including "explain analyze". All "explain analyze" in my previous mail was run until the resulting execution time had stabilized, relatively. I will try with "set enable_seqscan off" when I get back to the office. > How many records are in the tables you're querying? Also answered on in my follow-up. > Are you regularly > vacuuming and analyzing the database or the individual tables? Vacuum is run nightly, and I also did a manual "vacuum analyze table" on the table in question. > Are > any of the tables clustered? If so, on what indexes and how often > are you re-clustering them? Huh? :) > What version of PostgreSQL are you using? Also answered in my follow-up - "not yet pg8" :) From pgsql-performance-owner@postgresql.org Mon May 30 14:15:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E04BF52806 for ; Mon, 30 May 2005 14:15:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76704-02 for ; Mon, 30 May 2005 17:15:12 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9810252816 for ; Mon, 30 May 2005 14:15:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4UHF8e0024604; Mon, 30 May 2005 13:15:08 -0400 (EDT) To: "Steinar H. Gunderson" Cc: pgsql-performance@postgresql.org Subject: Re: Postgresql and xeon. In-reply-to: <20050530165447.GA9708@uio.no> References: <200505300919.40827.josh@agliodbs.com> <20050530165447.GA9708@uio.no> Comments: In-reply-to "Steinar H. Gunderson" message dated "Mon, 30 May 2005 18:54:47 +0200" Date: Mon, 30 May 2005 13:15:08 -0400 Message-ID: <24603.1117473308@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/441 X-Sequence-Number: 12605 "Steinar H. Gunderson" writes: > I must admit I still haven't really understood it -- I know that it appears > on multiple operating systems, on multiple architectures, but most with Xeon > CPUs, and that it's probably related to the poor memory bandwidth between the > CPUs, but that's about it. I've read the threads I could find on the list > archives, but I've yet to see somebody pinpoint exactly what in PostgreSQL is > causing this. The problem appears to be that heavy contention for a spinlock is extremely expensive on multiprocessor Xeons --- apparently, the CPUs waste tremendous amounts of time passing around exclusive ownership of the memory cache line containing the spinlock. While any SMP system is likely to have some issues here, the Xeons seem to be particularly bad at it. In the case that was discussed extensively last spring, the lock that was causing the problem was the BufMgrLock. Since 8.0 we've rewritten the buffer manager in hopes of reducing contention, but I don't know if the problem is really gone or not. The buffer manager is hardly the only place with the potential for heavy contention... regards, tom lane From pgsql-performance-owner@postgresql.org Mon May 30 14:58:09 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0057852805 for ; Mon, 30 May 2005 14:58:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87672-07 for ; Mon, 30 May 2005 17:58:07 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id ACCF552832 for ; Mon, 30 May 2005 14:58:05 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4UHvsJQ024840; Mon, 30 May 2005 13:57:54 -0400 (EDT) To: Tobias Brox Cc: Michael Fuhr , pgsql-performance@postgresql.org Subject: Re: timestamp indexing In-reply-to: <20050530170816.GA9222@oppetid.no> References: <20050530091951.GO26100@tobias.exoweb.net> <20050530135429.GA78082@winnie.fuhr.org> <20050530170816.GA9222@oppetid.no> Comments: In-reply-to Tobias Brox message dated "Mon, 30 May 2005 19:08:16 +0200" Date: Mon, 30 May 2005 13:57:54 -0400 Message-ID: <24839.1117475874@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/442 X-Sequence-Number: 12606 Tobias Brox writes: >> What version of PostgreSQL are you using? > Also answered in my follow-up - "not yet pg8" :) Your followup hasn't shown up here yet, but if the query is written like WHERE timestampcol >= now() - interval 'something' then the pre-8.0 planner is not capable of making a good estimate of the selectivity of the WHERE clause. One solution is to fold the timestamp computation to a constant on the client side. regards, tom lane From pgsql-performance-owner@postgresql.org Mon May 30 19:00:50 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 50D0952856 for ; Mon, 30 May 2005 19:00:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82915-03 for ; Mon, 30 May 2005 22:00:42 +0000 (GMT) Received: from presinet-main.presinet.com (presinet.com [209.53.156.1]) by svr1.postgresql.org (Postfix) with ESMTP id 84BF752806 for ; Mon, 30 May 2005 19:00:38 -0300 (ADT) Received: from [10.10.1.151] (BRICK [10.10.1.151]) by presinet-main.presinet.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2658.3) id L9MTJ0HM; Mon, 30 May 2005 14:57:08 -0700 Message-ID: <429B8D05.5040705@PresiNET.com> Date: Mon, 30 May 2005 15:00:37 -0700 From: Bricklen Anderson User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Colton A Smith Cc: pgsql-performance@postgresql.org Subject: Re: poor performance involving a small table References: In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.02 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/447 X-Sequence-Number: 12611 Colton A Smith wrote: > > Hi: > > I have a table called sensors: > > Table "public.sensor" > Column | Type | Modifiers > -----------------+--------------------------+------------------------------------------------- > > sensor_id | integer | not null default > nextval('sensor_id_seq'::text) > sensor_model_id | integer | not null > serial_number | character varying(50) | not null > purchase_date | timestamp with time zone | not null > variable_id | integer | not null > datalink_id | integer | not null > commentary | text | > Indexes: > "sensor_pkey" PRIMARY KEY, btree (sensor_id) > Foreign-key constraints: > "datalink_id_exists" FOREIGN KEY (datalink_id) REFERENCES > datalink(datalink_id) ON DELETE RESTRICT > "sensor_model_id_exists" FOREIGN KEY (sensor_model_id) REFERENCES > sensor_model(sensor_model_id) ON DELETE RESTRICT > "variable_id_exists" FOREIGN KEY (variable_id) REFERENCES > variable(variable_id) ON DELETE RESTRICT > > > Currently, it has only 19 rows. But when I try to delete a row, it takes > forever. I tried restarting the server. I tried a full vacuum to no > avail. I tried the following: > > explain analyze delete from sensor where sensor_id = 12; > QUERY PLAN > ------------------------------------------------------------------------------------------------ > > Seq Scan on sensor (cost=0.00..1.25 rows=1 width=6) (actual > time=0.055..0.068 rows=1 loops=1) > Filter: (sensor_id = 12) > Total runtime: 801641.333 ms > (3 rows) > > Can anybody help me out? Thanks so much! > I'd say the obvious issue would be your foreign keys slowing things down. Have you analyzed the referenced tables, and indexed the columns on the referenced tables? -- _______________________________ This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. _______________________________ From pgsql-performance-owner@postgresql.org Mon May 30 19:07:05 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3925652849 for ; Mon, 30 May 2005 19:07:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03328-03 for ; Mon, 30 May 2005 22:06:53 +0000 (GMT) Received: from adicia.telenet-ops.be (adicia.telenet-ops.be [195.130.132.56]) by svr1.postgresql.org (Postfix) with ESMTP id 41E465281B for ; Mon, 30 May 2005 19:06:51 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by adicia.telenet-ops.be (Postfix) with SMTP id 3E73244137 for ; Tue, 31 May 2005 00:06:51 +0200 (MEST) Received: from [10.0.1.11] (d5152B1F3.access.telenet.be [81.82.177.243]) by adicia.telenet-ops.be (Postfix) with ESMTP id BC3814411B for ; Tue, 31 May 2005 00:06:50 +0200 (MEST) Mime-Version: 1.0 (Apple Message framework v622) To: pgsql-performance@postgresql.org Message-Id: <14ab8d7ed7b485e9721af087c65d0992@implements.be> Content-Type: multipart/mixed; boundary=Apple-Mail-83--402827114 From: Yves Vindevogel Subject: Drop / create indexes and vacuumdb Date: Tue, 31 May 2005 00:06:49 +0200 X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/448 X-Sequence-Number: 12612 --Apple-Mail-83--402827114 Content-Type: multipart/alternative; boundary=Apple-Mail-84--402827113 --Apple-Mail-84--402827113 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi, Does it make a difference in performance and/or disc space if I 1) drop index / vacuumdb -zf / create index or 2) drop index / create index / vacuumdb -zf I guess it makes a diff for the --analyze, not ? Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements --Apple-Mail-84--402827113 Content-Transfer-Encoding: quoted-printable Content-Type: text/enriched; charset=ISO-8859-1 Hi, Does it make a difference in performance and/or disc space if I 1) drop index / vacuumdb -zf / create index or 2) drop index / create index / vacuumdb -zf I guess it makes a diff for the --analyze, not ? Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements = --Apple-Mail-84--402827113-- --Apple-Mail-83--402827114 Content-Transfer-Encoding: base64 Content-Type: image/tiff; x-unix-mode=0666; name="Pasted Graphic 2.tiff" Content-Disposition: inline; filename="Pasted Graphic 2.tiff" TU0AKgAAFciAP6BP5/wWDQeEQmFQuGQ2HQ+FP5+v9rOh5P9IMBuP8zK9tP8fJNlP8QoNjP8FndhP 8MnyVjJHSMrqFnv9BL1vP9ett2v98PuJxChUOiUWGQOCUalUujOV4PZ/qBluR/mdVtJ/jVHst/ho 9MF/g08WABHJfv8AWa0WoAHFfWuzgg6sB/hY9ysUohjv8qqVqv9LMZxv9ouV40zEYmHUjFY2HPx+ RNtOl4Rhftt/phiRs6LC/iA5LewnJeWg46W22+02cAHOwa26bC0HPY7TZ7G2G9dv8EHFdP8Om9YP 8rKJov9UtFzv9Dzh/sRvu5/vZ9PzHdeF4zsUqgQRlOR5v9DMBwv8uqe/jZIVwNHu6B0/WAKHvWGr RAA1ra0G1c/vfgANrdraXrTQIAA6JW2TUrQNz/ja0oAjO4YAjSWS0DOWawjys4RkIk4Lj2sAWEUZ B/ieUJqH+PZdnAf5aG06R5nsfLtqW7UaoWZJwukwLyi4VRsn+F5HGYf8QJWBQ7JWAI5tYti2Dm1T bQHAq0De1Q2FwtA1Fof4AjVDIBDQV0vDQWK0DY/oADYWsrNQN81NOuDZtYOM6ycs4Cjq+Q9JWE5D pGJpOpqP5dMwW5sHUf53xlHCExupjqoIbh3Hu55vp6ch3Hof4wlMrAdEWYh/gmP1RtXK0DDi2rXy nVzXjpVs8NM1g1vuNU2gANEugGMBRwu4YADTNsvwyAA3v+0k6LRWLb2dBUpjk2I4NVOx/gYPC6BU QiwCgSsSlWZpxH+ahzsOaBzvCe7qoMpKlUghd1n2f5oHId5/lQaJ0n+RBf3GLpUGwf4iksrg0FVF ICzlXT9QBB0tWO/+FjlKVWtfijTNRBsvDbhrdP3NUAwY38KFfkc0PuNjRWLLz8ytiTUVdVlnjlA2 MWPAWRAAM8LAAMjhhuR5ir4ULjigT5pn+P5co2T6pn+YBup6dp6xoh6kHie95modNOFkah0H+Qhd pyKBNmcf68r2Bo9GGtdpwIAUotM1Q4QMNzUDZhuVZbLsvy7KkqZZCnAb4AFcQY1C3LW1Wb5lOa2t ZvUt78NNjcMN83wEOMDczvuTzXNQ3QEN01WRL2b8XBYEDuugQEFUYgkpIo5FjIJTmhfZkHG8J0nm fB/sifp/EQYLBioUKsBkRKVgWPLX7stA4VnaDa+tZlZel0j+gCMpWS8MRULQNeIDY/4zTIAIyFX0 GFybZnr+rZ8p2a1s6tUNfADXXI1Yb8jLX+MNQk+1Az7zWqwVa/FaJrHpvSLeAQOhdE/l7CSJwrAb BXDXH+PkyA/gUiPGaftASWW6JeDgnGAsCmLNvcYqlz5+FchnZMrqGbeE3JoYhAMAKbEvOGeigtaE CDZwJcgxtiML0uMgQYzllKt2GhtP/EaH6cgAm+fnCtVEVXFOKNU54AC1B/tyLfBx4YJBGwhAAG5m yUoGH/TgxlZ7nGXw3YdEpYTPWOvaSq/JVEX28rEDQsGKDoGPx+QYnE1URg2paZY4dy7EHTx9cc41 upqIfwkjSgJWyW0MgBdK9I1DGAAwnS8G8+4cGYyUWWbKMg/gSiOjQG+FMQ44qqlmgBNUSYYMohKW 2ULFZaR8NdMFucoz/w/ZcAAMzgH+j/AKGV8QAZkhmWNM0AJ/I5zCiJEGYjF1qoGmxI5MqwT7JVlG buLULJhPXlbK+WMt3HwHmIbF8xaA0n6mvPgN7EJhx9Vcax+hsX6wGZuldNDnTSgQDoloGohS6BYE 62gPQqyRhlFE2gIYkCRgdD4WcAUsnxvlYklKgUCn4upi29JkkpG/pbYgtKbr86TLOnbLCF066ZLP kGsI+7NY9rRjZHB+0ew4M5S0AKT4FA8l0BaIUk4XHkj/EYLwzAtVyj/GwRYf49B8D6H+OMdw9R/j DG8vcTgx1xhpFTBoHYilRgaDygQAobXCynVVSSVdRYTLJls5CcIaqX0zpw/Kms76c2DSnTsNNPaA TbpggqOSCg4MkQwcAPiBAzimJqI4Xg3R/itX0P8bY66xD7MiYkgg5h4vAF2NgdY/xNGCH+HQVMIQ WiCNVM2L6Ap4s3ShFixMubA2HnjcUulhab3GuIbGxVjLlxXZoawMKFgsCiaSOUd6nB6XbH+PofKN LtqcH7eMf5AyimQOtegf4/TIEFvYP8dyjTm2eV1KdmNgrlIKr/cOxF+LjmRldTZY88L/U6P/YtyF +b82PDAhkOQsyNkHu8jS76NB4YXH+PvDUG7v3lIFeu8mFbuj6q8PXE2HEaXqIEUEgxnh2T2YhD/B WBZcUunVjO59yMB3PsHc3BONLemxwaP8NwsTMEPvVeMieJKvXmHZk8f48h5GHyYP8e+V3g3tvMQs VY01FLCxjgTHk8b943yBTOVoJEiXJzPgae1zr+2HwYhnIuRzrjczwP8eY8zDmKy7l8NOYcx40zKW nNswizytg+kXHc/qS48x9o7QbNMhZ0yMdvPBG7wmNz/jB6WYs436uFmbHhbFrAFgjhl4Y/g5IvH+ 0EkYFw+NuAHqmoet9bWJwPnDHEfM55E0udjTNW7uZ+y9p6L+oNe3Bxtoa4lACzgQee2kQ5Jwo1RK QPQfK8xejaJ6FG6w/wEh1NZJ+L6ydoH+zfqTUK0dK7AzsY7Yem9jaA0Fu2wVf9eJObqW+TxuwbCS K4JEYVnh2O/vWQM5K+wtCehCCAP5YABybV035xCAJIJqnrTyFqB9H8e1Lu/OumM870MTp3MGn9J8 g5Zsxhk2ZURLfGmrBAEg5m/CISIf4jRekblaCgRoyS0BjWNZVw6uZ70hnsrkND/Fbn3kWWtmz1ID a5NxyLYJ1xujdI3iZTm9dkYy4/P9yFKIcFoDQsbtKW4nT2YbLrpr450V6zTGem7N+YzXVzDZ0PSl ddIb8GQVrlD9sQjy4FKHVy0ZDDeLHCPWuuD/68Y0Vg1LX8c0bQSBiAq9JrVv2pYwZkzq6mqxDi8y XJgBkjZGftMMdUgm5PKyCBnogBI72hYgZlgrD6WWgMzPZkxGdUzfIfIzsdb66PXr/Jxp+XwRGlOL GnuJm2b0l7vo/dJeDL4N7qwWN+qn5CqedNMATuzZmObaad1s4dBMl/6wmG/Pt1+oAAYk2hToiuQc 5FxyjyRoHqH0xYKE+Q8k+UIgH0KAH+HSHqXmGwHSIuEGF0I25eWE8A96/g2akwhIk8Puf25mpi3w /IeG/M8y0O10/WgM3cpUS8l0mS+ocOYgDQS0ASDUTOB6EaJWDkXyXwFyL+GqGkPKHQHMOkxIXmIO HAHAJyyuKgvGIIHgU2H+G0GuHKH+FwF6KwEAtAH+CUEcLOAiNC2QnKcOZSZCmO9ongNep2sA3Y2W nY/KwE9hDazc8w8Sug9mh6cAZ0/UAEC0FKH+AOCOEoJQBeD8H+A2A+DYYGBuD2H+D6DmFCH+F0Fq hDB+PKGcGaaSGsGmJyGOGGg0EuEgP0CqCOEOH+BIA+DQH+AgBSDrD+CAEcH+AICwFNA+pamupfDQ /G1E2asfDksJDesNBCv012x+5WDmQSseeiAaCGEiH+BEAmC0H+A8AcCyH+A4AXGqAqAOCsLqAQCw H+BMAuDIH+CJEWPMCpFKCaCEEASEBFESA2AaC2H+AoAOCqK6AVGqA8AYCvGcAiC9HmBlHZBglBDt F80LF7BNDdBHDg2U0JGI0lGEseWsAgB6EYH+BUAkC4H+BKAuDDGcArH+BCAnH+A8AeC6K7HjG7H4 AoANHtG1G4A1GxGkAfHkBAAjJOBCAqC/FMAuDAH+BOApJ8A0BYDy2aWtGEzI1G2dKRIUwDGDF9BP DooBISnVImB9IsBRJHI2AuDHK3HHI4DFK3K6BGArI8BAAlJ8A8AhJqAlJxJBK3LDLBK9LmBNKCH+ AwBZEZIGcjGM3zKVIRL7BEH8zVKfKojrKlMCQVIk2jKuH/KzH/I5K7MjLFMpMnI5HGBIAvG/I5J9 MvMrK5M/K7LrJ9LxL1DXL5KYp1L/MM80g2wABMzWAGjVDZIc/XDrIiNjKtKxK1MtNBN7MlN9HFJ5 M3J7NDONMnNHLvLzKNKnMS5dNPMAsGpgLKLoAQNswAH8EAGAXGB0EobQAwEEJOblOa1uzJIfNvF9 MXFVMbMfOPODOBOBMxM1K3M7PfPdNFLtNLOZOcfjIOgVPIfeAaD2VGBUEY6ECyFQL+awXWH+HCHa KgW+KoAqDsPu3Mt8rxMO+fOjPTNzMZN3MhPtN/M/PlOJPrPhPvHBPzOXL3KPKhP69Mv4SmYWWs4m QyDGFUGsH+GeHEOkHW204SIED6FmaSBqeZHmQ3Fikw7iPwZWkCSs40Yg0CwTQAxpPUAhPZN5RDS1 PjOHPpRRRFOTP1RZSo5W1skw6MDa6g5omYZW94AYDkN+BOD+NKCoE6SKHy1WA8EOL2Z8cuhGTU/f SlArAu95L2cmiO1xSrQ7PXQ/S/S1RJS9RFUlNBTDRXNPRavw3St25kTXBiQsADBfUFNO/fUC6K+A N+9fTI2SkOfG6YmY9MZWDEFS+0TInFUQSfPI1NQ9MdSzRPUnS5MzRLUdRPUqD02RRaeoseDdSaQn ScQi9G/kPu+e/o+E8UQUoGv/IXMKsOfqZu8O/eV2S89E7QZ7XG8w/edGQYxiTeoSB3FKBQAlRBV9 S3LnWDUjXpN7LCBOAnJ8AyBXKKV0Z7KPKO6i764rXI9wS8DJVq6TAw+hP5MFBJDi0Ofq0i86mQPv XMDRWlBi6QVy6iAYCUEuJIBDESBGA0DNI2AxLjRCAxS4BGAvH5I5J2BLZdZVV9ZtZqDKJIA+DUH+ AiB4ES2a4pDFDE+fVIkg84ZylyTUn7RdYjIZYhQy14fipY9SDTWhSjRg6UAEC+fZGWEfEMBCDbFM AtJ9MzI9LlM8BFZjJ5ZpNBMzLCBJLKH+A+A3ZSAiByEMmcC0FO7Q7eTVSW+ectBY9HQ2oFDTNXak Ns9fIa0hPPVUfqfq5i3OjohIAEC6fYAWB6ERFUBSDxLuAtZSA7JSA/JoH/LPH+BIAtK7bZG4BGAt JCApH+A+AhJPGnJOA0AfH+AiBIDoWuBzc6AICvD8PxUAWJWWj2sfWwsPP9cXWzKc/PGE0jPQvwiE 9kWsAeB+EVI2AaCpdQAbGjGnHkA4AbJPHhI0A2AZI0A6AdI1drG+A6AfG/HhGjfVI1fLfJGpfBGq BGAZHsAvKJA+j7eZencVNSlZGBelINchalStIqbTV7J5I8BDLtdrJPfLfSAZHkA2AXfPfXENJTfl JrK0BFdjMoBOArX7UsYhUxaledgRcZgVBLMTepVU17StSxXlMrZzbgAtLDgrdoAlGiBBK1dhZZLi AxK/OFORRVNNhbhu0PhhafgTW1gXilgbgRhzUbV/OOAwDPFMAxe/ZrPriXXnWJidP3hiuZgPiphk eGA8EUJGWEc3MNhtgdUXSvi5XxS1Z3Zhe/MzbfjNRRUrieVpeejtOg0OseDeNYQexAIEE4GcX2B4 EkRKAMDsNjXSTWcVVVjvi1jzh1WHM/j8AvkAAvkFlHkLjVjdjZF4pPk0nANKLKQIBCESL2D6F6XG XgvWqwHQMqEsGIRaL6RSAgD6bcQAbyNRBkLQDCWNhdNxkPj1V5h3i7N7lLlPlTmtUpjTTHak1tUE DHDyQMDWN+ggQIByEiJOEGOcGIG8Okq7CMXay2KMG8HaU4rcMGCIE8aSBcEWL2Ci4ccggbKXhxlD j3jPPdmxbdLnm3PxNJhZkO1CseseDUNKBIEMJWB8EqhCBqEuGgH+DiFiL+GXQcINAEIhl4McIkXc IICurWWuDulCNiDW85VVi3mplHmuH/j/oZM9odRTohkNNQnjYIc6QIAILmH+BgEOLOtabCUcIPpV qiIOHMKeOQGoJ6C+FaMwAuEJT474DYTfliJQrbgjmrj5OBoXkDobrTJ/LsArX+LQDI72nBlkJQLv C2FBpAEoGOMGGhqsvKH7nlqpqlnpsKKMHgJ+tgGQPKCmFIaSAwD8LOA4EGJWBiCdEFH1G/iPp0Av rXlRrboTdXLDdrI0BSBkD4H/n8JOAkD7o0EwhCECF+PKG6HceBsQRtsPtyOuq4/+22RcFYJGBkBK Ddp4AtI8A2AdHkA/H9uPZZrVp5lNp9OFMzK7iLJ9HhHlgrJ8BSA3FSEWECe+vNsVnkXdt4MVqnvR qiHmHkKgF+F0JqEMD8fECQB4D7uPI8AyAZGjubJ8BAAqClbqAng4AbfZdsKyBTuMDiDOE2H+FmFe JGHMU1vXwrvVwrwxCKagF3pADyDiFEH+CWCAEHJ+A3G4B+BmDmH+DQC7EEFGE4NKHYHUXvwxxqIj t3xtxyIaw0ImGwGus8HgUZx1yGavxxyJyPyRySKIKQFuFibQGOGEYFyVynypymKQCaB/xIDkDOE8 IQFSFEVGE+EsQIIWGEF4L+EwEeP6IOE4EoN2DOC0ErpCDLy6DYDAEyH+FiFU6EHyq6H+DqDUFAH+ G4GwOWIWw0IIEMD68HzsE0H+DgDIE4H+DaDD0cG8G4X2FgFS6EFGE2LAIWG0GsHMH+EoEWTaIOFn uEH+DKCzzkDjzoH+DJ1aH+FuFgbRsGIIEKD2fZyCrEIOGUGMI2E8EqNLz6XmDsDXEgDUC6EwH+DW C9zx1ZzkF4FuOOHUq0D8Dnb8DeDHwd0h0kEeEKQsKQCkCLFKDv2SIQD6DkFJENg2H/ygYFxkPCBu BQDkH+CwCXIsIOCiCJb2CQB0D+H+FEE0LoEYEGTOCgCGEKH/2uMrGfI8GEF7RyIWHwOoH+CEBptU EaEITOFCEyLOF0FoJr16aUDpb9fbH+GAF0RSz2KgCABjdACSB4ED3V3YH+C8CjbCFAEwLP006EG8 G2X35LbnK6B/5iH+GcGSs8FoFehCC0CYEavXAT5WRSDyDdxACKBtvwFwFkJqHEHAUVxeLACSB3HZ 2GNKEyEgP6EsEaNEKQCn3MH+DuDZEgIOEUEAZMDuDbxB7jFL5zbCDQC2Et2cC/zwIP8AH+BoBKDf 1iCxEEC4CfFgEqEYNFCeU4BWA2DSXIGgXGIWu+XmCQB35r2R0EEgEOQyIWEOD88GECDvVmCyCZIs DACpGaE0EkN+DP8GIQEGDyFUH/3LFL0Ue+HkHh18IMHPwoCqCRe54ILoCMBvEKC6Cl8CC18IIWFa FKL2DGCtEEIXE0MH2+H+EKD4fZ10fZ374Z7h7l7p7sIMEF9eRd6d1p1t4H4L/ohCDECsEkIQIAVC MiX+dTUoH++n0/X++4W/4hEHe7Xo/xQGTO/zQXEu/0Cd1S/0Yglg/3g73q/yWPUE/zsa1C/0IeVW /0GeFU/3G4Xa/0MfVY/1or2bQlbRUiiVpJpQ/y+U0jEYggzzOSkRUM/0KfJqfzop3+p1Aw3+53I7 n+UCJWak3m26H+OxYdX+Xiij6leVRY3+YKheaks1Yy3+VCPBEIe5zM5qOxbdICAADgEAAAMAAAAB ADgAAAEBAAMAAAABAEAAAAECAAMAAAAEAAAWdgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQA AAABAAAACAEVAAMAAAABAAQAAAEWAAQAAAABAAAAkgEXAAQAAAABAAAVwAEaAAUAAAABAAAWfgEb AAUAAAABAAAWhgEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAFSAAMAAAABAAEAAAAAAAAACAAIAAgA CAAK/IAAACcQAAr8gAAAJxA= --Apple-Mail-83--402827114 Content-Type: multipart/alternative; boundary=Apple-Mail-85--402827112 --Apple-Mail-85--402827112 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Ghandi. --Apple-Mail-85--402827112 Content-Transfer-Encoding: 7bit Content-Type: text/enriched; charset=US-ASCII Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Ghandi. --Apple-Mail-85--402827112-- --Apple-Mail-83--402827114-- From pgsql-performance-owner@postgresql.org Mon May 30 02:18:32 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2F09528B2 for ; Mon, 30 May 2005 02:18:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16881-01 for ; Mon, 30 May 2005 05:18:30 +0000 (GMT) Received: from hummer.onthenet.com.au (hummer.OntheNet.com.au [203.13.68.9]) by svr1.postgresql.org (Postfix) with ESMTP id 0CCB75287A for ; Mon, 30 May 2005 02:18:29 -0300 (ADT) Received: from [192.168.2.24] (imp5.dsl.onthenet.net [203.144.16.135]) by hummer.onthenet.com.au (Postfix) with ESMTP id 495F519FBD1 for ; Mon, 30 May 2005 15:18:27 +1000 (EST) Message-ID: <429B90D1.9030402@wildcash.com> Date: Mon, 30 May 2005 15:16:49 -0700 From: Rudi Starcevic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en MIME-Version: 1.0 To: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <758d5e7f05052614232f6c9164@mail.gmail.com> <4a0cafe205052706043ef8f53f@mail.gmail.com> <4a0cafe205052706042d4e60e5@mail.gmail.com> <14584.1117204158@sss.pgh.pa.us> In-Reply-To: <14584.1117204158@sss.pgh.pa.us> X-Enigmail-Version: 0.86.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.329 tagged_above=0 required=5 tests=DATE_IN_FUTURE_12_24 X-Spam-Level: ** X-Archive-Number: 200505/428 X-Sequence-Number: 12592 Hi, I had some disk io issues recently with NFS, I found the command 'iostat -x 5' to be a great help when using Linux. For example here is the output when I do a 10GB file transfer onto hdc Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util hdc 0.00 875.95 0.00 29.66 0.00 7244.89 0.00 3622.44 244.27 3.07 103.52 1.78 5.27 The last field show the disk is 5.27% busy. I have seen this value at 100%, adding more server brought it under 100%. It seems that if you hit 100% problems sort of cascade all over that place. For example Apache connections went right up and hit their max. I am not sure how accurate the % is but it has work pretty well for me. Perhaps use this command in another window with you run your SQL and see what it shows. HTH. Kind regards, Rudi. From pgsql-performance-owner@postgresql.org Mon May 30 19:42:09 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A9D9052806 for ; Mon, 30 May 2005 19:42:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16826-05 for ; Mon, 30 May 2005 22:41:59 +0000 (GMT) Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz [202.0.58.24]) by svr1.postgresql.org (Postfix) with ESMTP id 9114752815 for ; Mon, 30 May 2005 19:41:58 -0300 (ADT) Received: from smtp-3.paradise.net.nz (smtp-3a.paradise.net.nz [202.0.32.196]) by linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id <0IHB00F3ZR20HT@linda-5.paradise.net.nz> for pgsql-performance@postgresql.org; Tue, 31 May 2005 10:42:01 +1200 (NZST) Received: from [192.168.1.11] (218-101-14-55.paradise.net.nz [218.101.14.55]) by smtp-3.paradise.net.nz (Postfix) with ESMTP id 6BD8EAE36D; Tue, 31 May 2005 10:42:00 +1200 (NZST) Date: Tue, 31 May 2005 10:41:59 +1200 From: Mark Kirkwood Subject: Re: tuning In-reply-to: <20050526164228.S10655@vbp2.vbp2.com> To: list Cc: pgsql-performance@postgresql.org Message-id: <429B96B7.2050502@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050511) References: <20050526164228.S10655@vbp2.vbp2.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.117 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/449 X-Sequence-Number: 12613 list wrote: > hi- > > i would like to see if someone could recommend something > to make my query run faster. > > > Values in postgresql.conf: > shared_buffers = 1000 > sort_mem is commented out > effective_cache_size is commented out > random_page_cost is commented out > I would increase shared_buffers (say 5000 - 10000), and also effective_cache_size (say around 20000 - 50000 - but work out how much memory this box has free or cached and adjust accordingly). From your explain output, it looks like sorting is not too much of a problem - so you can leave it unchanged (for this query anyway). > Here is the query in question: > select * from productvendorview where (productlistid=3 or > productlistid=5 or productlistid=4) and (lower(item) like '9229%' or > lower(descrip) like 'toner%') order by vendorname,item limit 100; > You might want to break this into 2 queries and union them, so you can (potentially) use the indexes on productlistid,lower(item) and productlistid, lower(descrip) separately. > This query scans 412,457 records. > > Here is the EXPLAIN ANALYZE for the query: > > Limit (cost=45718.83..45719.08 rows=100 width=108) (actual > time=39093.636..39093.708 rows=100 loops=1) > -> Sort (cost=45718.83..45727.48 rows=3458 width=108) (actual > time=39093.629..39093.655 rows=100 loops=1) > Sort Key: v.vendorname, p.item > -> Hash Join (cost=22.50..45515.57 rows=3458 width=108) > (actual time=95.490..39062.927 rows=2440 loops=1) > Hash Cond: ("outer".vendorid = "inner".id) > -> Seq Scan on test p (cost=0.00..45432.57 rows=3457 > width=62) (actual time=89.066..39041.654 rows=2444 loops=1) > Filter: (((productlistid = 3) OR (productlistid = > 5) OR (productlistid = 4)) AND > ((lower((item)::text) ~~ '9229%'::text) OR > (lower((descrip)::text) ~~ 'toner%'::text))) > -> Hash (cost=20.00..20.00 rows=1000 width=54) (actual > time=6.289..6.289 rows=0 loops=1) > -> Seq Scan on vendor v (cost=0.00..20.00 > rows=1000 width=54) (actual time=0.060..3.653 rows=2797 loops=1) > Total runtime: 39094.713 ms > (10 rows) > I guess the relation 'test' is a copy of product (?) Cheers Mark From pgsql-performance-owner@postgresql.org Mon May 30 22:51:14 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 40F105288E for ; Mon, 30 May 2005 22:51:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73940-03 for ; Tue, 31 May 2005 01:51:09 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id BEFAA52891 for ; Mon, 30 May 2005 22:51:08 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 6845724FDD; Tue, 31 May 2005 09:51:12 +0800 (WST) Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 43FB424FCE; Tue, 31 May 2005 09:51:12 +0800 (WST) Message-ID: <429BC35A.7060904@familyhealth.com.au> Date: Tue, 31 May 2005 09:52:26 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Colton A Smith Cc: pgsql-performance@postgresql.org Subject: Re: poor performance involving a small table References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.065 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/450 X-Sequence-Number: 12614 > Seq Scan on sensor (cost=0.00..1.25 rows=1 width=6) (actual > time=0.055..0.068 rows=1 loops=1) > Filter: (sensor_id = 12) > Total runtime: 801641.333 ms > (3 rows) > > Can anybody help me out? Thanks so much! Does your table have millions of dead rows? Do you vacuum once an hour? Run VACUUM FULL ANALYE sensor; Chris From pgsql-performance-owner@postgresql.org Mon May 30 23:06:48 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7871452814 for ; Mon, 30 May 2005 23:06:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57849-03 for ; Tue, 31 May 2005 02:06:43 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id 1B27A52805 for ; Mon, 30 May 2005 23:06:32 -0300 (ADT) Received: (qmail 8451 invoked from network); 31 May 2005 02:06:25 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 31 May 2005 02:06:25 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id 5E10A6F76D; Tue, 31 May 2005 10:06:25 +0800 (CST) Date: Tue, 31 May 2005 10:06:25 +0800 From: Tobias Brox To: Tom Lane Cc: Tobias Brox , Michael Fuhr , pgsql-performance@postgresql.org Subject: Re: timestamp indexing Message-ID: <20050531020625.GA26100@tobias.exoweb.net> References: <20050530091951.GO26100@tobias.exoweb.net> <20050530135429.GA78082@winnie.fuhr.org> <20050530170816.GA9222@oppetid.no> <24839.1117475874@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24839.1117475874@sss.pgh.pa.us> Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/451 X-Sequence-Number: 12615 [Tom Lane - Mon at 01:57:54PM -0400] > Your followup hasn't shown up here yet, I'll check up on that and resend it. > but if the query is written like > WHERE timestampcol >= now() - interval 'something' > then the pre-8.0 planner is not capable of making a good estimate of the > selectivity of the WHERE clause. > One solution is to fold the timestamp > computation to a constant on the client side. I don't think there are any of that in the production; we always make the timestamps on the client side. As to my original problem, I looked up on table clustering on google. Right, for report performance, we store some aggregates in the table which are updated several times. If I've understood it correctly, the row will physically be moved to the tail of the table every time the attribute is updated. I understand that it may make sense to do a full table scan if a random 10% of the rows should be selected. Forcing the usage of the index caused a tiny improvement of performance, but only after running it some few times to be sure the index got buffered :-) -- Tobias Brox, Beijing From pgsql-performance-owner@postgresql.org Mon May 30 23:20:25 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F52E52806 for ; Mon, 30 May 2005 23:20:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30228-10 for ; Tue, 31 May 2005 02:20:20 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id 69CFE52896 for ; Mon, 30 May 2005 23:20:14 -0300 (ADT) Received: (qmail 8955 invoked from network); 31 May 2005 02:20:14 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 31 May 2005 02:20:14 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id CF1096F76D; Tue, 31 May 2005 10:20:13 +0800 (CST) Date: Tue, 31 May 2005 10:20:11 +0800 From: Tobias Brox To: pgsql-performance@postgresql.org Subject: Re: timestamp indexing Message-ID: <20050531022011.GC26100@tobias.exoweb.net> References: <20050530091951.GO26100@tobias.exoweb.net> <20050530135429.GA78082@winnie.fuhr.org> <20050530170816.GA9222@oppetid.no> <24839.1117475874@sss.pgh.pa.us> <20050531020625.GA26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050531020625.GA26100@tobias.exoweb.net> Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/452 X-Sequence-Number: 12616 [Tobias Brox - Tue at 10:06:25AM +0800] > [Tom Lane - Mon at 01:57:54PM -0400] > > Your followup hasn't shown up here yet, > > I'll check up on that and resend it. Hrm ... messed-up mail configuration I suppose. Here we go: Paul McGarry unintentionally sent a request for more details off the list, since it was intended for the list I'll send my reply here. While writing up the reply, and doing research, I discovered that this is not a problem with indexing timestamps per se, but more with a query of the kind "give me 5% of the table"; it seems like it will often prefer to do a full table scan instead of going via the index. I think that when I had my university courses on databases, we also learned about flat indexes, where the whole index has to be rebuilt whenever a field is updated or inserted in the middle, and I also think we learned that the table usually would be sorted physically by the primary key on the disk. As long as we have strictly incrementing primary keys and timestamps, such a setup would probably be more efficient for queries of the kind "give me all activity for the last two weeks"? Here follows my reply to Paul, including some gory details: [Paul McGarry - Mon at 07:59:35PM +1000] > What version of postgresql are you using and what are the exact > datatypes and queries? We are still using 7.4.6, but I suppose that if our issues are completely or partially solved in pg 8, that would make a good case for upgrading :-) The datatypes I'm indexing are timestamp without time zone. Actually I may be on the wrong hunting ground now - the production system froze completely some days ago basically due to heavy iowait and load on the database server, rendering postgresql completely unresponsive - and back then we had too poor logging to find out what queries that was causing it to grind to a halt, and since we've never such a bad problem before, we didn't know how to handle the situation (we just restarted the entire postgresql; if we had been just killing the processes running the rogue database queries, we would have had very good tracks of it in the logs). I digress. The last days I've looked through profiling logs, and I'm checking if the accumulatively worst queries can be tuned somehow. Most of them are big joins, but I'm a bit concerned of the amounts of "Seq Scan" returned by "explain" despite the fact that only a small fraction of the tables are queried. I reduced the problem to a simple "select * from table where created>xxx" and discovered that it still won't use index, and still will be costly (though of course not much compared to the big joined query). The "ticket" table have less than a million rows, around 50k made the last ten days: NBET=> explain analyze select * from ticket where created>'2005-05-20'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Seq Scan on ticket (cost=0.00..19819.91 rows=89553 width=60) (actual time=535.884..1018.268 rows=53060 loops=1) Filter: (created > '2005-05-20 00:00:00'::timestamp without time zone) Total runtime: 1069.514 ms (3 rows) Anyway, it seems to me that "indexing on timestamp" is not the real issue here, because when restricting by primary key (numeric, sequential ID) the execution time is the same or worse, still doing a sequence scan: NBET=> explain analyze select * from ticket where id>711167; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Seq Scan on ticket (cost=0.00..19819.91 rows=92273 width=60) (actual time=550.855..1059.843 rows=53205 loops=1) Filter: (id > 711167) Total runtime: 1110.469 ms (3 rows) I've tried running equivalent queries on a table with twice as many rows and width=180, it will pull from the index both when querying by ID and timestamp, and it will usually spend less time. Running "select * from ticket" seems to execute ~2x slower than when having the restriction. > I have a 7.3 database with a "timestamp with time zone" field and we > have to be very careful to explicitly cast values as that in queries > if it is to use the index correctly. I believe it's an issue that is > cleared up in newer versions though. I suppose so - as said, restricting by primary key didn't improve the performance significantly, so I was clearly wrong indicating that this is a special issue with indexing a timestamp. -- Tobias Brox, Beijing From pgsql-performance-owner@postgresql.org Mon May 30 23:31:17 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7EA9852806 for ; Mon, 30 May 2005 23:31:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95908-09 for ; Tue, 31 May 2005 02:31:08 +0000 (GMT) Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net [67.119.5.202]) by svr1.postgresql.org (Postfix) with ESMTP id CC01E52891 for ; Mon, 30 May 2005 23:31:06 -0300 (ADT) Received: (from andrew@localhost) by pillette.com (8.11.6/8.11.6) id j4V2V6e25466; Mon, 30 May 2005 19:31:06 -0700 Date: Mon, 30 May 2005 19:31:06 -0700 From: andrew@pillette.com Message-Id: <200505310231.j4V2V6e25466@pillette.com> Subject: Re: poor performance involving a small table To: Colton A Smith Cc: pgsql-performance@postgresql.org X-Originating-IP: 64.172.57.4 X-Mailer: Webmin 0.940 MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.195 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, NO_REAL_NAME X-Spam-Level: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Archive-Number: 200505/453 X-Sequence-Number: 12617 This is a multi-part message in MIME format. --bound1117506666 Content-Type: text/plain Content-Transfer-Encoding: 7bit Colton A Smith wrote .. ------------------------------------------------------------------------------------------------ > Seq Scan on sensor (cost=0.00..1.25 rows=1 width=6) (actual > time=0.055..0.068 rows=1 loops=1) > Filter: (sensor_id = 12) > Total runtime: 801641.333 ms > (3 rows) Do you have some foreign keys pointing in the other direction? In other words, is there another table such that a delete on sensors causing a delete (or a check of some key) in another table? EXPLAIN doesn't show these. And that might be a big table missing an index. --bound1117506666-- From pgsql-performance-owner@postgresql.org Tue May 31 00:02:27 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7E5FE52815 for ; Tue, 31 May 2005 00:02:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36115-06 for ; Tue, 31 May 2005 03:02:14 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id 0409152806 for ; Tue, 31 May 2005 00:02:10 -0300 (ADT) Received: (qmail 10959 invoked from network); 31 May 2005 03:02:07 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 31 May 2005 03:02:07 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id 9DD45E09C4; Tue, 31 May 2005 11:02:07 +0800 (CST) Date: Tue, 31 May 2005 11:02:07 +0800 From: Tobias Brox To: pgsql-performance@postgresql.org Subject: Index on a NULL-value Message-ID: <20050531030207.GD26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/454 X-Sequence-Number: 12618 I read in the manual today: Indexes are not used for IS NULL clauses by default. The best way to use indexes in such cases is to create a partial index using an IS NULL predicate. This is from the documentation for PostgreSQL 8. I did not find anything equivalent in the 7.4.8-documentation. I wasn't aware of this until it became an issue :-) Well, so I follow the tip but in vain. Reduced and reproduced like this in PostgreSQL 7.4.7: test=# create table mock(a int, b int); CREATE TABLE test=# create index b_is_null on mock((b IS NULL)); CREATE INDEX test=# insert into mock values (10,20); INSERT 70385040 1 test=# insert into mock values (20,30); INSERT 70385041 1 test=# insert into mock values (30, NULL); INSERT 70385042 1 test=# set enable_seqscan=off; SET test=# explain select * from mock where b is NULL; QUERY PLAN -------------------------------------------------------------------- Seq Scan on mock (cost=100000000.00..100000020.00 rows=6 width=8) Filter: (b IS NULL) (2 rows) vacuum analyze also didn't help to recognize the index ;-) Any tips? Rewrite the application to not use NULL-values? Hide under bedclothes and hope the problem goes away? Install more memory in the server? :-) -- Tobias Brox, Beijing From pgsql-performance-owner@postgresql.org Tue May 31 00:18:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7135352805 for ; Tue, 31 May 2005 00:18:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02904-06 for ; Tue, 31 May 2005 03:18:03 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 8DA3D52806 for ; Tue, 31 May 2005 00:18:01 -0300 (ADT) Received: (qmail 19522 invoked by uid 500); 31 May 2005 03:16:54 -0000 Date: Mon, 30 May 2005 22:16:53 -0500 From: Bruno Wolff III To: Tobias Brox Cc: pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value Message-ID: <20050531031653.GA17723@wolff.to> Mail-Followup-To: Bruno Wolff III , Tobias Brox , pgsql-performance@postgresql.org References: <20050531030207.GD26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050531030207.GD26100@tobias.exoweb.net> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/455 X-Sequence-Number: 12619 On Tue, May 31, 2005 at 11:02:07 +0800, Tobias Brox wrote: > I read in the manual today: > > Indexes are not used for IS NULL clauses by default. The best way to use > indexes in such cases is to create a partial index using an IS NULL > predicate. > > This is from the documentation for PostgreSQL 8. I did not find anything > equivalent in the 7.4.8-documentation. > > I wasn't aware of this until it became an issue :-) Well, so I follow the > tip but in vain. Reduced and reproduced like this in PostgreSQL 7.4.7: > > test=# create table mock(a int, b int); > CREATE TABLE > test=# create index b_is_null on mock((b IS NULL)); > CREATE INDEX > test=# insert into mock values (10,20); > INSERT 70385040 1 > test=# insert into mock values (20,30); > INSERT 70385041 1 > test=# insert into mock values (30, NULL); > INSERT 70385042 1 > test=# set enable_seqscan=off; > SET > test=# explain select * from mock where b is NULL; > QUERY PLAN > -------------------------------------------------------------------- > Seq Scan on mock (cost=100000000.00..100000020.00 rows=6 width=8) > Filter: (b IS NULL) > (2 rows) > > vacuum analyze also didn't help to recognize the index ;-) It isn't surprising that an index wasn't used since a sequential scan is going to be faster in your test case. If you want to test this out, you to want use realistically sized tables. From pgsql-performance-owner@postgresql.org Tue May 31 00:23:20 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8A5CC5287E for ; Tue, 31 May 2005 00:21:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33144-04 for ; Tue, 31 May 2005 03:21:35 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id BF6455281E for ; Tue, 31 May 2005 00:21:25 -0300 (ADT) Received: (qmail 12007 invoked from network); 31 May 2005 03:21:23 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 31 May 2005 03:21:23 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id 7A71BE09C5; Tue, 31 May 2005 11:21:22 +0800 (CST) Date: Tue, 31 May 2005 11:21:20 +0800 From: Tobias Brox To: pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value Message-ID: <20050531032119.GH26100@tobias.exoweb.net> References: <20050531030207.GD26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050531030207.GD26100@tobias.exoweb.net> Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/456 X-Sequence-Number: 12620 [Tobias Brox - Tue at 11:02:07AM +0800] > test=# explain select * from mock where b is NULL; > QUERY PLAN > -------------------------------------------------------------------- > Seq Scan on mock (cost=100000000.00..100000020.00 rows=6 width=8) > Filter: (b IS NULL) > (2 rows) (...) > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match That tip helped me :-) test=# explain select * from mock where (b IS NULL)=true; QUERY PLAN ---------------------------------------------------------------------- Index Scan using b_is_null on mock (cost=0.00..4.68 rows=1 width=8) Index Cond: ((b IS NULL) = true) (2 rows) -- Tobias Brox, Beijing From pgsql-performance-owner@postgresql.org Tue May 31 00:34:00 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BEAFE52815 for ; Tue, 31 May 2005 00:32:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66284-01 for ; Tue, 31 May 2005 03:32:12 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id 664925281B for ; Tue, 31 May 2005 00:32:09 -0300 (ADT) Received: (qmail 12590 invoked from network); 31 May 2005 03:31:58 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 31 May 2005 03:31:58 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id 8E495E09C5; Tue, 31 May 2005 11:31:58 +0800 (CST) Date: Tue, 31 May 2005 11:31:58 +0800 From: Tobias Brox To: pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value Message-ID: <20050531033158.GI26100@tobias.exoweb.net> References: <20050531030207.GD26100@tobias.exoweb.net> <20050531031653.GA17723@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050531031653.GA17723@wolff.to> Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/457 X-Sequence-Number: 12621 [Tobias Brox] > test=# set enable_seqscan=off; [Bruno Wolff III - Mon at 10:16:53PM -0500] > It isn't surprising that an index wasn't used since a sequential scan is > going to be faster in your test case. > > If you want to test this out, you to want use realistically sized tables. Wrong. In this case I was not wondering about the planners choise of not using the index, but the fact that the planner could not find the index at all. Reproducing it on a simple table in a test environment was a valid strategy to solve this specific problem. -- Tobias Brox, Beijing From pgsql-performance-owner@postgresql.org Tue May 31 00:45:16 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0BBCD52869 for ; Tue, 31 May 2005 00:37:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39963-07 for ; Tue, 31 May 2005 03:37:41 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id C08555294F for ; Tue, 31 May 2005 00:37:36 -0300 (ADT) Received: (qmail 20260 invoked by uid 500); 31 May 2005 03:36:33 -0000 Date: Mon, 30 May 2005 22:36:33 -0500 From: Bruno Wolff III To: Tobias Brox Cc: pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value Message-ID: <20050531033633.GA20015@wolff.to> Mail-Followup-To: Bruno Wolff III , Tobias Brox , pgsql-performance@postgresql.org References: <20050531030207.GD26100@tobias.exoweb.net> <20050531032119.GH26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050531032119.GH26100@tobias.exoweb.net> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/458 X-Sequence-Number: 12622 On Tue, May 31, 2005 at 11:21:20 +0800, Tobias Brox wrote: > [Tobias Brox - Tue at 11:02:07AM +0800] > > test=# explain select * from mock where b is NULL; > > QUERY PLAN > > -------------------------------------------------------------------- > > Seq Scan on mock (cost=100000000.00..100000020.00 rows=6 width=8) > > Filter: (b IS NULL) > > (2 rows) > > (...) > > > ---------------------------(end of broadcast)--------------------------- > > TIP 9: the planner will ignore your desire to choose an index scan if your > > joining column's datatypes do not match > > That tip helped me :-) > > test=# explain select * from mock where (b IS NULL)=true; > QUERY PLAN > > ---------------------------------------------------------------------- > Index Scan using b_is_null on mock (cost=0.00..4.68 rows=1 width=8) > Index Cond: ((b IS NULL) = true) > (2 rows) Looked back at your first example and saw that you didn't use a partial index which is why you had to contort things to make it possible to use an indexed search. (Though the planner really should have done this since all of the rows should be in one disk block and doing an index scan should require doing more disk reads than a sequential scan for the test case you used.) You want something like this: CREATE INDEX b_is_null ON mock(b) WHERE b IS NULL; The advantage is that the index can be a lot smaller than an index over all of the rows in the case where only a small fraction of rows have a null value for b. (If this isn't the case you probably don't want the index.) From pgsql-performance-owner@postgresql.org Tue May 31 00:47:38 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 164B752832 for ; Tue, 31 May 2005 00:45:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90395-06 for ; Tue, 31 May 2005 03:45:36 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id 94E5E5281C for ; Tue, 31 May 2005 00:45:32 -0300 (ADT) Received: (qmail 13453 invoked from network); 31 May 2005 03:45:29 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 31 May 2005 03:45:29 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id CCBC0E09C5; Tue, 31 May 2005 11:45:29 +0800 (CST) Date: Tue, 31 May 2005 11:45:29 +0800 From: Tobias Brox To: Bruno Wolff III , Tobias Brox , pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value Message-ID: <20050531034529.GJ26100@tobias.exoweb.net> References: <20050531030207.GD26100@tobias.exoweb.net> <20050531032119.GH26100@tobias.exoweb.net> <20050531033633.GA20015@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050531033633.GA20015@wolff.to> Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/459 X-Sequence-Number: 12623 [Bruno Wolff III - Mon at 10:36:33PM -0500] > You want something like this: > CREATE INDEX b_is_null ON mock(b) WHERE b IS NULL; Oh, cool. I wasn't aware that this is possible. This would probably help us a lot of places. :-) -- Tobias Brox, Beijing From pgsql-performance-owner@postgresql.org Tue May 31 01:09:10 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C053E52849 for ; Tue, 31 May 2005 01:09:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10465-10 for ; Tue, 31 May 2005 04:09:04 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 212E252843 for ; Tue, 31 May 2005 01:09:03 -0300 (ADT) Received: (qmail 21478 invoked by uid 500); 31 May 2005 04:08:01 -0000 Date: Mon, 30 May 2005 23:08:01 -0500 From: Bruno Wolff III To: Tobias Brox Cc: pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value Message-ID: <20050531040801.GA21334@wolff.to> Mail-Followup-To: Bruno Wolff III , Tobias Brox , pgsql-performance@postgresql.org References: <20050531030207.GD26100@tobias.exoweb.net> <20050531031653.GA17723@wolff.to> <20050531033158.GI26100@tobias.exoweb.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050531033158.GI26100@tobias.exoweb.net> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/460 X-Sequence-Number: 12624 On Tue, May 31, 2005 at 11:31:58 +0800, Tobias Brox wrote: > [Tobias Brox] > > test=# set enable_seqscan=off; > > [Bruno Wolff III - Mon at 10:16:53PM -0500] > > It isn't surprising that an index wasn't used since a sequential scan is > > going to be faster in your test case. > > > > If you want to test this out, you to want use realistically sized tables. > > Wrong. In this case I was not wondering about the planners choise of not > using the index, but the fact that the planner could not find the index at > all. Reproducing it on a simple table in a test environment was a valid > strategy to solve this specific problem. I missed that you turned sequential scans off for your test. From pgsql-performance-owner@postgresql.org Tue May 31 01:18:52 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BCAA452869 for ; Tue, 31 May 2005 01:18:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32757-02 for ; Tue, 31 May 2005 04:18:47 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 59D085280A for ; Tue, 31 May 2005 01:18:46 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4V4IXG3007924; Tue, 31 May 2005 00:18:33 -0400 (EDT) To: Bruno Wolff III Cc: Tobias Brox , pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value In-reply-to: <20050531033633.GA20015@wolff.to> References: <20050531030207.GD26100@tobias.exoweb.net> <20050531032119.GH26100@tobias.exoweb.net> <20050531033633.GA20015@wolff.to> Comments: In-reply-to Bruno Wolff III message dated "Mon, 30 May 2005 22:36:33 -0500" Date: Tue, 31 May 2005 00:18:33 -0400 Message-ID: <7923.1117513113@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/461 X-Sequence-Number: 12625 Bruno Wolff III writes: > Looked back at your first example and saw that you didn't use a partial > index which is why you had to contort things to make it possible to > use an indexed search. FWIW, there is code in CVS tip that recognizes the connection between an index on a boolean expression and a WHERE clause testing that expression. It's not quite perfect --- using Tobias' example I see regression=# explain select * from mock where b is NULL; QUERY PLAN ------------------------------------------------------------------------ Index Scan using b_is_null on mock (cost=0.00..51.67 rows=10 width=8) Index Cond: ((b IS NULL) = true) Filter: (b IS NULL) (3 rows) so there's a useless filter condition still being generated. But it gets the job done as far as using the index, anyway. > You want something like this: > CREATE INDEX b_is_null ON mock(b) WHERE b IS NULL; I think best practice for something like this is to make the partial index's columns be something different from what the partial condition tests. Done as above, every actual index entry will be a null, so the entry contents are just dead weight. Instead do, say, CREATE INDEX b_is_null ON mock(a) WHERE b IS NULL; where a is chosen as a column that you frequently also test in conjunction with "b IS NULL". That is, the above index can efficiently handle queries like ... WHERE a = 42 AND b IS NULL ... regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 31 01:21:44 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 70FA45281A for ; Tue, 31 May 2005 01:21:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43602-02 for ; Tue, 31 May 2005 04:21:39 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 2569E5280A for ; Tue, 31 May 2005 01:21:38 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DcyFp-0000u1-00; Tue, 31 May 2005 00:21:25 -0400 To: Tobias Brox Cc: Bruno Wolff III , pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value References: <20050531030207.GD26100@tobias.exoweb.net> <20050531032119.GH26100@tobias.exoweb.net> <20050531033633.GA20015@wolff.to> <20050531034529.GJ26100@tobias.exoweb.net> In-Reply-To: <20050531034529.GJ26100@tobias.exoweb.net> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 31 May 2005 00:21:25 -0400 Message-ID: <87mzqcvxdm.fsf@stark.xeocode.com> Lines: 33 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/462 X-Sequence-Number: 12626 Tobias Brox writes: > [Bruno Wolff III - Mon at 10:36:33PM -0500] > > You want something like this: > > CREATE INDEX b_is_null ON mock(b) WHERE b IS NULL; > > Oh, cool. I wasn't aware that this is possible. This would probably help > us a lot of places. :-) Yeah it's a cool feature. I'm not 100% sure but I think it still won't consider this index unless the column being indexed is used in some indexable operation. So for example if you had CREATE INDEX b_null on mock(other) WHERE b IS NULL; and something like SELECT * FROM b WHERE b IS NULL ORDER BY other or SELECT * FROM b where other > 0 AND b IS NULL then it would be a candidate because the ORDER BY or the other > 0 make the index look relevant. But I don't think (again I'm not 100% sure) that the partial index WHERE clause is considered in picking which indexes to consider. It *is* considered in evaluating which index is the best one to use and whether it's better than a sequential scan. Just not in the initial choice of which indexes to look at at all. -- greg From pgsql-performance-owner@postgresql.org Tue May 31 02:13:11 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BA8AA5280A for ; Tue, 31 May 2005 02:13:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01084-06 for ; Tue, 31 May 2005 05:13:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3643952855 for ; Tue, 31 May 2005 02:13:06 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4V5Ck9x008325; Tue, 31 May 2005 01:12:46 -0400 (EDT) To: Greg Stark Cc: Tobias Brox , Bruno Wolff III , pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value In-reply-to: <87mzqcvxdm.fsf@stark.xeocode.com> References: <20050531030207.GD26100@tobias.exoweb.net> <20050531032119.GH26100@tobias.exoweb.net> <20050531033633.GA20015@wolff.to> <20050531034529.GJ26100@tobias.exoweb.net> <87mzqcvxdm.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "31 May 2005 00:21:25 -0400" Date: Tue, 31 May 2005 01:12:46 -0400 Message-ID: <8324.1117516366@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/463 X-Sequence-Number: 12627 Greg Stark writes: > then it would be a candidate because the ORDER BY or the other > 0 make the > index look relevant. But I don't think (again I'm not 100% sure) that the > partial index WHERE clause is considered in picking which indexes to consider. Nope, the partial index will be considered simply on the strength of its predicate matching the WHERE clause. Of course, if you can get some additional mileage by having the index contents be useful, that's great --- but it's not necessary. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 31 02:59:46 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EBCBC52800 for ; Tue, 31 May 2005 02:59:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97998-09 for ; Tue, 31 May 2005 05:59:40 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id 3CB1852843 for ; Tue, 31 May 2005 02:59:33 -0300 (ADT) Received: (qmail 19218 invoked from network); 31 May 2005 05:59:32 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 31 May 2005 05:59:32 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id 25816E09C7; Tue, 31 May 2005 13:59:32 +0800 (CST) Date: Tue, 31 May 2005 13:59:32 +0800 From: Tobias Brox To: Tom Lane Cc: Bruno Wolff III , Tobias Brox , pgsql-performance@postgresql.org Subject: Re: Index on a NULL-value Message-ID: <20050531055932.GL26100@tobias.exoweb.net> References: <20050531030207.GD26100@tobias.exoweb.net> <20050531032119.GH26100@tobias.exoweb.net> <20050531033633.GA20015@wolff.to> <7923.1117513113@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7923.1117513113@sss.pgh.pa.us> Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/464 X-Sequence-Number: 12628 > CREATE INDEX b_is_null ON mock(a) WHERE b IS NULL; > > where a is chosen as a column that you frequently also test in > conjunction with "b IS NULL". That is, the above index can efficiently > handle queries like > > ... WHERE a = 42 AND b IS NULL ... This is wonderful, it seems like most of our problems (probably also regarding the "index on timestamp"-thread I started separately) can be solved with partial indexing on expressions. No need to hide under bedclothes anymore ;-) -- Tobias Brox, Beijing From pgsql-performance-owner@postgresql.org Tue May 31 06:37:59 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3EB6E5282A for ; Tue, 31 May 2005 06:37:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82527-10 for ; Tue, 31 May 2005 09:37:53 +0000 (GMT) Received: from mail.sto.netlight.se (1-1-10-39a.sh.sth.bostream.se [82.182.50.216]) by svr1.postgresql.org (Postfix) with ESMTP id 811D75287E for ; Tue, 31 May 2005 06:37:51 -0300 (ADT) Received: from prraxp ([192.168.12.53]) by mail.sto.netlight.se (8.11.2/8.11.2) with ESMTP id j4VARD328550 for ; Tue, 31 May 2005 12:27:13 +0200 From: "Praveen Raja" To: Subject: very large table Date: Tue, 31 May 2005 11:37:48 +0200 Message-ID: <022801c565c4$6b1ac8c0$541510ac@sek.se> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0229_01C565D5.2EA398C0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4024 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.078 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/465 X-Sequence-Number: 12629 This is a multi-part message in MIME format. ------=_NextPart_000_0229_01C565D5.2EA398C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi I'm trying to move an existing solution from MySQL to PostgreSQL. As it is now the solution has 4 tables where data in inserted by an application. At regular intervals (10min) data from these tables is consolidated and moved to another table for reporting purposes. There exist many instances of these reporting tables and in total they are expected to hold about 500 million rows. There are about 200 of these reporting tables at the moment with data split among them. When a request comes in all these tables are searched. While moving to PostgreSQL is it a good idea to move from using multiple tables to one table for so many rows? ------=_NextPart_000_0229_01C565D5.2EA398C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi

 

I’m trying to move an existing solution = from MySQL to PostgreSQL. As it is now the solution has 4 tables where data in = inserted by an application. At regular intervals (10min) data from these tables is consolidated and moved to another table for reporting purposes. There = exist many instances of these reporting tables and in total they are expected = to hold about 500 million rows. There are about 200 of these reporting tables at = the moment with data split among them. When a request comes in all these = tables are searched. While moving to PostgreSQL is it a good idea to move from = using multiple tables to one table for so many rows?

------=_NextPart_000_0229_01C565D5.2EA398C0-- From pgsql-performance-owner@postgresql.org Tue May 31 10:16:47 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 857D0528AE for ; Tue, 31 May 2005 10:16:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78512-08 for ; Tue, 31 May 2005 13:16:37 +0000 (GMT) Received: from mail2.aeccom.com (port-212-202-101-158.static.qsc.de [212.202.101.158]) by svr1.postgresql.org (Postfix) with ESMTP id D5D4B5283A for ; Tue, 31 May 2005 10:16:34 -0300 (ADT) Received: from [192.168.2.12] (port-83-236-156-26.static.qsc.de [83.236.156.26]) by mail2.aeccom.com (Postfix) with ESMTP id 6DCFE378 for ; Tue, 31 May 2005 15:16:37 +0200 (CEST) Message-ID: <429C63B5.4060403@aeccom.com> Date: Tue, 31 May 2005 15:16:37 +0200 From: =?ISO-8859-1?Q?Dirk_Lutzeb=E4ck?= Organization: AEC/communications GmbH User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: SURVEY: who is running postgresql on 8 or more CPUs? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/466 X-Sequence-Number: 12630 Hi, I would like to start a little survey who is running postgresql on an 8way or more machine (Intel, Sparc, AMD no matter). Purpose: find out how postgresql runs in high performance areas. Please fillout: Machine (Vendor, Product): Architecture (Intel/Sparc/AMD/IBM): Processors (Type/Number/GHz): RAM: Operating System: PostgreSQL Version: Database size (GB): Disk system: Type of application: Your email contact: Willing to answer questions in this group: Comments: Please answer here or to me. I compile the results and feed them back here. Regards, Dirk From pgsql-performance-owner@postgresql.org Tue May 31 10:17:41 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9CF4F528C5 for ; Tue, 31 May 2005 10:17:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43090-08 for ; Tue, 31 May 2005 13:17:29 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) by svr1.postgresql.org (Postfix) with ESMTP id 8934D52914 for ; Tue, 31 May 2005 10:17:28 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so3452998wra for ; Tue, 31 May 2005 06:17:32 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=CPlc91dCVEaem9BDyf6VNfeccp9rlex2n+4MgS+C0AUyR111d48mPDKiiQ1ZorSB5UiGLQkD6xeyWRBPIJV2xXxMpmNfZZqrKr0dCl1/gySGAoeVYbsxMk5VnIgHiqMei6r8sOJnt7UVhzaOLKDLcMX2OEIuRpWgDZ0eb2ZZ+H0= Received: by 10.54.34.77 with SMTP id h77mr6574862wrh; Tue, 31 May 2005 06:17:32 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Tue, 31 May 2005 06:17:31 -0700 (PDT) Message-ID: <4a0cafe20505310617d803a0c@mail.gmail.com> Date: Tue, 31 May 2005 08:17:31 -0500 From: Josh Close Reply-To: Josh Close To: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-Reply-To: <429B90D1.9030402@wildcash.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <758d5e7f05052614232f6c9164@mail.gmail.com> <4a0cafe205052706043ef8f53f@mail.gmail.com> <4a0cafe205052706042d4e60e5@mail.gmail.com> <14584.1117204158@sss.pgh.pa.us> <429B90D1.9030402@wildcash.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/467 X-Sequence-Number: 12631 I didn't see iostat as available to install, but I'm using dstat to see thi= s. The server has constant disk reads averaging around 50M and quite a few in the 60M range. This is when selects are being done, which is almost always. I would think if postgres is grabbing everything from memory that this wouldn't happen. This is why I think there must be some way to allocate more mem to postgres. There is 2 gigs of mem in this server. Here are my current settings. max_connections =3D 100 shared_buffers =3D 50000 sort_mem =3D 4096 vacuum_mem =3D 32768 effective_cache_size =3D 450000 Shared buffers is set to 10% of total mem. Effective cache size is 90% of m= em. Is there anything that can be done to have postgres grab more from memory rather than disk? On 5/30/05, Rudi Starcevic wrote: > Hi, >=20 > I had some disk io issues recently with NFS, I found the command 'iostat > -x 5' to be a great help when using Linux. >=20 > For example here is the output when I do a 10GB file transfer onto hdc > Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s > avgrq-sz avgqu-sz await svctm %util > hdc 0.00 875.95 0.00 29.66 0.00 7244.89 0.00 3622.44 > 244.27 3.07 103.52 1.78 5.27 >=20 > The last field show the disk is 5.27% busy. >=20 > I have seen this value at 100%, adding more server brought it under 100%. > It seems that if you hit 100% problems sort of cascade all over that > place. For example Apache connections went right up and hit their max. >=20 > I am not sure how accurate the % is but it has work pretty well for me. >=20 > Perhaps use this command in another window with you run your SQL and see > what it shows. >=20 > HTH. > Kind regards, > Rudi. >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings >=20 --=20 -Josh From pgsql-performance-owner@postgresql.org Tue May 31 11:06:22 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 929E2528C5 for ; Tue, 31 May 2005 11:06:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61283-07 for ; Tue, 31 May 2005 14:06:13 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 54694528BB for ; Tue, 31 May 2005 11:06:12 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4VE6F6r011708; Tue, 31 May 2005 10:06:16 -0400 (EDT) To: "Praveen Raja" Cc: pgsql-performance@postgresql.org Subject: Re: very large table In-reply-to: <022801c565c4$6b1ac8c0$541510ac@sek.se> References: <022801c565c4$6b1ac8c0$541510ac@sek.se> Comments: In-reply-to "Praveen Raja" message dated "Tue, 31 May 2005 11:37:48 +0200" Date: Tue, 31 May 2005 10:06:15 -0400 Message-ID: <11707.1117548375@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/468 X-Sequence-Number: 12632 "Praveen Raja" writes: > I'm trying to move an existing solution from MySQL to PostgreSQL. As it > is now the solution has 4 tables where data in inserted by an > application. At regular intervals (10min) data from these tables is > consolidated and moved to another table for reporting purposes. There > exist many instances of these reporting tables and in total they are > expected to hold about 500 million rows. There are about 200 of these > reporting tables at the moment with data split among them. When a > request comes in all these tables are searched. While moving to > PostgreSQL is it a good idea to move from using multiple tables to one > table for so many rows? If the multiple tables represent a partitioning scheme that makes sense to your application (ie, you can tell a priori which tables to look in for a given query) then it's probably worth keeping. But it sounds like they don't make that much sense, since you mention searching all the tables. In that case you should think about consolidating. There is lots of stuff in the recent list archives about partitioned tables; might be worth reading, even though much of it is talking about features we don't yet have. It would point out the issues you need to think about --- for example, do you periodically discard some of the data, and if so do the tables correspond to the discard units? DROP TABLE is a lot quicker than trying to DELETE and then VACUUM a portion of a very large table. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 31 11:33:34 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 56D455288E for ; Tue, 31 May 2005 11:33:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45180-09 for ; Tue, 31 May 2005 14:33:32 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id C0DE552891 for ; Tue, 31 May 2005 11:33:31 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4VEXXeT011909; Tue, 31 May 2005 10:33:33 -0400 (EDT) To: Josh Close Cc: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-reply-to: <4a0cafe20505310617d803a0c@mail.gmail.com> References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <758d5e7f05052614232f6c9164@mail.gmail.com> <4a0cafe205052706043ef8f53f@mail.gmail.com> <4a0cafe205052706042d4e60e5@mail.gmail.com> <14584.1117204158@sss.pgh.pa.us> <429B90D1.9030402@wildcash.com> <4a0cafe20505310617d803a0c@mail.gmail.com> Comments: In-reply-to Josh Close message dated "Tue, 31 May 2005 08:17:31 -0500" Date: Tue, 31 May 2005 10:33:33 -0400 Message-ID: <11908.1117550013@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/469 X-Sequence-Number: 12633 Josh Close writes: > There is 2 gigs of mem in this server. Here are my current settings. > max_connections = 100 > shared_buffers = 50000 > sort_mem = 4096 > vacuum_mem = 32768 > effective_cache_size = 450000 > Shared buffers is set to 10% of total mem. Effective cache size is 90% of mem. Uh, shared_buffers and effective_cache_size are both measured in pages, which are 8K apiece unless you built with a nondefault BLCKSZ. So the above calculations are off ... > Is there anything that can be done to have postgres grab more from > memory rather than disk? It's not so much a matter of what Postgres will do as what the kernel will do. Check to see if there is some limit on how much memory the kernel will set aside for disk buffers. Plain old "top" will generally tell you what is going on, though interpreting its output sometimes requires some wizardry. regards, tom lane From pgsql-performance-owner@postgresql.org Tue May 31 13:37:05 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BD4745288E for ; Tue, 31 May 2005 13:37:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09962-02 for ; Tue, 31 May 2005 16:36:53 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) by svr1.postgresql.org (Postfix) with ESMTP id 2A30C52876 for ; Tue, 31 May 2005 13:36:50 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so3591697wra for ; Tue, 31 May 2005 09:36:50 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=myhouN9DaVsTNJo6rjCavuwJLzdYfC+PCJUO/yIi2/YWvIRL+VwfS9DoxPTzTGp6CkBrbAxDSlS0QbHOT1oxS9rQaOzISliSVtvOdE11r0pDTdYqrHpg7AtkI+F2DU+9v7xs9tJj/p4hT9y5Y0NIV72wiXI0x7QrFGEoOOhItLI= Received: by 10.54.54.56 with SMTP id c56mr6766042wra; Tue, 31 May 2005 09:36:50 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Tue, 31 May 2005 09:36:49 -0700 (PDT) Message-ID: <4a0cafe2050531093631c725e3@mail.gmail.com> Date: Tue, 31 May 2005 11:36:49 -0500 From: Josh Close Reply-To: Josh Close To: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-Reply-To: <1117551659.7612.85.camel@fandelm.ecommit.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe20505310617d803a0c@mail.gmail.com> <1117551659.7612.85.camel@fandelm.ecommit.de> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/470 X-Sequence-Number: 12634 On 5/31/05, Martin Fandel wrote: > In the documentation of > http://www.powerpostgresql.com/Downloads/annotated_conf_80.html > is the shared_buffers set to 1/3 of the availble RAM. You're set > 50000*8/1024=3D391 MB SHMEM. The effective_cache_size in your > configuration is 450000*8/1024=3D3516 MB SHMEM. That's 3907MB > of RAM but you have less than 2048MB availble. I wrote that wrong, there is actually 4 gigs of ram available. >=20 > What value do you have in /proc/sys/kernel/shmmax? >=20 > I'm really new at using postgres and i have not many experience > but maybe you can try to use 1/3 (682MB/87424)for shared_buffers > and 2/3 (1365MB/174720) for the effective_cache_size? But i these > settings are to high too. >=20 > best regards > Martin From pgsql-performance-owner@postgresql.org Tue May 31 14:02:08 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ADF6652867 for ; Tue, 31 May 2005 14:02:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39372-08 for ; Tue, 31 May 2005 17:02:01 +0000 (GMT) Received: from superman.pns.networktel.net (superman.pns.networktel.net [216.83.236.232]) by svr1.postgresql.org (Postfix) with ESMTP id 78D5952942 for ; Tue, 31 May 2005 14:01:58 -0300 (ADT) Received: from zod.pns.networktel.net (lora.pns.networktel.net [216.83.236.238]) by superman.pns.networktel.net (8.12.9/8.12.6) with ESMTP id j4VH1vvQ061492 for ; Tue, 31 May 2005 17:01:57 GMT (envelope-from justin.davis@rapidsys.net) Received: from JustinIBM (216-107-99-186.wan.networktel.net [216.107.99.186]) by zod.pns.networktel.net (8.13.3/8.12.11) with ESMTP id j4VH1oFl055853 for ; Tue, 31 May 2005 17:01:59 GMT (envelope-from justin.davis@rapidsys.net) Message-Id: <200505311701.j4VH1oFl055853@zod.pns.networktel.net> From: "Justin Davis" To: Subject: 'Fastest' PC's are slowest in the house Date: Tue, 31 May 2005 13:02:12 -0400 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0016_01C565E0.FE448430" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Thread-Index: AcVmAnyDZNUgntrVQ0SrEEew7B06DQ== X-Virus-Scanned: ClamAV version 0.85.1, clamav-milter version 0.85 on zod.pns.networktel.net X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.452 tagged_above=0 required=5 tests=HTML_50_60, HTML_MESSAGE, HTML_TEXT_AFTER_BODY, HTML_TEXT_AFTER_HTML X-Spam-Level: X-Archive-Number: 200505/471 X-Sequence-Number: 12635 This is a multi-part message in MIME format. ------=_NextPart_000_0016_01C565E0.FE448430 Content-Type: text/plain; charset="windows-1250" Content-Transfer-Encoding: 7bit I have five PC's accessing a PG database that is mounted on a Dell Windows 2003 server. The PC's are accessing the database with a Fujitsu cobol program via ODBC (all machines have same (newest) ODBC driver from PG). 2 of the machines are the newest I have and both pretty identically configured but are very slow by comparison to the others. My colleagues and I are still in the exploration / decision process, we have been working with and learning the database about 2 months. I'm looking to see if anyone knows of O/S or hardware issues right off the bat or can recommend a debug method, log checking, etc. path we might follow. The program in question reads the PG database and displays matching query results on a cobol screen, for the point of this topic that is all it is doing. We run the same query from each PC which returns 15 records out of a 6,000 record customer DB. The machines: - 2 are 2.0 Ghz Dells with 512 Ram & XP SP2 - they take just over 2 minutes - 1 AMD 2.4 with 256 Ram & XP SP2 - just under 2 secs. - 1 AMD 900 Mhz with 256 Ram & XP SP 1 - just under 2 secs - 1 Intel 266 Mhz with 256 Ram & Windows 2000 - 11-13 secs Thanks, Justin Davis Rapid Systems, Inc. 800.356.8952 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.322 / Virus Database: 267.3.0 - Release Date: 5/30/2005 ------=_NextPart_000_0016_01C565E0.FE448430 Content-Type: text/html; charset="windows-1250" Content-Transfer-Encoding: quoted-printable
I have = five PC's=20 accessing a PG database that is mounted on a Dell Windows 2003 = server.  The PC's are accessing the database with a Fujitsu cobol = program=20 via ODBC (all machines have same (newest) ODBC driver from=20 PG).  2 of the machines are the newest I have and both = pretty=20 identically configured but are very slow by comparison to the = others.  My=20 colleagues and I are still in the exploration / decision process, we = have been=20 working with and learning the database about 2 = months.
 
I'm = looking to see=20 if anyone knows of O/S or hardware issues right off the bat or can = recommend a=20 debug method, log checking, etc. path we might = follow.
 
The = program in=20 question reads the PG database and displays matching query results on a = cobol=20 screen, for the point of this topic that is all it is doing.  We = run the=20 same query from each PC which returns 15 records out of a 6,000 record = customer=20 DB.
 
The=20 machines:
 
- 2 = are 2.0 Ghz=20 Dells with 512 Ram & XP SP2 - they take just over 2=20 minutes
- 1 = AMD 2.4 with 256=20 Ram & XP SP2 - just under 2 secs.
- 1 = AMD 900 Mhz with=20 256 Ram & XP SP 1 - just under 2 secs
- 1 = Intel 266 Mhz=20 with 256 Ram & Windows 2000 - 11-13 secs
 
 
Thanks,
 
Justin Davis
Rapid Systems, = Inc.
800.356.8952
 

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.3.0 - Release Date: 5/30/2005

------=_NextPart_000_0016_01C565E0.FE448430-- From pgsql-www-owner@postgresql.org Tue May 31 14:57:03 2005 X-Original-To: pgsql-www-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 45AD652B21; Tue, 31 May 2005 14:52:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35510-06; Tue, 31 May 2005 17:52:26 +0000 (GMT) Received: from hub.org (hub.org [200.46.204.220]) by svr1.postgresql.org (Postfix) with ESMTP id D76C752B9E; Tue, 31 May 2005 14:46:37 -0300 (ADT) Received: from localhost (unknown [200.46.204.144]) by hub.org (Postfix) with ESMTP id 159D764BA1B; Tue, 31 May 2005 14:46:39 -0300 (ADT) Received: from hub.org ([200.46.204.220]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26461-10; Tue, 31 May 2005 17:45:55 +0000 (GMT) Received: from ganymede.hub.org (blk-224-176-51.eastlink.ca [24.224.176.51]) by hub.org (Postfix) with ESMTP id 1A7FF64B941; Tue, 31 May 2005 14:45:56 -0300 (ADT) Received: by ganymede.hub.org (Postfix, from userid 1000) id 3ED233F026; Tue, 31 May 2005 14:45:56 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 3A0003F025; Tue, 31 May 2005 14:45:56 -0300 (ADT) Date: Tue, 31 May 2005 14:45:56 -0300 (ADT) From: "Marc G. Fournier" X-X-Sender: scrappy@ganymede.hub.org To: pgsql-announce@postgresql.org Cc: pgsql-general@postgresql.org, pgsql-hackers@postgresql.org, pgsql-novice@postgresql.org, pgsql-www@postgresql.org, pgsql-docs@postgresql.org, pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org, pgsql-ports@postgresql.org, pgsql-sql@postgresql.org, pgsql-admin@postgresql.org Subject: Major flood of mail to lists ... Message-ID: <20050531144342.D933@ganymede.hub.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.001 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, SUSPICIOUS_RECIPS X-Spam-Level: * X-Archive-Number: 200505/116 X-Sequence-Number: 8137 Do to moderator error (namely, mine), several hundred messages (spread across all the lists) were just approved ... Sorry for all the incoming junk :( ---- Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664 From pgsql-performance-owner@postgresql.org Tue May 31 15:49:39 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ABAFC54063 for ; Tue, 31 May 2005 15:49:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81759-01 for ; Tue, 31 May 2005 18:49:25 +0000 (GMT) Received: from email.aon.at (WARSL404PIP1.highway.telekom.at [195.3.96.112]) by svr1.postgresql.org (Postfix) with ESMTP id 871D552F3E for ; Tue, 31 May 2005 15:15:14 -0300 (ADT) Received: (qmail 31069 invoked from network); 31 May 2005 18:15:07 -0000 Received: from m162p014.dipool.highway.telekom.at (HELO PASCAL) ([62.46.10.46]) (envelope-sender ) by smarthub72.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 31 May 2005 18:15:07 -0000 From: Manfred Koizar To: Josh Close Cc: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io Date: Tue, 31 May 2005 20:18:13 +0200 Message-ID: References: <4a0cafe20505310617d803a0c@mail.gmail.com> <1117551659.7612.85.camel@fandelm.ecommit.de> <4a0cafe2050531093631c725e3@mail.gmail.com> In-Reply-To: <4a0cafe2050531093631c725e3@mail.gmail.com> X-Mailer: Forte Agent 2.0/32.652 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.407 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/473 X-Sequence-Number: 12637 >On 5/31/05, Martin Fandel wrote: >> In the documentation of >> http://www.powerpostgresql.com/Downloads/annotated_conf_80.html >> is the shared_buffers set to 1/3 of the availble RAM. Well, it says "you should never use more than 1/3 of your available RAM" which is not quite the same as "it is set to 1/3." I'd even say, never set it higher than 1/10 of your available RAM, unless you know what you're doing and why you're doing it. Servus Manfred From pgsql-performance-owner@postgresql.org Tue May 31 16:40:56 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4857E52A09 for ; Tue, 31 May 2005 16:40:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35128-08 for ; Tue, 31 May 2005 19:40:40 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 7D59B53F57 for ; Tue, 31 May 2005 15:46:38 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4VIkZ73013958; (envelope-from ) Tue, 31 May 2005 13:46:35 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4VIkXlF006656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 31 May 2005 13:46:34 -0500 (CDT) Message-ID: <429CB109.5080908@arbash-meinel.com> Date: Tue, 31 May 2005 13:46:33 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Martin Fandel Cc: pgsql-performance@postgresql.org Subject: Re: postgresql-8.0.1 performance tuning References: <1117201312.7060.6.camel@fandelm.ecommit.de> In-Reply-To: <1117201312.7060.6.camel@fandelm.ecommit.de> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig4D765F634D1FADE6C5F7A1D4" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.24 tagged_above=0 required=5 tests=AWL, INFO_TLD X-Spam-Level: X-Archive-Number: 200505/474 X-Sequence-Number: 12638 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig4D765F634D1FADE6C5F7A1D4 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Martin Fandel wrote: > Hi @ all, > > i'm trying to tune my postgresql-db but i don't know if the values are > right > set. > > I use the following environment for the postgres-db: > > ######### Hardware ############ > cpu: 2x P4 3Ghz > ram: 1024MB DDR 266Mhz > > partitions: > /dev/sda3 23G 9,6G 13G 44% / > /dev/sda1 11G 156M 9,9G 2% /var > /dev/sdb1 69G 13G 57G 19% /var/lib/pgsql > > /dev/sda is in raid 1 (2x 35GB / 10000upm / sca) > /dev/sdb is in raid 10 (4x 35GB / 10000upm / sca) > ######### /Hardware ############ You probably want to put the pg_xlog file onto /dev/sda rather than having it in /dev/sdb. Having it separate from the data usually boosts performance a lot. I believe you can just mv it to a different directory, and then recreate it as a symlink. (Stop the database first :) > > ######### Config ############ > /etc/sysctl.conf: > kernel.shmall = 786432000 > kernel.shmmax = 786432000 > Not really sure about these two. > /etc/fstab: > /dev/sdb1 /var/lib/pgsql reiserfs > acl,user_xattr,noatime,data=writeback 1 2 > Seems decent. > /var/lib/pgsql/data/postgresql.conf > superuser_reserved_connections = 2 > shared_buffers = 3000 > work_mem = 131072 > maintenance_work_mem = 131072 These both seem pretty large. But it depends on how many concurrent connections doing sorting/hashing/etc you expect. If you are only expecting 1 connection, these are probably fine. Otherwise with 1GB of RAM I would probably make work_mem more like 4096/8192. Remember, running out of work_mem means postgres will spill to disk, slowing that query. Running out of RAM causes the system to swap, making everything slow. > max_stack_depth = 2048 > max_fsm_pages = 20000 > max_fsm_relations = 1000 > max_files_per_process = 1000 > vacuum_cost_delay = 10 > vacuum_cost_page_hit = 1 > vacuum_cost_page_miss = 10 > vacuum_cost_page_dirty = 20 > vacuum_cost_limit = 200 > bgwriter_delay = 200 > bgwriter_percent = 1 > bgwriter_maxpages = 100 > fsync = true > wal_sync_method = fsync > wal_buffers = 64 > commit_delay = 0 > commit_siblings = 5 > checkpoint_segments = 256 > checkpoint_timeout = 900 > checkpoint_warning = 30 > effective_cache_size = 10000 > random_page_cost = 4 > cpu_tuple_cost = 0.01 > cpu_index_tuple_cost = 0.001 > cpu_operator_cost = 0.0025 > geqo = true > geqo_threshold = 12 > geqo_effort = 5 > geqo_pool_size = 0 > geqo_generations = 0 > geqo_selection_bias = 2.0 > deadlock_timeout = 1000 > max_locks_per_transaction = 64 > ######### /Config ############ > > ######### Transactions ############ > we have about 115-300 transactions/min in about 65 tables. > ######### /Transactions ############ > > I'm really new at using postgres. So i need some experience to set this > parameters in the postgresql- and the system-config. I can't find standard > calculations for this. :/ The postgresql-documentation doesn't help me to > set the best values for this. > > The database must be high-availble. I configured rsync to sync the > complete > /var/lib/pgsql-directory to my hot-standby. On the hotstandby i will > make the > dumps of the database to improve the performance of the master-db. > I didn't think an rsync was completely valid. Probably you should look more into Slony. http://slony.info It is a single-master asynchronous replication system. I believe it is pretty easy to setup, and does what you really want. > In my tests the synchronization works fine. I synchronised the hole > directory > and restarted the database of the hotstandby. While restarting, > postgresql turned > back the old (not archived) wals and the database of my hotstandby was > consistent. Is this solution recommended? Or must i use archived wal's > with > real system-snapshots? > > best regards, > > Martin Fandel John =:-> --------------enig4D765F634D1FADE6C5F7A1D4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCnLELJdeBCYSNAAMRAh4eAJ0TJTxzs7nMs57ibp8BgIS8PS8u0gCfUxBx SPCvFGnKvPTyMV9DzfbJAyw= =+1i+ -----END PGP SIGNATURE----- --------------enig4D765F634D1FADE6C5F7A1D4--