diff --git "a/pgsql-performance.200406" "b/pgsql-performance.200406" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200406" @@ -0,0 +1,31892 @@ +From pgsql-general-owner@postgresql.org Tue Jun 1 18:04:04 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4FBB7D1B21B; Tue, 1 Jun 2004 18:04:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97033-04; Tue, 1 Jun 2004 18:03:47 -0300 (ADT) +Received: from mailbox.maricopa.gov (mailbox.maricopa.gov [156.42.4.109]) + by svr1.postgresql.org (Postfix) with ESMTP + id A4D12D1B181; Tue, 1 Jun 2004 18:03:41 -0300 (ADT) +Received: from maricopa_xcng2.maricopa.gov (maricopa_xcng2.maricopa.gov + [156.42.103.174] (may be forged)) + by mailbox.maricopa.gov (8.8.6 (PHNE_17190)/8.8.6) with ESMTP id + NAA09455; Tue, 1 Jun 2004 13:57:09 -0700 (MST) +Received: by maricopa_xcng2 with Internet Mail Service (5.5.2657.72) + id ; Tue, 1 Jun 2004 14:03:44 -0700 +Message-ID: <64EDC403A1417B4299488BAE87CA7CBF01CD0E4B@maricopa_xcng0> +From: Duane Lee - EGOVX +To: "PG General (E-mail)" , + "PSQL Performance (E-mail)" +Subject: Trigger & Function +Date: Tue, 1 Jun 2004 14:03:40 -0700 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C4481B.EA270880" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200406/63 +X-Sequence-Number: 61446 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C4481B.EA270880 +Content-Type: text/plain; + charset="iso-8859-1" + +I'm trying to create a trigger (AFTER INSERT, UPDATE, DELETE) as an audit +routine inserting into an audit table the "before" and "after" views of the +row being acted upon. My problem is I defined the "before" and "after" +fields in the audit table as TEXT and when I try to move NEW or OLD into +these fields I get the error "NEW used in query that is not in a rule". I +tried defining a variable as RECORD type but when I tried executing I would +get a "syntax error at or near..." the variable when it was referenced in +the code (new_fld := NEW for instance). + +I'm currently stumped. I don't want an audit table for each and every table +I want to audit. I want a single audit table to handle multiple tables. Do +any of you more astute users have any ideas to help me? Can you tell me +where I'm going wrong? Is my wish to have a single audit table for multiple +tables all folly? An explanation of the "rule" error shown above would help +as well. + +Any help will be appreciated. + +TIA, +Duane + +Here is the function definition: + +CREATE OR REPLACE FUNCTION func_aud_tst01() RETURNS trigger AS ' + DECLARE + action char(1); + b4 text; + aftr text; + BEGIN + IF TG_OP = ''INSERT'' THEN + action := ''I''; + b4 := ''''; + aftr := NEW; +-- b4 := ''Test b4 I''; +-- aftr := ''Test aftr I''; + ELSIF TG_OP = ''UPDATE'' THEN + action := ''U''; +-- b4 := OLD; +-- aftr := NEW; + b4 := ''Test b4 U''; + aftr := ''Test aftr U''; + ELSE + action := ''D''; +-- b4 := OLD; +-- aftr := ''''; + b4 := ''Test b4 D''; + aftr := ''Test aftr D''; + END IF; + insert into audtst(table_name, act_type, before_look, after_look) + values(TG_RELNAME, action, b4, aftr); + RETURN NEW; + END; +' LANGUAGE plpgsql; +-- + COMMIT WORK; + +------_=_NextPart_001_01C4481B.EA270880 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +Trigger & Function + + + +

I'm trying to create a trigger (AFTER INSERT, UPDATE, DEL= +ETE) as an audit routine inserting into an audit table the "before&quo= +t; and "after" views of the row being acted upon.  My proble= +m is I defined the "before" and "after" fields in the a= +udit table as TEXT and when I try to move NEW or OLD into these fields I ge= +t the error "NEW used in query that is not in a rule".  I tr= +ied defining a variable as RECORD type but when I tried executing I would g= +et a "syntax error at or near..." the variable when it was refere= +nced in the code (new_fld :=3D NEW for instance).

+ +

I'm currently stumped.  I don't want an audit table = +for each and every table I want to audit.  I want a single audit table= + to handle multiple tables.  Do any of you more astute users have any = +ideas to help me?  Can you tell me where I'm going wrong?  Is my = +wish to have a single audit table for multiple tables all folly?  An e= +xplanation of the "rule" error shown above would help as well.

+ +

Any help will be appreciated. +

+ +

TIA, +
Duane +

+ +

Here is the function definition: +

+ +

CREATE OR REPLACE FUNCTION func_aud_tst01() RETURNS trigg= +er AS ' +
  DECLARE +
    action char(1); +
    b4     text; +
    aftr   text; +
  BEGIN +
    IF TG_OP =3D ''INSERT'' THEN +
      action :=3D ''I''; +
      b4 :=3D ''''; +
      aftr :=3D NEW; +
--      b4 :=3D ''Test b4 I'';<= +/FONT> +
--      aftr :=3D ''Test aftr I= +''; +
    ELSIF TG_OP =3D ''UPDATE'' THEN +
      action :=3D ''U''; +
--      b4 :=3D OLD; +
--      aftr :=3D NEW; +
      b4 :=3D ''Test b4 U''; +
      aftr :=3D ''Test aftr U''= +; +
    ELSE +
      action :=3D ''D''; +
--      b4 :=3D OLD; +
--      aftr :=3D ''''; +
      b4 :=3D ''Test b4 D''; +
      aftr :=3D ''Test aftr D''= +; +
    END IF; +
    insert into audtst(table_name, act_ty= +pe, before_look, after_look) +
    values(TG_RELNAME, action, b4, aftr);= + +
    RETURN NEW; +
  END; +
' LANGUAGE plpgsql; +
-- +
  COMMIT WORK; +

+ + + +------_=_NextPart_001_01C4481B.EA270880-- + +From pgsql-general-owner@postgresql.org Tue Jun 1 19:04:47 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D3C50D1B1DC; Tue, 1 Jun 2004 19:04:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18762-08; Tue, 1 Jun 2004 19:04:23 -0300 (ADT) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP + id 011D9D1B18C; Tue, 1 Jun 2004 19:04:20 -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 i51M4KRF003457; + Tue, 1 Jun 2004 17:04:20 -0500 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id i51M4K8Y003455; + Tue, 1 Jun 2004 17:04:20 -0500 +From: Mike Nolan +Message-Id: <200406012204.i51M4K8Y003455@gw.tssi.com> +Subject: Re: [PERFORM] Trigger & Function +To: DLee@mail.maricopa.gov (Duane Lee - EGOVX) +Date: Tue, 1 Jun 2004 17:04:19 -0500 (CDT) +Cc: pgsql-general@postgresql.org ("PG General (E-mail)"), + pgsql-performance@postgresql.org ("PSQL Performance (E-mail)") +In-Reply-To: <64EDC403A1417B4299488BAE87CA7CBF01CD0E4B@maricopa_xcng0> from + "Duane Lee - EGOVX" at Jun 01, 2004 02:03:40 PM +X-Mailer: ELM [version 2.5 PL3] +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/65 +X-Sequence-Number: 61448 + +> My problem is I defined the "before" and "after" +> fields in the audit table as TEXT and when I try to move NEW or OLD into +> these fields I get the error "NEW used in query that is not in a rule". + +You're trying to insert record data into a text field, that doesn't work. +OLD and NEW can be used as either record identifiers (as in RETURN OLD) +or column qualifiers (as in OLD.colname), but you can't intermingle them. + +I don't think postgres (pl/pgsql) has row-to-variable and variable-to-row +functions like serialize and unserialize, that's probably what you'd need. +It would probably be necessary to write something like that in C, since +at this point pl/perl cannot be used for trigger functions. + +I've not tried using pl/php yet, the announcement for it says it can be +used for trigger functions. + +My first thought is that even if there was a serialize/unserialize +capabiity you might be able to write something using it that creates +the log entry but not anything that allows you to query the log for +specific column or row entries. + +It would probably require a MAJOR extension of SQL to add it to pg, +as there would need to be qualifiers that can be mapped to specific +tables and columns. Even if we had that, storing values coming from +multiple tables into a single audit table would present huge challenges. + +I've found only two ways to implement audit logs: + +1. Have separate log tables that match the structure of + the tables they are logging. + +2. Write a trigger function that converts columns to something you can + store in a common log table. (I've not found a way to do this without + inserting one row for each column being logged, though.) +-- +Mike Nolan + +From pgsql-performance-owner@postgresql.org Tue Jun 1 19:55:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E230CD1B1D0 + for ; + Tue, 1 Jun 2004 19:55:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40034-01 + for ; + Tue, 1 Jun 2004 19:55:42 -0300 (ADT) +Received: from fep10.012.net.il (fep10.012.net.il [212.117.129.245]) + by svr1.postgresql.org (Postfix) with ESMTP id B905DD1B1A9 + for ; + Tue, 1 Jun 2004 19:55:36 -0300 (ADT) +Received: from [127.0.0.1] ([80.178.80.135]) by fep10.012.net.il with ESMTP + id <20040601225528.GMVT24472.fep10@[80.178.80.135]>; + Wed, 2 Jun 2004 01:55:28 +0300 +Received: from [127.0.0.1] ([127.0.0.1]) + by [127.0.0.1] with ESMTP (SpamPal v1.50) + sender ; 02 Jun 2004 01:56:07 +0300 +Date: Wed, 2 Jun 2004 01:56:07 +0300 +From: Vitaly Belman +Reply-To: Vitaly Belman +X-Priority: 3 (Normal) +Message-ID: <16113857921.20040602015607@012.net.il> +To: pgsql-performance@postgresql.org, + Bryan Encina , + Matthew Nuzum +Subject: PostgreSQL on VMWare vs Windows vs CoLinux +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200406/3 +X-Sequence-Number: 7061 + +Hello pgsql-performance, + + I was using the native windows PostgreSQL 7.5Dev and was adviced by + several people to use an emulated PostgreSQL instead, as it is just + a beta. + + Well, I give it a whirl and tried both commercial VMWare and the + freeweare open-source CoLinux, both work under Windows and both + emulate Linux, that's a quick review of my experience with them, may + someone in need learn from it. + + This might be not the best place for such a post, but since the + subject was brought up here, I'll post it here as well. If someone + thinks it should be posted somewhere else, let me know. + + Installation & Configuration + ---------------------------- + + VMWare: + + On the bright side, the installation went quite smoothly, VMWare + configured all the network stuff by itself and I had no trouble + using the net right away. On the grim side, the installation itself + took ages, compared to the plug & play feel of CoLinux. + + Installing PostgreSQL on VMWare was quite straightforward, just as + the the PostgreSQL documention goes. + + CoLinux: + + As I said, with CoLinux the installation itself goes very quickly. + To get Linux running you need to download practically less than 20mb + which include the distribution (Debian in my case) and the CoLinux + setup. Configuring CoLinux took a bit longer than VMWare, yet, not + long as I thought it would take. In fact, it can be very easy if you + just follow the documention of CoLinux Wiki stuff, there are some + very easy to follow tutorials there. + + Installing PostgreSQL on CoLinux proved a little more difficult + (again, Debian), but I posted a quick tutorial that should smooth + the process: http://www.colinux.org/wiki/index.php/PostgreSQL. + + Performance + ----------- + + This was a totally subjective test (especially since one of the + participants is in a beta stage), yet, that's what I tested and that's + what I needed to know. + + To make the test as fair as possible, I did an exact dump of the + same database. I ran the SQLs (around 10) in the same order on all + of them and repeated the test several times. I also did an EXPLAIN + on the queries to make sure all the databases work on the query the + same way. It wasn't a full test though, I didn't test mass select + load, nor inserts, nor work under heavy load, nor I tried different + types of joins. All I did was to run some heavy (in execution time) + queries. So you should take these "tests" just for what they are. + + That's what I got: + + The native window port performed poorly lagging + 30%-50% behind the VMWare/CoLinux solutions in execution times, + rather sad, but not unexpected, I guess. + + CoLinux and VMWare give AROUND the same results, yet CoLinux did + give slightly better performance (I'd say 5%-10%) but with such + slight improvement and inconsistency I wouldn't count it as much. + + Conclusion + ---------- + + With all that said, VMWare is badly suited for running a database, + while CoLinux can be run as a service (didn't try it yet though), + VMWare always sits there, it is slow to go up, slow to go down and + generally feels like a system hog. + + I'll go on with CoLinux for now and hope it will act as good as it + looks. + + http://www.vmware.com/ + http://www.colinux.org/ + + Thanks to Bryan and Matthew for their advices regarding the emulations. + +Regards, + Vitaly Belman + + ICQ: 1912453 + AIM: VitalyB1984 + MSN: tmdagent@hotmail.com + Yahoo!: VitalyBe + + +From pgsql-performance-owner@postgresql.org Tue Jun 1 21:08:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D945AD1B256 + for ; + Tue, 1 Jun 2004 21:08:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65572-09 + for ; + Tue, 1 Jun 2004 21:08:39 -0300 (ADT) +Received: from outputservices.com (outputt1130.customer.frii.net + [216.17.159.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F286D1B1AC + for ; + Tue, 1 Jun 2004 21:08:34 -0300 (ADT) +Received: from outputservices.com (outputservices.com [137.106.76.15]) + by outputservices.com (8.11.3/8.11.3) with ESMTP id i5208Yb21346; + Tue, 1 Jun 2004 18:08:34 -0600 (MDT) +Message-ID: <40BD1A82.7010001@outputservices.com> +Date: Tue, 01 Jun 2004 18:08:34 -0600 +From: Marty Scholes +User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:0.9.9) Gecko/20020517 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org, pgsql@mohawksoft.com, + pgadmin@pse-consulting.de +Cc: marty@outputservices.com +Subject: Disk performance, was Re: tablespaces and DB administration +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/4 +X-Sequence-Number: 7062 + +This was a lively debate on what was faster, single spindles or RAID. + +This is important, because I keep running into people who do not +understand the performance dynamics of a RDBMS like Oracle or Pg. + +Pg and Oracle make a zillion tiny reads and writes and fsync() +regularly. If your drive will copy a 4GB file at a sustained rate of 72 +MB/s, that tells you nothing about how it will do with an RDBMS. + +I will throw in my experience on RAID vs spindles. + +With the RAID write cache disabled, a well balanced set of spindles will +kill a RAID system any day. + +Enable the cache, and the RAID starts inching ahead. My experience is +that no one can continuously keep I/O properly balanced across several +spindles on a production system. Things change and the I/O mix changes. + Then, the RAID is outperforming the spindles. If you want to spend +the rest of your career constantly balancing I/O across spindles, then +do so. + +For the rest of us, with a write cache, a hardware RAID wins hands down +over the long haul. + +It might make sense to provide some sort of benchmarking tool for +various systems so that we can predict I/O performance. + +Run the following code both on a hardware RAID and on a single spindle. + +#include +#include +#include +#include +#include +#include + +void makefile(int fs) +{ + int i; + char buf[8192]; + int ld; + int blocks=4096; + int pos; + time_t stim; + time_t etim; + float avg; + + unlink("dump.out"); + ld=open("dump.out", O_WRONLY | O_CREAT); + + printf("Writing %d blocks sequentially\n", blocks); + time(&stim); + for (i=0; i; + Wed, 2 Jun 2004 00:18: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 30409-03 + for ; + Wed, 2 Jun 2004 03:18:44 +0000 (GMT) +Received: from ndl1mr1-a-fixed.sancharnet.in (ndl1mr1-a-fixed.sancharnet.in + [61.0.0.45]) + by svr1.postgresql.org (Postfix) with ESMTP id E9121D1B26D + for ; + Wed, 2 Jun 2004 00:18:39 -0300 (ADT) +Received: from conversion-daemon.ndl1mr1-a-fixed.sancharnet.in by + ndl1mr1-a-fixed.sancharnet.in + (iPlanet Messaging Server 5.2 HotFix 1.27 (built May 12 2004)) + id <0HYN00801VDCFQ@ndl1mr1-a-fixed.sancharnet.in> + (original mail from sank89@sancharnet.in) + for pgsql-performance@postgresql.org; + Wed, 02 Jun 2004 08:48:34 +0530 (IST) +Received: from [61.0.94.221] by ndl1mr1-a-fixed.sancharnet.in + (iPlanet Messaging Server 5.2 HotFix 1.27 (built May 12 2004)) + with ESMTPA id <0HYN0066UVUVPF@ndl1mr1-a-fixed.sancharnet.in> for + pgsql-performance@postgresql.org; Wed, 02 Jun 2004 08:48:34 +0530 (IST) +Date: Wed, 02 Jun 2004 08:46:59 +0530 +From: "V i s h a l Kashyap @ [Sai Hertz And Control Systems]" + +Subject: PostgreSQL and Kernel 2.6.x +To: pgsql-performance@postgresql.org +Reply-To: aspire420@hotpop.com +Message-id: <40BD46AB.7090102@sancharnet.in> +Organization: Sai Hertz And Control Systems Pvt Ltd +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=us-ascii +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/5 +X-Sequence-Number: 7063 + + +Dear all, + +Have anyone compiled PostgreSQL with kernel 2.6.x +if YES +1. Was their any performance gains +Else +1. Is it possible +2. What problems would keeping us away from compiling on kernel 2.6 + +-- +Best Regards, +Vishal Kashyap +Director / Lead Software Developer, +Sai Hertz And Control Systems Pvt Ltd, +http://saihertz.rediffblogs.com +Jabber IM: vishalkashyap[ a t ]jabber.org +ICQ : 264360076 +Yahoo IM: mailforvishal[ a t ]yahoo.com +----------------------------------------------- +You yourself, as much as anybody in the entire +universe, deserve your love and affection. +- Buddha +--------------- +pgsql=# select marital_status from vishals_life; + +marital_status +------------------ +Single not looking + +1 Row(s) affected + + + + + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 00:32:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A512D1B17C + for ; + Wed, 2 Jun 2004 00:32: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 30157-10 + for ; + Wed, 2 Jun 2004 03:31:52 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A27FD1B196 + for ; + Wed, 2 Jun 2004 00:31:51 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 4880D76A14; Tue, 1 Jun 2004 23:31:57 -0400 (EDT) +Subject: Re: PostgreSQL and Kernel 2.6.x +From: Rod Taylor +To: aspire420@hotpop.com +Cc: Postgresql Performance +In-Reply-To: <40BD46AB.7090102@sancharnet.in> +References: <40BD46AB.7090102@sancharnet.in> +Content-Type: text/plain +Message-Id: <1086147109.85942.86.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 01 Jun 2004 23:31:50 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/6 +X-Sequence-Number: 7064 + +On Tue, 2004-06-01 at 23:16, V i s h a l Kashyap @ [Sai Hertz And +Control Systems] wrote: +> Dear all, +> +> Have anyone compiled PostgreSQL with kernel 2.6.x +> if YES +> 1. Was their any performance gains + +OSDL reports approx 20% improvement. I've seen similar with some data +access patterns. + +> 2. What problems would keeping us away from compiling on kernel 2.6 + +Nothing that I know of assuming you have vendor support for it. + + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 17:02:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E37DD1CC7F + for ; + Wed, 2 Jun 2004 08:57: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 99671-04 + for ; + Wed, 2 Jun 2004 11:57:54 +0000 (GMT) +Received: from mx1.2at.nl (mx1.2at.nl [62.166.148.220]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D581D1CA04 + for ; + Wed, 2 Jun 2004 08:57:48 -0300 (ADT) +Content-class: urn:content-classes:message +Subject: Postgres query optimization with varchar fields +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Wed, 2 Jun 2004 13:57:44 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Postgres query optimization with varchar fields +Thread-Index: AcRImM+bMZQvLTBnTvSlSl1yqb9jFw== +From: "W.H. van Atteveldt" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/15 +X-Sequence-Number: 7073 + +Dear reader,=20 + +I am investigating whether it is useful to directly query a database +containing a rather large text corpus (order of magnitude 100k - 1m +newspaper articles, so around 100 million words), or whether I should +use third party text indexing services. I want to know things such as: +how often is a certain word (or pattern) mentioned in an article and how +often it is mentioned with the condition that another word is nearby +(same article or n words distant). + +I created a table listing the words one word per row, and created an +index on the word and wordnr columns. An example query would be: + +simple: select articleid, count(*) as count from words w where articleid +in (select id from articles where batchid in (84,85,100,101,118,121)) +and (word like '') group by articleid +complex: select articleid, count(*) as count from words w where +articleid in (select id from articles where batchid in +(84,85,100,101,118,121)) and (word like '') and exists (select +* from words w2 where w.articleid =3D w2.articleid and (word like +'')) group by articleid + +According to the diagnostics, the database does use the indices for the +query, but it is still rather slow (around 10 minutes for a 'simple +query', x seconds for a complex one) + +It is important that the complex query only counts instances where the +PATTERN is found and PATTERN2 only functions as a criterium and does not +add to the count. + +My questions are: (technical details provided below) +- Does anyone disagree with the general setup? +- Is there a more sensible way to phrase my SQL? +- Any other ideas to improve performance? + +Thanks, + +Wouter van Atteveldt +Free University Amsterdam + +------ + +Technicalities: + +I am using a Postgresql 7.4.1 database on a linux machine (uname -a: +Linux swpc450.cs.vu.nl 2.4.22-1.2115.nptl #1 Wed Oct 29 15:31:21 EST +2003 i686 athlon i386 GNU/Linux). The table of interest is: (lemma, pos, +simplepos currently not used) + + Table "public.words" + Column | Type | Modifiers +------------+------------------------+---------------------------------- +--------------------- + id | integer | not null default +nextval('public.words_id_seq'::text) + articleid | integer | not null + sentencenr | integer | not null + word | character varying(255) | not null + lemma | character varying(255) | + pos | character varying(255) | + simplepos | character(1) | + wordnr | integer | not null + parnr | integer | not null +Indexes: + "words_pkey" primary key, btree (id) + "words_aid" btree (articleid) + "words_word" btree (word) + "words_word_ptrn" btree (word varchar_pattern_ops) + "words_wordnr" btree (wordnr) + +Query plans: + +anoko=3D> explain select articleid, count(*) as count from words w where +articleid in (select id from articles where batchid in +(84,85,100,101,118,121)) and (word like 'integratie%') group by +articleid; +=20 +QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20 +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------------------------------------------------------ + HashAggregate (cost=3D937959.21..937959.22 rows=3D2 width=3D4) + -> Hash IN Join (cost=3D95863.70..937816.01 rows=3D28640 width=3D4) + Hash Cond: ("outer".articleid =3D "inner".id) + -> Index Scan using words_word_ptrn on words w +(cost=3D0.00..836604.62 rows=3D208886 width=3D4) + Index Cond: (((word)::text ~>=3D~ 'integratie'::character +varying) AND ((word)::text ~<~ 'integratif'::character varying)) + Filter: ((word)::text ~~ 'integratie%'::text) + -> Hash (cost=3D94998.60..94998.60 rows=3D146041 width=3D4) + -> Index Scan using articles_batchid, articles_batchid, +articles_batchid, articles_batchid, articles_batchid, articles_batchid +on articles (cost=3D0.00..94998.60 rows=3D146041 width=3D4) + Index Cond: ((batchid =3D 84) OR (batchid =3D 85) OR +(batchid =3D 100) OR (batchid =3D 101) OR (batchid =3D 118) OR (batchid =3D +121)) + +explain select articleid, count(*) as count from words w where articleid +in (select id from articles where batchid in (84,85,100,101,118,121)) +and (word like '') and exists (select * from words w2 where +w.articleid =3D w2.articleid and (word like '')) group by +articleid +anoko-> ; +=20 +QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20 +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------------------------------------------------------ + GroupAggregate (cost=3D168253089.23..168254556.46 rows=3D1 width=3D4) + -> Merge IN Join (cost=3D168253089.23..168254484.85 rows=3D14320 +width=3D4) + Merge Cond: ("outer".articleid =3D "inner".id) + -> Sort (cost=3D168144438.23..168144699.33 rows=3D104443 width= +=3D4) + Sort Key: w.articleid + -> Index Scan using words_word_ptrn on words w +(cost=3D0.00..168134972.17 rows=3D104443 width=3D4) + Index Cond: ((word)::text ~=3D~ +''::character varying) + Filter: (((word)::text ~~ ''::text) AND +(subplan)) + SubPlan + -> Index Scan using words_aid on words w2 +(cost=3D0.00..836948.84 rows=3D1045 width=3D460) + Index Cond: ($0 =3D articleid) + Filter: ((word)::text ~~ +''::text) + -> Sort (cost=3D108651.01..109016.11 rows=3D146041 width=3D4) + Sort Key: articles.id + -> Index Scan using articles_batchid, articles_batchid, +articles_batchid, articles_batchid, articles_batchid, articles_batchid +on articles (cost=3D0.00..94998.60 rows=3D146041 width=3D4) + Index Cond: ((batchid =3D 84) OR (batchid =3D 85) OR +(batchid =3D 100) OR (batchid =3D 101) OR (batchid =3D 118) OR (batchid =3D +121)) + +From pgsql-performance-owner@postgresql.org Wed Jun 2 11:28:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 66C7BD1B1DC + for ; + Wed, 2 Jun 2004 11:28: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 58132-02 + for ; + Wed, 2 Jun 2004 14:28:32 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id A320AD1B173 + for ; + Wed, 2 Jun 2004 11:28:27 -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 1BVWiP-0008Dt-00; Wed, 02 Jun 2004 10:27:37 -0400 +To: Vitaly Belman +Cc: pgsql-performance@postgresql.org, + Bryan Encina , + Matthew Nuzum +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +References: <16113857921.20040602015607@012.net.il> +In-Reply-To: <16113857921.20040602015607@012.net.il> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Jun 2004 10:27:36 -0400 +Message-ID: <87n03m592f.fsf@stark.xeocode.com> +Lines: 27 +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-Archive-Number: 200406/7 +X-Sequence-Number: 7065 + + +Vitaly Belman writes: + +> With all that said, VMWare is badly suited for running a database, +> while CoLinux can be run as a service (didn't try it yet though), +> VMWare always sits there, it is slow to go up, slow to go down and +> generally feels like a system hog. + +Uhm, it sounds like you're using VMWare Workstation? VMWare has a range of +different versions including some that are specifically targeted towards +server situations. I think they had the idea that hosting companies would run +hundreds of virtual machines on a server and provide their hosting clients +with a virtual machine to play with. + +That said, I'm curious why the emulated servers performed better than the +Native Windows port. My first thought is that they probably aren't syncing +every write to disk so effectively they're defeating the fsyncs, allowing the +host OS to buffer disk writes. + +I would be curious to see better stats on things like a pgbench run which +would give some idea of the context switch efficiency, and a large select or +update, which would give some idea of the i/o throughput. Really there's no +excuse for the Windows port to be slower than an emulator. Barring effects +like the disk caching I mentioned, it should far outpace the emulators. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 12:52:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EA6FBD1B18C + for ; + Wed, 2 Jun 2004 12:25: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 79341-07 + for ; + Wed, 2 Jun 2004 15:25: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 41F20D1CE38 + for ; + Wed, 2 Jun 2004 12:25:43 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i52FOtFR024745; + Wed, 2 Jun 2004 11:24:55 -0400 (EDT) +To: Greg Stark +Cc: Vitaly Belman , pgsql-performance@postgresql.org, + Bryan Encina , + Matthew Nuzum +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +In-reply-to: <87n03m592f.fsf@stark.xeocode.com> +References: <16113857921.20040602015607@012.net.il> + <87n03m592f.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "02 Jun 2004 10:27:36 -0400" +Date: Wed, 02 Jun 2004 11:24:55 -0400 +Message-ID: <24744.1086189895@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/10 +X-Sequence-Number: 7068 + +Greg Stark writes: +> That said, I'm curious why the emulated servers performed better than the +> Native Windows port. My first thought is that they probably aren't syncing +> every write to disk so effectively they're defeating the fsyncs, allowing the +> host OS to buffer disk writes. + +It would be fairly easy to check this by repeating the comparisons with +fsync = off in postgresql.conf. A performance number that doesn't +change much would be a smoking gun ;-). + +The native port hasn't had any performance testing done on it yet, and +I wouldn't be surprised to hear of a gotcha or two. Perhaps with the +recent schedule change there will be some time for performance tuning +before we go beta. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Jun 2 12:48:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F2B51D1CAE3 + for ; + Wed, 2 Jun 2004 12:30: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 85861-02 + for ; + Wed, 2 Jun 2004 15:30:35 +0000 (GMT) +Received: from smtp017.mail.yahoo.com (smtp017.mail.yahoo.com + [216.136.174.114]) + by svr1.postgresql.org (Postfix) with SMTP id 59657D1B1BD + for ; + Wed, 2 Jun 2004 12:30:33 -0300 (ADT) +Received: from unknown (HELO europa.janwieck.net) (janwieck@68.80.245.191 with + login) by smtp017.mail.yahoo.com with SMTP; 2 Jun 2004 15:30:32 -0000 +Received: from Yahoo.com (ismtp.afilias.com [216.217.55.254]) (authenticated) + by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id i52FUT008727; + Wed, 2 Jun 2004 11:30:29 -0400 +Message-ID: <40BDF28E.9060003@Yahoo.com> +Date: Wed, 02 Jun 2004 11:30:22 -0400 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Vitaly Belman +Cc: pgsql-performance@postgresql.org, + Bryan Encina , + Matthew Nuzum +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +References: <16113857921.20040602015607@012.net.il> +In-Reply-To: <16113857921.20040602015607@012.net.il> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/9 +X-Sequence-Number: 7067 + +Using VMware myself quite extensively, I wonder what the disk +configuration was that you created for the VM. Where the disks +preallocated and did you make sure that they are contiguous on the NTFS +filesystem? Did you install the VMware tools in the guest operating system? + +What did you use to measure the "performance"? + + +Jan + +On 6/1/2004 6:56 PM, Vitaly Belman wrote: + +> Hello pgsql-performance, +> +> I was using the native windows PostgreSQL 7.5Dev and was adviced by +> several people to use an emulated PostgreSQL instead, as it is just +> a beta. +> +> Well, I give it a whirl and tried both commercial VMWare and the +> freeweare open-source CoLinux, both work under Windows and both +> emulate Linux, that's a quick review of my experience with them, may +> someone in need learn from it. +> +> This might be not the best place for such a post, but since the +> subject was brought up here, I'll post it here as well. If someone +> thinks it should be posted somewhere else, let me know. +> +> Installation & Configuration +> ---------------------------- +> +> VMWare: +> +> On the bright side, the installation went quite smoothly, VMWare +> configured all the network stuff by itself and I had no trouble +> using the net right away. On the grim side, the installation itself +> took ages, compared to the plug & play feel of CoLinux. +> +> Installing PostgreSQL on VMWare was quite straightforward, just as +> the the PostgreSQL documention goes. +> +> CoLinux: +> +> As I said, with CoLinux the installation itself goes very quickly. +> To get Linux running you need to download practically less than 20mb +> which include the distribution (Debian in my case) and the CoLinux +> setup. Configuring CoLinux took a bit longer than VMWare, yet, not +> long as I thought it would take. In fact, it can be very easy if you +> just follow the documention of CoLinux Wiki stuff, there are some +> very easy to follow tutorials there. +> +> Installing PostgreSQL on CoLinux proved a little more difficult +> (again, Debian), but I posted a quick tutorial that should smooth +> the process: http://www.colinux.org/wiki/index.php/PostgreSQL. +> +> Performance +> ----------- +> +> This was a totally subjective test (especially since one of the +> participants is in a beta stage), yet, that's what I tested and that's +> what I needed to know. +> +> To make the test as fair as possible, I did an exact dump of the +> same database. I ran the SQLs (around 10) in the same order on all +> of them and repeated the test several times. I also did an EXPLAIN +> on the queries to make sure all the databases work on the query the +> same way. It wasn't a full test though, I didn't test mass select +> load, nor inserts, nor work under heavy load, nor I tried different +> types of joins. All I did was to run some heavy (in execution time) +> queries. So you should take these "tests" just for what they are. +> +> That's what I got: +> +> The native window port performed poorly lagging +> 30%-50% behind the VMWare/CoLinux solutions in execution times, +> rather sad, but not unexpected, I guess. +> +> CoLinux and VMWare give AROUND the same results, yet CoLinux did +> give slightly better performance (I'd say 5%-10%) but with such +> slight improvement and inconsistency I wouldn't count it as much. +> +> Conclusion +> ---------- +> +> With all that said, VMWare is badly suited for running a database, +> while CoLinux can be run as a service (didn't try it yet though), +> VMWare always sits there, it is slow to go up, slow to go down and +> generally feels like a system hog. +> +> I'll go on with CoLinux for now and hope it will act as good as it +> looks. +> +> http://www.vmware.com/ +> http://www.colinux.org/ +> +> Thanks to Bryan and Matthew for their advices regarding the emulations. +> +> Regards, +> Vitaly Belman +> +> ICQ: 1912453 +> AIM: VitalyB1984 +> MSN: tmdagent@hotmail.com +> Yahoo!: VitalyBe +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend + + +-- +#======================================================================# +# It's easier to get forgiveness for being wrong than for being right. # +# Let's break this rule - forgive me. # +#================================================== JanWieck@Yahoo.com # + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 12:38:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 93BFDD1B18C + for ; + Wed, 2 Jun 2004 12:38: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 87023-07 + for ; + Wed, 2 Jun 2004 15:38:20 +0000 (GMT) +Received: from trade-india.com (infocom02.trade-india.com [67.18.55.69]) + by svr1.postgresql.org (Postfix) with SMTP id 5770DD1CE86 + for ; + Wed, 2 Jun 2004 12:38:18 -0300 (ADT) +Received: (qmail 23321 invoked from network); 2 Jun 2004 15:40:25 -0000 +Received: from unknown (HELO ?203.145.130.142?) (203.145.130.142) + by infocom02.trade-india.com with SMTP; 2 Jun 2004 15:40:25 -0000 +Message-ID: <40BDF46F.2000005@trade-india.com> +Date: Wed, 02 Jun 2004 21:08:23 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla Thunderbird 0.6 (X11/20040502) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: aspire420@hotpop.com +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL and Kernel 2.6.x +References: <40BD46AB.7090102@sancharnet.in> +In-Reply-To: <40BD46AB.7090102@sancharnet.in> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/8 +X-Sequence-Number: 7066 + +V i s h a l Kashyap @ [Sai Hertz And Control Systems] wrote: + +> +> Dear all, +> +> Have anyone compiled PostgreSQL with kernel 2.6.x if YES +> 1. Was their any performance gains +> Else +> 1. Is it possible +> 2. What problems would keeping us away from compiling on kernel 2.6 +> +We run pgsql on 2.6.6 there was upto 30% improvement in performance +for certain queries. None, everything works just fine. + + +Regds +Mallah. + +From pgsql-general-owner@postgresql.org Wed Jun 2 14:11:35 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5B0D9D1B1F7; Wed, 2 Jun 2004 14:01: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 19124-02; Wed, 2 Jun 2004 17:01:37 +0000 (GMT) +Received: from mailbox.maricopa.gov (mailbox.maricopa.gov [156.42.4.109]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5B9FAD1B3D9; Wed, 2 Jun 2004 14:01:35 -0300 (ADT) +Received: from maricopa_xcng2.maricopa.gov (maricopa_xcng2.maricopa.gov + [156.42.103.174] (may be forged)) + by mailbox.maricopa.gov (8.8.6 (PHNE_17190)/8.8.6) with ESMTP id + JAA01588; Wed, 2 Jun 2004 09:54:58 -0700 (MST) +Received: by maricopa_xcng2 with Internet Mail Service (5.5.2657.72) + id ; Wed, 2 Jun 2004 10:01:15 -0700 +Message-ID: <64EDC403A1417B4299488BAE87CA7CBF01CD0E4F@maricopa_xcng0> +From: Duane Lee - EGOVX +To: "'Mike Nolan'" , + Duane Lee - EGOVX +Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Trigger & Function +Date: Wed, 2 Jun 2004 10:01:10 -0700 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C448C3.34154BD0" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/102 +X-Sequence-Number: 61485 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C448C3.34154BD0 +Content-Type: text/plain; + charset="iso-8859-1" + +Thanks for the response. I was pretty sure it couldn't be done the way I +wanted to but felt I would ask anyway. + +Thanks again, +Duane + +-----Original Message----- +From: Mike Nolan [mailto:nolan@gw.tssi.com] +Sent: Tuesday, June 01, 2004 3:04 PM +To: DLee@mail.maricopa.gov +Cc: pgsql-general@postgresql.org; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Trigger & Function + + +> My problem is I defined the "before" and "after" +> fields in the audit table as TEXT and when I try to move NEW or OLD into +> these fields I get the error "NEW used in query that is not in a rule". + +You're trying to insert record data into a text field, that doesn't work. +OLD and NEW can be used as either record identifiers (as in RETURN OLD) +or column qualifiers (as in OLD.colname), but you can't intermingle them. + +I don't think postgres (pl/pgsql) has row-to-variable and variable-to-row +functions like serialize and unserialize, that's probably what you'd need. +It would probably be necessary to write something like that in C, since +at this point pl/perl cannot be used for trigger functions. + +I've not tried using pl/php yet, the announcement for it says it can be +used for trigger functions. + +My first thought is that even if there was a serialize/unserialize +capabiity you might be able to write something using it that creates +the log entry but not anything that allows you to query the log for +specific column or row entries. + +It would probably require a MAJOR extension of SQL to add it to pg, +as there would need to be qualifiers that can be mapped to specific +tables and columns. Even if we had that, storing values coming from +multiple tables into a single audit table would present huge challenges. + +I've found only two ways to implement audit logs: + +1. Have separate log tables that match the structure of + the tables they are logging. + +2. Write a trigger function that converts columns to something you can + store in a common log table. (I've not found a way to do this without + inserting one row for each column being logged, though.) +-- +Mike Nolan + +------_=_NextPart_001_01C448C3.34154BD0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Trigger & Function + + + +

Thanks for the response.  I was pretty sure it could= +n't be done the way I wanted to but felt I would ask anyway. +

+ +

Thanks again, +
Duane +

+ +

-----Original Message----- +
From: Mike Nolan [m= +ailto:nolan@gw.tssi.com] +
Sent: Tuesday, June 01, 2004 3:04 PM +
To: DLee@mail.maricopa.gov +
Cc: pgsql-general@postgresql.org; pgsql-performance@post= +gresql.org +
Subject: Re: [PERFORM] Trigger & Function +

+
+ +

> My problem is I defined the "before" and &= +quot;after" +
> fields in the audit table as TEXT and when I try to= + move NEW or OLD into +
> these fields I get the error "NEW used in quer= +y that is not in a rule".  +

+ +

You're trying to insert record data into a text field, th= +at doesn't work. +
OLD and NEW can be used as either record identifiers (as= + in RETURN OLD) +
or column qualifiers (as in OLD.colname), but you can't = +intermingle them. +

+ +

I don't think postgres (pl/pgsql) has row-to-variable and= + variable-to-row +
functions like serialize and unserialize, that's probabl= +y what you'd need. +
It would probably be necessary to write something like t= +hat in C, since +
at this point pl/perl cannot be used for trigger functio= +ns.  +

+ +

I've not tried using pl/php yet, the announcement for it = +says it can be +
used for trigger functions.  +

+ +

My first thought is that even if there was a serialize/un= +serialize +
capabiity you might be able to write something using it = +that creates +
the log entry but not anything that allows you to query = +the log for +
specific column or row entries. +

+ +

It would probably require a MAJOR extension of SQL to add= + it to pg, +
as there would need to be qualifiers that can be mapped = +to specific +
tables and columns.  Even if we had that, storing v= +alues coming from +
multiple tables into a single audit table would present = +huge challenges. +

+ +

I've found only two ways to implement audit logs: +

+ +

1.  Have separate log tables that match the structur= +e of +
    the tables they are logging. +

+ +

2.  Write a trigger function that converts columns t= +o something you can +
    store in a common log table.  (I= +'ve not found a way to do this without +
    inserting one row for each column bei= +ng logged, though.) +
-- +
Mike Nolan +

+ + + +------_=_NextPart_001_01C448C3.34154BD0-- + +From pgsql-performance-owner@postgresql.org Wed Jun 2 15:48:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BC3C7D1B1BD + for ; + Wed, 2 Jun 2004 15:48: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 71075-08 + for ; + Wed, 2 Jun 2004 18:48:26 +0000 (GMT) +Received: from out1.strato.net (out1.strato.net [205.160.247.180]) + by svr1.postgresql.org (Postfix) with ESMTP id B31E9D1B17C + for ; + Wed, 2 Jun 2004 15:48:23 -0300 (ADT) +Received: from cust1.strato.net (cust1.backoff.inside.strato.net + [172.16.248.177]) by out1.strato.net (Postfix) with ESMTP + id 20B0677BBE; Wed, 2 Jun 2004 14:48:23 -0400 (EDT) +Received: from unit91 (01-108.033.popsite.net [66.19.76.108]) + by cust1.strato.net (Postfix) with ESMTP + id 32370778FA; Wed, 2 Jun 2004 14:48:18 -0400 (EDT) +From: "Matthew Nuzum" +To: "'Tom Lane'" , + "'Greg Stark'" +Cc: "'Vitaly Belman'" , + , + "'Bryan Encina'" , + "'Matthew Nuzum'" +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +Date: Wed, 2 Jun 2004 14:51:37 -0400 +Organization: Followers.net, Inc. +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +In-Reply-To: <24744.1086189895@sss.pgh.pa.us> +Thread-Index: AcRIvZUOXOju8Z8JQqCTmRUsFYXXngAEonzA +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Message-Id: <20040602184818.32370778FA@cust1.strato.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/12 +X-Sequence-Number: 7070 + +I have colinux running on a Fedora Core 1 image. I have the rhdb 3 (or +PostgreSQL RedHat Edition 3) on it running. Here are tests with fsync on +and off: + FSYNC OFF FSYNC ON RUN +136.9 142.0 124.5 149.1 1 +122.1 126.7 140.1 169.7 2 +125.7 148.7 147.4 180.4 3 +103.3 136.7 136.8 166.3 4 +126.5 146.1 152.3 187.9 5 +114.4 133.3 144.8 176.7 6 +124.0 146.5 143.3 175.0 7 +121.7 166.8 147.8 180.5 8 +127.3 151.8 146.7 180.0 9 +124.6 143.0 137.2 167.5 10 +-------------------------------------- +122.7 144.2 142.1 173.3 AVG + +I hope those numbers' formatting come through all right. + +This computer is an AMD Athlon 900MHz with 448MB Ram running XP Pro SP1 +This is using Colinux 0.60 (not the recently released 0.61) and 96MB of RAM +allocated to linux. + +The computer was idle but it was running Putty, Excel and Task Manager +during the process. (I prefer to use Putty to SSH into the virtual computer +than to run the fltk console) + +It occurs to me that the fsync may be performed to the linux filesystem, but +this filesystem is merely a file on the windows drive. Would Windows cache +this file? It's 2GB in size, so if it did, it would only be able to cache +part of it. + +I'd like to run a more difficult test personally. It seems like this test +goes too fast to be very useful. + +If someone would like me to try something more specific, e-mail me right +away and I'll do it. I must leave my office at 4:15 EDT and will not return +until Friday, although I can do another test on my home computer Thursday. + +Matthew Nuzum | Makers of "Elite Content Management System" +www.followers.net | View samples of Elite CMS in action +matt@followers.net | http://www.followers.net/portfolio/ + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance- +> owner@postgresql.org] On Behalf Of Tom Lane +> Sent: Wednesday, June 02, 2004 11:25 AM +> To: Greg Stark +> Cc: Vitaly Belman; pgsql-performance@postgresql.org; Bryan Encina; Matthew +> Nuzum +> Subject: Re: [PERFORM] PostgreSQL on VMWare vs Windows vs CoLinux +> +> Greg Stark writes: +> > That said, I'm curious why the emulated servers performed better than +> the +> > Native Windows port. My first thought is that they probably aren't +> syncing +> > every write to disk so effectively they're defeating the fsyncs, +> allowing the +> > host OS to buffer disk writes. +> +> It would be fairly easy to check this by repeating the comparisons with +> fsync = off in postgresql.conf. A performance number that doesn't +> change much would be a smoking gun ;-). +> +> The native port hasn't had any performance testing done on it yet, and +> I wouldn't be surprised to hear of a gotcha or two. Perhaps with the +> recent schedule change there will be some time for performance tuning +> before we go beta. +> +> 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 + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 16:14:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EB47D1B1BD + for ; + Wed, 2 Jun 2004 16: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 76052-10 + for ; + Wed, 2 Jun 2004 19:04:15 +0000 (GMT) +Received: from usbb-lacimss3.unisys.com (usbb-lacimss3.unisys.com + [192.63.108.53]) + by svr1.postgresql.org (Postfix) with ESMTP id 43E0ED1B18F + for ; + Wed, 2 Jun 2004 16:04:08 -0300 (ADT) +Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.43]unverified) by + usbb-lacimss3 with InterScan Messaging Security Suite; + Wed, 02 Jun 2004 15:17:21 -0400 +Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.44]) by + USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 2 Jun 2004 15:03:35 -0400 +Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by + USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 2 Jun 2004 15:03:35 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 2 Jun 2004 20:03:33 +0100 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +Date: Wed, 2 Jun 2004 21:03:33 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] PostgreSQL on VMWare vs Windows vs CoLinux +Thread-Index: AcRIvZUOXOju8Z8JQqCTmRUsFYXXngAEonzAAADxyiA= +From: "Leeuw van der, Tim" +To: +X-OriginalArrivalTime: 02 Jun 2004 19:03:33.0938 (UTC) + FILETIME=[4D3DD120:01C448D4] +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/13 +X-Sequence-Number: 7071 + +Hi All, + +I think it would actually be interesting to see the performance of the Cygw= +in version for these same benchmarks, then we've covered all ways to run Po= +stgreSQL on Windows systems. (I expect though that performance of Cygwin-Po= +stgreSQL will improve considerably when an updated version is released that= + uses Cygwin native IPC instead of the ipc-daemon.) + +regards, + +--Tim + +From pgsql-performance-owner@postgresql.org Wed Jun 2 16:35:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65561D1B1DC + for ; + Wed, 2 Jun 2004 16:25: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 74852-03 + for ; + Wed, 2 Jun 2004 19:25:18 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 89B20D1B1D0 + for ; + Wed, 2 Jun 2004 16:25:15 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5257425; Wed, 02 Jun 2004 12:26:50 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Context Switching issue: Spinlock doesn't fix. +Date: Wed, 2 Jun 2004 12:25:25 -0700 +User-Agent: KMail/1.5.4 +Cc: pg@fastcrypt.com +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406021225.25463.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/14 +X-Sequence-Number: 7072 + +Folks, + +I've been testing varying SPINS_PER_DELAY in a client's installation of +PostgreSQL against a copy of a production database, to test varying this +statistic as a way of fixing the issue. + +It does not seem to work. + +I've tested all of the following graduated levels: + +100 (the original) +250 +500 +1000 +2000 +5000 +10000 +20000 +30000 +50000 + +None of these quantities seem to make any difference at all in the number of +context switches -- neither down nor up. Seems to me like this is a dead +end. Does anyone have test results that show otherwise? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 17:28:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CBB31D1B17C + for ; + Wed, 2 Jun 2004 17:17: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 12742-05 + for ; + Wed, 2 Jun 2004 20:17:26 +0000 (GMT) +Received: from mail.libertyrms.com (unknown [207.219.45.62]) + by svr1.postgresql.org (Postfix) with ESMTP id 54949D1B18F + for ; + Wed, 2 Jun 2004 17:17:23 -0300 (ADT) +Received: from dba4.int.libertyrms.com ([10.1.3.13] ident=ahammond) + by mail.libertyrms.com with esmtp (Exim 4.22) + id 1BVcAq-0001CN-Ph; Wed, 02 Jun 2004 16:17:20 -0400 +Message-ID: <40BE360B.3060104@ca.afilias.info> +Date: Wed, 02 Jun 2004 16:18:19 -0400 +From: Andrew Hammond +User-Agent: Mozilla Thunderbird 0.6 (X11/20040512) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dan Harris +Cc: Bjoern Metzdorf , + pgsql-performance@postgresql.org +Subject: Re: Hardware opinions wanted +References: <40B66E71.7060703@drivefaster.net> + <40B717BF.9060507@turtle-entertainment.de> +In-Reply-To: <40B717BF.9060507@turtle-entertainment.de> +X-Enigmail-Version: 0.83.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-SA-Exim-Mail-From: ahammond@ca.afilias.info +X-SA-Exim-Scanned: No; SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/17 +X-Sequence-Number: 7075 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +I'm working through the aquisition process for a quad Opteron box right +now. I'll be benchmarking it against a quad processor p630 as well as a +quad Xeon after we get it and posting results here. But that's about a +month or two from now. + +I expect that the results will be strongly in favour of the Opetron, +especially the price / performance since the Opteron box is being quoted +at about half the price of the p630 systems. + +One thing you may wish to consider is going with lots of 10kRPM SATA +disks instead of 15kRPM SCSI disks. Two companies that I'm aware of +offer quad Opteron solutions with SATA raid: + +http://www.quatopteron.com/ +http://alltec.com/home.php + +Andrew Hammond +DBA - Afilias +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFAvjYKgfzn5SevSpoRAvq0AJkBDXOKL52HXg43mQ6rXe/i9RzFkQCfYQn8 +HpHP2U0jvjfYIvihNLFLbzA= +=LyqB +-----END PGP SIGNATURE----- + +From pgsql-performance-owner@postgresql.org Wed Jun 2 17:27:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F4F0D1B88E + for ; + Wed, 2 Jun 2004 17:24: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 15562-02 + for ; + Wed, 2 Jun 2004 20:24:48 +0000 (GMT) +Received: from smtp1.actcom.co.il (mx1.actcom.co.il [192.114.47.13]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BBB4D1B459 + for ; + Wed, 2 Jun 2004 17:24:45 -0300 (ADT) +Received: from actcom.co.il (actcom.co.il [192.114.47.1]) + by smtp1.actcom.co.il (8.12.11/8.12.11) with ESMTP id i52KOKBQ019294; + Wed, 2 Jun 2004 23:24:30 +0300 +Received: from shemesh.biz by actcom.co.il with ESMTP + (8.11.6/actcom-0.3) id i52KOJi00894; + Wed, 2 Jun 2004 23:24:19 +0300 (EET DST) + (rfc931-sender: line102-130.adsl.actcom.co.il [192.117.102.130]) +Message-ID: <40BE3773.1000107@shemesh.biz> +Date: Wed, 02 Jun 2004 23:24:19 +0300 +From: Shachar Shemesh +Organization: Lingnu Open Source Consulting +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.6) Gecko/20040528 Debian/1.6-7 +X-Accept-Language: en, he +MIME-Version: 1.0 +To: Greg Stark +Cc: Vitaly Belman , pgsql-performance@postgresql.org, + Bryan Encina , + Matthew Nuzum +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +References: <16113857921.20040602015607@012.net.il> + <87n03m592f.fsf@stark.xeocode.com> +In-Reply-To: <87n03m592f.fsf@stark.xeocode.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-Archive-Number: 200406/16 +X-Sequence-Number: 7074 + +Greg Stark wrote: + +>That said, I'm curious why the emulated servers performed better than the +>Native Windows port. My first thought is that they probably aren't syncing +>every write to disk so effectively they're defeating the fsyncs, allowing the +>host OS to buffer disk writes. +> +> +I havn't tested it, and it's certanly possible. However, please bear in +mind that it is also possible that it just gives better performance. + +The reason this may be possible is that the emulation layer gets the CPU +(and other resources) from the OS in bulk, and decides on it's own how +to allocate it to the various processes running within the emulation. +Inparticular, this "on it's own" is done using the stock Linux kernel. +As Postgresql works sufficiently better on Linux than on Windows, this +yields better performance. + +Again - speculation only. Someone should defenitely make sure that no +caching takes place where it shouldn't. + +As a side note, I have had a chance to talk to Dan Aloni (coLinux +maintainer) about running PostgreSQL on coLinux. He said that he knows +that this particular use is high on people's priority list, but he feels +it is totally unsafe to run a production database on alpha grade +software. Then again, free software projects being what they are, this +is usually what a maintainer would say. + + Shachar + +-- +Shachar Shemesh +Lingnu Open Source Consulting +http://www.lingnu.com/ + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 17:45:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FECED1B1AE + for ; + Wed, 2 Jun 2004 17:45: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 25475-09 + for ; + Wed, 2 Jun 2004 20:45:28 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 16447D1B196 + for ; + Wed, 2 Jun 2004 17:45:25 -0300 (ADT) +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 on VMWare vs Windows vs CoLinux +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Wed, 2 Jun 2004 16:45:27 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AE4A@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] PostgreSQL on VMWare vs Windows vs CoLinux +Thread-Index: AcRI4NvNCv4wHiUHTLiozjAK76GMigAABypw +From: "Merlin Moncure" +To: "Shachar Shemesh" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/18 +X-Sequence-Number: 7076 + +Shachar Shemesh wrote: +> Greg Stark wrote: +>=20 +> >That said, I'm curious why the emulated servers performed better than +the +> >Native Windows port. My first thought is that they probably aren't +> syncing +> >every write to disk so effectively they're defeating the fsyncs, +allowing +> the +> >host OS to buffer disk writes. +> > +> > +> I havn't tested it, and it's certanly possible. However, please bear +in +> mind that it is also possible that it just gives better performance. +>=20 +> The reason this may be possible is that the emulation layer gets the +CPU +> (and other resources) from the OS in bulk, and decides on it's own how +> to allocate it to the various processes running within the emulation. +> Inparticular, this "on it's own" is done using the stock Linux kernel. +> As Postgresql works sufficiently better on Linux than on Windows, this +> yields better performance. + +'better' does not mean 'faster'. Win32 has a pretty decent journaling +filesytem (ntfs) and a good I/O subsystem which includes IPC. Process +management is poor compared to newer linux kernels but this is +unimportant except in extreme cases. Right now the win32 native does +not sync() (but does fsync()). So, the performance is somewhere between +fsync =3D off and fsync =3D on (probably much closer to fsync =3D on). It = +is +reasonable to assume that the win32 port will outperform the unix +versions at many tasks (at the expense of safety) until the new sync() +code is put in. + +If tested on the same source base, 40-60% differences can only be coming +from the I/O subsystem. There are other factors which aren't clear from +this exchange like what version of gcc, etc. + +Merlin + +From pgsql-performance-owner@postgresql.org Wed Jun 2 18:13:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EF6BD1CD7E + for ; + Wed, 2 Jun 2004 18:13: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 81633-07 + for ; + Wed, 2 Jun 2004 21:13:42 +0000 (GMT) +Received: from ml-hw5.monsterlabs.com (ml-hw5.monsterlabs.com + [216.183.105.167]) + by svr1.postgresql.org (Postfix) with SMTP id 1A66FD1CCD1 + for ; + Wed, 2 Jun 2004 18:13:39 -0300 (ADT) +Received: (qmail 27878 invoked from network); 2 Jun 2004 21:13:41 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.15?) + (64.3.242.80) + by ml-hw5.monsterlabs.com with SMTP; 2 Jun 2004 21:13:41 -0000 +From: Marcus Whitney +Reply-To: marcus@coldfeetcreative.com +Organization: Coldfeet Creative +To: +Subject: Re: Pl/Pgsql Functions running simultaneously +Date: Wed, 2 Jun 2004 16:08:56 -0500 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200406021608.56919.marcus@coldfeetcreative.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/19 +X-Sequence-Number: 7077 + +Hello all, + + I have an import function that I have been working on for some time now, = +and=20 +it performed well up until recently. It is doing a lot, and because the=20 +queries are not cached, I am not sure if that is what the problem is. If a= +=20 +function takes a while, does it lock any of the tables it is accessing, eve= +n=20 +for SELECT? + +Below is the bulk of the function: + +-- set sql statement variables + create_import_file_sql :=3D ''COPY '' || container_table || '' ('' = +||=20 +filtered_container_columns || '') TO '' ||=20 +quote_literal(formatted_import_file) || '' WITH NULL AS '' ||=20=20 +null_single_quotes; + upload_to_import_table_sql :=3D ''COPY '' || import_table || '' (''= + ||=20 +field_names || '') FROM '' || quote_literal(formatted_import_file) || '' WI= +TH=20 +NULL AS '' || null_single_quotes; + clean_personalization_fields_sql :=3D ''UPDATE '' || import_table |= +| ''=20 +SET emma_member_email =3D btrim(emma_member_email, '' ||=20 +quote_literal(quoted_single_quote) || '') , emma_member_name_first =3D=20 +btrim(emma_member_name_first, '' || quote_literal(quoted_single_quote) ||= +=20 +'') , emma_member_name_last =3D btrim(emma_member_name_last, '' ||=20 +quote_literal(quoted_single_quote) || '') ;''; + clean_personalization_fields_sql2 :=3D ''UPDATE '' || import_table = +|| ''=20 +SET emma_member_email =3D btrim(emma_member_email) , emma_member_name_first= + =3D=20 +btrim(emma_member_name_first) , emma_member_name_last =3D=20 +btrim(emma_member_name_last) ;''; + set_account_id_sql :=3D ''UPDATE '' || import_table || '' SET=20 +emma_account_id =3D '' || account_id; + set_default_active_status_sql :=3D ''UPDATE '' || import_table || '= +' SET=20 +emma_member_status_id =3D 1''; + set_errors_for_null_email_sql :=3D ''UPDATE '' || import_table || '= +' SET=20 +emma_member_status_id =3D 2 WHERE emma_member_email IS NULL''; + record_null_email_count_sql :=3D ''UPDATE '' || import_history_tabl= +e ||=20 +'' SET emma_import_null_email_count =3D (SELECT COUNT(*) FROM '' ||=20 +import_table || '' WHERE emma_member_email IS NULL) WHERE=20 +emma_import_history_id =3D'' || import_history_id; + set_errors_for_invalid_email_sql :=3D ''UPDATE '' || import_table |= +| ''=20=20 +SET emma_member_status_id =3D 2 WHERE emma_member_email !~* '' || email_re= +gex; + record_invalid_email_count_sql :=3D ''UPDATE '' || import_history_t= +able=20 +|| '' SET emma_import_invalid_email_count =3D ( SELECT COUNT(*) FROM '' ||= +=20 +import_table || '' WHERE emma_member_email !~* '' || email_regex || '' )= +=20 +WHERE emma_import_history_id =3D'' || import_history_id; + get_dupes_in_import_sql :=3D ''SELECT emma_member_email,=20 +emma_member_status_id FROM '' || import_table || '' GROUP BY=20 +emma_member_email, emma_member_status_id having count(*) > 1''; + insert_dupes_sql :=3D ''INSERT INTO '' || dupe_table || '' SELECT = +*=20 +FROM '' || import_table || '' WHERE LOWER(emma_member_email) =3D LOWER('' |= +|=20 +member_table || ''.emma_member_email)''; + record_table_dupe_count_sql :=3D ''UPDATE '' || import_history_tabl= +e ||=20 +'' SET emma_import_table_dupe_email_count =3D (SELECT COUNT(*) FROM '' ||= +=20 +import_table || '' WHERE emma_member_email =3D LOWER('' || member_table ||= +=20 +''.emma_member_email)) WHERE emma_import_history_id =3D'' || import_history= +_id; + remove_dupes_from_import_table_sql :=3D ''DELETE FROM '' || import_= +table=20 +|| '' WHERE LOWER(emma_member_email) =3D LOWER('' || member_table ||=20 +''.emma_member_email)''; + create_clean_import_file_sql :=3D ''COPY '' || import_table || '' T= +O ''=20 +|| quote_literal(clean_import_file) || '' WITH NULL AS '' ||=20=20 +null_single_quotes; + create_members_groups_ids_file_sql :=3D ''COPY '' || import_table |= +|=20 +'' (emma_member_id) TO '' || quote_literal(members_groups_ids_file) || ''= +=20 +WITH NULL AS '' || null_single_quotes; + empty_import_table_sql :=3D ''TRUNCATE '' || import_table; + upload_clean_import_sql :=3D ''COPY '' || member_table || '' FROM '= +' ||=20 +quote_literal(clean_import_file) || '' WITH NULL AS '' ||=20=20 +null_single_quotes; + upload_members_groups_ids_sql :=3D ''COPY '' || members_groups_ids_= +table=20 +|| '' (emma_member_id) FROM '' || quote_literal(members_groups_ids_file) ||= +=20 +'' WITH NULL AS '' || null_single_quotes; + empty_members_groups_ids_sql :=3D ''TRUNCATE '' ||=20 +members_groups_ids_table; + empty_members_dupes_sql :=3D ''TRUNCATE '' || dupe_table; + vacuum_sql :=3D ''VACUUM '' || member_table || ''; VACUUM '' ||=20 +import_table || ''; VACUUM '' || container_table || ''; VACUUM '' ||=20 +members_groups_table || ''; VACUUM '' || members_groups_ids_table || '';=20 +VACUUM '' || dupe_table; + + -- BEGIN ACTIVITY + -- Create the filtered import file with the + EXECUTE create_import_file_sql; + -- Load data from the filtered file to the import table + EXECUTE upload_to_import_table_sql; + -- Set account id in import table + EXECUTE set_account_id_sql; + -- Set the status of all the records to 1 + EXECUTE set_default_active_status_sql; + -- Clean personalization data + EXECUTE clean_personalization_fields_sql; + EXECUTE clean_personalization_fields_sql2; + -- Set the status to error for all NULL emails + EXECUTE set_errors_for_null_email_sql; + -- Record the count of null emails + EXECUTE record_null_email_count_sql; + -- Set the status to error for all invalid emails + EXECUTE set_errors_for_invalid_email_sql; + -- Record the count of invalid emails + EXECUTE record_invalid_email_count_sql; + + -- Remove duplicates in import table (originally in file) + FOR duplicate_record IN EXECUTE get_dupes_in_import_sql LOOP + IF duplicate_record.emma_member_email IS NOT NULL THEN + FOR replacement_record IN EXECUTE '' SELECT * FROM '' |= +|=20 +import_table || '' WHERE emma_member_email =3D '' ||=20 +quote_literal(duplicate_record.emma_member_email) || '' ORDER BY=20 +emma_member_id LIMIT 1'' LOOP + escape_first_name :=3D quote_literal=20 +(replacement_record.emma_member_name_first); + escape_last_name :=3D quote_literal=20 +(replacement_record.emma_member_name_last); + escape_email :=3D quote_literal=20 +(replacement_record.emma_member_email); + escape_status_id :=3D=20 +quote_literal(replacement_record.emma_member_status_id); + -- Record count of dupes + FOR dupe_record_count IN EXECUTE ''SELECT COUNT= +(*)=20 +AS count FROM '' || import_table || '' WHERE LOWER(emma_member_email) =3D= +=20 +LOWER('' || escape_email || '')'' LOOP + EXECUTE ''UPDATE '' ||=20 +import_history_table || '' SET emma_import_file_dupe_email_count =3D'' ||= +=20 +dupe_record_count.count; + END LOOP; + FOR primary_dupe_record IN EXECUTE ''SELECT=20 +MAX(emma_member_id) AS max_id FROM '' || import_table || '' WHERE=20 +LOWER(emma_member_email) =3D LOWER('' || escape_email || '')'' LOOP + EXECUTE ''UPDATE '' || import_table || = +''=20=20 +SET emma_member_status_id =3D 5 WHERE emma_member_id =3D '' ||=20 +primary_dupe_record.max_id; + EXECUTE ''DELETE FROM '' || import_tabl= +e=20 +|| '' WHERE emma_member_email =3D '' ||=20 +quote_literal(duplicate_record.emma_member_email) || '' AND=20 +emma_member_status_id !=3D 5''; + EXECUTE ''UPDATE '' || import_table || = +''=20=20 +SET emma_member_status_id =3D 1 WHERE emma_member_status_id =3D 5''; + END LOOP; + import_dupe_count :=3D import_dupe_count + 1; + END LOOP; + END IF; + END LOOP; + + -- Move dupes over to the dupe table + EXECUTE insert_dupes_sql; + -- Record the count of dupes from import to members + EXECUTE record_table_dupe_count_sql; + -- Delete the dupes from the import table + EXECUTE remove_dupes_from_import_table_sql; + -- Create clean import file + EXECUTE create_clean_import_file_sql; + -- Create groups_id file + EXECUTE create_members_groups_ids_file_sql; + -- Empty import table + EXECUTE empty_import_table_sql; + -- Upload clean members from import + EXECUTE upload_clean_import_sql; + -- Upload group ids + EXECUTE upload_members_groups_ids_sql; + + -- Associate to groups + groups :=3D string_to_array(group_list, '',''); + if array_lower(groups, 1) IS NOT NULL THEN + FOR i IN array_lower(groups, 1)..array_upper(groups, 1) LOOP + EXECUTE ''INSERT INTO '' || members_groups_ids_table |= +|=20 +'' SELECT '' || member_table || ''.emma_member_id FROM ONLY '' ||=20 +member_table || '' WHERE LOWER('' || member_table || ''.emma_member_email) = +=3D=20 +LOWER('' || dupe_table || ''.emma_member_email) AND '' || member_table ||= +=20 +''.emma_member_id NOT IN (SELECT '' || members_groups_table ||=20 +''.emma_member_id FROM '' || members_groups_table || '' WHERE '' ||=20 +members_groups_table || ''.emma_group_id =3D '' || groups[i] || '') AND '' = +||=20 +member_table || ''.emma_member_id NOT IN (SELECT emma_member_id FROM '' ||= +=20 +members_groups_ids_table || '')''; + EXECUTE ''DELETE FROM '' || members_groups_ids_table |= +|=20 +'' WHERE emma_member_id IN (SELECT emma_member_id FROM '' ||=20 +members_groups_table || '' WHERE emma_group_id =3D '' || groups[i] || '' )'= +'; + EXECUTE ''INSERT INTO '' || members_groups_table || ''= +=20 +SELECT DISTINCT '' || groups[i] || '' AS emma_group_id, emma_member_id FRO= +M=20 +'' || members_groups_ids_table; + END LOOP; + END IF; + +Any pointers on large plpgsql operations are appreciated. Especially when= +=20 +more than one instance is runinng. Thanks. + + + +--=20 +marcus whitney + +chief architect : cold feet creative + +www.coldfeetcreative.com + +800.595.4401 +=A0 + + +cold feet presents emma + +email marketing for discriminating + +organizations everywhere + +visit www.myemma.com + +From pgsql-performance-owner@postgresql.org Wed Jun 2 18:32:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B6F0D1DFB5 + for ; + Wed, 2 Jun 2004 18:32: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 08268-10 + for ; + Wed, 2 Jun 2004 21:32:38 +0000 (GMT) +Received: from ml-hw5.monsterlabs.com (ml-hw5.monsterlabs.com + [216.183.105.167]) + by svr1.postgresql.org (Postfix) with SMTP id D5834D1D11B + for ; + Wed, 2 Jun 2004 18:32:10 -0300 (ADT) +Received: (qmail 4273 invoked from network); 2 Jun 2004 21:32:12 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.15?) + (64.3.242.80) + by ml-hw5.monsterlabs.com with SMTP; 2 Jun 2004 21:32:12 -0000 +From: Marcus Whitney +Reply-To: marcus@coldfeetcreative.com +Organization: Coldfeet Creative +To: pgsql-performance@postgresql.org +Subject: Re: Inherited Tables Performance +Date: Wed, 2 Jun 2004 16:27:28 -0500 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200406021627.28906.marcus@coldfeetcreative.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/21 +X-Sequence-Number: 7079 + +Is there any crossover in performance with sibling inherited tables?=20=20 + +For Ex.=20 + +if I have a parent table called : people + +A child of 'people' called: Adults + and +A child of 'people' called: Kids + +Does the work I do to Adults, namely copies, huge updates and such ever aff= +ect=20 +the performance of Kids? + +Thanks. + + +--=20 +marcus whitney + +chief architect : cold feet creative + +www.coldfeetcreative.com + +800.595.4401 +=A0 + + +cold feet presents emma + +email marketing for discriminating + +organizations everywhere + +visit www.myemma.com + +From pgsql-performance-owner@postgresql.org Wed Jun 2 18:31:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7755BD1B1AE + for ; + Wed, 2 Jun 2004 18:31: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 45136-05 + for ; + Wed, 2 Jun 2004 21:31:25 +0000 (GMT) +Received: from gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C277D1B1BD + for ; + Wed, 2 Jun 2004 18:31:19 -0300 (ADT) +Received: from gary (unverified [192.168.1.2]) + by gpdnet.co.uk (SurgeMail 1.8g3) with ESMTP id 226 + for ; Wed, 02 Jun 2004 23:31:58 +0100 +From: "Gary Doades" +To: +Date: Wed, 02 Jun 2004 22:31:27 +0100 +MIME-Version: 1.0 +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +Message-ID: <40BE553F.32703.10C5956B@localhost> +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AE4A@Herge.rcsinc.local> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Server: High Performance Mail Server - http://surgemail.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/20 +X-Sequence-Number: 7078 + +On 2 Jun 2004 at 16:45, Merlin Moncure wrote: + +> +> 'better' does not mean 'faster'. Win32 has a pretty decent journaling +> filesytem (ntfs) and a good I/O subsystem which includes IPC. Process +> management is poor compared to newer linux kernels but this is +> unimportant except in extreme cases. Right now the win32 native does +> not sync() (but does fsync()). So, the performance is somewhere between +> fsync = off and fsync = on (probably much closer to fsync = on). It is +> reasonable to assume that the win32 port will outperform the unix +> versions at many tasks (at the expense of safety) until the new sync() +> code is put in. +> +> If tested on the same source base, 40-60% differences can only be coming +> from the I/O subsystem. There are other factors which aren't clear from +> this exchange like what version of gcc, etc. +> + +Hmm, interesting. + +I've been running the Win32 port for a couple of weeks now. Using the +same database as a Linux 2.6 system. Same processor and memory +but different disks. + +Linux system has 10K rpm SCSI disks +Windows has 7200 rpm serial ATA disks. + +When a lot of IO is involved the performance differences are very mixed +as I would expect. Sometimes Windows wins, sometimes Linux. + +BUT, very consistently, when NO IO is involved then the Win32 port is +always around 20% slower than Linux. In cases where the EXPLAIN +ANALYZE results are different I have disregarded. In all the cases that +the EXPLAIN ANALYZE results are the same and no IO is involved the +Win32 port is slower. + +Currently I am putting this down to the build/gcc differences. I can't see +why there should be this difference otherwise. (memory +management??) + +Regards, +Gary. + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 18:39:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A17B4D1B1CD + for ; + Wed, 2 Jun 2004 18:39: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 54409-02 + for ; + Wed, 2 Jun 2004 21:39:37 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 59A4DD1B1AE + for ; + Wed, 2 Jun 2004 18:39:33 -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 1BVdRx-0000wf-00; Wed, 02 Jun 2004 17:39:05 -0400 +To: "Matthew Nuzum" +Cc: "'Tom Lane'" , "'Greg Stark'" , + "'Vitaly Belman'" , , + "'Bryan Encina'" , + "'Matthew Nuzum'" +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +References: <20040602184818.32370778FA@cust1.strato.net> +In-Reply-To: <20040602184818.32370778FA@cust1.strato.net> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Jun 2004 17:39:04 -0400 +Message-ID: <87vfi94p3b.fsf@stark.xeocode.com> +Lines: 54 +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-Archive-Number: 200406/22 +X-Sequence-Number: 7080 + +"Matthew Nuzum" writes: + +> I have colinux running on a Fedora Core 1 image. I have the rhdb 3 (or +> PostgreSQL RedHat Edition 3) on it running. Here are tests with fsync on +> and off: +> FSYNC OFF FSYNC ON RUN +> 136.9 142.0 124.5 149.1 1 +> 122.1 126.7 140.1 169.7 2 +> 125.7 148.7 147.4 180.4 3 +> 103.3 136.7 136.8 166.3 4 +> 126.5 146.1 152.3 187.9 5 +> 114.4 133.3 144.8 176.7 6 +> 124.0 146.5 143.3 175.0 7 +> 121.7 166.8 147.8 180.5 8 +> 127.3 151.8 146.7 180.0 9 +> 124.6 143.0 137.2 167.5 10 +> -------------------------------------- +> 122.7 144.2 142.1 173.3 AVG +> +> I hope those numbers' formatting come through all right. + +No, they didn't. You used tabs? Are they four space tabs or 8 space tabs? +I assume 4 space tabs, but then what is the meaning of the four columns? +You have two columns for each fsync setting? One's under Windows and one's +under Vmware? Which is which? + +> It occurs to me that the fsync may be performed to the linux filesystem, but +> this filesystem is merely a file on the windows drive. Would Windows cache +> this file? It's 2GB in size, so if it did, it would only be able to cache +> part of it. + +Well VMWare certainly doesn't know that the linux process called fsync. For +all it knows the Linux kernel just schedule the i/o because it felt it was +time. + +So the question is how does VMWare alway handle i/o normally. Does it always +handle i/o from the Guest OS synchronously or does it buffer it via the +Host OS's i/o system. + +I'm actually not sure which it does, it could be doing something strange. But +does seem most likely that it lets Windows buffer the writes, or does so +itself. It might also depend on whether you're using raw disks or a virtual +disk file. Undoable disks would throw another wrench in the works entirely. + +Note that "caching" isn't really the question. It doesn't have to cache the +entire 2GB file or even very much of it. It just has to store the block that +linux wants to write and report success to linux without waiting for the disk +to report success. Linux will then think the file is sync'd to disk and allow +postgres to continue with the next transaction without actually waiting for +the physical disk to spin around to the right place and the head to seek and +perform the write. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 22:33:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1100ED1B1BD + for ; + Wed, 2 Jun 2004 22: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 30602-01 + for ; + Thu, 3 Jun 2004 01:33:32 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 003E6D1B1AE + for ; + Wed, 2 Jun 2004 22:33:27 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i531XNWL094135; Thu, 3 Jun 2004 09:33:24 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <40BE8216.5000802@familyhealth.com.au> +Date: Thu, 03 Jun 2004 09:42:46 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "W.H. van Atteveldt" +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres query optimization with varchar fields +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-Archive-Number: 200406/23 +X-Sequence-Number: 7081 + +> I am investigating whether it is useful to directly query a database +> containing a rather large text corpus (order of magnitude 100k - 1m +> newspaper articles, so around 100 million words), or whether I should +> use third party text indexing services. I want to know things such as: +> how often is a certain word (or pattern) mentioned in an article and how +> often it is mentioned with the condition that another word is nearby +> (same article or n words distant). + +You really want to use the contrib/tsearch2 module that comes already +with PostgreSQL. + +cd contrib/tsearch2 +gmake install +psql < tsearch2.sql +more README.tsearch2 + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 23:00:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CB86D1B341 + for ; + Wed, 2 Jun 2004 23:00: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 37695-04 + for ; + Thu, 3 Jun 2004 02:00:47 +0000 (GMT) +Received: from ms-smtp-05.tampabay.rr.com (ms-smtp-05-smtplb.tampabay.rr.com + [65.32.5.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 8614FD1B33B + for ; + Wed, 2 Jun 2004 23:00:40 -0300 (ADT) +Received: from [192.168.0.112] (222-60.26-24.tampabay.rr.com [24.26.60.222]) + by ms-smtp-05.tampabay.rr.com (8.12.10/8.12.7) with ESMTP id + i5320cJI017226; Wed, 2 Jun 2004 22:00:39 -0400 (EDT) +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +From: Matthew Nuzum +To: Greg Stark +Cc: "'Tom Lane'" , "'Vitaly Belman'" , + pgsql-performance@postgresql.org, + "'Bryan Encina'" , + "'Matthew Nuzum'" +In-Reply-To: <87vfi94p3b.fsf@stark.xeocode.com> +References: <20040602184818.32370778FA@cust1.strato.net> + <87vfi94p3b.fsf@stark.xeocode.com> +Content-Type: text/plain +Organization: Followers.net, Inc. +Message-Id: <1086228031.2766.28.camel@ip112> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 02 Jun 2004 22:00:33 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Symantec AntiVirus Scan Engine +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/24 +X-Sequence-Number: 7082 + +On Wed, 2004-06-02 at 17:39, Greg Stark wrote: +> "Matthew Nuzum" writes: +> +> > I have colinux running on a Fedora Core 1 image. I have the rhdb 3 (or +> > PostgreSQL RedHat Edition 3) on it running. Here are tests with fsync on +> > and off: +> > FSYNC OFF FSYNC ON RUN +> > 136.9 142.0 124.5 149.1 1 +> > 122.1 126.7 140.1 169.7 2 +> > 125.7 148.7 147.4 180.4 3 +> > 103.3 136.7 136.8 166.3 4 +> > 126.5 146.1 152.3 187.9 5 +> > 114.4 133.3 144.8 176.7 6 +> > 124.0 146.5 143.3 175.0 7 +> > 121.7 166.8 147.8 180.5 8 +> > 127.3 151.8 146.7 180.0 9 +> > 124.6 143.0 137.2 167.5 10 +> > -------------------------------------- +> > 122.7 144.2 142.1 173.3 AVG +> > +> > I hope those numbers' formatting come through all right. +> +> No, they didn't. You used tabs? Are they four space tabs or 8 space tabs? +> I assume 4 space tabs, but then what is the meaning of the four columns? +> You have two columns for each fsync setting? One's under Windows and one's +> under Vmware? Which is which? +> +Sorry that wasn't clear. The pgbench program puts out two numbers, +can't remember what they are, I think one number included the time to +make the connection. Therefore, the first two columns represent the two +values presented from pgbench with FSYNC off. The second two columns +are those same to figures but with FSYNC ON. The 5th column is the +run. I did 10 runs and included the output of all runs so that incase +anything significant could be gleaned from the details, the data would +be there. + +The executive summary is this: +Tom was curious if colinux might be deceiving the applications that +expect the fsync to occur. He suspected that pgbench run with and +without fsync enabled might reveal something. Therefore: +FSYNC ON: 142.1 +FSYNC OFF: 122.7 + +Having FSYNC off seems to yield faster results. + +I'd like some input on a more demanding test though, because these tests +run so quickly I can't help but be suspicious of their accuracy. When +there are two OSs involved, it seems like the momentary activity of a +background process could skew these results. + +> > It occurs to me that the fsync may be performed to the linux filesystem, but +> > this filesystem is merely a file on the windows drive. Would Windows cache +> > this file? It's 2GB in size, so if it did, it would only be able to cache +> > part of it. +> +> Well VMWare certainly doesn't know that the linux process called fsync. For +> all it knows the Linux kernel just schedule the i/o because it felt it was +> time. +> +> So the question is how does VMWare alway handle i/o normally. Does it always +> handle i/o from the Guest OS synchronously or does it buffer it via the +> Host OS's i/o system. +We probably will never know what the internal workings of VMWare are +like because it is a closed source program. I'm not slighting them, I +have purchased a license of VMWare and use it for my software testing. +However, colinux is an open source project and we can easily find out +how they handle this. I have little interest in this as I use this +merely as a tool to speed up my application development and do not run +any critical services what-so-ever. + +> +> I'm actually not sure which it does, it could be doing something strange. But +> does seem most likely that it lets Windows buffer the writes, or does so +> itself. It might also depend on whether you're using raw disks or a virtual +> disk file. Undoable disks would throw another wrench in the works entirely. +In these tests I'm using a virtual disk file. This is a 2GB file on the +hard drive that linux sees as a disk partition. Colinux does not +support undoable disks in the way that vmware does. Their wiky site +does not mention anything tricky being done to force disk writes to +actually be written; the implication therefore is that it leaves the i/o +completely at the discretion of XP. Also note that XP Pro and 2000 Pro +both offer different caching options for the user to choose so unless it +does something to actually force a write the answer is probably "who +knows." + +> +> Note that "caching" isn't really the question. It doesn't have to cache the +> entire 2GB file or even very much of it. It just has to store the block that +> linux wants to write and report success to linux without waiting for the disk +> to report success. Linux will then think the file is sync'd to disk and allow +> postgres to continue with the next transaction without actually waiting for +> the physical disk to spin around to the right place and the head to seek and +> perform the write. + +That's interesting to know. I wondered about that. + +So, my summary is this: +If you develop applications in windows that run in linux and you need a +testing platform you may like colinux a lot because of the following: + * It's purchase price is 0 + * It's seems to be capable of running any (or at least many) +distribution based on 2.4 kernel + * It appears to run much faster than VMWare (maybe because it has far +fewer features, including the ability to run X apps unless you use VNC +or a separate X server) +* When idle it causes no apparent load on the CPU. This is the best +part in my opinion. VMWare causes a drag on the system even when idle +and especially when active. With colinux you can simply minimize the +console or run it as a service and forget about it until you need it. + +You may prefer VMWare if you need: + * GUI setup tools + * Full PC hardware support (sound, fb, etc) + * Undoable disk support + * Painless install (colinux isn't hard but it's not "shrink wrap" +quality yet) + * Need special kernel features. Colinux uses its own kernel which has +been ported to windows. + +OK, this horse is dead... anyone else want to kick it? Just kidding... + +If you want me to test something for you, I'd be happy to. Be specific +and give me the details and I'll run it through the wringer on Friday. +Oh, and don't ask me to download anything big please. 25 of us share a +56k modem there so bandwidth is limited. + +Hope this is helpful to someone, have a nice day. + +-- +Matthew Nuzum +Followers.net, Inc. + + +From pgsql-performance-owner@postgresql.org Wed Jun 2 23:13:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B590BD1B18F + for ; + Wed, 2 Jun 2004 23:13: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 41409-01 + for ; + Thu, 3 Jun 2004 02:13:09 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CD92D1B33B + for ; + Wed, 2 Jun 2004 23:13:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i532ClbP015926; + Wed, 2 Jun 2004 22:12:47 -0400 (EDT) +To: Matthew Nuzum +Cc: Greg Stark , "'Vitaly Belman'" , + pgsql-performance@postgresql.org, + "'Bryan Encina'" , + "'Matthew Nuzum'" +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +In-reply-to: <1086228031.2766.28.camel@ip112> +References: <20040602184818.32370778FA@cust1.strato.net> + <87vfi94p3b.fsf@stark.xeocode.com> <1086228031.2766.28.camel@ip112> +Comments: In-reply-to Matthew Nuzum + message dated "Wed, 02 Jun 2004 22:00:33 -0400" +Date: Wed, 02 Jun 2004 22:12:47 -0400 +Message-ID: <15925.1086228767@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/25 +X-Sequence-Number: 7083 + +Matthew Nuzum writes: +> I'd like some input on a more demanding test though, because these tests +> run so quickly I can't help but be suspicious of their accuracy. + +So increase the number of transactions tested (-t switch to pgbench). + +Be aware also that you really want -s (database size scale factor) to +exceed -c (number of concurrent clients) for meaningful results. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 3 00:51:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C79AD1B17C + for ; + Thu, 3 Jun 2004 00:51: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 68381-02 + for ; + Thu, 3 Jun 2004 03:51: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 71B7AD1B16B + for ; + Thu, 3 Jun 2004 00:51:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i533pQwb016588; + Wed, 2 Jun 2004 23:51:26 -0400 (EDT) +To: "Merlin Moncure" +Cc: "Shachar Shemesh" , + pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on VMWare vs Windows vs CoLinux +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AE4A@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AE4A@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Wed, 02 Jun 2004 16:45:27 -0400" +Date: Wed, 02 Jun 2004 23:51:25 -0400 +Message-ID: <16587.1086234685@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/26 +X-Sequence-Number: 7084 + +"Merlin Moncure" writes: +> ... Right now the win32 native does +> not sync() (but does fsync()). So, the performance is somewhere between +> fsync = off and fsync = on (probably much closer to fsync = on). It is +> reasonable to assume that the win32 port will outperform the unix +> versions at many tasks (at the expense of safety) until the new sync() +> code is put in. + +... which was three days ago. Why are we still speculating? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 3 10:07:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CD48FD1B193 + for ; + Thu, 3 Jun 2004 10: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 22233-10 + for ; + Thu, 3 Jun 2004 13:07:48 +0000 (GMT) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id CF2A8D1B173 + for ; + Thu, 3 Jun 2004 10:07:44 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BVrwi-000Cm9-0Z; Thu, 03 Jun 2004 14:07:48 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 4C62916707; Thu, 3 Jun 2004 14:07:47 +0100 (BST) +Message-ID: <40BF22A5.8060102@archonet.com> +Date: Thu, 03 Jun 2004 14:07:49 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.6 (X11/20040502) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: David Teran +Cc: PgSQL Performance ML +Subject: Re: select max(id) from aTable is very slow +References: <62A9E13D-60A0-11D8-B420-000A95A6F0DC@cluster9.com> +In-Reply-To: <62A9E13D-60A0-11D8-B420-000A95A6F0DC@cluster9.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/27 +X-Sequence-Number: 7085 + +David Teran wrote: +> Hi, +> +> we have a table with about 6.000.000 rows. There is an index on a +> column with the name id which is an integer and serves as primary key. +> +> When we execute select max(id) from theTable; it takes about 10 +> seconds. Explain analyze returns: + +Due to the open-ended nature of PG's aggregate function system, it can't +see inside the max() function to realise it doesn't need all the values. + +Fortune favours the flexible however - the simple workaround is to use +the equivalent: + SELECT id FROM theTable ORDER BY id DESC LIMIT 1; + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Jun 3 18:42:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 39E50D1B349 + for ; + Thu, 3 Jun 2004 18:42: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 91793-06 + for ; + Thu, 3 Jun 2004 21:42:52 +0000 (GMT) +Received: from ml-hw5.monsterlabs.com (ml-hw5.monsterlabs.com + [216.183.105.167]) + by svr1.postgresql.org (Postfix) with SMTP id 9B5C9D1B343 + for ; + Thu, 3 Jun 2004 18:42:48 -0300 (ADT) +Received: (qmail 16217 invoked from network); 3 Jun 2004 21:42:50 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.15?) + (64.3.242.80) + by ml-hw5.monsterlabs.com with SMTP; 3 Jun 2004 21:42:50 -0000 +From: Marcus Whitney +Reply-To: marcus@coldfeetcreative.com +Organization: Coldfeet Creative +To: +Subject: Re: Pl/Pgsql Functions running simultaneously +Date: Thu, 3 Jun 2004 16:38:03 -0500 +User-Agent: KMail/1.6.1 +References: <200406021608.56919.marcus@coldfeetcreative.com> +In-Reply-To: <200406021608.56919.marcus@coldfeetcreative.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200406031638.03409.marcus@coldfeetcreative.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/28 +X-Sequence-Number: 7086 + +Am I on the wrong list to ask this question, or does this list usually have= +=20 +low activity? Just asking because I am new and I need to know where to ask= +=20 +this question. Thanks. + +On Wednesday 02 June 2004 16:08, Marcus Whitney wrote: +> Hello all, +> +> I have an import function that I have been working on for some time now, +> and it performed well up until recently. It is doing a lot, and because +> the queries are not cached, I am not sure if that is what the problem is.= +=20 +> If a function takes a while, does it lock any of the tables it is +> accessing, even for SELECT? +> +> Below is the bulk of the function: +> +> -- set sql statement variables +> create_import_file_sql :=3D ''COPY '' || container_table || '' ('= +' || +> filtered_container_columns || '') TO '' || +> quote_literal(formatted_import_file) || '' WITH NULL AS '' || +> null_single_quotes; +> upload_to_import_table_sql :=3D ''COPY '' || import_table || '' (= +'' +> || field_names || '') FROM '' || quote_literal(formatted_import_file) || = +'' +> WITH NULL AS '' || null_single_quotes; +> clean_personalization_fields_sql :=3D ''UPDATE '' || import_table= + || +> '' SET emma_member_email =3D btrim(emma_member_email, '' || +> quote_literal(quoted_single_quote) || '') , emma_member_name_first =3D +> btrim(emma_member_name_first, '' || quote_literal(quoted_single_quote) || +> '') , emma_member_name_last =3D btrim(emma_member_name_last, '' || +> quote_literal(quoted_single_quote) || '') ;''; +> clean_personalization_fields_sql2 :=3D ''UPDATE '' || import_tabl= +e || +> '' SET emma_member_email =3D btrim(emma_member_email) , +> emma_member_name_first =3D btrim(emma_member_name_first) ,=20=20 +> emma_member_name_last =3D +> btrim(emma_member_name_last) ;''; +> set_account_id_sql :=3D ''UPDATE '' || import_table || '' SET +> emma_account_id =3D '' || account_id; +> set_default_active_status_sql :=3D ''UPDATE '' || import_table ||= + '' +> SET emma_member_status_id =3D 1''; +> set_errors_for_null_email_sql :=3D ''UPDATE '' || import_table ||= + '' +> SET emma_member_status_id =3D 2 WHERE emma_member_email IS NULL''; +> record_null_email_count_sql :=3D ''UPDATE '' || import_history_ta= +ble +> || '' SET emma_import_null_email_count =3D (SELECT COUNT(*) FROM '' || +> import_table || '' WHERE emma_member_email IS NULL) WHERE +> emma_import_history_id =3D'' || import_history_id; +> set_errors_for_invalid_email_sql :=3D ''UPDATE '' || import_table= + || +> '' SET emma_member_status_id =3D 2 WHERE emma_member_email !~* '' || +> email_regex; record_invalid_email_count_sql :=3D ''UPDATE '' || +> import_history_table +> +> || '' SET emma_import_invalid_email_count =3D ( SELECT COUNT(*) FROM '' = +|| +> +> import_table || '' WHERE emma_member_email !~* '' || email_regex || '' ) +> WHERE emma_import_history_id =3D'' || import_history_id; +> get_dupes_in_import_sql :=3D ''SELECT emma_member_email, +> emma_member_status_id FROM '' || import_table || '' GROUP BY +> emma_member_email, emma_member_status_id having count(*) > 1''; +> insert_dupes_sql :=3D ''INSERT INTO '' || dupe_table || '' SELEC= +T * +> FROM '' || import_table || '' WHERE LOWER(emma_member_email) =3D LOWER(''= + || +> member_table || ''.emma_member_email)''; +> record_table_dupe_count_sql :=3D ''UPDATE '' || import_history_ta= +ble +> || '' SET emma_import_table_dupe_email_count =3D (SELECT COUNT(*) FROM ''= + || +> import_table || '' WHERE emma_member_email =3D LOWER('' || member_table || +> ''.emma_member_email)) WHERE emma_import_history_id =3D'' || +> import_history_id; remove_dupes_from_import_table_sql :=3D ''DELETE FROM = +'' +> || import_table +> +> || '' WHERE LOWER(emma_member_email) =3D LOWER('' || member_table || +> +> ''.emma_member_email)''; +> create_clean_import_file_sql :=3D ''COPY '' || import_table || ''= + TO +> '' +> +> || quote_literal(clean_import_file) || '' WITH NULL AS '' || +> +> null_single_quotes; +> create_members_groups_ids_file_sql :=3D ''COPY '' || import_table= + || +> '' (emma_member_id) TO '' || quote_literal(members_groups_ids_file) || '' +> WITH NULL AS '' || null_single_quotes; +> empty_import_table_sql :=3D ''TRUNCATE '' || import_table; +> upload_clean_import_sql :=3D ''COPY '' || member_table || '' FROM= + '' +> || quote_literal(clean_import_file) || '' WITH NULL AS '' || +> null_single_quotes; +> upload_members_groups_ids_sql :=3D ''COPY '' || +> members_groups_ids_table +> +> || '' (emma_member_id) FROM '' || quote_literal(members_groups_ids_file) = +|| +> +> '' WITH NULL AS '' || null_single_quotes; +> empty_members_groups_ids_sql :=3D ''TRUNCATE '' || +> members_groups_ids_table; +> empty_members_dupes_sql :=3D ''TRUNCATE '' || dupe_table; +> vacuum_sql :=3D ''VACUUM '' || member_table || ''; VACUUM '' || +> import_table || ''; VACUUM '' || container_table || ''; VACUUM '' || +> members_groups_table || ''; VACUUM '' || members_groups_ids_table || ''; +> VACUUM '' || dupe_table; +> +> -- BEGIN ACTIVITY +> -- Create the filtered import file with the +> EXECUTE create_import_file_sql; +> -- Load data from the filtered file to the import table +> EXECUTE upload_to_import_table_sql; +> -- Set account id in import table +> EXECUTE set_account_id_sql; +> -- Set the status of all the records to 1 +> EXECUTE set_default_active_status_sql; +> -- Clean personalization data +> EXECUTE clean_personalization_fields_sql; +> EXECUTE clean_personalization_fields_sql2; +> -- Set the status to error for all NULL emails +> EXECUTE set_errors_for_null_email_sql; +> -- Record the count of null emails +> EXECUTE record_null_email_count_sql; +> -- Set the status to error for all invalid emails +> EXECUTE set_errors_for_invalid_email_sql; +> -- Record the count of invalid emails +> EXECUTE record_invalid_email_count_sql; +> +> -- Remove duplicates in import table (originally in file) +> FOR duplicate_record IN EXECUTE get_dupes_in_import_sql LOOP +> IF duplicate_record.emma_member_email IS NOT NULL THEN +> FOR replacement_record IN EXECUTE '' SELECT * FROM '' +> || import_table || '' WHERE emma_member_email =3D '' || +> quote_literal(duplicate_record.emma_member_email) || '' ORDER BY +> emma_member_id LIMIT 1'' LOOP +> escape_first_name :=3D quote_literal +> (replacement_record.emma_member_name_first); +> escape_last_name :=3D quote_literal +> (replacement_record.emma_member_name_last); +> escape_email :=3D quote_literal +> (replacement_record.emma_member_email); +> escape_status_id :=3D +> quote_literal(replacement_record.emma_member_status_id); +> -- Record count of dupes +> FOR dupe_record_count IN EXECUTE ''SELECT +> COUNT(*) AS count FROM '' || import_table || '' WHERE +> LOWER(emma_member_email) =3D LOWER('' || escape_email || '')'' LOOP +> EXECUTE ''UPDATE '' || +> import_history_table || '' SET emma_import_file_dupe_email_count =3D'' || +> dupe_record_count.count; +> END LOOP; +> FOR primary_dupe_record IN EXECUTE ''SELECT +> MAX(emma_member_id) AS max_id FROM '' || import_table || '' WHERE +> LOWER(emma_member_email) =3D LOWER('' || escape_email || '')'' LOOP +> EXECUTE ''UPDATE '' || import_table || +> '' SET emma_member_status_id =3D 5 WHERE emma_member_id =3D '' || +> primary_dupe_record.max_id; +> EXECUTE ''DELETE FROM '' || +> import_table +> +> || '' WHERE emma_member_email =3D '' || +> +> quote_literal(duplicate_record.emma_member_email) || '' AND +> emma_member_status_id !=3D 5''; +> EXECUTE ''UPDATE '' || import_table || +> '' SET emma_member_status_id =3D 1 WHERE emma_member_status_id =3D 5''; +> END LOOP; +> import_dupe_count :=3D import_dupe_count + 1; +> END LOOP; +> END IF; +> END LOOP; +> +> -- Move dupes over to the dupe table +> EXECUTE insert_dupes_sql; +> -- Record the count of dupes from import to members +> EXECUTE record_table_dupe_count_sql; +> -- Delete the dupes from the import table +> EXECUTE remove_dupes_from_import_table_sql; +> -- Create clean import file +> EXECUTE create_clean_import_file_sql; +> -- Create groups_id file +> EXECUTE create_members_groups_ids_file_sql; +> -- Empty import table +> EXECUTE empty_import_table_sql; +> -- Upload clean members from import +> EXECUTE upload_clean_import_sql; +> -- Upload group ids +> EXECUTE upload_members_groups_ids_sql; +> +> -- Associate to groups +> groups :=3D string_to_array(group_list, '',''); +> if array_lower(groups, 1) IS NOT NULL THEN +> FOR i IN array_lower(groups, 1)..array_upper(groups, 1) LOOP +> EXECUTE ''INSERT INTO '' || members_groups_ids_table +> || '' SELECT '' || member_table || ''.emma_member_id FROM ONLY '' || +> member_table || '' WHERE LOWER('' || member_table || ''.emma_member_email) +> =3D LOWER('' || dupe_table || ''.emma_member_email) AND '' || member_tabl= +e || +> ''.emma_member_id NOT IN (SELECT '' || members_groups_table || +> ''.emma_member_id FROM '' || members_groups_table || '' WHERE '' || +> members_groups_table || ''.emma_group_id =3D '' || groups[i] || '') AND '= +' || +> member_table || ''.emma_member_id NOT IN (SELECT emma_member_id FROM '' || +> members_groups_ids_table || '')''; +> EXECUTE ''DELETE FROM '' || members_groups_ids_table +> || '' WHERE emma_member_id IN (SELECT emma_member_id FROM '' || +> members_groups_table || '' WHERE emma_group_id =3D '' || groups[i] || '' = +)''; +> EXECUTE ''INSERT INTO '' || members_groups_table || = +'' +> SELECT DISTINCT '' || groups[i] || '' AS emma_group_id, emma_member_id +> FROM '' || members_groups_ids_table; +> END LOOP; +> END IF; +> +> Any pointers on large plpgsql operations are appreciated. Especially when +> more than one instance is runinng. Thanks. + +--=20 +marcus whitney + +chief architect : cold feet creative + +www.coldfeetcreative.com + +800.595.4401 +=A0 + + +cold feet presents emma + +email marketing for discriminating + +organizations everywhere + +visit www.myemma.com + +From pgsql-performance-owner@postgresql.org Thu Jun 3 20:09:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9377AD1B431 + for ; + Thu, 3 Jun 2004 20:09: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 13047-09 + for ; + Thu, 3 Jun 2004 23:09:17 +0000 (GMT) +Received: from corpmsx.gaiam.com (unknown [12.147.81.200]) + by svr1.postgresql.org (Postfix) with ESMTP id F3335D1B3AD + for ; + Thu, 3 Jun 2004 20:09:12 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C449BF.F47D01EE" +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Subject: Most transactions per second on largest box? +Date: Thu, 3 Jun 2004 17:10:26 -0600 +Message-ID: <8D36D5916571CB4489C2E4D0CAD6E89301BEE595@corpmsx.gaiam.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Most transactions per second on largest box? +Thread-Index: AcRJv1bSQBPjF2XISaimmbvF8nbVqw== +From: +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/29 +X-Sequence-Number: 7087 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C449BF.F47D01EE +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +This is a very general question but what is the largest linux box anyone +has run PostgreSQL on and what kind of concurrent transactions per +second have you seen?=20 + +=20 + +We have a client who has huge bursts of activity, coinciding with high +rated TV appearances, meaning hundreds of thousands of users registering +and logging in at the same time. + +=20 + +Currently we are running a dual cpu dell blade server on redhat linux +(2.4?) and PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC 2.96, +raid5 and am using sqlrelay for connection pooling. It works fine under +ordinary load but bogs down too much under these huge loads.=20 + +=20 + +I would love to be able to tell them that a specific box like a 2 ghz +quad xenon with 10 GB of ram, on a raid 10 server will get them x +concurrent transactions per second with x threads running. From that I +can give them a great estimate on how many registrations per minute +there money can buy, but right now all I can tell them is that if you +spend more money you will get more tps.=20 + +=20 + +Thanks for any info you may have.=20 + + +------_=_NextPart_001_01C449BF.F47D01EE +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

This is a very general question but what is the largest = +linux +box anyone has run PostgreSQL on and what kind of concurrent transactions p= +er +second have you seen?

+ +

 

+ +

We have a client who has huge bursts of activity, coinci= +ding +with high rated TV appearances, meaning hundreds of thousands of users +registering and logging in at the same time.

+ +

 

+ +

Currently we are running a dual cpu dell blade server on +redhat linux (2.4?) and PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by = +GCC +2.96, raid5 and am using sqlrelay for connection pooling.  It works fi= +ne +under ordinary load but bogs down too much under these huge loads.

+ +

 

+ +

I would love to be able to tell them that a specific box +like a 2 ghz quad xenon with 10 GB of ram, on a raid 10 server will get the= +m x concurrent +transactions per second with x threads running. From that I can give them a= + great +estimate on how many registrations per minute there money can buy, but right +now all I can tell them is that if you spend more money you will get more t= +ps.

+ +

 

+ +

Thanks for any info you may have.

+ +
+ + + + + +------_=_NextPart_001_01C449BF.F47D01EE-- + +From pgsql-performance-owner@postgresql.org Fri Jun 4 02:57:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B356DD1B1EC + for ; + Fri, 4 Jun 2004 02:57: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 28927-03 + for ; + Fri, 4 Jun 2004 05:57:53 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id A677DD1B18F + for ; + Fri, 4 Jun 2004 02:57: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 1BW7i4-0004c8-00; Fri, 04 Jun 2004 01:57:44 -0400 +To: +Cc: +Subject: Re: Most transactions per second on largest box? +References: <8D36D5916571CB4489C2E4D0CAD6E89301BEE595@corpmsx.gaiam.com> +In-Reply-To: <8D36D5916571CB4489C2E4D0CAD6E89301BEE595@corpmsx.gaiam.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 04 Jun 2004 01:57:43 -0400 +Message-ID: <87llj33lwo.fsf@stark.xeocode.com> +Lines: 48 +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-Archive-Number: 200406/30 +X-Sequence-Number: 7088 + + + writes: + +> Currently we are running a dual cpu dell blade server on redhat linux +> (2.4?) and PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC 2.96, +> raid5 and am using sqlrelay for connection pooling. It works fine under +> ordinary load but bogs down too much under these huge loads. + +I can't answer the question you asked. But I would suggest you upgrade your +compiler. 2.96 is just about the worst version of gcc to be using for +anything. It has known bugs where it just flatly miscompiles code, resulting +in programs that crash or behave strangely. + +Also postgresql 7.4 has lots of very nice performance improvements including +everyone's favourite, "IN" optimization. So you might consider upgrading to +7.4.2. + +> I would love to be able to tell them that a specific box like a 2 ghz +> quad xenon with 10 GB of ram, on a raid 10 server will get them x +> concurrent transactions per second with x threads running. From that I +> can give them a great estimate on how many registrations per minute +> there money can buy, but right now all I can tell them is that if you +> spend more money you will get more tps. + +Unfortunately nobody will be able to give you precise numbers since it will +depend a *lot* on the precise queries and database design you're working with. +There are also a lot of variables in the hardware design where you trade off +increasing cpus vs improving the disk subsystem and such. + +You're going to have to do some performance testing of your application on +different hardware and extrapolate from that. Unfortunately (or fortunately +depending on your billing model:) this can be a lot of work. It involves +setting up a database with a realistic quantity of data, and some sort of test +harness simulating users. + +In general terms though, several people have mentioned being happy with +Opteron servers, and generally people find spending money on good hardware +RAID cards with battery backed caches and more disks to spread data over to be +more effective than spending money on more or faster processors. + +If you benchmark your application on a given set of hardware and analyze where +your bottleneck is then people may be able to suggest what alternatives to +consider and may be able to give some idea of what type of improvement to +expect. But it takes actual data from vmstat, iostat, et al to do this +analysis. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Jun 4 09:10:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 04DDAD1B224 + for ; + Fri, 4 Jun 2004 09:10: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 50547-07 + for ; + Fri, 4 Jun 2004 12:10:47 +0000 (GMT) +Received: from postkontoret.flygtaxi.se (gateway.flygtaxi.se [212.37.18.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D07DD1B23F + for ; + Fri, 4 Jun 2004 09:10:43 -0300 (ADT) +Received: from [172.17.6.145] (helo=mksoft.nu) + by postkontoret.flygtaxi.se with esmtp (Exim 3.36 #1 (Debian)) + id 1BWDWx-0000cY-00 + for ; Fri, 04 Jun 2004 14:10:39 +0200 +Message-ID: <40C066C1.2090808@mksoft.nu> +Date: Fri, 04 Jun 2004 14:10:41 +0200 +From: =?ISO-8859-1?Q?Mikael_Kjellstr=F6m?= +User-Agent: Mozilla Thunderbird 0.5 (X11/20040306) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Planner problem +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/31 +X-Sequence-Number: 7089 + +Hi! + +I am having a bit of problem with the plan that the planner produces. + +First a little info: + +OS: Linux Debian +Version: PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc GCC) +3.3.3 (Debian 20040401) +CPU: AMD Athlon XP 2000+ +Memory: 1GB +Disk: 4 SCSI-3 UW 10000rpm in RAID 1 (mirror) mode + +shared_mem: 20000 +Sort mem: 8192 +effective_cache_size: 80000 + + +Row count for the tables involved: +priceavailable: 8564 +product: 3 +productCodeAlias: 7 +locationIATA: 3402 +locationConnection: 64 +price: 4402 + + +I have runned both vacuum full and vacuum analyze before I run my query +and shared_mem is set to 20000 + + +Here is the result I am getting: + +EXPLAIN ANALYZE +SELECT + CASE WHEN 'D' = 'A' THEN price.priceArrival ELSE price.priceDeparture +END AS price, + price.vatPercent AS vatPercent +FROM + priceavailable pa, + product product, + productCodeAlias productAlias, + locationiata la, + locationconnection lc, + price price +WHERE + pa.direction IN('D', 'B') + AND pa.productId = product.productId + AND product.productId = productAlias.productId + AND productAlias.productCode = 'TAXI' + AND pa.locationConnectionId = lc.locationConnectionId + AND lc.locationConnectionCode = 'RNB' + AND pa.locationId = la.locationId + AND la.iataCode = 'KB8' + AND price.pricegroupId = pa.priceGroupId + AND price.productId = product.productId + AND '2004-06-01 05:30:00.000000+02' BETWEEN price.validstartdate AND +price.validstopdate + AND product.organizationId = 1 + AND price.organizationId = product.organizationId + AND pa.deletionDate IS NULL + AND product.deletionDate IS NULL + AND la.deletionDate IS NULL + AND lc.deletionDate IS NULL + AND price.deletionDate IS NULL +; + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=2.14..17.16 rows=1 width=8) (actual +time=3274.196..4620.299 rows=1 loops=1) + -> Nested Loop (cost=2.14..13.49 rows=1 width=12) (actual +time=2643.441..4617.246 rows=47 loops=1) + Join Filter: (("outer".productid = "inner".productid) AND +("inner".pricegroupid = "outer".pricegroupid)) + -> Nested Loop (cost=0.00..7.72 rows=1 width=12) (actual +time=0.238..5.455 rows=111 loops=1) + -> Seq Scan on locationconnection lc (cost=0.00..1.80 +rows=1 width=4) (actual time=0.153..0.245 rows=1 loops=1) + Filter: ((locationconnectioncode = 'RNB'::text) +AND (deletiondate IS NULL)) + -> Index Scan using priceavailableix1 on priceavailable +pa (cost=0.00..5.91 rows=1 width=16) (actual time=0.067..4.182 rows=111 +loops=1) + Index Cond: (pa.locationconnectionid = +"outer".locationconnectionid) + Filter: (((direction = 'D'::text) OR (direction = +'B'::text)) AND (deletiondate IS NULL)) + -> Hash Join (cost=2.14..5.74 rows=2 width=24) (actual +time=0.058..39.116 rows=1243 loops=111) + Hash Cond: ("outer".productid = "inner".productid) + -> Index Scan using priceix2 on price (cost=0.00..3.41 +rows=23 width=20) (actual time=0.042..25.811 rows=4402 loops=111) + Index Cond: ('2004-06-01'::date <= validstopdate) + Filter: (('2004-06-01'::date >= validstartdate) +AND (deletiondate IS NULL) AND (organizationid = 1)) + -> Hash (cost=2.14..2.14 rows=1 width=12) (actual +time=0.132..0.132 rows=0 loops=1) + -> Nested Loop (cost=0.00..2.14 rows=1 width=12) +(actual time=0.088..0.123 rows=1 loops=1) + Join Filter: ("outer".productid = +"inner".productid) + -> Seq Scan on product (cost=0.00..1.04 +rows=1 width=8) (actual time=0.013..0.022 rows=3 loops=1) + Filter: ((organizationid = 1) AND +(deletiondate IS NULL)) + -> Seq Scan on productcodealias +productalias (cost=0.00..1.09 rows=1 width=4) (actual time=0.022..0.024 +rows=1 loops=3) + Filter: (productcode = 'TAXI'::text) + -> Index Scan using locationiataix4 on locationiata la +(cost=0.00..3.66 rows=1 width=4) (actual time=0.052..0.052 rows=0 loops=47) + Index Cond: ("outer".locationid = la.locationid) + Filter: ((iatacode = 'KB8'::text) AND (deletiondate IS NULL)) + Total runtime: 4620.852 ms + + +If I do an "set enable_nestloop = 0" and run the exact same question I get: + + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=150.55..154.20 rows=1 width=8) (actual +time=68.095..103.006 rows=1 loops=1) + Hash Cond: ("outer".locationid = "inner".locationid) + -> Hash Join (cost=145.65..149.29 rows=1 width=12) (actual +time=66.304..102.709 rows=47 loops=1) + Hash Cond: (("outer".productid = "inner".productid) AND +("outer".pricegroupid = "inner".pricegroupid)) + -> Hash Join (cost=2.15..5.75 rows=2 width=24) (actual +time=0.343..38.844 rows=1243 loops=1) + Hash Cond: ("outer".productid = "inner".productid) + -> Index Scan using priceix2 on price (cost=0.00..3.41 +rows=23 width=20) (actual time=0.053..26.225 rows=4402 loops=1) + Index Cond: ('2004-06-01'::date <= validstopdate) + Filter: (('2004-06-01'::date >= validstartdate) +AND (deletiondate IS NULL) AND (organizationid = 1)) + -> Hash (cost=2.14..2.14 rows=1 width=12) (actual +time=0.191..0.191 rows=0 loops=1) + -> Hash Join (cost=1.09..2.14 rows=1 width=12) +(actual time=0.174..0.184 rows=1 loops=1) + Hash Cond: ("outer".productid = +"inner".productid) + -> Seq Scan on product (cost=0.00..1.04 +rows=1 width=8) (actual time=0.017..0.025 rows=3 loops=1) + Filter: ((organizationid = 1) AND +(deletiondate IS NULL)) + -> Hash (cost=1.09..1.09 rows=1 width=4) +(actual time=0.073..0.073 rows=0 loops=1) + -> Seq Scan on productcodealias +productalias (cost=0.00..1.09 rows=1 width=4) (actual time=0.042..0.045 +rows=1 loops=1) + Filter: (productcode = 'TAXI'::text) + -> Hash (cost=143.50..143.50 rows=1 width=12) (actual +time=61.650..61.650 rows=0 loops=1) + -> Merge Join (cost=1.81..143.50 rows=1 width=12) +(actual time=59.914..61.419 rows=111 loops=1) + Merge Cond: ("outer".locationconnectionid = +"inner".locationconnectionid) + -> Index Scan using priceavailableix1 on +priceavailable pa (cost=0.00..141.57 rows=43 width=16) (actual +time=0.048..48.739 rows=6525 loops=1) + Filter: (((direction = 'D'::text) OR +(direction = 'B'::text)) AND (deletiondate IS NULL)) + -> Sort (cost=1.81..1.81 rows=1 width=4) (actual +time=0.215..0.290 rows=1 loops=1) + Sort Key: lc.locationconnectionid + -> Seq Scan on locationconnection lc +(cost=0.00..1.80 rows=1 width=4) (actual time=0.125..0.194 rows=1 loops=1) + Filter: ((locationconnectioncode = +'RNB'::text) AND (deletiondate IS NULL)) + -> Hash (cost=4.89..4.89 rows=1 width=4) (actual time=0.122..0.122 +rows=0 loops=1) + -> Index Scan using locationiataix1 on locationiata la +(cost=0.00..4.89 rows=1 width=4) (actual time=0.108..0.112 rows=1 loops=1) + Index Cond: (iatacode = 'KB8'::text) + Filter: (deletiondate IS NULL) +Total runtime: 103.563 ms + +Which is a lot faster than the original question. + +If I then enable nestloop again and lower the geqo_threshold from 11 +(default) to 5 and run the same query again I get: + + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=7.72..17.19 rows=1 width=8) (actual +time=9.752..42.278 rows=1 loops=1) + -> Nested Loop (cost=7.72..13.52 rows=1 width=12) (actual +time=5.698..41.079 rows=47 loops=1) + Join Filter: ("outer".productid = "inner".productid) + -> Nested Loop (cost=7.72..12.47 rows=1 width=28) (actual +time=5.663..39.992 rows=47 loops=1) + Join Filter: ("inner".productid = "outer".productid) + -> Hash Join (cost=7.72..11.37 rows=1 width=24) +(actual time=5.470..36.848 rows=111 loops=1) + Hash Cond: (("outer".pricegroupid = +"inner".pricegroupid) AND ("outer".productid = "inner".productid)) + -> Index Scan using priceix2 on price +(cost=0.00..3.41 rows=23 width=20) (actual time=0.050..26.475 rows=4402 +loops=1) + Index Cond: ('2004-06-01'::date <= +validstopdate) + Filter: (('2004-06-01'::date >= +validstartdate) AND (deletiondate IS NULL) AND (organizationid = 1)) + -> Hash (cost=7.72..7.72 rows=1 width=12) +(actual time=1.809..1.809 rows=0 loops=1) + -> Nested Loop (cost=0.00..7.72 rows=1 +width=12) (actual time=0.253..1.587 rows=111 loops=1) + -> Seq Scan on locationconnection lc + (cost=0.00..1.80 rows=1 width=4) (actual time=0.163..0.234 rows=1 loops=1) + Filter: ((locationconnectioncode += 'RNB'::text) AND (deletiondate IS NULL)) + -> Index Scan using priceavailableix1 +on priceavailable pa (cost=0.00..5.91 rows=1 width=16) (actual +time=0.070..0.965 rows=111 loops=1) + Index Cond: +(pa.locationconnectionid = "outer".locationconnectionid) + Filter: (((direction = +'D'::text) OR (direction = 'B'::text)) AND (deletiondate IS NULL)) + -> Seq Scan on productcodealias productalias +(cost=0.00..1.09 rows=1 width=4) (actual time=0.020..0.022 rows=1 loops=111) + Filter: (productcode = 'TAXI'::text) + -> Seq Scan on product (cost=0.00..1.04 rows=1 width=8) +(actual time=0.005..0.013 rows=3 loops=47) + Filter: ((organizationid = 1) AND (deletiondate IS NULL)) + -> Index Scan using locationiataix4 on locationiata la +(cost=0.00..3.66 rows=1 width=4) (actual time=0.022..0.022 rows=0 loops=47) + Index Cond: ("outer".locationid = la.locationid) + Filter: ((iatacode = 'KB8'::text) AND (deletiondate IS NULL)) +Total runtime: 42.852 ms + +Which is even faster than disable:ing nestloop. + +So my question is why is the planner making such a bad choice and how +can I make it choose a better plan? + + +/Mikael + + +From pgsql-performance-owner@postgresql.org Fri Jun 4 12:10:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AF73D1B1BD + for ; + Fri, 4 Jun 2004 11:21: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 97971-06 + for ; + Fri, 4 Jun 2004 14:21:15 +0000 (GMT) +Received: from p0.pureserver.info (ami.ga [217.160.111.113]) + by svr1.postgresql.org (Postfix) with SMTP id 25AECD1B188 + for ; + Fri, 4 Jun 2004 11:21:14 -0300 (ADT) +Received: (qmail 5157 invoked by uid 703); 4 Jun 2004 14:21:11 -0000 +Date: Fri, 4 Jun 2004 16:21:11 +0200 +From: CH +To: pgsql-performance@postgresql.org +Subject: Re: filesystem option tuning +Message-ID: <20040604162111.A5057@p15097255.pureserver.info> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.3.16i +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/33 +X-Sequence-Number: 7091 + +Hi! + +> > Does that mean only the xlog, or also the clog? As far as I understand, the +> > clog contains some meta-information on the xlog, so presumably it is +> > flushed to disc synchronously together with the xlog? That would mean that +> > they each need a separate disk to prevent one disk having to seek too +> > often...? +> +> You can put clog and xlog on same drive. That should be enough in most cases. +> xlog is written sequentially and never read back other than for recovery +> after a crash. clog is typically 8KB or a page and should not be an IO +> overhead even in high traffic databases. + +For many small commits it's usually the disk seek, the moving of the head, +that produces the overhead. Even if there is only a single byte changed in +the clog, it's an independent operation for the harddisk to seek to, and +write, the block. + +> Well, if you have tablespaces, you don't have to mess with symlinking +> clog/xlog or use location facility which is bit rough. You should be able to +> manage such a setup solely from postgresql. That is an advantage of +> tablespaces. + +Right, hadn't thought of that. + +> > Here goes ... we are talking about a database cluster with two tables where +> > things are happening, one is a kind of log that is simply "appended" to and +> > will expect to reach a size of several million entries in the time window +> > that is kept, the other is a persistent backing of application data that +> > will mostly see read-modify-writes of single records. Two writers to the +> > history, one writer to the data table. The volume of data is not very high +> > and RAM is enough... +> +> Even if you have enough RAM, you should use pg_autovacuum so that your tables +> are in shape. This is especially required when your update/insert rate is +> high. + +I haven't looked at pg_autovacuum yet, but had planned on doing a vacuum or +vacuum flush once every day (or rather, once every night). + +[next message] + +> > > Does that mean only the xlog, or also the clog? +> +> > You can put clog and xlog on same drive. +> +> You can, but I think you shouldn't. [...] + +So the clog is not written to every time the xlog is written to? + +On a related issue, what's the connection between the "fsync" and the +"wal_sync_method" configuration switches? Does fsync apply to the wal, +to checkpointing, to regular data writes (assuming data blocks are +written to between checkpoints if there's "nothing better to do"), or +to all? Does it select the wal_sync_method to be used for other writes +too? + +(The other issue I am trying to sort out is the interference with journalled +filesystems, in this case SUN UFS with the logging option. That's another +layer of transaction log, and I do not know all details yet to get an +impression of how it affects safety and performance wrt. all these partition +questions...) + +(Why are these not common questions covered in the documentation? Is nobody +interested, or does everybody have battery-backed cache on the SCSI HA and +does not care how often the disk would have to seek without?) + +Thanks & Regards, +Colin + +From pgsql-performance-owner@postgresql.org Fri Jun 4 11:41:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F2A6D1BB9E + for ; + Fri, 4 Jun 2004 11: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 38359-01 + for ; + Fri, 4 Jun 2004 14:41: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 B93B5D1B8C4 + for ; + Fri, 4 Jun 2004 11:41:51 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i54EfoVl027263; + Fri, 4 Jun 2004 10:41:50 -0400 (EDT) +To: =?ISO-8859-1?Q?Mikael_Kjellstr=F6m?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Planner problem +In-reply-to: <40C066C1.2090808@mksoft.nu> +References: <40C066C1.2090808@mksoft.nu> +Comments: In-reply-to =?ISO-8859-1?Q?Mikael_Kjellstr=F6m?= + + message dated "Fri, 04 Jun 2004 14:10:41 +0200" +Date: Fri, 04 Jun 2004 10:41:50 -0400 +Message-ID: <27262.1086360110@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200406/32 +X-Sequence-Number: 7090 + +=?ISO-8859-1?Q?Mikael_Kjellstr=F6m?= writes: +> I am having a bit of problem with the plan that the planner produces. + +Actually, your problem is with the row-count estimates. Some of them +are pretty wildly off, which inevitably leads to bad plan choices. +In particular the price row estimate is off by a factor of 200 in all +three plans: + +> -> Index Scan using priceix2 on price (cost=0.00..3.41 rows=23 width=20) (actual time=0.042..25.811 rows=4402 loops=111) +> Index Cond: ('2004-06-01'::date <= validstopdate) +> Filter: (('2004-06-01'::date >= validstartdate) AND (deletiondate IS NULL) AND (organizationid = 1)) + +> -> Index Scan using priceix2 on price (cost=0.00..3.41 rows=23 width=20) (actual time=0.053..26.225 rows=4402 loops=1) +> Index Cond: ('2004-06-01'::date <= validstopdate) +> Filter: (('2004-06-01'::date >= validstartdate) AND (deletiondate IS NULL) AND (organizationid = 1)) + +> -> Index Scan using priceix2 on price (cost=0.00..3.41 rows=23 width=20) (actual time=0.050..26.475 rows=4402 loops=1) +> Index Cond: ('2004-06-01'::date <= validstopdate) +> Filter: (('2004-06-01'::date >= validstartdate) AND (deletiondate IS NULL) AND (organizationid = 1)) + +and priceavailable is off by a factor of 100: + +> -> Index Scan using priceavailableix1 on priceavailable pa (cost=0.00..5.91 rows=1 width=16) (actual time=0.067..4.182 rows=111 loops=1) +> Index Cond: (pa.locationconnectionid = "outer".locationconnectionid) +> Filter: (((direction = 'D'::text) OR (direction = 'B'::text)) AND (deletiondate IS NULL)) + +> -> Index Scan using priceavailableix1 on priceavailable pa (cost=0.00..141.57 rows=43 width=16) (actual time=0.048..48.739 rows=6525 loops=1) +> Filter: (((direction = 'D'::text) OR (direction = 'B'::text)) AND (deletiondate IS NULL)) + +> -> Index Scan using priceavailableix1 on priceavailable pa (cost=0.00..5.91 rows=1 width=16) (actual time=0.070..0.965 rows=111 loops=1) +> Index Cond: (pa.locationconnectionid = "outer".locationconnectionid) +> Filter: (((direction = 'D'::text) OR (direction = 'B'::text)) AND (deletiondate IS NULL)) + +Are you sure you've vacuum analyzed these two tables recently? If so, +what may be needed is to increase ANALYZE's statistics target for +the columns used in the conditions. (See ALTER TABLE SET STATISTICS) + +I suspect that part of the story here has to do with cross-column +correlations, which the present planner will never figure out since it +has no cross-column statistics. But it's hard to believe that that's +the problem for cases as simple as + +> Filter: (((direction = 'D'::text) OR (direction = 'B'::text)) AND (deletiondate IS NULL)) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 4 12:33:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 856A3D1CAC0 + for ; + Fri, 4 Jun 2004 12:33: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 60046-10 + for ; + Fri, 4 Jun 2004 15:33:33 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 51D0ED1B435 + for ; + Fri, 4 Jun 2004 12:33:30 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i54FXTg2027975; + Fri, 4 Jun 2004 11:33:29 -0400 (EDT) +To: CH +Cc: pgsql-performance@postgresql.org +Subject: Re: filesystem option tuning +In-reply-to: <20040604162111.A5057@p15097255.pureserver.info> +References: <20040604162111.A5057@p15097255.pureserver.info> +Comments: In-reply-to CH + message dated "Fri, 04 Jun 2004 16:21:11 +0200" +Date: Fri, 04 Jun 2004 11:33:29 -0400 +Message-ID: <27974.1086363209@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/34 +X-Sequence-Number: 7092 + +CH writes: +> So the clog is not written to every time the xlog is written to? + +No. One clog page holds 32000 transactions' worth of transaction status +values, so on average we need only one clog page write per 32000 +transactions. + +> On a related issue, what's the connection between the "fsync" and the +> "wal_sync_method" configuration switches? + +fsync is the master circuit breaker: turn it off, there is no power at +the wal_sync_method socket ;-). We stop doing anything special about +enforcing write ordering for any files, but just assume that the kernel ++ hardware can be trusted not to lose data they've been given. + +With fsync on, wal_sync_method means something. + +fsync on also enables fsync/sync for the data files at checkpoint +times. We don't need to force writes for those between checkpoints, +so wal_sync_method doesn't apply to data files (nor clog). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 4 12:47:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 446F6D1B273 + for ; + Fri, 4 Jun 2004 12:43: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 72462-05 + for ; + Fri, 4 Jun 2004 15:43:01 +0000 (GMT) +Received: from auscorpex-1.austin.messageone.com (mail.messageone.com + [66.219.55.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 26FD3D1B16F + for ; + Fri, 4 Jun 2004 12:43:00 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: postgres performance: comparing 2 data centers +Date: Fri, 4 Jun 2004 10:42:59 -0500 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: postgres performance: comparing 2 data centers +Thread-Index: AcRKSpzVk7TI/WUjRR+MlG8boRp5EA== +From: "Michael Nonemacher" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/35 +X-Sequence-Number: 7093 + +I have two instances of a production application that uses Postgres 7.2, +deployed in two different data centers for about the last 6 months. The +sizes, schemas, configurations, hardware, and access patterns of the two +databases are nearly identical, but one consistently takes at least 5x +longer than the other for some common operations. During this time, CPU +usage and IO on the slow database are both high (sustained); I'm not +sure about the fast database. These common operations are chatty - at +least tens of thousands of queries over a 5 to 60 minute stretch - but +the queries themselves are fairly simple. The query plans are identical +across both databases, and the data distribution is comparable. The +tables involved in these common operations change frequently, and are +indexed according to these queries. The queries use the indexes as +expected. The tables involved have 50k-500k rows. + +We 'vacuum analyze' nightly, and we recently rebuilt the indexes on the +slow database (using reindex table). This cut the number of index pages +dramatically: from ~1800 to ~50, but didn't noticeably change the time +or CPU utilization for the common operations described above. + +When running pgbench, both databases have very similar results (200-260 +over multiple runs with 5 concurrent threads). + +I know of a few things I can do to make this operation marginally +simpler, but I'm most interested in the difference between the two +databases. + +I haven't come up with a theory that explains each of these things. +What are some things I can look into to track this down further? + +mike + +From pgsql-performance-owner@postgresql.org Fri Jun 4 13:02:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DFA9D1B273 + for ; + Fri, 4 Jun 2004 13: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 88061-01 + for ; + Fri, 4 Jun 2004 16:02:44 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A684D1B16F + for ; + Fri, 4 Jun 2004 13:02:42 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: postgres performance: comparing 2 data centers +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Fri, 4 Jun 2004 12:02:41 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AE51@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] postgres performance: comparing 2 data centers +Thread-Index: AcRKSpzVk7TI/WUjRR+MlG8boRp5EAAAnxFw +From: "Merlin Moncure" +To: "Michael Nonemacher" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/36 +X-Sequence-Number: 7094 + +Michael wrote: +> I have two instances of a production application that uses Postgres +7.2, +> deployed in two different data centers for about the last 6 months. +The +> sizes, schemas, configurations, hardware, and access patterns of the +two +> databases are nearly identical, but one consistently takes at least 5x +> longer than the other for some common operations. During this time, +CPU +> usage and IO on the slow database are both high (sustained); I'm not +> sure about the fast database. These common operations are chatty - at +> least tens of thousands of queries over a 5 to 60 minute stretch - but +> the queries themselves are fairly simple. The query plans are +identical +> across both databases, and the data distribution is comparable. The +> tables involved in these common operations change frequently, and are +> indexed according to these queries. The queries use the indexes as +> expected. The tables involved have 50k-500k rows. + +Have you isolated any hardware issues? For example, if you are using +ATA cables, and one is kinked or too long, you could be having ATA +errors which cause bizarre and intermittent slowdowns and pauses, +especially in raid systems. Do a filesystem diagnostic to check this. + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Jun 4 13:07:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 75DBCD1B459 + for ; + Fri, 4 Jun 2004 13:07: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 89520-01 + for ; + Fri, 4 Jun 2004 16:07: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 6E1DFD1B273 + for ; + Fri, 4 Jun 2004 13:07:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i54G7PS6028867; + Fri, 4 Jun 2004 12:07:25 -0400 (EDT) +To: "Michael Nonemacher" +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres performance: comparing 2 data centers +In-reply-to: + +References: + +Comments: In-reply-to "Michael Nonemacher" + message dated "Fri, 04 Jun 2004 10:42:59 -0500" +Date: Fri, 04 Jun 2004 12:07:25 -0400 +Message-ID: <28866.1086365245@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/37 +X-Sequence-Number: 7095 + +"Michael Nonemacher" writes: +> I have two instances of a production application that uses Postgres 7.2, +> deployed in two different data centers for about the last 6 months. The +> sizes, schemas, configurations, hardware, and access patterns of the two +> databases are nearly identical, but one consistently takes at least 5x +> longer than the other for some common operations. + +Does VACUUM VERBOSE show comparable physical sizes (in pages) for the +key tables in both databases? Maybe the slow one has lots of dead space +in the tables (not indexes). It would be useful to look at EXPLAIN +ANALYZE output of both databases for some of those common ops, too. +It could be that you're getting different plans in the two cases for +some reason. + +> We 'vacuum analyze' nightly, and we recently rebuilt the indexes on the +> slow database (using reindex table). This cut the number of index pages +> dramatically: from ~1800 to ~50, but didn't noticeably change the time +> or CPU utilization for the common operations described above. + +That's pretty suspicious. + +If it's not dead space or plan choice, the only other thing I can think +of is physical tuple ordering. You might try CLUSTERing on the +most-heavily-used index of each table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 4 18:39:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 06A11D1B88E + for ; + Fri, 4 Jun 2004 18:39: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 44349-05 + for ; + Fri, 4 Jun 2004 21:39:06 +0000 (GMT) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D8CAD1B434 + for ; + Fri, 4 Jun 2004 18:39:02 -0300 (ADT) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i54K539U006679; + Fri, 4 Jun 2004 16:05:04 -0400 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [10.225.10.110]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i54Ld1N28088; + Fri, 4 Jun 2004 17:39:02 -0400 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id LP852MGQ; Fri, 4 Jun 2004 17:38:59 -0400 +Subject: Re: Pl/Pgsql Functions running simultaneously +From: Robert Treat +To: marcus@coldfeetcreative.com +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200406031638.03409.marcus@coldfeetcreative.com> +References: <200406021608.56919.marcus@coldfeetcreative.com> + <200406031638.03409.marcus@coldfeetcreative.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 04 Jun 2004 17:39:01 -0400 +Message-Id: <1086385141.29236.1118.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/38 +X-Sequence-Number: 7096 + +Uh... I don't think this is necessarily the wrong list, sometimes people +don't have much to chime in. You could try reposting to -sql or -general +I suppose. + +As for my take on your questions, I wasn't exactly clear on what the +problem is. If its just that things seem slow, make sure you have done +the appropriate vacuum/analyze/reindex tech and then try adding some +debug info to the function to determine where in the function it is +slowing down. + +queries inside plpgsql functions will take locks as needed, but they are +no different than regular statements, just keep in mind that the queries +inside the function will work like an implicit transaction. + +Robert Treat + +On Thu, 2004-06-03 at 17:38, Marcus Whitney wrote: +> Am I on the wrong list to ask this question, or does this list usually have +> low activity? Just asking because I am new and I need to know where to ask +> this question. Thanks. +> +> On Wednesday 02 June 2004 16:08, Marcus Whitney wrote: +> > Hello all, +> > +> > I have an import function that I have been working on for some time now, +> > and it performed well up until recently. It is doing a lot, and because +> > the queries are not cached, I am not sure if that is what the problem is. +> > If a function takes a while, does it lock any of the tables it is +> > accessing, even for SELECT? +> > +> > Below is the bulk of the function: +> > +> > -- set sql statement variables +> > create_import_file_sql := ''COPY '' || container_table || '' ('' || +> > filtered_container_columns || '') TO '' || +> > quote_literal(formatted_import_file) || '' WITH NULL AS '' || +> > null_single_quotes; +> > upload_to_import_table_sql := ''COPY '' || import_table || '' ('' +> > || field_names || '') FROM '' || quote_literal(formatted_import_file) || '' +> > WITH NULL AS '' || null_single_quotes; +> > clean_personalization_fields_sql := ''UPDATE '' || import_table || +> > '' SET emma_member_email = btrim(emma_member_email, '' || +> > quote_literal(quoted_single_quote) || '') , emma_member_name_first = +> > btrim(emma_member_name_first, '' || quote_literal(quoted_single_quote) || +> > '') , emma_member_name_last = btrim(emma_member_name_last, '' || +> > quote_literal(quoted_single_quote) || '') ;''; +> > clean_personalization_fields_sql2 := ''UPDATE '' || import_table || +> > '' SET emma_member_email = btrim(emma_member_email) , +> > emma_member_name_first = btrim(emma_member_name_first) , +> > emma_member_name_last = +> > btrim(emma_member_name_last) ;''; +> > set_account_id_sql := ''UPDATE '' || import_table || '' SET +> > emma_account_id = '' || account_id; +> > set_default_active_status_sql := ''UPDATE '' || import_table || '' +> > SET emma_member_status_id = 1''; +> > set_errors_for_null_email_sql := ''UPDATE '' || import_table || '' +> > SET emma_member_status_id = 2 WHERE emma_member_email IS NULL''; +> > record_null_email_count_sql := ''UPDATE '' || import_history_table +> > || '' SET emma_import_null_email_count = (SELECT COUNT(*) FROM '' || +> > import_table || '' WHERE emma_member_email IS NULL) WHERE +> > emma_import_history_id ='' || import_history_id; +> > set_errors_for_invalid_email_sql := ''UPDATE '' || import_table || +> > '' SET emma_member_status_id = 2 WHERE emma_member_email !~* '' || +> > email_regex; record_invalid_email_count_sql := ''UPDATE '' || +> > import_history_table +> > +> > || '' SET emma_import_invalid_email_count = ( SELECT COUNT(*) FROM '' || +> > +> > import_table || '' WHERE emma_member_email !~* '' || email_regex || '' ) +> > WHERE emma_import_history_id ='' || import_history_id; +> > get_dupes_in_import_sql := ''SELECT emma_member_email, +> > emma_member_status_id FROM '' || import_table || '' GROUP BY +> > emma_member_email, emma_member_status_id having count(*) > 1''; +> > insert_dupes_sql := ''INSERT INTO '' || dupe_table || '' SELECT * +> > FROM '' || import_table || '' WHERE LOWER(emma_member_email) = LOWER('' || +> > member_table || ''.emma_member_email)''; +> > record_table_dupe_count_sql := ''UPDATE '' || import_history_table +> > || '' SET emma_import_table_dupe_email_count = (SELECT COUNT(*) FROM '' || +> > import_table || '' WHERE emma_member_email = LOWER('' || member_table || +> > ''.emma_member_email)) WHERE emma_import_history_id ='' || +> > import_history_id; remove_dupes_from_import_table_sql := ''DELETE FROM '' +> > || import_table +> > +> > || '' WHERE LOWER(emma_member_email) = LOWER('' || member_table || +> > +> > ''.emma_member_email)''; +> > create_clean_import_file_sql := ''COPY '' || import_table || '' TO +> > '' +> > +> > || quote_literal(clean_import_file) || '' WITH NULL AS '' || +> > +> > null_single_quotes; +> > create_members_groups_ids_file_sql := ''COPY '' || import_table || +> > '' (emma_member_id) TO '' || quote_literal(members_groups_ids_file) || '' +> > WITH NULL AS '' || null_single_quotes; +> > empty_import_table_sql := ''TRUNCATE '' || import_table; +> > upload_clean_import_sql := ''COPY '' || member_table || '' FROM '' +> > || quote_literal(clean_import_file) || '' WITH NULL AS '' || +> > null_single_quotes; +> > upload_members_groups_ids_sql := ''COPY '' || +> > members_groups_ids_table +> > +> > || '' (emma_member_id) FROM '' || quote_literal(members_groups_ids_file) || +> > +> > '' WITH NULL AS '' || null_single_quotes; +> > empty_members_groups_ids_sql := ''TRUNCATE '' || +> > members_groups_ids_table; +> > empty_members_dupes_sql := ''TRUNCATE '' || dupe_table; +> > vacuum_sql := ''VACUUM '' || member_table || ''; VACUUM '' || +> > import_table || ''; VACUUM '' || container_table || ''; VACUUM '' || +> > members_groups_table || ''; VACUUM '' || members_groups_ids_table || ''; +> > VACUUM '' || dupe_table; +> > +> > -- BEGIN ACTIVITY +> > -- Create the filtered import file with the +> > EXECUTE create_import_file_sql; +> > -- Load data from the filtered file to the import table +> > EXECUTE upload_to_import_table_sql; +> > -- Set account id in import table +> > EXECUTE set_account_id_sql; +> > -- Set the status of all the records to 1 +> > EXECUTE set_default_active_status_sql; +> > -- Clean personalization data +> > EXECUTE clean_personalization_fields_sql; +> > EXECUTE clean_personalization_fields_sql2; +> > -- Set the status to error for all NULL emails +> > EXECUTE set_errors_for_null_email_sql; +> > -- Record the count of null emails +> > EXECUTE record_null_email_count_sql; +> > -- Set the status to error for all invalid emails +> > EXECUTE set_errors_for_invalid_email_sql; +> > -- Record the count of invalid emails +> > EXECUTE record_invalid_email_count_sql; +> > +> > -- Remove duplicates in import table (originally in file) +> > FOR duplicate_record IN EXECUTE get_dupes_in_import_sql LOOP +> > IF duplicate_record.emma_member_email IS NOT NULL THEN +> > FOR replacement_record IN EXECUTE '' SELECT * FROM '' +> > || import_table || '' WHERE emma_member_email = '' || +> > quote_literal(duplicate_record.emma_member_email) || '' ORDER BY +> > emma_member_id LIMIT 1'' LOOP +> > escape_first_name := quote_literal +> > (replacement_record.emma_member_name_first); +> > escape_last_name := quote_literal +> > (replacement_record.emma_member_name_last); +> > escape_email := quote_literal +> > (replacement_record.emma_member_email); +> > escape_status_id := +> > quote_literal(replacement_record.emma_member_status_id); +> > -- Record count of dupes +> > FOR dupe_record_count IN EXECUTE ''SELECT +> > COUNT(*) AS count FROM '' || import_table || '' WHERE +> > LOWER(emma_member_email) = LOWER('' || escape_email || '')'' LOOP +> > EXECUTE ''UPDATE '' || +> > import_history_table || '' SET emma_import_file_dupe_email_count ='' || +> > dupe_record_count.count; +> > END LOOP; +> > FOR primary_dupe_record IN EXECUTE ''SELECT +> > MAX(emma_member_id) AS max_id FROM '' || import_table || '' WHERE +> > LOWER(emma_member_email) = LOWER('' || escape_email || '')'' LOOP +> > EXECUTE ''UPDATE '' || import_table || +> > '' SET emma_member_status_id = 5 WHERE emma_member_id = '' || +> > primary_dupe_record.max_id; +> > EXECUTE ''DELETE FROM '' || +> > import_table +> > +> > || '' WHERE emma_member_email = '' || +> > +> > quote_literal(duplicate_record.emma_member_email) || '' AND +> > emma_member_status_id != 5''; +> > EXECUTE ''UPDATE '' || import_table || +> > '' SET emma_member_status_id = 1 WHERE emma_member_status_id = 5''; +> > END LOOP; +> > import_dupe_count := import_dupe_count + 1; +> > END LOOP; +> > END IF; +> > END LOOP; +> > +> > -- Move dupes over to the dupe table +> > EXECUTE insert_dupes_sql; +> > -- Record the count of dupes from import to members +> > EXECUTE record_table_dupe_count_sql; +> > -- Delete the dupes from the import table +> > EXECUTE remove_dupes_from_import_table_sql; +> > -- Create clean import file +> > EXECUTE create_clean_import_file_sql; +> > -- Create groups_id file +> > EXECUTE create_members_groups_ids_file_sql; +> > -- Empty import table +> > EXECUTE empty_import_table_sql; +> > -- Upload clean members from import +> > EXECUTE upload_clean_import_sql; +> > -- Upload group ids +> > EXECUTE upload_members_groups_ids_sql; +> > +> > -- Associate to groups +> > groups := string_to_array(group_list, '',''); +> > if array_lower(groups, 1) IS NOT NULL THEN +> > FOR i IN array_lower(groups, 1)..array_upper(groups, 1) LOOP +> > EXECUTE ''INSERT INTO '' || members_groups_ids_table +> > || '' SELECT '' || member_table || ''.emma_member_id FROM ONLY '' || +> > member_table || '' WHERE LOWER('' || member_table || ''.emma_member_email) +> > = LOWER('' || dupe_table || ''.emma_member_email) AND '' || member_table || +> > ''.emma_member_id NOT IN (SELECT '' || members_groups_table || +> > ''.emma_member_id FROM '' || members_groups_table || '' WHERE '' || +> > members_groups_table || ''.emma_group_id = '' || groups[i] || '') AND '' || +> > member_table || ''.emma_member_id NOT IN (SELECT emma_member_id FROM '' || +> > members_groups_ids_table || '')''; +> > EXECUTE ''DELETE FROM '' || members_groups_ids_table +> > || '' WHERE emma_member_id IN (SELECT emma_member_id FROM '' || +> > members_groups_table || '' WHERE emma_group_id = '' || groups[i] || '' )''; +> > EXECUTE ''INSERT INTO '' || members_groups_table || '' +> > SELECT DISTINCT '' || groups[i] || '' AS emma_group_id, emma_member_id +> > FROM '' || members_groups_ids_table; +> > END LOOP; +> > END IF; +> > +> > Any pointers on large plpgsql operations are appreciated. Especially when +> > more than one instance is runinng. Thanks. +> +> -- +> marcus whitney +> +> chief architect : cold feet creative +> +> www.coldfeetcreative.com +> +> 800.595.4401 +> +> +> +> cold feet presents emma +> +> email marketing for discriminating +> +> organizations everywhere +> +> visit www.myemma.com +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Fri Jun 4 19:07:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69BF8D1B587 + for ; + Fri, 4 Jun 2004 19:07: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 62094-03 + for ; + Fri, 4 Jun 2004 22:07:54 +0000 (GMT) +Received: from auscorpex-1.austin.messageone.com (mail.messageone.com + [66.219.55.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F224D1B445 + for ; + Fri, 4 Jun 2004 19:07:50 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.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: postgres performance: comparing 2 data centers +Date: Fri, 4 Jun 2004 17:07:52 -0500 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] postgres performance: comparing 2 data centers +Thread-Index: AcRKSpzVk7TI/WUjRR+MlG8boRp5EAAM7QkA +From: "Michael Nonemacher" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/39 +X-Sequence-Number: 7097 + +Slight update: + +Thanks for the replies; this is starting to make a little more sense... + +I've managed to track down the root of the problem to a single query on +a single table. I have a query that looks like this: + select count(*) from members where group_id =3D ? and member_id > +0; + +The members table contains about 500k rows. It has an index on +(group_id, member_id) and on (member_id, group_id). + +It seems like the statistics are wildly different depending on whether +the last operation on the table was a 'vacuum analyze' or an 'analyze'. +Vacuum or vacuum-analyze puts the correct number (~500k) in +pg_class.reltuples, but analyze puts 7000 in pg_class.reltuples. The +reltuples numbers associated with this table's indexes are unchanged. + +After a vacuum-analyze, the query correctly uses the index on (group_id, +member_id), and runs very fast (sub-millisecond reported by explain +analyze). After an analyze, the query uses the (member_id, group_id) +index, and the query takes much longer (150ms reported by explain +analyze). (Yes, I said the 2 databases were using the same query plan; +it turns out they're only sometimes using the same query plan. :( ) + +A similar problem happens to some of my other tables (according to +pg_class.reltuples), although I haven't seen query performance change as +much. + +Any idea what could cause this bad analyze behavior? Any guesses why +this has happened in one of my data centers but not both? (Coincidence +isn't a big stretch here.) What can I do to stop or change this +behavior? Apologies if this is a known problem... + +mike + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Michael +Nonemacher +Sent: Friday, June 04, 2004 10:43 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] postgres performance: comparing 2 data centers + + +I have two instances of a production application that uses Postgres 7.2, +deployed in two different data centers for about the last 6 months. The +sizes, schemas, configurations, hardware, and access patterns of the two +databases are nearly identical, but one consistently takes at least 5x +longer than the other for some common operations. During this time, CPU +usage and IO on the slow database are both high (sustained); I'm not +sure about the fast database. These common operations are chatty - at +least tens of thousands of queries over a 5 to 60 minute stretch - but +the queries themselves are fairly simple. The query plans are identical +across both databases, and the data distribution is comparable. The +tables involved in these common operations change frequently, and are +indexed according to these queries. The queries use the indexes as +expected. The tables involved have 50k-500k rows. + +We 'vacuum analyze' nightly, and we recently rebuilt the indexes on the +slow database (using reindex table). This cut the number of index pages +dramatically: from ~1800 to ~50, but didn't noticeably change the time +or CPU utilization for the common operations described above. + +When running pgbench, both databases have very similar results (200-260 +over multiple runs with 5 concurrent threads). + +I know of a few things I can do to make this operation marginally +simpler, but I'm most interested in the difference between the two +databases. + +I haven't come up with a theory that explains each of these things. What +are some things I can look into to track this down further? + +mike + +---------------------------(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 Jun 6 18:57:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 32561D1B445 + for ; + Fri, 4 Jun 2004 19:27: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 61035-10 + for ; + Fri, 4 Jun 2004 22:27:11 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ADFA3D1B34E + for ; + Fri, 4 Jun 2004 19:27:07 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 023CB76A2A; Fri, 4 Jun 2004 18:27:13 -0400 (EDT) +Subject: Re: postgres performance: comparing 2 data centers +From: Rod Taylor +To: Michael Nonemacher +Cc: Postgresql Performance +In-Reply-To: + +References: + +Content-Type: text/plain +Message-Id: <1086388027.67371.92.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Fri, 04 Jun 2004 18:27:08 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/52 +X-Sequence-Number: 7110 + +> The members table contains about 500k rows. It has an index on +> (group_id, member_id) and on (member_id, group_id). + + +Yes, bad stats are causing it to pick a poor plan, but you're giving it +too many options (which doesn't help) and using space up unnecessarily. + +Keep (group_id, member_id) +Remove (member_id, group_id) +Add (member_id) + +An index on just member_id is actually going to perform better than +member_id, group_id since it has a smaller footprint on the disk. + +Anytime where both group_id and member_id are in the query, the +(group_id, member_id) index will likely be used. + +-- +Rod Taylor + +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL +PGP Key: http://www.rbt.ca/signature.asc + + +From pgsql-performance-owner@postgresql.org Fri Jun 4 19:29:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 33C99D1B88E + for ; + Fri, 4 Jun 2004 19:29: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 68676-02 + for ; + Fri, 4 Jun 2004 22:29:30 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 711AFD1B8E8 + for ; + Fri, 4 Jun 2004 19:29:27 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 007AB76A2A; Fri, 4 Jun 2004 18:29:34 -0400 (EDT) +Subject: Re: postgres performance: comparing 2 data centers +From: Rod Taylor +To: Michael Nonemacher +Cc: Postgresql Performance +In-Reply-To: + +References: + +Content-Type: text/plain +Message-Id: <1086388169.67371.94.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Fri, 04 Jun 2004 18:29:29 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/40 +X-Sequence-Number: 7098 + +On Fri, 2004-06-04 at 18:07, Michael Nonemacher wrote: +> Slight update: +> +> Thanks for the replies; this is starting to make a little more sense... +> +> I've managed to track down the root of the problem to a single query on +> a single table. I have a query that looks like this: +> select count(*) from members where group_id = ? and member_id > +> 0; +> +> The members table contains about 500k rows. It has an index on +> (group_id, member_id) and on (member_id, group_id). +> +> It seems like the statistics are wildly different depending on whether +> the last operation on the table was a 'vacuum analyze' or an 'analyze'. + + +Yes, bad stats are causing it to pick a poor plan (might be better in +7.5), but you're giving it too many options (which doesn't help) and +using diskspace up unnecessarily. + +Keep (group_id, member_id) +Remove (member_id, group_id) +Add (member_id) + +An index on just member_id is actually going to perform better than +member_id, group_id since it has a smaller footprint on the disk. + +Anytime where both group_id and member_id are in the query, the +(group_id, member_id) index will likely be used. + + + +From pgsql-performance-owner@postgresql.org Fri Jun 4 20:12:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B211DD1B173 + for ; + Fri, 4 Jun 2004 20: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 85605-04 + for ; + Fri, 4 Jun 2004 23:12:53 +0000 (GMT) +Received: from auscorpex-1.austin.messageone.com (mail.messageone.com + [66.219.55.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 66774D1B16E + for ; + Fri, 4 Jun 2004 20:12:49 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.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: postgres performance: comparing 2 data centers +Date: Fri, 4 Jun 2004 18:12:52 -0500 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] postgres performance: comparing 2 data centers +Thread-Index: AcRKgxP+IVjXittfRJKLHKyXXr+fcwABbHgQ +From: "Michael Nonemacher" +To: "Rod Taylor" +Cc: "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/41 +X-Sequence-Number: 7099 + +Agreed. + +We originally created the indexes this way because we sometimes do +searches where one of the columns is constrained using =3D, and the other +using a range search, but it's not clear to me how much Postgres +understands multi-column indexes. Will I get the gain I'd expect from a +(member_id, group_id) index on a query like "where member_id =3D ? and +group_id > ?"? + +I've since found a few other often-used tables where the reltuples +counts generated by 'analyze' are off by a factor of 5 or more. In the +short term, I'm just trying to eliminate the automatic-analyzes where +possible and make sure they're followed up quickly with a 'vacuum' where +it's not possible. + +Is "analyze generating bad stats" a known issue? Is there anything I +could be doing to aggravate or work around the problem? + +mike + +-----Original Message----- +From: Rod Taylor [mailto:ports@rbt.ca]=20 +Sent: Friday, June 04, 2004 5:27 PM +To: Michael Nonemacher +Cc: Postgresql Performance +Subject: Re: [PERFORM] postgres performance: comparing 2 data centers + + +> The members table contains about 500k rows. It has an index on=20 +> (group_id, member_id) and on (member_id, group_id). + + +Yes, bad stats are causing it to pick a poor plan, but you're giving it +too many options (which doesn't help) and using space up unnecessarily. + +Keep (group_id, member_id) +Remove (member_id, group_id) +Add (member_id) + +An index on just member_id is actually going to perform better than +member_id, group_id since it has a smaller footprint on the disk. + +Anytime where both group_id and member_id are in the query, the +(group_id, member_id) index will likely be used. + +--=20 +Rod Taylor + +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL PGP Key: +http://www.rbt.ca/signature.asc + + +From pgsql-performance-owner@postgresql.org Fri Jun 4 21:33:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 03FCFD1B238 + for ; + Fri, 4 Jun 2004 21:33: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 04580-09 + for ; + Sat, 5 Jun 2004 00:33:37 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B14CD1B1DC + for ; + Fri, 4 Jun 2004 21:33:32 -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 1BWP7m-0008Gu-00; Fri, 04 Jun 2004 20:33:26 -0400 +To: "Michael Nonemacher" +Cc: "Rod Taylor" , + "Postgresql Performance" +Subject: Re: postgres performance: comparing 2 data centers +References: + +In-Reply-To: + +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 04 Jun 2004 20:33:26 -0400 +Message-ID: <873c5a2695.fsf@stark.xeocode.com> +Lines: 62 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/42 +X-Sequence-Number: 7100 + +"Michael Nonemacher" writes: + +> Agreed. +> +> We originally created the indexes this way because we sometimes do +> searches where one of the columns is constrained using =, and the other +> using a range search, but it's not clear to me how much Postgres +> understands multi-column indexes. Will I get the gain I'd expect from a +> (member_id, group_id) index on a query like "where member_id = ? and +> group_id > ?"? + +It will use them, whether you see a gain depends on the distribution of your +data. Does the group_id > ? exclude enough records that it's worth having to +do all the extra i/o the bigger index would require? + +Personally I think the other poster was a bit hasty to assert unconditionally +that it's never worth it. If you have a lot of records for every member_id and +very few of which will be greater than '?' then it might be worth it. If +however you'll only ever have on the order of a hundred or fewer records per +member_id and a significant chunk of them will have group_id > '?' then it +will probably be a wash or worse. + +There's another side to the story though. In a web site or other OLTP +application you may find you're better off with the multi-column index. Even +if it performs less well on average than the smaller single column index when +users have reasonable numbers of groups. That's becuase you're guaranteed +(assuming postgres is using it) that even if a user someday has an obscene +number of groups he won't suddenly break your web site by driving your +database into the ground. + +There is a difference between latency and bandwidth, and between average and +worst-case. Sometimes it's necessary to keep an eye on worst-case scenarios +and not just average bandwidth. + +But that said. If you are reasonably certain that you'll never or rarely have +thousands of groups per user you're probably better off with the indexes the +other person described. + +> I've since found a few other often-used tables where the reltuples +> counts generated by 'analyze' are off by a factor of 5 or more. In the +> short term, I'm just trying to eliminate the automatic-analyzes where +> possible and make sure they're followed up quickly with a 'vacuum' where +> it's not possible. +> +> Is "analyze generating bad stats" a known issue? Is there anything I +> could be doing to aggravate or work around the problem? + +I would suggest trying a VACUUM FULL and then retrying the ANALYZE. I suspect +you might have a lot of dead tuples at the beginning of your table which is +confusing the sampling. If that's it, then yes it's known and in fact already +improved in what will be 7.5. You may be able to avoid the situation by +vacuuming more frequently. + +If that doesn't solve it then I would suggest trying to raise the statistics +targets for the columns in question with + + ALTER TABLE name ALTER column SET STATISTICS integer + +The default is 100 iirc. You could try 200 or even more. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sat Jun 5 01:17:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A0928D1B278 + for ; + Sat, 5 Jun 2004 01:17: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 84757-01 + for ; + Sat, 5 Jun 2004 04:17:38 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A3A5AD1B18C + for ; + Sat, 5 Jun 2004 01:17:36 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i554HZZp014803; + Sat, 5 Jun 2004 00:17:35 -0400 (EDT) +To: "Michael Nonemacher" +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres performance: comparing 2 data centers +In-reply-to: + +References: + +Comments: In-reply-to "Michael Nonemacher" + message dated "Fri, 04 Jun 2004 17:07:52 -0500" +Date: Sat, 05 Jun 2004 00:17:35 -0400 +Message-ID: <14802.1086409055@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/43 +X-Sequence-Number: 7101 + +"Michael Nonemacher" writes: +> It seems like the statistics are wildly different depending on whether +> the last operation on the table was a 'vacuum analyze' or an 'analyze'. +> Vacuum or vacuum-analyze puts the correct number (~500k) in +> pg_class.reltuples, but analyze puts 7000 in pg_class.reltuples. + +Okay, this is a known issue: in 7.4 and earlier, ANALYZE is easily +fooled as to the total number of rows in the table. It samples the +initial portion of the table and assumes that the density of live rows +per page in that section is representative of the rest of the table. +Evidently that assumption is way off for your table. There's an +improved sampling algorithm in CVS tip that we hope will avoid this +error in 7.5 and beyond, but the immediate problem for you is what +to do in 7.4. I'd suggest either VACUUM FULL or CLUSTER to clean out +the existing dead space; then you should look into whether you need +to increase your vacuum frequency and/or FSM settings to keep it from +getting into this state again. Ideally the average dead space per +page *should* be consistent over the whole table, and the fact that +it isn't suggests strongly that you've got space-management issues +to deal with. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Jun 5 14:15:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 071A1D1E06E + for ; + Sat, 5 Jun 2004 14:15: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 09079-10 + for ; + Sat, 5 Jun 2004 17:15:42 +0000 (GMT) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id D712FD1D2AE + for ; + Sat, 5 Jun 2004 14:14:53 -0300 (ADT) +Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) + by www.postgresql.com (Postfix) with ESMTP id 51135CF8008 + for ; + Sat, 5 Jun 2004 11:42:39 -0300 (ADT) +Received: from [127.0.0.1] (helo=localhost) + by stan.aopsys.com with esmtp (Exim 4.30) id 1BWcIZ-0003Mg-17 + for pgsql-performance@postgresql.org; Sat, 05 Jun 2004 16:37:27 +0200 +To: pgsql-performance@postgresql.org +Subject: Unused table of view +From: Laurent Martelli +Date: Sat, 05 Jun 2004 16:37:26 +0200 +Message-ID: <87y8n2t6jd.fsf@stan.aopsys.com> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/44 +X-Sequence-Number: 7102 + +Hello, + +I'm using postgresql 7.4.2, and I have this view: +slooze=# \d userpictures2 + Vue �public.userpictures2� + Colonne | Type | Modificateurs +-------------+--------------------------+--------------- + pictureid | integer | + rollid | character varying(64) | + frameid | character varying(64) | + description | character varying(255) | + filename | character varying(255) | + owner | integer | + entrydate | timestamp with time zone | + date | timestamp with time zone | + nbclick | integer | + nbrates | integer | + maxrate | smallint | + minrate | smallint | + averagerate | real | + sumrates | integer | + userid | integer | +D�finition de la vue + SELECT DISTINCT ON (permissions.pictureid, userid) pictures.pictureid, rollid, frameid, description, filename, "owner", entrydate, date, nbclick, nbrates, maxrate, minrate, averagerate, sumrates, userid + FROM permissions + JOIN groupsdef USING (groupid) + JOIN pictures USING (pictureid) + WHERE groupsdef.groupid = permissions.groupid + ORDER BY permissions.pictureid, userid; + + +Now consider this query: + +SELECT count(*) FROM userpictures JOIN topicscontent using(PictureID) WHERE TopicID=137 and UserID=2; + +The pictures table is scanned, but it's not needed. (see plan at the end). + +I believe it's not need because my tables are as follow: + +CREATE TABLE pictures ( + PictureID serial PRIMARY KEY, + RollID character varying(64) NOT NULL REFERENCES rolls, + FrameID character varying(64) NOT NULL, + Description character varying(255), + Filename character varying(255), + Owner integer NOT NULL REFERENCES users, + EntryDate datetime DEFAULT now(), + Date datetime, + NbClick integer DEFAULT 0, + NbRates integer DEFAULT 0, + MaxRate int2, + MinRate int2, + AverageRate float4 DEFAULT 5, + SumRates integer DEFAULT 0); + +CREATE TABLE permissions ( + GroupID integer NOT NULL REFERENCES groups ON DELETE cascade, + PictureID integer NOT NULL REFERENCES pictures ON DELETE cascade, + UNIQUE (GroupID, PictureID)); + +CREATE TABLE groupsdef ( + UserID integer REFERENCES users, + GroupID integer REFERENCES groups, + PRIMARY KEY (UserID,GroupID)); + +CREATE TABLE topicscontent ( + TopicID integer REFERENCES topics ON DELETE cascade, + PictureID integer REFERENCES pictures ON DELETE cascade, + Direct boolean NOT NULL, + PRIMARY KEY (TopicID,PictureID) ); + +So obviously, the join on pictures is not adding any rows, since +permissions.PictureID references pictures.PictureID and +pictures.PictureID is the primary key. + +I can workaround with a second view: + +slooze=# \d userpictures2 + Vue �public.userpictures2� + Colonne | Type | Modificateurs +-----------+---------+--------------- + pictureid | integer | + userid | integer | +D�finition de la vue + SELECT DISTINCT pictureid, userid + FROM permissions + JOIN groupsdef USING (groupid) + WHERE groupsdef.groupid = permissions.groupid + ORDER BY pictureid, userid; + +But it would be better if Postgresql could figure it out itself. Is +there a way to currently avoid the 2nd view ? + +QUERY PLAN for SELECT count(*) FROM userpictures JOIN topicscontent using(PictureID) WHERE TopicID=137 and UserID=2; +-------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=1195.15..1195.15 rows=1 width=0) (actual time=89.252..89.253 rows=1 loops=1) + -> Merge Join (cost=1096.05..1194.98 rows=66 width=0) (actual time=84.574..89.202 rows=8 loops=1) + Merge Cond: ("outer".pictureid = "inner".pictureid) + -> Subquery Scan userpictures (cost=995.78..1081.47 rows=4897 width=4) (actual time=84.386..88.530 rows=841 loops=1) + -> Unique (cost=995.78..1032.50 rows=4897 width=105) (actual time=84.377..87.803 rows=841 loops=1) + -> Sort (cost=995.78..1008.02 rows=4897 width=105) (actual time=84.369..84.786 rows=1433 loops=1) + Sort Key: permissions.pictureid, groupsdef.userid + -> Hash Join (cost=371.82..695.65 rows=4897 width=105) (actual time=23.328..56.498 rows=5076 loops=1) + Hash Cond: ("outer".pictureid = "inner".pictureid) + -> Index Scan using pictures_pkey on pictures (cost=0.00..164.87 rows=2933 width=97) (actual time=0.015..4.591 rows=2933 loops=1) + -> Hash (cost=359.58..359.58 rows=4897 width=8) (actual time=23.191..23.191 rows=0 loops=1) + -> Merge Join (cost=10.16..359.58 rows=4897 width=8) (actual time=0.110..19.365 rows=5076 loops=1) + Merge Cond: ("outer".groupid = "inner".groupid) + -> Sort (cost=10.16..10.19 rows=12 width=8) (actual time=0.080..0.088 rows=11 loops=1) + Sort Key: groupsdef.groupid + -> Index Scan using groupsdef_userid_key on groupsdef (cost=0.00..9.94 rows=12 width=8) (actual time=0.038..0.056 rows=11 loops=1) + Index Cond: (userid = 2) + -> Index Scan using permissions_groupid_key on permissions (cost=0.00..279.63 rows=8305 width=8) (actual time=0.015..9.801 rows=7633 loops=1) + -> Sort (cost=100.28..100.37 rows=38 width=4) (actual time=0.114..0.118 rows=8 loops=1) + Sort Key: topicscontent.pictureid + -> Index Scan using topicscontent_topicid on topicscontent (cost=0.00..99.28 rows=38 width=4) (actual time=0.052..0.072 rows=8 loops=1) + Index Cond: (topicid = 137) + Total runtime: 91.096 ms + + +QUERY PLAN for SELECT count(*) FROM userpictures JOIN topicscontent using(PictureID) WHERE TopicID=137 and UserID=2; +-------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=859.09..859.09 rows=1 width=4) (actual time=30.488..30.489 rows=1 loops=1) + -> Merge Join (cost=759.99..858.92 rows=66 width=4) (actual time=27.845..30.466 rows=8 loops=1) + Merge Cond: ("outer".pictureid = "inner".pictureid) + -> Subquery Scan userpictures2 (cost=659.71..745.41 rows=4897 width=4) (actual time=27.707..29.853 rows=841 loops=1) + -> Unique (cost=659.71..696.44 rows=4897 width=8) (actual time=27.701..29.121 rows=841 loops=1) + -> Sort (cost=659.71..671.95 rows=4897 width=8) (actual time=27.696..28.153 rows=1433 loops=1) + Sort Key: permissions.pictureid, groupsdef.userid + -> Merge Join (cost=10.16..359.58 rows=4897 width=8) (actual time=0.101..20.682 rows=5076 loops=1) + Merge Cond: ("outer".groupid = "inner".groupid) + -> Sort (cost=10.16..10.19 rows=12 width=8) (actual time=0.074..0.078 rows=11 loops=1) + Sort Key: groupsdef.groupid + -> Index Scan using groupsdef_userid_key on groupsdef (cost=0.00..9.94 rows=12 width=8) (actual time=0.035..0.055 rows=11 loops=1) + Index Cond: (userid = 2) + -> Index Scan using permissions_groupid_key on permissions (cost=0.00..279.63 rows=8305 width=8) (actual time=0.014..10.093 rows=7633 loops=1) + -> Sort (cost=100.28..100.37 rows=38 width=4) (actual time=0.091..0.094 rows=8 loops=1) + Sort Key: topicscontent.pictureid + -> Index Scan using topicscontent_topicid on topicscontent (cost=0.00..99.28 rows=38 width=4) (actual time=0.039..0.057 rows=8 loops=1) + Index Cond: (topicid = 137) + Total runtime: 31.376 ms + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-performance-owner@postgresql.org Sat Jun 5 14:40:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C4F8BD1CF5B + for ; + Sat, 5 Jun 2004 14: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 25736-07 + for ; + Sat, 5 Jun 2004 17:40: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 3DA29D1CCBD + for ; + Sat, 5 Jun 2004 14:36:40 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i55HaULh024846; + Sat, 5 Jun 2004 13:36:30 -0400 (EDT) +To: Laurent Martelli +Cc: pgsql-performance@postgresql.org +Subject: Re: Unused table of view +In-reply-to: <87y8n2t6jd.fsf@stan.aopsys.com> +References: <87y8n2t6jd.fsf@stan.aopsys.com> +Comments: In-reply-to Laurent Martelli + message dated "Sat, 05 Jun 2004 16:37:26 +0200" +Date: Sat, 05 Jun 2004 13:36:30 -0400 +Message-ID: <24845.1086456990@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/45 +X-Sequence-Number: 7103 + +Laurent Martelli writes: +> The pictures table is scanned, but it's not needed. + +Yes it is. For example, if pictures is empty then the view yields +zero rows. Omitting the join to pictures could give a different result. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 5 17:24:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D41BFD1E604 + for ; + Wed, 5 May 2004 15:58:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97142-05 + for ; + Wed, 5 May 2004 15:57:58 -0300 (ADT) +Received: from smtp.uol.com.br (smtpout4.uol.com.br [200.221.11.57]) + by svr1.postgresql.org (Postfix) with ESMTP id 0CB52D1E80C + for ; + Wed, 5 May 2004 15:57:56 -0300 (ADT) +Received: from smannote (unknown [200.210.129.190]) + by scorpion4.uol.com.br (Postfix) with SMTP id 99B547EC8 + for ; + Wed, 5 May 2004 15:57:53 -0300 (BRT) +Message-ID: <034d01c44b2e$ae9b2b00$cf00a8c0@smannote> +From: "Carlos Eduardo Smanioto" +To: +Subject: [OFF-TOPIC] - Known maximum size of the PostgreSQL Database +Date: Sat, 5 Jun 2004 15:55:32 -0300 +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.3718.0 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3718.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=2.4 tagged_above=0.0 required=5.0 + tests=DATE_IN_FUTURE_96_XX +X-Spam-Level: ** +X-Archive-Number: 200405/42 +X-Sequence-Number: 6873 + +Hello all, + +What's the case of bigger database PostgreSQL (so greate and amount of +registers) that they know??? + +Thanks, +Carlos Eduardo Smanioto + + +From pgsql-performance-owner@postgresql.org Sat Jun 5 16:01:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79739D1B18C + for ; + Sat, 5 Jun 2004 16:01: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 48461-05 + for ; + Sat, 5 Jun 2004 19:01:44 +0000 (GMT) +Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A3BAD1B17C + for ; + Sat, 5 Jun 2004 16:01:41 -0300 (ADT) +Received: from [127.0.0.1] (helo=localhost) + by stan.aopsys.com with esmtp (Exim 4.30) + id 1BWgQ6-0003U0-2P; Sat, 05 Jun 2004 21:01:30 +0200 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Unused table of view +References: <87y8n2t6jd.fsf@stan.aopsys.com> <24845.1086456990@sss.pgh.pa.us> +From: Laurent Martelli +Organization: AOPSYS +Date: Sat, 05 Jun 2004 21:01:29 +0200 +In-Reply-To: <24845.1086456990@sss.pgh.pa.us> (Tom Lane's message of "Sat, + 05 Jun 2004 13:36:30 -0400") +Message-ID: <87u0xpu8vq.fsf@stan.aopsys.com> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/46 +X-Sequence-Number: 7104 + +>>>>> "Tom" == Tom Lane writes: + + Tom> Laurent Martelli writes: + >> The pictures table is scanned, but it's not needed. + + Tom> Yes it is. For example, if pictures is empty then the view + Tom> yields zero rows. Omitting the join to pictures could give a + Tom> different result. + +Since Permission is like this: + +CREATE TABLE permissions ( + GroupID integer NOT NULL REFERENCES groups ON DELETE cascade, + PictureID integer NOT NULL REFERENCES pictures ON DELETE cascade, + UNIQUE (GroupID, PictureID)); + +if the pictures table is empty, so is permissions, because +permissions.PictureID references pictures. + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-jdbc-owner@postgresql.org Sat Jun 5 17:12:39 2004 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP + id 948C8D1B1F8; Sat, 5 Jun 2004 17:12: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 66133-09; Sat, 5 Jun 2004 20:12:31 +0000 (GMT) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP + id A36ECD1B1D1; Sat, 5 Jun 2004 17:12:28 -0300 (ADT) +X-TFF-CGPSA-Version: 1.2.7 +X-TFF-CGPSA-Filter: Scanned +Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) + by noao.edu (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 12292472; Sat, 05 Jun 2004 13:12:29 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.8) with ESMTP id i55KCTQ5016107; + Sat, 5 Jun 2004 13:12:29 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.12.8/8.12.8/Submit) id i55KCTfs016105; + Sat, 5 Jun 2004 13:12:29 -0700 +X-Authentication-Warning: weaver.tuc.noao.edu: swampler set sender to + swampler@noao.edu using -f +Subject: Using a COPY...FROM through JDBC? +From: Steve Wampler +Reply-To: swampler@noao.edu +To: Postgres-JDBC , + Postgres-performance +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: National Solar Observatory +Message-Id: <1086466349.29063.76.camel@weaver.tuc.noao.edu> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Sat, 05 Jun 2004 13:12:29 -0700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/22 +X-Sequence-Number: 10224 + + +I've got a simple database (no indices, 6 columns) that I need +to write data quickly into through JDBC connections from +multiple such connections simultaneously in a distributed +environment. (This is going to be a message logging service +for software generated messages.) + +Using a PreparedStatement, I can get about 400/s inserted. If I +(on the java side) buffer up the entries and dump them in large +transaction blocks I can push this up to about 1200/s. I'd +like to go faster. One approach that I think might be +promising would be to try using a COPY command instead of +an INSERT, but I don't have a file for input, I have a +Java collection, so COPY isn't quite right. Is there anyway to +efficiently use COPY without having to create a file (remember +that the java apps are distributed on a LAN and aren't running +on the DB server.) Is this a dead end because of the way +COPY is implemented to only use a file? + +Is there something else I can do? Ultimately, this will end +up on a machine running 1+0 RAID, so I expect that will give +me some performance boost as well, but I'd like to push it +up as best I can with my current hardware setup. + +Thanks for any advice! +-Steve +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Sun Jun 6 07:40:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 237D6D1B1CA + for ; + Sun, 6 Jun 2004 07:40: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 18105-07 + for ; + Sun, 6 Jun 2004 10:40:26 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id A7BC9D1B187 + for ; + Sun, 6 Jun 2004 07:40:22 -0300 (ADT) +Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1BWv4i-0000Wu-00 + for ; Sun, 06 Jun 2004 12:40:24 +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 ; Sun, 06 Jun 2004 12:40:24 +0200 +Received: from hf517 by srv.protecting.net with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Sun, 06 Jun 2004 12:40:24 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Harald Fuchs +Subject: Re: Slow in morning hours +Date: 05 Jun 2004 22:54:31 +0200 +Organization: Linux Private Site +Lines: 21 +Message-ID: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> + <40361DBE.3636.10FEBF@localhost> +Reply-To: hf517@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=1.3 tagged_above=0.0 required=5.0 + tests=DATE_IN_PAST_12_24, FROM_ENDS_IN_NUMS +X-Spam-Level: * +X-Archive-Number: 200406/48 +X-Sequence-Number: 7106 + +In article <40361DBE.3636.10FEBF@localhost>, + writes: + +> Hi All, +> I am using Linux 7.2 and postgresql 7.2. + +> Our Office hours are over at 6pm but we use to keep our server +> running 24 hours a day. On the second day morning, Our PGSQL +> Server becomes very slow. + +> After continuous usage of one hour, It gradually starts responding +> faster ! This has become every day routine ! + +> do u have any idea related to this !!!! Is there any other reason that I +> need to check up? + +> Please any any idea to get relief daily morning problem !! + +I guess you're doing a VACUUM at night which invalidates the buffer +cache. If that's what happens, it's easy to fix: run some dummy +queries after the VACUUM which cause the buffer cache to get filled. + + +From pgsql-performance-owner@postgresql.org Sun Jun 6 08:09:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 35A37D1B1DA + for ; + Sun, 6 Jun 2004 08: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 25962-07 + for ; + Sun, 6 Jun 2004 11:08:52 +0000 (GMT) +Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id C4072D1B1CA + for ; + Sun, 6 Jun 2004 08:08:44 -0300 (ADT) +Received: from [127.0.0.1] (helo=localhost) + by stan.aopsys.com with esmtp (Exim 4.30) id 1BWvW7-0003we-LI + for pgsql-performance@postgresql.org; Sun, 06 Jun 2004 13:08:43 +0200 +To: pgsql-performance@postgresql.org +Subject: Query involving views +From: Laurent Martelli +Date: Sun, 06 Jun 2004 13:08:43 +0200 +Message-ID: <87pt8dt03o.fsf@stan.aopsys.com> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/49 +X-Sequence-Number: 7107 + +Hello again, + +This question is related to my previous one (Unused table of view, see +http://archives.postgresql.org/pgsql-performance/2004-06/msg00043.php). +For the moment, I have queries where I join tables by hand. Since a +few tables are always joined together, I thought I could define a view +to centralize this and make my queries more readable. But I then +observe a drop in performances on some queries because it seems the +view is not "broken" by the planner, so some optimizations cannot +occur anymore. Maybe this assertion is plain wrong, it's just my +feeling of the situation. + +I'm using postgresql 7.4.2 on Debian GNU/Linux. + +Here are the details of my tables, queries and views: + +CREATE TABLE pictures ( + PictureID serial PRIMARY KEY, + RollID character varying(64) NOT NULL REFERENCES rolls, + FrameID character varying(64) NOT NULL, + Description character varying(255), + Filename character varying(255), + Owner integer NOT NULL REFERENCES users, + EntryDate datetime DEFAULT now(), + Date datetime, + NbClick integer DEFAULT 0, + NbRates integer DEFAULT 0, + MaxRate int2, + MinRate int2, + AverageRate float4 DEFAULT 5, + SumRates integer DEFAULT 0); + +-- Each picture can belong to a number of topics +CREATE TABLE topicscontent ( + TopicID integer REFERENCES topics ON DELETE cascade, + PictureID integer REFERENCES pictures ON DELETE cascade, + Direct boolean NOT NULL, + PRIMARY KEY (TopicID,PictureID) ); + +-- Each picture can be viewed by a number of groups +CREATE TABLE permissions ( + GroupID integer NOT NULL REFERENCES groups ON DELETE cascade, + PictureID integer NOT NULL REFERENCES pictures ON DELETE cascade, + UNIQUE (GroupID, PictureID)); + +-- Each user can belong to a number of groups +CREATE TABLE groupsdef ( + UserID integer REFERENCES users, + GroupID integer REFERENCES groups, + PRIMARY KEY (UserID,GroupID)); + +-- Each picture can have a number of keywords +CREATE TABLE keywords ( + Type integer, + PictureID integer NOT NULL REFERENCES pictures ON DELETE cascade, + Value character varying(128) NOT NULL, + UNIQUE (Type,PictureID,Value)); + + +Without views, if I want all the picture with a keyword value of +'laurent' that a user with ID of 2 can see, sorted by AverageRate: + +SELECT DISTINCT ON (AverageRate,PictureID) P.* + FROM Pictures AS P, GroupsDef AS G, Permissions AS A, Keywords AS K + WHERE P.PictureID=A.PictureID + AND G.GroupID=A.GroupID + AND K.Value in ('laurent') + AND K.PictureID=P.PictureID + AND UserID=2 + ORDER BY AverageRate,PictureID; + +QUERY PLAN + + Unique (cost=528.93..532.71 rows=504 width=97) (actual time=32.447..33.062 rows=274 loops=1) + -> Sort (cost=528.93..530.19 rows=504 width=97) (actual time=32.443..32.590 rows=505 loops=1) + Sort Key: p.averagerate, p.pictureid + -> Hash Join (cost=297.36..506.31 rows=504 width=97) (actual time=12.495..29.312 rows=505 loops=1) + Hash Cond: ("outer".groupid = "inner".groupid) + -> Hash Join (cost=292.14..466.79 rows=900 width=101) (actual time=12.056..26.180 rows=750 loops=1) + Hash Cond: ("outer".pictureid = "inner".pictureid) + -> Seq Scan on permissions a (cost=0.00..125.05 rows=8305 width=8) (actual time=0.007..6.271 rows=8305 loops=1) + -> Hash (cost=291.43..291.43 rows=285 width=101) (actual time=11.961..11.961 rows=0 loops=1) + -> Hash Join (cost=110.26..291.43 rows=285 width=101) (actual time=6.378..11.573 rows=274 loops=1) + Hash Cond: ("outer".pictureid = "inner".pictureid) + -> Seq Scan on pictures p (cost=0.00..68.33 rows=2933 width=97) (actual time=0.007..2.426 rows=2933 loops=1) + -> Hash (cost=109.55..109.55 rows=285 width=4) (actual time=6.163..6.163 rows=0 loops=1) + -> Seq Scan on keywords k (cost=0.00..109.55 rows=285 width=4) (actual time=0.032..5.929 rows=274 loops=1) + Filter: ((value)::text = 'laurent'::text) + -> Hash (cost=5.19..5.19 rows=12 width=4) (actual time=0.217..0.217 rows=0 loops=1) + -> Seq Scan on groupsdef g (cost=0.00..5.19 rows=12 width=4) (actual time=0.038..0.197 rows=11 loops=1) + Filter: (userid = 2) + Total runtime: 33.554 ms + +Now, if I use the following view to abstract access rights: + +CREATE VIEW userpictures ( + PictureID,RollID,FrameID,Description,Filename, + Owner,EntryDate,Date, + NbClick,NbRates,MaxRate,MinRate,AverageRate,SumRates, + UserID) + AS SELECT DISTINCT ON (Permissions.PictureID,UserID) + Pictures.PictureID,RollID,FrameID,Description,Filename,Owner, + EntryDate,Date,NbClick,NbRates,MaxRate,MinRate,AverageRate,SumRates, + UserID + FROM Permissions + JOIN Groupsdef using (GroupID) + JOIN pictures using (PictureID); + +The query I use is: + +SELECT P.* + FROM UserPictures AS P, Keywords AS K + WHERE P.PictureID=K.PictureID + AND K.Value in ('laurent') + AND UserID=2 + ORDER BY AverageRate,PictureID; + +QUERY PLAN + + Sort (cost=1126.98..1128.54 rows=622 width=438) (actual time=142.053..142.132 rows=274 loops=1) + Sort Key: p.averagerate, p.pictureid + -> Merge Join (cost=995.75..1098.12 rows=622 width=438) (actual time=116.412..140.481 rows=274 loops=1) + Merge Cond: ("outer".pictureid = "inner".pictureid) + -> Subquery Scan p (cost=874.58..955.99 rows=4652 width=438) (actual time=108.709..130.049 rows=2361 loops=1) + -> Unique (cost=874.58..909.47 rows=4652 width=105) (actual time=108.685..119.661 rows=2361 loops=1) + -> Sort (cost=874.58..886.21 rows=4652 width=105) (actual time=108.676..110.185 rows=4403 loops=1) + Sort Key: permissions.pictureid, groupsdef.userid + -> Hash Join (cost=388.35..591.19 rows=4652 width=105) (actual time=32.031..63.322 rows=5076 loops=1) + Hash Cond: ("outer".pictureid = "inner".pictureid) + -> Seq Scan on pictures (cost=0.00..68.33 rows=2933 width=97) (actual time=0.011..2.836 rows=2933 loops=1) + -> Hash (cost=376.72..376.72 rows=4652 width=8) (actual time=31.777..31.777 rows=0 loops=1) + -> Merge Join (cost=5.40..376.72 rows=4652 width=8) (actual time=0.285..27.805 rows=5076 loops=1) + Merge Cond: ("outer".groupid = "inner".groupid) + -> Index Scan using permissions_groupid_key on permissions (cost=0.00..280.77 rows=8305 width=8) (actual time=0.031..13.018 rows=7633 loops=1) + -> Sort (cost=5.40..5.43 rows=12 width=8) (actual time=0.237..1.762 rows=5078 loops=1) + Sort Key: groupsdef.groupid + -> Seq Scan on groupsdef (cost=0.00..5.19 rows=12 width=8) (actual time=0.034..0.203 rows=11 loops=1) + Filter: (userid = 2) + -> Sort (cost=121.17..121.88 rows=285 width=4) (actual time=6.987..7.065 rows=274 loops=1) + Sort Key: k.pictureid + -> Seq Scan on keywords k (cost=0.00..109.55 rows=285 width=4) (actual time=0.056..6.656 rows=274 loops=1) + Filter: ((value)::text = 'laurent'::text) + Total runtime: 144.045 ms + +To me the only difference between the queries is that second one +includes a UserID column. One strange thing is that width from 105 +jumps to 438 during "Subquery Scan p". + +I think it's because of DISTINCT ON in the view. If I use this view: + + +CREATE VIEW userpictures ( + PictureID,RollID,FrameID,Description,Filename, + Owner,EntryDate,Date, + NbClick,NbRates,MaxRate,MinRate,AverageRate,SumRates, + UserID) + AS SELECT Pictures.PictureID,RollID,FrameID,Description,Filename,Owner, + EntryDate,Date,NbClick,NbRates,MaxRate,MinRate,AverageRate,SumRates, + UserID + FROM Permissions + JOIN Groupsdef using (GroupID) + JOIN pictures using (PictureID); + +and this query: + +SELECT DISTINCT ON (AverageRate,PictureID) P.* + FROM UserPictures AS P, Keywords AS K + WHERE P.PictureID=K.PictureID + AND K.Value in ('laurent') + AND UserID=2 + ORDER BY AverageRate,PictureID; + +The result is similar to the query without the view: + +QUERY PLAN + + Unique (cost=525.39..529.17 rows=504 width=101) (actual time=34.689..35.287 rows=274 loops=1) + -> Sort (cost=525.39..526.65 rows=504 width=101) (actual time=34.686..34.828 rows=505 loops=1) + Sort Key: pictures.averagerate, pictures.pictureid + -> Hash Join (cost=297.36..502.76 rows=504 width=101) (actual time=11.786..31.739 rows=505 loops=1) + Hash Cond: ("outer".groupid = "inner".groupid) + -> Hash Join (cost=292.14..466.79 rows=807 width=101) (actual time=11.409..28.389 rows=750 loops=1) + Hash Cond: ("outer".pictureid = "inner".pictureid) + -> Seq Scan on permissions (cost=0.00..125.05 rows=8305 width=8) (actual time=0.004..9.177 rows=8305 loops=1) + -> Hash (cost=291.43..291.43 rows=285 width=101) (actual time=11.319..11.319 rows=0 loops=1) + -> Hash Join (cost=110.26..291.43 rows=285 width=101) (actual time=5.919..10.961 rows=274 loops=1) + Hash Cond: ("outer".pictureid = "inner".pictureid) + -> Seq Scan on pictures (cost=0.00..68.33 rows=2933 width=97) (actual time=0.004..2.258 rows=2933 loops=1) + -> Hash (cost=109.55..109.55 rows=285 width=4) (actual time=5.700..5.700 rows=0 loops=1) + -> Seq Scan on keywords k (cost=0.00..109.55 rows=285 width=4) (actual time=0.029..5.471 rows=274 loops=1) + Filter: ((value)::text = 'laurent'::text) + -> Hash (cost=5.19..5.19 rows=12 width=8) (actual time=0.198..0.198 rows=0 loops=1) + -> Seq Scan on groupsdef (cost=0.00..5.19 rows=12 width=8) (actual time=0.031..0.178 rows=11 loops=1) + Filter: (userid = 2) + Total runtime: 35.657 ms + + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-performance-owner@postgresql.org Sun Jun 6 13:22:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C168DD1B187 + for ; + Sun, 6 Jun 2004 13:22: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 05947-04 + for ; + Sun, 6 Jun 2004 16:22:30 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A8689D1B17A + for ; + Sun, 6 Jun 2004 13:22:28 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i56GMQsC004647; + Sun, 6 Jun 2004 12:22:26 -0400 (EDT) +To: Laurent Martelli +Cc: pgsql-performance@postgresql.org +Subject: Re: Query involving views +In-reply-to: <87pt8dt03o.fsf@stan.aopsys.com> +References: <87pt8dt03o.fsf@stan.aopsys.com> +Comments: In-reply-to Laurent Martelli + message dated "Sun, 06 Jun 2004 13:08:43 +0200" +Date: Sun, 06 Jun 2004 12:22:25 -0400 +Message-ID: <4646.1086538945@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/50 +X-Sequence-Number: 7108 + +Laurent Martelli writes: +> Now, if I use the following view to abstract access rights: + +> CREATE VIEW userpictures ( +> PictureID,RollID,FrameID,Description,Filename, +> Owner,EntryDate,Date, +> NbClick,NbRates,MaxRate,MinRate,AverageRate,SumRates, +> UserID) +> AS SELECT DISTINCT ON (Permissions.PictureID,UserID) +> Pictures.PictureID,RollID,FrameID,Description,Filename,Owner, +> EntryDate,Date,NbClick,NbRates,MaxRate,MinRate,AverageRate,SumRates, +> UserID +> FROM Permissions +> JOIN Groupsdef using (GroupID) +> JOIN pictures using (PictureID); + +> [ performance sucks ] + +Find a way to get rid of the DISTINCT ON. That's essentially an +optimization fence. Worse, the way you are using it here, it doesn't +even give well-defined results, since there's no ORDER BY constraining +which row will be selected out of a set of duplicates. (I think it may +not matter to you, since you don't really care which groupsdef row is +selected, but in general a view constructed like this is broken.) + +It might work to do the view as + +SELECT ... all that stuff ... +FROM pictures p, users u +WHERE + EXISTS (SELECT 1 FROM permissions prm, groupsdef g + WHERE p.pictureid = prm.pictureid AND prm.groupid = g.groupid + AND g.userid = u.userid); + +I'm not sure offhand about the performance properties of this either, +but it would be worth trying. + +A cruder answer is just to accept that the view may give you multiple +hits, and put the DISTINCT in the top-level query. + +I think though that in the long run you're going to need to rethink this +representation of permissions. It's nice and simple but it's not going +to scale well. Even your "fast" query is going to look like a dog once +you get to many thousands of permission entries. + +It might work to maintain a derived table (basically a materialized +view) of the form (userid, groupid, pictureid) signifying that a user +can access a picture through membership in a group. Put a nonunique +index on (userid, pictureid) on it. This could then drive the EXISTS +test efficiently. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jun 6 18:12:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 09753D1B211 + for ; + Sun, 6 Jun 2004 18:12: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 90104-08 + for ; + Sun, 6 Jun 2004 21:12:30 +0000 (GMT) +Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id CC749D1B272 + for ; + Sun, 6 Jun 2004 18:12:24 -0300 (ADT) +Received: from [127.0.0.1] (helo=localhost) + by stan.aopsys.com with esmtp (Exim 4.30) + id 1BX4w4-0004Dh-Bn; Sun, 06 Jun 2004 23:12:08 +0200 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Query involving views +References: <87pt8dt03o.fsf@stan.aopsys.com> <4646.1086538945@sss.pgh.pa.us> +From: Laurent Martelli +Organization: AOPSYS +Date: Sun, 06 Jun 2004 23:12:07 +0200 +In-Reply-To: <4646.1086538945@sss.pgh.pa.us> (Tom Lane's message of "Sun, 06 + Jun 2004 12:22:25 -0400") +Message-ID: <87llj0tmqg.fsf@stan.aopsys.com> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/51 +X-Sequence-Number: 7109 + +>>>>> "Tom" == Tom Lane writes: + + Tom> Laurent Martelli writes: + >> Now, if I use the following view to abstract access rights: + + >> CREATE VIEW userpictures ( + >> PictureID,RollID,FrameID,Description,Filename, + >> Owner,EntryDate,Date, + >> NbClick,NbRates,MaxRate,MinRate,AverageRate,SumRates, UserID) AS + >> SELECT DISTINCT ON (Permissions.PictureID,UserID) + >> Pictures.PictureID,RollID,FrameID,Description,Filename,Owner, + >> EntryDate,Date,NbClick,NbRates,MaxRate,MinRate,AverageRate,SumRates, + >> UserID FROM Permissions JOIN Groupsdef using (GroupID) JOIN + >> pictures using (PictureID); + + >> [ performance sucks ] + + Tom> Find a way to get rid of the DISTINCT ON. That's essentially + Tom> an optimization fence. Worse, the way you are using it here, + Tom> it doesn't even give well-defined results, since there's no + Tom> ORDER BY constraining which row will be selected out of a set + Tom> of duplicates. (I think it may not matter to you, since you + Tom> don't really care which groupsdef row is selected, + +That's true. I do not use columns from groupsdef in the end. + + Tom> but in general a view constructed like this is broken.) + + Tom> It might work to do the view as + + Tom> SELECT ... all that stuff ... FROM pictures p, users u WHERE + Tom> EXISTS (SELECT 1 FROM permissions prm, groupsdef g WHERE + Tom> p.pictureid = prm.pictureid AND prm.groupid = g.groupid AND + Tom> g.userid = u.userid); + + Tom> I'm not sure offhand about the performance properties of this + Tom> either, but it would be worth trying. + +This one does not yield very good performance. In fact, the best +performances I have is when I use a where clause like this one: + + WHERE PictureID IN + (SELECT PictureID FROM permissions JOIN groupsdef USING(GroupID) + WHERE groupsdef.UserID=2) + +But it's not as elegant to write as the initial view using "distinct +on". I could create a view like this: + + CREATE VIEW userpictures (PictureID,UserID) + AS SELECT pictureid,userid + FROM permissions JOIN groupsdef USING(GroupID) + +and then do queries like this: + + SELECT * FROM pictures + WHERE PictureID IN (SELECT PictureID FROM userpictures WHERE UserID=2) + +but it's stillnot as elegant as + + SELECT * FROM userpictures WHERE UserID=2 + +I think I'll try a function: + +CREATE FUNCTION picturesID(int) RETURNS SETOF int AS ' + SELECT PictureID FROM permissions JOIN groupsdef USING(GroupID) + WHERE groupsdef.UserID=$1 +' LANGUAGE sql; + +SELECT * FROM pictures WHERE PictureID IN (select * from picturesID(2)); + +Here's something funny: using a function seems gives slihtly better results +than inlining the query (I did a dozen of runs and the timings were consistent): + +SELECT * FROM pictures WHERE PictureID IN (select * from picturesID(2)); +QUERY PLAN + Hash Join (cost=15.50..100.49 rows=200 width=97) (actual time=28.609..46.568 rows=2906 loops=1) + Hash Cond: ("outer".pictureid = "inner".picturesid) + -> Seq Scan on pictures (cost=0.00..68.33 rows=2933 width=97) (actual time=0.018..2.610 rows=2933 loops=1) + -> Hash (cost=15.00..15.00 rows=200 width=4) (actual time=28.467..28.467 rows=0 loops=1) + -> HashAggregate (cost=15.00..15.00 rows=200 width=4) (actual time=23.698..26.201 rows=2906 loops=1) + -> Function Scan on picturesid (cost=0.00..12.50 rows=1000 width=4) (actual time=16.202..19.952 rows=5076 loops=1) + Total runtime: 48.601 ms + +SELECT * FROM pictures WHERE PictureID IN ( + SELECT PictureID FROM permissions JOIN groupsdef USING(GroupID) + WHERE groupsdef.UserID=2); +QUERY PLAN + + Hash Join (cost=394.93..504.24 rows=2632 width=97) (actual time=35.770..53.574 rows=2906 loops=1) + Hash Cond: ("outer".pictureid = "inner".pictureid) + -> Seq Scan on pictures (cost=0.00..68.33 rows=2933 width=97) (actual time=0.014..2.543 rows=2933 loops=1) + -> Hash (cost=388.35..388.35 rows=2632 width=4) (actual time=35.626..35.626 rows=0 loops=1) + -> HashAggregate (cost=388.35..388.35 rows=2632 width=4) (actual time=30.988..33.502 rows=2906 loops=1) + -> Merge Join (cost=5.40..376.72 rows=4652 width=4) (actual time=0.247..26.628 rows=5076 loops=1) + Merge Cond: ("outer".groupid = "inner".groupid) + -> Index Scan using permissions_groupid_key on permissions (cost=0.00..280.77 rows=8305 width=8) (actual time=0.031..11.629 rows=7633 loops=1) + -> Sort (cost=5.40..5.43 rows=12 width=4) (actual time=0.207..1.720 rows=5078 loops=1) + Sort Key: groupsdef.groupid + -> Seq Scan on groupsdef (cost=0.00..5.19 rows=12 width=4) (actual time=0.030..0.182 rows=11 loops=1) + Filter: (userid = 2) + Total runtime: 54.748 ms + + Tom> A cruder answer is just to accept that the view may give you + Tom> multiple hits, and put the DISTINCT in the top-level query. + +I thought of that. But it has the drawback that if you use an ORDER +BY, you must have the same columns in the DISTINCT. + + Tom> I think though that in the long run you're going to need to + Tom> rethink this representation of permissions. It's nice and + Tom> simple but it's not going to scale well. Even your "fast" + Tom> query is going to look like a dog once you get to many + Tom> thousands of permission entries. + + Tom> It might work to maintain a derived table (basically a + Tom> materialized view) of the form (userid, groupid, pictureid) + Tom> signifying that a user can access a picture through membership + Tom> in a group. Put a nonunique index on (userid, pictureid) on + Tom> it. This could then drive the EXISTS test efficiently. + +I'll probably do that if perf goes down when the database grows +bigger. + +Thanks for all the advice. + +Best regards, +Laurent + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-jdbc-owner@postgresql.org Sun Jun 6 19:26:03 2004 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP + id A73D1D1B8BB; Sun, 6 Jun 2004 19:09: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 26329-01; Sun, 6 Jun 2004 22:09:50 +0000 (GMT) +Received: from mail.logi-track.com (www.logi-track.com [213.239.193.212]) + by svr1.postgresql.org (Postfix) with ESMTP + id 29CA9D1B8C4; Sun, 6 Jun 2004 19:09:47 -0300 (ADT) +Received: from kingfisher.intern.logi-track.com + (p83.129.169.125.tisdip.tiscali.de [83.129.169.125]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logi-track.com (Postfix) with ESMTP + id 2527430187; Sun, 6 Jun 2004 22:11:24 +0000 (UTC) +Date: Mon, 7 Jun 2004 00:08:00 +0200 +From: Markus Schaber +To: swampler@noao.edu +Cc: Postgres-JDBC , + Postgres-performance +Subject: Re: Using a COPY...FROM through JDBC? +Message-Id: <20040607000800.636d7353@kingfisher.intern.logi-track.com> +In-Reply-To: <1086466349.29063.76.camel@weaver.tuc.noao.edu> +References: <1086466349.29063.76.camel@weaver.tuc.noao.edu> +Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= +X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i386-pc-linux-gnu) +X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; + UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; + Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K wrote: + +> I've got a simple database (no indices, 6 columns) that I need +> to write data quickly into through JDBC connections from +> multiple such connections simultaneously in a distributed +> environment. (This is going to be a message logging service +> for software generated messages.) +> Using a PreparedStatement, I can get about 400/s inserted. If I +> (on the java side) buffer up the entries and dump them in large +> transaction blocks I can push this up to about 1200/s. I'd +> like to go faster. One approach that I think might be +> promising would be to try using a COPY command instead of +> an INSERT, but I don't have a file for input, I have a=20 +> Java collection, so COPY isn't quite right. Is there anyway to +> efficiently use COPY without having to create a file (remember +> that the java apps are distributed on a LAN and aren't running +> on the DB server.) Is this a dead end because of the way +> COPY is implemented to only use a file? + +We also found that using the psql frontend, using COPY seems to give a +factor 10 or more speedup. Sadly, as far as I learned, the current JDBC +driver does not support COPY ... FROM STDIN. + +As a very bad workaround, it might be acceptable to use Runtime.exec() +to start the psql command line tool, and issue the statement there, or +even add a C-lib via JNI. Of course, the best "workaround" would be to +implement COPY support for the driver, and send the Patches to the +PGJDBC team for inclusion :-) + +We also had to do some trickery to get instertion of lots of rows fast. +We dit lots of benchmarks, and currently use the following method: + +Our input data is divided into chunks (the optimal size depends on the +machine, and seems to be between 250 and 3000). As the current pgjdbc +preparedStatements implementation just does a text replacement, but we +wantedto get the last bit of speed out of the machine, we issue a +"PREPARE" statement for the insertion on connection setup, and then +addBatch() a "EXECUTE blubb (data, row, values)" statement. + +Then we have several concurrent threads, all running essentially a {get +batch, write batch, commit} loop on their own connection. Increasing +the thread number to more than three did not show further substantial +performance improvements. This lead us to the conclusion that +concurrency can compensate for the time the postmaster is forced to wait +while it syncs the WAL to disk, but there's still a concurrency limit +inside of postgres for inserts (I presume they have to lock at some +times, the multiversioning seems not to cover inserts very well). + +Also, we surprisingly found that setting the transaction isolation to +"serializable" can speed things remarkably in some cases... + +> Is there something else I can do? Ultimately, this will end +> up on a machine running 1+0 RAID, so I expect that will give +> me some performance boost as well, but I'd like to push it +> up as best I can with my current hardware setup. + +As any sane setup runs with syncing enabled in the backend, and each +sync (and so each commit) at least has to write at least one block, you +can calculate the theoretical maximum number of commits your machine can +achieve. + +If you have 15k rpm disks (AFAIK, the fastest one currently available), +they spin at 250 rotations per second, so you cannot have more than 250 +commits per second. + +Regarding the fact that your machine has to do some works between the +sync() calls (e. G. processing the whole next batch), it is very likely +that it misses the next turn, so that you're likely to get a factor 2 or +3 number in reality. + +One way to overcome this limit is using multiple writer threads, and +(having a highly capable I/O sybsystem) enabling commit delay in your +backend so that you can have more than one commit during the same write +operation. + +It might also help to put the WAL log to a different disk (just link or +mount or mount --bind the appropriate subdirectory in your database), or +even put the indices on a third disk (needs ugly trickery) - it's a +shame that postmaster does not really support this techniques which are +considered standard in any professional database. + +If you really need much more speed, that you could try to put the WAL +on a Solid State Disk (essentially a battery-backed RAM) so you can +overcome this physical limit, or (if you really trust your hardware and +your power supply) put the WAL into a RAMDISK or switch of syncing in +your postmaster configuration. + +One thing you should check is whether I/O or CPU is the limiting factor. +If you have a cpu utilization higher than 90%, than all the tricks I +told you won't help much. (But using COPY still could help a lot as it +cut's down the CPU usage very much.) + +We tested with two machines, a single-processor developer machine, and a +2-way 64-Bit Itanium SMP machine. On the desktop machine, a single +thread already utilized 80% CPU, and so only small improvement was +possible using 2 or more threads.=20 + +On the SMP machine, we had substantial improvements using 2 or 3 +threads, but then going up to 8 threads gave no more remarkable speedup +constantly utilizing about 120% CPU (Remember we have a 2-way machine). +I think that there are some internal postgres locks that prohibit +further concurrency for inserts in the same table. + +> Thanks for any advice! + +Hope, that helps, +Markus Schaber + +--=20 +markus schaber | dipl. informatiker +logi-track ag | rennweg 14-16 | ch 8001 z=FCrich +phone +41-43-888 62 52 | fax +41-43-888 62 53 +mailto:schabios@logi-track.com | www.logi-track.com + +From pgsql-performance-owner@postgresql.org Mon Jun 7 02:54:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3A87D1B178 + for ; + Mon, 7 Jun 2004 02:54: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 74289-09 + for ; + Mon, 7 Jun 2004 05:54:03 +0000 (GMT) +Received: from loki.globexplorer.com (unknown [208.35.14.101]) + by svr1.postgresql.org (Postfix) with ESMTP id A0FB5D1B1BD + for ; + Mon, 7 Jun 2004 02:53: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="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: General performance questions about postgres on Apple +Date: Sun, 6 Jun 2004 22:54:00 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A256832801057A97@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] General performance questions about postgres on Apple +Thread-Index: AcRMUBvU/rQ97auuSiuzHW2IDYb/nwAA27uD +From: "Gregory S. Williamson" +To: "Sean Shanny" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/54 +X-Sequence-Number: 7112 + + +Why is my name on a mail from Tom Lane ? Really, he knows a *lot* more than= + I and should get due credit. + +Seriously, is this the peformance remailer mangling something ? + +Greg Williamson +(the real one) + +-----Original Message----- +From: Gregory S. Williamson +Sent: Sun 6/6/2004 10:46 PM +To: Sean Shanny +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] General performance questions about postgres on Apple +In-reply-to: <40396A16.9040301@earthlink.net>=20 +References: + <403682D6.60807@earthlink.net> <19368.1077492611@sss.pgh.pa.us> + <40396A16.9040301@earthlink.net> +Comments: In-reply-to Sean Shanny message + dated "Sun, 22 Feb 2004 21:48:54 -0500" +Date: Sun, 22 Feb 2004 22:24:29 -0500 +Message-ID: <20382.1077506669@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Mailing-List: pgsql-performance +Precedence: bulk +Sender: pgsql-performance-owner@postgresql.org +X-imss-version: 2.5 +X-imss-result: Passed +X-imss-scores: Clean:99.90000 C:21 M:2 S:5 R:5 +X-imss-settings: Baseline:2 C:2 M:2 S:2 R:2 (0.1500 0.3000) +Return-Path: pgsql-performance-owner+M5783@postgresql.org +X-OriginalArrivalTime: 07 Jun 2004 05:27:21.0994 (UTC) FILETIME=3D[1BC0EEA0= +:01C44C50] + +Sean Shanny writes: +> We have the following setting for random page cost: +> random_page_cost =3D 1 # units are one sequential page fetch c= +ost +> Any suggestions on what to bump it up to? + +Well, the default setting is 4 ... what measurements prompted you to +reduce it to 1? The particular example you showed suggested that the +true value on your setup might be 10 or more. + +Now I would definitely not suggest that you settle on any particular +value based on only one test case. You need to try to determine an +appropriate average value, bearing in mind that there's likely to be +lots of noise in any particular measurement. + +But in general, setting random_page_cost to 1 is only reasonable when +you are dealing with a fully-cached-in-RAM database, which yours isn't. + + regards, tom lane + +---------------------------(end of broadcast)--------------------------- +TIP 8: explain analyze is your friend + + + + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 04:39:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C2DFD1B17C + for ; + Mon, 7 Jun 2004 04:35: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 15003-04 + for ; + Mon, 7 Jun 2004 07:35:46 +0000 (GMT) +Received: from fe07.axelero.hu (fe07.axelero.hu [195.228.240.95]) + by svr1.postgresql.org (Postfix) with ESMTP id E9E15D1B178 + for ; + Mon, 7 Jun 2004 04:35:42 -0300 (ADT) +Received: from fe07 (localhost-02 [127.0.2.1]) + by fe07.axelero.hu (8.12.11/8.12.11) with SMTP id i577Zhwr086237 + for ; + Mon, 7 Jun 2004 09:35:43 +0200 (CEST) +Received: from fe07.axelero.hu [127.0.2.1] via SMTP gateway + by fe07 [195.228.240.95]; id A050CD2D753 + at Mon, 07 Jun 2004 09:35:43 +0200 +Received: from fejleszt4 (121-248-182-81.adsl-fixip.axelero.hu + [81.182.248.121]) + by fe07.axelero.hu (8.12.11/8.12.11) with SMTP id i577ZcGD085926 + for ; + Mon, 7 Jun 2004 09:35:38 +0200 (CEST) +Message-ID: <076f01c44c62$208aa680$0403a8c0@fejleszt4> +From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" +To: +Subject: Relation of cpu_*_costs? +Date: Mon, 7 Jun 2004 09:36:19 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-2" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-RAVMilter-Version: 8.4.3(snapshot 20030217) (fe07.axelero.hu) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/55 +X-Sequence-Number: 7113 + +Dear Gurus, + +Please feel free to show me to the archives if my question has already been +answered. + +Last week I fumbled with CPU_TUPLE_COST and revealed that 4 out of 4 tested +queries improved by 10-60% if I changed it from 0.01 (default) to 0.40 +(ugh). Setting it higher did not bring any improvement. + +%----------------------- cut here -----------------------% +QUESTION1: is there a (theoretical or practical) relation between this one +and the other cpu costs? Should I also increase those values by the same +rate and find a balance that way? + +As far as I can guess, there should be a linear relation, i.e. +cpu_tuple_cost:cpu_index_tuple_cost:cpu_operator_cost should be a constant +ratio, but then again, I suspect there is a cause that they have separate +entries in the config file ;) + + +%----------------------- cut here -----------------------% +The queries were, or contained, something like: + + SELECT s.qty FROM a, s WHERE a.id = s.a_id AND a.b_id = 1234; + +where +* "a" and "s" are in 1:N relation, +* "b" and "a" are in 1:N relation, +* a.id is pkey in "a" and b.id is pkey in "b". + +These queries usually return up to 6-10% of the tuples in s (about 16k of +220k) and the planner chose seq scans on s. Disabling seq scan and some +other things finally brought up a plan containing index scans that improved +two queries. (I tested the other two after I found out the solution of +these, to see if they improve or get worse) + +Also noticed that the largest gain was from the smallest change on +cpu_tuple_cost: the query with the largest improvement (to 32% of orig time) +chose the better plan from 0.03, but the other one improved (to 79%) only if +set cpu_tuple_cost to 0.40 or higher. + + +%----------------------- cut here -----------------------% +QUESTION2: am I right setting cpu_tuple_cost, or may there be another cause +of poor plan selection? Also tried lowering random_page_cost, but even 1.0 +didn't yield any improvement. + + +%----------------------- cut here -----------------------% +CONFIGURATION: PostgreSQL 7.3.4, IBM Xeon 2x2.4GHz HT, 5x36GB 10krpm HW +RAID-5. + +We found out quite early that random page cost is quite low (now we have it +at 1.5-- maybe it's still to high) and it's true that tasks that require raw +cpu power aren't very much faster than PIII-800. Unfortunately I can't test +the same hw on 7.4 yet, since it's a production server. + +TIA, +G. +%----------------------- cut here -----------------------% +\end + + +From pgsql-jdbc-owner@postgresql.org Mon Jun 7 04:49:57 2004 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP + id 25643D1B1AC; Mon, 7 Jun 2004 04:49: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 15947-10; Mon, 7 Jun 2004 07:49:48 +0000 (GMT) +Received: from mail.logi-track.com (www.logi-track.com [213.239.193.212]) + by svr1.postgresql.org (Postfix) with ESMTP + id 454CCD1B188; Mon, 7 Jun 2004 04:49:45 -0300 (ADT) +Received: from kingfisher.intern.logi-track.com (G7ccb.g.pppool.de + [80.185.124.203]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logi-track.com (Postfix) with ESMTP + id F408230165; Mon, 7 Jun 2004 07:51:23 +0000 (UTC) +Date: Mon, 7 Jun 2004 09:47:58 +0200 +From: Markus Schaber +Cc: Postgres-JDBC , + Postgres-performance +Subject: Re: Using a COPY...FROM through JDBC? +Message-Id: <20040607094758.5eb0bf71@kingfisher.intern.logi-track.com> +In-Reply-To: <20040607000800.636d7353@kingfisher.intern.logi-track.com> +References: <1086466349.29063.76.camel@weaver.tuc.noao.edu> + <20040607000800.636d7353@kingfisher.intern.logi-track.com> +Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= +X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i386-pc-linux-gnu) +X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; + UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; + Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K; + Mon, 7 Jun 2004 07:22: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 04501-04 + for ; + Mon, 7 Jun 2004 10:22:28 +0000 (GMT) +Received: from mail63.csoft.net (unknown [63.111.22.74]) + by svr1.postgresql.org (Postfix) with SMTP id 87674D1B26D + for ; Mon, 7 Jun 2004 07:22:24 -0300 (ADT) +Received: (qmail 31580 invoked by uid 1112); 7 Jun 2004 09:26:38 -0000 +Date: Mon, 7 Jun 2004 04:26:38 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary.csoft.net +To: Steve Wampler +Cc: Postgres-JDBC , + Postgres-performance +Subject: Re: Using a COPY...FROM through JDBC? +In-Reply-To: <1086466349.29063.76.camel@weaver.tuc.noao.edu> +Message-ID: +References: <1086466349.29063.76.camel@weaver.tuc.noao.edu> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/33 +X-Sequence-Number: 10235 + + + +On Sat, 5 Jun 2004, Steve Wampler wrote: + +> +> [I want to use copy from JDBC] +> + +I made a patch to the driver to support COPY as a PG extension. The +patch required properly encoded and formatted copy data available +from an InputStream. Following some feedback from others I began adding +the ability to handle different encodings and the ability to read and +write objects without requiring any knowledge of the copy data format. I +got hung up on the object read/write part because of some issues with how +type conversions are done in the driver. + +At the moment there is a big push being made by Oliver Jowett to get true +V3 protocol support implemented which is currently my highest priority. +Getting copy support into the JDBC driver is something I'd like to see for +7.5, but I couldn't say if that will happen or how complete it may be. +Depending on your needs perhaps the initial patch is sufficient. + +http://archives.postgresql.org/pgsql-jdbc/2003-12/msg00186.php + +Kris Jurka + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 08:35:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3830FD1B276 + for ; + Mon, 7 Jun 2004 08:35: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 32529-08 + for ; + Mon, 7 Jun 2004 11:35:18 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F46ED1B238 + for ; + Mon, 7 Jun 2004 08:35:00 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 47FED2BDE8 + for ; + Mon, 7 Jun 2004 13:34:45 +0200 (SAST) +Received: from ucsns.ucs.co.za ([127.0.0.1]) + by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 20705-07 for ; + Mon, 7 Jun 2004 13:34:16 +0200 (SAST) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 19BCF2BDDF + for ; + Mon, 7 Jun 2004 13:34:16 +0200 (SAST) +Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) + by ucspost.ucs.co.za (Postfix) with ESMTP id E11C5D9F6A + for ; + Mon, 7 Jun 2004 13:34:15 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with SMTP id B8E4297642 + for ; + Mon, 7 Jun 2004 13:34:15 +0200 (SAST) +Date: Mon, 7 Jun 2004 13:34:15 +0200 +From: Stef +To: pgsql-performance@postgresql.org +Subject: Postgres function use makes machine crash. +Message-Id: <20040607133415.09a2ce2f@svb.ucs.co.za> +X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? + Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. +X-Operating-System: sid +X-X-X: _-^-_ +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="Multipart=_Mon__7_Jun_2004_13_34_15_+0200_pHQJTKtA2k4B5Fq7" +X-Virus-Scanned: by amavisd-new at ucs.co.za +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/58 +X-Sequence-Number: 7116 + +This is a multi-part message in MIME format. + +--Multipart=_Mon__7_Jun_2004_13_34_15_+0200_pHQJTKtA2k4B5Fq7 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit + +Hi all, + +I've been dealing with a problem for the past two days +where a certain sql statement works 2 out of 5 times, and +the other 3 times, it causes the machine (quad Xeon 2.8GHz ++ 792543232 bytes mem, linux kernel 2.4.26-custom, pg ver 7.3.4) +to slow down, and finally grind to a halt. It looks like postgres +gets itself into an insane loop, because no matter how much +shared memory I give it, it uses it all, and then +the kernel starts swapping. + +I'm pretty sure it's not the kernel, because I've tried four different +2.4.2* stable kernels, and the same happens. + +I've attached the query, and the functions used inside the query, +as well as the table structure and an explain. (I haven't been +able to get explain analyze) + +It seems that when I replace the functions used in the query, +with the actual values returned by them (one date in each case), +the query runs in 10 seconds. + +I did vacuum analyze, and reindex seemed to work at one +stage, but now it doesn't anymore. + +Is there some limitation in using functions that I do not know +about, or is it a bug? + +(It seems to be hanging on the max_fpp('''') +function call from inside the fpp_max_ms() function.) + +Please help. + +Kind Regards +Stefan + +--Multipart=_Mon__7_Jun_2004_13_34_15_+0200_pHQJTKtA2k4B5Fq7 +Content-Type: application/octet-stream; + name="query.sql" +Content-Disposition: attachment; + filename="query.sql" +Content-Transfer-Encoding: base64 + +Q1JFQVRFIFRBQkxFIGdpcl9vdXRzdGFuZGluZ19hZ2VkCkFTICgKU0VMRUNU +ICAgIGdyb3VwX2NvZGU6OnRleHQgICAgICAgICAgICAgICAgICAgICAgICAg +IEFTIGdyb3VwX2NvZGUsCiAgICAgICAgICBza3U6OnRleHQgICAgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICBBUyBza3UsCiAgICAgICAgICBzdGt0 +eXBlX2NvZGU6OnZhcmNoYXIoMikgICAgICAgICAgICAgICAgICBBUyBzdGt0 +eXBlX2NvZGUsCiAgICAgICAgICBicm5fY29kZTo6dGV4dCAgICAgICAgICAg +ICAgICAgICAgICAgICAgICBBUyBicm5fY29kZSwKICAgICAgICAgIFNVTShv +dmVyZHVlKTo6aW50NCAgICAgICAgICAgICAgICAgICAgICAgIEFTIG92ZXJk +dWUsCiAgICAgICAgICBTVU0oY3VycmVudCk6OmludDQgICAgICAgICAgICAg +ICAgICAgICAgICBBUyBjdXJyZW50LAogICAgICAgICAgU1VNKGZ1dHVyZSk6 +OmludDQgICAgICAgICAgICAgICAgICAgICAgICAgQVMgZnV0dXJlCkZST00g +KApTRUxFQ1QgICAgZ3JvdXBfY29kZSwKICAgICAgICAgIHNrdSwKICAgICAg +ICAgIHN0a3R5cGVfY29kZSwKICAgICAgICAgIGJybl9jb2RlLAogICAgICAg +ICAgQ0FTRSBXSEVOIHRvX2RhdGUgPD0gbWF4X2ZwcF9tcygpIFRIRU4KICAg +ICAgICAgICAgIFNVTShvdXRfcXR5KQogICAgICAgICAgRUxTRSAgMAogICAg +ICAgICAgRU5EICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg +IEFTIG92ZXJkdWUsCiAgICAgICAgICBDQVNFIFdIRU4gdG9fZGF0ZSA+IG1h +eF9mcHBfbXMoKQogICAgICAgICAgQU5EIHRvX2RhdGUgPD0gbWF4X2ZwcF9t +ZSgpIFRIRU4KICAgICAgICAgICAgIFNVTShvdXRfcXR5KQogICAgICAgICAg +RUxTRSAwCiAgICAgICAgICBFTkQgICAgICAgICAgICAgICAgICAgICAgICAg +ICAgICAgICAgICAgQVMgY3VycmVudCwKICAgICAgICAgIENBU0UgV0hFTiB0 +b19kYXRlID4gbWF4X2ZwcF9tZSgpIFRIRU4KICAgICAgICAgICAgIFNVTShv +dXRfcXR5KQogICAgICAgICAgRUxTRSAwCiAgICAgICAgICBFTkQgICAgICAg +ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQVMgZnV0dXJlCkZST00g +Z2lyX291dHN0YW5kaW5nCkdST1VQIEJZICBncm91cF9jb2RlLAogICAgICAg +ICAgc2t1LAogICAgICAgICAgc3RrdHlwZV9jb2RlLAogICAgICAgICAgYnJu +X2NvZGUsCiAgICAgICAgICB0b19kYXRlCikgQVMgc3ViCkdST1VQIEJZICBn +cm91cF9jb2RlLAogICAgICAgICAgc2t1LAogICAgICAgICAgc3RrdHlwZV9j +b2RlLAogICAgICAgICAgYnJuX2NvZGUKKTsK + +--Multipart=_Mon__7_Jun_2004_13_34_15_+0200_pHQJTKtA2k4B5Fq7 +Content-Type: text/plain; + name="explain.txt" +Content-Disposition: attachment; + filename="explain.txt" +Content-Transfer-Encoding: 7bit + +=# EXPLAIN SELECT group_code::text AS group_code, +-# sku::text AS sku, +-# stktype_code::varchar(2) AS stktype_code, +-# brn_code::text AS brn_code, +-# SUM(overdue)::int4 AS overdue, +-# SUM(current)::int4 AS current, +-# SUM(future)::int4 AS future +-# FROM ( +(# SELECT group_code, +(# sku, +(# stktype_code, +(# brn_code, +(# CASE WHEN to_date <= max_fpp_ms() THEN +(# SUM(out_qty) +(# ELSE 0 +(# END AS overdue, +(# CASE WHEN to_date > max_fpp_ms() +(# AND to_date <= max_fpp_me() THEN +(# SUM(out_qty) +(# ELSE 0 +(# END AS current, +(# CASE WHEN to_date > max_fpp_me() THEN +(# SUM(out_qty) +(# ELSE 0 +(# END AS future +(# FROM gir_outstanding +(# GROUP BY group_code, +(# sku, +(# stktype_code, +(# brn_code, +(# to_date +(# ) AS sub +-# GROUP BY group_code, +-# sku, +-# stktype_code, +-# brn_code +-# ; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------- + Aggregate (cost=15880.41..16055.62 rows=876 width=44) + -> Group (cost=15880.41..15989.92 rows=8761 width=44) + -> Sort (cost=15880.41..15902.31 rows=8761 width=44) + Sort Key: group_code, sku, stktype_code, brn_code + -> Subquery Scan sub (cost=13335.57..15306.72 rows=8761 width=44) + -> Aggregate (cost=13335.57..15306.72 rows=8761 width=44) + -> Group (cost=13335.57..14649.67 rows=87607 width=44) + -> Sort (cost=13335.57..13554.58 rows=87607 width=44) + Sort Key: group_code, sku, stktype_code, brn_code, to_date + -> Seq Scan on gir_outstanding (cost=0.00..4687.07 rows=87607 width=44) +(10 rows) + + +--Multipart=_Mon__7_Jun_2004_13_34_15_+0200_pHQJTKtA2k4B5Fq7 +Content-Type: application/octet-stream; + name="functions.sql" +Content-Disposition: attachment; + filename="functions.sql" +Content-Transfer-Encoding: base64 + +Q1JFQVRFIEZVTkNUSU9OIG1heF9mcHAgKHRleHQpIFJFVFVSTlMgdGV4dAog +ICAgQVMgJ3NlbGVjdCBmcHBfY2RlIGZyb20gYnJfcHJvZiAnCiAgICBMQU5H +VUFHRSBzcWw7CgoKQ1JFQVRFIEZVTkNUSU9OIG1heF9mcHBfbWUgKCkgUkVU +VVJOUyBkYXRlCiAgICBBUyAnCi8qIFRoaXMgZnVuY3Rpb24gcmV0dXJucyB0 +aGUgY3VycmVudCBmcHAgbWUgZGF0ZSAgKi8Kc2VsZWN0IG1lX2R0ZTo6ZGF0 +ZQpmcm9tIGZwcAp3aGVyZSBjb2RlID0gbWF4X2ZwcCgnJycnKQonCiAgICBM +QU5HVUFHRSBzcWw7CgoKQ1JFQVRFIEZVTkNUSU9OIG1heF9mcHBfbXMgKCkg +UkVUVVJOUyBkYXRlCiAgICBBUyAnCi8qIFRoaXMgZnVuY3Rpb24gcmV0dXJu +cyB0aGUgY3VycmVudCBmcHAgbXMgZGF0ZSAgKi8Kc2VsZWN0IG1lX2R0ZTo6 +ZGF0ZSAKZnJvbSAoCiAgIHNlbGVjdCBtYXgoY29kZSkgYXMgY29kZSAKZnJv +bSBmcHAKd2hlcmUgY29kZSA8IG1heF9mcHAoJycnJykKCikgYXMgc3ViLCBm +cHAgZgp3aGVyZSBmLmNvZGUgPSBzdWIuY29kZQoKJwogICAgTEFOR1VBR0Ug +c3FsOwoK + +--Multipart=_Mon__7_Jun_2004_13_34_15_+0200_pHQJTKtA2k4B5Fq7 +Content-Type: text/plain; + name="structures.txt" +Content-Disposition: attachment; + filename="structures.txt" +Content-Transfer-Encoding: 7bit + +=# \d gir_outstanding + Table "public.gir_outstanding" + Column | Type | Modifiers +----------------+-----------------------------+----------- + supp_code | text | + supp_name | text | + supp_brn | text | + ord_no | text | + due_date | timestamp without time zone | + to_date | timestamp without time zone | + group_code | text | + brn_code | text | + desc_short | text | + cluster_brn | text | + country_code | text | + req_doc_no | integer | + ops_code | text | + sku | text | + std_descr | text | + acde_code | text | + req_qty | double precision | + grv_qty | double precision | + skul_qty | double precision | + pref_date | timestamp without time zone | + skul_grv_qty | double precision | + out_qty | double precision | + skul_ord_cost | numeric(16,2) | + out_cost | numeric | + stktype_code | character varying(2) | + gir_type_code | text | + gir_type_descr | text | +Indexes: gir_oustanding_idx1 btree (cluster_brn, sku, stktype_code) + +=# select count(1) from gir_outstanding; + count +------- + 87607 +(1 row) + +=# \d fpp + Table "public.fpp" + Column | Type | Modifiers +---------+-----------------------------+----------- + code | text | not null + descr | text | + me_dte | timestamp without time zone | + cal_dte | timestamp without time zone | + gl_per | integer | +Indexes: fpp_pkey primary key btree (code), + fpp_uidx1 unique btree (code) + +=# select count(1) from fpp; + count +------- + 92 + +=# \d br_prof + Table "public.br_prof" + Column | Type | Modifiers +--------------------+-----------------------------+----------- + br_cde | text | not null + bprof_opened | timestamp without time zone | + fpp_cde | text | + bprof_avg_del_time | integer | + bprof_auto_err_log | boolean | +Indexes: br_prof_pkey primary key btree (br_cde) + +=# select count(1) from br_prof; + count +------- + 1 +(1 row) + + +--Multipart=_Mon__7_Jun_2004_13_34_15_+0200_pHQJTKtA2k4B5Fq7-- + +From pgsql-performance-owner@postgresql.org Mon Jun 7 10:53:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9791BD1B8E8 + for ; + Mon, 7 Jun 2004 10:51: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 94179-09 + for ; + Mon, 7 Jun 2004 13:51: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 BF52AD1B3AD + for ; + Mon, 7 Jun 2004 10:51:54 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i57Dputa002605; + Mon, 7 Jun 2004 09:51:57 -0400 (EDT) +To: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" +Cc: pgsql-performance@postgresql.org +Subject: Re: Relation of cpu_*_costs? +In-reply-to: <076f01c44c62$208aa680$0403a8c0@fejleszt4> +References: <076f01c44c62$208aa680$0403a8c0@fejleszt4> +Comments: In-reply-to "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" + message dated "Mon, 07 Jun 2004 09:36:19 +0200" +Date: Mon, 07 Jun 2004 09:51:56 -0400 +Message-ID: <2604.1086616316@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/59 +X-Sequence-Number: 7117 + +"=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" writes: +> Last week I fumbled with CPU_TUPLE_COST and revealed that 4 out of 4 tested +> queries improved by 10-60% if I changed it from 0.01 (default) to 0.40 +> (ugh). Setting it higher did not bring any improvement. + +That's pretty hard to believe; particularly on modern machines, I'd +think that moving it down would make more sense than moving it up. +You're essentially asserting that the CPU time to process one tuple +is almost half of the time needed to bring a page in from disk. + +I suspect that your test cases were toy cases small enough to be +fully cached and thus not incur any actual I/O ... + +> [ trying to get a nestloop indexscan plan to be generated ] + +I believe that the planner's cost model for nestloops with inner +indexscan is wrong: it costs each inner iteration independently, when +in fact there should be some savings, because at least the topmost +levels of the index will soon be fully cached. However, when I tried +to work out a proper model of this effect, I ended up with equations +that gave higher indexscan costs than what's in there now :-(. So that +didn't seem like it would make anyone happy. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jun 7 12:12:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D5D39D1B557 + for ; + Mon, 7 Jun 2004 12:11: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 49626-02 + for ; + Mon, 7 Jun 2004 15:11:25 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D60BED1B1DC + for ; + Mon, 7 Jun 2004 12:11:23 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i57FBLKH003530; + Mon, 7 Jun 2004 11:11:21 -0400 (EDT) +To: Stef +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres function use makes machine crash. +In-reply-to: <20040607133415.09a2ce2f@svb.ucs.co.za> +References: <20040607133415.09a2ce2f@svb.ucs.co.za> +Comments: In-reply-to Stef + message dated "Mon, 07 Jun 2004 13:34:15 +0200" +Date: Mon, 07 Jun 2004 11:11:21 -0400 +Message-ID: <3529.1086621081@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/60 +X-Sequence-Number: 7118 + +Stef writes: +> I've been dealing with a problem for the past two days +> where a certain sql statement works 2 out of 5 times, and +> the other 3 times, it causes the machine (quad Xeon 2.8GHz +> + 792543232 bytes mem, linux kernel 2.4.26-custom, pg ver 7.3.4) +> to slow down, and finally grind to a halt. + +IIRC, PG prior to 7.4 had some problems with memory leaks in repeated +execution of SQL-language functions ... and your query sure looks like +it's going to be doing a lot of repeated execution of those functions. + +Please try it on 7.4.2 and see if you still have a problem. + +It seems somewhat interesting that you see the problem only sometimes +and not every time, but there's not much point in investigating further +if it turns out the problem is already fixed. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jun 7 12:36:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F0A16D1B1EC + for ; + Mon, 7 Jun 2004 12:36: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 63455-05 + for ; + Mon, 7 Jun 2004 15:36:05 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B5109D1B1D1 + for ; + Mon, 7 Jun 2004 12:36:02 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 842E42BDD6 + for ; + Mon, 7 Jun 2004 17:35:22 +0200 (SAST) +Received: from ucsns.ucs.co.za ([127.0.0.1]) + by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 29660-04 for ; + Mon, 7 Jun 2004 17:34:53 +0200 (SAST) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id A87F32BE0A + for ; + Mon, 7 Jun 2004 17:34:53 +0200 (SAST) +Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) + by ucspost.ucs.co.za (Postfix) with ESMTP id 705E8DA134 + for ; + Mon, 7 Jun 2004 17:34:53 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with SMTP id 278F397642 + for ; + Mon, 7 Jun 2004 17:34:54 +0200 (SAST) +Date: Mon, 7 Jun 2004 17:34:53 +0200 +From: Stef +To: pgsql-performance@postgresql.org +Subject: Re: Postgres function use makes machine crash. +Message-Id: <20040607173453.48f9b15b@svb.ucs.co.za> +In-Reply-To: <3529.1086621081@sss.pgh.pa.us> +References: <20040607133415.09a2ce2f@svb.ucs.co.za> + <3529.1086621081@sss.pgh.pa.us> +X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? + Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. +X-Operating-System: sid +X-X-X: _-^-_ +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at ucs.co.za +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/61 +X-Sequence-Number: 7119 + +Tom Lane mentioned : +=> Please try it on 7.4.2 and see if you still have a problem. + +Will do, and I'll post the results + +Thanks! + +From pgsql-performance-owner@postgresql.org Mon Jun 7 13:00:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CBD8D1B1DC + for ; + Mon, 7 Jun 2004 12:52: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 75118-03 + for ; + Mon, 7 Jun 2004 15:52:47 +0000 (GMT) +Received: from mail005.syd.optusnet.com.au (mail005.syd.optusnet.com.au + [211.29.132.54]) + by svr1.postgresql.org (Postfix) with ESMTP id ADA3ED1B16B + for ; + Mon, 7 Jun 2004 12:52:44 -0300 (ADT) +Received: from wine.pumptheory.com (d198-142-112-197.dsl.nsw.optusnet.com.au + [198.142.112.197]) + by mail005.syd.optusnet.com.au (8.11.6p2/8.11.6) with SMTP id + i57Fqfw03861 + for ; Tue, 8 Jun 2004 01:52:42 +1000 +Received: (qmail 5695 invoked from network); 7 Jun 2004 15:52:15 -0000 +Received: from localhost (HELO pumptheory.com) (127.0.0.1) + by wine.pumptheory.com with SMTP; 7 Jun 2004 15:52:15 -0000 +Message-ID: <40C48F2E.5090704@pumptheory.com> +Date: Tue, 08 Jun 2004 01:52:14 +1000 +From: Mark Aufflick +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: PREPAREing statements versus compiling PLPGSQL +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.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/62 +X-Sequence-Number: 7120 + +Hi all, + +I am optimizing some code that does a lot of iterative selects and +inserts within loops. Because of the exception handling limitations in +postgres and with no ability to twiddle autocommit, just about every +operation is standalone. + +over 5000 odd lines this gets very slow (5-10 minutes including processing). + +In seeking to speed it up I am PREPARing the most common inserts and +selects. I have a few operations already inside plpgsql functions. +EXECUTE means something different within a plpgsql funtion, so I am +wondering if there is a way to execute a pre-prepared query inside a +function. + +Or is this even necessary - are queries within plpgsql functions +automatically prepared when the function is first compiled? On a similar +note, is there any benefit in PREPAREing a select from a plpgsql function? + +Or does anyone have any smart ways to turn off autocommit? (I have +already played with commit_delay and commit_siblings). + +My empirical testing has proven inconclusive (other than turning off +fsync which makes a huge difference, but not possible on the live +system, or using a fat copmaq raid card). + +Thanks for any help, + +Mark. + +-- +Mark Aufflick + e: mark@pumptheory.com + w: www.pumptheory.com (business) + w: mark.aufflick.com (personal) + p: +61 438 700 647 + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 13:36:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 88D71D1B265 + for ; + Mon, 7 Jun 2004 13:36: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 00436-02 + for ; + Mon, 7 Jun 2004 16:36:41 +0000 (GMT) +Received: from ml-hw5.monsterlabs.com (ml-hw5.monsterlabs.com + [216.183.105.167]) + by svr1.postgresql.org (Postfix) with SMTP id CE46CD1B238 + for ; + Mon, 7 Jun 2004 13:36:38 -0300 (ADT) +Received: (qmail 2896 invoked from network); 7 Jun 2004 16:36:38 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.15?) + (64.3.242.80) + by ml-hw5.monsterlabs.com with SMTP; 7 Jun 2004 16:36:38 -0000 +From: Marcus Whitney +Reply-To: marcus@coldfeetcreative.com +Organization: Coldfeet Creative +To: pgsql-performance@postgresql.org +Subject: pl/pgsql and Transaction Isolation +Date: Mon, 7 Jun 2004 11:31:46 -0500 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200406071131.46488.marcus@coldfeetcreative.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/63 +X-Sequence-Number: 7121 + +Hello, + + I have an instance where I have a series of pl/pgsql calls, that report s= +tat=20 +results to a common table. When other queries try to hit the stat table=20 +(with DML commands; SELECT, INSERT, UPDATE, DELETE etc.) they are forced to= +=20 +wait in a queue until the pl/pgsql has finished executing.=20=20 + +will: + + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;=20 + +before these DML queries eliminate the locking? + + +--=20 +marcus whitney + +chief architect : cold feet creative + +www.coldfeetcreative.com + +800.595.4401 +=A0 + + +cold feet presents emma + +email marketing for discriminating + +organizations everywhere + +visit www.myemma.com + +From pgsql-performance-owner@postgresql.org Mon Jun 7 13:48:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 41B8FD1BB17 + for ; + Mon, 7 Jun 2004 13:48: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 08742-02 + for ; + Mon, 7 Jun 2004 16:48:35 +0000 (GMT) +Received: from ml-hw5.monsterlabs.com (ml-hw5.monsterlabs.com + [216.183.105.167]) + by svr1.postgresql.org (Postfix) with SMTP id D2EACD1B3B6 + for ; + Mon, 7 Jun 2004 13:48:33 -0300 (ADT) +Received: (qmail 9894 invoked from network); 7 Jun 2004 16:48:33 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.15?) + (64.3.242.80) + by ml-hw5.monsterlabs.com with SMTP; 7 Jun 2004 16:48:33 -0000 +From: Marcus Whitney +Reply-To: marcus@coldfeetcreative.com +Organization: Coldfeet Creative +To: Robert Treat +Subject: Re: Pl/Pgsql Functions running simultaneously +Date: Mon, 7 Jun 2004 11:43:41 -0500 +User-Agent: KMail/1.6.1 +References: <200406021608.56919.marcus@coldfeetcreative.com> + <200406031638.03409.marcus@coldfeetcreative.com> + <1086385141.29236.1118.camel@camel> +In-Reply-To: <1086385141.29236.1118.camel@camel> +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200406071143.41841.marcus@coldfeetcreative.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/64 +X-Sequence-Number: 7122 + +Thanks for your reply. My comments are below. + +On Friday 04 June 2004 16:39, you wrote: +> Uh... I don't think this is necessarily the wrong list, sometimes people +> don't have much to chime in. You could try reposting to -sql or -general +> I suppose. + +I'll try one of those. + +> +> As for my take on your questions, I wasn't exactly clear on what the +> problem is. If its just that things seem slow, make sure you have done +> the appropriate vacuum/analyze/reindex tech and then try adding some +> debug info to the function to determine where in the function it is +> slowing down. + +Yeah, I do a fair amount of vacuum/analyze , but I am unclear as to when I= +=20 +should run REINDEX. Is their a way to tell that indexes have become corrup= +t,=20 +or need to be reindexed? + +> +> queries inside plpgsql functions will take locks as needed, but they are +> no different than regular statements, just keep in mind that the queries +> inside the function will work like an implicit transaction. + +I've noticed. Thanks for the info. + +> +> Robert Treat +> +> On Thu, 2004-06-03 at 17:38, Marcus Whitney wrote: +> > Am I on the wrong list to ask this question, or does this list usually +> > have low activity? Just asking because I am new and I need to know whe= +re +> > to ask this question. Thanks. +> > +> > On Wednesday 02 June 2004 16:08, Marcus Whitney wrote: +> > > Hello all, +> > > +> > > I have an import function that I have been working on for some time +> > > now, and it performed well up until recently. It is doing a lot, and +> > > because the queries are not cached, I am not sure if that is what the +> > > problem is. If a function takes a while, does it lock any of the tabl= +es +> > > it is accessing, even for SELECT? +> > > +> > > Below is the bulk of the function: +> > > +> > > -- set sql statement variables +> > > create_import_file_sql :=3D ''COPY '' || container_table || '' +> > > ('' || filtered_container_columns || '') TO '' || +> > > quote_literal(formatted_import_file) || '' WITH NULL AS '' || +> > > null_single_quotes; +> > > upload_to_import_table_sql :=3D ''COPY '' || import_table || = +'' +> > > ('' +> > > +> > > || field_names || '') FROM '' || quote_literal(formatted_import_file) +> > > || || '' +> > > +> > > WITH NULL AS '' || null_single_quotes; +> > > clean_personalization_fields_sql :=3D ''UPDATE '' || import_t= +able +> > > || '' SET emma_member_email =3D btrim(emma_member_email, '' || +> > > quote_literal(quoted_single_quote) || '') , emma_member_name_first = +=3D +> > > btrim(emma_member_name_first, '' || quote_literal(quoted_single_quote) +> > > || '') , emma_member_name_last =3D btrim(emma_member_name_last, '' = +|| +> > > quote_literal(quoted_single_quote) || '') ;''; +> > > clean_personalization_fields_sql2 :=3D ''UPDATE '' || +> > > import_table || '' SET emma_member_email =3D btrim(emma_member_email)= + , +> > > emma_member_name_first =3D btrim(emma_member_name_first) , +> > > emma_member_name_last =3D +> > > btrim(emma_member_name_last) ;''; +> > > set_account_id_sql :=3D ''UPDATE '' || import_table || '' SET +> > > emma_account_id =3D '' || account_id; +> > > set_default_active_status_sql :=3D ''UPDATE '' || import_tabl= +e || +> > > '' SET emma_member_status_id =3D 1''; +> > > set_errors_for_null_email_sql :=3D ''UPDATE '' || import_tabl= +e || +> > > '' SET emma_member_status_id =3D 2 WHERE emma_member_email IS NULL''; +> > > record_null_email_count_sql :=3D ''UPDATE '' || import_history_table +> > > +> > > || '' SET emma_import_null_email_count =3D (SELECT COUNT(*) FROM '' || +> > > +> > > import_table || '' WHERE emma_member_email IS NULL) WHERE +> > > emma_import_history_id =3D'' || import_history_id; +> > > set_errors_for_invalid_email_sql :=3D ''UPDATE '' || import_t= +able +> > > || '' SET emma_member_status_id =3D 2 WHERE emma_member_email !~* ''= + || +> > > email_regex; record_invalid_email_count_sql :=3D ''UPDATE '' || +> > > import_history_table +> > > +> > > || '' SET emma_import_invalid_email_count =3D ( SELECT COUNT(*) FROM= + '' +> > > || || +> > > +> > > import_table || '' WHERE emma_member_email !~* '' || email_regex || = +'' +> > > ) WHERE emma_import_history_id =3D'' || import_history_id; +> > > get_dupes_in_import_sql :=3D ''SELECT emma_member_email, +> > > emma_member_status_id FROM '' || import_table || '' GROUP BY +> > > emma_member_email, emma_member_status_id having count(*) > 1''; +> > > insert_dupes_sql :=3D ''INSERT INTO '' || dupe_table || '' +> > > SELECT * FROM '' || import_table || '' WHERE LOWER(emma_member_email)= + =3D +> > > LOWER('' || member_table || ''.emma_member_email)''; +> > > record_table_dupe_count_sql :=3D ''UPDATE '' || +> > > import_history_table +> > > +> > > || '' SET emma_import_table_dupe_email_count =3D (SELECT COUNT(*) FRO= +M '' +> > > || || +> > > +> > > import_table || '' WHERE emma_member_email =3D LOWER('' || member_tab= +le +> > > || ''.emma_member_email)) WHERE emma_import_history_id =3D'' || +> > > import_history_id; remove_dupes_from_import_table_sql :=3D ''DELETE F= +ROM +> > > '' +> > > +> > > || import_table +> > > || +> > > || '' WHERE LOWER(emma_member_email) =3D LOWER('' || member_table || +> > > +> > > ''.emma_member_email)''; +> > > create_clean_import_file_sql :=3D ''COPY '' || import_table |= +| '' +> > > TO '' +> > > +> > > || quote_literal(clean_import_file) || '' WITH NULL AS '' || +> > > +> > > null_single_quotes; +> > > create_members_groups_ids_file_sql :=3D ''COPY '' || import_t= +able +> > > || '' (emma_member_id) TO '' || quote_literal(members_groups_ids_file) +> > > || '' WITH NULL AS '' || null_single_quotes; +> > > empty_import_table_sql :=3D ''TRUNCATE '' || import_table; +> > > upload_clean_import_sql :=3D ''COPY '' || member_table || '' = +FROM +> > > '' +> > > +> > > || quote_literal(clean_import_file) || '' WITH NULL AS '' || +> > > +> > > null_single_quotes; +> > > upload_members_groups_ids_sql :=3D ''COPY '' || +> > > members_groups_ids_table +> > > +> > > || '' (emma_member_id) FROM '' || +> > > || quote_literal(members_groups_ids_file) || +> > > +> > > '' WITH NULL AS '' || null_single_quotes; +> > > empty_members_groups_ids_sql :=3D ''TRUNCATE '' || +> > > members_groups_ids_table; +> > > empty_members_dupes_sql :=3D ''TRUNCATE '' || dupe_table; +> > > vacuum_sql :=3D ''VACUUM '' || member_table || ''; VACUUM '' = +|| +> > > import_table || ''; VACUUM '' || container_table || ''; VACUUM '' || +> > > members_groups_table || ''; VACUUM '' || members_groups_ids_table || +> > > ''; VACUUM '' || dupe_table; +> > > +> > > -- BEGIN ACTIVITY +> > > -- Create the filtered import file with the +> > > EXECUTE create_import_file_sql; +> > > -- Load data from the filtered file to the import table +> > > EXECUTE upload_to_import_table_sql; +> > > -- Set account id in import table +> > > EXECUTE set_account_id_sql; +> > > -- Set the status of all the records to 1 +> > > EXECUTE set_default_active_status_sql; +> > > -- Clean personalization data +> > > EXECUTE clean_personalization_fields_sql; +> > > EXECUTE clean_personalization_fields_sql2; +> > > -- Set the status to error for all NULL emails +> > > EXECUTE set_errors_for_null_email_sql; +> > > -- Record the count of null emails +> > > EXECUTE record_null_email_count_sql; +> > > -- Set the status to error for all invalid emails +> > > EXECUTE set_errors_for_invalid_email_sql; +> > > -- Record the count of invalid emails +> > > EXECUTE record_invalid_email_count_sql; +> > > +> > > -- Remove duplicates in import table (originally in file) +> > > FOR duplicate_record IN EXECUTE get_dupes_in_import_sql LOOP +> > > IF duplicate_record.emma_member_email IS NOT NULL THEN +> > > FOR replacement_record IN EXECUTE '' SELECT * FROM +> > > '' +> > > +> > > || import_table || '' WHERE emma_member_email =3D '' || +> > > +> > > quote_literal(duplicate_record.emma_member_email) || '' ORDER BY +> > > emma_member_id LIMIT 1'' LOOP +> > > escape_first_name :=3D quote_literal +> > > (replacement_record.emma_member_name_first); +> > > escape_last_name :=3D quote_literal +> > > (replacement_record.emma_member_name_last); +> > > escape_email :=3D quote_literal +> > > (replacement_record.emma_member_email); +> > > escape_status_id :=3D +> > > quote_literal(replacement_record.emma_member_status_id); +> > > -- Record count of dupes +> > > FOR dupe_record_count IN EXECUTE ''SELECT +> > > COUNT(*) AS count FROM '' || import_table || '' WHERE +> > > LOWER(emma_member_email) =3D LOWER('' || escape_email || '')'' LOOP +> > > EXECUTE ''UPDATE '' || +> > > import_history_table || '' SET emma_import_file_dupe_email_count =3D= +'' +> > > || dupe_record_count.count; +> > > END LOOP; +> > > FOR primary_dupe_record IN EXECUTE ''SELE= +CT +> > > MAX(emma_member_id) AS max_id FROM '' || import_table || '' WHERE +> > > LOWER(emma_member_email) =3D LOWER('' || escape_email || '')'' LOOP +> > > EXECUTE ''UPDATE '' || import_tab= +le +> > > || '' SET emma_member_status_id =3D 5 WHERE emma_member_id =3D '' || +> > > primary_dupe_record.max_id; +> > > EXECUTE ''DELETE FROM '' || +> > > import_table +> > > +> > > || '' WHERE emma_member_email =3D '' || +> > > +> > > quote_literal(duplicate_record.emma_member_email) || '' AND +> > > emma_member_status_id !=3D 5''; +> > > EXECUTE ''UPDATE '' || import_tab= +le +> > > || '' SET emma_member_status_id =3D 1 WHERE emma_member_status_id =3D= + 5''; +> > > END LOOP; +> > > import_dupe_count :=3D import_dupe_count = ++ 1; +> > > END LOOP; +> > > END IF; +> > > END LOOP; +> > > +> > > -- Move dupes over to the dupe table +> > > EXECUTE insert_dupes_sql; +> > > -- Record the count of dupes from import to members +> > > EXECUTE record_table_dupe_count_sql; +> > > -- Delete the dupes from the import table +> > > EXECUTE remove_dupes_from_import_table_sql; +> > > -- Create clean import file +> > > EXECUTE create_clean_import_file_sql; +> > > -- Create groups_id file +> > > EXECUTE create_members_groups_ids_file_sql; +> > > -- Empty import table +> > > EXECUTE empty_import_table_sql; +> > > -- Upload clean members from import +> > > EXECUTE upload_clean_import_sql; +> > > -- Upload group ids +> > > EXECUTE upload_members_groups_ids_sql; +> > > +> > > -- Associate to groups +> > > groups :=3D string_to_array(group_list, '',''); +> > > if array_lower(groups, 1) IS NOT NULL THEN +> > > FOR i IN array_lower(groups, 1)..array_upper(groups, 1) +> > > LOOP EXECUTE ''INSERT INTO '' || members_groups_ids_table +> > > +> > > || '' SELECT '' || member_table || ''.emma_member_id FROM ONLY '' || +> > > +> > > member_table || '' WHERE LOWER('' || member_table || +> > > ''.emma_member_email) =3D LOWER('' || dupe_table || ''.emma_member_em= +ail) +> > > AND '' || member_table || ''.emma_member_id NOT IN (SELECT '' || +> > > members_groups_table || ''.emma_member_id FROM '' || +> > > members_groups_table || '' WHERE '' || members_groups_table || +> > > ''.emma_group_id =3D '' || groups[i] || '') AND '' || member_table || +> > > ''.emma_member_id NOT IN (SELECT emma_member_id FROM '' || +> > > members_groups_ids_table || '')''; +> > > EXECUTE ''DELETE FROM '' || +> > > members_groups_ids_table +> > > +> > > || '' WHERE emma_member_id IN (SELECT emma_member_id FROM '' || +> > > +> > > members_groups_table || '' WHERE emma_group_id =3D '' || groups[i] ||= + '' +> > > )''; EXECUTE ''INSERT INTO '' || members_groups_table || '' SELECT +> > > DISTINCT '' || groups[i] || '' AS emma_group_id, emma_member_id FROM +> > > '' || members_groups_ids_table; +> > > END LOOP; +> > > END IF; +> > > +> > > Any pointers on large plpgsql operations are appreciated. Especially +> > > when more than one instance is runinng. Thanks. +> > +> > -- +> > marcus whitney +> > +> > chief architect : cold feet creative +> > +> > www.coldfeetcreative.com +> > +> > 800.595.4401 +> > +> > +> > +> > cold feet presents emma +> > +> > email marketing for discriminating +> > +> > organizations everywhere +> > +> > visit www.myemma.com +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 7: don't forget to increase your free space map settings + +--=20 +marcus whitney + +chief architect : cold feet creative + +www.coldfeetcreative.com + +800.595.4401 +=A0 + + +cold feet presents emma + +email marketing for discriminating + +organizations everywhere + +visit www.myemma.com + +From pgsql-performance-owner@postgresql.org Mon Jun 7 14:18:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 45CB3D1B238 + for ; + Mon, 7 Jun 2004 14: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 14737-08 + for ; + Mon, 7 Jun 2004 17:18:30 +0000 (GMT) +Received: from fe07.axelero.hu (fe07.axelero.hu [195.228.240.95]) + by svr1.postgresql.org (Postfix) with ESMTP id AA618D1B265 + for ; + Mon, 7 Jun 2004 14:18:27 -0300 (ADT) +Received: from fe07 (localhost-02 [127.0.2.1]) + by fe07.axelero.hu (8.12.11/8.12.11) with SMTP id i57HIRHT008434 + for ; + Mon, 7 Jun 2004 19:18:27 +0200 (CEST) +Received: from fe07.axelero.hu [127.0.2.1] via SMTP gateway + by fe07 [195.228.240.95]; id A020EFDB599 + at Mon, 07 Jun 2004 19:18:26 +0200 +Received: from fejleszt4 (121-248-182-81.adsl-fixip.axelero.hu + [81.182.248.121]) + by fe07.axelero.hu (8.12.11/8.12.11) with SMTP id i57HIMHd008312 + for ; + Mon, 7 Jun 2004 19:18:23 +0200 (CEST) +Message-ID: <0a0101c44cb3$89d3c2b0$0403a8c0@fejleszt4> +From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" +To: +References: <076f01c44c62$208aa680$0403a8c0@fejleszt4> + <2604.1086616316@sss.pgh.pa.us> +Subject: Re: Relation of cpu_*_costs? +Date: Mon, 7 Jun 2004 19:19:06 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-2" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-RAVMilter-Version: 8.4.3(snapshot 20030217) (fe07.axelero.hu) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/65 +X-Sequence-Number: 7123 + +Dear Tom, + +Thanks for your response. + +----- Original Message ----- +From: "Tom Lane" +Sent: Monday, June 07, 2004 3:51 PM + + +> That's pretty hard to believe; particularly on modern machines, I'd +> think that moving it down would make more sense than moving it up. +> You're essentially asserting that the CPU time to process one tuple +> is almost half of the time needed to bring a page in from disk. + +That is exactly what I had in mind. We found that 5x10krpm HW RAID 5 array +blazing fast, while we were really disappointed about CPU. E.g. +* tar'ing 600MB took seconds; gzip'ing it took minutes. +* initdb ran so fast that I didn't have time to hit Ctrl+C because + I forgot a switch ;) +* dumping the DB in or out was far faster than adddepend between 7.2 and 7.3 +* iirc index scans returning ~26k rows of ~64k were faster than seq scan. + (most suspicious case of disk cache) + +But whatever is the case with my hardware -- could you tell me something +(even a search keyword ;) ) about my theoretical question: i.e. relation of +cpu_*_costs? + +> I suspect that your test cases were toy cases small enough to be +> fully cached and thus not incur any actual I/O ... + +Dunno. The server has 1GB RAM; full DB is ~100MB; largest query was ~7k +which moved at least 2 tables of >200k rows and several smaller ones. If it +is a "toy case" for such hw, I humbly accept your opinion. + +BTW its runtime improved from 53 to 48 sec -- all due to changing cpu tuple +cost. I ran the query at different costs, in fast succession: + +run cost sec + #1 0.01 53 + #2 0.4 50 + #3 1.0 48 + #4 1.0 48 + #5 0.4 48 + #6 0.01 53 + +For the second result, I'd say disk cache, yes-- but what about the last +result? It's all the same as the first one. Must have been some plan change +(I can send the exp-ana results if you wish) + +G. +%----------------------- cut here -----------------------% +\end + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 14:30:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AB4AAD1B1EC + for ; + Mon, 7 Jun 2004 14:30: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 29404-03 + for ; + Mon, 7 Jun 2004 17:30:33 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A0F4D1B18F + for ; + Mon, 7 Jun 2004 14:30:29 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: is it possible to for the planner to optimize this form? +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Mon, 7 Jun 2004 13:30:29 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AE56@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: is it possible to for the planner to optimize this form? +Thread-Index: AcRMtSCLdQGYmz9ZQ1aVwDJWFT91CA== +From: "Merlin Moncure" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/66 +X-Sequence-Number: 7124 + +Right now, I am having trouble getting the planner to optimize queries +in the form of=20 + +select t.key, t.field from t a + where=20 + ( + select count(*) from t b + where b.field > a.field + ) =3D k + +The subplan (either index or seq. scan) executes once for each row in t, +which of course takes forever. + +This query is a way of achieving LIMIT type results (substitute n-1 +desired rows for k) using standard SQL, which is desirable in some +circumstances. Is it theoretically possible for this to be optimized? + +Merlin + + +From pgsql-jdbc-owner@postgresql.org Mon Jun 7 14:41:09 2004 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5F989D1B1D1; Mon, 7 Jun 2004 14:41: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 26844-09; Mon, 7 Jun 2004 17:41:00 +0000 (GMT) +Received: from noao.edu (wiyn.org [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP + id 047B2D1B17A; Mon, 7 Jun 2004 14:40:57 -0300 (ADT) +X-TFF-CGPSA-Version: 1.2.7 +X-TFF-CGPSA-Filter: Scanned +Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) + by noao.edu (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 12313884; Mon, 07 Jun 2004 10:40:57 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.8) with ESMTP id i57HevQ5004081; + Mon, 7 Jun 2004 10:40:57 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.12.8/8.12.8/Submit) id i57Hevl7004079; + Mon, 7 Jun 2004 10:40:57 -0700 +X-Authentication-Warning: weaver.tuc.noao.edu: swampler set sender to + swampler@noao.edu using -f +Subject: Re: [PERFORM] Using a COPY...FROM through JDBC? +From: Steve Wampler +Reply-To: swampler@noao.edu +To: Kris Jurka +Cc: Postgres-JDBC , + Postgres-performance +In-Reply-To: +References: <1086466349.29063.76.camel@weaver.tuc.noao.edu> + +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: National Solar Observatory +Message-Id: <1086630056.25790.17.camel@weaver.tuc.noao.edu> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 07 Jun 2004 10:40:56 -0700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/35 +X-Sequence-Number: 10237 + +On Mon, 2004-06-07 at 02:26, Kris Jurka wrote: +> On Sat, 5 Jun 2004, Steve Wampler wrote: +> +> > +> > [I want to use copy from JDBC] +> > +> +> I made a patch to the driver to support COPY as a PG extension. +... +> http://archives.postgresql.org/pgsql-jdbc/2003-12/msg00186.php + +Thanks Kris - that patch worked beautifully and bumped the +insert rate from ~1000 entries/second to ~9000 e/s in my +test code. + +Here's hoping it makes it into 7.5. + +I do have a little concern about what's happening in the +back end during the copy - I suspect the entire table is +locked, which may impact the performance when multiple +clients are saving entries into the table. Anyone know +if that's how COPY works? (For that matter, would that +also be true of a transaction consisting of a set of +inserts?) + +Thanks again! +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-jdbc-owner@postgresql.org Mon Jun 7 14:59:36 2004 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP + id 8DB3FD1B1DA; Mon, 7 Jun 2004 14:59: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 40454-08; Mon, 7 Jun 2004 17:59:27 +0000 (GMT) +Received: from noao.edu (email.noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP + id 97F01D1B1CA; Mon, 7 Jun 2004 14:59:25 -0300 (ADT) +X-TFF-CGPSA-Version: 1.2.7 +X-TFF-CGPSA-Filter: Scanned +Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) + by noao.edu (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 12314184; Mon, 07 Jun 2004 10:59:25 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.8) with ESMTP id i57HxPQ5004508; + Mon, 7 Jun 2004 10:59:25 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.12.8/8.12.8/Submit) id i57HxPfh004506; + Mon, 7 Jun 2004 10:59:25 -0700 +X-Authentication-Warning: weaver.tuc.noao.edu: swampler set sender to + swampler@noao.edu using -f +Subject: Re: [PERFORM] Using a COPY...FROM through JDBC? +From: Steve Wampler +Reply-To: swampler@noao.edu +To: Kris Jurka +Cc: Postgres-JDBC , + Postgres-performance +In-Reply-To: <1086630056.25790.17.camel@weaver.tuc.noao.edu> +References: <1086466349.29063.76.camel@weaver.tuc.noao.edu> + + <1086630056.25790.17.camel@weaver.tuc.noao.edu> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: National Solar Observatory +Message-Id: <1086631165.25790.26.camel@weaver.tuc.noao.edu> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 07 Jun 2004 10:59:25 -0700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/36 +X-Sequence-Number: 10238 + +On Mon, 2004-06-07 at 10:40, Steve Wampler wrote: + +> Thanks Kris - that patch worked beautifully and bumped the +> insert rate from ~1000 entries/second to ~9000 e/s in my +> test code. + +As a followup - that 9000 e/s becomes ~21,000 e/s if I don't +have the java code also dump the message to standard output! + +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Mon Jun 7 16:48:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C6B07D1B243 + for ; + Mon, 7 Jun 2004 16: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 84665-08 + for ; + Mon, 7 Jun 2004 19:45:45 +0000 (GMT) +Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) + by svr1.postgresql.org (Postfix) with ESMTP id A45BED1B19D + for ; + Mon, 7 Jun 2004 16:45:42 -0300 (ADT) +Received: from wocker (wocker.unixathome.org [192.168.0.99]) + by bast.unixathome.org (Postfix) with ESMTP id 0EA813D3E + for ; + Mon, 7 Jun 2004 15:45:43 -0400 (EDT) +From: "Dan Langille" +To: pgsql-performance@postgresql.org +Date: Mon, 07 Jun 2004 15:45:42 -0400 +MIME-Version: 1.0 +Subject: seq scan woes +Message-ID: <40C48DA6.3356.48DAC2EB@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/69 +X-Sequence-Number: 7127 + +A production system has had a query recently degrade in performance. +What once took < 1s now takes over 1s. I have tracked down the +problem to a working example. + +Compare http://rafb.net/paste/results/itZIx891.html +with http://rafb.net/paste/results/fbUTNF95.html + +The first shows the query as is, without much change (actually, this +query is nested within a larger query, but it demonstrates the +problem). The query time is about 1 second. + +In the second URL, a "SET ENABLE_SEQSCAN TO OFF;" is done, and the +time drops to 151ms, which is acceptable. + +What I don't understand is why the ports table is scanned in the +first place. Clues please? +-- +Dan Langille : http://www.langille.org/ +BSDCan - http://www.bsdcan.org/ + + +From pgsql-performance-owner@postgresql.org Wed Jun 9 16:29:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 01457D1B18C + for ; + Mon, 7 Jun 2004 17:03: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 96300-10 + for ; + Mon, 7 Jun 2004 20:01:34 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 67916D1BA5E + for ; + Mon, 7 Jun 2004 17:01:14 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id ED7DE76A7A; Mon, 7 Jun 2004 16:00:32 -0400 (EDT) +Subject: Re: seq scan woes +From: Rod Taylor +To: Dan Langille +Cc: Postgresql Performance +In-Reply-To: <40C48DA6.3356.48DAC2EB@localhost> +References: <40C48DA6.3356.48DAC2EB@localhost> +Content-Type: text/plain +Message-Id: <1086638426.86807.40.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 07 Jun 2004 16:00:28 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/98 +X-Sequence-Number: 7156 + +On Mon, 2004-06-07 at 15:45, Dan Langille wrote: +> A production system has had a query recently degrade in performance. +> What once took < 1s now takes over 1s. I have tracked down the +> problem to a working example. + +What changes have you made to postgresql.conf? + +Could you send explain analyse again with SEQ_SCAN enabled but with +nested loops disabled? + +Off the cuff? I might hazard a guess that effective_cache is too low or +random_page_cost is a touch too high. Probably the former. +-- +Rod Taylor + +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL +PGP Key: http://www.rbt.ca/signature.asc + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 17:18:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DA639D1B9A6 + for ; + Mon, 7 Jun 2004 17:12: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 02480-05 + for ; + Mon, 7 Jun 2004 20:12:41 +0000 (GMT) +Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) + by svr1.postgresql.org (Postfix) with ESMTP id E8F32D1B8E8 + for ; + Mon, 7 Jun 2004 17:12:38 -0300 (ADT) +Received: from wocker (wocker.unixathome.org [192.168.0.99]) + by bast.unixathome.org (Postfix) with ESMTP + id 784D93D34; Mon, 7 Jun 2004 16:12:40 -0400 (EDT) +From: "Dan Langille" +To: Rod Taylor +Date: Mon, 07 Jun 2004 16:12:40 -0400 +MIME-Version: 1.0 +Subject: Re: seq scan woes +Cc: Postgresql Performance +Message-ID: <40C493F8.1181.48F37175@localhost> +In-reply-to: <1086638426.86807.40.camel@jester> +References: <40C48DA6.3356.48DAC2EB@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/70 +X-Sequence-Number: 7128 + +On 7 Jun 2004 at 16:00, Rod Taylor wrote: + +> On Mon, 2004-06-07 at 15:45, Dan Langille wrote: +> > A production system has had a query recently degrade in performance. +> > What once took < 1s now takes over 1s. I have tracked down the +> > problem to a working example. +> +> What changes have you made to postgresql.conf? + +Nothing recently (ie. past few months). Nothing at all really. +Perhaps I need to start tuning that. + +> Could you send explain analyse again with SEQ_SCAN enabled but with +> nested loops disabled? + +See http://rafb.net/paste/results/zpJEvb28.html + +13s + +> Off the cuff? I might hazard a guess that effective_cache is too low or +> random_page_cost is a touch too high. Probably the former. + +I grep'd postgresql.conf: + +#effective_cache_size = 1000 # typically 8KB each +#random_page_cost = 4 # units are one sequential page fetch cost + +NOTE: both above are commented out. + +Thank you +-- +Dan Langille : http://www.langille.org/ +BSDCan - http://www.bsdcan.org/ + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 17:41:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B1FDD1BAAD + for ; + Mon, 7 Jun 2004 17:31: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 13027-05 + for ; + Mon, 7 Jun 2004 20:31:43 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id DCDD9D1BA91 + for ; + Mon, 7 Jun 2004 17:31:40 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5298169; Mon, 07 Jun 2004 13:33:18 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Merlin Moncure" , + +Subject: Re: is it possible to for the planner to optimize this form? +Date: Mon, 7 Jun 2004 13:31:37 -0700 +User-Agent: KMail/1.4.3 +References: <6EE64EF3AB31D5448D0007DD34EEB34101AE56@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AE56@Herge.rcsinc.local> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200406071331.37140.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/71 +X-Sequence-Number: 7129 + +Merlin, + +> select t.key, t.field from t a +> where +> ( +> select count(*) from t b +> where b.field > a.field +> ) = k +> +> The subplan (either index or seq. scan) executes once for each row in t, +> which of course takes forever. +> +> This query is a way of achieving LIMIT type results (substitute n-1 +> desired rows for k) using standard SQL, which is desirable in some +> circumstances. Is it theoretically possible for this to be optimized? + +I don't think so, no. PostgreSQL does have some issues using indexes for +count() queires which makes the situation worse. However, with the query +you presented, I don't see any way around the planner executing the subquery +once for every row in t. + +Except, of course, for some kind of scheme involving materialized views, if +you don't need up-to-the minute data. In that case, you could store in a +table the count(*)s of t for each threshold value of b.field. But, +dynamically, that would be even slower. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Jun 9 16:31:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37E14D1B18C + for ; + Mon, 7 Jun 2004 17:38: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 21318-04 + for ; + Mon, 7 Jun 2004 20:38:20 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 93012D1B557 + for ; + Mon, 7 Jun 2004 17:38:17 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 2C1AE76A7E; Mon, 7 Jun 2004 16:38:23 -0400 (EDT) +Subject: Re: seq scan woes +From: Rod Taylor +To: Dan Langille +Cc: Postgresql Performance +In-Reply-To: <40C493F8.1181.48F37175@localhost> +References: <40C48DA6.3356.48DAC2EB@localhost> + <40C493F8.1181.48F37175@localhost> +Content-Type: text/plain +Message-Id: <1086640698.86807.61.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 07 Jun 2004 16:38:18 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/99 +X-Sequence-Number: 7157 + +On Mon, 2004-06-07 at 16:12, Dan Langille wrote: +> On 7 Jun 2004 at 16:00, Rod Taylor wrote: +> +> > On Mon, 2004-06-07 at 15:45, Dan Langille wrote: +> > > A production system has had a query recently degrade in performance. +> > > What once took < 1s now takes over 1s. I have tracked down the +> > > problem to a working example. +> > +> > What changes have you made to postgresql.conf? +> +> Nothing recently (ie. past few months). Nothing at all really. +> Perhaps I need to start tuning that. +> +> > Could you send explain analyse again with SEQ_SCAN enabled but with +> > nested loops disabled? +> +> See http://rafb.net/paste/results/zpJEvb28.html + +This doesn't appear to be the same query as we were shown earlier. + +> > Off the cuff? I might hazard a guess that effective_cache is too low or +> > random_page_cost is a touch too high. Probably the former. +> +> I grep'd postgresql.conf: +> +> #effective_cache_size = 1000 # typically 8KB each +> #random_page_cost = 4 # units are one sequential page fetch cost + +This would be the issue. You haven't told PostgreSQL anything about your +hardware. The defaults are somewhat modest. + +http://www.postgresql.org/docs/7.4/static/runtime-config.html + +Skim through the run-time configuration parameters that can be set in +postgresql.conf. + +Pay particular attention to: + * shared_buffers (you may be best with 2000 or 4000) + * effective_cache_size (set to 50% of ram size if dedicated db + machine) + * random_page_cost (good disks will bring this down to a 2 from a + 4) + + +-- +Rod Taylor + +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL +PGP Key: http://www.rbt.ca/signature.asc + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 18:02:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E1677D1B229 + for ; + Mon, 7 Jun 2004 18:02: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 32298-01 + for ; + Mon, 7 Jun 2004 21:02:40 +0000 (GMT) +Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) + by svr1.postgresql.org (Postfix) with ESMTP id DD274D1B188 + for ; + Mon, 7 Jun 2004 18:02:37 -0300 (ADT) +Received: from wocker (wocker.unixathome.org [192.168.0.99]) + by bast.unixathome.org (Postfix) with ESMTP + id 2311D3D34; Mon, 7 Jun 2004 17:02:36 -0400 (EDT) +From: "Dan Langille" +To: Rod Taylor +Date: Mon, 07 Jun 2004 17:02:36 -0400 +MIME-Version: 1.0 +Subject: Re: seq scan woes +Cc: Postgresql Performance +Message-ID: <40C49FAC.11805.49212810@localhost> +In-reply-to: <1086640698.86807.61.camel@jester> +References: <40C493F8.1181.48F37175@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/72 +X-Sequence-Number: 7130 + +On 7 Jun 2004 at 16:38, Rod Taylor wrote: + +> On Mon, 2004-06-07 at 16:12, Dan Langille wrote: +> > On 7 Jun 2004 at 16:00, Rod Taylor wrote: +> > +> > > On Mon, 2004-06-07 at 15:45, Dan Langille wrote: +> > > > A production system has had a query recently degrade in performance. +> > > > What once took < 1s now takes over 1s. I have tracked down the +> > > > problem to a working example. +> > > +> > > What changes have you made to postgresql.conf? +> > +> > Nothing recently (ie. past few months). Nothing at all really. +> > Perhaps I need to start tuning that. +> > +> > > Could you send explain analyse again with SEQ_SCAN enabled but with +> > > nested loops disabled? +> > +> > See http://rafb.net/paste/results/zpJEvb28.html +> +> This doesn't appear to be the same query as we were shown earlier. + +My apologies. I should try to cook dinner and paste at the same time. + ;) + +http://rafb.net/paste/results/rVr3To35.html is the right query. + +> > > Off the cuff? I might hazard a guess that effective_cache is too low or +> > > random_page_cost is a touch too high. Probably the former. +> > +> > I grep'd postgresql.conf: +> > +> > #effective_cache_size = 1000 # typically 8KB each +> > #random_page_cost = 4 # units are one sequential page fetch cost +> +> This would be the issue. You haven't told PostgreSQL anything about your +> hardware. The defaults are somewhat modest. +> +> http://www.postgresql.org/docs/7.4/static/runtime-config.html +> +> Skim through the run-time configuration parameters that can be set in +> postgresql.conf. +> +> Pay particular attention to: +> * shared_buffers (you may be best with 2000 or 4000) +> * effective_cache_size (set to 50% of ram size if dedicated db +> machine) +> * random_page_cost (good disks will bring this down to a 2 from a +> 4) + +I'll have a play with that and report back. + +Thanks. +-- +Dan Langille : http://www.langille.org/ +BSDCan - http://www.bsdcan.org/ + + +From pgsql-jdbc-owner@postgresql.org Mon Jun 7 18:59:15 2004 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DD1CD1B181 + for ; + Mon, 7 Jun 2004 18: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 55874-09 + for ; + Mon, 7 Jun 2004 21:59:15 +0000 (GMT) +Received: from mail63.csoft.net (unknown [63.111.22.74]) + by svr1.postgresql.org (Postfix) with SMTP id 368F7D1B1EC + for ; Mon, 7 Jun 2004 18:59:07 -0300 (ADT) +Received: (qmail 29494 invoked by uid 1112); 7 Jun 2004 21:38:02 -0000 +Date: Mon, 7 Jun 2004 16:38:01 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary.csoft.net +To: Steve Wampler +Cc: Postgres-JDBC , + Postgres-performance +Subject: Re: [PERFORM] Using a COPY...FROM through JDBC? +In-Reply-To: <1086630056.25790.17.camel@weaver.tuc.noao.edu> +Message-ID: +References: <1086466349.29063.76.camel@weaver.tuc.noao.edu> + + <1086630056.25790.17.camel@weaver.tuc.noao.edu> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/38 +X-Sequence-Number: 10240 + + + +On Mon, 7 Jun 2004, Steve Wampler wrote: + +> I do have a little concern about what's happening in the +> back end during the copy - I suspect the entire table is +> locked, which may impact the performance when multiple +> clients are saving entries into the table. Anyone know +> if that's how COPY works? (For that matter, would that +> also be true of a transaction consisting of a set of +> inserts?) +> + +The table is not locked in either the copy or the insert case. + +Kris Jurka + +From pgsql-performance-owner@postgresql.org Mon Jun 14 19:31:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A6751D1B281 + for ; + Mon, 14 Jun 2004 19:31: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 70228-10 + for ; + Mon, 14 Jun 2004 22:31:07 +0000 (GMT) +Received: from hotmail.com (bay17-dav15.bay17.hotmail.com [64.4.43.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B310D1B19A + for ; + Mon, 14 Jun 2004 19:31:03 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 14 Jun 2004 15:22:19 -0700 +Received: from 142.104.250.115 by bay17-dav15.bay17.hotmail.com with DAV; + Mon, 07 Jun 2004 21:46:54 +0000 +X-Originating-IP: [142.104.250.115] +X-Originating-Email: [borajetta@hotmail.com] +X-Sender: borajetta@hotmail.com +From: "borajetta" +To: +Subject: 50 000 000 Table entries and I have to do a keyword search HELP + NEEDED +Date: Mon, 7 Jun 2004 14:47:17 -0700 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0018_01C44C9E.5410FE00" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 14 Jun 2004 22:22:19.0625 (UTC) + FILETIME=[0E763D90:01C4525E] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE, RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/147 +X-Sequence-Number: 7205 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0018_01C44C9E.5410FE00 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +So I have a table with about 50 million entries in it, I have to do a keywo= +rd search. + +=20 + +The keyword search is done on the title of the entry. For example a entry = +could be "This is a title string which could be searched" + +=20 + +I have tried a few ways to search but I get horrible search times. Some ke= +ywords will come up with matches as big as .25 million but most are around = +1000-5000. + +=20 + +I use an index which narrows the table down to about 1.5-2million entries. + +=20 + +I used 2 tables which had a 1:1 correspondence. + +One held a gist index which was on a int field which searched the for the k= +eyword. Then I would join the table to another to retrieve the rest of the= + information about the items it matched. + +=20 + +This was slow even for returning 100 entries. About 10 seconds, sometimes = +5. But when I start getting 1xxx entries its about 30-50 seconds. The res= +t is just horrible. + +=20 + +How should I set up my indexes and or tables. + +We were thinking of putting the index inside one table then the join would = +not have to be done but this still returns rather slow results. + +=20 + +I have not fully tested this method but it looks like when run for just the= + keyword search on the title and no joining it can return in about 10 secon= +ds or less. + +This is a great improvement but I am currently going to make the table all = +in one and see how long it will take. I believe it will not be much more a= +s there will be no join needed only the returning of some attribute fields.= +=20=20 + +=20 + +This is still not the kind of time I would like to see, I wanted something = +around 2 seconds or less. I know there is a lot of information especially = +if .25 million rows are to be returned but if there is only 1xxx-9xxx rows = +to be returned I believe 2 seconds seems about right. + +=20 + +How do search engines do it? + +Any suggestions are welcome, + +=20 + +Thanks + +------=_NextPart_000_0018_01C44C9E.5410FE00 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+

So I have a table with about 50 million entries in it, I have to d= +o a=20 +keyword search.

+

 

+

The keyword search is done on the title of the entry.  For example a entry could be "Thi= +s is a=20 +title string which could be searched"

+

 

+

I have tried a few ways to search but I get horrible search times.= +  Some keywords will come up with m= +atches=20 +as big as .25 million but most are around 1000-5000.

+

 

+

I use an index which narrows the table down to about 1.5-2million= +=20 +entries.

+

 

+

I used 2 tables which had a 1:1 correspondence.

+

One held a gist index which was on a int field which searched the = +for the=20 +keyword.  Then I would join t= +he=20 +table to another to retrieve the rest of the information about the items it= +=20 +matched.

+

 

+

This was slow even for returning 100 entries.  About 10 seconds, sometimes 5.  But when I start getting 1xxx ent= +ries=20 +its about 30-50 seconds.  The= + rest=20 +is just horrible.

+

 

+

How should I set up my indexes and or tables.

+

We were thinking of putting the index inside one table then the jo= +in=20 +would not have to be done but this still returns rather slow results.

+

 

+

I have not fully tested this method but it looks like when run for= + just=20 +the keyword search on the title and no joining it can return in about 10 se= +conds=20 +or less.

+

This is a great improvement but I am currently goi= +ng to=20 +make the table all in one and see how long it will take.  I believe it will not be much mor= +e as=20 +there will be no join needed only the returning of some attribute fields. 

+

 

+

This is still not the kind of time I would like to see, I wanted= +=20 +something around 2 seconds or less. = +=20 +I know there is a lot of information especially if .25 million rows = +are=20 +to be returned but if there is only 1xxx-9xxx rows to be returned I believe= + 2=20 +seconds seems about right.

+

 

+

How do search engines do it?

+

Any suggestions are welcome,

+

 

+

Thanks

+ +------=_NextPart_000_0018_01C44C9E.5410FE00-- + +From pgsql-performance-owner@postgresql.org Mon Jun 7 19:21:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E3A50D1B265 + for ; + Mon, 7 Jun 2004 19:21: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 64105-08 + for ; + Mon, 7 Jun 2004 22:21:02 +0000 (GMT) +Received: from correo2.lamundial.hn (unknown [200.62.45.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 581FBD1B4A9 + for ; + Mon, 7 Jun 2004 19:20:58 -0300 (ADT) +Received: from lamundial.hn (computo [192.168.0.140]) + by correo2.lamundial.hn (8.12.11/linuxconf) with ESMTP id + i57MF5B0000846 + for ; Mon, 7 Jun 2004 16:15:07 -0600 +Message-ID: <40C4E9EA.7000708@lamundial.hn> +Date: Mon, 07 Jun 2004 16:19:22 -0600 +From: =?ISO-8859-1?Q?Josu=E9_Maldonado?= +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Join slow on "large" tables +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/74 +X-Sequence-Number: 7132 + +Hello list, + +Server is dual Xeon 2.4, 2GBRAM, Postgresql is running on partition: +/dev/sda9 29G 8.9G 20G 31% /home2 +/dev/sda9 on /home2 type jfs (rw) + +Version() +PostgreSQL 7.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2 +20020903 (Red Hat Linux 8.0 3.2-7) + +I have a view to join two tables inventory details (pkardex) and +inventory documents header (pmdoc) this view usually runs pretty slow as +indicated in the explain analyze, pkardex is 1943465 rows and its size +aprox 659MB, pmdoc is 1183520 rows and its size is aprox 314MB. The view +definition is: + +SELECT pkd_pk AS kpk, (pkd_stamp)::date AS kfecha, pkd_docto AS kdocto, + ((((pdc_custid)::text || ' '::text) || +(pdc_custname)::text))::character + varying(50) AS kclpv, pkd_saldo AS ksaldo, pkd_es AS kes, CASE WHEN +(pkd_es + = 'E'::bpchar) THEN pkd_qtyinv ELSE (0)::numeric END AS kentrada, +CASE WHEN + (pkd_es = 'S'::bpchar) THEN pkd_qtyinv ELSE (0)::numeric END AS +ksalida, + pkd_pcode AS kprocode, pkd_price AS kvalor, pdc_tipdoc AS ktipdoc +FROM (pkardex JOIN pmdoc ON ((pmdoc.pdc_pk = pkardex.doctofk))); + + +Shared memory is: +/root: cat /proc/sys/kernel/shmmax +1073741824 + +and postgresql.conf have this settings: +tcpip_socket = true +sort_mem = 8190 # min 64, size in KB +vacuum_mem = 262144 # min 1024, size in KB +checkpoint_segments = 10 +max_connections = 256 +shared_buffers = 32000 +effective_cache_size = 160000 # typically 8KB each +random_page_cost = 2 # units are one sequ + +The explain analyze is: +dbmund=# explain analyze select * from vkardex where kprocode='1017'; + Nested Loop (cost=0.00..32155.66 rows=5831 width=114) (actual +time=18.223..47983.157 rows=4553 loops=1) + -> Index Scan using pkd_pcode_idx on pkardex (cost=0.00..11292.52 +rows=5831 width=72) (actual time=18.152..39520.406 rows=5049 loops=1) + Index Cond: ((pkd_pcode)::text = '1017'::text) + -> Index Scan using pdc_pk_idx on pmdoc (cost=0.00..3.55 rows=1 +width=50) (actual time=1.659..1.661 rows=1 loops=5049) + Index Cond: (pmdoc.pdc_pk = "outer".doctofk) + Total runtime: 47988.067 ms +(6 rows) + +Does anyone can help me how to properly tune postgresql to gain some +speed in such queries, some people have mentioned a RAM increase is +necesary, about 8GB or more to have postgresql to run smooth, any +comment or suggestion. I really appreciate any help. + +Regards, + + +-- +Sinceramente, +Josu� Maldonado. +"Que se me den seis l�neas escritas de pu�o y letra del hombre m�s +honrado del mundo, y hallar� en ellas motivos para hacerle ahorcar." +--cardenal Richelieu (Cardenal y pol�tico franc�s. 1.585 - 1.642) + +From pgsql-performance-owner@postgresql.org Mon Jun 7 19:32:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 40ABED1BAAD + for ; + Mon, 7 Jun 2004 19:31: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 78080-01 + for ; + Mon, 7 Jun 2004 22:31:49 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 41496D1BAAE + for ; + Mon, 7 Jun 2004 19:31:45 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5298956; Mon, 07 Jun 2004 15:33:23 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: =?iso-8859-1?q?Josu=E9=20Maldonado?= , + pgsql-performance@postgresql.org +Subject: Re: Join slow on "large" tables +Date: Mon, 7 Jun 2004 15:31:49 -0700 +User-Agent: KMail/1.5.4 +References: <40C4E9EA.7000708@lamundial.hn> +In-Reply-To: <40C4E9EA.7000708@lamundial.hn> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406071531.49207.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200406/75 +X-Sequence-Number: 7133 + +Josue' + +> -> Index Scan using pkd_pcode_idx on pkardex (cost=0.00..11292.52 +> rows=5831 width=72) (actual time=18.152..39520.406 rows=5049 loops=1) + +Looks to me like there's a problem with index bloat on pkd_pcode_idx. Try +REINDEXing it, and if that doesn't help, VACUUM FULL on pkardex. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 19:47:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BE53D1BAAE + for ; + Mon, 7 Jun 2004 19:46: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 83432-03 + for ; + Mon, 7 Jun 2004 22:46:38 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id 6F9F2D1B503 + for ; + Mon, 7 Jun 2004 19:46:35 -0300 (ADT) +Received: (qmail 74169 invoked by uid 0); 7 Jun 2004 22:46:38 -0000 +Received: from unknown (63.231.195.13) + by mpls-qmqp-01.inet.qwest.net with QMQP; 7 Jun 2004 22:46:38 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-13.inet.qwest.net with SMTP; 7 Jun 2004 22:46:38 -0000 +Date: Mon, 07 Jun 2004 16:47:12 -0600 +Message-Id: <1086648432.27200.37.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "=?ISO-8859-1?Q?Josu=E9?= Maldonado" +Cc: pgsql-performance@postgresql.org +Subject: Re: Join slow on "large" tables +In-Reply-To: <40C4E9EA.7000708@lamundial.hn> +References: <40C4E9EA.7000708@lamundial.hn> +Content-Type: text/plain; charset=utf-8 +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/76 +X-Sequence-Number: 7134 + +On Mon, 2004-06-07 at 16:19, Josué Maldonado wrote: +> Hello list, +> +> Server is dual Xeon 2.4, 2GBRAM, Postgresql is running on partition: +> /dev/sda9 29G 8.9G 20G 31% /home2 +> /dev/sda9 on /home2 type jfs (rw) +> +> Version() +> PostgreSQL 7.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2 +> 20020903 (Red Hat Linux 8.0 3.2-7) +> +> I have a view to join two tables inventory details (pkardex) and +> inventory documents header (pmdoc) this view usually runs pretty slow as +> indicated in the explain analyze, pkardex is 1943465 rows and its size +> aprox 659MB, pmdoc is 1183520 rows and its size is aprox 314MB. The view +> definition is: +> +> SELECT pkd_pk AS kpk, (pkd_stamp)::date AS kfecha, pkd_docto AS kdocto, +> ((((pdc_custid)::text || ' '::text) || +> (pdc_custname)::text))::character +> varying(50) AS kclpv, pkd_saldo AS ksaldo, pkd_es AS kes, CASE WHEN +> (pkd_es +> = 'E'::bpchar) THEN pkd_qtyinv ELSE (0)::numeric END AS kentrada, +> CASE WHEN +> (pkd_es = 'S'::bpchar) THEN pkd_qtyinv ELSE (0)::numeric END AS +> ksalida, +> pkd_pcode AS kprocode, pkd_price AS kvalor, pdc_tipdoc AS ktipdoc +> FROM (pkardex JOIN pmdoc ON ((pmdoc.pdc_pk = pkardex.doctofk))); +> +> +> Shared memory is: +> /root: cat /proc/sys/kernel/shmmax +> 1073741824 +> +> and postgresql.conf have this settings: +> tcpip_socket = true +> sort_mem = 8190 # min 64, size in KB +> vacuum_mem = 262144 # min 1024, size in KB +> checkpoint_segments = 10 +> max_connections = 256 +> shared_buffers = 32000 +> effective_cache_size = 160000 # typically 8KB each +> random_page_cost = 2 # units are one sequ +> +> The explain analyze is: +> dbmund=# explain analyze select * from vkardex where kprocode='1017'; +> Nested Loop (cost=0.00..32155.66 rows=5831 width=114) (actual +> time=18.223..47983.157 rows=4553 loops=1) +> -> Index Scan using pkd_pcode_idx on pkardex (cost=0.00..11292.52 +> rows=5831 width=72) (actual time=18.152..39520.406 rows=5049 loops=1) +> Index Cond: ((pkd_pcode)::text = '1017'::text) +> -> Index Scan using pdc_pk_idx on pmdoc (cost=0.00..3.55 rows=1 +> width=50) (actual time=1.659..1.661 rows=1 loops=5049) +> Index Cond: (pmdoc.pdc_pk = "outer".doctofk) +> Total runtime: 47988.067 ms +> (6 rows) + +OK, you have to ask yourself a question here. Do I have enough memory +to let both postgresql and the kernel to cache this data, or enough +memory for only one. Then, you pick one and try it out. But there's +some issues here. PostgreSQL's shared buffer are not, and should not +generally be thought of as "cache". A cache's job it to hold the whole +working set, or as much as possible, ready for access. A buffer's job +is to hold all the data we're tossing around right this second. Once +we're done with the data, the buffers can and do just drop whatever was +in them. PostgreSQL does not have caching, in the classical sense. +that may or may not change. + +The kernel, on the other hand, has both cache and buffer. Ever notice +that a Linux top shows the cache usually being much bigger than the +buffers? My 512 Meg home box right now has 252968k for cache, and +43276k for buffers. + +Now, you're tossing around enough data to actually maybe have a use for +a huge set of buffers, but this means you'll need to starve your cache +to get enough buffers. Which means that if one process does this kind +of join, drops connection, and two seconds later, another process +connects and does nearly the same thing, it's likely to have to read it +all from the hard drives again, as it's not in the postgresql buffer, +and not in the kernel cache. + +Starting a seperate connection, doing a simple select * from table1; +sekect * from table 2, dropping the result set returned, and staying +connected seems to be enough to get 7.4 to hold onto the data. + +PostgreSQL's current buffer management algo is dirt simple. The ones in +the kernel's cache are quite good. So you can quickly reach a point +where PostgreSQL is chasing it's tail where the kernel would have done +OK. + +Your numbers show that you are tossing 659M and 314M against each other, +but I don't know if you're harvesting the whole set at once, or just a +couple row of each. Indexing help, or is this always gonna be a big seq +scan of 90% of both tables? + +If you are getting the whole thing all the time, and want postgresql to +buffer the whole thing (I recommend against it, although a very few +circumstances seem to support it) you need to have 973M of buffer. That +would be 124544 or we'll just call it 130000. This high of a number +means you will be getting more than 50% of the RAM for postgreSQL. At +that point, it seems you might as well go for broke and grab most of it, +~200000 or so. + +If you're not always mushing the two things against each other, and +you've got other datasets to interact with, index it. + +Oh, in your reply you might to include an explain analyze of the query, +and maybe an output of top while the query is running. + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 19:49:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E97E2D1B181 + for ; + Mon, 7 Jun 2004 19:49: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 84535-04 + for ; + Mon, 7 Jun 2004 22:49:47 +0000 (GMT) +Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) + by svr1.postgresql.org (Postfix) with ESMTP id B1E6FD1B434 + for ; + Mon, 7 Jun 2004 19:49:43 -0300 (ADT) +Received: from wocker (wocker.unixathome.org [192.168.0.99]) + by bast.unixathome.org (Postfix) with ESMTP + id C0CE33D3D; Mon, 7 Jun 2004 18:49:46 -0400 (EDT) +From: "Dan Langille" +To: Rod Taylor +Date: Mon, 07 Jun 2004 18:49:46 -0400 +MIME-Version: 1.0 +Subject: Re: seq scan woes +Cc: Postgresql Performance +Message-ID: <40C4B8CA.5077.4983460F@localhost> +In-reply-to: <1086640698.86807.61.camel@jester> +References: <40C493F8.1181.48F37175@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/77 +X-Sequence-Number: 7135 + +On 7 Jun 2004 at 16:38, Rod Taylor wrote: + +> On Mon, 2004-06-07 at 16:12, Dan Langille wrote: +> > I grep'd postgresql.conf: +> > +> > #effective_cache_size = 1000 # typically 8KB each +> > #random_page_cost = 4 # units are one sequential page fetch cost +> +> This would be the issue. You haven't told PostgreSQL anything about your +> hardware. The defaults are somewhat modest. +> +> http://www.postgresql.org/docs/7.4/static/runtime-config.html +> +> Skim through the run-time configuration parameters that can be set in +> postgresql.conf. +> +> Pay particular attention to: +> * shared_buffers (you may be best with 2000 or 4000) + +I do remember increasing this in the past. It was now at 1000 and is +now at 2000. + +see http://rafb.net/paste/results/VbXQcZ87.html + +> * effective_cache_size (set to 50% of ram size if dedicated db +> machine) + +The machine has 512MB RAM. effective_cache_size was at 1000. So +let's try a 256MB cache. Does that the match a 32000 setting? I +tried it. The query went to 1.5s. At 8000, the query was 1s. At +2000, the query was about 950ms. + +This machine is a webserver/database/mail server, but the FreshPorts +database is by far its biggest task. + +> * random_page_cost (good disks will bring this down to a 2 from a +> 4) + +I've got mine set at 4. Increasing it to 6 gave me a 1971ms query. +At 3, it was a 995ms. Setting it to 2 gave me a 153ms query. + +How interesting. + +For camparison, I reset shared_buffers and effective_cache_size back +to their original value (both at 1000). This gave me a 130-140ms +query. + +The disks in question is: + +ad0: 19623MB [39870/16/63] at ata0-master UDMA100 + +I guess that might be this disk: +http://www.harddrives4less.com/ibmdes6020ua2.html + +I invite comments upon my findings. + +Rod: thanks for the suggestions. + + + + +> +> +> -- +> Rod Taylor +> +> Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL +> PGP Key: http://www.rbt.ca/signature.asc +> +> + + +-- +Dan Langille : http://www.langille.org/ +BSDCan - http://www.bsdcan.org/ + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 19:55:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCEC3D1B4A9 + for ; + Mon, 7 Jun 2004 19:55: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 86925-03 + for ; + Mon, 7 Jun 2004 22:55:24 +0000 (GMT) +Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) + by svr1.postgresql.org (Postfix) with ESMTP id 70585D1B434 + for ; + Mon, 7 Jun 2004 19:55:21 -0300 (ADT) +Received: from wocker (wocker.unixathome.org [192.168.0.99]) + by bast.unixathome.org (Postfix) with ESMTP + id 72B703D34; Mon, 7 Jun 2004 18:55:24 -0400 (EDT) +From: "Dan Langille" +To: Rod Taylor +Date: Mon, 07 Jun 2004 18:55:24 -0400 +MIME-Version: 1.0 +Subject: Re: seq scan woes +Cc: Postgresql Performance +Message-ID: <40C4BA1C.26370.498870C7@localhost> +In-reply-to: <40C4B8CA.5077.4983460F@localhost> +References: <1086640698.86807.61.camel@jester> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/78 +X-Sequence-Number: 7136 + +On 7 Jun 2004 at 18:49, Dan Langille wrote: + +> On 7 Jun 2004 at 16:38, Rod Taylor wrote: +> > * random_page_cost (good disks will bring this down to a 2 from a +> > 4) +> +> I've got mine set at 4. Increasing it to 6 gave me a 1971ms query. +> At 3, it was a 995ms. Setting it to 2 gave me a 153ms query. +> +> How interesting. + +The explain analyse: http://rafb.net/paste/results/pWhHsL86.html +-- +Dan Langille : http://www.langille.org/ +BSDCan - http://www.bsdcan.org/ + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 20:14:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E2EED1B265 + for ; + Mon, 7 Jun 2004 20:14: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 93038-05 + for ; + Mon, 7 Jun 2004 23:14:42 +0000 (GMT) +Received: from correo2.lamundial.hn (mail.lamundial.hn [200.62.45.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 655C5D1B19D + for ; + Mon, 7 Jun 2004 20:14:36 -0300 (ADT) +Received: from lamundial.hn (computo [192.168.0.140]) + by correo2.lamundial.hn (8.12.11/linuxconf) with ESMTP id + i57N8Ruu001174; Mon, 7 Jun 2004 17:08:30 -0600 +Message-ID: <40C4F66C.8030609@lamundial.hn> +Date: Mon, 07 Jun 2004 17:12:44 -0600 +From: =?ISO-8859-1?Q?Josu=E9_Maldonado?= +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Join slow on "large" tables +References: <40C4E9EA.7000708@lamundial.hn> + <200406071531.49207.josh@agliodbs.com> +In-Reply-To: <200406071531.49207.josh@agliodbs.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/79 +X-Sequence-Number: 7137 + +Hi Josh and thanks for your response, + +El 07/06/2004 4:31 PM, Josh Berkus en su mensaje escribio: + +> Josue' +> +> +>> -> Index Scan using pkd_pcode_idx on pkardex (cost=0.00..11292.52 +>>rows=5831 width=72) (actual time=18.152..39520.406 rows=5049 loops=1) +> +> +> Looks to me like there's a problem with index bloat on pkd_pcode_idx. Try +> REINDEXing it, and if that doesn't help, VACUUM FULL on pkardex. +> + +Recreated the index (drop then create) and did the vacuum full pkardex +and the behavior seems to be the same: + +dbmund=# explain analyze select * from vkardex where kprocode='1013'; + Nested Loop (cost=0.00..2248.19 rows=403 width=114) (actual +time=846.318..16030.633 rows=3145 loops=1) + -> Index Scan using pkd_pcode_idx on pkardex (cost=0.00..806.27 +rows=403 width=72) (actual time=0.054..87.393 rows=3544 loops=1) + Index Cond: ((pkd_pcode)::text = '1013'::text) + -> Index Scan using pdc_pk_idx on pmdoc (cost=0.00..3.55 rows=1 +width=50) (actual time=4.482..4.484 rows=1 loops=3544) + Index Cond: (pmdoc.pdc_pk = "outer".doctofk) + Total runtime: 16033.807 ms +(6 rows) + +At the time the querie was running top returned: + +5:11pm up 1:28, 3 users, load average: 0.19, 0.97, 1.41 +69 processes: 66 sleeping, 1 running, 2 zombie, 0 stopped +CPU0 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +CPU1 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +CPU2 states: 0.1% user, 0.4% system, 0.0% nice, 98.4% idle +CPU3 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +Mem: 2069596K av, 1477784K used, 591812K free, 0K shrd, 2336K +buff +Swap: 2096440K av, 9028K used, 2087412K free 1388372K +cached + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND + 1225 postgres 17 0 257M 257M 255M S 0.6 12.7 7:14 postmaster + 1978 postgres 11 0 1044 1044 860 R 0.2 0.0 0:00 top + 1 root 9 0 472 444 428 S 0.0 0.0 0:04 init + 2 root 8 0 0 0 0 SW 0.0 0.0 0:00 keventd + +and free returned: +/root: free + total used free shared buffers cached +Mem: 2069596 1477832 591764 0 2320 1388372 +-/+ buffers/cache: 87140 1982456 +Swap: 2096440 9028 2087412 + +I'm not a Linux guru, it looks like a memory leak. + + +-- +Sinceramente, + +Josu� Maldonado. +"Las palabras de aliento despu�s de la censura son como el sol tras el +aguacero." + +From pgsql-performance-owner@postgresql.org Mon Jun 7 20:21:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96AD4D1BAAD + for ; + Mon, 7 Jun 2004 20: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 90070-09 + for ; + Mon, 7 Jun 2004 23:21:09 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E408D1B34C + for ; + Mon, 7 Jun 2004 20:21:03 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5299287; Mon, 07 Jun 2004 16:22:41 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: =?iso-8859-1?q?Josu=E9=20Maldonado?= +Subject: Re: Join slow on "large" tables +Date: Mon, 7 Jun 2004 16:21:10 -0700 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: <40C4E9EA.7000708@lamundial.hn> + <200406071531.49207.josh@agliodbs.com> + <40C4F66C.8030609@lamundial.hn> +In-Reply-To: <40C4F66C.8030609@lamundial.hn> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406071621.10732.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200406/80 +X-Sequence-Number: 7138 + +Josue' + +> dbmund=# explain analyze select * from vkardex where kprocode='1013'; +> Nested Loop (cost=0.00..2248.19 rows=403 width=114) (actual +> time=846.318..16030.633 rows=3145 loops=1) +> -> Index Scan using pkd_pcode_idx on pkardex (cost=0.00..806.27 +> rows=403 width=72) (actual time=0.054..87.393 rows=3544 loops=1) +> Index Cond: ((pkd_pcode)::text = '1013'::text) +> -> Index Scan using pdc_pk_idx on pmdoc (cost=0.00..3.55 rows=1 +> width=50) (actual time=4.482..4.484 rows=1 loops=3544) +> Index Cond: (pmdoc.pdc_pk = "outer".doctofk) +> Total runtime: 16033.807 ms + +Huh? It is not at all the same. Your index scan is down to 87ms from +27,000! And the total query is down to 16seconds from 47 seconds. Don't +you consider that an improvement? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Jun 7 20:32:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 40D77D1B211 + for ; + Mon, 7 Jun 2004 20:32: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 00623-04 + for ; + Mon, 7 Jun 2004 23:32:20 +0000 (GMT) +Received: from correo2.lamundial.hn (mail.lamundial.hn [200.62.45.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 81E6CD1B265 + for ; + Mon, 7 Jun 2004 20:32:00 -0300 (ADT) +Received: from lamundial.hn (computo [192.168.0.140]) + by correo2.lamundial.hn (8.12.11/linuxconf) with ESMTP id + i57NPu3U001275; Mon, 7 Jun 2004 17:25:57 -0600 +Message-ID: <40C4FA85.8070205@lamundial.hn> +Date: Mon, 07 Jun 2004 17:30:13 -0600 +From: =?ISO-8859-1?Q?Josu=E9_Maldonado?= +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Join slow on "large" tables +References: <40C4E9EA.7000708@lamundial.hn> + <200406071531.49207.josh@agliodbs.com> + <40C4F66C.8030609@lamundial.hn> + <200406071621.10732.josh@agliodbs.com> +In-Reply-To: <200406071621.10732.josh@agliodbs.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/81 +X-Sequence-Number: 7139 + +Josh, + +El 07/06/2004 5:21 PM, Josh Berkus en su mensaje escribio: +> +> Huh? It is not at all the same. Your index scan is down to 87ms from +> 27,000! And the total query is down to 16seconds from 47 seconds. Don't +> you consider that an improvement? + +Yes there was an improvement with respect the previus query, but still +16 seconds is too slow for that query. And usually the query takes more +than 10 seconds even with small data sets returned. + +Thanks, + + +-- +Sinceramente, +Josu� Maldonado. + +"La cultura es capaz de descifrar los enigmas en que nos envuelve la vida." + +From pgsql-performance-owner@postgresql.org Mon Jun 7 20:32:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 60EA6D1B265 + for ; + Mon, 7 Jun 2004 20:32: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 95509-08 + for ; + Mon, 7 Jun 2004 23:32:19 +0000 (GMT) +Received: from mailbox.maricopa.gov (mailbox.maricopa.gov [156.42.4.109]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EED9D1B19D + for ; + Mon, 7 Jun 2004 20:31:50 -0300 (ADT) +Received: from maricopa_xcng2.maricopa.gov (maricopa_xcng2.maricopa.gov + [156.42.103.174] (may be forged)) + by mailbox.maricopa.gov (8.8.6 (PHNE_17190)/8.8.6) with ESMTP id + QAA13962; Mon, 7 Jun 2004 16:25:09 -0700 (MST) +Received: by maricopa_xcng2 with Internet Mail Service (5.5.2657.72) + id ; Mon, 7 Jun 2004 16:31:44 -0700 +Message-ID: <64EDC403A1417B4299488BAE87CA7CBF01CD0E62@maricopa_xcng0> +From: Duane Lee - EGOVX +To: "'Josh Berkus'" , + Merlin Moncure , + pgsql-performance@postgresql.org +Subject: Re: is it possible to for the planner to optimize this +Date: Mon, 7 Jun 2004 16:31:44 -0700 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C44CE7.97BD79F0" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200406/82 +X-Sequence-Number: 7140 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C44CE7.97BD79F0 +Content-Type: text/plain; + charset="iso-8859-1" + +I didn't really look that closely at the problem but have you thought of +trying: + +select t.key, t.field from t a + , (select count(*) as cntb from t b + where b.field > a.field) as dmytbl +where +cntb = k + +This is called an inline view or sometimes a nested table. You would be +joining table t to this inline view with the join criteria being "cntb = k" +where k is in t. + + +-----Original Message----- +From: Josh Berkus [mailto:josh@agliodbs.com] +Sent: Monday, June 07, 2004 1:32 PM +To: Merlin Moncure; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] is it possible to for the planner to optimize +this form? + + +Merlin, + +> select t.key, t.field from t a +> where +> ( +> select count(*) from t b +> where b.field > a.field +> ) = k +> +> The subplan (either index or seq. scan) executes once for each row in t, +> which of course takes forever. +> +> This query is a way of achieving LIMIT type results (substitute n-1 +> desired rows for k) using standard SQL, which is desirable in some +> circumstances. Is it theoretically possible for this to be optimized? + +I don't think so, no. PostgreSQL does have some issues using indexes for +count() queires which makes the situation worse. However, with the query +you presented, I don't see any way around the planner executing the subquery + +once for every row in t. + +Except, of course, for some kind of scheme involving materialized views, if +you don't need up-to-the minute data. In that case, you could store in a +table the count(*)s of t for each threshold value of b.field. But, +dynamically, that would be even slower. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +---------------------------(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 + +------_=_NextPart_001_01C44CE7.97BD79F0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] is it possible to for the planner to optimize this for= +m? + + + +

I didn't really look that closely at the problem but have= + you thought of trying: +

+ +

select t.key, t.field from t a +
    , (select count(*) as cntb from t b +
         where b= +.field > a.field) as dmytbl +
where +
cntb =3D k +

+ +

This is called an inline view or sometimes a nested table= +.  You would be joining table t to this inline view with the join crit= +eria being "cntb =3D k" where k is in t.

+
+ +

-----Original Message----- +
From: Josh Berkus [= +mailto:josh@agliodbs.com] +
Sent: Monday, June 07, 2004 1:32 PM +
To: Merlin Moncure; pgsql-performance@postgresql.org +
Subject: Re: [PERFORM] is it possible to for the planner= + to optimize +
this form? +

+
+ +

Merlin, +

+ +

> select t.key, t.field from t a +
>     where +
>     ( +
>         sel= +ect count(*) from t b +
>         whe= +re b.field > a.field +
>     ) =3D k +
> +
> The subplan (either index or seq. scan) executes on= +ce for each row in t, +
> which of course takes forever. +
> +
> This query is a way of achieving LIMIT type results= + (substitute n-1 +
> desired rows for k) using standard SQL, which is de= +sirable in some +
> circumstances.  Is it theoretically possible f= +or this to be optimized? +

+ +

I don't think so, no.   PostgreSQL does have so= +me issues using indexes for +
count() queires which makes the situation worse. &n= +bsp; However, with the query +
you presented, I don't see any way around the planner ex= +ecuting the subquery +
once for every row in t. +

+ +

Except, of course, for some kind of scheme involving mate= +rialized views, if +
you don't need up-to-the minute data.   In tha= +t case, you could store in a +
table the count(*)s of t for each threshold value of b.f= +ield.  But, +
dynamically, that would be even slower. +

+ +

-- +
Josh Berkus +
Aglio Database Solutions +
San Francisco +

+ +

---------------------------(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 t= +o the mailing list cleanly +

+ + + +------_=_NextPart_001_01C44CE7.97BD79F0-- + +From pgsql-performance-owner@postgresql.org Tue Jun 8 01:29:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C7B0D1B44E + for ; + Tue, 8 Jun 2004 01:29: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 05830-09 + for ; + Tue, 8 Jun 2004 04:29: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 C5C3AD1B276 + for ; + Tue, 8 Jun 2004 01:29:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i584TZAM025925; + Tue, 8 Jun 2004 00:29:35 -0400 (EDT) +To: marcus@coldfeetcreative.com +Cc: pgsql-performance@postgresql.org +Subject: Re: pl/pgsql and Transaction Isolation +In-reply-to: <200406071131.46488.marcus@coldfeetcreative.com> +References: <200406071131.46488.marcus@coldfeetcreative.com> +Comments: In-reply-to Marcus Whitney + message dated "Mon, 07 Jun 2004 11:31:46 -0500" +Date: Tue, 08 Jun 2004 00:29:35 -0400 +Message-ID: <25924.1086668975@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/83 +X-Sequence-Number: 7141 + +Marcus Whitney writes: +> I have an instance where I have a series of pl/pgsql calls, that report stat +> results to a common table. When other queries try to hit the stat table +> (with DML commands; SELECT, INSERT, UPDATE, DELETE etc.) they are forced to +> wait in a queue until the pl/pgsql has finished executing. + +This is quite hard to believe, unless your pl/pgsql is doing something +as unfriendly as LOCKing the table. + +Do you want to post a more complete description of your problem? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 8 02:19:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D89ED1B18C + for ; + Tue, 8 Jun 2004 02:19: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 31247-06 + for ; + Tue, 8 Jun 2004 05:18:59 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 37441D1B1FD + for ; + Tue, 8 Jun 2004 02:18:57 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i585INje026336; + Tue, 8 Jun 2004 01:18:23 -0400 (EDT) +To: =?ISO-8859-1?Q?Josu=E9_Maldonado?= +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org +Subject: Re: Join slow on "large" tables +In-reply-to: <40C4F66C.8030609@lamundial.hn> +References: <40C4E9EA.7000708@lamundial.hn> + <200406071531.49207.josh@agliodbs.com> + <40C4F66C.8030609@lamundial.hn> +Comments: In-reply-to =?ISO-8859-1?Q?Josu=E9_Maldonado?= + message dated "Mon, 07 Jun 2004 17:12:44 -0600" +Date: Tue, 08 Jun 2004 01:18:22 -0400 +Message-ID: <26335.1086671902@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/84 +X-Sequence-Number: 7142 + +=?ISO-8859-1?Q?Josu=E9_Maldonado?= writes: +> Recreated the index (drop then create) and did the vacuum full pkardex +> and the behavior seems to be the same: + +Well, there was a pretty huge improvement in the pkardex scan time, +whether you noticed it or not: 39520.406 to 87.393 msec. This +definitely suggests that you've been lax about vacuuming this table. + +I'm wondering whether pmdoc might not be overdue for vacuuming as +well. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 8 04:28:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BF522D1B34C + for ; + Tue, 8 Jun 2004 04:28: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 78674-07 + for ; + Tue, 8 Jun 2004 07:28:17 +0000 (GMT) +Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id 12F9FD1B238 + for ; + Tue, 8 Jun 2004 04:28:13 -0300 (ADT) +Received: (qmail 10551 invoked by uid 0); 8 Jun 2004 17:28:10 +1000 +Received: from cpe-203-45-37-117.vic.bigpond.net.au (HELO wizzard.pws.com.au) + (wizzard@pws.com.au@203.45.37.117) + by mail.pws.com.au with SMTP; 8 Jun 2004 17:28:10 +1000 +From: Russell Smith +To: pgsql-performance@postgresql.org +Subject: Use of Functional Indexs and Planner estimates +Date: Tue, 8 Jun 2004 17:24:36 +1000 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Message-Id: <200406081724.36617.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/85 +X-Sequence-Number: 7143 + +Dear All, + +I have a table with approximately 570k Rows. + + + Table "filter.rules" + Column | Type | Modifiers +----------+------------------------+---------------------------------------- + rulename | character varying(16) | not null default ''::character varying + uri | character varying(200) | not null default ''::character varying + redirect | character varying(200) | not null default ''::character varying + moddate | date | not null default ('now'::text)::date + active | boolean | not null default true + comment | character varying(255) | not null default ''::character varying +Indexes: + "rules_pkey" primary key, btree (rulename, uri) + "moddate_idx" btree (moddate) + "rules_idx" btree (lower((uri)::text)) + +Statistic on the uri column have been set 1000 +Vacuum full and analyze was run before tests, no alteration to tables since then. + +# analyze verbose filter.rules; +INFO: analyzing "filter.rules" +INFO: "rules": 5228 pages, 300000 rows sampled, 570533 estimated total rows +ANALYZE + +# explain analyze SELECT rulename, redirect from filter.rules WHERE lower(uri) IN(lower('land.com'),lower('com'),lower('land.com/'),lower('com/')) GROUP BY rulename,redirect; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HashAggregate (cost=22352.79..22352.79 rows=1 width=12) (actual time=2047.331..2047.332 rows=1 loops=1) + -> Seq Scan on rules (cost=0.00..22296.32 rows=11294 width=12) (actual time=540.149..2047.308 rows=1 loops=1) + Filter: ((lower((uri)::text) = 'land.com'::text) OR (lower((uri)::text) = 'com'::text) OR (lower((uri)::text) = 'land.com/'::text) OR (lower((uri)::text) = 'com/'::text)) + Total runtime: 2047.420 ms +(4 rows) + +# SET enable_seqscan=off; + +# explain analyze SELECT rulename, redirect from filter.rules WHERE lower(uri) IN(lower('land.com'),lower('com'),lower('land.com/'),lower('com/')) GROUP BY rulename,redirect; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HashAggregate (cost=38970.68..38970.68 rows=1 width=12) (actual time=0.328..0.328 rows=1 loops=1) + -> Index Scan using rules_idx, rules_idx, rules_idx, rules_idx on rules (cost=0.00..38914.21 rows=11294 width=12) (actual time=0.210..0.312 rows=1 loops=1) + Index Cond: ((lower((uri)::text) = 'land.com'::text) OR (lower((uri)::text) = 'com'::text) OR (lower((uri)::text) = 'land.com/'::text) OR (lower((uri)::text) = 'com/'::text)) + Total runtime: 0.700 ms +(4 rows) + +Could anybody offer explanations of why the planner does such a terrible job of estimated the number of rows for this query, with the stats set so high. +Tests were also done with stats set to 100, and 1. The results are exactly the same. Which I would have assumed. + +Also I am interested in how functional indexes have statistics collected for them, if they do. As to possibly minimize or avoid this problem in the future. + +Thanks for your considersation of this matter. + +Regards + +Russell Smith. + +From pgsql-performance-owner@postgresql.org Tue Jun 8 05:57:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DCF2D1B1DC + for ; + Tue, 8 Jun 2004 05:57: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 20747-06 + for ; + Tue, 8 Jun 2004 08:57:23 +0000 (GMT) +Received: from email08.aon.at (WARSL402PIP7.highway.telekom.at [195.3.96.94]) + by svr1.postgresql.org (Postfix) with SMTP id BDC12D1B3AD + for ; + Tue, 8 Jun 2004 05:57:19 -0300 (ADT) +Received: (qmail 358630 invoked from network); 8 Jun 2004 08:57:21 -0000 +Received: from m170p006.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.11.38]) (envelope-sender ) + by 172.18.5.237 (qmail-ldap-1.03) with SMTP + for ; 8 Jun 2004 08:57:21 -0000 +From: Manfred Koizar +To: Russell Smith +Cc: pgsql-performance@postgresql.org +Subject: Re: Use of Functional Indexs and Planner estimates +Date: Tue, 08 Jun 2004 10:57:49 +0200 +Message-ID: <6kvac0hridvjffsnf527tk0gh7qu58cac4@email.aon.at> +References: <200406081724.36617.mr-russ@pws.com.au> +In-Reply-To: <200406081724.36617.mr-russ@pws.com.au> +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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/86 +X-Sequence-Number: 7144 + +On Tue, 8 Jun 2004 17:24:36 +1000, Russell Smith +wrote: +>Also I am interested in how functional indexes have statistics collected for them, if they do. + +Not in any released version. + +http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/analyze.c + +| Revision 1.70 / Sun Feb 15 21:01:39 2004 UTC (3 months, 3 weeks ago) by tgl +| Changes since 1.69: +323 -16 lines +| +| First steps towards statistics on expressional (nee functional) indexes. +| This commit teaches ANALYZE to store such stats in pg_statistic, but +| nothing is done yet about teaching the planner to use 'em. + +So statistics gathering for expressional indexes will be in 7.5, but I +don't know about the state of the planner ... + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Tue Jun 8 11:27:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B05A3D1B189 + for ; + Tue, 8 Jun 2004 11:24: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 76541-10 + for ; + Tue, 8 Jun 2004 14:24:48 +0000 (GMT) +Received: from ml-hw5.monsterlabs.com (ml-hw5.monsterlabs.com + [216.183.105.167]) + by svr1.postgresql.org (Postfix) with SMTP id 4E8A5D1B19D + for ; + Tue, 8 Jun 2004 11:24:40 -0300 (ADT) +Received: (qmail 7051 invoked from network); 8 Jun 2004 14:24:40 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.15?) + (64.3.242.80) + by ml-hw5.monsterlabs.com with SMTP; 8 Jun 2004 14:24:40 -0000 +From: Marcus Whitney +Reply-To: marcus@coldfeetcreative.com +Organization: Coldfeet Creative +To: Tom Lane +Subject: Re: pl/pgsql and Transaction Isolation +Date: Tue, 8 Jun 2004 09:19:44 -0500 +User-Agent: KMail/1.6.1 +References: <200406071131.46488.marcus@coldfeetcreative.com> + <25924.1086668975@sss.pgh.pa.us> +In-Reply-To: <25924.1086668975@sss.pgh.pa.us> +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200406080919.45031.marcus@coldfeetcreative.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/87 +X-Sequence-Number: 7145 + +You were right not to believe it. I had an update on a whole table that I +hadn't noticed. Thanks for debunking. + +On Monday 07 June 2004 23:29, you wrote: +> Marcus Whitney writes: +> > I have an instance where I have a series of pl/pgsql calls, that report +> > stat results to a common table. When other queries try to hit the stat +> > table (with DML commands; SELECT, INSERT, UPDATE, DELETE etc.) they are +> > forced to wait in a queue until the pl/pgsql has finished executing. +> +> This is quite hard to believe, unless your pl/pgsql is doing something +> as unfriendly as LOCKing the table. +> +> Do you want to post a more complete description of your problem? +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + +-- +marcus whitney + +From pgsql-performance-owner@postgresql.org Tue Jun 8 11:34:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 07578D1B189 + for ; + Tue, 8 Jun 2004 11:33: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 87064-06 + for ; + Tue, 8 Jun 2004 14:33:33 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DF7A0D1B1CA + for ; + Tue, 8 Jun 2004 11:33:28 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i58EXVwi001316; + Tue, 8 Jun 2004 10:33:31 -0400 (EDT) +To: Manfred Koizar +Cc: Russell Smith , + pgsql-performance@postgresql.org +Subject: Re: Use of Functional Indexs and Planner estimates +In-reply-to: <6kvac0hridvjffsnf527tk0gh7qu58cac4@email.aon.at> +References: <200406081724.36617.mr-russ@pws.com.au> + <6kvac0hridvjffsnf527tk0gh7qu58cac4@email.aon.at> +Comments: In-reply-to Manfred Koizar + message dated "Tue, 08 Jun 2004 10:57:49 +0200" +Date: Tue, 08 Jun 2004 10:33:30 -0400 +Message-ID: <1315.1086705210@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/88 +X-Sequence-Number: 7146 + +Manfred Koizar writes: +> So statistics gathering for expressional indexes will be in 7.5, but I +> don't know about the state of the planner ... + +Planner support is there too: + +2004-02-16 19:52 tgl + + * src/: backend/optimizer/path/costsize.c, + backend/optimizer/util/relnode.c, backend/utils/adt/selfuncs.c, + include/optimizer/pathnode.h, include/utils/selfuncs.h: Make use of + statistics on index expressions. There are still some corner cases + that could stand improvement, but it does all the basic stuff. A + byproduct is that the selectivity routines are no longer + constrained to working on simple Vars; we might in future be able + to improve the behavior for subexpressions that don't match + indexes. + +I don't recall anymore what "corner cases" I had in mind for future +improvement. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 8 11:58:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DD41D1B360 + for ; + Tue, 8 Jun 2004 11:37: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 83176-10 + for ; + Tue, 8 Jun 2004 14:37:48 +0000 (GMT) +Received: from correo2.lamundial.hn (unknown [200.62.45.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A218D1B18C + for ; + Tue, 8 Jun 2004 11:37:41 -0300 (ADT) +Received: from lamundial.hn (computo [192.168.0.140]) + by correo2.lamundial.hn (8.12.11/linuxconf) with ESMTP id + i58EViEW004808; Tue, 8 Jun 2004 08:31:45 -0600 +Message-ID: <40C5CED2.3020002@lamundial.hn> +Date: Tue, 08 Jun 2004 08:36:02 -0600 +From: =?UTF-8?B?Sm9zdcOpIE1hbGRvbmFkbw==?= +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Scott Marlowe +Cc: pgsql-performance@postgresql.org +Subject: Re: Join slow on "large" tables +References: <40C4E9EA.7000708@lamundial.hn> + <1086648432.27200.37.camel@localhost.localdomain> +In-Reply-To: <1086648432.27200.37.camel@localhost.localdomain> +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/89 +X-Sequence-Number: 7147 + +Hello Scott, + +El 07/06/2004 4:47 PM, Scott Marlowe en su mensaje escribio: + +> OK, you have to ask yourself a question here. Do I have enough memory +> to let both postgresql and the kernel to cache this data, or enough +> memory for only one. Then, you pick one and try it out. But there's +> some issues here. PostgreSQL's shared buffer are not, and should not +> generally be thought of as "cache". A cache's job it to hold the whole +> working set, or as much as possible, ready for access. A buffer's job +> is to hold all the data we're tossing around right this second. Once +> we're done with the data, the buffers can and do just drop whatever was +> in them. PostgreSQL does not have caching, in the classical sense. +> that may or may not change. +> +> The kernel, on the other hand, has both cache and buffer. Ever notice +> that a Linux top shows the cache usually being much bigger than the +> buffers? My 512 Meg home box right now has 252968k for cache, and +> 43276k for buffers. + +I noticed buffers are lower agains cache at least as top shows, dunno if +I'm wrong: + + 8:28am up 1:00, 2 users, load average: 0.40, 0.97, 0.75 +65 processes: 64 sleeping, 1 running, 0 zombie, 0 stopped +CPU0 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +CPU1 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +CPU2 states: 0.0% user, 0.1% system, 0.0% nice, 99.4% idle +CPU3 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +Mem: 2069596K av, 1882228K used, 187368K free, 0K shrd, 32924K +buff +Swap: 2096440K av, 0K used, 2096440K free 1757220K +cached + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND + 1508 root 13 0 1040 1040 856 R 0.1 0.0 0:00 top + 1 root 8 0 476 476 432 S 0.0 0.0 0:04 init + + + +> Now, you're tossing around enough data to actually maybe have a use for +> a huge set of buffers, but this means you'll need to starve your cache +> to get enough buffers. Which means that if one process does this kind +> of join, drops connection, and two seconds later, another process +> connects and does nearly the same thing, it's likely to have to read it +> all from the hard drives again, as it's not in the postgresql buffer, +> and not in the kernel cache. +> +> Starting a seperate connection, doing a simple select * from table1; +> sekect * from table 2, dropping the result set returned, and staying +> connected seems to be enough to get 7.4 to hold onto the data. +> +> PostgreSQL's current buffer management algo is dirt simple. The ones in +> the kernel's cache are quite good. So you can quickly reach a point +> where PostgreSQL is chasing it's tail where the kernel would have done +> OK. +> +> Your numbers show that you are tossing 659M and 314M against each other, +> but I don't know if you're harvesting the whole set at once, or just a +> couple row of each. Indexing help, or is this always gonna be a big seq +> scan of 90% of both tables? + +Generally only a small set is queried, the bigest record set expected is +about 24,000 rows and does not exced the 10MB size, explain analyze +shows the planner is using the index as expected but performance still poor. + +> If you are getting the whole thing all the time, and want postgresql to +> buffer the whole thing (I recommend against it, although a very few +> circumstances seem to support it) you need to have 973M of buffer. That +> would be 124544 or we'll just call it 130000. This high of a number +> means you will be getting more than 50% of the RAM for postgreSQL. At +> that point, it seems you might as well go for broke and grab most of it, +> ~200000 or so. +> +> If you're not always mushing the two things against each other, and +> you've got other datasets to interact with, index it. +> +> Oh, in your reply you might to include an explain analyze of the query, +> and maybe an output of top while the query is running. +> + +dbmund=# explain analyze select * from vkardex where kprocode='1013'; + Nested Loop (cost=0.00..2248.19 rows=403 width=114) (actual +time=846.318..16030.633 rows=3145 loops=1) + -> Index Scan using pkd_pcode_idx on pkardex (cost=0.00..806.27 +rows=403 width=72) (actual time=0.054..87.393 rows=3544 loops=1) + Index Cond: ((pkd_pcode)::text = '1013'::text) + -> Index Scan using pdc_pk_idx on pmdoc (cost=0.00..3.55 rows=1 +width=50) (actual time=4.482..4.484 rows=1 loops=3544) + Index Cond: (pmdoc.pdc_pk = "outer".doctofk) + Total runtime: 16033.807 ms +(6 rows) + +At the time the querie was running top returned: +5:11pm up 1:28, 3 users, load average: 0.19, 0.97, 1.41 +69 processes: 66 sleeping, 1 running, 2 zombie, 0 stopped +CPU0 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +CPU1 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +CPU2 states: 0.1% user, 0.4% system, 0.0% nice, 98.4% idle +CPU3 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle +Mem: 2069596K av, 1477784K used, 591812K free, 0K shrd, 2336K +buff +Swap: 2096440K av, 9028K used, 2087412K free 1388372K +cached + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND + 1225 postgres 17 0 257M 257M 255M S 0.6 12.7 7:14 postmaster + 1978 postgres 11 0 1044 1044 860 R 0.2 0.0 0:00 top + 1 root 9 0 472 444 428 S 0.0 0.0 0:04 init + 2 root 8 0 0 0 0 SW 0.0 0.0 0:00 keventd + +and free returned: +/root: free + total used free shared buffers cached +Mem: 2069596 1477832 591764 0 2320 1388372 +-/+ buffers/cache: 87140 1982456 +Swap: 2096440 9028 2087412 + + +Thanks, + + +-- +Sinceramente, +Josué Maldonado. +"El verdadero placer está en la búsqueda, más que en la explicación." -- +Isaac Asimov + +From pgsql-performance-owner@postgresql.org Tue Jun 8 12:37:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CE76D1BA0A + for ; + Tue, 8 Jun 2004 11:53: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 92287-07 + for ; + Tue, 8 Jun 2004 14:53:33 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id C8AEBD1B49D + for ; + Tue, 8 Jun 2004 11:53:27 -0300 (ADT) +Received: (qmail 26576 invoked by uid 0); 8 Jun 2004 14:53:32 -0000 +Received: from unknown (63.231.195.5) + by mpls-qmqp-01.inet.qwest.net with QMQP; 8 Jun 2004 14:53:32 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-05.inet.qwest.net with SMTP; 8 Jun 2004 14:53:32 -0000 +Date: Tue, 08 Jun 2004 08:54:11 -0600 +Message-Id: <1086706451.27200.50.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Russell Smith" +Cc: pgsql-performance@postgresql.org +Subject: Re: Use of Functional Indexs and Planner estimates +In-Reply-To: <200406081724.36617.mr-russ@pws.com.au> +References: <200406081724.36617.mr-russ@pws.com.au> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/90 +X-Sequence-Number: 7148 + +On Tue, 2004-06-08 at 01:24, Russell Smith wrote: +> Dear All, +> +> I have a table with approximately 570k Rows. +> +> +> Table "filter.rules" +> Column | Type | Modifiers +> ----------+------------------------+---------------------------------------- +> rulename | character varying(16) | not null default ''::character varying +> uri | character varying(200) | not null default ''::character varying +> redirect | character varying(200) | not null default ''::character varying +> moddate | date | not null default ('now'::text)::date +> active | boolean | not null default true +> comment | character varying(255) | not null default ''::character varying +> Indexes: +> "rules_pkey" primary key, btree (rulename, uri) +> "moddate_idx" btree (moddate) +> "rules_idx" btree (lower((uri)::text)) +> +> Statistic on the uri column have been set 1000 +> Vacuum full and analyze was run before tests, no alteration to tables since then. +> +> # analyze verbose filter.rules; +> INFO: analyzing "filter.rules" +> INFO: "rules": 5228 pages, 300000 rows sampled, 570533 estimated total rows +> ANALYZE +> +> # explain analyze SELECT rulename, redirect from filter.rules WHERE lower(uri) IN(lower('land.com'),lower('com'),lower('land.com/'),lower('com/')) GROUP BY rulename,redirect; +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +> HashAggregate (cost=22352.79..22352.79 rows=1 width=12) (actual time=2047.331..2047.332 rows=1 loops=1) +> -> Seq Scan on rules (cost=0.00..22296.32 rows=11294 width=12) (actual time=540.149..2047.308 rows=1 loops=1) +> Filter: ((lower((uri)::text) = 'land.com'::text) OR (lower((uri)::text) = 'com'::text) OR (lower((uri)::text) = 'land.com/'::text) OR (lower((uri)::text) = 'com/'::text)) +> Total runtime: 2047.420 ms +> (4 rows) +> +> # SET enable_seqscan=off; +> +> # explain analyze SELECT rulename, redirect from filter.rules WHERE lower(uri) IN(lower('land.com'),lower('com'),lower('land.com/'),lower('com/')) GROUP BY rulename,redirect; +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +> HashAggregate (cost=38970.68..38970.68 rows=1 width=12) (actual time=0.328..0.328 rows=1 loops=1) +> -> Index Scan using rules_idx, rules_idx, rules_idx, rules_idx on rules (cost=0.00..38914.21 rows=11294 width=12) (actual time=0.210..0.312 rows=1 loops=1) +> Index Cond: ((lower((uri)::text) = 'land.com'::text) OR (lower((uri)::text) = 'com'::text) OR (lower((uri)::text) = 'land.com/'::text) OR (lower((uri)::text) = 'com/'::text)) +> Total runtime: 0.700 ms +> (4 rows) +> +> Could anybody offer explanations of why the planner does such a terrible job of estimated the number of rows for this query, with the stats set so high. +> Tests were also done with stats set to 100, and 1. The results are exactly the same. Which I would have assumed. + +Simple, the planner is choosing a sequential scan when it should be +choosing an index scan. This is usually because random_page_cost is set +too high, at the default of 4. Try settings between 1.2 and 2.x or so +to see how that helps. Be sure and test with various queries of your +own to be sure you've got about the right setting. + + +From pgsql-performance-owner@postgresql.org Tue Jun 8 13:12:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B1CDCD1B349 + for ; + Tue, 8 Jun 2004 12:26: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 26026-02 + for ; + Tue, 8 Jun 2004 15:26:39 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id 95BB9D1B233 + for ; + Tue, 8 Jun 2004 12:26:37 -0300 (ADT) +Received: (qmail 57949 invoked by uid 0); 8 Jun 2004 14:58:37 -0000 +Received: from mpls-pop-07.inet.qwest.net (63.231.195.7) + by mpls-qmqp-03.inet.qwest.net with QMQP; 8 Jun 2004 14:58:37 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-07.inet.qwest.net with SMTP; 8 Jun 2004 15:26:36 -0000 +Date: Tue, 08 Jun 2004 09:27:16 -0600 +Message-Id: <1086708436.27200.66.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "=?ISO-8859-1?Q?Josu=E9?= Maldonado" +Cc: pgsql-performance@postgresql.org +Subject: Re: Join slow on "large" tables +In-Reply-To: <40C5CED2.3020002@lamundial.hn> +References: <40C4E9EA.7000708@lamundial.hn> + <1086648432.27200.37.camel@localhost.localdomain> + <40C5CED2.3020002@lamundial.hn> +Content-Type: text/plain; charset=utf-8 +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/92 +X-Sequence-Number: 7150 + +On Tue, 2004-06-08 at 08:36, Josué Maldonado wrote: +> Hello Scott, + +SNIP... + +> > Your numbers show that you are tossing 659M and 314M against each other, +> > but I don't know if you're harvesting the whole set at once, or just a +> > couple row of each. Indexing help, or is this always gonna be a big seq +> > scan of 90% of both tables? +> +> Generally only a small set is queried, the bigest record set expected is +> about 24,000 rows and does not exced the 10MB size, explain analyze +> shows the planner is using the index as expected but performance still poor. + +If that is the case, then shared_buffers should likely only be 1000 to +10000. anything over 10000 is usually a bad idea, unless you've proven +it to be faster than <10000. + +> dbmund=# explain analyze select * from vkardex where kprocode='1013'; +> Nested Loop (cost=0.00..2248.19 rows=403 width=114) (actual +> time=846.318..16030.633 rows=3145 loops=1) +> -> Index Scan using pkd_pcode_idx on pkardex (cost=0.00..806.27 +> rows=403 width=72) (actual time=0.054..87.393 rows=3544 loops=1) +> Index Cond: ((pkd_pcode)::text = '1013'::text) +> -> Index Scan using pdc_pk_idx on pmdoc (cost=0.00..3.55 rows=1 +> width=50) (actual time=4.482..4.484 rows=1 loops=3544) +> Index Cond: (pmdoc.pdc_pk = "outer".doctofk) +> Total runtime: 16033.807 ms +> (6 rows) + +Well, it looks like your predicted versus actual rows are a bit off, and +in the final bit, the planner things that it is going to be merging 403 +rows but is in fact merging 3145 rows. Try + +set enable_nestloop = off; +and run the explain analyze again and see if that's faster. If so, try +upping your target stats on kprocode (see "\h alter table" in psql for +the syntax), rerun analyze, and try the query with set enable_nestloop = +on to see if the planner makes the right choice. + + + + +From pgsql-performance-owner@postgresql.org Tue Jun 8 13:00:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BC84CD1B278 + for ; + Tue, 8 Jun 2004 12:31: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 19774-09 + for ; + Tue, 8 Jun 2004 15:31:09 +0000 (GMT) +Received: from web13123.mail.yahoo.com (web13123.mail.yahoo.com + [216.136.174.141]) + by svr1.postgresql.org (Postfix) with SMTP id C8F62D1B241 + for ; + Tue, 8 Jun 2004 12:31:07 -0300 (ADT) +Message-ID: <20040608153106.61670.qmail@web13123.mail.yahoo.com> +Received: from [63.78.248.48] by web13123.mail.yahoo.com via HTTP; + Tue, 08 Jun 2004 08:31:06 PDT +Date: Tue, 8 Jun 2004 08:31:06 -0700 (PDT) +From: Litao Wu +Subject: reindex and copy - deadlock? +To: pgsql-performance@postgresql.org +Cc: pgsql-performance@postgresql.org +In-Reply-To: <40C5CED2.3020002@lamundial.hn> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/91 +X-Sequence-Number: 7149 + +Hi, + +We often experience with the problem that reindex +cannot be finished in our production database. +It's typically done with 30 minutes. However, +sometimes, when there is another "COPY" process, +reindex will not finish. By monitoring the CPU +time reindex takes, it does not increase at all. +That seems a deadlock. But the following query shows +only reindex process (23127)is granted lock while +COPY process (3149) is not. + +Last time when we have this problem and kill +reindex process and COPY process does not work. +We had to bounce the database server. + +As you know, when reindex is running, nobody can +access the table. +Can someone kindly help? + +Thanks, + + + +Here is lock info from database: + + replace | database | transaction | pid + | mode | granted +-----------------------+----------+-------------+-------+---------------------+--------- + email | 17613 | | +3149 | RowExclusiveLock | f + email_cre_dom_idx | 17613 | | +23127 | ExclusiveLock | t + email_cid_cre_idx | 17613 | | +23127 | ShareLock | t + email_cid_cre_idx | 17613 | | +23127 | AccessExclusiveLock | t + email | 17613 | | +23127 | ShareLock | t + email | 17613 | | +23127 | AccessExclusiveLock | t + email_cid_cre_dom_idx | 17613 | | +23127 | ShareLock | t + email_cid_cre_dom_idx | 17613 | | +23127 | AccessExclusiveLock | t + email_did_cre_idx | 17613 | | +23127 | ShareLock | t + email_did_cre_idx | 17613 | | +23127 | AccessExclusiveLock | t + email_cre_dom_idx | 17613 | | +23127 | AccessExclusiveLock | t +(11 rows) + + +Here are the processes of 3149 and 23127 from OS: + +postgres 3149 1.3 6.4 154104 134444 ? S +Jun03 92:04 postgres: postgres db1 xx.xx.xx.xx COPY +waiting + +postgres 23127 3.2 9.3 228224 194512 ? S +03:35 15:03 postgres: postgres db1 [local] REINDEX + +Here are queries from database: +23127 | REINDEX table email + + 3149 | COPY email (...) FROM stdin + + + + + + + +__________________________________ +Do you Yahoo!? +Friends. Fun. Try the all-new Yahoo! Messenger. +http://messenger.yahoo.com/ + +From pgsql-performance-owner@postgresql.org Tue Jun 8 13:47:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 301F7D1B8E8 + for ; + Tue, 8 Jun 2004 13:47: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 59823-08 + for ; + Tue, 8 Jun 2004 16:47:09 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 78F31D1B8C4 + for ; + Tue, 8 Jun 2004 13:47:08 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i58Gl8qd002961; + Tue, 8 Jun 2004 12:47:08 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: reindex and copy - deadlock? +In-reply-to: <20040608153106.61670.qmail@web13123.mail.yahoo.com> +References: <20040608153106.61670.qmail@web13123.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Tue, 08 Jun 2004 08:31:06 -0700" +Date: Tue, 08 Jun 2004 12:47:08 -0400 +Message-ID: <2960.1086713228@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/93 +X-Sequence-Number: 7151 + +Litao Wu writes: +> We often experience with the problem that reindex +> cannot be finished in our production database. +> It's typically done with 30 minutes. However, +> sometimes, when there is another "COPY" process, +> reindex will not finish. By monitoring the CPU +> time reindex takes, it does not increase at all. +> That seems a deadlock. + +There is no deadlock visible in your report: the reindex process is not +waiting for a lock, according to either ps or pg_locks. You sure it's +not just slow? I'd expect reindex to be largely I/O bound, so the lack +of CPU activity doesn't prove much. + +If you think it's actually stuck waiting for something, try attaching to +the REINDEX backend process with gdb to get a stack trace. That would +at least give some idea what it's waiting for. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 8 14:25:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BEE0D1B276 + for ; + Tue, 8 Jun 2004 14:25: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 81432-08 + for ; + Tue, 8 Jun 2004 17:25:45 +0000 (GMT) +Received: from web13123.mail.yahoo.com (web13123.mail.yahoo.com + [216.136.174.141]) + by svr1.postgresql.org (Postfix) with SMTP id C477ED1B233 + for ; + Tue, 8 Jun 2004 14:25:42 -0300 (ADT) +Message-ID: <20040608172542.90818.qmail@web13123.mail.yahoo.com> +Received: from [63.78.248.48] by web13123.mail.yahoo.com via HTTP; + Tue, 08 Jun 2004 10:25:42 PDT +Date: Tue, 8 Jun 2004 10:25:42 -0700 (PDT) +From: Litao Wu +Subject: Re: reindex and copy - deadlock? +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <2960.1086713228@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/94 +X-Sequence-Number: 7152 + +Thank you, Tom! + +We vacuum and reindex every night and +reindex typically took 30 minutes. Today, +it ran since 3AM, and has not finished till 8:30AM. + +The email and its indexe sizes are: +tablename indexname size_kb reltuples +email 1292696 8.07905e+06 +email email_cre_dom_idx 323112 +email email_cid_cre_dom_idx 357952 +email email_did_cre_idx 205712 +email email_cid_cre_idx 205560 + +I agree with you that deadlock is unlikely from +database and OS report. + +We have bounced the server since it is a production +database and nobody can access email table because +of this. + +I will use gdb next time. What's this right way to +get info as postgres owner? +gdb +attach pid + +Thanks again! + + +--- Tom Lane wrote: +> Litao Wu writes: +> > We often experience with the problem that reindex +> > cannot be finished in our production database. +> > It's typically done with 30 minutes. However, +> > sometimes, when there is another "COPY" process, +> > reindex will not finish. By monitoring the CPU +> > time reindex takes, it does not increase at all. +> > That seems a deadlock. +> +> There is no deadlock visible in your report: the +> reindex process is not +> waiting for a lock, according to either ps or +> pg_locks. You sure it's +> not just slow? I'd expect reindex to be largely I/O +> bound, so the lack +> of CPU activity doesn't prove much. +> +> If you think it's actually stuck waiting for +> something, try attaching to +> the REINDEX backend process with gdb to get a stack +> trace. That would +> at least give some idea what it's waiting for. +> +> regards, tom lane + + + + + +__________________________________ +Do you Yahoo!? +Friends. Fun. Try the all-new Yahoo! Messenger. +http://messenger.yahoo.com/ + +From pgsql-performance-owner@postgresql.org Tue Jun 8 14:52:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BA90D1B435 + for ; + Tue, 8 Jun 2004 14:52: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 96002-01 + for ; + Tue, 8 Jun 2004 17:51:54 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AD0BD1B4A9 + for ; + Tue, 8 Jun 2004 14:51:18 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i58Hp8xN004465; + Tue, 8 Jun 2004 13:51:08 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: reindex and copy - deadlock? +In-reply-to: <20040608172542.90818.qmail@web13123.mail.yahoo.com> +References: <20040608172542.90818.qmail@web13123.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Tue, 08 Jun 2004 10:25:42 -0700" +Date: Tue, 08 Jun 2004 13:51:08 -0400 +Message-ID: <4464.1086717068@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/95 +X-Sequence-Number: 7153 + +Litao Wu writes: +> I will use gdb next time. What's this right way to +> get info as postgres owner? + + $ gdb /path/to/postgres + gdb> attach PID-of-backend-process + gdb> bt + gdb> quit + +You might try this for practice on any idle backend; it shouldn't affect +the state of the backend, except for freezing it while you issue the +commands. + +If "bt" gives you just a list of numbers and no symbolic information, +then it won't be much help; you'll need to rebuild the backend with +debugging information so that we can make some sense of the trace. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 8 15:44:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B0F4D1B1E0 + for ; + Tue, 8 Jun 2004 15:44: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 09265-09 + for ; + Tue, 8 Jun 2004 18:44:18 +0000 (GMT) +Received: from corpmsx.gaiam.com (unknown [12.147.81.200]) + by svr1.postgresql.org (Postfix) with ESMTP id A55B9D1B18F + for ; + Tue, 8 Jun 2004 15:44:15 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C44D88.C389E96D" +Subject: RamDisk +Date: Tue, 8 Jun 2004 12:45:26 -0600 +Message-ID: <8D36D5916571CB4489C2E4D0CAD6E89301BEE5AD@corpmsx.gaiam.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: RamDisk +Thread-Index: AcRJv1bSQBPjF2XISaimmbvF8nbVqwDxuRIA +From: +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_FONTCOLOR_UNKNOWN, HTML_MESSAGE, NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200406/96 +X-Sequence-Number: 7154 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C44D88.C389E96D +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +=20 + +I am putting together new server to deal with huge burst loads of +traffic. I have been reading up on performance recommendations on the +site and am interested to try a battery backed up ram disks for the wal +buffer. I would like to hear about types and brands of ram disk you have +tried out and if anyone has a make or type they love or hate. What kind +of pgbench improvements have you seen. ) Did anyone experience any linux +driver issues with their ram disk? We will probably run it with Redhat +(2.4.20), on an Opteron 8GB (2,4 or 8) cpu box (clients choice) with the +fastest raid system we can afford. Thanks for the info. + +=20 + +=20 + + +------_=_NextPart_001_01C44D88.C389E96D +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

 

+ +

I am putting together new server to de= +al +with huge burst loads of traffic.  I have been reading up on performan= +ce +recommendations on the site and am interested to try a battery backed up ram +disks for the wal buffer. I would like to hear about types and brands of ram +disk you have tried out and if anyone has a make or type they love or hate.= + What +kind of pgbench improvements have you seen. ) Did anyone experience any lin= +ux driver +issues with their ram disk? We will probably run it with Redhat (2.4.20), o= +n an +Opteron 8GB (2,4 or 8) cpu box (clients choice) with the fastest raid syste= +m we +can afford. Thanks for the info.

+ +

 

+ +

 = +

+ +
+ + + + + +------_=_NextPart_001_01C44D88.C389E96D-- + +From pgsql-performance-owner@postgresql.org Wed Jun 9 13:09:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 288BFD1B19F + for ; + Wed, 9 Jun 2004 13:03: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 86674-08 + for ; + Wed, 9 Jun 2004 16:02:59 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id B65A1D1B1A5 + for ; + Wed, 9 Jun 2004 13:02:57 -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 1BY5UL-00027u-00; Wed, 09 Jun 2004 11:59:41 -0400 +To: "Scott Marlowe" +Cc: "Russell Smith" , + pgsql-performance@postgresql.org +Subject: Re: Use of Functional Indexs and Planner estimates +References: <200406081724.36617.mr-russ@pws.com.au> + <1086706451.27200.50.camel@localhost.localdomain> +In-Reply-To: <1086706451.27200.50.camel@localhost.localdomain> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 09 Jun 2004 11:59:41 -0400 +Message-ID: <87n03cvi1e.fsf@stark.xeocode.com> +Lines: 37 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/97 +X-Sequence-Number: 7155 + + +"Scott Marlowe" writes: + +> > -> Seq Scan on rules +> > (cost=0.00..22296.32 rows=11294 width=12) +> > (actual time=540.149..2047.308 rows=1 loops=1) + + +> Simple, the planner is choosing a sequential scan when it should be +> choosing an index scan. This is usually because random_page_cost is set +> too high, at the default of 4. Try settings between 1.2 and 2.x or so +> to see how that helps. Be sure and test with various queries of your +> own to be sure you've got about the right setting. + +Unless you make random_page_cost about .0004 (4/11294) it isn't going to be +costing this query right (That's a joke, don't do it:). It's thinking there +are 11,000 records matching the where clause when in fact there is only 1. + +If you know how an upper bound on how many records the query should be finding +you might try a kludge involving putting a LIMIT inside the group by. ie, +something like + +select rulename,redirect + from (select rulename,redirect + from ... + where ... + limit 100) as kludge + group by rulename,redirect + +This would at least tell the planner not to expect more than 100 rows and to +take the plan likely to produce the first 100 rows fastest. + +But this has the disadvantage of uglifying your code and introducing an +arbitrary limit. When 7.5 comes out it you'll want to rip this out. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Jun 9 16:56:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3AC9D1B761 + for ; + Wed, 9 Jun 2004 16:33: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 92400-04 + for ; + Wed, 9 Jun 2004 19:33:09 +0000 (GMT) +Received: from server272.com (ns1.server272.com [64.14.68.49]) + by svr1.postgresql.org (Postfix) with SMTP id 4C397D1B75E + for ; + Wed, 9 Jun 2004 16:33:06 -0300 (ADT) +Received: (qmail 4505 invoked from network); 9 Jun 2004 19:34:09 -0000 +Received: from unknown (HELO pesky) (63.170.214.187) + by server272.com with SMTP; 9 Jun 2004 19:34:09 -0000 +Subject: Index oddity +From: ken +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Message-Id: <1086809460.32077.246.camel@pesky> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 09 Jun 2004 12:31:00 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/100 +X-Sequence-Number: 7158 + +I'm having a performance issue that I just can't resolve and its very, +very curious. Thought someone here might be able to shed some light on +the subject. + +I'm using Postgres 7.4.2 on Red Hat 9. I have a table with 763,809 rows +in it defined as follows ... + +ksedb=# \d nrgfeature + Table "public.nrgfeature" + Column | Type | Modifiers +----------------+-----------------------------+----------- + fid1 | numeric(64,0) | not null + fid2 | numeric(64,0) | not null + created | timestamp without time zone | not null + createdby | character varying(30) | not null + modified | timestamp without time zone | + modifiedby | character varying(30) | + geommodified | timestamp without time zone | + geommodifiedby | character varying(30) | + deleted | timestamp without time zone | + deletedby | character varying(30) | + featuretypeid | smallint | not null + description | text | + datasourceid | smallint | not null + lowerleftx | double precision | not null + lowerlefty | double precision | not null + upperrightx | double precision | not null + upperrighty | double precision | not null + diagonalsize | double precision | + login | character varying(25) | +Indexes: + "nrgfeature_pkey" primary key, btree (fid1, fid2) + "nrgfeature_ft_index" btree (featuretypeid) + "nrgfeature_xys_index" btree (upperrightx, lowerleftx, upperrighty, +lowerlefty, diagonalsize) +Inherits: commonfidattrs, + commonrevisionattrs + + +... If I write a query as follows ... + +SELECT * +FROM nrgfeature f +WHERE + upperRightX > 321264.23697721504 + AND lowerLeftX < 324046.79981208267 + AND upperRightY > 123286.26189863647 + AND lowerLeftY < 124985.92745047594 + AND diagonalSize > 50.000 +; + +... (or any value for diagonalsize over 50) then my query runs in 50-100 +milliseconds. However, if the diagonalSize value is changed to 49.999 +or any value below 50, then the query takes over a second for a factor +of 10 degradation in speed, even though the exact same number of rows is +returned. + +The query plan for diagonalSize > 50.000 is ... + +Index Scan using nrgfeature_xys_index on nrgfeature f +(cost=0.00..17395.79 rows=4618 width=220) + Index Cond: ((upperrightx > 321264.236977215::double precision) AND +(lowerleftx < 324046.799812083::double precision) AND (upperrighty > +123286.261898636::double precision) AND (lowerlefty < +124985.927450476::double precision) AND (diagonalsize > 50::double +precision)) + +... while for diagonalSize > 49.999 is ... + + Seq Scan on nrgfeature f (cost=0.00..31954.70 rows=18732 width=220) + Filter: ((upperrightx > 321264.236977215::double precision) AND +(lowerleftx < 324046.799812083::double precision) AND (upperrighty > +123286.261898636::double precision) AND (lowerlefty < +124985.927450476::double precision) AND (diagonalsize > 49.999::double +precision)) + +... and yes, if I set enable_seqscan=false then the index is forced to +be used. However, despite this being an undesirable solution for this +simple case it doesn't solve the problem for the general case. As soon +as I add in joins with a couple of tables to perform the actual query I +want to perform, the seq scan setting doesn't force the index to be used +anymore. Instead, the primary key index is used at this same +diagonalSize cutoff and the 5-part double precision clause is used as a +filter to the index scan and the result is again a very slow query. + +I can provide those queries and results but that would only complicate +this already lengthy email and the above seems to be the crux of the +problem anyway. + +Any help or thoughts would be greatly appreciated of course. + +Thanks, + +Ken Southerland + + +-- +------s----a----m----s----i----x----e----d----d------ +-- + +Ken Southerland +Senior Consultant +Sam Six EDD +http://www.samsixedd.com + +503-236-4288 (office) +503-358-6542 (cell) + + + +From pgsql-performance-owner@postgresql.org Wed Jun 9 17:12:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B955D1B19F + for ; + Wed, 9 Jun 2004 17:12: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 05772-07 + for ; + Wed, 9 Jun 2004 20:12:14 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DA710D1B19A + for ; + Wed, 9 Jun 2004 17:12:12 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 747E176A79; Wed, 9 Jun 2004 16:12:16 -0400 (EDT) +Subject: Re: Index oddity +From: Rod Taylor +To: ken +Cc: Postgresql Performance +In-Reply-To: <1086809460.32077.246.camel@pesky> +References: <1086809460.32077.246.camel@pesky> +Content-Type: text/plain +Message-Id: <1086811930.2539.90.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 09 Jun 2004 16:12:11 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, + HTML_TAG_BALANCE_TABLE +X-Spam-Level: +X-Archive-Number: 200406/101 +X-Sequence-Number: 7159 + +It seems to believe that the number of rows returned for the >49.999 +case will be 4 times the number for the >50 case. If that was true, then +the sequential scan would be correct. + +ALTER TABLE ALTER COLUMN diagonalsize SET STATISTICS 1000; +ANALZYE
; + +Send back EXPLAIN ANALYZE output for the >49.999 case. + +> The query plan for diagonalSize > 50.000 is ... +> +> Index Scan using nrgfeature_xys_index on nrgfeature f +> (cost=0.00..17395.79 rows=4618 width=220) +> Index Cond: ((upperrightx > 321264.236977215::double precision) AND +> (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> 123286.261898636::double precision) AND (lowerlefty < +> 124985.927450476::double precision) AND (diagonalsize > 50::double +> precision)) +> +> ... while for diagonalSize > 49.999 is ... +> +> Seq Scan on nrgfeature f (cost=0.00..31954.70 rows=18732 width=220) +> Filter: ((upperrightx > 321264.236977215::double precision) AND +> (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> 123286.261898636::double precision) AND (lowerlefty < +> 124985.927450476::double precision) AND (diagonalsize > 49.999::double +> precision)) + + +From pgsql-performance-owner@postgresql.org Wed Jun 9 17:52:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B81CFD1B1A5 + for ; + Wed, 9 Jun 2004 17: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 22151-04 + for ; + Wed, 9 Jun 2004 20:52:15 +0000 (GMT) +Received: from server272.com (ns1.server272.com [64.14.68.49]) + by svr1.postgresql.org (Postfix) with SMTP id B8059D1B16B + for ; + Wed, 9 Jun 2004 17:52:11 -0300 (ADT) +Received: (qmail 2075 invoked from network); 9 Jun 2004 20:53:16 -0000 +Received: from unknown (HELO pesky) (63.170.214.187) + by server272.com with SMTP; 9 Jun 2004 20:53:16 -0000 +Subject: Re: Index oddity +From: ken +To: Rod Taylor +Cc: Postgresql Performance +In-Reply-To: <1086811930.2539.90.camel@jester> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> +Content-Type: text/plain +Message-Id: <1086814209.32077.252.camel@pesky> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 09 Jun 2004 13:50:09 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, + HTML_TAG_BALANCE_TABLE +X-Spam-Level: +X-Archive-Number: 200406/102 +X-Sequence-Number: 7160 + +Thanks Rod, + +This setting has no effect however. If I set statistics to 1000, or +even 0, (and then reanalyze the table) I see no change in the behaviour +of the query plans. i.e. there is still the odd transtion in the plans +at diagonalSize = 50. + +Ken + + + +On Wed, 2004-06-09 at 13:12, Rod Taylor wrote: +> It seems to believe that the number of rows returned for the >49.999 +> case will be 4 times the number for the >50 case. If that was true, then +> the sequential scan would be correct. +> +> ALTER TABLE
ALTER COLUMN diagonalsize SET STATISTICS 1000; +> ANALZYE
; +> +> Send back EXPLAIN ANALYZE output for the >49.999 case. +> +> > The query plan for diagonalSize > 50.000 is ... +> > +> > Index Scan using nrgfeature_xys_index on nrgfeature f +> > (cost=0.00..17395.79 rows=4618 width=220) +> > Index Cond: ((upperrightx > 321264.236977215::double precision) AND +> > (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> > 123286.261898636::double precision) AND (lowerlefty < +> > 124985.927450476::double precision) AND (diagonalsize > 50::double +> > precision)) +> > +> > ... while for diagonalSize > 49.999 is ... +> > +> > Seq Scan on nrgfeature f (cost=0.00..31954.70 rows=18732 width=220) +> > Filter: ((upperrightx > 321264.236977215::double precision) AND +> > (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> > 123286.261898636::double precision) AND (lowerlefty < +> > 124985.927450476::double precision) AND (diagonalsize > 49.999::double +> > precision)) +> +> +> ---------------------------(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 Wed Jun 9 17:56:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BA0ED1B211 + for ; + Wed, 9 Jun 2004 17:56: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 18881-10 + for ; + Wed, 9 Jun 2004 20:56:42 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 68ADBD1B1D9 + for ; + Wed, 9 Jun 2004 17:56:37 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id E1E8B76A32; Wed, 9 Jun 2004 16:56:43 -0400 (EDT) +Subject: Re: Index oddity +From: Rod Taylor +To: ken +Cc: Postgresql Performance +In-Reply-To: <1086814209.32077.252.camel@pesky> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> <1086814209.32077.252.camel@pesky> +Content-Type: text/plain +Message-Id: <1086814597.2539.92.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 09 Jun 2004 16:56:38 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, + HTML_TAG_BALANCE_TABLE +X-Spam-Level: +X-Archive-Number: 200406/103 +X-Sequence-Number: 7161 + +On Wed, 2004-06-09 at 16:50, ken wrote: +> Thanks Rod, +> +> This setting has no effect however. If I set statistics to 1000, or + +Okay.. but you never did send EXPLAIN ANALYZE output. I want to know +what it is really finding. + +> On Wed, 2004-06-09 at 13:12, Rod Taylor wrote: +> > It seems to believe that the number of rows returned for the >49.999 +> > case will be 4 times the number for the >50 case. If that was true, then +> > the sequential scan would be correct. +> > +> > ALTER TABLE
ALTER COLUMN diagonalsize SET STATISTICS 1000; +> > ANALZYE
; +> > +> > Send back EXPLAIN ANALYZE output for the >49.999 case. +> > +> > > The query plan for diagonalSize > 50.000 is ... +> > > +> > > Index Scan using nrgfeature_xys_index on nrgfeature f +> > > (cost=0.00..17395.79 rows=4618 width=220) +> > > Index Cond: ((upperrightx > 321264.236977215::double precision) AND +> > > (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> > > 123286.261898636::double precision) AND (lowerlefty < +> > > 124985.927450476::double precision) AND (diagonalsize > 50::double +> > > precision)) +> > > +> > > ... while for diagonalSize > 49.999 is ... +> > > +> > > Seq Scan on nrgfeature f (cost=0.00..31954.70 rows=18732 width=220) +> > > Filter: ((upperrightx > 321264.236977215::double precision) AND +> > > (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> > > 123286.261898636::double precision) AND (lowerlefty < +> > > 124985.927450476::double precision) AND (diagonalsize > 49.999::double +> > > precision)) +> > +> > +> > ---------------------------(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 Wed Jun 9 18:04:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 06B79D1B1D9 + for ; + Wed, 9 Jun 2004 18:04: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 35885-05 + for ; + Wed, 9 Jun 2004 21:04:14 +0000 (GMT) +Received: from server272.com (ns1.server272.com [64.14.68.49]) + by svr1.postgresql.org (Postfix) with SMTP id D2A2CD1B1A5 + for ; + Wed, 9 Jun 2004 18:04:11 -0300 (ADT) +Received: (qmail 6857 invoked from network); 9 Jun 2004 21:05:16 -0000 +Received: from unknown (HELO pesky) (63.170.214.187) + by server272.com with SMTP; 9 Jun 2004 21:05:16 -0000 +Subject: Re: Index oddity +From: ken +To: Rod Taylor +Cc: Postgresql Performance +In-Reply-To: <1086814597.2539.92.camel@jester> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> +Content-Type: text/plain +Message-Id: <1086814928.32077.259.camel@pesky> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 09 Jun 2004 14:02:09 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, + HTML_TAG_BALANCE_TABLE +X-Spam-Level: +X-Archive-Number: 200406/104 +X-Sequence-Number: 7162 + +On Wed, 2004-06-09 at 13:56, Rod Taylor wrote: +> On Wed, 2004-06-09 at 16:50, ken wrote: +> > Thanks Rod, +> > +> > This setting has no effect however. If I set statistics to 1000, or +> +> Okay.. but you never did send EXPLAIN ANALYZE output. I want to know +> what it is really finding. + +Ah, sorry, missed the ANALYZE portion of your request (thought you only +wanted the result of explain if it changed due to the setting). + +Here is the query plan with statistics on diagonalsize set to the +default (-1) ... + + Seq Scan on nrgfeature f (cost=0.00..32176.98 rows=19134 width=218) +(actual time=61.640..1009.414 rows=225 loops=1) + Filter: ((upperrightx > 321264.236977215::double precision) AND +(lowerleftx < 324046.799812083::double precision) AND (upperrighty > +123286.261898636::double precision) AND (lowerlefty < +124985.927450476::double precision) AND (diagonalsize > 49.999::double +precision)) + +... and here is the plan with statistics set to 1000 ... + + Seq Scan on nrgfeature f (cost=0.00..31675.57 rows=18608 width=218) +(actual time=63.544..1002.701 rows=225 loops=1) + Filter: ((upperrightx > 321264.236977215::double precision) AND +(lowerleftx < 324046.799812083::double precision) AND (upperrighty > +123286.261898636::double precision) AND (lowerlefty < +124985.927450476::double precision) AND (diagonalsize > 49.999::double +precision)) + +... so yeah, its obviously finding way, way less rows than it thinks it +will. + +thanks, + +ken + + +> +> > On Wed, 2004-06-09 at 13:12, Rod Taylor wrote: +> > > It seems to believe that the number of rows returned for the >49.999 +> > > case will be 4 times the number for the >50 case. If that was true, then +> > > the sequential scan would be correct. +> > > +> > > ALTER TABLE
ALTER COLUMN diagonalsize SET STATISTICS 1000; +> > > ANALZYE
; +> > > +> > > Send back EXPLAIN ANALYZE output for the >49.999 case. +> > > + + + +From pgsql-performance-owner@postgresql.org Wed Jun 9 18:29:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED24ED1B211 + for ; + Wed, 9 Jun 2004 18:29: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 54647-03 + for ; + Wed, 9 Jun 2004 21:29:05 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5ABDBD1B16B + for ; + Wed, 9 Jun 2004 18:29:02 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id EA53576A61; Wed, 9 Jun 2004 17:29:08 -0400 (EDT) +Subject: Re: Index oddity +From: Rod Taylor +To: ken +Cc: Postgresql Performance +In-Reply-To: <1086814928.32077.259.camel@pesky> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> <1086814928.32077.259.camel@pesky> +Content-Type: text/plain +Message-Id: <1086816543.2539.98.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 09 Jun 2004 17:29:03 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/105 +X-Sequence-Number: 7163 + +> ... and here is the plan with statistics set to 1000 ... +> +> Seq Scan on nrgfeature f (cost=0.00..31675.57 rows=18608 width=218) +> (actual time=63.544..1002.701 rows=225 loops=1) +> Filter: ((upperrightx > 321264.236977215::double precision) AND +> (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> 123286.261898636::double precision) AND (lowerlefty < +> 124985.927450476::double precision) AND (diagonalsize > 49.999::double +> precision)) + +It's better like this, but still way off the mark. Even your good query +which uses the index was out by more than an order of magnitude. + +Try raising the statistics levels for upperrightx, lowerleftx, +upperrighty and lowerlefty. + +Failing that, you might be able to push it back down again by giving +diagonalsize an upper limit. Perhaps 500 is a value that would never +occur. + + AND (diagonalsize BETWEEN 49.999::double precision AND 500) + + + +From pgsql-performance-owner@postgresql.org Wed Jun 9 20:13:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DAEADD1B233 + for ; + Wed, 9 Jun 2004 20:13: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 92493-05 + for ; + Wed, 9 Jun 2004 23:13:11 +0000 (GMT) +Received: from server272.com (ns1.server272.com [64.14.68.49]) + by svr1.postgresql.org (Postfix) with SMTP id C737FD1B211 + for ; + Wed, 9 Jun 2004 20:13:05 -0300 (ADT) +Received: (qmail 19797 invoked from network); 9 Jun 2004 23:14:10 -0000 +Received: from unknown (HELO pesky) (63.170.214.187) + by server272.com with SMTP; 9 Jun 2004 23:14:10 -0000 +Subject: Re: Index oddity +From: ken +To: Postgresql Performance +In-Reply-To: <1086816543.2539.98.camel@jester> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> <1086814928.32077.259.camel@pesky> + <1086816543.2539.98.camel@jester> +Content-Type: text/plain +Message-Id: <1086822662.32077.278.camel@pesky> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 09 Jun 2004 16:11:03 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/106 +X-Sequence-Number: 7164 + +I had already tried setting the statistics to 1000 for all five of these +double precision fields with effectively no improvement. Should have +mentioned that. + +Also the between makes all values for diagonalSize bad since it is +effectively doing digonalSize > X and diagonalSize < Y. If I do a query +with the same values for the four x,y values and diagonalSize < Y, then +for Y=49.999 the query is fast but for anything 50.000 and greater the +query is slow. The exact opposite of the greater than queries not +surprisingly. + +I also think I originally reported that the two queries gave the same +number of rows. That is not true. It was true when I had other joins +in, but when I stripped the query down to this core problem I should +have noticed that the number of results now differs between the two, +which I didn't at first. + +If I take away the diagonalSize condition in my query I find that there +are 225 rows that satisfy the other conditions. 155 of these have a +diagonalSize value of exactly 50.000, while the remaining 70 rows all +have values larger than 50. Thus there is a big discrete jump in the +number of rows at a diagonalSize of 50. However, the statistics are off +by two orders of magnitude in guessing how many rows there are going to +be in this case and thus is not using my index. How can I fix that? + +Ken + + + +On Wed, 2004-06-09 at 14:29, Rod Taylor wrote: +> > ... and here is the plan with statistics set to 1000 ... +> > +> > Seq Scan on nrgfeature f (cost=0.00..31675.57 rows=18608 width=218) +> > (actual time=63.544..1002.701 rows=225 loops=1) +> > Filter: ((upperrightx > 321264.236977215::double precision) AND +> > (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> > 123286.261898636::double precision) AND (lowerlefty < +> > 124985.927450476::double precision) AND (diagonalsize > 49.999::double +> > precision)) +> +> It's better like this, but still way off the mark. Even your good query +> which uses the index was out by more than an order of magnitude. +> +> Try raising the statistics levels for upperrightx, lowerleftx, +> upperrighty and lowerlefty. +> +> Failing that, you might be able to push it back down again by giving +> diagonalsize an upper limit. Perhaps 500 is a value that would never +> occur. +> +> AND (diagonalsize BETWEEN 49.999::double precision AND 500) +> +> +> + + +From pgsql-performance-owner@postgresql.org Wed Jun 9 22:38:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EE944D1B18A + for ; + Wed, 9 Jun 2004 22: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 37966-07 + for ; + Thu, 10 Jun 2004 01:38:40 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id ED783D1B1CE + for ; + Wed, 9 Jun 2004 22:38:34 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i5A1cYWL037397; Thu, 10 Jun 2004 09:38:35 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <40C7BD2A.70604@familyhealth.com.au> +Date: Thu, 10 Jun 2004 09:45:14 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: ken +Cc: Postgresql Performance +Subject: Re: Index oddity +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> + <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> + <1086814928.32077.259.camel@pesky> + <1086816543.2539.98.camel@jester> + <1086822662.32077.278.camel@pesky> +In-Reply-To: <1086822662.32077.278.camel@pesky> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/107 +X-Sequence-Number: 7165 + +> If I take away the diagonalSize condition in my query I find that there +> are 225 rows that satisfy the other conditions. 155 of these have a +> diagonalSize value of exactly 50.000, while the remaining 70 rows all +> have values larger than 50. Thus there is a big discrete jump in the +> number of rows at a diagonalSize of 50. However, the statistics are off +> by two orders of magnitude in guessing how many rows there are going to +> be in this case and thus is not using my index. How can I fix that? + +Maybe you should drop your random_page_cost to something less than 4, +eg. 3 or even 2... + +Chris + +From pgsql-performance-owner@postgresql.org Wed Jun 9 23:18:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BE87D1B1D5 + for ; + Wed, 9 Jun 2004 23:17: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 49216-10 + for ; + Thu, 10 Jun 2004 02:17:58 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C09CD1B1B3 + for ; + Wed, 9 Jun 2004 23:17:53 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id CA88D76A7F; Wed, 9 Jun 2004 22:18:03 -0400 (EDT) +Subject: Re: Index oddity +From: Rod Taylor +To: Christopher Kings-Lynne +Cc: ken , + Postgresql Performance +In-Reply-To: <40C7BD2A.70604@familyhealth.com.au> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> <1086814928.32077.259.camel@pesky> + <1086816543.2539.98.camel@jester> <1086822662.32077.278.camel@pesky> + <40C7BD2A.70604@familyhealth.com.au> +Content-Type: text/plain +Message-Id: <1086833876.2539.156.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 09 Jun 2004 22:17:57 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/108 +X-Sequence-Number: 7166 + +On Wed, 2004-06-09 at 21:45, Christopher Kings-Lynne wrote: +> > If I take away the diagonalSize condition in my query I find that there +> > are 225 rows that satisfy the other conditions. 155 of these have a + +> Maybe you should drop your random_page_cost to something less than 4, +> eg. 3 or even 2... + +The big problem is a very poor estimate (off by a couple orders of +magnitude). I was hoping someone with more knowledge in fixing those +would jump in. + + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 00:11:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AE84D1B18F + for ; + Thu, 10 Jun 2004 00:08: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 81657-02 + for ; + Thu, 10 Jun 2004 03:08:53 +0000 (GMT) +Received: from mail.coretech.co.nz (coretech.co.nz [202.36.204.41]) + by svr1.postgresql.org (Postfix) with ESMTP id DF531D1B243 + for ; + Thu, 10 Jun 2004 00:08:50 -0300 (ADT) +Received: (qmail 436 invoked from network); 10 Jun 2004 03:08:49 -0000 +Received: from unknown (HELO coretech.co.nz) (10.0.10.28) + by 0 with SMTP; 10 Jun 2004 03:08:49 -0000 +Message-ID: <40C7D0C1.5040504@coretech.co.nz> +Date: Thu, 10 Jun 2004 15:08:49 +1200 +From: Mark Kirkwood +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rod Taylor +Cc: Christopher Kings-Lynne , + ken , + Postgresql Performance +Subject: Re: Index oddity +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> + <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> + <1086814928.32077.259.camel@pesky> + <1086816543.2539.98.camel@jester> + <1086822662.32077.278.camel@pesky> + <40C7BD2A.70604@familyhealth.com.au> + <1086833876.2539.156.camel@jester> +In-Reply-To: <1086833876.2539.156.camel@jester> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/109 +X-Sequence-Number: 7167 + + + +Rod Taylor wrote: + +> +>The big problem is a very poor estimate (off by a couple orders of +>magnitude). I was hoping someone with more knowledge in fixing those +>would jump in. +> +> +> +> +ANALYZE might be producing poor stats due to : + +i) many dead tuples or +ii) high proportion of dead tuples in the first few pages of the table + +Does a VACUUM FULL followed by ANALYZE change the estimates (or have you +tried this already)? + +(p.s. - I probably don't qualify for the 'more knowledge' bit either...) + +regards + +Mark + +From pgsql-performance-owner@postgresql.org Thu Jun 10 00:37:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A246ED1B175 + for ; + Thu, 10 Jun 2004 00: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 87560-07 + for ; + Thu, 10 Jun 2004 03:37:02 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id BF3D2D1B16D + for ; + Thu, 10 Jun 2004 00:36:58 -0300 (ADT) +Received: from commandprompt.com (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i5A3ago08380; + Wed, 9 Jun 2004 20:36:42 -0700 +Message-ID: <40C7D63A.7050707@commandprompt.com> +Date: Wed, 09 Jun 2004 20:32:10 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mark Kirkwood +Cc: Rod Taylor , + Christopher Kings-Lynne , + ken , + Postgresql Performance +Subject: Re: Index oddity +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> + <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> + <1086814928.32077.259.camel@pesky> + <1086816543.2539.98.camel@jester> + <1086822662.32077.278.camel@pesky> + <40C7BD2A.70604@familyhealth.com.au> + <1086833876.2539.156.camel@jester> + <40C7D0C1.5040504@coretech.co.nz> +In-Reply-To: <40C7D0C1.5040504@coretech.co.nz> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/110 +X-Sequence-Number: 7168 + + +>> +> ANALYZE might be producing poor stats due to : +> +> i) many dead tuples or +> ii) high proportion of dead tuples in the first few pages of the table +> +> Does a VACUUM FULL followed by ANALYZE change the estimates (or have +> you tried this already)? +> +> (p.s. - I probably don't qualify for the 'more knowledge' bit either...) + +You can also increase your statistics_target which will make ANALYZE +take longer but can help a great deal +with larger data sets. + +Sincerely, + +Joshua D. Drake + + + +> +> regards +> +> Mark +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 02:02:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A0DDD1B273 + for ; + Thu, 10 Jun 2004 02:02: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 16533-03 + for ; + Thu, 10 Jun 2004 05:02: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 B67D2D1B17B + for ; + Thu, 10 Jun 2004 02:01:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5A51wYf019760; + Thu, 10 Jun 2004 01:01:58 -0400 (EDT) +To: ken +Cc: Rod Taylor , + Postgresql Performance +Subject: Re: Index oddity +In-reply-to: <1086814928.32077.259.camel@pesky> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> + <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> + <1086814928.32077.259.camel@pesky> +Comments: In-reply-to ken + message dated "Wed, 09 Jun 2004 14:02:09 -0700" +Date: Thu, 10 Jun 2004 01:01:58 -0400 +Message-ID: <19759.1086843718@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/111 +X-Sequence-Number: 7169 + +ken writes: +> ... and here is the plan with statistics set to 1000 ... + +> Seq Scan on nrgfeature f (cost=0.00..31675.57 rows=18608 width=218) +> (actual time=63.544..1002.701 rows=225 loops=1) +> Filter: ((upperrightx > 321264.236977215::double precision) AND +> (lowerleftx < 324046.799812083::double precision) AND (upperrighty > +> 123286.261898636::double precision) AND (lowerlefty < +> 124985.927450476::double precision) AND (diagonalsize > 49.999::double +> precision)) + +> ... so yeah, its obviously finding way, way less rows than it thinks it +> will. + +Yup. I think your problem here is that the conditions on the different +columns are highly correlated, but the planner doesn't know anything +about that, because it has no cross-column statistics. + +You could check that the individual conditions are accurately estimated +by looking at the estimated and actual row counts in + +explain analyze +SELECT * FROM nrgfeature f WHERE upperRightX > 321264.23697721504; + +explain analyze +SELECT * FROM nrgfeature f WHERE lowerLeftX < 324046.79981208267; + +etc --- but I'll bet lunch that they are right on the money with the +higher statistics targets, and probably not too far off even at the +default. The trouble is that the planner is simply multiplying these +probabilities together to get its estimate for the combined query, +and when the columns are not independent that leads to a very bad +estimate. + +In particular it sounds like you have a *whole lot* of rows that have +diagonalSize just under 50, and so changing the diagonalSize condition +to include those makes for a big change in the predicted number of rows, +even though for the specific values of upperRightX and friends in your +test query there isn't any change in the actual number of matching rows. + +I don't have any advice to magically solve this problem. I would +suggest experimenting with alternative data representations -- for +example, maybe it would help to store "leftX" and "width" in place +of "leftX" and "rightX", etc. What you want to do is try to decorrelate +the column values. leftX and rightX are likely to have a strong +correlation, but maybe leftX and width don't. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 10 11:24:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BF546D1B349 + for ; + Thu, 10 Jun 2004 11:24: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 51907-03 + for ; + Thu, 10 Jun 2004 14:24:25 +0000 (GMT) +Received: from gatefox.foxi.nl (foxi.xs4all.nl [194.109.246.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D1BDD1B377 + for ; + Thu, 10 Jun 2004 11:24:19 -0300 (ADT) +Received: from techfox.foxi (techfox.foxi [192.168.0.79]) + by gatefox.foxi.nl (8.10.2-20030922/8.10.2) with ESMTP id i5AEOMu01194 + for ; Thu, 10 Jun 2004 16:24:22 +0200 +From: Frank van Vugt +Organization: Foxi Consultants in Technology BV +To: pgsql-performance@postgresql.org +Subject: *very* inefficient choice made by the planner (regarding IN(...)) +Date: Thu, 10 Jun 2004 16:24:21 +0200 +User-Agent: KMail/1.5.4 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406101624.21739.ftm.van.vugt@foxi.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/112 +X-Sequence-Number: 7170 + +L.S. + +Could anybody explain why the planner is doing what it is doing? + +What could I do to make it easier to choose a better plan? + + + +********* +Summary +********* +On a freshly vacuum/analysed pair of tables with 7389 and 64333 records, this: + +select id from location where id not in (select location_id from +location_carrier); + +takes 581546,497 ms + + +While a variant like: + +select id from location where not exists (select 1 from location_carrier where +location_id = location.id); + +takes only 124,625 ms + + +********* +Details +********* +=# select version(); + version +--------------------------------------------------------------------- + PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66 +(1 row) + + +=# \d location + Table "public.location" + Column | Type | Modifiers +------------+-----------------------------+----------- + id | integer | not null +Indexes: + "location_pkey" primary key, btree (id) + + +=# select count(*) from location; + count +------- + 7389 +(1 row) + + +=# \d location_carrier + Table "public.location_carrier" + Column | Type | Modifiers +---------------------+-----------------------------+----------- + location_id | integer | not null + carrier_id | integer | not null +Indexes: + "location_carrier_pkey" primary key, btree (location_id, carrier_id) + + +=# select count(*) from location_carrier; + count +------- + 64333 +(1 row) + + +=# explain select id from location where id not in (select location_id from +location_carrier); + QUERY PLAN +------------------------------------------------------------------------------- + Seq Scan on "location" (cost=0.00..5077093.72 rows=3695 width=4) + Filter: (NOT (subplan)) + SubPlan + -> Seq Scan on location_carrier (cost=0.00..1213.33 rows=64333 width=4) +(4 rows) + + +=# explain analyse select id from location where id not in (select location_id +from location_carrier); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on "location" (cost=0.00..5077093.72 rows=3695 width=4) (actual +time=248.310..581541.483 rows=240 loops=1) + Filter: (NOT (subplan)) + SubPlan + -> Seq Scan on location_carrier (cost=0.00..1213.33 rows=64333 width=4) +(actual time=0.007..48.517 rows=19364 loops=7389) + Total runtime: 581542.560 ms +(5 rows) + +Time: 581546,497 ms + + +=# explain analyse select id from location l left outer join location_carrier +lc on l.id = lc.location_id where lc.location_id is null; + QUERY +PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------- + Merge Left Join (cost=0.00..3022.51 rows=7389 width=4) (actual +time=0.083..435.841 rows=240 loops=1) + Merge Cond: ("outer".id = "inner".location_id) + Filter: ("inner".location_id IS NULL) + -> Index Scan using location_pkey on "location" l (cost=0.00..258.85 +rows=7389 width=4) (actual time=0.041..26.211 rows=7389 loops=1) + -> Index Scan using location_carrier_pkey on location_carrier lc +(cost=0.00..1941.22 rows=64333 width=4) (actual time=0.015..238.305 +rows=64333 loops=1) + Total runtime: 436.213 ms +(6 rows) + +Time: 440,787 ms + + +megafox=# explain analyse select id from location where not exists (select 1 +from location_carrier where location_id = location.id); + QUERY +PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on "location" (cost=0.00..13242.14 rows=3695 width=4) (actual +time=0.078..120.785 rows=240 loops=1) + Filter: (NOT (subplan)) + SubPlan + -> Index Scan using location_carrier_pkey on location_carrier +(cost=0.00..17.61 rows=10 width=0) (actual time=0.011..0.011 rows=1 +loops=7389) + Index Cond: (location_id = $0) + Total runtime: 121.165 ms +(6 rows) + +Time: 124,625 ms + + + + + + + +-- +Best, + + + + +Frank. + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 12:00:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 32E1AD1B17C + for ; + Thu, 10 Jun 2004 12:00: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 72109-02 + for ; + Thu, 10 Jun 2004 15:00:30 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 6ECE4D1B1F8 + for ; + Thu, 10 Jun 2004 12:00:29 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 3865835810; Thu, 10 Jun 2004 08:00:28 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 36FC13580A; Thu, 10 Jun 2004 08:00:28 -0700 (PDT) +Date: Thu, 10 Jun 2004 08:00:28 -0700 (PDT) +From: Stephan Szabo +To: Frank van Vugt +Cc: pgsql-performance@postgresql.org +Subject: Re: *very* inefficient choice made by the planner (regarding +In-Reply-To: <200406101624.21739.ftm.van.vugt@foxi.nl> +Message-ID: <20040610075749.G17875@megazone.bigpanda.com> +References: <200406101624.21739.ftm.van.vugt@foxi.nl> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/113 +X-Sequence-Number: 7171 + + +On Thu, 10 Jun 2004, Frank van Vugt wrote: + +> Could anybody explain why the planner is doing what it is doing? +> +> What could I do to make it easier to choose a better plan? + +You might try raising sort_mem to see if it chooses a better plan. I +think it may be guessing that the hash won't fit and falling back to the +plan you were getting. + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 12:19:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C50DD1B20D + for ; + Thu, 10 Jun 2004 12:19: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 71740-08 + for ; + Thu, 10 Jun 2004 15:19:38 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DC598D1B17C + for ; + Thu, 10 Jun 2004 12:19:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5AFJZe5024881; + Thu, 10 Jun 2004 11:19:35 -0400 (EDT) +To: Frank van Vugt +Cc: pgsql-performance@postgresql.org +Subject: Re: *very* inefficient choice made by the planner (regarding IN(...)) +In-reply-to: <200406101624.21739.ftm.van.vugt@foxi.nl> +References: <200406101624.21739.ftm.van.vugt@foxi.nl> +Comments: In-reply-to Frank van Vugt + message dated "Thu, 10 Jun 2004 16:24:21 +0200" +Date: Thu, 10 Jun 2004 11:19:35 -0400 +Message-ID: <24880.1086880775@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/114 +X-Sequence-Number: 7172 + +Frank van Vugt writes: +> What could I do to make it easier to choose a better plan? + +Increase sort_mem. You want it to pick a "hashed subplan", but +it's not doing so because 64000 rows won't fit in the default +sort_mem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 10 12:32:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F9B0D1B1A1 + for ; + Thu, 10 Jun 2004 12:32: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 76319-09 + for ; + Thu, 10 Jun 2004 15:32:12 +0000 (GMT) +Received: from gatefox.foxi.nl (foxi.xs4all.nl [194.109.246.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B3B4D1B19F + for ; + Thu, 10 Jun 2004 12:32:10 -0300 (ADT) +Received: from techfox.foxi (techfox.foxi [192.168.0.79]) + by gatefox.foxi.nl (8.10.2-20030922/8.10.2) with ESMTP id i5AFW8u02404 + for ; Thu, 10 Jun 2004 17:32:08 +0200 +From: Frank van Vugt +Organization: Foxi Consultants in Technology BV +To: pgsql-performance@postgresql.org +Subject: Re: *very* inefficient choice made by the planner (regarding IN(...)) +Date: Thu, 10 Jun 2004 17:32:08 +0200 +User-Agent: KMail/1.5.4 +References: <200406101624.21739.ftm.van.vugt@foxi.nl> + <24880.1086880775@sss.pgh.pa.us> +In-Reply-To: <24880.1086880775@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406101732.08594.ftm.van.vugt@foxi.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/115 +X-Sequence-Number: 7173 + +Wow, + +The effectiveness of the pgsql mailinglists never ceases to amaze me. + +Default sort mem it was, I guess I'd simply been to cautious with this +per-client setting. + + + + +Stephan & Tom : thanks! + + + + +-- +Best, + + + + +Frank. + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 12:44:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B926D1B381 + for ; + Thu, 10 Jun 2004 12: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 90541-07 + for ; + Thu, 10 Jun 2004 15:44:07 +0000 (GMT) +Received: from simmts6-srv.bellnexxia.net (simmts6.bellnexxia.net + [206.47.199.164]) + by svr1.postgresql.org (Postfix) with ESMTP id EB5CFD1B384 + for ; + Thu, 10 Jun 2004 12:44:05 -0300 (ADT) +Received: from localhost ([67.71.24.121]) by simmts6-srv.bellnexxia.net + (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP + id <20040610154401.KPXW10364.simmts6-srv.bellnexxia.net@localhost>; + Thu, 10 Jun 2004 11:44:01 -0400 +Received: from sympatico.ca ([192.168.250.6]) + by (8.11.6/8.11.6) with ESMTP id i5AFi3g12704; + Thu, 10 Jun 2004 11:44:03 -0400 +Message-ID: <40C881FE.5000301@sympatico.ca> +Date: Thu, 10 Jun 2004 11:45:02 -0400 +From: Jean-Luc Lachance +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 Netscape/7.1 (ax) +X-Accept-Language: en, en-us, en-gb, fr, fr-ca +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: Frank van Vugt +Subject: Re: *very* inefficient choice made by the planner (regarding +References: <200406101624.21739.ftm.van.vugt@foxi.nl> +In-Reply-To: <200406101624.21739.ftm.van.vugt@foxi.nl> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/116 +X-Sequence-Number: 7174 + +The real question is: + +If the two statments are functionally equivalent, why can't PG rewrite +the "NOT IN" version into the more efficient "NOT EXISTS"? + + + +Frank van Vugt wrote: + +> L.S. +> +> Could anybody explain why the planner is doing what it is doing? +> +> What could I do to make it easier to choose a better plan? +> +> +> +> ********* +> Summary +> ********* +> On a freshly vacuum/analysed pair of tables with 7389 and 64333 records, this: +> +> select id from location where id not in (select location_id from +> location_carrier); +> +> takes 581546,497 ms +> +> +> While a variant like: +> +> select id from location where not exists (select 1 from location_carrier where +> location_id = location.id); +> +> takes only 124,625 ms +> +> +> ********* +> Details +> ********* +> =# select version(); +> version +> --------------------------------------------------------------------- +> PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66 +> (1 row) +> +> +> =# \d location +> Table "public.location" +> Column | Type | Modifiers +> ------------+-----------------------------+----------- +> id | integer | not null +> Indexes: +> "location_pkey" primary key, btree (id) +> +> +> =# select count(*) from location; +> count +> ------- +> 7389 +> (1 row) +> +> +> =# \d location_carrier +> Table "public.location_carrier" +> Column | Type | Modifiers +> ---------------------+-----------------------------+----------- +> location_id | integer | not null +> carrier_id | integer | not null +> Indexes: +> "location_carrier_pkey" primary key, btree (location_id, carrier_id) +> +> +> =# select count(*) from location_carrier; +> count +> ------- +> 64333 +> (1 row) +> +> +> =# explain select id from location where id not in (select location_id from +> location_carrier); +> QUERY PLAN +> ------------------------------------------------------------------------------- +> Seq Scan on "location" (cost=0.00..5077093.72 rows=3695 width=4) +> Filter: (NOT (subplan)) +> SubPlan +> -> Seq Scan on location_carrier (cost=0.00..1213.33 rows=64333 width=4) +> (4 rows) +> +> +> =# explain analyse select id from location where id not in (select location_id +> from location_carrier); +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------------------- +> Seq Scan on "location" (cost=0.00..5077093.72 rows=3695 width=4) (actual +> time=248.310..581541.483 rows=240 loops=1) +> Filter: (NOT (subplan)) +> SubPlan +> -> Seq Scan on location_carrier (cost=0.00..1213.33 rows=64333 width=4) +> (actual time=0.007..48.517 rows=19364 loops=7389) +> Total runtime: 581542.560 ms +> (5 rows) +> +> Time: 581546,497 ms +> +> +> =# explain analyse select id from location l left outer join location_carrier +> lc on l.id = lc.location_id where lc.location_id is null; +> QUERY +> PLAN +> -------------------------------------------------------------------------------------------------------------------------------------------------------------- +> Merge Left Join (cost=0.00..3022.51 rows=7389 width=4) (actual +> time=0.083..435.841 rows=240 loops=1) +> Merge Cond: ("outer".id = "inner".location_id) +> Filter: ("inner".location_id IS NULL) +> -> Index Scan using location_pkey on "location" l (cost=0.00..258.85 +> rows=7389 width=4) (actual time=0.041..26.211 rows=7389 loops=1) +> -> Index Scan using location_carrier_pkey on location_carrier lc +> (cost=0.00..1941.22 rows=64333 width=4) (actual time=0.015..238.305 +> rows=64333 loops=1) +> Total runtime: 436.213 ms +> (6 rows) +> +> Time: 440,787 ms +> +> +> megafox=# explain analyse select id from location where not exists (select 1 +> from location_carrier where location_id = location.id); +> QUERY +> PLAN +> ----------------------------------------------------------------------------------------------------------------------------------------------------- +> Seq Scan on "location" (cost=0.00..13242.14 rows=3695 width=4) (actual +> time=0.078..120.785 rows=240 loops=1) +> Filter: (NOT (subplan)) +> SubPlan +> -> Index Scan using location_carrier_pkey on location_carrier +> (cost=0.00..17.61 rows=10 width=0) (actual time=0.011..0.011 rows=1 +> loops=7389) +> Index Cond: (location_id = $0) +> Total runtime: 121.165 ms +> (6 rows) +> +> Time: 124,625 ms +> +> +> +> +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 12:59:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F3F6D1B37A + for ; + Thu, 10 Jun 2004 12:59: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 02911-07 + for ; + Thu, 10 Jun 2004 15:59:08 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DBF00D1B2A8 + for ; + Thu, 10 Jun 2004 12:59:07 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5AFx5ZS025305; + Thu, 10 Jun 2004 11:59:05 -0400 (EDT) +To: Jean-Luc Lachance +Cc: pgsql-performance@postgresql.org, + Frank van Vugt +Subject: Re: *very* inefficient choice made by the planner (regarding +In-reply-to: <40C881FE.5000301@sympatico.ca> +References: <200406101624.21739.ftm.van.vugt@foxi.nl> + <40C881FE.5000301@sympatico.ca> +Comments: In-reply-to Jean-Luc Lachance + message dated "Thu, 10 Jun 2004 11:45:02 -0400" +Date: Thu, 10 Jun 2004 11:59:05 -0400 +Message-ID: <25304.1086883145@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/117 +X-Sequence-Number: 7175 + +Jean-Luc Lachance writes: +> If the two statments are functionally equivalent, why can't PG rewrite +> the "NOT IN" version into the more efficient "NOT EXISTS"? + +They're not equivalent. In particular, the behavior in the presence of +NULLs is quite different. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 10 13:02:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 649D5D1B16D + for ; + Thu, 10 Jun 2004 13:02: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 04109-08 + for ; + Thu, 10 Jun 2004 16:02:53 +0000 (GMT) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F9C4D1B384 + for ; + Thu, 10 Jun 2004 13:02:48 -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: Database Server Tuning +Date: Thu, 10 Jun 2004 12:02:46 -0400 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850982D2@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Database Server Tuning +Thread-Index: AcROtNnQYRQw24bSQVCe4fdW6JeQeQATzMIH +From: "Anjan Dave" +To: , "Vivek Khera" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/118 +X-Sequence-Number: 7176 + +Vml2ZWssDQogDQpXYXMgdGhlcmUgYW55dGhpbmcgc3BlY2lmaWMgdGhhdCBo +ZWxwZWQgeW91IGRlY2lkZSBvbiBhIFJBSUQtNSBhbmQgbm90IGEgUkFJRC0x +MD8NCiANCkkgaGF2ZSBteSBEQnMgb24gUkFJRDEwLCBhbmQgd291bGQgc29v +biBiZSBtb3ZpbmcgdGhlbSBvbiBGQyBkcml2ZXMsIGFuZCBpIGFtIGNvbnNp +ZGVyaW5nIFJBSUQtMTAuDQogDQpUaGFua3MsDQpBbmphbg0KDQoJLS0tLS1P +cmlnaW5hbCBNZXNzYWdlLS0tLS0gDQoJRnJvbTogSm9zaCBCZXJrdXMgW21h +aWx0bzpqb3NoQGFnbGlvZGJzLmNvbV0gDQoJU2VudDogVHVlIDMvMi8yMDA0 +IDQ6MjcgUE0gDQoJVG86IFZpdmVrIEtoZXJhOyBwZ3NxbC1wZXJmb3JtYW5j +ZUBwb3N0Z3Jlc3FsLm9yZyANCglDYzogDQoJU3ViamVjdDogUmU6IFtQRVJG +T1JNXSBEYXRhYmFzZSBTZXJ2ZXIgVHVuaW5nDQoJDQoJDQoNCglWaXZlaywN +CgkNCgk+IEkgZGlkIGEgYnVuY2ggb2YgdGVzdGluZyB3aXRoIGRpZmZlcmVu +dCBSQUlEIGxldmVscyBvbiBhIDE0IGRpc2sNCgk+IGFycmF5LiAgSSBmaW5h +bGx5IHNldHRsZWQgb24gdGhpczogIFJBSUQ1IGFjcm9zcyAxNCBkaXNrcyBm +b3IgdGhlDQoJPiBkYXRhLCB0aGUgT1MgKGluY2x1ZGluZyBzeXNsb2cgZGly +ZWN0b3J5KSBhbmQgV0FMIG9uIGEgUkFJRDEgcGFpciBvbg0KCT4gdGhlIG90 +aGVyIGNoYW5uZWwgb2YgdGhlIHNhbWUgY29udHJvbGxlciAoSSBkaWRuJ3Qg +d2FudCB0byBzcHJpbmcgZm9yDQoJPiBkdWFsIFJBSUQgY29udHJvbGxlcnMp +LiAgVGhlIGJpZ2dlc3QgYnVtcHMgaW4gcGVyZm9ybWFuY2UgY2FtZSBmcm9t +DQoJPiBpbmNyZWFzaW5nIHRoZSBjaGVja3BvaW50X2J1ZmZlcnMgc2luY2Ug +bXkgREIgaXMgaGVhdmlseSB3cml0dGVuIHRvLA0KCT4gYW5kIGluY3JlYXNp +bmcgc29ydF9tZW0uDQoJDQoJV2l0aCBsYXJnZSBSQUlELCBoYXZlIHlvdSBm +b3VuZCB0aGF0IGhhdmluZyBXQUwgb24gYSBzZXBlcmF0ZSBhcnJheSBhY3R1 +YWxseQ0KCWJvb3N0cyBwZXJmb3JtYW5jZT8gICBUaGUgZW1waXJpY2FsIHRl +c3RzIHdlJ3ZlIHNlZW4gc28gZmFyIGRvbid0IHNlZW0gdG8NCglzdXBwb3J0 +IHRoaXMuDQoJDQoJLS0NCgktSm9zaCBCZXJrdXMNCgkgQWdsaW8gRGF0YWJh +c2UgU29sdXRpb25zDQoJIFNhbiBGcmFuY2lzY28NCgkNCgkNCgktLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0oZW5kIG9mIGJyb2FkY2FzdCktLS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0NCglUSVAgMTogc3Vic2NyaWJlIGFuZCB1 +bnN1YnNjcmliZSBjb21tYW5kcyBnbyB0byBtYWpvcmRvbW9AcG9zdGdyZXNx +bC5vcmcNCgkNCg0K + +From pgsql-performance-owner@postgresql.org Thu Jun 10 13:51:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 303A5D1B175 + for ; + Thu, 10 Jun 2004 13:51: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 34487-03 + for ; + Thu, 10 Jun 2004 16:51:27 +0000 (GMT) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F4ECD1B389 + for ; + Thu, 10 Jun 2004 13:51:24 -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 76DED217B5; + Thu, 10 Jun 2004 12:51:24 -0400 (EDT) +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850982D2@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850982D2@vt-pe2550-001.vantage.vantage.com> +Mime-Version: 1.0 (Apple Message framework v618) +Content-Type: multipart/signed; micalg=sha1; + boundary=Apple-Mail-20--942581411; + protocol="application/pkcs7-signature" +Message-Id: <688B58EC-BAFE-11D8-AE8E-000A9578CFCC@kcilink.com> +Cc: +From: Vivek Khera +Subject: Re: Database Server Tuning +Date: Thu, 10 Jun 2004 12:51:24 -0400 +To: "Anjan Dave" +X-Mailer: Apple Mail (2.618) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/119 +X-Sequence-Number: 7177 + +--Apple-Mail-20--942581411 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + + +On Jun 10, 2004, at 12:02 PM, Anjan Dave wrote: + +> Vivek, +> +> Was there anything specific that helped you decide on a RAID-5 and not +> a RAID-10? + +performance testing on restore times. My DB is more than 50% write, so +I needed to optimize for writes. + +> I have my DBs on RAID10, and would soon be moving them on FC drives, +> and i am considering RAID-10. + +If I had to do it over again, I'd most likely go with RAID-50, and take +the hit on restore time for the advantage on reads. I have to dig +through my records again to see the details... but then I have to do +all that for my OSCON presentation on this topic at the end of July in +Portland, OR. ;-) + + +--Apple-Mail-20--942581411 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEH +AQAAoIIGhzCCAz8wggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJ +BgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNh +cGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcxKDAmBgNVBAsT +H0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1Ro +YXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVy +c29uYWwtZnJlZW1haWxAdGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0x +MzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUg +Q29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29u +YWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw +gYkCgYEAxKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/ +Uc4B1OVQCjDXAmNaLIkVcI7dyfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOC +dz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/p7bRPGEEQB5kGXJgt/sC +AwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDowOKA2 +oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVt +YWlsQ0EuY3JsMAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UE +AxMRUHJpdmF0ZUxhYmVsMi0xMzgwDQYJKoZIhvcNAQEFBQADgYEASIzRUIPq +Cy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A9BxQIJNwPP2t4WFi +w9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNAMIICqaADAgEC +AgMMB/4wDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCWkExJTAjBgNVBAoT +HFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA0MDMzMDIwNDIx +MVoXDTA1MDMzMDIwNDIxMVowgYoxHzAdBgNVBAMTFlRoYXd0ZSBGcmVlbWFp +bCBNZW1iZXIxHjAcBgkqhkiG9w0BCQEWD3ZpdmVrQGtoZXJhLm9yZzEgMB4G +CSqGSIb3DQEJARYRa2hlcmFAa2NpbGluay5jb20xJTAjBgkqhkiG9w0BCQEW +FnZpdmVrQG1haWxlcm1haWxlci5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IB +DwAwggEKAoIBAQDBSjHPUwN+eaM5uwCtKXo+khMQU4oD9GC4XhNNrVzqx2Jg +x/ep985wo5jxHZ2VJ9wKBt6MuKav8Q6H60oMRot3gW3FYPX5k7GkuMIoThjV +0GzixL/utq5OacDiO8dupSH7CT13AxNfNGFSW3Q6O/PaJ0b2pupL7X+EHY3+ +lpzKV8+OMwcRUW71tI3sZghipVuiUeWZhrJQsuuxxZLM7IyGD0uepCQT3hCI +iClpzJTGDygwW7nBPRuXI2tMAU4wFYZG34BH+JVRYKfm4WH99/9IH7Fz55u0 +qNsvPL7FhZakIDA0QjEprv35zbO9uFSu/PY4Yj91Vaih8PtKkLi+rCVnAgMB +AAGjVzBVMEUGA1UdEQQ+MDyBD3ZpdmVrQGtoZXJhLm9yZ4ERa2hlcmFAa2Np +bGluay5jb22BFnZpdmVrQG1haWxlcm1haWxlci5jb20wDAYDVR0TAQH/BAIw +ADANBgkqhkiG9w0BAQQFAAOBgQA696KzrXtGrERiiN3zJBHZxIox5mVn1Bt/ +RL6JO8PRw4CFuFvLI77Vf9yCiduWd+J7ijfhCmEj3m/W9KmWP4XEArbhIBBO +1lBa2lyHd7LUNnhUTzruAbHdyc4e25PpS3TM3YbFX7e+wdrcdZYWZgiYDb1l +x60aJ4MtJ5+msGQeazGCAucwggLjAgEBMGkwYjELMAkGA1UEBhMCWkExJTAj +BgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMT +I1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBAgMMB/4wCQYF +Kw4DAhoFAKCCAVMwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG +9w0BCQUxDxcNMDQwNjEwMTY1MTI0WjAjBgkqhkiG9w0BCQQxFgQUHs6+kWMY +arG2Q+HO7EQ6vBcymhkweAYJKwYBBAGCNxAEMWswaTBiMQswCQYDVQQGEwJa +QTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoG +A1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAwwH +/jB6BgsqhkiG9w0BCRACCzFroGkwYjELMAkGA1UEBhMCWkExJTAjBgNVBAoT +HFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBAgMMB/4wDQYJKoZIhvcN +AQEBBQAEggEAoMNIjsnp/pUsQ6x9DUBvRJkLbnscbK6fLyCSn5bVuIl+VRA7 ++unR93asaa2SD5RAAg5gfGXzWZLTvExpnNCQ2fc2EWz+BM5XmQLrrKBL+B5X +njg81vNls1NcYcEi00mJ+Nkrx85f8kBUhYxvxRomLYOITlTW23nUR6GnTS4o +mZC5DL3oIzV0o5ttvhLChAd/m4bLaZlo6Hhlq+ae0xtPEe3KcGxK9EV/pcFu +7WreL5szST7ficEStmQrFgtkfnqsMoRuJvGq/VRKG1P5Ty/3MKkaAd7u6ZWi +5GOjsBVbH5oRhnIgG//1+k1hQd6QpvF/EINbYVyAob7q33KrzAizIAAAAAAA +AA== + +--Apple-Mail-20--942581411-- + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 13:55:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A0625D1B37E + for ; + Thu, 10 Jun 2004 13:55: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 37768-03 + for ; + Thu, 10 Jun 2004 16:55:33 +0000 (GMT) +Received: from simmts6-srv.bellnexxia.net (simmts6.bellnexxia.net + [206.47.199.164]) + by svr1.postgresql.org (Postfix) with ESMTP id 0943ED1B1B3 + for ; + Thu, 10 Jun 2004 13:55:30 -0300 (ADT) +Received: from localhost ([67.71.24.121]) by simmts6-srv.bellnexxia.net + (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP + id <20040610165527.LLPV10364.simmts6-srv.bellnexxia.net@localhost>; + Thu, 10 Jun 2004 12:55:27 -0400 +Received: from sympatico.ca ([192.168.250.6]) + by (8.11.6/8.11.6) with ESMTP id i5AGtRg12740; + Thu, 10 Jun 2004 12:55:28 -0400 +Message-ID: <40C892BA.8080704@sympatico.ca> +Date: Thu, 10 Jun 2004 12:56:26 -0400 +From: Jean-Luc Lachance +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 Netscape/7.1 (ax) +X-Accept-Language: en, en-us, en-gb, fr, fr-ca +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org, + Frank van Vugt +Subject: Re: *very* inefficient choice made by the planner (regarding +References: <200406101624.21739.ftm.van.vugt@foxi.nl> + <40C881FE.5000301@sympatico.ca> <25304.1086883145@sss.pgh.pa.us> +In-Reply-To: <25304.1086883145@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/120 +X-Sequence-Number: 7178 + +I agree, but it should be a simple rewrite. No? + +x IS NULL/IS NOT NULL AND/OR NOT EXISTS + + +Tom Lane wrote: + +> Jean-Luc Lachance writes: +> +>>If the two statments are functionally equivalent, why can't PG rewrite +>>the "NOT IN" version into the more efficient "NOT EXISTS"? +> +> +> They're not equivalent. In particular, the behavior in the presence of +> NULLs is quite different. +> +> regards, tom lane +> + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 14:09:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BBDCAD1B37A + for ; + Thu, 10 Jun 2004 14:09: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 40610-05 + for ; + Thu, 10 Jun 2004 17:09:09 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 23E22D1B373 + for ; + Thu, 10 Jun 2004 14:09:07 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 38922358E9; Thu, 10 Jun 2004 10:09:07 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 36E00358E8; Thu, 10 Jun 2004 10:09:07 -0700 (PDT) +Date: Thu, 10 Jun 2004 10:09:07 -0700 (PDT) +From: Stephan Szabo +To: Jean-Luc Lachance +Cc: Tom Lane , pgsql-performance@postgresql.org, + Frank van Vugt +Subject: Re: *very* inefficient choice made by the planner (regarding +In-Reply-To: <40C892BA.8080704@sympatico.ca> +Message-ID: <20040610100332.D20710@megazone.bigpanda.com> +References: <200406101624.21739.ftm.van.vugt@foxi.nl> + <40C881FE.5000301@sympatico.ca> + <25304.1086883145@sss.pgh.pa.us> <40C892BA.8080704@sympatico.ca> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/121 +X-Sequence-Number: 7179 + + +On Thu, 10 Jun 2004, Jean-Luc Lachance wrote: + +> I agree, but it should be a simple rewrite. No? + +It's NULLs inside the subselect that are the issue. + +select 1 in (select a from foo) +select exists ( select 1 from foo where a=1) + +If foo.a contains a row with NULL but no rows containing a 1, the above +give different results (unknown and exists) and IIRC, exists cannot +return unknown, so there's no simple rewrite of the subselect that gives +equivalent behavior. + + +From pgsql-performance-owner@postgresql.org Thu Jun 10 14:14:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 56C6BD1B379 + for ; + Thu, 10 Jun 2004 14:14: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 48005-02 + for ; + Thu, 10 Jun 2004 17:14:37 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 75033D1B1A1 + for ; + Thu, 10 Jun 2004 14:14:36 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 56BA73538C; Thu, 10 Jun 2004 10:14:36 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 5502935388; Thu, 10 Jun 2004 10:14:36 -0700 (PDT) +Date: Thu, 10 Jun 2004 10:14:36 -0700 (PDT) +From: Stephan Szabo +To: Jean-Luc Lachance +Cc: Tom Lane , pgsql-performance@postgresql.org, + Frank van Vugt +Subject: Re: *very* inefficient choice made by the planner (regarding +In-Reply-To: <20040610100332.D20710@megazone.bigpanda.com> +Message-ID: <20040610101410.X21002@megazone.bigpanda.com> +References: <200406101624.21739.ftm.van.vugt@foxi.nl> + <40C881FE.5000301@sympatico.ca> + <25304.1086883145@sss.pgh.pa.us> <40C892BA.8080704@sympatico.ca> + <20040610100332.D20710@megazone.bigpanda.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/122 +X-Sequence-Number: 7180 + + +On Thu, 10 Jun 2004, Stephan Szabo wrote: + +> +> On Thu, 10 Jun 2004, Jean-Luc Lachance wrote: +> +> > I agree, but it should be a simple rewrite. No? +> +> It's NULLs inside the subselect that are the issue. +> +> select 1 in (select a from foo) +> select exists ( select 1 from foo where a=1) +> +> If foo.a contains a row with NULL but no rows containing a 1, the above +> give different results (unknown and exists) and IIRC, exists cannot + +Erm that exists should have been false + +From pgsql-performance-owner@postgresql.org Fri Jun 11 08:17:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BC27CD1B18F + for ; + Fri, 11 Jun 2004 08:17: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 60555-01 + for ; + Fri, 11 Jun 2004 11:17:19 +0000 (GMT) +Received: from ns.trainorthornton.co.uk (ns.trainorthornton.co.uk + [194.216.113.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 57BFAD1B17B + for ; + Fri, 11 Jun 2004 08:17:15 -0300 (ADT) +Received: from monolith (host217-45-114-105.in-addr.btopenworld.com + [217.45.114.105]) + by ns.trainorthornton.co.uk (Postfix) with SMTP id E5F5215D888 + for ; + Fri, 11 Jun 2004 12:08:36 +0100 (BST) +Date: Fri, 11 Jun 2004 12:14:55 +0100 +From: Nick Trainor +Subject: ORDER BY user defined function performance issues +To: +Mime-Version: 1.0 +Organization: Trainor Thornton +X-Mailer: GoldMine [5.50.10424] +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable +Message-Id: <20040611110837.E5F5215D888@ns.trainorthornton.co.uk> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/123 +X-Sequence-Number: 7181 + +I have an application which logs interactions on a regular basis. The inte= +raction details (their types, etc) are held in one table (tblitem) and the = +'hits' are held in tbltotal. + +I have written a function to get the total 'hits' during a period and need = +to collect together the information from tblitem with it. + +The query works OK returning results in under a second: + +EXPLAIN ANALYSE SELECT t1.value1,t1.value2,getday_total('1','23',t1.id::int= +eger,'31','59','2','2004','182','153','6','2004','0') FROM tblitem t1 WHERE= + t1.type_id=3D23::int2 and (t1.id >=3D 1::int8 and t1.id<=3D9223372036854= +775807::int8) +OFFSET 0 LIMIT 20; +tracker-# QU= +ERY PLAN +---------------------------------------------------------------------------= +------------------------------------------------------------- + Limit (cost=3D0.00..7.70 rows=3D20 width=3D56) (actual time=3D19.50..846.= +89 rows=3D20 loops=3D1) + -> Index Scan using tblitemtype_id on tblitem t1 (cost=3D0.00..230.10 = +rows=3D598 width=3D56) (actual time=3D19.49..846.81 rows=3D21 loops=3D1) + Index Cond: (type_id =3D 23::smallint) + Filter: ((id >=3D 1::bigint) AND (id <=3D 9223372036854775807::big= +int)) + Total runtime: 847.04 msec + +---- +I realised that Postgresql did not like passing t1.id to the function witho= +ut some form of constraints - hence the (t1.id >=3D 1::int8 and t1.id<=3D92= +23372036854775807::int8) dummy constraints. +---- + + +However, when I seek to ORDER the results, then it takes 'forever': + +EXPLAIN ANALYSE SELECT t1.value1,t1.value2, +getday_total('1','23',t1.id::integer,'31','59','2','2004','182','153','6','= +2004','0') FROM tblitem t1 WHERE t1.type_id=3D23::int2 and (t1.id >=3D 1:= +:int8 and t1.id<=3D9223372036854775807::int8) +ORDER BY getday_total('1','23',t1.id::integer,'31','59','2','2004','182','1= +53','6','2004','0') DESC +OFFSET 0 LIMIT 20; + + +tracker-# tracker-# + = + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +------------------------------------------- + Limit (cost=3D257.66..257.71 rows=3D20 width=3D56) (actual time=3D25930.9= +0..25930.95 rows=3D20 loops=3D1) + -> Sort (cost=3D257.66..259.15 rows=3D598 width=3D56) (actual time=3D2= +5930.90..25930.91 rows=3D21 loops=3D1) + Sort Key: getday_total(1::smallint, 23::smallint, (id)::integer, 3= +1::smallint, 59::smallint, 2::smallint, 2004::smallint, 182::smallint, 153:= +:smallint, 6::smallint, 2004::smallint, 0) + -> Index Scan using tblitemtype_id on tblitem t1 (cost=3D0.00..2= +30.10 rows=3D598 width=3D56) (actual time=3D19.60..25927.68 rows=3D693 loop= +s=3D1) + Index Cond: (type_id =3D 23::smallint) + Filter: ((id >=3D 1::bigint) AND (id <=3D 922337203685477580= +7::bigint)) + Total runtime: 25931.15 msec + + +And this is a database of only a few thousand rows, we are anticipating tha= +t this database is going to get huge. + +What am I missing here? How can I get it to order by the total of interact= +ions without hitting the performance problem? + +Any help would be much appreciated. + +Nick + +nick A-T trainorthornton d-o-t co d-o-t uk + + + +Version: +PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.2 (Man= +drake Linux 9.1 3.2.2-3mdk) + +From pgsql-performance-owner@postgresql.org Fri Jun 11 10:41:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A845D1B1DC + for ; + Fri, 11 Jun 2004 10:41: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 17750-05 + for ; + Fri, 11 Jun 2004 13:41:18 +0000 (GMT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 360D3D1B1CB + for ; + Fri, 11 Jun 2004 10:41:11 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BYmHS-000DLR-0V; Fri, 11 Jun 2004 14:41:14 +0100 +Date: Fri, 11 Jun 2004 14:41:08 +0100 +From: Paul Thomas +To: Nick Trainor +Cc: "pgsql-performance @ postgresql . org" +Subject: Re: ORDER BY user defined function performance issues +Message-ID: <20040611144108.A28875@bacon> +References: <20040611110837.E5F5215D888@ns.trainorthornton.co.uk> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <20040611110837.E5F5215D888@ns.trainorthornton.co.uk>; + from nick.trainor@trainorthornton.co.uk on Fri, Jun 11, 2004 at + 12:14:55 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 35 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/124 +X-Sequence-Number: 7182 + + +On 11/06/2004 12:14 Nick Trainor wrote: +> [snip] +> However, when I seek to ORDER the results, then it takes 'forever': +> +> EXPLAIN ANALYSE SELECT t1.value1,t1.value2, +> getday_total('1','23',t1.id::integer,'31','59','2','2004','182','153','6','2004','0') +> FROM tblitem t1 WHERE t1.type_id=23::int2 and (t1.id >= 1::int8 and +> t1.id<=9223372036854775807::int8) +> ORDER BY +> getday_total('1','23',t1.id::integer,'31','59','2','2004','182','153','6','2004','0') +> DESC +> OFFSET 0 LIMIT 20; + +I expect that pg is having to evaluate your function every time it does a +compare within its sort. Something like +SELECT t1.value1,t1.value2, + getday_total(..) AS foo +FROM tblitem t1 WHERE t1.type_id=23::int2 and (t1.id >= 1::int8 and +t1.id<=9223372036854775807::int8) +ORDER BY foo + +might work. Otherwise try selecting into a temp table then doing the order +by on that table. + +HTH + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Fri Jun 11 10:55:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 324ABD1B1A1 + for ; + Fri, 11 Jun 2004 10:55: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 22232-06 + for ; + Fri, 11 Jun 2004 13:55:58 +0000 (GMT) +Received: from xtecnica.com (host154-218.pool80206.interbusiness.it + [80.206.218.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 55BA8D1B1B9 + for ; + Fri, 11 Jun 2004 10:55:50 -0300 (ADT) +Received: from DOMENICO2K by xtecnica.com (MDaemon.PRO.v7.1.0.R) + with ESMTP id md50000021078.msg + for ; Fri, 11 Jun 2004 15:53:59 +0200 +Message-ID: <003901c44fbb$a6f02090$70c8007e@xtecnica.it> +Reply-To: "Domenico Sgarbossa" +From: "Domenico Sgarbossa" +To: +Subject: Problems with vacuum! +Date: Fri, 11 Jun 2004 15:54:44 +0200 +Organization: XTECNICA srl +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0036_01C44FCC.6A2FB290" +X-Priority: 1 +X-MSMail-Priority: High +X-Mailer: Microsoft Outlook Express 5.50.4927.1200 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 +X-Authenticated-Sender: domenico@xtecnica.com +X-Spam-Processed: xtecnica.com, Fri, 11 Jun 2004 15:53:59 +0200 + (not processed: message from valid local sender) +X-MDRemoteIP: 126.0.200.112 +X-Return-Path: domenico@xtecnica.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: xtecnica.com, Fri, 11 Jun 2004 15:54:00 +0200 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.2 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_MESSAGE, X_MSMAIL_PRIORITY_HIGH, X_PRIORITY_HIGH +X-Spam-Level: * +X-Archive-Number: 200406/125 +X-Sequence-Number: 7183 + +This is a multi-part message in MIME format. + + + +------=_NextPart_000_0036_01C44FCC.6A2FB290 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +I'm running postgrSQL 7.2 on a linux Red Hat 8.0 box with 2GB of RAM=20 +When I boot-up the system , this is the TOP situation: + +11:59am up 4 min, 1 user, load average: 0.37, 0.26, 0.11 + +77 processes: 74 sleeping, 3 running, 0 zombie, 0 stopped + +CPU states: 0.3% user, 0.7% system, 0.0% nice, 98.8% idle + +Mem: 1031020K av, 177808K used, 853212K free, 0K shrd, 14744K bu= +ff + +Swap: 2096472K av, 0K used, 2096472K free 67828K ca= +ched + +After I've done a vacuum , the situation is: + +=20 + 12:04pm up 8 min, 1 user, load average: 0.22, 0.23, 0.12 + +78 processes: 76 sleeping, 2 running, 0 zombie, 0 stopped + +CPU states: 2.5% user, 1.9% system, 0.0% nice, 95.4% idle + +Mem: 1031020K av, 1016580K used, 14440K free, 0K shrd, 18624K bu= +ff + +Swap: 2096472K av, 0K used, 2096472K free 833896K ca= +ched + +As you see the memory used by vacuum isn't released anymore? Anyone know wh= +y? + +My statement is: vacuumdb --analyze dbname +My pg paramaters on postgresql.conf are: + +# +# Shared Memory Size +# +shared_buffers =3D 2048 # 2*max_connections, min 16 +max_fsm_relations =3D 100 # min 10, fsm is free space map +max_fsm_pages =3D 10000 # min 1000, fsm is free space map +max_locks_per_transaction =3D 64 # min 10 +wal_buffers =3D 8 # min 4 + +# +# Non-shared Memory Sizes +# +sort_mem =3D 512 # min 32 +vacuum_mem =3D 8192 # min 1024 + +Did anyone know why this happend?=20 + +Distinti Saluti + +Sgarbossa Domenico +X Tecnica S.R.L. +www.xtecnica.com +Tel: 049/9409154 - 049/5970297 +Fax: 049/9400288 + + +------=_NextPart_000_0036_01C44FCC.6A2FB290 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
I'm running postgrSQL 7.2 on a linux Red H= +at 8.0=20 +box with 2GB of RAM
+
When I boot-up the system , this is the TO= +P=20 +situation:
+
+

11:59am  up 4 min,  1 user,  load average: 0.37, 0.26,=20 +0.11

+

77 processes= +: 74=20 +sleeping, 3 running, 0 zombie, 0 stopped

+

CPU states:<= +SPAN=20 +style=3D"mso-spacerun: yes">  0.3% user,  0.7% system,  0.0% nice, 98.8%=20 +idle

+

Mem:  1031020K av,  177808K used,  853212K free,       0K= +=20 +shrd,   14744K=20 +buff

+

Swap: 209647= +2K=20 +av,      = +=20 +0K used, 2096472K free        = +;          =20 +67828K cached

+
After I've done a vacuum , the situation= +=20 +is:
+
 
+
&n= +bsp; +

 12:04pm  up 8 min,  1 user,  load average: 0.22, 0.23,=20 +0.12

+

78 processes= +: 76=20 +sleeping, 2 running, 0 zombie, 0 stopped

+

CPU states:<= +SPAN=20 +style=3D"mso-spacerun: yes">  2.5% user,  1.9% system,  0.0% nice, 95.4%=20 +idle

+

Mem:  1031020K av, 1016580K used,   14440K free,       0K= +=20 +shrd,   18624K=20 +buff

+

Swap: 209647= +2K=20 +av,      = +=20 +0K used, 2096472K free        = +;         =20 +833896K cached

+
As you see the memory used by vacuum isn't released anymore? Anyone kn= +ow=20 +why?
+
 
+
My statement is: vacuumdb --analyze dbname
+
My pg paramaters on postgresql.conf are:
+
 
+
#
#       Shared Memory=20 +Size
#
shared_buffers =3D 2048      &nb= +sp; #=20 +2*max_connections, min 16
max_fsm_relations =3D 100    # = +min 10,=20 +fsm is free space map
max_fsm_pages =3D 10000    &nb= +sp; #=20 +min 1000, fsm is free space map
max_locks_per_transaction =3D 64 # min= +=20 +10
wal_buffers =3D=20 +8            # min= +=20 +4
+
 
+
#
#       Non-shared Memory=20 +Sizes
#
sort_mem =3D=20 +512            = + #=20 +min 32
vacuum_mem =3D=20 +8192          # min 1024
+
Did anyone know why this happend?
+

Distinti Saluti
+
 
+
Sgarbossa Domenico
X Tecnica S.R.L.
= +www.xtecnica.com
Tel: 049/9409154 -= +=20 +049/5970297
Fax: 049/9400288
+ +------=_NextPart_000_0036_01C44FCC.6A2FB290-- + + +From pgsql-performance-owner@postgresql.org Fri Jun 11 11:40:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B738D1B1A1 + for ; + Fri, 11 Jun 2004 11: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 52277-05 + for ; + Fri, 11 Jun 2004 14:40:08 +0000 (GMT) +Received: from mail.astudios.com (unknown [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 9024BD1B169 + for ; + Fri, 11 Jun 2004 11:39:59 -0300 (ADT) +thread-index: AcRPwplQC8MaU931TJOaNVqM6SmWlA== +Received: from [10.4.2.252] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 11 Jun 2004 10:44:28 -0400 +Message-ID: <40C9C43F.2060402@sermonaudio.com> +Content-Class: urn:content-classes:message +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.132 +Date: Fri, 11 Jun 2004 10:39:59 -0400 +From: "Chris Hoover" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7) Gecko/20040514 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Domenico Sgarbossa" +Cc: +Subject: Re: Problems with vacuum! +References: <003901c44fbb$a6f02090$70c8007e@xtecnica.it> +In-Reply-To: <003901c44fbb$a6f02090$70c8007e@xtecnica.it> +Content-Type: text/plain; + charset="ISO-8859-1"; + format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 11 Jun 2004 14:44:28.0421 (UTC) + FILETIME=[991BEB50:01C44FC2] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/126 +X-Sequence-Number: 7184 + +Domenico Sgarbossa wrote: + +> I'm running postgrSQL 7.2 on a linux Red Hat 8.0 box with 2GB of RAM +> When I boot-up the system , this is the TOP situation: +> +> 11:59am up 4 min, 1 user, load average: 0.37, 0.26, 0.11 +> +> 77 processes: 74 sleeping, 3 running, 0 zombie, 0 stopped +> +> CPU states: 0.3% user, 0.7% system, 0.0% nice, 98.8% idle +> +> Mem: 1031020K av, 177808K used, 853212K free, 0K shrd, +> 14744K buff +> +> Swap: 2096472K av, 0K used, 2096472K free +> 67828K cached +> +> After I've done a vacuum , the situation is: +> +> +> +> 12:04pm up 8 min, 1 user, load average: 0.22, 0.23, 0.12 +> +> 78 processes: 76 sleeping, 2 running, 0 zombie, 0 stopped +> +> CPU states: 2.5% user, 1.9% system, 0.0% nice, 95.4% idle +> +> Mem: 1031020K av, 1016580K used, 14440K free, 0K shrd, +> 18624K buff +> +> Swap: 2096472K av, 0K used, 2096472K free +> 833896K cached +> +> As you see the memory used by vacuum isn't released anymore? Anyone +> know why? +> +> My statement is: vacuumdb --analyze dbname +> My pg paramaters on postgresql.conf are: +> +> # +> # Shared Memory Size +> # +> shared_buffers = 2048 # 2*max_connections, min 16 +> max_fsm_relations = 100 # min 10, fsm is free space map +> max_fsm_pages = 10000 # min 1000, fsm is free space map +> max_locks_per_transaction = 64 # min 10 +> wal_buffers = 8 # min 4 +> +> # +> # Non-shared Memory Sizes +> # +> sort_mem = 512 # min 32 +> vacuum_mem = 8192 # min 1024 +> Did anyone know why this happend? +> +> Distinti Saluti +> +> Sgarbossa Domenico +> X Tecnica S.R.L. +> www.xtecnica.com +> Tel: 049/9409154 - 049/5970297 +> Fax: 049/9400288 + +Your vacuum memory was released. However, the linux kernel likes to +keep most memory in the cached buffer instead of totally freeing it. +The guru's behind the kernel figured out they get better performance +this way. + +HTH, + +Chris + + +From pgsql-performance-owner@postgresql.org Fri Jun 11 11:54:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 83382D1B169 + for ; + Fri, 11 Jun 2004 11:54: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 52888-10 + for ; + Fri, 11 Jun 2004 14:54:28 +0000 (GMT) +Received: from xtecnica.com (host154-218.pool80206.interbusiness.it + [80.206.218.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BFE2D1B18F + for ; + Fri, 11 Jun 2004 11:54:23 -0300 (ADT) +Received: from DOMENICO2K by xtecnica.com (MDaemon.PRO.v7.1.0.R) + with ESMTP id md50000021096.msg + for ; Fri, 11 Jun 2004 16:52:34 +0200 +Message-ID: <004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> +Reply-To: "Domenico Sgarbossa" +From: "Domenico Sgarbossa" +To: "Rosser Schwarz" , + +References: <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com> +Subject: Re: [BULK] Problems with vacuum! +Date: Fri, 11 Jun 2004 16:53:22 +0200 +Organization: XTECNICA srl +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 1 +X-MSMail-Priority: High +X-Mailer: Microsoft Outlook Express 5.50.4927.1200 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 +X-Authenticated-Sender: domenico@xtecnica.com +X-Spam-Processed: xtecnica.com, Fri, 11 Jun 2004 16:52:34 +0200 + (not processed: message from valid local sender) +X-MDRemoteIP: 126.0.200.112 +X-Return-Path: domenico@xtecnica.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: xtecnica.com, Fri, 11 Jun 2004 16:52:35 +0200 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 + tests=X_MSMAIL_PRIORITY_HIGH, X_PRIORITY_HIGH +X-Spam-Level: * +X-Archive-Number: 200406/127 +X-Sequence-Number: 7185 + +Thanks for your advice! + +As I immagine the system released dinamically the shared memory .... the +problem is that +when , after vacuum, users runs my application (ERP) and the system swap on +disk so the global performance +decrease very fast until the system is so slow that I need to reboot the +server. + +It seems that the cached memory isn't released by the system... so the +system begin to swap to disk! +The swap problem is very important, it makes useless run vacuum 'cause after +vacuum the system +begin to swap.... so my application runs very slow! + +Could you explain me better your final advice please? + +> Watching this "cached" value over normal usage of your machine to get +> a running average is how you come up with your effective_cache_size +> configuration directive. + +what does this mean pratically? + +thanks! + +Distinti Saluti + +Sgarbossa Domenico +X Tecnica S.R.L. +www.xtecnica.com +Tel: 049/9409154 - 049/5970297 +Fax: 049/9400288 + +----- Original Message ----- +From: "Rosser Schwarz" +To: "'Domenico Sgarbossa'" ; + +Sent: Friday, June 11, 2004 4:09 PM +Subject: RE: [BULK] [PERFORM] Problems with vacuum! + + +> while you weren't looking, Domenico Sgarbossa wrote: +> +> Compare the "cached" values in each run of top. +> +> Before: 67828K cached +> +> After: 833896K cached +> +> The kernel is caching your tables for you. That memory isn't actually +> being -used-, in the active, "a process has claimed this memory" sense. +> If a process comes along that needs more memory than free, the kernel +> will flush some of those cached pages (to swap?) to make room for +> whatever the memory requirements of the newcomer are. +> +> Watching this "cached" value over normal usage of your machine to get +> a running average is how you come up with your effective_cache_size +> configuration directive. +> +> /rls +> +> -- +> Rosser Schwarz +> Total Card, Inc. +> +> +> + + + + +From pgsql-performance-owner@postgresql.org Fri Jun 11 12:03:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EC7ED1B1CB + for ; + Fri, 11 Jun 2004 12: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 61164-08 + for ; + Fri, 11 Jun 2004 15:03:54 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id A959ED1B1A1 + for ; + Fri, 11 Jun 2004 12:03:53 -0300 (ADT) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1BYnZP-0000mO-00 + for ; Fri, 11 Jun 2004 17:03:51 +0200 +Received: from sp-260-1.net4.netcentrix.net ([4.21.254.118]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Fri, 11 Jun 2004 17:03:51 +0200 +Received: from doug by sp-260-1.net4.netcentrix.net with local (Gmexim 0.1 + (Debian)) id 1AlnuQ-0007hv-00 + for ; Fri, 11 Jun 2004 17:03:51 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Doug McNaught +Subject: Re: [BULK] Problems with vacuum! +Date: Fri, 11 Jun 2004 11:03:48 -0400 +Lines: 14 +Message-ID: <87pt8616i3.fsf@asmodeus.mcnaught.org> +References: <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com> + <004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: sp-260-1.net4.netcentrix.net +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +Cancel-Lock: sha1:y4KkfkG8JUBSW+SnmQbUzOZ/omQ= +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/128 +X-Sequence-Number: 7186 + +"Domenico Sgarbossa" writes: + +> Thanks for your advice! +> +> It seems that the cached memory isn't released by the system... so the +> system begin to swap to disk! + +If you really think this is true, there should be a process that is +holding on to the memory. Use 'ps' to find that process. + +I also noticed that your shared_buffers setting seemed a bit low--you +might want to increase it. + +-Doug + + +From pgsql-performance-owner@postgresql.org Fri Jun 11 12:11:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0214DD1B20E + for ; + Fri, 11 Jun 2004 12:11: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 69994-06 + for ; + Fri, 11 Jun 2004 15:11:50 +0000 (GMT) +Received: from web13121.mail.yahoo.com (web13121.mail.yahoo.com + [216.136.174.83]) + by svr1.postgresql.org (Postfix) with SMTP id 54833D1B169 + for ; + Fri, 11 Jun 2004 12:11:49 -0300 (ADT) +Message-ID: <20040611151148.57555.qmail@web13121.mail.yahoo.com> +Received: from [63.78.248.48] by web13121.mail.yahoo.com via HTTP; + Fri, 11 Jun 2004 08:11:48 PDT +Date: Fri, 11 Jun 2004 08:11:48 -0700 (PDT) +From: Litao Wu +Subject: Re: reindex and copy - deadlock? +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4464.1086717068@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/129 +X-Sequence-Number: 7187 + +Hi Tom, + +Here is gdb info. + +This happens in our production database +3 times this week. It's totally unacceptable. +I have written a drop/create script to +avoid reindex. However, drop/create +seems to me take more time than reindex +for the whole database. + +Your help is greatly appreciated! + +Version: +PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC +2.96 + + +=========================================== +su - postgres +ps -auxww|grep REINDEX +postgres 18903 1.2 8.1 195388 169512 ? S +04:49 1:54 postgres:postgres db1 [local] REINDEX +postgres 13329 0.0 0.0 1768 620 pts/0 S +07:23 0:00 grep REINDEX +gdb /bin/postgres +GNU gdb Red Hat Linux (5.2-2) +Copyright 2002 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General +Public License, and you are +welcome to change it and/or distribute copies of it +under certain +conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show +warranty" for details. +This GDB was configured as "i386-redhat-linux"...(no +debugging symbols +found)... +(gdb) attach 18903 +Attaching to program: /bin/postgres, process 18903 +Reading symbols from /usr/lib/libz.so.1...(no +debugging symbols +found)...done. +Loaded symbols for /usr/lib/libz.so.1 +Reading symbols from /usr/lib/libreadline.so.4...(no +debugging symbols +found)...done. +Loaded symbols for /usr/lib/libreadline.so.4 +Reading symbols from /lib/libtermcap.so.2...(no +debugging symbols +found)...done. +Loaded symbols for /lib/libtermcap.so.2 +Reading symbols from /lib/libcrypt.so.1...(no +debugging symbols +found)...done. +Loaded symbols for /lib/libcrypt.so.1 +Reading symbols from /lib/libresolv.so.2...(no +debugging symbols +found)...done. +Loaded symbols for /lib/libresolv.so.2 +Reading symbols from /lib/libnsl.so.1...(no debugging +symbols found)...done. +Loaded symbols for /lib/libnsl.so.1 +Reading symbols from /lib/libdl.so.2...(no debugging +symbols found)...done. +Loaded symbols for /lib/libdl.so.2 +Reading symbols from /lib/i686/libm.so.6...(no +debugging symbols +found)...done. +Loaded symbols for /lib/i686/libm.so.6 +Reading symbols from /lib/i686/libc.so.6...(no +debugging symbols +found)...done. +Loaded symbols for /lib/i686/libc.so.6 +Reading symbols from /lib/ld-linux.so.2...(no +debugging symbols +found)...done. +Loaded symbols for /lib/ld-linux.so.2 +Reading symbols from /lib/libnss_files.so.2...(no +debugging symbols +found)...done. +Loaded symbols for /lib/libnss_files.so.2 +0x420e8bb2 in semop () from /lib/i686/libc.so.6 +(gdb) bt +#0 0x420e8bb2 in semop () from /lib/i686/libc.so.6 +#1 0x080ffa28 in PGSemaphoreLock () +#2 0x08116432 in LWLockAcquire () +#3 0x0810f572 in LockBuffer () +#4 0x0807dea3 in _bt_getbuf () +#5 0x080813ec in _bt_leafbuild () +#6 0x080816a6 in _bt_leafbuild () +#7 0x08081b8b in _bt_leafbuild () +#8 0x080813cc in _bt_leafbuild () +#9 0x0807e1d0 in btbuild () +#10 0x081631c3 in OidFunctionCall3 () +#11 0x080920a7 in index_build () +#12 0x08092593 in reindex_index () +#13 0x08092473 in IndexBuildHeapScan () +#14 0x0809275d in reindex_relation () +#15 0x080b9164 in ReindexTable () +#16 0x08118ece in pg_exec_query_string () +#17 0x08119fe5 in PostgresMain () +#18 0x0810214c in ClosePostmasterPorts () +#19 0x08101a9e in ClosePostmasterPorts () +#20 0x08100ca1 in PostmasterMain () +#21 0x08100862 in PostmasterMain () +#22 0x080deed7 in main () +#23 0x42017589 in __libc_start_main () from +/lib/i686/libc.so.6 +(gdb) quit +The program is running. Quit anyway (and detach it)? +(y or n) y +Detaching from program: /bin/postgres, process 18903 + +--- Tom Lane wrote: +> Litao Wu writes: +> > I will use gdb next time. What's this right way to +> > get info as postgres owner? +> +> $ gdb /path/to/postgres +> gdb> attach PID-of-backend-process +> gdb> bt +> gdb> quit +> +> You might try this for practice on any idle backend; +> it shouldn't affect +> the state of the backend, except for freezing it +> while you issue the +> commands. +> +> If "bt" gives you just a list of numbers and no +> symbolic information, +> then it won't be much help; you'll need to rebuild +> the backend with +> debugging information so that we can make some sense +> of the trace. +> +> regards, tom lane + + + + + +__________________________________ +Do you Yahoo!? +Friends. Fun. Try the all-new Yahoo! Messenger. +http://messenger.yahoo.com/ + +From pgsql-performance-owner@postgresql.org Fri Jun 11 13:05:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 24013D1B182 + for ; + Fri, 11 Jun 2004 13:05: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 95193-06 + for ; + Fri, 11 Jun 2004 16:05: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 E9567D1B1B3 + for ; + Fri, 11 Jun 2004 13:05:20 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5BG5KlD012458; + Fri, 11 Jun 2004 12:05:20 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: reindex and copy - deadlock? +In-reply-to: <20040611151148.57555.qmail@web13121.mail.yahoo.com> +References: <20040611151148.57555.qmail@web13121.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Fri, 11 Jun 2004 08:11:48 -0700" +Date: Fri, 11 Jun 2004 12:05:20 -0400 +Message-ID: <12457.1086969920@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/130 +X-Sequence-Number: 7188 + +Litao Wu writes: +> (gdb) bt +> #0 0x420e8bb2 in semop () from /lib/i686/libc.so.6 +> #1 0x080ffa28 in PGSemaphoreLock () +> #2 0x08116432 in LWLockAcquire () +> #3 0x0810f572 in LockBuffer () +> #4 0x0807dea3 in _bt_getbuf () +> #5 0x080813ec in _bt_leafbuild () +> #6 0x080816a6 in _bt_leafbuild () +> #7 0x08081b8b in _bt_leafbuild () +> #8 0x080813cc in _bt_leafbuild () +> #9 0x0807e1d0 in btbuild () +> #10 0x081631c3 in OidFunctionCall3 () +> #11 0x080920a7 in index_build () +> #12 0x08092593 in reindex_index () + +Hmm. I don't think I believe this backtrace. It's obviously wrong at +lines 5-7 - _bt_leafbuild doesn't call itself nor call _bt_getbuf. +It's possible that you don't have any local symbols in this executable +and what we're seeing is the nearest global symbol, so let's ignore +that; but if we take lines 0-4 at face value, what it says is that the +REINDEX is stuck waiting for buffer lock on a buffer for a new empty +page it has just added to the new index. This is flatly impossible. +There is no other process that could possibly be interested in that +buffer, or for that matter even be able to name it (since the new index +has a new relfilenode value that isn't even visible to any other process +yet). I thought for a little bit that a background CHECKPOINT might be +trying to write out the new buffer, but that theory holds no water +either, because at this point in the _bt_getbuf sequence, the buffer is +not marked dirty (I just verified this by stepping through it in 7.4.2). + +I can think of lots of reasons why the REINDEX might block at the +previous step of the sequence, namely acquiring a fresh buffer ... but +once it's got the buffer there is surely no reason to block. + +What I'm inclined to think is that the backtrace isn't right at all. +Would it be possible for you to install a backend built with +--enable-debug and get a more reliable backtrace? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 11 15:01:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F267ED1B25F + for ; + Fri, 11 Jun 2004 15: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 37859-10 + for ; + Fri, 11 Jun 2004 18:00:16 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D78CCD1B1BB + for ; + Fri, 11 Jun 2004 14:59:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5BHxgMe016730; + Fri, 11 Jun 2004 13:59:43 -0400 (EDT) +To: Nick Trainor +Cc: pgsql-performance@postgresql.org +Subject: Re: ORDER BY user defined function performance issues +In-reply-to: <20040611110837.E5F5215D888@ns.trainorthornton.co.uk> +References: <20040611110837.E5F5215D888@ns.trainorthornton.co.uk> +Comments: In-reply-to Nick Trainor + message dated "Fri, 11 Jun 2004 12:14:55 +0100" +Date: Fri, 11 Jun 2004 13:59:42 -0400 +Message-ID: <16729.1086976782@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/131 +X-Sequence-Number: 7189 + +Nick Trainor writes: +> What am I missing here? + +The ORDER BY query has to evaluate the function at *every* row of the +table before it can sort. The other query was only evaluating the +function at twenty rows. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 11 15:40:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FE58D1B1DC + for ; + Fri, 11 Jun 2004 15:40: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 63281-09 + for ; + Fri, 11 Jun 2004 18:40:02 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 92BA5D1B187 + for ; + Fri, 11 Jun 2004 15:39:59 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: in-transaction insert performance in 7.5devel +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Fri, 11 Jun 2004 14:40:00 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AE59@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: in-transaction insert performance in 7.5devel +Thread-Index: AcRP44A2bpd15X1GRViyyRjwDPd8gw== +From: "Merlin Moncure" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/132 +X-Sequence-Number: 7190 + +I am batch inserting insert statements into a database with fsync =3D on. +My single disk system is on a 10k drive...even though I am inside a +transaction there is at least 1 file sync per row insert.=20=20 + +Is this normal? On my hardware, which is pretty quick, I am limited to +about 50 inserts/sec. If I operate outside of a transaction, the number +is closer to 30. With fsync off, I can hit over 1000. + +IIRC in previous versions insert performance was a lot faster when in +transaction, is that the case? + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Jun 11 15:55:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3948D1B18A + for ; + Fri, 11 Jun 2004 15:55: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 68335-05 + for ; + Fri, 11 Jun 2004 18:55:04 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DC54CD1B187 + for ; + Fri, 11 Jun 2004 15:55:01 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 0ABCC76A56; Fri, 11 Jun 2004 14:55:06 -0400 (EDT) +Subject: Re: in-transaction insert performance in 7.5devel +From: Rod Taylor +To: Merlin Moncure +Cc: Postgresql Performance +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AE59@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AE59@Herge.rcsinc.local> +Content-Type: text/plain +Message-Id: <1086980100.2539.187.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Fri, 11 Jun 2004 14:55:01 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/133 +X-Sequence-Number: 7191 + +On Fri, 2004-06-11 at 14:40, Merlin Moncure wrote: +> I am batch inserting insert statements into a database with fsync = on. +> My single disk system is on a 10k drive...even though I am inside a +> transaction there is at least 1 file sync per row insert. + +Which filesystem? + +PostgreSQL isn't issuing the sync except at commit of a transaction, but +some filesystems do wacky things if you ask them too. + + + +From pgsql-performance-owner@postgresql.org Fri Jun 11 16:04:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DADD6D1B1B4 + for ; + Fri, 11 Jun 2004 16:04: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 72797-06 + for ; + Fri, 11 Jun 2004 19:04:05 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 75F29D1B1A5 + for ; + Fri, 11 Jun 2004 16:04:02 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: in-transaction insert performance in 7.5devel +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Fri, 11 Jun 2004 15:04:03 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AE5A@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] in-transaction insert performance in 7.5devel +Thread-Index: AcRP5ZqqvykQtm5UTY+7D3/n6vA1wAAAA8Dg +From: "Merlin Moncure" +To: "Rod Taylor" +Cc: "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/134 +X-Sequence-Number: 7192 + +Rod Taylor wrote: +> On Fri, 2004-06-11 at 14:40, Merlin Moncure wrote: +> > I am batch inserting insert statements into a database with fsync =3D +on. +> > My single disk system is on a 10k drive...even though I am inside a +> > transaction there is at least 1 file sync per row insert. +>=20 +> Which filesystem? +>=20 +> PostgreSQL isn't issuing the sync except at commit of a transaction, +but +> some filesystems do wacky things if you ask them too. + +Um, NTFS. :) I'm playing with the new 'syncer' to get a feel for the +new performance considerations. + +As I understand it, sync() is never called anymore. mdsync() hits the +all the files 1 by 1 with an fsync. My understanding of the commit +process is that 30 tps is quite reasonable for my hardware.=20=20 + +What surprised was that I am getting at least 1 seek/insert inside a +transaction.=20=20 + +Merlin=20 + +From pgsql-performance-owner@postgresql.org Fri Jun 11 16:27:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 00387D1B179 + for ; + Fri, 11 Jun 2004 16:27: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 76050-08 + for ; + Fri, 11 Jun 2004 19:27:02 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D825D1B17B + for ; + Fri, 11 Jun 2004 16:27:00 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 40A4E76B2B; Fri, 11 Jun 2004 15:27:05 -0400 (EDT) +Subject: Re: in-transaction insert performance in 7.5devel +From: Rod Taylor +To: Merlin Moncure +Cc: Postgresql Performance +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AE5A@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AE5A@Herge.rcsinc.local> +Content-Type: text/plain +Message-Id: <1086982020.2539.189.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Fri, 11 Jun 2004 15:27:01 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/135 +X-Sequence-Number: 7193 + +> As I understand it, sync() is never called anymore. mdsync() hits the +> all the files 1 by 1 with an fsync. My understanding of the commit +> process is that 30 tps is quite reasonable for my hardware. + +Sorry. I didn't see the version in the subject and assumed 7.4 on a +Linux machine with excessive journaling enabled. + + +From pgsql-performance-owner@postgresql.org Fri Jun 11 16:35:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9274CD1B348 + for ; + Fri, 11 Jun 2004 16:35: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 86325-06 + for ; + Fri, 11 Jun 2004 19:35:25 +0000 (GMT) +Received: from web13125.mail.yahoo.com (web13125.mail.yahoo.com + [216.136.174.143]) + by svr1.postgresql.org (Postfix) with SMTP id 64C83D1B33F + for ; + Fri, 11 Jun 2004 16:35:22 -0300 (ADT) +Message-ID: <20040611193523.15778.qmail@web13125.mail.yahoo.com> +Received: from [63.78.248.48] by web13125.mail.yahoo.com via HTTP; + Fri, 11 Jun 2004 12:35:23 PDT +Date: Fri, 11 Jun 2004 12:35:23 -0700 (PDT) +From: Litao Wu +Subject: Re: reindex and copy - deadlock? +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <12457.1086969920@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/136 +X-Sequence-Number: 7194 + +We have another production database, +which is similar with this one. +It has never had REINDEX block problem yet. +One difference between these two databases +is the one having REINDEX problem is using +NTFS file system. + +Is it possible the root of problem? + +Thanks, + +--- Tom Lane wrote: +> Litao Wu writes: +> > (gdb) bt +> > #0 0x420e8bb2 in semop () from +> /lib/i686/libc.so.6 +> > #1 0x080ffa28 in PGSemaphoreLock () +> > #2 0x08116432 in LWLockAcquire () +> > #3 0x0810f572 in LockBuffer () +> > #4 0x0807dea3 in _bt_getbuf () +> > #5 0x080813ec in _bt_leafbuild () +> > #6 0x080816a6 in _bt_leafbuild () +> > #7 0x08081b8b in _bt_leafbuild () +> > #8 0x080813cc in _bt_leafbuild () +> > #9 0x0807e1d0 in btbuild () +> > #10 0x081631c3 in OidFunctionCall3 () +> > #11 0x080920a7 in index_build () +> > #12 0x08092593 in reindex_index () +> +> Hmm. I don't think I believe this backtrace. It's +> obviously wrong at +> lines 5-7 - _bt_leafbuild doesn't call itself nor +> call _bt_getbuf. +> It's possible that you don't have any local symbols +> in this executable +> and what we're seeing is the nearest global symbol, +> so let's ignore +> that; but if we take lines 0-4 at face value, what +> it says is that the +> REINDEX is stuck waiting for buffer lock on a buffer +> for a new empty +> page it has just added to the new index. This is +> flatly impossible. +> There is no other process that could possibly be +> interested in that +> buffer, or for that matter even be able to name it +> (since the new index +> has a new relfilenode value that isn't even visible +> to any other process +> yet). I thought for a little bit that a background +> CHECKPOINT might be +> trying to write out the new buffer, but that theory +> holds no water +> either, because at this point in the _bt_getbuf +> sequence, the buffer is +> not marked dirty (I just verified this by stepping +> through it in 7.4.2). +> +> I can think of lots of reasons why the REINDEX might +> block at the +> previous step of the sequence, namely acquiring a +> fresh buffer ... but +> once it's got the buffer there is surely no reason +> to block. +> +> What I'm inclined to think is that the backtrace +> isn't right at all. +> Would it be possible for you to install a backend +> built with +> --enable-debug and get a more reliable backtrace? +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to +majordomo@postgresql.org + + + + + +__________________________________ +Do you Yahoo!? +Friends. Fun. Try the all-new Yahoo! Messenger. +http://messenger.yahoo.com/ + +From pgsql-performance-owner@postgresql.org Fri Jun 11 16:52:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B318CD1B17B + for ; + Fri, 11 Jun 2004 16:52: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 00762-01 + for ; + Fri, 11 Jun 2004 19:52: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 F05A1D1B23C + for ; + Fri, 11 Jun 2004 16:52:09 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5BJqAFh017839; + Fri, 11 Jun 2004 15:52:10 -0400 (EDT) +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org +Subject: Re: in-transaction insert performance in 7.5devel +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AE59@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AE59@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Fri, 11 Jun 2004 14:40:00 -0400" +Date: Fri, 11 Jun 2004 15:52:10 -0400 +Message-ID: <17838.1086983530@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/137 +X-Sequence-Number: 7195 + +"Merlin Moncure" writes: +> I am batch inserting insert statements into a database with fsync = on. +> My single disk system is on a 10k drive...even though I am inside a +> transaction there is at least 1 file sync per row insert. + +Are you certain you're inside a transaction? + +Tracing a process doing simple inserts within a transaction block, +I don't see the process doing any I/O at all, just send/recv. The +background writer process is doing the work, but it shouldn't block +the inserter. + +[ thinks for a bit... ] Hmm. I see that XLogFlush for a buffer's LSN +is done while holding share lock on the buffer (see FlushBuffer in +bufmgr.c). This would mean that anyone trying to acquire exclusive lock +on the buffer would have to wait for WAL fsync. In a situation where +you were repeatedly inserting into the same table, it's somewhat likely +that the inserter would block this way while the bgwriter is trying to +flush a previous update of the same page. But that shouldn't happen for +*every* insert; it could happen at most once every bgwriter_delay msec. + +Does it help if you change FlushBuffer to release buffer lock while +flushing xlog? + + + /* + * Protect buffer content against concurrent update. (Note that + * hint-bit updates can still occur while the write is in progress, + * but we assume that that will not invalidate the data written.) + */ + LockBuffer(buffer, BUFFER_LOCK_SHARE); + + /* + * Force XLOG flush for buffer' LSN. This implements the basic WAL + * rule that log updates must hit disk before any of the data-file + * changes they describe do. + */ + recptr = BufferGetLSN(buf); + ++ LockBuffer(buffer, BUFFER_LOCK_UNLOCK); + + XLogFlush(recptr); + ++ LockBuffer(buffer, BUFFER_LOCK_SHARE); + + +(This is not a committable change because it breaks the WAL guarantee; +to do this we'd have to loop until the LSN doesn't change during flush, +and I'm not sure that's a good idea. But you can do it for testing +purposes just to see if this is where the performance issue is or not.) + +Prior versions hold this lock during flush as well, but it's less likely +that the same page an active process is interested in is being written +out, since before the bgwriter only the least-recently-used page would +be a candidate for writing. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 11 17:28:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 939ADD1B169 + for ; + Fri, 11 Jun 2004 17:28: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 14607-02 + for ; + Fri, 11 Jun 2004 20:27:54 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A4DED1B1CB + for ; + Fri, 11 Jun 2004 17:27:51 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5BKRr1M018173; + Fri, 11 Jun 2004 16:27:53 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: reindex and copy - deadlock? +In-reply-to: <20040611193523.15778.qmail@web13125.mail.yahoo.com> +References: <20040611193523.15778.qmail@web13125.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Fri, 11 Jun 2004 12:35:23 -0700" +Date: Fri, 11 Jun 2004 16:27:53 -0400 +Message-ID: <18172.1086985673@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/138 +X-Sequence-Number: 7196 + +Litao Wu writes: +> One difference between these two databases +> is the one having REINDEX problem is using +> NTFS file system. + +Oh? That's interesting. + +> Is it possible the root of problem? + +I would not expect it to show this particular symptom --- if the +backtrace is accurate. But there are nearby places that might have +FS-dependent behavior. Can you do anything about my request for +a stack trace from a debug-enabled build? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 11 18:04:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 86E8DD1B19C + for ; + Fri, 11 Jun 2004 18: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 30898-01 + for ; + Fri, 11 Jun 2004 21:04:45 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EB3FD1B187 + for ; + Fri, 11 Jun 2004 18:04:42 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: in-transaction insert performance in 7.5devel +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Fri, 11 Jun 2004 17:04:44 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AE5B@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] in-transaction insert performance in 7.5devel +Thread-Index: AcRP7ZcyLj83LmHTQ8aILxe7JdwskAACQIPA +From: "Merlin Moncure" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/139 +X-Sequence-Number: 7197 + + +Tom Lane wrote: +> "Merlin Moncure" writes: +> > I am batch inserting insert statements into a database with fsync =3D +on. +> > My single disk system is on a 10k drive...even though I am inside a +> > transaction there is at least 1 file sync per row insert. +>=20 +> Are you certain you're inside a transaction? +>=20 +> Tracing a process doing simple inserts within a transaction block, +> I don't see the process doing any I/O at all, just send/recv. The +> background writer process is doing the work, but it shouldn't block +> the inserter. +>=20 +> [ thinks for a bit... ] Hmm. I see that XLogFlush for a buffer's LSN +> is done while holding share lock on the buffer (see FlushBuffer in +> bufmgr.c). This would mean that anyone trying to acquire exclusive +lock +> on the buffer would have to wait for WAL fsync. In a situation where +> you were repeatedly inserting into the same table, it's somewhat +likely +> that the inserter would block this way while the bgwriter is trying to +> flush a previous update of the same page. But that shouldn't happen +for +> *every* insert; it could happen at most once every bgwriter_delay +msec. +>=20 +> Does it help if you change FlushBuffer to release buffer lock while +> flushing xlog? + +Putting your change in resulted in about a 15% increase in insert +performance. There may be some quirky things going on here with NTFS... + +I did an update clean from cvs and I noticed big speedup across the +board. Right now sync performance is right in line with my +expectations. In any case, I checked and confirm that there are no +spurious fsyncs running when they are not supposed to be. + +Merlin + + + +From pgsql-performance-owner@postgresql.org Fri Jun 11 18:30:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A375D1B169 + for ; + Fri, 11 Jun 2004 18:30: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 38308-06 + for ; + Fri, 11 Jun 2004 21:30: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 CC2CDD1B175 + for ; + Fri, 11 Jun 2004 18:30:48 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5BLUodw018743; + Fri, 11 Jun 2004 17:30:50 -0400 (EDT) +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org +Subject: Re: in-transaction insert performance in 7.5devel +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AE5B@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AE5B@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Fri, 11 Jun 2004 17:04:44 -0400" +Date: Fri, 11 Jun 2004 17:30:50 -0400 +Message-ID: <18742.1086989450@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/140 +X-Sequence-Number: 7198 + +"Merlin Moncure" writes: +> Tom Lane wrote: +>> Does it help if you change FlushBuffer to release buffer lock while +>> flushing xlog? + +> Putting your change in resulted in about a 15% increase in insert +> performance. There may be some quirky things going on here with NTFS... + +> I did an update clean from cvs and I noticed big speedup across the +> board. Right now sync performance is right in line with my +> expectations. In any case, I checked and confirm that there are no +> spurious fsyncs running when they are not supposed to be. + +Was that 15% before or after updating from CVS? + +The more I think about the looping aspect the less I like it, so I'd +prefer not to pursue making the unlock change for real. But if it's +really a 15% win then maybe we need to... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jun 13 00:22:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B6EAD1B20E + for ; + Sun, 13 Jun 2004 00:22: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 46284-09 + for ; + Sun, 13 Jun 2004 03:21:57 +0000 (GMT) +Received: from fep13.012.net.il (fep13.012.net.il [212.117.129.242]) + by svr1.postgresql.org (Postfix) with ESMTP id CAB77D1B229 + for ; + Sun, 13 Jun 2004 00:21:55 -0300 (ADT) +Received: from [127.0.0.1] ([80.178.84.246]) by fep13.012.net.il with ESMTP + id <20040613032033.MHUS4510.fep13@[80.178.84.246]> + for ; + Sun, 13 Jun 2004 06:20:33 +0300 +Received: from [127.0.0.1] ([127.0.0.1]) + by [127.0.0.1] with ESMTP (SpamPal v1.50) + sender ; 13 Jun 2004 06:21:17 +0300 +Date: Sun, 13 Jun 2004 06:21:17 +0300 +From: Vitaly Belman +Reply-To: Vitaly Belman +X-Priority: 3 (Normal) +Message-ID: <2393942843.20040613062117@012.net.il> +To: pgsql-performance@postgresql.org +Subject: Additional select fields in a GROUP BY +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.8 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200406/141 +X-Sequence-Number: 7199 + +Hello, + +Consider the following query: + +select t1field1, avg(t2fieild2) +from t1, t2 +where t1.field1 = t2.field2 +group by t1field1 + +That works fine. But I'd really like to see more fields of t1 in this +query, however I can't add them into the select because they're not +part of the GROUP BY, thus I have to add them to there too: + +select t1field1, t1field2, t1field3, avg(t2fieild2) +from t1, t2 +where t1.field1 = t2.field2 +group by t1field1, t1field2, t1field3 + +The problem is that addind them all to GROUP BY causes a performance +loss.. The only solution I found is using a subquery like this: + +select * from +t1, (select t1field1, avg(t2fieild2) +from t1, t2 +where t1.field1 = t2.field2 +group by t1field1) t1inner +where t1.field1 = t1inner.field1 + +It works just fine.. But I prefer not to use subqueries unless I am +really forced to due to the design of my application. + +Another solution I considered is using aggreate function like that: + +select t1field1, max(t1field2), max(t1field3), avg(t2fieild2) +from t1, t2 +where t1.field1 = t2.field2 +group by t1field1 + +Sadly, this caused the same performance... I wonder though, is it +possible to make an aggregate function like first(), last() in Oracle +(IIRC)? I believe that in such cases MySQL does first() by itself. + +Other ideas are welcome too. + + +Regards, + Vitaly Belman + + ICQ: 1912453 + AIM: VitalyB1984 + MSN: tmdagent@hotmail.com + Yahoo!: VitalyBe + + +From pgsql-performance-owner@postgresql.org Sun Jun 13 00:40:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 25604D1B7C9 + for ; + Sun, 13 Jun 2004 00:40: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 49540-10 + for ; + Sun, 13 Jun 2004 03:40:01 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 124D9D1B7C8 + for ; + Sun, 13 Jun 2004 00:39:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5D3dtCV021367; + Sat, 12 Jun 2004 23:39:55 -0400 (EDT) +To: Vitaly Belman +Cc: pgsql-performance@postgresql.org +Subject: Re: Additional select fields in a GROUP BY +In-reply-to: <2393942843.20040613062117@012.net.il> +References: <2393942843.20040613062117@012.net.il> +Comments: In-reply-to Vitaly Belman + message dated "Sun, 13 Jun 2004 06:21:17 +0300" +Date: Sat, 12 Jun 2004 23:39:55 -0400 +Message-ID: <21366.1087097995@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/142 +X-Sequence-Number: 7200 + +Vitaly Belman writes: +> The problem is that addind them all to GROUP BY causes a performance +> loss. + +Really? I'd think that there'd be no visible loss if the earlier +fields of the GROUP BY are already unique. The sort comparison +should stop at the first field that determines the sort order. +Can you provide a self-contained example? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jun 13 10:46:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A67BD1B215 + for ; + Sun, 13 Jun 2004 10:46: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 00718-05 + for ; + Sun, 13 Jun 2004 13:46:15 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id CFDA5D1B269 + for ; + Sun, 13 Jun 2004 10:46:09 -0300 (ADT) +Received: (qmail 3708 invoked by uid 500); 13 Jun 2004 13:52:12 -0000 +Date: Sun, 13 Jun 2004 08:52:12 -0500 +From: Bruno Wolff III +To: Vitaly Belman +Cc: pgsql-performance@postgresql.org +Subject: Re: Additional select fields in a GROUP BY +Message-ID: <20040613135212.GA3260@wolff.to> +Mail-Followup-To: Vitaly Belman , + pgsql-performance@postgresql.org +References: <2393942843.20040613062117@012.net.il> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <2393942843.20040613062117@012.net.il> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/143 +X-Sequence-Number: 7201 + +On Sun, Jun 13, 2004 at 06:21:17 +0300, + Vitaly Belman wrote: +> +> Consider the following query: +> +> select t1field1, avg(t2fieild2) +> from t1, t2 +> where t1.field1 = t2.field2 +> group by t1field1 +> +> That works fine. But I'd really like to see more fields of t1 in this +> query, however I can't add them into the select because they're not +> part of the GROUP BY, thus I have to add them to there too: + +If t1.field1 is a candiate key for t1, then the normal thing to do is +to group t2 by t2.field1 (assuming you really meant to join on t2.field1, +not t2.field2) and THEN join to t1. That may even be faster than the way you +are doing things now. + +So the query would look like: + +SELECT t1.field1, t1.field2, t1.field3, a.t2avg FROM t1, + (SELECT field1, avg(field2) as t2avg FROM t2 GROUP BY field1) as a + WHERE t1.field1 = a.field1 + +From pgsql-performance-owner@postgresql.org Sun Jun 13 14:35:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EF5BD1B188 + for ; + Sun, 13 Jun 2004 14:35: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 66111-10 + for ; + Sun, 13 Jun 2004 17:35:46 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) + by svr1.postgresql.org (Postfix) with SMTP id A73AFD1B172 + for ; + Sun, 13 Jun 2004 14:35:36 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id v18so20689rnb + for ; + Sun, 13 Jun 2004 10:35:36 -0700 (PDT) +Received: by 10.38.101.26 with SMTP id y26mr24375rnb; + Sun, 13 Jun 2004 10:35:36 -0700 (PDT) +Message-ID: +Date: Sun, 13 Jun 2004 20:35:36 +0300 +From: Vitaly Belman +To: Bruno Wolff III , Tom Lane +Subject: Re: Additional select fields in a GROUP BY +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20040613135212.GA3260@wolff.to> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <2393942843.20040613062117@012.net.il> + <20040613135212.GA3260@wolff.to> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/144 +X-Sequence-Number: 7202 + +Bruno: + +It wasn't exactly my case but you did give me an idea by this tip, +changing a perspective did quite good to the timing of this query. + +Tom: + +Hmm.. I am not sure how I can demonstrate this to you... To see the +time differences you'd need the whole table.. That's quite a lot of +data to be posted on a mailing list, if you wish to test it on your +side, I'll dump this table partly and send them to you somehow. + +I do stand by what I said though, here's the real query example: + +Original query (execution time, 800ms): + +select s.series_id, avg(vote_avg), sum(vote_count) +from v_bookseries s, bv_seriesgenres sg +where s.series_id = sg.series_id and sg.genre_id = 1 +group by s.series_id +order by sum(vote_count) desc +limit 10 + +QUERY PLAN: + +Limit (cost=6523.51..6523.53 rows=10 width=12) + -> Sort (cost=6523.51..6566.27 rows=17104 width=12) + Sort Key: sum(b.vote_count) + -> GroupAggregate (cost=1368.54..5320.92 rows=17104 width=12) + -> Merge Join (cost=1368.54..4796.91 rows=58466 width=12) + Merge Cond: ("outer".series_id = "inner".series_id) + -> Merge Join (cost=0.00..6676.41 rows=65902 width=16) + Merge Cond: ("outer".series_id = "inner".series_id) + -> Index Scan using bv_series_pkey on +bv_series s (cost=0.00..386.83 rows=17104 width=4) + -> Index Scan using i_books_series_id on +bv_books b (cost=0.00..14148.38 rows=171918 width=12) + -> Sort (cost=1368.54..1406.47 rows=15173 width=4) + Sort Key: sg.series_id + -> Index Scan using i_seriesgenres_genre_id +on bv_seriesgenres sg (cost=0.00..314.83 rows=15173 width=4) + Index Cond: (genre_id = 1) + + +Query with added GROUP BY members (execution time, 1400ms): + +select s.series_id, s.series_name, s.series_picture, avg(vote_avg), +sum(vote_count) +from v_bookseries s, bv_seriesgenres sg +where s.series_id = sg.series_id and sg.genre_id = 1 +group by s.series_id, s.series_name, s.series_picture +order by sum(vote_count) desc +limit 10 + +QUERY PLAN: + +Limit (cost=12619.76..12619.79 rows=10 width=47) + -> Sort (cost=12619.76..12662.52 rows=17104 width=47) + Sort Key: sum(b.vote_count) + -> GroupAggregate (cost=10454.67..11417.18 rows=17104 width=47) + -> Sort (cost=10454.67..10600.83 rows=58466 width=47) + Sort Key: s.series_id, s.series_name, s.series_picture + -> Merge Join (cost=1368.54..4796.91 rows=58466 width=47) + Merge Cond: ("outer".series_id = "inner".series_id) + -> Merge Join (cost=0.00..6676.41 +rows=65902 width=51) + Merge Cond: ("outer".series_id = +"inner".series_id) + -> Index Scan using bv_series_pkey on +bv_series s (cost=0.00..386.83 rows=17104 width=39) + -> Index Scan using i_books_series_id +on bv_books b (cost=0.00..14148.38 rows=171918 width=12) + -> Sort (cost=1368.54..1406.47 rows=15173 width=4) + Sort Key: sg.series_id + -> Index Scan using +i_seriesgenres_genre_id on bv_seriesgenres sg (cost=0.00..314.83 +rows=15173 width=4) + Index Cond: (genre_id = 1) + +Notice that the GROUP BY items added the following to the plan: + + -> GroupAggregate (cost=10454.67..11417.18 rows=17104 width=47) + -> Sort (cost=10454.67..10600.83 rows=58466 width=47) + Sort Key: s.series_id, s.series_name, s.series_picture + +Which eventually almost doubles the execution time. + + +On Sun, 13 Jun 2004 08:52:12 -0500, Bruno Wolff III wrote: +> +> On Sun, Jun 13, 2004 at 06:21:17 +0300, +> Vitaly Belman wrote: +> > +> > Consider the following query: +> > +> > select t1field1, avg(t2fieild2) +> > from t1, t2 +> > where t1.field1 = t2.field2 +> > group by t1field1 +> > +> > That works fine. But I'd really like to see more fields of t1 in this +> > query, however I can't add them into the select because they're not +> > part of the GROUP BY, thus I have to add them to there too: +> +> If t1.field1 is a candiate key for t1, then the normal thing to do is +> to group t2 by t2.field1 (assuming you really meant to join on t2.field1, +> not t2.field2) and THEN join to t1. That may even be faster than the way you +> are doing things now. +> +> So the query would look like: +> +> SELECT t1.field1, t1.field2, t1.field3, a.t2avg FROM t1, +> (SELECT field1, avg(field2) as t2avg FROM t2 GROUP BY field1) as a +> WHERE t1.field1 = a.field1 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> + +From pgsql-performance-owner@postgresql.org Sun Jun 13 14:59:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A0C70D1B179 + for ; + Sun, 13 Jun 2004 14:59: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 70868-09 + for ; + Sun, 13 Jun 2004 17:59: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 E9FD8D1B16E + for ; + Sun, 13 Jun 2004 14:59:24 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5DHxOFX026743; + Sun, 13 Jun 2004 13:59:24 -0400 (EDT) +To: Vitaly Belman +Cc: Bruno Wolff III , + pgsql-performance@postgresql.org +Subject: Re: Additional select fields in a GROUP BY +In-reply-to: +References: <2393942843.20040613062117@012.net.il> + <20040613135212.GA3260@wolff.to> + +Comments: In-reply-to Vitaly Belman + message dated "Sun, 13 Jun 2004 20:35:36 +0300" +Date: Sun, 13 Jun 2004 13:59:24 -0400 +Message-ID: <26742.1087149564@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/145 +X-Sequence-Number: 7203 + +Vitaly Belman writes: +> Notice that the GROUP BY items added the following to the plan: + +> -> Sort (cost=10454.67..10600.83 rows=58466 width=47) +> Sort Key: s.series_id, s.series_name, s.series_picture + +Oh, I see: in the first case you need no sort at all because the output +of the indexscan is already known to be sorted by s.series_id. I was +thinking of a sort with more or fewer sort columns, but that's not the +issue here. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jun 20 15:16:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F266D1B172 + for ; + Mon, 14 Jun 2004 06:25: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 68654-08 + for ; + Mon, 14 Jun 2004 09:25:00 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 13FB3D1B16F + for ; + Mon, 14 Jun 2004 06:20:54 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i5E9JXDW098707 + for ; Mon, 14 Jun 2004 09:19:33 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i5E9D5rT097953 + for pgsql-performance@postgresql.org; Mon, 14 Jun 2004 09:13:05 GMT +From: "Thanks" +X-Newsgroups: comp.databases.postgresql.performance +Subject: pg_fetch_array +Date: Mon, 14 Jun 2004 17:12:25 +0800 +Organization: Hub.Org Networking Services +Lines: 29 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.9 tagged_above=0.0 required=5.0 + tests=NO_DNS_FOR_FROM, PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200406/208 +X-Sequence-Number: 7266 + +Hello.... + +I would like to know the performance of pg_fetch_array. Cosider the code: + +$query = "select * from foo"; +$result = pg_query( $db, $query ); + +while ($row = pg_fetch_array($result)) +{ + $a = $row["a"]; + $b = $row["b"]; + $c = $row["c"]; + $d = $row["d"]; +} + +Does php need to read database everytime when pg_fetch_array is executed in +the while loop or all the rows have been in the memory after pg_query? + +If read database is needed, is there any method to copy all the rows into +memory by using other command? (because I have a application which needs +large amount database update/retrieval and I wish the performance of the +overall applications run faster.) + +or other method you would like to recommend in order to make the faster +response time? + +Thank you in advance. + + + +From pgsql-performance-owner@postgresql.org Mon Jun 14 12:26:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A0FBD1B175 + for ; + Mon, 14 Jun 2004 12:26: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 08536-08 + for ; + Mon, 14 Jun 2004 15:26:02 +0000 (GMT) +Received: from airdefense.net (unknown [64.25.5.183]) + by svr1.postgresql.org (Postfix) with ESMTP id C40E6D1B169 + for ; + Mon, 14 Jun 2004 12:26:00 -0300 (ADT) +Received: from ([172.16.0.100]) by ironmail.airdefense.net with ESMTP ; + Mon, 14 Jun 2004 11:25:35 -0400 +Received: from kaos.securitymatrix.com ([172.16.0.101]) + by localhost.localdomain (8.11.6/8.11.6) with ESMTP id i5ED6ls15979 + for ; Mon, 14 Jun 2004 09:06:47 -0400 +Subject: Re: [BULK] Problems with vacuum! +From: Dawn Hollingsworth +To: pgsql-performance@postgresql.org +In-Reply-To: <87pt8616i3.fsf@asmodeus.mcnaught.org> +References: <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com> + <004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> + <87pt8616i3.fsf@asmodeus.mcnaught.org> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 (1.0.8-9.7x.1) +Date: 14 Jun 2004 11:24:07 -0400 +Message-Id: <1087226647.1775.14.camel@kaos> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/146 +X-Sequence-Number: 7204 + + +We actually found that in the 2.4-20 kernel for RedHat there was a known +issue that was causing cached memory to not be reused and our box +started to swap also. + +http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=89226 + +This may be what you are experiencing if your using the same kernel. + +Dawn Hollingsworth +Senior Director R&D +AirDefense, Inc. + + + +On Fri, 2004-06-11 at 11:03, Doug McNaught wrote: +> "Domenico Sgarbossa" writes: +> +> > Thanks for your advice! +> > +> > It seems that the cached memory isn't released by the system... so the +> > system begin to swap to disk! +> + + + +From pgsql-performance-owner@postgresql.org Mon Jun 14 20:49:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BC81D1B169 + for ; + Mon, 14 Jun 2004 20:49: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 04681-07 + for ; + Mon, 14 Jun 2004 23:49:46 +0000 (GMT) +Received: from server272.com (ns1.server272.com [64.14.68.49]) + by svr1.postgresql.org (Postfix) with SMTP id 255E4D1B175 + for ; + Mon, 14 Jun 2004 20:49:41 -0300 (ADT) +Received: (qmail 17402 invoked from network); 14 Jun 2004 23:50:50 -0000 +X-Relay-Users: samsixed.user +X-Abuse: Send abuse reports to: abuse@suresupport.com +Received: from unknown (HELO pesky) (63.170.214.187) + by server272.com with SMTP; 14 Jun 2004 23:50:50 -0000 +Subject: Re: Index oddity (still) +From: ken +To: Postgresql Performance +In-Reply-To: <19759.1086843718@sss.pgh.pa.us> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> <1086814928.32077.259.camel@pesky> + <19759.1086843718@sss.pgh.pa.us> +Content-Type: text/plain +Message-Id: <1087256828.28557.115.camel@pesky> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 14 Jun 2004 16:47:08 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/148 +X-Sequence-Number: 7206 + +Apologies in advance for the length of this post but I want to be as +thorough as possible in describing my problem to avoid too much banter +back and forth. + +First off, thanks to all for your help with my index problem on my +multi-column index made up of 5 double precision columns. + +Unfortunately, I was unable to make it work with any of the suggestions +provided. However, Tom's suggestion of experimenting with alternative +data representations led me to explore using the built-in geometric data +object box to store this information since that is exactly what I am +storing. + +By adding an rtree index on this box column I was able to make this new +method work beautifully for most cases! The query that was taking over +a second went down under 20 milliseconds! Wow! + +However, for *some* cases the query now behaves very badly. My new +table is now essentially the following (with the unnecessary bits +removed for your ease of viewing) ... + + Column | Type | Modifiers +----------------+-----------------------------+----------- + fid1 | numeric(64,0) | not null + fid2 | numeric(64,0) | not null + boundingbox | box | + +Indexes: + "nrgfeature_pkey" primary key, btree (fid2, fid1) + "nrgfeature_bb_idx" rtree (boundingbox) + "nrgfeature_bblength_idx" btree (length(lseg(boundingbox))) + + +... with 763,809 rows. + +The query I run is of the form ... + + +SELECT * FROM nrgFeature WHERE +boundingbox && '((213854.57920364887, 91147.4541420119), +(212687.30997287965, 90434.4541420119))' +AND length(lseg(boundingbox)) > 12.916666666666668; + + +... If the bounding box is relatively small (like the one defined above) +then the query is very fast as relatively few rows are investigated by +the index. The explain analyze for the above is ... + + + Index Scan using nrgfeature_bb_idx on nrgfeature (cost=0.00..14987.30 +rows=1274 width=256) (actual time=0.046..0.730 rows=89 loops=1) + Index Cond: (boundingbox && +'(213854.579203649,91147.4541420119),(212687.30997288,90434.4541420119)'::box) + Filter: (length(lseg(boundingbox)) > 12.9166666666667::double +precision) + Total runtime: 0.830 ms + + +... Notice the statistics aren't great at guessing the number of rows, +however, since the number is sufficient to tell the optimizer to use the +index, it does and the query is blindingly fast. However, now let's try +and retrieve all the rows that overlap a much, much bigger bounding box +but limit the results to rows with very large bounding boxes (we are +displaying these things on the screen and if they are too small to see +at this scale there is no reason to return them in the query)... + + +SELECT * FROM nrgFeature WHERE +boundingbox && '((793846.1538461539, 423000.0), (-109846.15384615387, +-129000.0))' +AND length(lseg(boundingbox)) > 10000.0; + + +... and its explain analyze is ... + + + Index Scan using nrgfeature_bb_idx on nrgfeature (cost=0.00..14987.30 +rows=1274 width=256) (actual time=1.861..6427.876 rows=686 loops=1) + Index Cond: (boundingbox && +'(793846.153846154,423000),(-109846.153846154,-129000)'::box) + Filter: (length(lseg(boundingbox)) > 10000::double precision) + Total runtime: 6428.838 ms + + +... notice that the query now takes 6.4 seconds even though the +statistics look to be pretty close and only 686 rows are returned. The +reason is due to the condition on the length(lseg()) functions. Without +this condition the explain analyze is the following ... + + + Index Scan using nrgfeature_bb_idx on nrgfeature (cost=0.00..14958.66 +rows=3820 width=256) (actual time=21.356..7750.360 rows=763768 loops=1) + Index Cond: (boundingbox && +'(793846.153846154,423000),(-109846.153846154,-129000)'::box) + Total runtime: 8244.213 ms + + +... in which it can be seen that the statistics are way, way off. It +thinks its only going to get back 3820 rows but instead almost every row +in the table is returned! It should *not* be using this index in this +case. Is there something wrong with rtree indexes on box data types? + +So that is problem number one. + +Problem number two, and this is possibly a bug, is that postgres doesn't +seem to use functional indexes on geometric data. In the case +immediately above, the optimizer should choose the +nrgfeature_bblength_idx instead as it would immediately give the 686 +rows that satisfy the length(lseg()) condition and voila it would be +done. However, even if I *drop* the rtree index on the boundingbox +column, so that it can't use that index, the optimizer does not choose +the other index. Instead it reverts to doing a sequential scan of the +entire table and its really slow. + +Again, sorry for the long post. Hope someone has experience with either +of these problems. + +Ken + + + + +> I don't have any advice to magically solve this problem. I would +> suggest experimenting with alternative data representations -- for +> example, maybe it would help to store "leftX" and "width" in place +> of "leftX" and "rightX", etc. What you want to do is try to decorrelate +> the column values. leftX and rightX are likely to have a strong +> correlation, but maybe leftX and width don't. +> +> regards, tom lane +> + + +From pgsql-performance-owner@postgresql.org Mon Jun 14 21:11:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5AAD7D1B182 + for ; + Mon, 14 Jun 2004 21:11: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 23221-01 + for ; + Tue, 15 Jun 2004 00:11:42 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 5430BD1B19F + for ; + Mon, 14 Jun 2004 21:11:38 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5363550; Mon, 14 Jun 2004 17:13:19 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "borajetta" , + +Subject: Re: 50 000 000 Table entries and I have to do a keyword search HELP + NEEDED +Date: Mon, 14 Jun 2004 17:11:43 -0700 +User-Agent: KMail/1.5.4 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406141711.43571.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200406/149 +X-Sequence-Number: 7207 + +Borajetta, + +> So I have a table with about 50 million entries in it, I have to do a +keyword search. + +Are you using OpenFTS/TSearch2? Is your database optimized? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Jun 15 00:41:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C1ECFD1B54D + for ; + Tue, 15 Jun 2004 00:39: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 92679-07 + for ; + Tue, 15 Jun 2004 03:39:28 +0000 (GMT) +Received: from ml-hw5.monsterlabs.com (ml-hw5.monsterlabs.com + [216.183.105.167]) + by svr1.postgresql.org (Postfix) with SMTP id EAC58D1B297 + for ; + Tue, 15 Jun 2004 00:39:26 -0300 (ADT) +Received: (qmail 9627 invoked from network); 15 Jun 2004 03:39:25 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.15?) + (64.3.242.80) + by ml-hw5.monsterlabs.com with SMTP; 15 Jun 2004 03:39:25 -0000 +From: Marcus Whitney +Reply-To: marcus@coldfeetcreative.com +Organization: Coldfeet Creative +To: pgsql-performance@postgresql.org +Subject: Re: Failed System. Help. +Date: Mon, 14 Jun 2004 22:33:26 -0500 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200406142233.26374.marcus@coldfeetcreative.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/150 +X-Sequence-Number: 7208 + +Hello all, + + I have a PostgreSQL instance running on a Dell Poweredge 6450. 4 700Mhz +processors, 6 GB of Ram, 2GB Backside, 60GB Raid 10 Server. Today, it +crashed hard. At the command line (BASH), all I could get was 'bus fault' . +After rebooting, we were unable to mount the partition that PostgreSQL was +on. When trying to load one of our remote backup archives (pg_dump) from +the last week, they all die at a point, saying: + +pg_restore: [custom archiver] could not read data block -- expected 4096, got +3870 + + So, basically, we are running e2fsck very carefully as to not destroy any +files, but still try and clean up as many issues as possible. Is there +anyway to extract the pure data from those archives in spite of the bad +blocks? Also, any other suggestions for the situation are welcome. Thanks. + +- Marcus + +From pgsql-performance-owner@postgresql.org Tue Jun 15 00:47:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5625ED1B54D + for ; + Tue, 15 Jun 2004 00:47: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 92679-09 + for ; + Tue, 15 Jun 2004 03:47:10 +0000 (GMT) +Received: from ml-hw5.monsterlabs.com (ml-hw5.monsterlabs.com + [216.183.105.167]) + by svr1.postgresql.org (Postfix) with SMTP id CE350D1B297 + for ; + Tue, 15 Jun 2004 00:47:09 -0300 (ADT) +Received: (qmail 11880 invoked from network); 15 Jun 2004 03:47:08 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.15?) + (64.3.242.80) + by ml-hw5.monsterlabs.com with SMTP; 15 Jun 2004 03:47:08 -0000 +From: Marcus Whitney +Reply-To: marcus@coldfeetcreative.com +Organization: Coldfeet Creative +To: pgsql-performance@postgresql.org +Subject: Re: Failed System follow up +Date: Mon, 14 Jun 2004 22:41:10 -0500 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200406142241.10314.marcus@coldfeetcreative.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/151 +X-Sequence-Number: 7209 + +Just as a point of reference, my situation is very much like the one in this +thread: + +http://archive.netbsd.se/?list=pgsql-admin&a=2004-02&mid=50891 + +Thanks again. + +- Marcus + +From pgsql-benchmarks-owner@postgresql.org Sun Jun 20 02:27:34 2004 +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 55A6DD1B262 + for ; + Tue, 15 Jun 2004 03:03: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 41616-05 + for ; + Tue, 15 Jun 2004 06:03:45 +0000 (GMT) +Received: from rediffmail.com (unknown [203.199.83.148]) + by svr1.postgresql.org (Postfix) with SMTP id B98C3D1B1BC + for ; + Tue, 15 Jun 2004 03:03:42 -0300 (ADT) +Received: (qmail 28536 invoked by uid 510); 15 Jun 2004 06:03:40 -0000 +Date: 15 Jun 2004 06:03:40 -0000 +Message-ID: <20040615060340.28535.qmail@webmail26.rediffmail.com> +Received: from unknown (203.199.33.2) by rediffmail.com via HTTP; + 15 jun 2004 06:03:40 -0000 +MIME-Version: 1.0 +From: "Neeraj " +Reply-To: "Neeraj " +To: pgsql-benchmarks@postgresql.org, + pgsql-performance@postgresql.org, pgsql-general@postgresql.org +Subject: Interpreting OSDB Results +Content-type: multipart/alternative; + boundary="Next_1087279420---0-203.199.83.148-28517" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.9 tagged_above=0.0 required=5.0 + tests=HTML_IMAGE_ONLY_10, HTML_MESSAGE, MSGID_FROM_MTA_HEADER +X-Spam-Level: * +X-Archive-Number: 200406/2 +X-Sequence-Number: 13 + + This is a multipart mime message + + +--Next_1087279420---0-203.199.83.148-28517 +Content-type: text/html; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

+Hi All,
+
+Im testing my postgres 7.3.2 db on redhat 9.0 using osdb 0.16. I couldnot f= +ind any docuementation  for interpreting the results obtained. Im doin= +g multiuser (10 users) test. I've two different con figurations for postgre= +sql.conf. In one it takes 44 mins to finish while in other it takes 18 mins= + to finish. But tps (both mixed IR & mixed OLTP) is very high in first = +one. Also i want to know relation between tuples/sec and transactions/sec. = +
+
+Thanks & Regards
+
+ +

+ + +Neeraj Malhotra

+ + +--Next_1087279420---0-203.199.83.148-28517 +Content-type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi All, + +Im testing my postgres 7.3.2 db on redhat 9.0 using osdb 0.16. I couldnot f= +ind any docuementation for interpreting the results obtained. Im doing mul= +tiuser (10 users) test. I've two different con figurations for postgresql.c= +onf. In one it takes 44 mins to finish while in other it takes 18 mins to f= +inish. But tps (both mixed IR & mixed OLTP) is very high in first one. Also= + i want to know relation between tuples/sec and transactions/sec.=20 + +Thanks & Regards + + + +Neeraj Malhotra +--Next_1087279420---0-203.199.83.148-28517-- + + +From pgsql-performance-owner@postgresql.org Tue Jun 15 03:49:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EBAC9D1BAC0 + for ; + Tue, 15 Jun 2004 03:49: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 54652-05 + for ; + Tue, 15 Jun 2004 06:49:34 +0000 (GMT) +Received: from gatefox.foxi.nl (foxi.xs4all.nl [194.109.246.192]) + by svr1.postgresql.org (Postfix) with ESMTP id B3450D1B7DC + for ; + Tue, 15 Jun 2004 03:49:30 -0300 (ADT) +Received: from techfox.foxi (techfox.foxi [192.168.0.79]) + by gatefox.foxi.nl (8.10.2-20030922/8.10.2) with ESMTP id i5F6nTu01340 + for ; Tue, 15 Jun 2004 08:49:29 +0200 +From: Frank van Vugt +Organization: Foxi Consultants in Technology BV +To: pgsql-performance@postgresql.org +Subject: why is a constraint not 'pushed down' into a subselect when this + subselect is using a 'group by' ?? +Date: Tue, 15 Jun 2004 08:49:29 +0200 +User-Agent: KMail/1.5.4 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406150849.29470.ftm.van.vugt@foxi.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/153 +X-Sequence-Number: 7211 + +Hi all, + +I noticed the following. Given two tables, just simply articles and their +packages: + + article(id int) + package( id int, article_id int, amount) + +When taking the minimum package for articles given some constraint on the +article table + + select + article.id, + p_min + from + article, + (select + article_id, + min(amount) as p_min + from + package + group by + article_id + ) as foo + where + article.id = foo.article_id and + article.id < 50; + +The query plan shows + + QUERY PLAN +---------------------------------------------------------------------------------------- + Hash Join (cost=730.11..808.02 rows=1 width=8) + Hash Cond: ("outer".article_id = "inner".id) + -> Subquery Scan foo (cost=726.10..781.74 rows=4451 width=8) + -> HashAggregate (cost=726.10..737.23 rows=4451 width=8) + -> Seq Scan on package (cost=0.00..635.40 rows=18140 width=8) + -> Hash (cost=4.01..4.01 rows=1 width=4) + -> Index Scan using article_pkey on article (cost=0.00..4.01 rows=1 +width=4) + Index Cond: (id < 50) + +So, a seq scan on the complete package table is done, although it seems the +planner could have deduced that only the part that has 'article_id < 50' +would be relevant, since 'article.id < 50' and 'article.id = foo.article_id' + +If I ditch the group by, then this contraint does get pushed into the +subselect : + + select + article.id, + p_min + from + article, + (select + article_id, + amount as p_min + from + package + ) as foo + where + article.id = foo.article_id and + article.id < 50; + + + QUERY PLAN +----------------------------------------------------------------------------------- + Nested Loop (cost=0.00..14.22 rows=5 width=8) + -> Index Scan using article_pkey on article (cost=0.00..4.01 rows=1 +width=4) + Index Cond: (id < 50) + -> Index Scan using package_idx3 on package (cost=0.00..10.16 rows=4 +width=8) + Index Cond: ("outer".id = package.article_id) + + +So it seems the math-knowledge is there ;) +I'm wondering about what I'm overlooking here. When I take the first query and +add the article constraint 'manually', I get: + + select + article.id, + p_min + from + article, + (select + article_id, + min(amount) as p_min + from + package + where + article_id < 50 + group by + article_id + ) as foo + where + article.id = foo.article_id and + article.id < 50; + + QUERY PLAN +---------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..9.65 rows=1 width=8) + Join Filter: ("outer".id = "inner".article_id) + -> Index Scan using article_pkey on article (cost=0.00..4.01 rows=1 +width=4) + Index Cond: (id < 50) + -> Subquery Scan foo (cost=0.00..5.62 rows=1 width=8) + -> GroupAggregate (cost=0.00..5.61 rows=1 width=8) + -> Index Scan using package_idx3 on package (cost=0.00..5.60 +rows=2 width=8) + Index Cond: (article_id < 50) + + +which would have been a nice plan for the first query ;) + + +Could someone shine a light on this, please? + + + +-- +Best, + + + + +Frank. + + +From pgsql-performance-owner@postgresql.org Tue Jun 15 09:44:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 27663D1B21B + for ; + Tue, 15 Jun 2004 09:44: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 33012-04 + for ; + Tue, 15 Jun 2004 12:43:57 +0000 (GMT) +Received: from mail.autorevenue.com (ip-208.178.167.106.gblx.net + [208.178.167.106]) + by svr1.postgresql.org (Postfix) with ESMTP id B3148D1B20E + for ; + Tue, 15 Jun 2004 09:43:52 -0300 (ADT) +Received: from jeremydunn ([192.168.1.79]) (authenticated) + by mail.autorevenue.com (8.11.6/8.11.6) with ESMTP id i5FChqL17257; + Tue, 15 Jun 2004 08:43:52 -0400 +Reply-To: +From: "Jeremy Dunn" +To: "'borajetta'" +Cc: "Postgresql Performance" +Subject: Re: 50 000 000 Table entries and I have to do a keyword search HELP + NEEDED +Date: Tue, 15 Jun 2004 08:43:49 -0400 +Organization: AutoRevenue +Message-ID: <000601c452d6$68263570$4f01a8c0@jeremydunn> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0007_01C452B4.E1149570" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +In-Reply-To: +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200406/154 +X-Sequence-Number: 7212 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0007_01C452B4.E1149570 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +One option that does not take advantage of any fancy indexing methods is +to create a trigger on the table, on insert/update/delete, which +extracts each individual word from the field you care about, and creates +an entry in another 'keyword' table, id = 'word', value = pk of your +original table. then index the keyword table on the 'keyword' field, +and do your searches from there. this should improve performance +substantially, even on very large return sets, because the keyword table +rows are very small and thus a lot of them fit in a disk block. + +- Jeremy + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of borajetta +Sent: Monday, June 07, 2004 5:47 PM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] 50 000 000 Table entries and I have to do a keyword +search HELP NEEDED + + +So I have a table with about 50 million entries in it, I have to do a +keyword search. + + + +The keyword search is done on the title of the entry. For example a +entry could be "This is a title string which could be searched" + + + +I have tried a few ways to search but I get horrible search times. Some +keywords will come up with matches as big as .25 million but most are +around 1000-5000. + + + +I use an index which narrows the table down to about 1.5-2million +entries. + + + +I used 2 tables which had a 1:1 correspondence. + +One held a gist index which was on a int field which searched the for +the keyword. Then I would join the table to another to retrieve the +rest of the information about the items it matched. + + + +This was slow even for returning 100 entries. About 10 seconds, +sometimes 5. But when I start getting 1xxx entries its about 30-50 +seconds. The rest is just horrible. + + + +How should I set up my indexes and or tables. + +We were thinking of putting the index inside one table then the join +would not have to be done but this still returns rather slow results. + + + +I have not fully tested this method but it looks like when run for just +the keyword search on the title and no joining it can return in about 10 +seconds or less. + +This is a great improvement but I am currently going to make the table +all in one and see how long it will take. I believe it will not be much +more as there will be no join needed only the returning of some +attribute fields. + + + +This is still not the kind of time I would like to see, I wanted +something around 2 seconds or less. I know there is a lot of +information especially if .25 million rows are to be returned but if +there is only 1xxx-9xxx rows to be returned I believe 2 seconds seems +about right. + + + +How do search engines do it? + +Any suggestions are welcome, + + + +Thanks + + +------=_NextPart_000_0007_01C452B4.E1149570 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + + + +
One=20 +option that does not take advantage of any fancy indexing methods is to cre= +ate a=20 +trigger on the table, on insert/update/delete, which extracts each individu= +al=20 +word from the field you care about, and creates an entry in another 'keywor= +d'=20 +table, id =3D 'word', value =3D pk of your original table.  then index= + the=20 +keyword table on the 'keyword' field, and do your searches from there. = +;=20 +this should improve performance substantially, even on very large return se= +ts,=20 +because the keyword table rows are very small and thus a lot of them fit in= + a=20 +disk block.
+
 
+
-=20 +Jeremy
+
+
+
-----Original Message-----
From:=20 + pgsql-performance-owner@postgresql.org=20 + [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 + borajetta
Sent: Monday, June 07, 2004 5:47 PM
To:= +=20 + pgsql-performance@postgresql.org
Subject: [PERFORM] 50 000 000 = +Table=20 + entries and I have to do a keyword search HELP NEEDED

+
+

So I have a table with about 50 million entries in it, I have to= + do a=20 + keyword search.

+

 

+

The keyword search is done on the title of the entry.  For example a entry could be "T= +his is=20 + a title string which could be searched"

+

 

+

I have tried a few ways to search but I get horrible search time= +s.  Some keywords will come up with= +=20 + matches as big as .25 million but most are around 1000-5000.

+

 

+

I use an index which narrows the table down to about 1.5-2millio= +n=20 + entries.

+

 

+

I used 2 tables which had a 1:1 correspondence.

+

One held a gist index which was on a int field which searched th= +e for=20 + the keyword.  Then I would = +join=20 + the table to another to retrieve the rest of the information about the it= +ems=20 + it matched.

+

 

+

This was slow even for returning 100 entries.  About 10 seconds, sometimes 5.<= +SPAN=20 + style=3D"mso-spacerun: yes">  But when I start getting 1xxx e= +ntries=20 + its about 30-50 seconds.  T= +he rest=20 + is just horrible.

+

 

+

How should I set up my indexes and or tables.

+

We were thinking of putting the index inside one table then the = +join=20 + would not have to be done but this still returns rather slow=20 + results.

+

 

+

I have not fully tested this method but it looks like when run f= +or just=20 + the keyword search on the title and no joining it can return in about 10= +=20 + seconds or less.

+

This is a great improvement but I am currently g= +oing to=20 + make the table all in one and see how long it will take.  I believe it will not be much m= +ore as=20 + there will be no join needed only the returning of some attribute fields.= + 

+

 

+

This is still not the kind of time I would like to see, I wanted= +=20 + something around 2 seconds or less.&nbs= +p;=20 + I know there is a lot of information especially if .25 million row= +s are=20 + to be returned but if there is only 1xxx-9xxx rows to be returned I belie= +ve 2=20 + seconds seems about right.

+

 

+

How do search engines do it?

+

Any suggestions are welcome,

+

 

+

Thanks

+ +------=_NextPart_000_0007_01C452B4.E1149570-- + + +From pgsql-performance-owner@postgresql.org Tue Jun 15 10:23:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C4DD4D1B1D0 + for ; + Tue, 15 Jun 2004 10:23: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 55701-02 + for ; + Tue, 15 Jun 2004 13:23: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 E5933D1B19F + for ; + Tue, 15 Jun 2004 10:23:17 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5FDNKMj000297; + Tue, 15 Jun 2004 09:23:20 -0400 (EDT) +To: Frank van Vugt +Cc: pgsql-performance@postgresql.org +Subject: Re: why is a constraint not 'pushed down' into a subselect when this + subselect is using a 'group by' ?? +In-reply-to: <200406150849.29470.ftm.van.vugt@foxi.nl> +References: <200406150849.29470.ftm.van.vugt@foxi.nl> +Comments: In-reply-to Frank van Vugt + message dated "Tue, 15 Jun 2004 08:49:29 +0200" +Date: Tue, 15 Jun 2004 09:23:19 -0400 +Message-ID: <296.1087305799@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/155 +X-Sequence-Number: 7213 + +Frank van Vugt writes: +> If I ditch the group by, then this contraint does get pushed into the +> subselect : + +You're misinterpreting it. Without the group by, the plan is a +candidate for nestloop-with-inner-index-scan; with the group by, +there's another step in the way. + +Pushing down into subselects does get done, for instance in CVS tip +I can change the last part of your query to "foo.article_id < 50" +and get + + Hash Join (cost=25.18..53.53 rows=335 width=8) + Hash Cond: ("outer".id = "inner".article_id) + -> Seq Scan on article (cost=0.00..20.00 rows=1000 width=4) + -> Hash (cost=25.01..25.01 rows=67 width=8) + -> Subquery Scan foo (cost=24.17..25.01 rows=67 width=8) + -> HashAggregate (cost=24.17..24.34 rows=67 width=8) + -> Seq Scan on package (cost=0.00..22.50 rows=334 width=8) + Filter: (article_id < 50) + +Obviously this is on toy tables, but the point is that the constraint +does get pushed down through the GROUP BY when appropriate. + + regards, tom lane + + +From pgsql-performance-owner@postgresql.org Tue Jun 15 10:52:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49B7FD1B7BC + for ; + Tue, 15 Jun 2004 10:52: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 67145-05 + for ; + Tue, 15 Jun 2004 13:52:06 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F9FED1B34B + for ; + Tue, 15 Jun 2004 10:52:02 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5FDq6WX000736; + Tue, 15 Jun 2004 09:52:06 -0400 (EDT) +To: ken +Cc: Postgresql Performance +Subject: Re: Index oddity (still) +In-reply-to: <1087256828.28557.115.camel@pesky> +References: <1086809460.32077.246.camel@pesky> + <1086811930.2539.90.camel@jester> + <1086814209.32077.252.camel@pesky> + <1086814597.2539.92.camel@jester> + <1086814928.32077.259.camel@pesky> <19759.1086843718@sss.pgh.pa.us> + <1087256828.28557.115.camel@pesky> +Comments: In-reply-to ken + message dated "Mon, 14 Jun 2004 16:47:08 -0700" +Date: Tue, 15 Jun 2004 09:52:06 -0400 +Message-ID: <735.1087307526@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/156 +X-Sequence-Number: 7214 + +ken writes: +> Is there something wrong with rtree indexes on box data types? + +Not per se, but the selectivity estimator for && is just a stub :-(. +Feel free to take a stab at improving this, or take a look at PostGIS +--- I think those guys are working the same problem even now. + +> However, even if I *drop* the rtree index on the boundingbox +> column, so that it can't use that index, the optimizer does not choose +> the other index. Instead it reverts to doing a sequential scan of the +> entire table and its really slow. + +This is also a lack-of-statistical-knowledge problem. The optimizer has +no stats about the distribution of length(lseg(boundingbox)) and so it +does not realize that it'd be reasonable to use that index for a query +like "length(lseg(boundingbox)) > largevalue". As of 7.5 this issue +will be addressed, but in existing releases I think you could only get +that index to be used by forcing it with enable_seqscan = off :-( + +As a short-term workaround it might be reasonable to store that length +as an independent table column, which you could put an index on. You +could use triggers to ensure that it always matches the boundingbox. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jun 20 15:16:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8945DD1B7CF + for ; + Tue, 15 Jun 2004 12: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 23037-01 + for ; + Tue, 15 Jun 2004 15:15:44 +0000 (GMT) +Received: from hotmail.com (sea1-dav25.sea1.hotmail.com [207.68.162.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BF6BD1B7BC + for ; + Tue, 15 Jun 2004 12:15:42 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 15 Jun 2004 08:15:41 -0700 +Received: from 142.104.250.115 by sea1-dav25.sea1.hotmail.com with DAV; + Tue, 15 Jun 2004 15:15:41 +0000 +X-Originating-IP: [142.104.250.115] +X-Originating-Email: [smokedvw@hotmail.com] +X-Sender: smokedvw@hotmail.com +From: "Aaron" +To: +Cc: "Postgresql Performance" +References: <000601c452d6$68263570$4f01a8c0@jeremydunn> +Subject: Re: 50 000 000 Table entries and I have to do a keyword search HELP + NEEDED +Date: Tue, 15 Jun 2004 08:16:06 -0700 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_001F_01C452B1.0193F7E0" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 15 Jun 2004 15:15:41.0348 (UTC) + FILETIME=[9F1CE640:01C452EB] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE, RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/209 +X-Sequence-Number: 7267 + +This is a multi-part message in MIME format. + +------=_NextPart_000_001F_01C452B1.0193F7E0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +MessageThe words for the keyword can be made up of a sentace, ie 10 or more= + keywords to one entry. +Also incase I didnt answer before, we are using TSearch2 and all tables hav= +e been fully analyzed and indexed. +Any other suggestions? +How long do searches take when 10 000 rows are returned? +We can not use a limit of 100 because we need to analyze the entire data se= +t returned. +Thanks, + ----- Original Message -----=20 + From: Jeremy Dunn=20 + To: 'borajetta'=20 + Cc: Postgresql Performance=20 + Sent: Tuesday, June 15, 2004 5:43 AM + Subject: RE: [PERFORM] 50 000 000 Table entries and I have to do a keywor= +d search HELP NEEDED + + + One option that does not take advantage of any fancy indexing methods is = +to create a trigger on the table, on insert/update/delete, which extracts e= +ach individual word from the field you care about, and creates an entry in = +another 'keyword' table, id =3D 'word', value =3D pk of your original table= +. then index the keyword table on the 'keyword' field, and do your searche= +s from there. this should improve performance substantially, even on very = +large return sets, because the keyword table rows are very small and thus a= + lot of them fit in a disk block. + + - Jeremy + -----Original Message----- + From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-= +owner@postgresql.org] On Behalf Of borajetta + Sent: Monday, June 07, 2004 5:47 PM + To: pgsql-performance@postgresql.org + Subject: [PERFORM] 50 000 000 Table entries and I have to do a keyword = +search HELP NEEDED + + + So I have a table with about 50 million entries in it, I have to do a k= +eyword search. + +=20=20=20=20=20 + + The keyword search is done on the title of the entry. For example a en= +try could be "This is a title string which could be searched" + +=20=20=20=20=20 + + I have tried a few ways to search but I get horrible search times. Som= +e keywords will come up with matches as big as .25 million but most are aro= +und 1000-5000. + +=20=20=20=20=20 + + I use an index which narrows the table down to about 1.5-2million entri= +es. + +=20=20=20=20=20 + + I used 2 tables which had a 1:1 correspondence. + + One held a gist index which was on a int field which searched the for t= +he keyword. Then I would join the table to another to retrieve the rest of= + the information about the items it matched. + +=20=20=20=20=20 + + This was slow even for returning 100 entries. About 10 seconds, someti= +mes 5. But when I start getting 1xxx entries its about 30-50 seconds. The= + rest is just horrible. + +=20=20=20=20=20 + + How should I set up my indexes and or tables. + + We were thinking of putting the index inside one table then the join wo= +uld not have to be done but this still returns rather slow results. + +=20=20=20=20=20 + + I have not fully tested this method but it looks like when run for just= + the keyword search on the title and no joining it can return in about 10 s= +econds or less. + + This is a great improvement but I am currently going to make the table = +all in one and see how long it will take. I believe it will not be much mo= +re as there will be no join needed only the returning of some attribute fie= +lds.=20=20 + +=20=20=20=20=20 + + This is still not the kind of time I would like to see, I wanted someth= +ing around 2 seconds or less. I know there is a lot of information especia= +lly if .25 million rows are to be returned but if there is only 1xxx-9xxx r= +ows to be returned I believe 2 seconds seems about right. + +=20=20=20=20=20 + + How do search engines do it? + + Any suggestions are welcome, + +=20=20=20=20=20 + + Thanks + +------=_NextPart_000_001F_01C452B1.0193F7E0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + +Message + + + + + +
The words for the keyword can be made up o= +f a=20 +sentace, ie 10 or more keywords to one entry.
+
Also incase I didnt answer before, we are = +using=20 +TSearch2 and all tables have been fully analyzed and indexed.
+
Any other suggestions?
+
How long do searches take when 10 000 rows= + are=20 +returned?
+
We can not use a limit of 100 because we n= +eed to=20 +analyze the entire data set returned.
+
Thanks,
+
+
----- Original Message -----
+ Fro= +m:=20 + Je= +remy=20 + Dunn
+ +
Cc: Postgresql Performance=20 +
+
Sent: Tuesday, June 15, 2004 5:43= +=20 +AM
+
Subject: RE: [PERFORM] 50 000 000 = +Table=20 + entries and I have to do a keyword search HELP NEEDED
+

+
One=20 + option that does not take advantage of any fancy indexing methods is to c= +reate=20 + a trigger on the table, on insert/update/delete, which extracts each=20 + individual word from the field you care about, and creates an entry in an= +other=20 + 'keyword' table, id =3D 'word', value =3D pk of your original table. = +; then=20 + index the keyword table on the 'keyword' field, and do your searches from= +=20 + there.  this should improve performance substantially, even on very = +large=20 + return sets, because the keyword table rows are very small and thus a lot= + of=20 + them fit in a disk block.
+
 
+
-=20 + Jeremy
+
+
+
<= +FONT=20 + face=3DTahoma size=3D2>-----Original Message-----
From:=20 + pgsql-performance-owner@postgresql.org=20 + [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 + borajetta
Sent: Monday, June 07, 2004 5:47 PM
To:=20 + pgsql-performance@postgresql.org
Subject: [PERFORM] 50 000 00= +0=20 + Table entries and I have to do a keyword search HELP=20 + NEEDED

+
+

So I have a table with about 50 million entries in it, I have = +to do a=20 + keyword search.

+

 

+

The keyword search is done on the title of the entry.  For example a entry could be = +"This=20 + is a title string which could be searched"

+

 

+

I have tried a few ways to search but I get horrible search=20 + times.  Some keywords wil= +l come=20 + up with matches as big as .25 million but most are around=20 + 1000-5000.

+

 

+

I use an index which narrows the table down to about 1.5-2mill= +ion=20 + entries.

+

 

+

I used 2 tables which had a 1:1 correspondence.

+

One held a gist index which was on a int field which searched = +the for=20 + the keyword.  Then I woul= +d join=20 + the table to another to retrieve the rest of the information about the = +items=20 + it matched.

+

 

+

This was slow even for returning 100 entries.  About 10 seconds, sometimes 5= +.  But when I start getting 1xxx= +=20 + entries its about 30-50 seconds. = +;=20 + The rest is just horrible.

+

 

+

How should I set up my indexes and or tables.

+

We were thinking of putting the index inside one table then th= +e join=20 + would not have to be done but this still returns rather slow=20 + results.

+

 

+

I have not fully tested this method but it looks like when run= + for=20 + just the keyword search on the title and no joining it can return in ab= +out=20 + 10 seconds or less.

+

This is a great improvement but I am currently= + going=20 + to make the table all in one and see how long it will take.  I believe it will not be much= + more=20 + as there will be no join needed only the returning of some attribute=20 + fields.  +

 

+

This is still not the kind of time I would like to see, I want= +ed=20 + something around 2 seconds or less.&n= +bsp;=20 + I know there is a lot of information especially if .25 million r= +ows=20 + are to be returned but if there is only 1xxx-9xxx rows to be returned I= +=20 + believe 2 seconds seems about right.

+

 

+

How do search engines do it?

+

Any suggestions are welcome,

+

 

+

Thanks

+ +------=_NextPart_000_001F_01C452B1.0193F7E0-- + +From pgsql-performance-owner@postgresql.org Tue Jun 15 12:31:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F21CDD1B7D5 + for ; + Tue, 15 Jun 2004 12:30: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 29005-08 + for ; + Tue, 15 Jun 2004 15:30:46 +0000 (GMT) +Received: from gatefox.foxi.nl (foxi.xs4all.nl [194.109.246.192]) + by svr1.postgresql.org (Postfix) with ESMTP id A50B8D1B7CF + for ; + Tue, 15 Jun 2004 12:30:44 -0300 (ADT) +Received: from techfox.foxi (techfox.foxi [192.168.0.79]) + by gatefox.foxi.nl (8.10.2-20030922/8.10.2) with ESMTP id i5FFUeu08680; + Tue, 15 Jun 2004 17:30:40 +0200 +From: Frank van Vugt +Organization: Foxi Consultants in Technology BV +To: Tom Lane +Subject: Re: why is a constraint not 'pushed down' into a subselect when this + subselect is using a 'group by' ?? +Date: Tue, 15 Jun 2004 17:30:40 +0200 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: <200406150849.29470.ftm.van.vugt@foxi.nl> + <296.1087305799@sss.pgh.pa.us> +In-Reply-To: <296.1087305799@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406151730.40464.ftm.van.vugt@foxi.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/157 +X-Sequence-Number: 7215 + +> Obviously this is on toy tables + +The query is simplified, yes. But the data in the tables is real, albeit +they're not that large. + +> You're misinterpreting it. + +I might very well be ;) +But I also get the feeling I didn't explain to you well enough what I meant... + +> Without the group by, the plan is a candidate for +nestloop-with-inner-index-scan + +Yes, I understand that. I only ditched the group by to check whether the +contraint on the article table was indeed recognized as a constraint on the +package table based on 'article.id = foo.article_id'. And it is/was. + +> with the group by, there's another step in the way. + +Yep, but on my system, package gets seq-scanned *without* any additional +constraint, resulting in a loooooong processing time. + +> Pushing down into subselects does get done, for instance in CVS tip +> I can change the last part of your query to "foo.article_id < 50" +> and get ... + +This is why I think I wasn't clear enough. + +In the real thing, the constraint on the article table is built by some +external source and I cannot easily make assumptions to translate these to a +constraint on the package table, especially since I expect the planner to be +far better in that than me ;) + +So, my base query is this: + + select + article.id, p_min + from + article, + (select + article_id, min(amount) as p_min + from + package + group by + article_id + ) as foo + where + article.id = foo.article_id and + ; + + +Now, when = true, this obviously results in seqscans: + + Hash Join (cost=1106.79..1251.46 rows=4452 width=8) + Hash Cond: ("outer".article_id = "inner".id) + -> Subquery Scan foo (cost=726.10..781.74 rows=4451 width=8) + -> HashAggregate (cost=726.10..737.23 rows=4451 width=8) + -> Seq Scan on package (cost=0.00..635.40 rows=18140 width=8) + -> Hash (cost=369.35..369.35 rows=4535 width=4) + -> Seq Scan on article (cost=0.00..369.35 rows=4535 width=4) + +But when = 'article.id < 50', only article is indexscanned: + + Hash Join (cost=730.11..808.02 rows=1 width=8) + Hash Cond: ("outer".article_id = "inner".id) + -> Subquery Scan foo (cost=726.10..781.74 rows=4451 width=8) + -> HashAggregate (cost=726.10..737.23 rows=4451 width=8) + -> Seq Scan on package (cost=0.00..635.40 rows=18140 width=8) + -> Hash (cost=4.01..4.01 rows=1 width=4) + -> Index Scan using article_pkey on article (cost=0.00..4.01 rows=1 +width=4) + Index Cond: (id < 50) + + +Which still results in poor performance due to the seqscan on package. + +Putting the constraint on package is boosting performance indeed, but I cannot +make that assumption. + +So, what I was asking was: + +When the 'article.id < 50' constraint is added, it follows that +'foo.article_id < 50' is a constraint as well. Why is this constraint not +used to avoid the seqscan on package? + +> Obviously this is on toy tables, but the point is that the constraint +> does get pushed down through the GROUP BY when appropriate. + +I've seen it being pushed down when it already was defined as a constraint on +the group by, like in your example. + +If necessary, I'll throw together a few commands that build some example +tables to show what I mean. + + + +-- +Best, + + + + +Frank. + + +From pgsql-performance-owner@postgresql.org Tue Jun 15 15:17:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E7E67D1B21B + for ; + Tue, 15 Jun 2004 15:04: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 15350-02 + for ; + Tue, 15 Jun 2004 18:04:43 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D3A4D1B19F + for ; + Tue, 15 Jun 2004 15:04:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5FI4fuq003140; + Tue, 15 Jun 2004 14:04:41 -0400 (EDT) +To: Frank van Vugt +Cc: pgsql-performance@postgresql.org +Subject: Re: why is a constraint not 'pushed down' into a subselect when this + subselect is using a 'group by' ?? +In-reply-to: <200406151730.40464.ftm.van.vugt@foxi.nl> +References: <200406150849.29470.ftm.van.vugt@foxi.nl> + <296.1087305799@sss.pgh.pa.us> + <200406151730.40464.ftm.van.vugt@foxi.nl> +Comments: In-reply-to Frank van Vugt + message dated "Tue, 15 Jun 2004 17:30:40 +0200" +Date: Tue, 15 Jun 2004 14:04:41 -0400 +Message-ID: <3139.1087322681@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/158 +X-Sequence-Number: 7216 + +Frank van Vugt writes: +> When the 'article.id < 50' constraint is added, it follows that +> 'foo.article_id < 50' is a constraint as well. Why is this constraint not +> used to avoid the seqscan on package? + +We don't attempt to make every possible inference (and I don't think +you'd like it if we did). The current code will draw inferences about +transitive equality, for instance given a = b and b = c it will infer +a = c, if all three operators involved are mergejoinable. But given +a = b and some arbitrary other constraint on b, it won't consider +substituting a into that other constraint. This example doesn't +persuade me that it would be worth expending the cycles to do so. + +Aside from the sheer cost of planning time, there are semantic +pitfalls to consider. In some datatypes there are values that are +"equal" according to the = operator but are distinguishable by other +operators --- for example, zero and minus zero in IEEE-standard +float arithmetic. We'd need a great deal of caution in determining +what inferences can be drawn. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jun 20 15:16:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E4750D1CAF5 + for ; + Tue, 15 Jun 2004 18:30: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 25468-05 + for ; + Tue, 15 Jun 2004 21:30:44 +0000 (GMT) +Received: from bache.ece.cmu.edu (BACHE.ECE.CMU.EDU [128.2.129.23]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EE66D1CA34 + for ; + Tue, 15 Jun 2004 18:30:05 -0300 (ADT) +Received: from elysium.pdl.cmu.edu (ELYSIUM.PDL.CMU.EDU [128.2.134.97]) + by bache.ece.cmu.edu (Postfix) with SMTP id C6B8D73F + for ; + Tue, 15 Jun 2004 17:29:59 -0400 (EDT) +Date: Tue, 15 Jun 2004 17:29:59 -0400 (EDT) +From: Stan Bielski +X-Sender: bielski@elysium.pdl.cmu.edu +To: pgsql-performance@postgresql.org +Subject: Indexing question +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/207 +X-Sequence-Number: 7265 + +Hello all, + +I have a rather large table (~20 GB) of network logs taken over the period +of a month and stored under postgres 7.3. I'm trying to create an indexing +scheme so that I can do a query with a "where time > foo and time < bar" +and get the results without too much waiting. With this in mind, I created +a new database ordering each log entry by the time values (seconds, and +microseconds), and then created an index on the time value for seconds. I +didn't use the clusterdb command, but I did do a "select * into foo_tbl +order by time", which I understand to be the functional equivalent. The +result looks something like this: + + Table "public.allflow_tv_mydoom" + Column | Type | Modifiers +------------+---------+----------- + tv_s | bigint | + tv_us | bigint | + src | inet | + dst | inet | + sport | integer | + dport | integer | + bytes_in | bigint | + bytes_out | bigint | + isn_in | bigint | + isn_out | bigint | + num_starts | integer | + result | integer | + flags | integer | + age_s | bigint | + age_us | bigint | + ttl_left | bigint | + end_s | bigint | + end_us | bigint | +Indexes: allflow_tv_mydoom_x btree (tv_s) + +with tv_s, of course, being my value in seconds. I followed this up with +an ANALYZE so postrgres could absorb this structure into its logic. +However, whenever I want to do my query, it *insists* on doing a +sequential scan, even when I explicitly turn sequential scan off in +postgres.conf... here's an example: + +standb=# explain select * from allflow_tv_mydoom where tv_s < 1074200099 +and tv_s > 107506499; + QUERY PLAN +----------------------------------------------------------------------------------- + Seq Scan on allflow_tv_mydoom (cost=100000000.00..102303307.94 rows=1 +width=132) + Filter: ((tv_s < 1074200099) AND (tv_s > 107506499)) +(2 rows) + +In this query I'm basically asking for a day's worth of data. It should be +straightforward: it's all laid out in order and indexed, but it still +insists on (what I believe to be) tearing through the entire DB and +filtering out the other time values as it sees them. Even if I want just +the data from a particular second, it does the same thing: + +standb=# explain select * from allflow_tv_mydoom where tv_s = 1074200099; + QUERY PLAN +------------------------------------------------------------------------------------- + Seq Scan on allflow_tv_mydoom (cost=100000000.00..102140682.45 rows=145 +width=132) + Filter: (tv_s = 1074200099) +(2 rows) + +Naturally, this is incredibly frustrating because it takes forever, +regardless of the query. + +The funny thing though is that I have the same data in another table +where it is ordered and indexed by IP address, and the queries use the +index and work the way I want them to. Example: + +standb=# explain select * from flow_ip_mydoom where src = '10.0.5.5'; + QUERY PLAN +--------------------------------------------------------------------------------------------- + Index Scan using flow_ip_mydoom_x on flow_ip_mydoom (cost=0.00..333.41 +rows=376 width=132) + Index Cond: (src = '10.0.5.5'::inet) +(2 rows) + +Can someone please explain to me what's going on and how to fix it? If +there's an easier way to 'jump' to different time regions in the table +without indexing all the different seconds values, I'd like to know this +as well. + +Thanks a bunch, +-S + + + + + +From pgsql-performance-owner@postgresql.org Wed Jun 16 05:42:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B2736D1B1BE + for ; + Wed, 16 Jun 2004 05:42: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 17259-08 + for ; + Wed, 16 Jun 2004 08:42:16 +0000 (GMT) +Received: from gatefox.foxi.nl (foxi.xs4all.nl [194.109.246.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 68DAAD1B193 + for ; + Wed, 16 Jun 2004 05:42:12 -0300 (ADT) +Received: from techfox.foxi (techfox.foxi [192.168.0.79]) + by gatefox.foxi.nl (8.10.2-20030922/8.10.2) with ESMTP id i5G8gAu19362; + Wed, 16 Jun 2004 10:42:10 +0200 +From: Frank van Vugt +Organization: Foxi Consultants in Technology BV +To: Tom Lane +Subject: Re: why is a constraint not 'pushed down' into a subselect when this + subselect is using a 'group by' ?? +Date: Wed, 16 Jun 2004 10:42:10 +0200 +User-Agent: KMail/1.5.4 +References: <200406150849.29470.ftm.van.vugt@foxi.nl> + <200406151730.40464.ftm.van.vugt@foxi.nl> + <3139.1087322681@sss.pgh.pa.us> +In-Reply-To: <3139.1087322681@sss.pgh.pa.us> +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406161042.10259.ftm.van.vugt@foxi.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/159 +X-Sequence-Number: 7217 + +> We don't attempt to make every possible inference (and I don't think +> you'd like it if we did). + +I wasn't really asking you to, either ;)) + +Just trying to achieve a more in-depth understanding of the way things work. + +> This example doesn't +> persuade me that it would be worth expending the cycles to do so. + +In the real thing I can easily get good processing times by adding an extra +join with article inside in the group by and simply use the constraint on +that as well, so I'm ok with any choice you make on this. + +I thought this might have been some kind of special case though, given its +occurence on the use of group by. + +> for example, zero and minus zero in IEEE-standard float arithmetic. + +Good example, brings back a few memories as well ;) + + + + +Thanks for your explanation, Tom! + + + +-- +Best, + + + + +Frank. + + +From pgsql-performance-owner@postgresql.org Wed Jun 16 11:00:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A5DDD1B7D5 + for ; + Wed, 16 Jun 2004 11:00: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 28198-03 + for ; + Wed, 16 Jun 2004 14:00:55 +0000 (GMT) +Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com + [209.202.205.1]) + by svr1.postgresql.org (Postfix) with SMTP id 80298D1B7C1 + for ; + Wed, 16 Jun 2004 11:00:50 -0300 (ADT) +Received: (qmail 27693 invoked from network); 16 Jun 2004 14:05:47 -0000 +Received: from dhcp-10-124-7-36.ma.lycos.com (HELO ?10.124.7.36?) + (10.124.7.36) + by dhcp-7-248.ma.lycos.com with SMTP; 16 Jun 2004 14:05:47 -0000 +Mime-Version: 1.0 (Apple Message framework v613) +Content-Transfer-Encoding: 7bit +Message-Id: +Content-Type: text/plain; charset=US-ASCII; format=flowed +To: Postgres Performance +From: Jeff +Subject: Visual Explain +Date: Wed, 16 Jun 2004 10:01:32 -0400 +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/160 +X-Sequence-Number: 7218 + +I've known about this tool for a while, but it seems many people do not +know of its existence and I think it would be useful to a lot of people +who have a hard time reading explain analyze output. (And even those +who can read them without blinking.. when you get deep in join hell it +gets tricky!) + +Red Hat Visual Explain - part of Red Hat Database. + +It is what the name implies - a graphical (java) program to draw a +picture of your query plan (along with all the juicy information +explain analyze provides). I just tried it out today and after +upgrading my JDBC to 7.4 it worked fine (If you get a message about SET +AUTOCOMMIT then you need to upgrade your jdbc jar) + +Quite handy for getting a grasp on stupidly large query plans. + +http://sources.redhat.com/rhdb/visualexplain.html + +I used the CVS version, I have no idea how well the "official" releases +work. +Anyone else using it? + + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Wed Jun 16 16:15:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 04413D1B8E8 + for ; + Wed, 16 Jun 2004 16:15: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 01804-05 + for ; + Wed, 16 Jun 2004 19:15:30 +0000 (GMT) +Received: from zaphod.uchicago.edu (zaphod.uchicago.edu [128.135.72.61]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DB01D1B7D4 + for ; + Wed, 16 Jun 2004 16:15:27 -0300 (ADT) +Received: from [128.135.72.37] (mathlab09.uchicago.edu [128.135.72.37]) + by zaphod.uchicago.edu (8.12.10/8.12.10) with ESMTP id i5GJFSwc004156 + for ; Wed, 16 Jun 2004 14:15:28 -0500 +Subject: Basic Postgresql Performance Question +From: Bill +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Message-Id: <1087413327.3207.9.camel@mathlab09.uchicago.edu> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Wed, 16 Jun 2004 14:15:27 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/161 +X-Sequence-Number: 7219 + +Hi, +I currently have a mysql server running with a database of around 800 +gb. The problem is that the server is old (500 MHz Pentium III with 512 +MB RAM) and I want to change this to a new server and convert the +existing database to Postgresql on Debian (I assume that Postgresql +offers better performance for complex read only queries on large +databases), though I was wondering if + +1. It is possible to have some sort of load-balancing through buying +many computers without replication, i.e have one server which has the +databases and then other servers which has no database but just exists +to balance the memory and processor load? (I have heard this is possible +with C-JDBC)It is difficult to have enough space to replicate a 600 gb +database across all computers) + +2. It is advantageous to buy AMD 64 rather than the Pentium IV? + +Any thoughts? +Thanks. + + +From pgsql-performance-owner@postgresql.org Wed Jun 16 16:36:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 98F6ED1B7C1 + for ; + Wed, 16 Jun 2004 16: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 31542-06 + for ; + Wed, 16 Jun 2004 19:36:07 +0000 (GMT) +Received: from relay.snowman.net (snowman.net [66.93.83.236]) + by svr1.postgresql.org (Postfix) with ESMTP id 283DCD1B7BD + for ; + Wed, 16 Jun 2004 16:35:58 -0300 (ADT) +Received: from ns.snowman.net (ns.snowman.net [10.10.0.2]) + by relay.snowman.net (8.12.11/8.12.11/Debian-5) with ESMTP id + i5GJZoZu015009; Wed, 16 Jun 2004 15:35:50 -0400 +Received: from ns.snowman.net (localhost [127.0.0.1]) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) with ESMTP id + i5GJZuSe025757; Wed, 16 Jun 2004 15:35:56 -0400 +Received: (from sfrost@localhost) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) id i5GJZuaM025755; + Wed, 16 Jun 2004 15:35:56 -0400 +Date: Wed, 16 Jun 2004 15:35:56 -0400 +From: Stephen Frost +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: Basic Postgresql Performance Question +Message-ID: <20040616193556.GB11196@ns.snowman.net> +Mail-Followup-To: Bill , + pgsql-performance@postgresql.org +References: <1087413327.3207.9.camel@mathlab09.uchicago.edu> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="keTKGFoko14kU3Kt" +Content-Disposition: inline +In-Reply-To: <1087413327.3207.9.camel@mathlab09.uchicago.edu> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 15:25:17 up 137 days, 14:30, 6 users, load average: 0.23, 0.15, 0.14 +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/162 +X-Sequence-Number: 7220 + +--keTKGFoko14kU3Kt +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +* Bill (bill@math.uchicago.edu) wrote: +> I currently have a mysql server running with a database of around 800 +> gb. The problem is that the server is old (500 MHz Pentium III with 512 +> MB RAM) and I want to change this to a new server and convert the +> existing database to Postgresql on Debian (I assume that Postgresql +> offers better performance for complex read only queries on large +> databases), though I was wondering if + +Excellent plan. If you're looking at using Debian stable I'd encourage +you to consider using the PostgreSQL back-port of 7.4.2 to Debian stable +on backports.org. + +> 1. It is possible to have some sort of load-balancing through buying +> many computers without replication, i.e have one server which has the +> databases and then other servers which has no database but just exists +> to balance the memory and processor load? (I have heard this is possible +> with C-JDBC)It is difficult to have enough space to replicate a 600 gb +> database across all computers) + +I don't think so... There's something called OpenMosix which does this +on independent processes but not for threaded programs (since it doesn't +make sense to split them across different nodes if they're accessing the +same memory- every memory access would have to be checked) like the +PostgreSQL server. + +> 2. It is advantageous to buy AMD 64 rather than the Pentium IV? + +Personally, I certainly think so. More registers, more memory possible +inside one application, other stuff... + + Stephen + +--keTKGFoko14kU3Kt +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQFA0KEbrzgMPqB3kigRAuYLAJ0RIscGdnZCpZIxqVat7MVeVlVC6gCgkb8k +95NB54VmDIyEnN/s0+AAu0Q= +=U8cG +-----END PGP SIGNATURE----- + +--keTKGFoko14kU3Kt-- + +From pgsql-performance-owner@postgresql.org Wed Jun 16 17:09:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C62E3D1B193 + for ; + Wed, 16 Jun 2004 17:09: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 92195-01 + for ; + Wed, 16 Jun 2004 20:09:27 +0000 (GMT) +Received: from mail.speedfc.com (66-136-75-131.ded.swbell.net [66.136.75.131]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A04AD1BAF8 + for ; + Wed, 16 Jun 2004 17:09:20 -0300 (ADT) +Received: from [172.25.96.149] (unknown [172.25.96.149]) + by mail.speedfc.com (Postfix) with ESMTP + id 3A6159599; Wed, 16 Jun 2004 15:08:08 -0500 (CDT) +Message-ID: <40D0A8C6.8050803@speedfc.com> +Date: Wed, 16 Jun 2004 15:08:38 -0500 +From: Kevin Barnard +Organization: SpeedFC +User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Stephen Frost +Cc: Bill , pgsql-performance@postgresql.org +Subject: Re: Basic Postgresql Performance Question +References: <1087413327.3207.9.camel@mathlab09.uchicago.edu> + <20040616193556.GB11196@ns.snowman.net> +In-Reply-To: <20040616193556.GB11196@ns.snowman.net> +Content-Type: multipart/alternative; + boundary="------------040507000004070903050909" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: * +X-Archive-Number: 200406/163 +X-Sequence-Number: 7221 + +This is a multi-part message in MIME format. +--------------040507000004070903050909 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +Stephen Frost wrote: + +>>1. It is possible to have some sort of load-balancing through buying +>>many computers without replication, i.e have one server which has the +>>databases and then other servers which has no database but just exists +>>to balance the memory and processor load? (I have heard this is possible +>>with C-JDBC)It is difficult to have enough space to replicate a 600 gb +>>database across all computers) +>> +>> +> +>I don't think so... There's something called OpenMosix which does this +>on independent processes but not for threaded programs (since it doesn't +>make sense to split them across different nodes if they're accessing the +>same memory- every memory access would have to be checked) like the +>PostgreSQL server. +> +> +> +Look at www.linuxlabs.com they have a clustering system. Not exactly +the same thing but close to what I think you are looking for. + +-- +Kevin Barnard + + + +--------------040507000004070903050909 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+Stephen Frost wrote:
+
+
+
1.  It is possible to have some sort of load-balancing through buying
+many computers without replication, i.e have one server which has the
+databases and then other servers which has no database but just exists
+to balance the memory and processor load? (I have heard this is possible
+with C-JDBC)It is difficult to have enough space to replicate a 600 gb
+database across all computers)
+    
+
+

+I don't think so...  There's something called OpenMosix which does this
+on independent processes but not for threaded programs (since it doesn't
+make sense to split them across different nodes if they're accessing the
+same memory- every memory access would have to be checked) like the
+PostgreSQL server.
+
+  
+
+Look at www.linuxlabs.com they have a clustering system.  Not exactly +the same thing but close to what I think you are looking for.
+
-- 
+Kevin Barnard
+
+
+ + + +--------------040507000004070903050909-- + +From pgsql-performance-owner@postgresql.org Wed Jun 16 17:18:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FD02D1BAF5 + for ; + Wed, 16 Jun 2004 17:18: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 00519-05 + for ; + Wed, 16 Jun 2004 20:18:26 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id AE378D1B1BE + for ; + Wed, 16 Jun 2004 17:18:19 -0300 (ADT) +Received: (qmail 28564 invoked by uid 0); 16 Jun 2004 19:49:50 -0000 +Received: from mpls-pop-11.inet.qwest.net (63.231.195.11) + by mpls-qmqp-03.inet.qwest.net with QMQP; 16 Jun 2004 19:49:50 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-11.inet.qwest.net with SMTP; 16 Jun 2004 20:18:20 -0000 +Date: Wed, 16 Jun 2004 14:18:45 -0600 +Message-Id: <1087417125.1582.47.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Bill" +Cc: pgsql-performance@postgresql.org +Subject: Re: Basic Postgresql Performance Question +In-Reply-To: <1087413327.3207.9.camel@mathlab09.uchicago.edu> +References: <1087413327.3207.9.camel@mathlab09.uchicago.edu> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/164 +X-Sequence-Number: 7222 + +On Wed, 2004-06-16 at 13:15, Bill wrote: +> Hi, +> I currently have a mysql server running with a database of around 800 +> gb. The problem is that the server is old (500 MHz Pentium III with 512 +> MB RAM) and I want to change this to a new server and convert the +> existing database to Postgresql on Debian (I assume that Postgresql +> offers better performance for complex read only queries on large +> databases), + +Usually, but there are always queries that run faster or slower on a +given database due to differences in architecture and design. For +instance PostgreSQL tends to be slow when doing max/min aggs, but faster +when doing things involving complex joins and unions. + +> though I was wondering if +> +> 1. It is possible to have some sort of load-balancing through buying +> many computers without replication, i.e have one server which has the +> databases and then other servers which has no database but just exists +> to balance the memory and processor load? (I have heard this is possible +> with C-JDBC)It is difficult to have enough space to replicate a 600 gb +> database across all computers) + +That depends. Most databases are first I/O bound, then memory bound, +then CPU bound, in that order. With an 800Gb database your main "cost" +is gonna be moving data off of the platters and into memory, then having +the memory to hold the working sets, then the CPU to mush it together. + +Now, if you're reading only tiny portions at a time, but doing lots of +strange work on them, say weather forcasting, then you might be CPU +bound. But without knowing what your usage patterns are like, we don't +know whether or not running on multiple boxes would help. There are +replication systems, but there's no such thing as a free lunch. + +> 2. It is advantageous to buy AMD 64 rather than the Pentium IV? + +Yes and no. If having more than 2 gigs of ram is important, 64 bit +architecures run faster than 32 bit, where having over 2 gigs usually +results in a slow down due to the memory switching they use. + + +From pgsql-performance-owner@postgresql.org Wed Jun 16 17:49:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 55073D1B1B7 + for ; + Wed, 16 Jun 2004 17:49: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 51006-01 + for ; + Wed, 16 Jun 2004 20:49:23 +0000 (GMT) +Received: from relay.snowman.net (snowman.net [66.93.83.236]) + by svr1.postgresql.org (Postfix) with ESMTP id B6C10D1B18C + for ; + Wed, 16 Jun 2004 17:49:19 -0300 (ADT) +Received: from ns.snowman.net (ns.snowman.net [10.10.0.2]) + by relay.snowman.net (8.12.11/8.12.11/Debian-5) with ESMTP id + i5GKnCTr016304; Wed, 16 Jun 2004 16:49:12 -0400 +Received: from ns.snowman.net (localhost [127.0.0.1]) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) with ESMTP id + i5GKnIC9029875; Wed, 16 Jun 2004 16:49:18 -0400 +Received: (from sfrost@localhost) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) id i5GKnIjR029873; + Wed, 16 Jun 2004 16:49:18 -0400 +Date: Wed, 16 Jun 2004 16:49:18 -0400 +From: Stephen Frost +To: Scott Marlowe +Cc: Bill , pgsql-performance@postgresql.org +Subject: Re: Basic Postgresql Performance Question +Message-ID: <20040616204917.GC11196@ns.snowman.net> +Mail-Followup-To: Scott Marlowe , + Bill , pgsql-performance@postgresql.org +References: <1087413327.3207.9.camel@mathlab09.uchicago.edu> + <1087417125.1582.47.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="A+dGWgJqhC09RTtY" +Content-Disposition: inline +In-Reply-To: <1087417125.1582.47.camel@localhost.localdomain> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 16:47:09 up 137 days, 15:52, 6 users, load average: 0.17, 0.25, 0.26 +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/165 +X-Sequence-Number: 7223 + +--A+dGWgJqhC09RTtY +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* Scott Marlowe (smarlowe@qwest.net) wrote: +> On Wed, 2004-06-16 at 13:15, Bill wrote: +> > 2. It is advantageous to buy AMD 64 rather than the Pentium IV? +>=20 +> Yes and no. If having more than 2 gigs of ram is important, 64 bit +> architecures run faster than 32 bit, where having over 2 gigs usually +> results in a slow down due to the memory switching they use. + +This is truer on more traditional 64bit platforms than on amd64 which +has more differences than just the ability to handle 64bit size things. +amd64 also gives you access to more registers than were on the +register-starved i386 platforms which increases the speed for most +applications where it usually wouldn't when recompiled for 64bit. + + Stephen + +--A+dGWgJqhC09RTtY +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQFA0LJNrzgMPqB3kigRAqj1AKCAuNVeEW1XBu+RIbCCraTqSsVorgCdE48V +U6+Yn7GgHV28Zs7X6CMq8A0= +=YR0r +-----END PGP SIGNATURE----- + +--A+dGWgJqhC09RTtY-- + +From pgsql-performance-owner@postgresql.org Wed Jun 16 21:33:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D44CD1B215 + for ; + Wed, 16 Jun 2004 21:33: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 26068-07 + for ; + Thu, 17 Jun 2004 00:33:42 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 67925D1B1B7 + for ; + Wed, 16 Jun 2004 21:33:37 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5387498; Wed, 16 Jun 2004 17:35:18 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "'borajetta'" +Subject: Re: 50 000 000 Table entries and I have to do a keyword search HELP + NEEDED +Date: Wed, 16 Jun 2004 17:33:37 -0700 +User-Agent: KMail/1.5.4 +Cc: "Postgresql Performance" +References: <000601c452d6$68263570$4f01a8c0@jeremydunn> +In-Reply-To: <000601c452d6$68263570$4f01a8c0@jeremydunn> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406161733.37285.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200406/166 +X-Sequence-Number: 7224 + +Borajetta, + +The other thing you can do is take a look at your hardware. What are you +running this on? How much RAM? Are other things running on this server as +well? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Jun 17 08:10:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1123ED1B267 + for ; + Thu, 17 Jun 2004 08: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 20208-05 + for ; + Thu, 17 Jun 2004 11:10:08 +0000 (GMT) +Received: from mailhub2.sghms.ac.uk (firewall.sghms.ac.uk [194.82.50.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AE781D1B1BE + for ; + Thu, 17 Jun 2004 08:10:03 -0300 (ADT) +Received: from [194.82.51.24] (helo=imail) + by mailhub2.sghms.ac.uk with esmtp (Exim 4.24) + id 1BaumP-0004N0-OS; Thu, 17 Jun 2004 12:10:01 +0100 +Received: from [172.16.20.3] (mrc1-003.sghms.ac.uk [172.16.20.3]) + by imail.sghms.ac.uk + (iPlanet Messaging Server 5.2 Patch 1 (built Aug 19 2002)) with ESMTPA + id <0HZG00JEA9OPBA@imail.sghms.ac.uk>; + Thu, 17 Jun 2004 12:10:01 +0100 (BST) +Date: Thu, 17 Jun 2004 12:10:30 +0100 +From: Adam Witney +Subject: Re: Visual Explain +In-reply-to: +To: Jeff , + pgsql-performance +Message-id: +MIME-version: 1.0 +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +User-Agent: Microsoft-Entourage/10.1.1.2418 +X-MailScanner-Information: Please contact sysadmin at sghms.ac.uk for more + information +X-MailScanner-MH2: No Virues detected +X-MailScanner-SpamCheck: not spam, SpamAssassin (score=-1.9, required 5, + APARENTLY_FROM_MYSELF 1.00, BAYES_00 -4.90, FROM_SGHMS -1.00, + MY_OBFUJ 0.50, MY_OBFUT 0.50, MY_OBFUX 0.50, MY_OBFUY 1.00, + MY_OBFU_MISC 0.50) +X-MailScanner-From: awitney@sghms.ac.uk +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/167 +X-Sequence-Number: 7225 + + +Will this run on other platforms? OSX maybe? + +> I've known about this tool for a while, but it seems many people do not +> know of its existence and I think it would be useful to a lot of people +> who have a hard time reading explain analyze output. (And even those +> who can read them without blinking.. when you get deep in join hell it +> gets tricky!) +> +> Red Hat Visual Explain - part of Red Hat Database. +> +> It is what the name implies - a graphical (java) program to draw a +> picture of your query plan (along with all the juicy information +> explain analyze provides). I just tried it out today and after +> upgrading my JDBC to 7.4 it worked fine (If you get a message about SET +> AUTOCOMMIT then you need to upgrade your jdbc jar) +> +> Quite handy for getting a grasp on stupidly large query plans. +> +> http://sources.redhat.com/rhdb/visualexplain.html +> +> I used the CVS version, I have no idea how well the "official" releases +> work. +> Anyone else using it? +> +> +> -- +> Jeff Trout +> http://www.jefftrout.com/ +> http://www.stuarthamm.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 + + +-- +This message has been scanned for viruses and +dangerous content by MailScanner, and is +believed to be clean. + + +From pgsql-general-owner@postgresql.org Thu Jun 17 09:17:36 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EF88AD1B21B + for ; + Thu, 17 Jun 2004 09:17: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 78455-09 + for ; + Thu, 17 Jun 2004 12:17:16 +0000 (GMT) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 22252D1BC4D + for ; + Thu, 17 Jun 2004 09:16:44 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1Bavor-000Nfp-0Z; Thu, 17 Jun 2004 13:16:37 +0100 +Date: Thu, 17 Jun 2004 13:16:34 +0100 +From: Paul Thomas +To: Adam Witney +Cc: "pgsql-general @ postgresql . org" +Subject: Re: [PERFORM] Visual Explain +Message-ID: <20040617131634.C14210@bacon> +References: + +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: ; + from awitney@sghms.ac.uk on Thu, Jun 17, 2004 at 12:10:30 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 16 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/597 +X-Sequence-Number: 61980 + + +On 17/06/2004 12:10 Adam Witney wrote: +> +> Will this run on other platforms? OSX maybe? + +It's a Java app so it runs on any any platform with a reasonably modern +Java VM. + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Thu Jun 17 09:52:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 97367D1B298 + for ; + Thu, 17 Jun 2004 09: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 38071-06 + for ; + Thu, 17 Jun 2004 12:52:29 +0000 (GMT) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 59A53D1BA9E + for ; + Thu, 17 Jun 2004 09:52:16 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BawNO-0003Z4-0Z + for pgsql-performance@postgresql.org; Thu, 17 Jun 2004 13:52:18 +0100 +Date: Thu, 17 Jun 2004 13:52:15 +0100 +From: Paul Thomas +To: "pgsql-performance @ postgresql . org" +Subject: Re: Visual Explain +Message-ID: <20040617135215.A15884@bacon> +References: + <20040617131634.C14210@bacon> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <20040617131634.C14210@bacon>; + from paul@tmsl.demon.co.uk on Thu, Jun 17, 2004 at 13:16:34 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 17 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/168 +X-Sequence-Number: 7226 + + +On 17/06/2004 12:10 Adam Witney wrote: +> +> Will this run on other platforms? OSX maybe? + +It's a Java app so it runs on any any platform with a reasonably modern +Java VM. + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + + +From pgsql-performance-owner@postgresql.org Thu Jun 17 10:37:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BE34ED1B33D + for ; + Thu, 17 Jun 2004 10:37: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 03959-02 + for ; + Thu, 17 Jun 2004 13:36:59 +0000 (GMT) +Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com + [209.202.205.1]) + by svr1.postgresql.org (Postfix) with SMTP id 63E09D1B1D1 + for ; + Thu, 17 Jun 2004 10:36:46 -0300 (ADT) +Received: (qmail 10963 invoked from network); 17 Jun 2004 13:41:57 -0000 +Received: from dhcp-10-124-7-36.ma.lycos.com (HELO ?10.124.7.36?) + (10.124.7.36) + by dhcp-7-248.ma.lycos.com with SMTP; 17 Jun 2004 13:41:57 -0000 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <7A2AAAF2-C063-11D8-810C-000D9366F0C4@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance +From: Jeff +Subject: Re: Visual Explain +Date: Thu, 17 Jun 2004 09:37:29 -0400 +To: Adam Witney +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/169 +X-Sequence-Number: 7227 + + +On Jun 17, 2004, at 7:10 AM, Adam Witney wrote: + +> +> Will this run on other platforms? OSX maybe? +> + +I've run it on both linux (rh8) and osx (panther). + +its java so it *should* run anywhere. + +It isn't the fastest beast in the world though. takes a bit of time to +render the plan. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Thu Jun 17 13:35:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B2C7CD1B3A8 + for ; + Thu, 17 Jun 2004 13:35: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 88422-09 + for ; + Thu, 17 Jun 2004 16:35:34 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FDB3D1B19C + for ; + Thu, 17 Jun 2004 13:35:25 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: in-transaction insert performance in 7.5devel +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Thu, 17 Jun 2004 12:35:19 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AE5E@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] in-transaction insert performance in 7.5devel +Thread-Index: AcRP+18+Dcr3pWI/R2iZpQV8HyfkzgEhm7Jw +From: "Merlin Moncure" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/170 +X-Sequence-Number: 7228 + +> Was that 15% before or after updating from CVS? +>=20 +> The more I think about the looping aspect the less I like it, so I'd +> prefer not to pursue making the unlock change for real. But if it's +> really a 15% win then maybe we need to... +>=20 +> regards, tom lane + +After. So far, I haven't been able to reproduce original the insert +problem. A word of warning: the version I was testing with was patched +with some unapproved patches and that may have been part of the issue. + +Here are my results (10k drive, NTFS): +fsync off, in xact: ~ 398 i/sec +fsync off, outside xact: ~ 369 i/sec +fsync on, in xact: ~ 374 i/sec +fsync on, outside xact: ~ 35 i/sec + +with your code change: +fsync on, in xact: ~ 465 i/sec +fsync on, outside xact: ~ 42 i/sec + +Don't put too much faith in these results. If you are still +contemplating a code change, I'll set up a test unit for more accurate +results and post the code (my current tests are in COBOL).=20=20 + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Jun 17 13:54:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C7A9D1B20D + for ; + Thu, 17 Jun 2004 13:54: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 27920-01 + for ; + Thu, 17 Jun 2004 16:54:43 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) + by svr1.postgresql.org (Postfix) with SMTP id 007DED1B193 + for ; + Thu, 17 Jun 2004 13:54:41 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 34so103937rnh + for ; + Thu, 17 Jun 2004 09:54:41 -0700 (PDT) +Received: by 10.38.97.42 with SMTP id u42mr144294rnb; + Thu, 17 Jun 2004 09:54:41 -0700 (PDT) +Message-ID: +Date: Thu, 17 Jun 2004 19:54:41 +0300 +From: Vitaly Belman +To: Paul Thomas +Subject: Re: Visual Explain +Cc: "pgsql-performance @ postgresql . org" +In-Reply-To: <20040617135215.A15884@bacon> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + + <20040617131634.C14210@bacon> <20040617135215.A15884@bacon> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/171 +X-Sequence-Number: 7229 + +Is it possible to download the Visual Explain only (link)? I only see +that you can donwload the whole ISO (which I hardly need). + +On Thu, 17 Jun 2004 13:52:15 +0100, Paul Thomas wrote: +> +> +> On 17/06/2004 12:10 Adam Witney wrote: +> > +> > Will this run on other platforms? OSX maybe? +> +> It's a Java app so it runs on any any platform with a reasonably modern +> Java VM. +> +> -- +> Paul Thomas +> +------------------------------+---------------------------------------------+ +> | Thomas Micro Systems Limited | Software Solutions for +> Business | +> | Computer Consultants | +> http://www.thomas-micro-systems-ltd.co.uk | +> +------------------------------+---------------------------------------------+ +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + +From pgsql-performance-owner@postgresql.org Thu Jun 17 14:04:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E6ECAD1B193 + for ; + Thu, 17 Jun 2004 14:04: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 29086-04 + for ; + Thu, 17 Jun 2004 17:04:41 +0000 (GMT) +Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com + [209.202.205.1]) + by svr1.postgresql.org (Postfix) with SMTP id 247C5D1B1BE + for ; + Thu, 17 Jun 2004 14:04:39 -0300 (ADT) +Received: (qmail 13369 invoked from network); 17 Jun 2004 17:09:49 -0000 +Received: from dhcp-10-124-7-36.ma.lycos.com (HELO ?10.124.7.36?) + (10.124.7.36) + by dhcp-7-248.ma.lycos.com with SMTP; 17 Jun 2004 17:09:49 -0000 +In-Reply-To: +References: + + <20040617131634.C14210@bacon> <20040617135215.A15884@bacon> + +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <834BC71C-C080-11D8-810C-000D9366F0C4@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: Paul Thomas , + "pgsql-performance @ postgresql . org" + +From: Jeff +Subject: Re: Visual Explain +Date: Thu, 17 Jun 2004 13:05:19 -0400 +To: Vitaly Belman +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/172 +X-Sequence-Number: 7230 + + +On Jun 17, 2004, at 12:54 PM, Vitaly Belman wrote: + +> Is it possible to download the Visual Explain only (link)? I only see +> that you can donwload the whole ISO (which I hardly need). +> +you'll need to snag it out of cvs: + +http://sources.redhat.com/rhdb/cvs.html + +You can checkout just visual explain so you won't need to grab +everything. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Thu Jun 17 14:36:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0451AD1B34B + for ; + Thu, 17 Jun 2004 14:36: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 53888-06 + for ; + Thu, 17 Jun 2004 17:35:51 +0000 (GMT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 074D1D1B20E + for ; + Thu, 17 Jun 2004 14:35:23 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) + id 1Bb0nD-000Jfb-0V; Thu, 17 Jun 2004 18:35:15 +0100 +Date: Thu, 17 Jun 2004 18:35:11 +0100 +From: Paul Thomas +To: Vitaly Belman +Cc: "pgsql-performance @ postgresql . org" +Subject: Re: Visual Explain +Message-ID: <20040617183511.E15884@bacon> +References: + + <20040617131634.C14210@bacon> <20040617135215.A15884@bacon> + +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: ; + from vitalyb@gmail.com on Thu, Jun 17, 2004 at 17:54:41 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 14 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/173 +X-Sequence-Number: 7231 + +On 17/06/2004 17:54 Vitaly Belman wrote: +> Is it possible to download the Visual Explain only (link)? I only see +> that you can donwload the whole ISO (which I hardly need). + +You can get it from CVS and build it yourself. + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Thu Jun 17 15:14:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 154F8D1B20D + for ; + Thu, 17 Jun 2004 15: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 96164-04 + for ; + Thu, 17 Jun 2004 18:13:56 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.201]) + by svr1.postgresql.org (Postfix) with SMTP id 6C958D1B1BE + for ; + Thu, 17 Jun 2004 15:13:52 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 34so105727rnh + for ; + Thu, 17 Jun 2004 11:13:42 -0700 (PDT) +Received: by 10.38.97.42 with SMTP id u42mr146185rnb; + Thu, 17 Jun 2004 11:13:42 -0700 (PDT) +Message-ID: +Date: Thu, 17 Jun 2004 21:13:41 +0300 +From: Vitaly Belman +To: Paul Thomas +Subject: Re: Visual Explain +Cc: "pgsql-performance @ postgresql . org" +In-Reply-To: <20040617183511.E15884@bacon> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + + <20040617131634.C14210@bacon> <20040617135215.A15884@bacon> + + <20040617183511.E15884@bacon> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/174 +X-Sequence-Number: 7232 + +I see. Thanks :). + +On Thu, 17 Jun 2004 18:35:11 +0100, Paul Thomas wrote: +> +> On 17/06/2004 17:54 Vitaly Belman wrote: +> > Is it possible to download the Visual Explain only (link)? I only see +> > that you can donwload the whole ISO (which I hardly need). +> +> You can get it from CVS and build it yourself. +> +> +> +> -- +> Paul Thomas +> +------------------------------+---------------------------------------------+ +> | Thomas Micro Systems Limited | Software Solutions for +> Business | +> | Computer Consultants | +> http://www.thomas-micro-systems-ltd.co.uk | +> +------------------------------+---------------------------------------------+ +> + +From pgsql-performance-owner@postgresql.org Thu Jun 17 17:21:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 45423D1B21B + for ; + Thu, 17 Jun 2004 17:21: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 20989-10 + for ; + Thu, 17 Jun 2004 20:21:23 +0000 (GMT) +Received: from fdd00lnhub.federated.fds (external.fds.com [208.15.90.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C7AFAD1B20D + for ; + Thu, 17 Jun 2004 17:21:07 -0300 (ADT) +Subject: Slow vacuum performance +To: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 6.0 September 26, 2002 +Message-ID: + +From: Patrick Hatcher +Date: Thu, 17 Jun 2004 13:09:47 -0700 +X-MIMETrack: Serialize by Router on FDD00LNHUB/FSG/SVR/FDD(Release + 6.0|September 26, 2002) at 06/17/2004 03:58:44 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/175 +X-Sequence-Number: 7233 + + + + + +Pg: 7.4.2 +RedHat 7.3 +Ram: 8gig + +I have 6 million row table that I vacuum full analyze each night. The time +seems to be streching out further and further as I add more rows. I read +the archives and Josh's annotated pg.conf guide that setting the FSM higher +might help. Currently, my memory settings are set as such. Does this seem +low? + +Last reading from vaccum verbose: + INFO: analyzing "cdm.cdm_ddw_customer" +INFO: "cdm_ddw_customer": 209106 pages, 3000 rows sampled, 6041742 +estimated total rows +>>I think I should now set my max FSM to at least 210000 but wanted to make +sure + +shared_buffers = 2000 # min 16, at least max_connections*2, 8KB +each +sort_mem = 12288 # min 64, size in KB + +# - Free Space Map - + +max_fsm_pages = 100000 # min max_fsm_relations*16, 6 bytes each +#max_fsm_relations = 1000 # min 100, ~50 bytes each + + +TIA + +Patrick Hatcher +Macys.Com + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 01:31:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C9915D1B1B7 + for ; + Fri, 18 Jun 2004 01:30: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 12176-10 + for ; + Fri, 18 Jun 2004 04:30:17 +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 55B99D1B19C + for ; + Fri, 18 Jun 2004 01:30:14 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 8C3468469; Fri, 18 Jun 2004 06:30:12 +0200 (CEST) +Date: Fri, 18 Jun 2004 06:30:12 +0200 (CEST) +From: Dennis Bjorklund +To: Patrick Hatcher +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow vacuum performance +In-Reply-To: + +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/176 +X-Sequence-Number: 7234 + +On Thu, 17 Jun 2004, Patrick Hatcher wrote: + +> I have 6 million row table that I vacuum full analyze each night. The time +> seems to be streching out further and further as I add more rows. I read + +You could try to run normal (non full) vacuum every hour or so. If you do +normal vacuum often enough you probably don't need to run vacuum full at +all. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 05:17:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D4F72D1B753 + for ; + Fri, 18 Jun 2004 05:16: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 03449-08 + for ; + Fri, 18 Jun 2004 08:16:48 +0000 (GMT) +Received: from lamb.mcmillan.net.nz (218-101-13-11.paradise.net.nz + [218.101.13.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 136DFD1B745 + for ; + Fri, 18 Jun 2004 05:16:44 -0300 (ADT) +Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) + by lamb.mcmillan.net.nz (Postfix) with ESMTP id 06EE2AD98593; + Fri, 18 Jun 2004 20:15:45 +1200 (NZST) +Subject: Re: Slow vacuum performance +From: Andrew McMillan +To: Patrick Hatcher +Cc: pgsql-performance@postgresql.org +In-Reply-To: + +References: + +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-kDBQE+zc4SvUPN38qC0O" +Date: Fri, 18 Jun 2004 20:15:44 +1200 +Message-Id: <1087546544.4942.50.camel@lamb.mcmillan.net.nz> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.9.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/177 +X-Sequence-Number: 7235 + +--=-kDBQE+zc4SvUPN38qC0O +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Thu, 2004-06-17 at 13:09 -0700, Patrick Hatcher wrote: +>=20 +>=20 +>=20 +> Pg: 7.4.2 +> RedHat 7.3 +> Ram: 8gig +>=20 +> I have 6 million row table that I vacuum full analyze each night. The ti= +me +> seems to be streching out further and further as I add more rows. I read +> the archives and Josh's annotated pg.conf guide that setting the FSM high= +er +> might help. Currently, my memory settings are set as such. Does this se= +em +> low? +>=20 +> Last reading from vaccum verbose: +> INFO: analyzing "cdm.cdm_ddw_customer" +> INFO: "cdm_ddw_customer": 209106 pages, 3000 rows sampled, 6041742 +> estimated total rows +> >>I think I should now set my max FSM to at least 210000 but wanted to ma= +ke +> sure + +Yes, that's my interpretation of those numbers too. I would set +max_fsm_pages to 300000 (or more) in that case. + +If you have 8G of RAM in the machine your shared_buffers seems very low +too. Depending on how it is used I would increase that to at least the +recommended maximum (10000 - 80M). + +You don't quote your setting for effective_cache_size, but you should +probably look at what "/usr/bin/free" reports as "cached", divide that +by 10, and set it to that as a quick rule of thumb... + +Regards, + Andrew McMillan + + +> shared_buffers =3D 2000 # min 16, at least max_connections*2, 8= +KB +> each +> sort_mem =3D 12288 # min 64, size in KB +>=20 +> # - Free Space Map - +>=20 +> max_fsm_pages =3D 100000 # min max_fsm_relations*16, 6 bytes each +> #max_fsm_relations =3D 1000 # min 100, ~50 bytes each +>=20 + +------------------------------------------------------------------------- +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 + Make things as simple as possible, but no simpler -- Einstein +------------------------------------------------------------------------- + +--=-kDBQE+zc4SvUPN38qC0O +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQBA0qSwjJA0f48GgBIRAuR5AKC1ejXqwYqWE9nJ1rtpauuLesl/SgCfSSke +49klbZPZjmi226vi/dXJT/k= +=V/w3 +-----END PGP SIGNATURE----- + +--=-kDBQE+zc4SvUPN38qC0O-- + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 05:37:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B647CD1B745 + for ; + Fri, 18 Jun 2004 05:37: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 17248-07 + for ; + Fri, 18 Jun 2004 08:37:34 +0000 (GMT) +Received: from damo.axelero.hu (fe01.axelero.hu [195.228.240.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EFCED1B37D + for ; + Fri, 18 Jun 2004 05:37:30 -0300 (ADT) +Received: from damo (localhost-02 [127.0.2.1]) + by damo.axelero.hu (8.12.11/8.12.11) with SMTP id i5I8bTOK013651 + for ; + Fri, 18 Jun 2004 10:37:30 +0200 (CEST) +Received: from fe01.axelero.hu [127.0.2.1] via SMTP gateway + by damo [195.228.240.89]; id A0352FEEE4B + at Fri, 18 Jun 2004 10:37:29 +0200 +Received: from fejleszt4 (121-248-182-81.adsl-fixip.axelero.hu + [81.182.248.121]) + by fe01.axelero.hu (8.12.11/8.12.11) with SMTP id i5I8bITt013244 + for ; + Fri, 18 Jun 2004 10:37:22 +0200 (CEST) +Message-ID: <008501c4550f$87523a80$0403a8c0@fejleszt4> +From: =?iso-8859-1?Q?SZUCS_G=E1bor?= +To: +References: <200406101624.21739.ftm.van.vugt@foxi.nl> + <40C881FE.5000301@sympatico.ca> <25304.1086883145@sss.pgh.pa.us> + <40C892BA.8080704@sympatico.ca> + <20040610100332.D20710@megazone.bigpanda.com> + <20040610101410.X21002@megazone.bigpanda.com> +Subject: Re: *very* inefficient choice made by the planner (regarding +Date: Fri, 18 Jun 2004 10:37:40 +0200 +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.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/178 +X-Sequence-Number: 7236 + +Dear Gurus, + +----- Original Message ----- +From: "Stephan Szabo" +Sent: Thursday, June 10, 2004 7:14 PM + + +> +> On Thu, 10 Jun 2004, Stephan Szabo wrote: +> +> > +> > On Thu, 10 Jun 2004, Jean-Luc Lachance wrote: +> > +> > > I agree, but it should be a simple rewrite. No? +> > +> > It's NULLs inside the subselect that are the issue. +> > +> > select 1 in (select a from foo) +> > select exists ( select 1 from foo where a=1) + +Just a dumb try :) + + SELECT (exists(select 1 from foo where a isnull) AND NULL) + OR exists(select 1 from foo where a=1) + +AFAIK this returns +* NULL if (NULL in foo.a) and (1 not in foo.a) +* (1 in foo.a) otherwise. + +The weakness is the doubled exists clause. I'm sure it makes most cases at +least doubtful... + +G. +%----------------------- cut here -----------------------% +\end + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 08:32:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69C68D1B188 + for ; + Fri, 18 Jun 2004 08: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 66929-03 + for ; + Fri, 18 Jun 2004 11:32:06 +0000 (GMT) +Received: from web25104.mail.ukl.yahoo.com (web25104.mail.ukl.yahoo.com + [217.12.10.52]) + by svr1.postgresql.org (Postfix) with SMTP id 7C04AD1B18F + for ; + Fri, 18 Jun 2004 08:31:58 -0300 (ADT) +Message-ID: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.com> +Received: from [217.158.107.104] by web25104.mail.ukl.yahoo.com via HTTP; + Fri, 18 Jun 2004 12:31:57 BST +Date: Fri, 18 Jun 2004 12:31:57 +0100 (BST) +From: =?iso-8859-1?q?Gary=20Cowell?= +Subject: Major differences between oracle and postgres performance - what can + I do ? +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/179 +X-Sequence-Number: 7237 + +I'm trying to migrate an application from an Oracle +backend to PostgreSQL and have a performance question. + +The hardware for the database is the same, a SunFire +v120, 2x73GB U2W SCSI disks, 1GB RAM, 650MHz US-IIe +CPU. Running Solaris 8. + +The table in question has 541741 rows. Under Oracle, +the query ' select distinct version from vers where +version is not null ' returns 534 rows in 6.14 +seconds, with an execution plan showing a table scan +of vers followed by a sort. + +The explain output on postgres shows the same +execution with a scan on vers and a sort but the query +time is 78.6 seconds. + +The explain output from PostgreSQL is: + QUERY PLAN +--------------------------------------------------------------------------------- + Unique (cost=117865.77..120574.48 rows=142 +width=132) + -> Sort (cost=117865.77..119220.13 rows=541741 +width=132) + Sort Key: "version" + -> Seq Scan on vers (cost=0.00..21367.41 +rows=541741 width=132) + Filter: ("version" IS NOT NULL) + +I do have an index on the column in question but +neither oracle nor postgresql choose to use it (which +given that we're visiting all rows is perhaps not +surprising). + +I'm not as familiar with postgresql as I am with +Oracle but I think I've configured comparible +buffering and sort area sizes, certainly there isn't +much physical IO going on in either case. + +What can I do to speed up this query? Other queries +are slightly slower than under Oracle on the same +hardware but nothing like this. + +Thanks! + +G + + + + + +___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com + +From pgsql-performance-owner@postgresql.org Fri Jun 18 09:07:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB454D1B34B + for ; + Fri, 18 Jun 2004 09:07: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 91424-10 + for ; + Fri, 18 Jun 2004 12:07:38 +0000 (GMT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 46CBAD1B298 + for ; + Fri, 18 Jun 2004 09:07:34 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BbI9Y-0009fg-0V; Fri, 18 Jun 2004 13:07:31 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 9DFF517A96; Fri, 18 Jun 2004 13:07:15 +0100 (BST) +Message-ID: <40D2DAF3.2080107@archonet.com> +Date: Fri, 18 Jun 2004 13:07:15 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gary Cowell +Cc: pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance +References: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.com> +In-Reply-To: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/180 +X-Sequence-Number: 7238 + +Gary Cowell wrote: +> +> I'm not as familiar with postgresql as I am with +> Oracle but I think I've configured comparible +> buffering and sort area sizes, certainly there isn't +> much physical IO going on in either case. + +People are going to want to know: +1. version of PG +2. explain analyse output, rather than just explain +3. What values you've used for the postgresql.conf file + +The actual plan from explain analyse isn't going to be much use - as you +say, a scan of the whole table followed by sorting is the best you'll +get. However, the actual costs of these steps might say something useful. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Jun 18 09:10:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A98BFD1B20D + for ; + Fri, 18 Jun 2004 09:09: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 12692-03 + for ; + Fri, 18 Jun 2004 12:09:37 +0000 (GMT) +Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id BF8C1D1B1D0 + for ; + Fri, 18 Jun 2004 09:09:32 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BbIBW-0002vU-0b; Fri, 18 Jun 2004 13:09:30 +0100 +Date: Fri, 18 Jun 2004 13:09:27 +0100 +From: Paul Thomas +To: Gary Cowell +Cc: pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +Message-ID: <20040618130927.A17585@bacon> +References: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.com>; + from gary_cowell@yahoo.co.uk on Fri, Jun 18, 2004 at 12:31:57 + +0100 +X-Mailer: Balsa 1.2.3 +Lines: 26 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/181 +X-Sequence-Number: 7239 + + +On 18/06/2004 12:31 Gary Cowell wrote: +> [snip] +> I'm not as familiar with postgresql as I am with +> Oracle but I think I've configured comparible +> buffering and sort area sizes, certainly there isn't +> much physical IO going on in either case. +> +> What can I do to speed up this query? Other queries +> are slightly slower than under Oracle on the same +> hardware but nothing like this. + +Usual questions: + +have you vacuumed the table recently? +what are your postgresql.conf settings? +can you show us explain ANALYZE output rather than just explain output? + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Fri Jun 18 09:13:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B0D2D1B75C + for ; + Fri, 18 Jun 2004 09:13: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 22752-02 + for ; + Fri, 18 Jun 2004 12:13:46 +0000 (GMT) +Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com + [209.202.205.1]) + by svr1.postgresql.org (Postfix) with SMTP id 89929D1B3A8 + for ; + Fri, 18 Jun 2004 09:13:38 -0300 (ADT) +Received: (qmail 26619 invoked from network); 18 Jun 2004 12:19:03 -0000 +Received: from dhcp-10-124-7-36.ma.lycos.com (HELO ?10.124.7.36?) + (10.124.7.36) + by dhcp-7-248.ma.lycos.com with SMTP; 18 Jun 2004 12:19:03 -0000 +In-Reply-To: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.com> +References: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.com> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <082CB838-C121-11D8-810C-000D9366F0C4@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +Date: Fri, 18 Jun 2004 08:14:22 -0400 +To: Gary Cowell +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/182 +X-Sequence-Number: 7240 + + +On Jun 18, 2004, at 7:31 AM, Gary Cowell wrote: + +> The explain output on postgres shows the same +> execution with a scan on vers and a sort but the query +> time is 78.6 seconds. +> + +Does it run just as slow if you run it again? +It could be a case of the caches being empty + +> Oracle but I think I've configured comparible +> buffering and sort area sizes, certainly there isn't +> much physical IO going on in either case. +> + +Configuring PG like Oracle isn't the best thing in the world. The +general PG philosophy is to let the OS do all the caching & buffering +- this is reversed in the Oracle world. In 7.4 the rule of thumb is no +more than 10k shared_buffers.. beyond that the overhead of maintaining +it becomes excessive. (This isn't really the case in 7.5) + +Curiously, what are your sort_mem and shared_buffers settings? + + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 09:19:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AFC81D1B297 + for ; + Fri, 18 Jun 2004 09:19: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 26821-02 + for ; + Fri, 18 Jun 2004 12:19:51 +0000 (GMT) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id E4A42D1B273 + for ; + Fri, 18 Jun 2004 09:19:47 -0300 (ADT) +Received: from concord.pspl.co.in ([202.54.11.72]:64651 helo=frodo.hserus.net) + by frodo.hserus.net with asmtp + (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.34 #0) + id 1BbIJl-000GRG-H4 by authid with plain; + Fri, 18 Jun 2004 17:48:01 +0530 +Message-ID: <40D2DD73.7070600@frodo.hserus.net> +Date: Fri, 18 Jun 2004 17:47:55 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gary Cowell +Cc: pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance +References: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.com> +In-Reply-To: <20040618113157.84084.qmail@web25104.mail.ukl.yahoo.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.7 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_NJABL_SPAM +X-Spam-Level: +X-Archive-Number: 200406/183 +X-Sequence-Number: 7241 + +Gary Cowell wrote: +> The explain output on postgres shows the same +> execution with a scan on vers and a sort but the query +> time is 78.6 seconds. +> +> The explain output from PostgreSQL is: +> QUERY PLAN +> --------------------------------------------------------------------------------- +> Unique (cost=117865.77..120574.48 rows=142 +> width=132) +> -> Sort (cost=117865.77..119220.13 rows=541741 +> width=132) +> Sort Key: "version" +> -> Seq Scan on vers (cost=0.00..21367.41 +> rows=541741 width=132) +> Filter: ("version" IS NOT NULL) +> +> I do have an index on the column in question but +> neither oracle nor postgresql choose to use it (which +> given that we're visiting all rows is perhaps not +> surprising). + +Can you post explain analyze for the same query? It contains actual numbers +alond side the chosen plan. + +> +> I'm not as familiar with postgresql as I am with +> Oracle but I think I've configured comparible +> buffering and sort area sizes, certainly there isn't +> much physical IO going on in either case. + +Well, for postgresql you should check out + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html + +HTH + + Shridhar + +From pgsql-performance-owner@postgresql.org Fri Jun 18 10:52:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 313A7D1B172 + for ; + Fri, 18 Jun 2004 10:52: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 31833-04 + for ; + Fri, 18 Jun 2004 13:52:03 +0000 (GMT) +Received: from mail.unisoftbg.com (unknown [194.12.229.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 51F35D1B188 + for ; + Fri, 18 Jun 2004 10:51:54 -0300 (ADT) +Received: (qmail 26992 invoked by uid 507); 18 Jun 2004 13:58:55 -0000 +Received: from unknown (HELO t1.unisoftbg.com) (194.12.229.193) + by 0 with SMTP; 18 Jun 2004 13:58:55 -0000 +Message-ID: <40D2E1B0.9000805@t1.unisoftbg.com> +Date: Fri, 18 Jun 2004 14:36:00 +0200 +From: pginfo +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.0.1) Gecko/20020823 Netscape/7.0 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gary Cowell +Cc: pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> +Content-Type: multipart/alternative; + boundary="------------050809080405090101020502" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.6 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, + HTML_TITLE_EMPTY, RCVD_IN_DSBL +X-Spam-Level: * +X-Archive-Number: 200406/187 +X-Sequence-Number: 7245 + +--------------050809080405090101020502 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Hi , +I have similare problem and found that the problem is by pg sort. +It is extremly slow by me. + +Also in my case I tryed to migrate one db from oracle to pg . + +To solve this problem I dinamicaly set sort_mem to some big value. +In this case the sort is working into RAM and is relative fast. +You can try this and remember sort mem is per sort, not per connection. + +In my migration I found the only advantage for oracle is the very good sort. + +regards, +ivan. + +Gary Cowell wrote: + +>--- lnd@hnit.is wrote: > You can roughly estimate time +>spent for just scaning +> +> +>>the table using +>>something like this: +>> +>> select sum(version) from ... where version is not +>>null +>> +>> and just +>> +>> select sum(version) from ... +>> +>>The results would be interesting to compare. +>> +>> +> +>To answer (I hope) everyones questions at once: +> +>1) Oracle and postmaster were not running at the same +>time +>2) The queries were run once, to cache as much as +>possible then run again to get the timing +> +>3) Distinct vs. no distinct (i.e. sort performance). +> +>select length(version) from vers where version is not +>null; +> +>Time: 9748.174 ms +> +>select distinct(version) from vers where version is +>not null; +> +>Time: 67988.972 ms +> +>So about an extra 60 seconds with the distinct on. +> +>Here is the explain analyze output from psql: +> +># explain analyze select distinct version from vers +>where version is not null; +> +> QUERY PLAN +>----------------------------------------------------------------------------------------------------------------------------------- +> Unique (cost=117865.77..120574.48 rows=142 +>width=132) (actual time=63623.428..68269.111 rows=536 +>loops=1) +> -> Sort (cost=117865.77..119220.13 rows=541741 +>width=132) (actual time=63623.417..66127.641 +>rows=541741 loops=1) +> Sort Key: "version" +> -> Seq Scan on vers (cost=0.00..21367.41 +>rows=541741 width=132) (actual time=0.218..7214.903 +>rows=541741 loops=1) +> Filter: ("version" IS NOT NULL) +> Total runtime: 68324.215 ms +>(6 rows) +> +>Time: 68326.062 ms +> +> +>And the non-default .conf parameters: +> +>tcpip_socket = true +>max_connections = 100 +>password_encryption = true +>shared_buffers = 2000 +>sort_mem = 16384 +>vacuum_mem = 8192 +>effective_cache_size = 4000 +>syslog = 2 +> +>postgresql version is 7.4.3 +>compiled with GCC 3.3.2 on sun4u architecture. +> +> +> +> +> +> +> +> +>___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> +> +> + + +--------------050809080405090101020502 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + +Hi ,
+I have similare problem and found that the problem is by pg sort.
+It is extremly slow by me.
+
+Also in my case I tryed to migrate one db from oracle to pg .
+
+To solve this problem I dinamicaly set sort_mem to some big value.
+In this case the sort is working into RAM and is relative fast.
+You can try this and remember sort mem is per sort, not per connection.
+
+In my migration I found the only advantage for oracle is the very good sort.
+
+regards,
+ivan.
+
+Gary Cowell wrote:
+
+
--- lnd@hnit.is wrote: > You can roughly estimate time
+spent for just scaning
+  
+
+
the table using
+something like this: 
+
+	select sum(version) from ... where version is not
+null
+
+	and just 
+
+	select sum(version) from ...
+
+The results would be interesting to compare. 
+    
+
+

+To answer (I hope) everyones questions at once:
+
+1) Oracle and postmaster were not running at the same
+time
+2) The queries were run once, to cache as much as
+possible then run again to get the timing
+
+3) Distinct vs. no distinct (i.e. sort performance).
+
+select length(version) from vers where version is not
+null;
+
+Time: 9748.174 ms
+
+select distinct(version) from vers where version is
+not null;
+
+Time: 67988.972 ms
+
+So about an extra 60 seconds with the distinct on.
+
+Here is the explain analyze output from psql:
+
+# explain analyze select distinct version from vers
+where version is not null;
+                                                      
+     QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------
+ Unique  (cost=117865.77..120574.48 rows=142
+width=132) (actual time=63623.428..68269.111 rows=536
+loops=1)
+   ->  Sort  (cost=117865.77..119220.13 rows=541741
+width=132) (actual time=63623.417..66127.641
+rows=541741 loops=1)
+         Sort Key: "version"
+         ->  Seq Scan on vers  (cost=0.00..21367.41
+rows=541741 width=132) (actual time=0.218..7214.903
+rows=541741 loops=1)
+               Filter: ("version" IS NOT NULL)
+ Total runtime: 68324.215 ms
+(6 rows)
+
+Time: 68326.062 ms
+
+
+And the non-default .conf parameters:
+
+tcpip_socket = true
+max_connections = 100
+password_encryption = true
+shared_buffers = 2000
+sort_mem = 16384     
+vacuum_mem = 8192    
+effective_cache_size = 4000
+syslog = 2                 
+
+postgresql version is 7.4.3
+compiled with GCC 3.3.2 on sun4u architecture.
+
+
+
+
+
+	
+	
+		
+___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com
+
+---------------------------(end of broadcast)---------------------------
+TIP 2: you can get off all lists at once with the unregister command
+    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
+
+
+  
+
+
+ + + +--------------050809080405090101020502-- + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 10:26:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F1FBAD1B380 + for ; + Fri, 18 Jun 2004 10:25: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 93106-08 + for ; + Fri, 18 Jun 2004 13:25:56 +0000 (GMT) +Received: from web25103.mail.ukl.yahoo.com (web25103.mail.ukl.yahoo.com + [217.12.10.51]) + by svr1.postgresql.org (Postfix) with SMTP id 5B6A9D1B1B7 + for ; + Fri, 18 Jun 2004 10:25:51 -0300 (ADT) +Message-ID: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> +Received: from [217.158.107.104] by web25103.mail.ukl.yahoo.com via HTTP; + Fri, 18 Jun 2004 14:25:54 BST +Date: Fri, 18 Jun 2004 14:25:54 +0100 (BST) +From: =?iso-8859-1?q?Gary=20Cowell?= +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +To: pgsql-performance@postgresql.org +In-Reply-To: <0A5B2E3C3A64CA4AB14F76DBCA76DDA44EFAB3@seifur.hnit.is> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/185 +X-Sequence-Number: 7243 + +--- lnd@hnit.is wrote: > You can roughly estimate time +spent for just scaning +> the table using +> something like this: +> +> select sum(version) from ... where version is not +> null +> +> and just +> +> select sum(version) from ... +> +> The results would be interesting to compare. + +To answer (I hope) everyones questions at once: + +1) Oracle and postmaster were not running at the same +time +2) The queries were run once, to cache as much as +possible then run again to get the timing + +3) Distinct vs. no distinct (i.e. sort performance). + +select length(version) from vers where version is not +null; + +Time: 9748.174 ms + +select distinct(version) from vers where version is +not null; + +Time: 67988.972 ms + +So about an extra 60 seconds with the distinct on. + +Here is the explain analyze output from psql: + +# explain analyze select distinct version from vers +where version is not null; + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=117865.77..120574.48 rows=142 +width=132) (actual time=63623.428..68269.111 rows=536 +loops=1) + -> Sort (cost=117865.77..119220.13 rows=541741 +width=132) (actual time=63623.417..66127.641 +rows=541741 loops=1) + Sort Key: "version" + -> Seq Scan on vers (cost=0.00..21367.41 +rows=541741 width=132) (actual time=0.218..7214.903 +rows=541741 loops=1) + Filter: ("version" IS NOT NULL) + Total runtime: 68324.215 ms +(6 rows) + +Time: 68326.062 ms + + +And the non-default .conf parameters: + +tcpip_socket = true +max_connections = 100 +password_encryption = true +shared_buffers = 2000 +sort_mem = 16384 +vacuum_mem = 8192 +effective_cache_size = 4000 +syslog = 2 + +postgresql version is 7.4.3 +compiled with GCC 3.3.2 on sun4u architecture. + + + + + + + + +___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com + +From pgsql-performance-owner@postgresql.org Fri Jun 18 10:23:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A186D1B1B7 + for ; + Fri, 18 Jun 2004 10:23: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 97178-05 + for ; + Fri, 18 Jun 2004 13:23:43 +0000 (GMT) +Received: from mail.census.gov.ph (gateway.census.gov.ph [203.172.28.97]) + by svr1.postgresql.org (Postfix) with ESMTP id CA1F2D1B188 + for ; + Fri, 18 Jun 2004 10:22:48 -0300 (ADT) +Received: from notnot (gateway.census.gov.ph [203.172.28.97]) + by mail.census.gov.ph (8.12.8/8.12.8) with ESMTP id i5IDKLrA010944 + for ; Fri, 18 Jun 2004 21:20:50 +0800 +Message-Id: <200406181320.i5IDKLrA010944@mail.census.gov.ph> +From: "Michael Ryan S. Puncia" +To: +Subject: memory allocation +Date: Fri, 18 Jun 2004 21:34:40 +0800 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0000_01C4557C.16F70690" +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +Thread-Index: AcRVOQD5fTV4ABZhTWOYRYgUurM2Mw== +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2096 +X-MailScanner: Found to be clean by NSO mail server. +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200406/184 +X-Sequence-Number: 7242 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0000_01C4557C.16F70690 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +Hi everyone . + + + +How much memory should I give to the kernel and postgresql + + + +I have 1G of memory and 120G of HD + + + +Shared Buffers = ? + +Vacuum Mem = ? + +SHMAX = ? + + + +Sorry I have so many question .I am a newbie :-( + + + +I have 30G of data + +At least 30 simultaneus users + +But I will use it only for query with lot of sorting + + + +thanks + + +------=_NextPart_000_0000_01C4557C.16F70690 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Hi everyone .

+ +

 

+ +

How much memory should I give to the kernel and postgres= +ql

+ +

 

+ +

I have 1G of memory and 120G of HD

+ +

 

+ +

Shared Buffers =3D ?

+ +

Vacuum Mem =3D ?

+ +

SHMAX =3D ?

+ +

 

+ +

Sorry I have so many question .I am a newbie L

+ +

 

+ +

I have 30G of data

+ +

At least 30 simultaneus users + +

But I will use it only for query with lot of sorting

+ +

 

+ +

thanks

+ +
+ + + + + +------=_NextPart_000_0000_01C4557C.16F70690-- + + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 10:39:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CCA15D1B37D + for ; + Fri, 18 Jun 2004 10:39: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 21279-01 + for ; + Fri, 18 Jun 2004 13:39:42 +0000 (GMT) +Received: from emo.org.tr (emo.org.tr [195.142.105.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B8C2D1B188 + for ; + Fri, 18 Jun 2004 10:39:36 -0300 (ADT) +Received: by emo.org.tr (Postfix, from userid 41643) + id 33CF12FECE; Fri, 18 Jun 2004 16:39:33 +0300 (EEST) +Received: from localhost (localhost [127.0.0.1]) + by emo.org.tr (Postfix) with ESMTP id 2A812111ED6 + for ; + Fri, 18 Jun 2004 16:39:33 +0300 (EEST) +Date: Fri, 18 Jun 2004 16:39:30 +0300 (EEST) +From: Devrim GUNDUZ +X-X-Sender: devrim2@emo.org.tr +Reply-To: pgsql-performance@PostgreSQL.org +To: pgsql-performance@PostgreSQL.org +Subject: Re: memory allocation +In-Reply-To: <200406181320.i5IDKLrA010944@mail.census.gov.ph> +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.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200406/186 +X-Sequence-Number: 7244 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + + +Hi, + +On Fri, 18 Jun 2004, Michael Ryan S. Puncia wrote: + +> How much memory should I give to the kernel and postgresql +> +> I have 1G of memory and 120G of HD +> +> Shared Buffers = ? +> +> Vacuum Mem = ? + +Maybe you should read + +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.sxw +OR +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html + +> SHMAX = ? + +SHMMAX is not that relevant with PostgreSQL, it's rather relevant with +your operating system. + +Regards, +- -- +Devrim GUNDUZ +devrim~gunduz.org devrim.gunduz~linux.org.tr + http://www.tdmsoft.com + http://www.gunduz.org +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.1 (GNU/Linux) + +iD8DBQFA0vCUtl86P3SPfQ4RAvITAJ48FV24aBN+nc2+lkRwXc79HlHV6QCfSvRA +YuGjn8hs1jvOJ2Ah9oamIJQ= +=96+i +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 10:55:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C72CFD1B4E5 + for ; + Fri, 18 Jun 2004 10:55: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 30042-09 + for ; + Fri, 18 Jun 2004 13:55:43 +0000 (GMT) +Received: from xtecnica.com (host154-218.pool80206.interbusiness.it + [80.206.218.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 79088D1B267 + for ; + Fri, 18 Jun 2004 10:55:37 -0300 (ADT) +Received: from DOMENICO2K by xtecnica.com (MDaemon.PRO.v7.1.0.R) + with ESMTP id md50000022350.msg + for ; Fri, 18 Jun 2004 15:54:48 +0200 +Message-ID: <011101c4553b$c1967130$70c8007e@xtecnica.it> +Reply-To: "Domenico Sgarbossa" +From: "Domenico Sgarbossa" +To: +References: + <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com><004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> + <87pt8616i3.fsf@asmodeus.mcnaught.org> + <1087226647.1775.14.camel@kaos> +Subject: Re: [BULK] Problems with vacuum! +Date: Fri, 18 Jun 2004 15:54:20 +0200 +Organization: XTECNICA srl +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 1 +X-MSMail-Priority: High +X-Mailer: Microsoft Outlook Express 5.50.4927.1200 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 +X-Authenticated-Sender: domenico@xtecnica.com +X-Spam-Processed: xtecnica.com, Fri, 18 Jun 2004 15:54:48 +0200 + (not processed: message from valid local sender) +X-MDRemoteIP: 126.0.200.112 +X-Return-Path: domenico@xtecnica.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: xtecnica.com, Fri, 18 Jun 2004 15:54:52 +0200 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 + tests=X_MSMAIL_PRIORITY_HIGH, X_PRIORITY_HIGH +X-Spam-Level: * +X-Archive-Number: 200406/188 +X-Sequence-Number: 7246 + +The problems still remains... +I've tried to change shmax to 128 mb (i've got 2 GB of ram), +then the others parameter are set as follow: + +shared_buffers = 8096 # 2*max_connections, min 16 +max_fsm_relations = 500 # min 10, fsm is free space map +max_fsm_pages = 15000 # min 1000, fsm is free space map +max_locks_per_transaction = 64 # min 10 +wal_buffers = 8 # min 4 + +# +# Non-shared Memory Sizes +# +sort_mem = 1024 # min 32 +vacuum_mem = 16384 # min 1024 + +I've scheduled 2 tasks nightly: + +vacuumdb --analyze dbname +pg_dump -x -f dbname.dmp dbname + +so when the users go home, i've got something like 15/20000kb free ram, the +rest is cached and 0kb of swap... +It seems that when pg_dump starts the cached memory isn't released so the +system begin to swap, then the system +does the same with vacuum..... even if there 1.8 gb of cached ram (that +is'nt released anymore....) very strange! + +anyone could explain mw why this happend? + + +Distinti Saluti + +Sgarbossa Domenico +X Tecnica S.R.L. +www.xtecnica.com +Tel: 049/9409154 - 049/5970297 +Fax: 049/9400288 + + + + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 10:56:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EC02CD1B751 + for ; + Fri, 18 Jun 2004 10:56: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 31833-05 + for ; + Fri, 18 Jun 2004 13:56:26 +0000 (GMT) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 0206BD1B4E5 + for ; + Fri, 18 Jun 2004 10:56:19 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BbJqq-000Lxc-0W; Fri, 18 Jun 2004 14:56:16 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 22FB316DD7; Fri, 18 Jun 2004 14:56:15 +0100 (BST) +Message-ID: <40D2F47E.6060306@archonet.com> +Date: Fri, 18 Jun 2004 14:56:14 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gary Cowell +Cc: pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> +In-Reply-To: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/189 +X-Sequence-Number: 7247 + +Gary Cowell wrote: +> --- lnd@hnit.is wrote: > You can roughly estimate time +> spent for just scaning +> +>>the table using +>>something like this: +>> +>> select sum(version) from ... where version is not +>>null +>> +>> and just +>> +>> select sum(version) from ... +>> +>>The results would be interesting to compare. +> +> +> To answer (I hope) everyones questions at once: +> +> 1) Oracle and postmaster were not running at the same +> time +> 2) The queries were run once, to cache as much as +> possible then run again to get the timing +> +> 3) Distinct vs. no distinct (i.e. sort performance). +> +> select length(version) from vers where version is not +> null; +> +> Time: 9748.174 ms +> +> select distinct(version) from vers where version is +> not null; +> +> Time: 67988.972 ms +> +> So about an extra 60 seconds with the distinct on. + +Which is basically the sorting time... + +> Here is the explain analyze output from psql: +> +> # explain analyze select distinct version from vers +> where version is not null; +> +> QUERY PLAN +> ----------------------------------------------------------------------------------------------------------------------------------- +> Unique (cost=117865.77..120574.48 rows=142 +> width=132) (actual time=63623.428..68269.111 rows=536 +> loops=1) +> -> Sort (cost=117865.77..119220.13 rows=541741 +> width=132) (actual time=63623.417..66127.641 +> rows=541741 loops=1) +> Sort Key: "version" +> -> Seq Scan on vers (cost=0.00..21367.41 +> rows=541741 width=132) (actual time=0.218..7214.903 +> rows=541741 loops=1) +> Filter: ("version" IS NOT NULL) +> Total runtime: 68324.215 ms +> (6 rows) +> +> Time: 68326.062 ms + +Yep - the seq-scan takes 7214.903 ms, there's a huge setup time for the +sort (63623.417) and it's not finished until 66127.641ms have elapsed. + +> +> And the non-default .conf parameters: +> +> tcpip_socket = true +> max_connections = 100 +> password_encryption = true +> shared_buffers = 2000 +> sort_mem = 16384 +> vacuum_mem = 8192 +> effective_cache_size = 4000 +> syslog = 2 + +Well, I'd probably up vacuum_mem, and check how much RAM is being used +for disk cache - I'd guess it's more than 32MB (4000 * 8kb). + +You might want to up the shared_buffers, but that's going to depend on +the load. + +Try increasing sort_mem temporarily, and see if that makes a difference: + SET sort_mem = 64000; + EXPLAIN ANALYSE ... +The only thing I can think is that you're getting disk activity to get a +sort that slow. I'd be expecting a hash-sort if PG thought it could fit +the distinct values in memory. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Jun 18 10:58:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CBC28D1B755 + for ; + Fri, 18 Jun 2004 10:58: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 31833-06 + for ; + Fri, 18 Jun 2004 13:58:18 +0000 (GMT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id B39C2D1B750 + for ; + Fri, 18 Jun 2004 10:58:14 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BbJsn-000C5R-0U; Fri, 18 Jun 2004 14:58:18 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id E78BD16DD7; Fri, 18 Jun 2004 14:58:16 +0100 (BST) +Message-ID: <40D2F4F8.20600@archonet.com> +Date: Fri, 18 Jun 2004 14:58:16 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Michael Ryan S. Puncia" +Cc: pgsql-performance@postgresql.org +Subject: Re: memory allocation +References: <200406181320.i5IDKLrA010944@mail.census.gov.ph> +In-Reply-To: <200406181320.i5IDKLrA010944@mail.census.gov.ph> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/190 +X-Sequence-Number: 7248 + +Michael Ryan S. Puncia wrote: +> Hi everyone . +> +> +> +> How much memory should I give to the kernel and postgresql +> +> I have 1G of memory and 120G of HD + +Devrim's pointed you to a guide to the configuration file. There's also +an introduction to performance tuning on the same site. + +An important thing to remember is that the sort_mem is the amount of +memory available *per sort* and some queries can use several sorts. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Jun 18 12:15:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F110BD1B188 + for ; + Fri, 18 Jun 2004 12:15: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 04495-04 + for ; + Fri, 18 Jun 2004 15:15:01 +0000 (GMT) +Received: from mail.unisoftbg.com (unknown [194.12.229.207]) + by svr1.postgresql.org (Postfix) with ESMTP id E1892D1B4E5 + for ; + Fri, 18 Jun 2004 12:14:59 -0300 (ADT) +Received: (qmail 29801 invoked by uid 507); 18 Jun 2004 15:21:57 -0000 +Received: from unknown (HELO t1.unisoftbg.com) (194.12.229.193) + by 0 with SMTP; 18 Jun 2004 15:21:57 -0000 +Message-ID: <40D2F526.608@t1.unisoftbg.com> +Date: Fri, 18 Jun 2004 15:59:02 +0200 +From: pginfo +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.0.1) Gecko/20020823 Netscape/7.0 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> + <20412.1087570627@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------020302060900080700040301" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.6 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, + HTML_TITLE_EMPTY, RCVD_IN_DSBL +X-Spam-Level: * +X-Archive-Number: 200406/194 +X-Sequence-Number: 7252 + +--------------020302060900080700040301 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Hi, + +Tom Lane wrote: + +>=?iso-8859-1?q?Gary=20Cowell?= writes: +> +> +>> -> Sort (cost=117865.77..119220.13 rows=541741 +>>width=132) (actual time=63623.417..66127.641 +>>rows=541741 loops=1) +>> +>> +> +>This is clearly where the time is going. +> +> +> +>>sort_mem = 16384 +>> +>> +> +>Probably not enough for this problem. The estimated data size is +>upwards of 60 meg (132 bytes * half a mil rows); allowing for per-row +>overhead I suspect that you'd need sort_mem approaching 100 meg for +>a fully-in-memory sort. (Also I'd take the width=132 with a *big* +>grain of salt, unless you have reason to know that it's accurate.) +> +>The on-disk sorting algorithm that we use is designed to favor minimum +>disk space consumption over speed. It has a fairly nonrandom access +>pattern that can be pretty slow if your disks don't have good seek-time +>specs. +> +>I don't know whether Oracle's performance advantage is because they're +>not swapping the sort to disk at all, or because they use a different +>on-disk sort method with a more sequential access pattern. +> +>[... thinks for awhile ...] It seems possible that they may use sort +>code that knows it is performing a DISTINCT operation and discards +>duplicates on sight. Given that there are only 534 distinct values, +>the sort would easily stay in memory if that were happening. +> +>It would be interesting to compare Oracle and PG times for a straight +>sort of half a million rows, without the DISTINCT part; that would +>give us a clue whether they simply have much better sort technology, +>or whether they have a special optimization for sort+unique. +> +> +I was tested this situation and found that oracle is working also in +this case much faster (in some cases x10 ) compared to pg. +Also by in memory sort oracle is faster but the diferenc is not so big. +So I have oracle 8 and oracle 10 (also pg - it is my primary platform) +installed and can run some tests. +I am ready to help in this direction or if you can send any example I +will run it and post the result . + +regards, +ivan. + +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 8: explain analyze is your friend +> +> +> +> + + +--------------020302060900080700040301 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Hi,
+
+Tom Lane wrote:
+
+
=?iso-8859-1?q?Gary=20Cowell?= <gary_cowell@yahoo.co.uk> writes:
+  
+
+
   ->  Sort  (cost=117865.77..119220.13 rows=541741
+width=132) (actual time=63623.417..66127.641
+rows=541741 loops=1)
+    
+
+

+This is clearly where the time is going.
+
+  
+
+
sort_mem = 16384     
+    
+
+

+Probably not enough for this problem.  The estimated data size is
+upwards of 60 meg (132 bytes * half a mil rows); allowing for per-row
+overhead I suspect that you'd need sort_mem approaching 100 meg for
+a fully-in-memory sort.  (Also I'd take the width=132 with a *big*
+grain of salt, unless you have reason to know that it's accurate.)
+
+The on-disk sorting algorithm that we use is designed to favor minimum
+disk space consumption over speed.  It has a fairly nonrandom access
+pattern that can be pretty slow if your disks don't have good seek-time
+specs.
+
+I don't know whether Oracle's performance advantage is because they're
+not swapping the sort to disk at all, or because they use a different
+on-disk sort method with a more sequential access pattern.
+
+[... thinks for awhile ...]  It seems possible that they may use sort
+code that knows it is performing a DISTINCT operation and discards
+duplicates on sight.  Given that there are only 534 distinct values,
+the sort would easily stay in memory if that were happening.
+
+It would be interesting to compare Oracle and PG times for a straight
+sort of half a million rows, without the DISTINCT part; that would
+give us a clue whether they simply have much better sort technology,
+or whether they have a special optimization for sort+unique.
+  
+
+I was tested this situation and found that oracle is working also in this +case much faster (in some cases x10 ) compared to pg.
+Also by in memory sort oracle is faster but the diferenc is not so big.
+So I have oracle 8 and oracle 10 (also pg - it is my primary platform) installed +and can run some tests.
+I am ready to help in this direction or if you can send any example I will +run it and post the result .
+
+regards,
+ivan.
+
+
+			regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 8: explain analyze is your friend
+
+
+  
+
+
+ + + +--------------020302060900080700040301-- + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 11:29:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BF20AD1B170 + for ; + Fri, 18 Jun 2004 11:29: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 59567-05 + for ; + Fri, 18 Jun 2004 14:29: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 ED828D1B174 + for ; + Fri, 18 Jun 2004 11:29:29 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5IETPQ7020173; + Fri, 18 Jun 2004 10:29:26 -0400 (EDT) +To: =?iso-8859-1?Q?SZUCS_G=E1bor?= +Cc: pgsql-performance@postgresql.org +Subject: Re: *very* inefficient choice made by the planner (regarding +In-reply-to: <008501c4550f$87523a80$0403a8c0@fejleszt4> +References: <200406101624.21739.ftm.van.vugt@foxi.nl> + <40C881FE.5000301@sympatico.ca> <25304.1086883145@sss.pgh.pa.us> + <40C892BA.8080704@sympatico.ca> + <20040610100332.D20710@megazone.bigpanda.com> + <20040610101410.X21002@megazone.bigpanda.com> + <008501c4550f$87523a80$0403a8c0@fejleszt4> +Comments: In-reply-to =?iso-8859-1?Q?SZUCS_G=E1bor?= + message dated "Fri, 18 Jun 2004 10:37:40 +0200" +Date: Fri, 18 Jun 2004 10:29:25 -0400 +Message-ID: <20172.1087568965@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/191 +X-Sequence-Number: 7249 + +=?iso-8859-1?Q?SZUCS_G=E1bor?= writes: +>> It's NULLs inside the subselect that are the issue. +> +> select 1 in (select a from foo) +> select exists ( select 1 from foo where a=1) + +> Just a dumb try :) + +> SELECT (exists(select 1 from foo where a isnull) AND NULL) +> OR exists(select 1 from foo where a=1) + +The more general case is where you have a variable (or expression) +on the left of IN. That could be NULL too, and this still doesn't +give the right result in that case :-(. With NULL on the left the +correct answer would be FALSE if the subselect has zero rows, +NULL otherwise. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 18 11:58:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED597D1B757 + for ; + Fri, 18 Jun 2004 11:57: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 78657-08 + for ; + Fri, 18 Jun 2004 14:57:09 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0876AD1B749 + for ; + Fri, 18 Jun 2004 11:57:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5IEv7nI020413; + Fri, 18 Jun 2004 10:57:07 -0400 (EDT) +To: =?iso-8859-1?q?Gary=20Cowell?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +In-reply-to: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> +Comments: In-reply-to =?iso-8859-1?q?Gary=20Cowell?= + message dated "Fri, 18 Jun 2004 14:25:54 +0100" +Date: Fri, 18 Jun 2004 10:57:07 -0400 +Message-ID: <20412.1087570627@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/192 +X-Sequence-Number: 7250 + +=?iso-8859-1?q?Gary=20Cowell?= writes: +> -> Sort (cost=117865.77..119220.13 rows=541741 +> width=132) (actual time=63623.417..66127.641 +> rows=541741 loops=1) + +This is clearly where the time is going. + +> sort_mem = 16384 + +Probably not enough for this problem. The estimated data size is +upwards of 60 meg (132 bytes * half a mil rows); allowing for per-row +overhead I suspect that you'd need sort_mem approaching 100 meg for +a fully-in-memory sort. (Also I'd take the width=132 with a *big* +grain of salt, unless you have reason to know that it's accurate.) + +The on-disk sorting algorithm that we use is designed to favor minimum +disk space consumption over speed. It has a fairly nonrandom access +pattern that can be pretty slow if your disks don't have good seek-time +specs. + +I don't know whether Oracle's performance advantage is because they're +not swapping the sort to disk at all, or because they use a different +on-disk sort method with a more sequential access pattern. + +[... thinks for awhile ...] It seems possible that they may use sort +code that knows it is performing a DISTINCT operation and discards +duplicates on sight. Given that there are only 534 distinct values, +the sort would easily stay in memory if that were happening. + +It would be interesting to compare Oracle and PG times for a straight +sort of half a million rows, without the DISTINCT part; that would +give us a clue whether they simply have much better sort technology, +or whether they have a special optimization for sort+unique. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 18 12:12:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3732CD1B188 + for ; + Fri, 18 Jun 2004 12:11: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 93573-06 + for ; + Fri, 18 Jun 2004 15:11:05 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E033AD1B170 + for ; + Fri, 18 Jun 2004 12:11:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5IFB4MP020555; + Fri, 18 Jun 2004 11:11:04 -0400 (EDT) +To: "Domenico Sgarbossa" +Cc: pgsql-performance@postgresql.org +Subject: Re: [BULK] Problems with vacuum! +In-reply-to: <011101c4553b$c1967130$70c8007e@xtecnica.it> +References: + <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com><004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> + <87pt8616i3.fsf@asmodeus.mcnaught.org> + <1087226647.1775.14.camel@kaos> + <011101c4553b$c1967130$70c8007e@xtecnica.it> +Comments: In-reply-to "Domenico Sgarbossa" + message dated "Fri, 18 Jun 2004 15:54:20 +0200" +Date: Fri, 18 Jun 2004 11:11:03 -0400 +Message-ID: <20554.1087571463@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/193 +X-Sequence-Number: 7251 + +"Domenico Sgarbossa" writes: +> so when the users go home, i've got something like 15/20000kb free ram, the +> rest is cached and 0kb of swap... +> It seems that when pg_dump starts the cached memory isn't released so the +> system begin to swap, + +A sane kernel should drop disk buffers rather than swapping. We heard +recently about a bug in some versions of the Linux kernel that cause it +to prefer swapping to discarding disk cache, though. It sounds like +that's what you're hitting. Look into newer kernels ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 18 12:47:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 35C9ED1B503 + for ; + Fri, 18 Jun 2004 12:32: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 14536-10 + for ; + Fri, 18 Jun 2004 15:32:07 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 75609D1B34B + for ; + Fri, 18 Jun 2004 12:32:04 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 4AC4435726; Fri, 18 Jun 2004 08:32:00 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 48D0835723; Fri, 18 Jun 2004 08:32:00 -0700 (PDT) +Date: Fri, 18 Jun 2004 08:32:00 -0700 (PDT) +From: Stephan Szabo +To: =?iso-8859-1?Q?SZUCS_G=E1bor?= +Cc: pgsql-performance@postgresql.org +Subject: Re: *very* inefficient choice made by the planner (regarding +In-Reply-To: <008501c4550f$87523a80$0403a8c0@fejleszt4> +Message-ID: <20040618082006.N86299@megazone.bigpanda.com> +References: <200406101624.21739.ftm.van.vugt@foxi.nl> + <40C881FE.5000301@sympatico.ca> + <25304.1086883145@sss.pgh.pa.us> <40C892BA.8080704@sympatico.ca> + <20040610100332.D20710@megazone.bigpanda.com> + <20040610101410.X21002@megazone.bigpanda.com> + <008501c4550f$87523a80$0403a8c0@fejleszt4> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=iso-8859-1 +Content-Transfer-Encoding: QUOTED-PRINTABLE +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/195 +X-Sequence-Number: 7253 + +On Fri, 18 Jun 2004, [iso-8859-1] SZUCS G=E1bor wrote: + +> Dear Gurus, +> +> ----- Original Message ----- +> From: "Stephan Szabo" +> Sent: Thursday, June 10, 2004 7:14 PM +> +> +> > +> > On Thu, 10 Jun 2004, Stephan Szabo wrote: +> > +> > > +> > > On Thu, 10 Jun 2004, Jean-Luc Lachance wrote: +> > > +> > > > I agree, but it should be a simple rewrite. No? +> > > +> > > It's NULLs inside the subselect that are the issue. +> > > +> > > select 1 in (select a from foo) +> > > select exists ( select 1 from foo where a=3D1) +> +> Just a dumb try :) +> +> SELECT (exists(select 1 from foo where a isnull) AND NULL) +> OR exists(select 1 from foo where a=3D1) +> +> AFAIK this returns +> * NULL if (NULL in foo.a) and (1 not in foo.a) +> * (1 in foo.a) otherwise. +> +> The weakness is the doubled exists clause. I'm sure it makes most cases at +> least doubtful... + +Well, once you take into account the lhs being potentially null + lhe in (select rhe from foo) is something like: + +case when lhe is null then + not exists(select 1 from foo limit 1) or null +else + (exists(select 1 from foo where rhe is null) and null) + or exists(select 1 from foo where rhe=3Dlhe) +end + +I think the real win occurs for where clause cases if it can pull up the +exists that references lhe so that it doesn't try to evaluate it on every +row and that's unlikely to occur in something like the above. + +From pgsql-performance-owner@postgresql.org Fri Jun 18 12:48:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AF689D1B298 + for ; + Fri, 18 Jun 2004 12:47: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 33714-06 + for ; + Fri, 18 Jun 2004 15:47:24 +0000 (GMT) +Received: from web25105.mail.ukl.yahoo.com (web25105.mail.ukl.yahoo.com + [217.12.10.53]) + by svr1.postgresql.org (Postfix) with SMTP id 6FD85D1B241 + for ; + Fri, 18 Jun 2004 12:47:22 -0300 (ADT) +Message-ID: <20040618154721.37105.qmail@web25105.mail.ukl.yahoo.com> +Received: from [217.158.107.104] by web25105.mail.ukl.yahoo.com via HTTP; + Fri, 18 Jun 2004 16:47:21 BST +Date: Fri, 18 Jun 2004 16:47:21 +0100 (BST) +From: =?iso-8859-1?q?Gary=20Cowell?= +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/196 +X-Sequence-Number: 7254 + +> Try increasing sort_mem temporarily, and see if that +> makes a difference: +> SET sort_mem = 64000; +> EXPLAIN ANALYSE ... + +I did this (actualy 65536) and got the following: +pvcsdb=# explain analyze select distinct version from +vers where version is not null; + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------ + Unique (cost=117865.77..120574.48 rows=142 +width=132) (actual time=81595.178..86573.228 rows=536 +loops=1) + -> Sort (cost=117865.77..119220.13 rows=541741 +width=132) (actual time=81595.169..84412.069 +rows=541741 loops=1) + Sort Key: "version" + -> Seq Scan on vers (cost=0.00..21367.41 +rows=541741 width=132) (actual time=10.068..7397.374 +rows=541741 loops=1) + Filter: ("version" IS NOT NULL) + Total runtime: 86647.495 ms +(6 rows) + + +In response to Tom Lane, I have compared a +select/order by on the same data in Oracle and PG to +see if this changes things: + + +PG: Time: 67438.536 ms 541741 rows +Oracle: After an hour and a half I canned it + +So it seems the idea that oracle is dropping duplicate +rows prior to the sort when using distinct may indeed +be the case. + + From what I've seen here, it seems that PGs on-disk +sort performance is exceeding that of Oracle - it's +just that oracle sorts fewer rows for distinct. + + + + + + +___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com + +From pgsql-performance-owner@postgresql.org Fri Jun 18 13:30:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 38C3CD1B345 + for ; + Fri, 18 Jun 2004 13:30: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 64358-06 + for ; + Fri, 18 Jun 2004 16:30:03 +0000 (GMT) +Received: from relay.snowman.net (snowman.net [66.93.83.236]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E38CD1B298 + for ; + Fri, 18 Jun 2004 13:30:01 -0300 (ADT) +Received: from ns.snowman.net (ns.snowman.net [10.10.0.2]) + by relay.snowman.net (8.12.11/8.12.11/Debian-5) with ESMTP id + i5IGTv2C024517; Fri, 18 Jun 2004 12:29:57 -0400 +Received: from ns.snowman.net (localhost [127.0.0.1]) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) with ESMTP id + i5IGU4Jr014882; Fri, 18 Jun 2004 12:30:04 -0400 +Received: (from sfrost@localhost) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) id i5IGU3t2014880; + Fri, 18 Jun 2004 12:30:03 -0400 +Date: Fri, 18 Jun 2004 12:30:03 -0400 +From: Stephen Frost +To: Tom Lane +Cc: Gary Cowell , + pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +Message-ID: <20040618163003.GM11196@ns.snowman.net> +Mail-Followup-To: Tom Lane , + Gary Cowell , + pgsql-performance@postgresql.org +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> + <20412.1087570627@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="+CeNbjWahVCCmU74" +Content-Disposition: inline +In-Reply-To: <20412.1087570627@sss.pgh.pa.us> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 12:15:17 up 139 days, 11:20, 6 users, load average: 0.04, 0.10, 0.09 +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/197 +X-Sequence-Number: 7255 + +--+CeNbjWahVCCmU74 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +* Tom Lane (tgl@sss.pgh.pa.us) wrote: +> [... thinks for awhile ...] It seems possible that they may use sort +> code that knows it is performing a DISTINCT operation and discards +> duplicates on sight. Given that there are only 534 distinct values, +> the sort would easily stay in memory if that were happening. + +Could this optimization be added to PostgreSQL? It sounds like a very +reasonable thing to do. Hopefully there wouldn't be too much complexity +needed to add it. + + Stephen + +--+CeNbjWahVCCmU74 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQFA0xiLrzgMPqB3kigRAikJAJ95SOB/vwmCsPVSCKU6pzwGHy5nygCeMKv4 +l2bJW6DW6tiUTbuE4hovOPQ= +=IUAH +-----END PGP SIGNATURE----- + +--+CeNbjWahVCCmU74-- + +From pgsql-performance-owner@postgresql.org Fri Jun 18 14:04:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 199A7D1B74E + for ; + Fri, 18 Jun 2004 14: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 80950-05 + for ; + Fri, 18 Jun 2004 17:01:53 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2689ED1B54D + for ; + Fri, 18 Jun 2004 14:01:51 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5IH1pS3022515; + Fri, 18 Jun 2004 13:01:51 -0400 (EDT) +To: Stephen Frost +Cc: Gary Cowell , + pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +In-reply-to: <20040618163003.GM11196@ns.snowman.net> +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> + <20412.1087570627@sss.pgh.pa.us> + <20040618163003.GM11196@ns.snowman.net> +Comments: In-reply-to Stephen Frost + message dated "Fri, 18 Jun 2004 12:30:03 -0400" +Date: Fri, 18 Jun 2004 13:01:51 -0400 +Message-ID: <22514.1087578111@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/198 +X-Sequence-Number: 7256 + +Stephen Frost writes: +> * Tom Lane (tgl@sss.pgh.pa.us) wrote: +>> [... thinks for awhile ...] It seems possible that they may use sort +>> code that knows it is performing a DISTINCT operation and discards +>> duplicates on sight. Given that there are only 534 distinct values, +>> the sort would easily stay in memory if that were happening. + +> Could this optimization be added to PostgreSQL? It sounds like a very +> reasonable thing to do. + +That's what I was wondering about too. But first I'd like to get +some kind of reading on how effective it would be. If someone can +demonstrate that Oracle can do sort-and-drop-dups a lot faster than +it can do a straight sort of the same amount of input data, that +would be a strong indication that it's worth doing. At this point +we don't know if that's the source of their win or not. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 18 14:53:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DE85D1B737 + for ; + Fri, 18 Jun 2004 14:53: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 06710-07 + for ; + Fri, 18 Jun 2004 17:53:16 +0000 (GMT) +Received: from relay.snowman.net (snowman.net [66.93.83.236]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C022D1B503 + for ; + Fri, 18 Jun 2004 14:53:14 -0300 (ADT) +Received: from ns.snowman.net (ns.snowman.net [10.10.0.2]) + by relay.snowman.net (8.12.11/8.12.11/Debian-5) with ESMTP id + i5IHrBvB025901; Fri, 18 Jun 2004 13:53:11 -0400 +Received: from ns.snowman.net (localhost [127.0.0.1]) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) with ESMTP id + i5IHrHhA019333; Fri, 18 Jun 2004 13:53:17 -0400 +Received: (from sfrost@localhost) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) id i5IHrHs3019330; + Fri, 18 Jun 2004 13:53:17 -0400 +Date: Fri, 18 Jun 2004 13:53:17 -0400 +From: Stephen Frost +To: Tom Lane +Cc: Gary Cowell , + pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +Message-ID: <20040618175317.GN11196@ns.snowman.net> +Mail-Followup-To: Tom Lane , + Gary Cowell , + pgsql-performance@postgresql.org +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> + <20412.1087570627@sss.pgh.pa.us> + <20040618163003.GM11196@ns.snowman.net> + <22514.1087578111@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="eaOnqiUIFHwTGLlS" +Content-Disposition: inline +In-Reply-To: <22514.1087578111@sss.pgh.pa.us> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 13:07:55 up 139 days, 12:13, 6 users, load average: 0.09, 0.11, 0.10 +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/199 +X-Sequence-Number: 7257 + +--eaOnqiUIFHwTGLlS +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* Tom Lane (tgl@sss.pgh.pa.us) wrote: +> Stephen Frost writes: +> > * Tom Lane (tgl@sss.pgh.pa.us) wrote: +> >> [... thinks for awhile ...] It seems possible that they may use sort +> >> code that knows it is performing a DISTINCT operation and discards +> >> duplicates on sight. Given that there are only 534 distinct values, +> >> the sort would easily stay in memory if that were happening. +>=20 +> > Could this optimization be added to PostgreSQL? It sounds like a very +> > reasonable thing to do. +>=20 +> That's what I was wondering about too. But first I'd like to get +> some kind of reading on how effective it would be. If someone can +> demonstrate that Oracle can do sort-and-drop-dups a lot faster than +> it can do a straight sort of the same amount of input data, that +> would be a strong indication that it's worth doing. At this point +> we don't know if that's the source of their win or not. + +Alright, I did a couple tests, these are different systems with +different hardware, but in the end I think the difference is clear: + +tsf=3D# explain analyze select distinct access_type_id from p_gen_dom_dedic= +ated_swc_access ; + QUER= +Y PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20 +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +--=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20 + Unique (cost=3D321591.00..333205.56 rows=3D16 width=3D10) (actual time=3D= +32891.141..37420.429 rows=3D16 loops=3D1) + -> Sort (cost=3D321591.00..327398.28 rows=3D2322912 width=3D10) (actua= +l time=3D32891.137..35234.810 rows=3D2322912 loops=3D1) + Sort Key: access_type_id + -> Seq Scan on p_gen_dom_dedicated_swc_access (cost=3D0.00..5549= +2.12 rows=3D2322912 width=3D10) (actual time=3D0.013..3743.470 rows=3D23229= +12 loops=3D1) + Total runtime: 37587.519 ms +(5 rows) + +tsf=3D# explain analyze select access_type_id from p_gen_dom_dedicated_swc_= +access order by access_type_id; + QUERY P= +LAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +---------------------------------------------------------------------------= +----------------------------------------------------------------------- + Sort (cost=3D321591.00..327398.28 rows=3D2322912 width=3D10) (actual time= +=3D32926.696..35278.847 rows=3D2322912 loops=3D1) + Sort Key: access_type_id=20=20=20=20=20 + -> Seq Scan on p_gen_dom_dedicated_swc_access (cost=3D0.00..55492.12 r= +ows=3D2322912 width=3D10) (actual time=3D0.014..3753.443 rows=3D2322912 loo= +ps=3D1) + Total runtime: 36737.628 ms=20=20=20=20 +(4 rows)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20 + +So, about the same from postgres in each case. From Oracle: + +(select access_type_id from p_gen_dom_dedicated_swc_access order by access_= +type_id) +sauron:/home/sfrost> time sqlplus mci_vendor/mci @test.sql > /dev/null + +real 3m55.12s +user 2m25.87s +sys 0m10.59s + +(select distinct access_type_id from p_gen_dom_dedicated_swc_access) +sauron:/home/sfrost> time sqlplus mci_vendor/mci @test.sql > /dev/null + +real 0m5.08s +user 0m3.86s +sys 0m0.95s + +All the queries were run multiple times, though there wasn't all that +much difference in the times. Both systems are pretty speedy, but I +tend to feel the Postgres box is faster in CPU/disk access time, which +is probably why the Oracle system took 4 minutes to do what the Postgres +systems does in 40 seconds. My only other concern is the Oracle system +having to do the write I/O while the postgres one doesn't... I don't +see an obvious way to get around that though, and I'm not sure if it'd +really make *that* big of a difference. + + Stephen + +--eaOnqiUIFHwTGLlS +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQFA0ywNrzgMPqB3kigRAgNjAJ4vatzGX8hkylQDWWMPnljmm9vuvwCfQrwt +7ljdjAI3YSV7qIxSaKh7xzU= +=aOlw +-----END PGP SIGNATURE----- + +--eaOnqiUIFHwTGLlS-- + +From pgsql-performance-owner@postgresql.org Fri Jun 18 15:06:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A5EBD1B37D + for ; + Fri, 18 Jun 2004 15:06: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 12581-07 + for ; + Fri, 18 Jun 2004 18:06:36 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id 7C44FD1B345 + for ; + Fri, 18 Jun 2004 15:06:33 -0300 (ADT) +Received: (qmail 16678 invoked by uid 0); 18 Jun 2004 17:37:57 -0000 +Received: from mpls-pop-03.inet.qwest.net (63.231.195.3) + by mpls-qmqp-03.inet.qwest.net with QMQP; 18 Jun 2004 17:37:57 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-03.inet.qwest.net with SMTP; 18 Jun 2004 18:06:33 -0000 +Date: Fri, 18 Jun 2004 12:07:20 -0600 +Message-Id: <1087582040.28062.13.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Tom Lane" +Cc: "Domenico Sgarbossa" , + pgsql-performance@postgresql.org +Subject: Re: [BULK] Problems with vacuum! +In-Reply-To: <20554.1087571463@sss.pgh.pa.us> +References: <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com> + <004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> + <87pt8616i3.fsf@asmodeus.mcnaught.org> <1087226647.1775.14.camel@kaos> + <011101c4553b$c1967130$70c8007e@xtecnica.it> + <20554.1087571463@sss.pgh.pa.us> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/200 +X-Sequence-Number: 7258 + +On Fri, 2004-06-18 at 09:11, Tom Lane wrote: +> "Domenico Sgarbossa" writes: +> > so when the users go home, i've got something like 15/20000kb free ram, the +> > rest is cached and 0kb of swap... +> > It seems that when pg_dump starts the cached memory isn't released so the +> > system begin to swap, +> +> A sane kernel should drop disk buffers rather than swapping. We heard +> recently about a bug in some versions of the Linux kernel that cause it +> to prefer swapping to discarding disk cache, though. It sounds like +> that's what you're hitting. Look into newer kernels ... + +This was a common problem in the linux 2.4 series kernels, but has +supposedly been fixed in the 2.6 kernels. Having lots of memory and +turning off swap will "fix" the problem in 2.4, but if you run out of +real mem, you're hosed. + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 15:16:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B569D1B1EC + for ; + Fri, 18 Jun 2004 15:16: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 18017-07 + for ; + Fri, 18 Jun 2004 18:16:01 +0000 (GMT) +Received: from relay.snowman.net (snowman.net [66.93.83.236]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CC3FD1B1D0 + for ; + Fri, 18 Jun 2004 15:15:59 -0300 (ADT) +Received: from ns.snowman.net (ns.snowman.net [10.10.0.2]) + by relay.snowman.net (8.12.11/8.12.11/Debian-5) with ESMTP id + i5IIFvXw026262; Fri, 18 Jun 2004 14:15:57 -0400 +Received: from ns.snowman.net (localhost [127.0.0.1]) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) with ESMTP id + i5IIG3sN020687; Fri, 18 Jun 2004 14:16:03 -0400 +Received: (from sfrost@localhost) + by ns.snowman.net (8.12.11/8.12.10/Debian-5) id i5IIG3Qh020685; + Fri, 18 Jun 2004 14:16:03 -0400 +Date: Fri, 18 Jun 2004 14:16:03 -0400 +From: Stephen Frost +To: Tom Lane , Gary Cowell , + pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +Message-ID: <20040618181603.GO11196@ns.snowman.net> +Mail-Followup-To: Tom Lane , + Gary Cowell , + pgsql-performance@postgresql.org +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> + <20412.1087570627@sss.pgh.pa.us> + <20040618163003.GM11196@ns.snowman.net> + <22514.1087578111@sss.pgh.pa.us> + <20040618175317.GN11196@ns.snowman.net> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="S0SQiRKxtbUby28S" +Content-Disposition: inline +In-Reply-To: <20040618175317.GN11196@ns.snowman.net> +X-Editor: Vim http://www.vim.org/ +X-Info: http://www.snowman.net +X-Operating-System: Linux/2.4.24ns.3.0 (i686) +X-Uptime: 14:10:46 up 139 days, 13:16, 6 users, load average: 0.12, 0.14, 0.12 +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/201 +X-Sequence-Number: 7259 + +--S0SQiRKxtbUby28S +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* Stephen Frost (sfrost@snowman.net) wrote: +> systems does in 40 seconds. My only other concern is the Oracle system +> having to do the write I/O while the postgres one doesn't... I don't +> see an obvious way to get around that though, and I'm not sure if it'd +> really make *that* big of a difference. + +Alright, after talking with some people on #postgresql I found that in +Oracle you can do 'set autotrace traceonly', which removes the I/O +factor from the Oracle query. Doing this I also discovered that it +appears Oracle actually uses an index on that field that it knows about +to derive what the distinct results would be. That probably invalidates +this test for what we were specifically looking for, but, hey, using the +index to figure out what the distinct values for the key are isn't +exactly a bad idea. :) + +Here's the new results: + +(select access_type_id from p_gen_dom_dedicated_swc_access order by access_= +type_id;) +---------------------------------------------------------------------------= +-------- +sauron:/home/sfrost> time sqlplus mci_vendor/mci @test.sql=20=20=20=20=20= +=20=20=20=20=20=20=20 + +SQL*Plus: Release 9.2.0.1.0 - Production on Fri Jun 18 14:10:12 2004 + +Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. + + +Connected to: +Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production +With the Partitioning, OLAP and Oracle Data Mining options +JServer Release 9.2.0.1.0 - Production + + +2322912 rows selected. + + +Execution Plan +---------------------------------------------------------- + 0 SELECT STATEMENT Optimizer=3DCHOOSE (Cost=3D11459 Card=3D1303962 B + ytes=3D16951506) + + 1 0 SORT* (ORDER BY) (Cost=3D11459 Card=3D1303962 Bytes=3D16951506)= + :Q457001 + 2 1 TABLE ACCESS* (FULL) OF 'P_GEN_DOM_DEDICATED_SWC_ACCESS' :Q45= +7000 + (Cost=3D1550 Card=3D1303962 Bytes=3D16951506) + + + + 1 PARALLEL_TO_SERIAL SELECT A1.C0 C0 FROM :Q457000 A1 ORDER B= +Y A1 + .C0 + + 2 PARALLEL_TO_PARALLEL SELECT /*+ NO_EXPAND ROWID(A1) */ A1."AC= +CESS + _TYPE_ID" C0 FROM "P_GEN_DOM_DEDICAT + + + +Statistics +---------------------------------------------------------- + 32 recursive calls + 1594 db block gets + 64495 consistent gets + 105975 physical reads + 0 redo size + 40109427 bytes sent via SQL*Net to client + 1704111 bytes received via SQL*Net from client + 154862 SQL*Net roundtrips to/from client + 2 sorts (memory) + 4 sorts (disk) + 2322912 rows processed + +Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Pro= +duction +With the Partitioning, OLAP and Oracle Data Mining options +JServer Release 9.2.0.1.0 - Production + +real 1m38.55s +user 0m23.36s +sys 0m9.61s + +---------------------------------------------------------------------------= +-------- +(select distinct access_type_id from p_gen_dom_dedicated_swc_access) +---------------------------------------------------------------------------= +-------- +sauron:/home/sfrost> time sqlplus mci_vendor/mci @test.sql + +SQL*Plus: Release 9.2.0.1.0 - Production on Fri Jun 18 14:13:54 2004 + +Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. + + +Connected to: +Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production +With the Partitioning, OLAP and Oracle Data Mining options +JServer Release 9.2.0.1.0 - Production + + +16 rows selected. + + +Execution Plan +---------------------------------------------------------- + 0 SELECT STATEMENT Optimizer=3DCHOOSE (Cost=3D44874 Card=3D1303962 B + ytes=3D16951506) + + 1 0 SORT (UNIQUE) (Cost=3D44874 Card=3D1303962 Bytes=3D16951506) + 2 1 INDEX (FAST FULL SCAN) OF 'TABLE_8111_DUPLICATE_CHECK' ( + UNIQUE) (Cost=3D4 Card=3D1303962 Bytes=3D16951506) + + + + + +Statistics +---------------------------------------------------------- + 0 recursive calls + 0 db block gets + 47069 consistent gets + 47067 physical reads + 0 redo size + 841 bytes sent via SQL*Net to client + 662 bytes received via SQL*Net from client + 3 SQL*Net roundtrips to/from client + 1 sorts (memory) + 0 sorts (disk) + 16 rows processed + +Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Pro= +duction +With the Partitioning, OLAP and Oracle Data Mining options +JServer Release 9.2.0.1.0 - Production + +real 0m5.36s +user 0m0.04s +sys 0m0.07s +---------------------------------------------------------------------------= +-------- + + Stephen + +--S0SQiRKxtbUby28S +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQFA0zFjrzgMPqB3kigRAuoRAJ9jZahKqefqTShH6tpv0FhkcQjZYgCfcFtp +vyBhmSUfT1PCN5LUalZrg+U= +=6iTL +-----END PGP SIGNATURE----- + +--S0SQiRKxtbUby28S-- + +From pgsql-performance-owner@postgresql.org Fri Jun 18 16:08:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE68AD1B19C + for ; + Fri, 18 Jun 2004 15: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 33025-07 + for ; + Fri, 18 Jun 2004 18:48:51 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id B446AD1B18F + for ; + Fri, 18 Jun 2004 15:48:49 -0300 (ADT) +Received: from [192.168.1.80] (dsl093-038-087.pdx1.dsl.speakeasy.net + [66.93.38.87]) (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i5IImdo16120; + Fri, 18 Jun 2004 11:48:39 -0700 +Message-ID: <40D338BC.7080705@commandprompt.com> +Date: Fri, 18 Jun 2004 11:47:24 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 0.6 (X11/20040502) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Scott Marlowe +Cc: Tom Lane , Domenico Sgarbossa , + pgsql-performance@postgresql.org +Subject: Re: [BULK] Problems with vacuum! +References: <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com> + <004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> + <87pt8616i3.fsf@asmodeus.mcnaught.org> + <1087226647.1775.14.camel@kaos> + <011101c4553b$c1967130$70c8007e@xtecnica.it> + <20554.1087571463@sss.pgh.pa.us> + <1087582040.28062.13.camel@localhost.localdomain> +In-Reply-To: <1087582040.28062.13.camel@localhost.localdomain> +Content-Type: multipart/mixed; boundary="------------000004040304000206060909" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 + tests=RAZOR2_CF_RANGE_11_50, RAZOR2_CHECK +X-Spam-Level: * +X-Archive-Number: 200406/203 +X-Sequence-Number: 7261 + +This is a multi-part message in MIME format. +--------------000004040304000206060909 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Hello, + +I would have to double check BUT I believe this is fixed in later 2.4.x +kernels as well. If you don't want to go through the hassle of 2.6 +(although it really is a nice kernel) then upgrade to 2.4.26. + +Sincerely, + +Joshau D. Drake + +Scott Marlowe wrote: +> On Fri, 2004-06-18 at 09:11, Tom Lane wrote: +> +>>"Domenico Sgarbossa" writes: +>> +>>>so when the users go home, i've got something like 15/20000kb free ram, the +>>>rest is cached and 0kb of swap... +>>>It seems that when pg_dump starts the cached memory isn't released so the +>>>system begin to swap, +>> +>>A sane kernel should drop disk buffers rather than swapping. We heard +>>recently about a bug in some versions of the Linux kernel that cause it +>>to prefer swapping to discarding disk cache, though. It sounds like +>>that's what you're hitting. Look into newer kernels ... +> +> +> This was a common problem in the linux 2.4 series kernels, but has +> supposedly been fixed in the 2.6 kernels. Having lots of memory and +> turning off swap will "fix" the problem in 2.4, but if you run out of +> real mem, you're hosed. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL + +--------------000004040304000206060909 +Content-Type: text/x-vcard; charset=utf8; + name="jd.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="jd.vcf" + +begin:vcard +fn:Joshua D. Drake +n:Drake;Joshua D. +org:Command Prompt, Inc. +adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0034 +note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. +x-mozilla-html:FALSE +url:http://www.commandprompt.com/ +version:2.1 +end:vcard + + +--------------000004040304000206060909-- + +From pgsql-performance-owner@postgresql.org Fri Jun 18 16:02:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E2FC6D1B215 + for ; + Fri, 18 Jun 2004 15:58: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 44063-05 + for ; + Fri, 18 Jun 2004 18:58:00 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id 23ABFD1B1A0 + for ; + Fri, 18 Jun 2004 15:57:58 -0300 (ADT) +Received: (qmail 26657 invoked by uid 0); 18 Jun 2004 18:57:50 -0000 +Received: from unknown (63.231.195.5) + by mpls-qmqp-01.inet.qwest.net with QMQP; 18 Jun 2004 18:57:50 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-05.inet.qwest.net with SMTP; 18 Jun 2004 18:57:45 -0000 +Date: Fri, 18 Jun 2004 12:58:27 -0600 +Message-Id: <1087585107.28062.16.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Joshua D. Drake" +Cc: "Tom Lane" , + "Domenico Sgarbossa" , + pgsql-performance@postgresql.org +Subject: Re: [BULK] Problems with vacuum! +In-Reply-To: <40D338BC.7080705@commandprompt.com> +References: <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com> + <004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> + <87pt8616i3.fsf@asmodeus.mcnaught.org> <1087226647.1775.14.camel@kaos> + <011101c4553b$c1967130$70c8007e@xtecnica.it> + <20554.1087571463@sss.pgh.pa.us> + <1087582040.28062.13.camel@localhost.localdomain> + <40D338BC.7080705@commandprompt.com> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/202 +X-Sequence-Number: 7260 + +I believe it was more like the kernel was tuned to make it less common, +but certain things can still trigger it. I know the problem was still +there in the 2.4.24 on the last server I was playing with, but it was a +lot less of a problem than it had been under 2.4.9 on an earlier machine +with the same basic amount of memory. + +On Fri, 2004-06-18 at 12:47, Joshua D. Drake wrote: +> Hello, +> +> I would have to double check BUT I believe this is fixed in later 2.4.x +> kernels as well. If you don't want to go through the hassle of 2.6 +> (although it really is a nice kernel) then upgrade to 2.4.26. +> +> Sincerely, +> +> Joshau D. Drake +> +> Scott Marlowe wrote: +> > On Fri, 2004-06-18 at 09:11, Tom Lane wrote: +> > +> >>"Domenico Sgarbossa" writes: +> >> +> >>>so when the users go home, i've got something like 15/20000kb free ram, the +> >>>rest is cached and 0kb of swap... +> >>>It seems that when pg_dump starts the cached memory isn't released so the +> >>>system begin to swap, +> >> +> >>A sane kernel should drop disk buffers rather than swapping. We heard +> >>recently about a bug in some versions of the Linux kernel that cause it +> >>to prefer swapping to discarding disk cache, though. It sounds like +> >>that's what you're hitting. Look into newer kernels ... +> > +> > +> > This was a common problem in the linux 2.4 series kernels, but has +> > supposedly been fixed in the 2.6 kernels. Having lots of memory and +> > turning off swap will "fix" the problem in 2.4, but if you run out of +> > real mem, you're hosed. +> > +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 4: Don't 'kill -9' the postmaster +> + + +From pgsql-performance-owner@postgresql.org Fri Jun 18 17:57:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 57FA3D1B18F + for ; + Fri, 18 Jun 2004 17: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 95865-04 + for ; + Fri, 18 Jun 2004 20:47:18 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 10279D1B1EC + for ; + Fri, 18 Jun 2004 17:47:15 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5IKlHdX025465; + Fri, 18 Jun 2004 16:47:17 -0400 (EDT) +To: =?iso-8859-1?q?Gary=20Cowell?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +In-reply-to: <20040618154721.37105.qmail@web25105.mail.ukl.yahoo.com> +References: <20040618154721.37105.qmail@web25105.mail.ukl.yahoo.com> +Comments: In-reply-to =?iso-8859-1?q?Gary=20Cowell?= + message dated "Fri, 18 Jun 2004 16:47:21 +0100" +Date: Fri, 18 Jun 2004 16:47:17 -0400 +Message-ID: <25464.1087591637@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/204 +X-Sequence-Number: 7262 + +=?iso-8859-1?q?Gary=20Cowell?= writes: +> So it seems the idea that oracle is dropping duplicate +> rows prior to the sort when using distinct may indeed +> be the case. + +Okay. We won't have any short-term solution for making DISTINCT do that, +but if you are on PG 7.4 you could get the same effect from using +GROUP BY: instead of + select distinct version from vers where version is not null +try + select version from vers where version is not null group by version +You should get a HashAggregate plan out of that, and I'd think it'd be +pretty quick when there are not many distinct values of version. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Jun 18 20:06:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 47CABD1B193 + for ; + Fri, 18 Jun 2004 20:06: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 57564-02 + for ; + Fri, 18 Jun 2004 23:06:32 +0000 (GMT) +Received: from web25101.mail.ukl.yahoo.com (web25101.mail.ukl.yahoo.com + [217.12.10.49]) + by svr1.postgresql.org (Postfix) with SMTP id A6D52D1B18F + for ; + Fri, 18 Jun 2004 20:06:27 -0300 (ADT) +Message-ID: <20040618230629.47789.qmail@web25101.mail.ukl.yahoo.com> +Received: from [217.158.107.104] by web25101.mail.ukl.yahoo.com via HTTP; + Sat, 19 Jun 2004 00:06:29 BST +Date: Sat, 19 Jun 2004 00:06:29 +0100 (BST) +From: =?iso-8859-1?q?Gary=20Cowell?= +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +To: pgsql-performance@postgresql.org +In-Reply-To: <25464.1087591637@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/205 +X-Sequence-Number: 7263 + +--- Tom Lane wrote: > +=?iso-8859-1?q?Gary=20Cowell?= +> writes: +> > So it seems the idea that oracle is dropping +> duplicate +> > rows prior to the sort when using distinct may +> indeed +> > be the case. +> +> Okay. We won't have any short-term solution for +> making DISTINCT do that, +> but if you are on PG 7.4 you could get the same +> effect from using +> GROUP BY: instead of +> select distinct version from vers where version is +> not null +> try +> select version from vers where version is not null +> group by version +> You should get a HashAggregate plan out of that, and +> I'd think it'd be +> pretty quick when there are not many distinct values +> of version. +> + +Yeah out of the half million rows there are only ever +going to be 500 or so distinct values. + +I do indeed get such a plan. It's much faster that +way. Down to 16 seconds. I'll get the chap to rewrite +his app to use group by instead of distinct. + +Thanks (everyone) for the top class help! + + + + + +___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com + +From pgsql-performance-owner@postgresql.org Sun Jun 20 13:40:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3EC0D1B1C9 + for ; + Sun, 20 Jun 2004 13:40: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 68428-09 + for ; + Sun, 20 Jun 2004 16:40:20 +0000 (GMT) +Received: from smtp013.mail.yahoo.com (smtp013.mail.yahoo.com + [216.136.173.57]) + by svr1.postgresql.org (Postfix) with SMTP id F3D90D1B1B7 + for ; + Sun, 20 Jun 2004 13:40:19 -0300 (ADT) +Received: from unknown (HELO pc02) (janio?2003@200.227.209.138 with login) + by smtp013.mail.yahoo.com with SMTP; 20 Jun 2004 16:40:13 -0000 +Message-ID: <039601c456e5$437b4c70$0200a8c0@pc02> +From: "Janio Rosa da Silva" +To: +Subject: Hi! +Date: Sun, 20 Jun 2004 13:39:38 -0300 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0373_01C456CC.08598C60" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.4 tagged_above=0.0 required=5.0 + tests=FROM_ENDS_IN_NUMS, HTML_20_30, HTML_MESSAGE, RCVD_IN_SORBS +X-Spam-Level: * +X-Archive-Number: 200406/206 +X-Sequence-Number: 7264 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0373_01C456CC.08598C60 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, + +I am trying install the postgresql-7.4.3 simple installation. I did ./confi= +gure command at the postgresql directory source. While the configuring proc= +cess I receiving the follow message: + +checking for tar... /bin/tar +checking for strip... strip +checking whether it is possible to strip libraries... yes +checking for bison... bison -y +*** The installed version of Bison is too old. PostgreSQL needs +*** Bison version 1.875 or later. +checking for perl... /usr/bin/perl +checking for main in -lbsd... no +checking for setproctitle in -lutil... no +checking for main in -lm... yes + +But, after this message the install proccess continue like this message. Th= +e problem is that the installation never finish. I am thinking that the con= +figure proccess is in loop. Have it anything relation with my hardware conf= +iguration? The computer where I did this is: AMD K6-II 200 MHZ; 64 MB memo= +ry; +I would like why the configure proccess never finish. + +Regards, + +Janio +------=_NextPart_000_0373_01C456CC.08598C60 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi,
+
 
+
I am trying install the postgresql-7.4.3 s= +imple=20 +installation. I did ./configure command at the postgresql directory source.= +=20 +While the configuring proccess I receiving the follow message:
+
 
+
checking for tar... /bin/tar
checking f= +or=20 +strip... strip
checking whether it is possible to strip libraries...=20 +yes
checking for bison... bison -y
*** The installed version of Bison= + is=20 +too old.  PostgreSQL needs
*** Bison version 1.875 or later.
che= +cking=20 +for perl... /usr/bin/perl
checking for main in -lbsd... no
checking f= +or=20 +setproctitle in -lutil... no
checking for main in -lm... yes
+
 
+
But, after this message the install procce= +ss=20 +continue like this message. The problem is that the installation never fini= +sh. I=20 +am thinking that the configure proccess is in loop. Have it anything relati= +on=20 +with my hardware configuration? The computer where I did this is:  AMD= +=20 +K6-II 200 MHZ; 64 MB memory;
I would like why the configure proccess nev= +er=20 +finish.
+
 
+
Regards,
+
 
+
Janio
+ +------=_NextPart_000_0373_01C456CC.08598C60-- + + +From pgsql-performance-owner@postgresql.org Sun Jun 20 15:48:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CACF2D1B220 + for ; + Sun, 20 Jun 2004 15: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 13592-03 + for ; + Sun, 20 Jun 2004 18:45: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 6CE2BD1B1D0 + for ; + Sun, 20 Jun 2004 15:45:19 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5KIj65Z004120; + Sun, 20 Jun 2004 14:45:06 -0400 (EDT) +To: Stan Bielski +Cc: pgsql-performance@postgresql.org +Subject: Re: Indexing question +In-reply-to: +References: +Comments: In-reply-to Stan Bielski + message dated "Tue, 15 Jun 2004 17:29:59 -0400" +Date: Sun, 20 Jun 2004 14:45:06 -0400 +Message-ID: <4119.1087757106@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/210 +X-Sequence-Number: 7268 + +Stan Bielski writes: +> Table "public.allflow_tv_mydoom" +> Column | Type | Modifiers +> ------------+---------+----------- +> tv_s | bigint | + ^^^^^^ +> Indexes: allflow_tv_mydoom_x btree (tv_s) + +> standb=# explain select * from allflow_tv_mydoom where tv_s < 1074200099 +> and tv_s > 107506499; +> [ gives seqscan ] + +This is a FAQ :-(. Unadorned integer constants are taken to be int4 +not int8 (unless they are too large for int4), and cross-data-type +comparisons are not indexable in existing releases. So you have to +explicitly cast the comparison values to int8: + +explain select * from allflow_tv_mydoom where tv_s < 1074200099::bigint +and tv_s > 107506499::bigint; + +(or use the standard CAST syntax if you prefer). + +7.5 will have a fix for this ancient annoyance. + +BTW, is there a reason to be using tv_s+tv_us and not just a single +timestamptz column? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Jun 20 17:02:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 695EDD1B169 + for ; + Sun, 20 Jun 2004 17:02: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 30942-08 + for ; + Sun, 20 Jun 2004 20:02:20 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AF0BED1B1B7 + for ; + Sun, 20 Jun 2004 17:02:17 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id E09F876A7F; Sun, 20 Jun 2004 16:02:22 -0400 (EDT) +Subject: Re: pg_fetch_array +From: Rod Taylor +To: Thanks +Cc: Postgresql Performance +In-Reply-To: +References: +Content-Type: text/plain +Message-Id: <1087761736.64388.83.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Sun, 20 Jun 2004 16:02:17 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/211 +X-Sequence-Number: 7269 + +> Does php need to read database everytime when pg_fetch_array is executed in +> the while loop or all the rows have been in the memory after pg_query? + +You may need to ask the php people about this one. The PostgreSQL +protocol would allow data to continue streaming in at the same time as +you are processing other rows (asynchronous retrieval). So, optionally +they may fetch and cache all rows in local memory at pg_query OR grab +them in sets of 1000 rows and cache that (fetching the next set when the +first set runs out) OR grab one row for each fetch. + +You could run a simple select that will fetch 100M rows from a table +with no WHERE clause. See how quickly the first row come in, and how +much memory is used by the process. + +I suspect they call all of the rows at pg_query execution. Otherwise +they wouldn't know how to respond to a pg_num_rows() call. + + +On a side note, that is a rather unique email address. + + +From pgsql-performance-owner@postgresql.org Mon Jun 21 07:12:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 88B6DD1B74E + for ; + Mon, 21 Jun 2004 07:12: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 17591-07 + for ; + Mon, 21 Jun 2004 10:11:59 +0000 (GMT) +Received: from lamb.mcmillan.net.nz (218-101-45-111.paradise.net.nz + [218.101.45.111]) + by svr1.postgresql.org (Postfix) with ESMTP id A1043D1B340 + for ; + Mon, 21 Jun 2004 07:11:54 -0300 (ADT) +Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) + by lamb.mcmillan.net.nz (Postfix) with ESMTP id EEF84AD98593; + Mon, 21 Jun 2004 22:11:50 +1200 (NZST) +Subject: Re: Slow vacuum performance +From: Andrew McMillan +To: Patrick Hatcher +Cc: pgsql-performance@postgresql.org +In-Reply-To: + +References: + +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-rsKlli/hvj26Fqtk1EKU" +Date: Mon, 21 Jun 2004 22:11:49 +1200 +Message-Id: <1087812709.1748.41.camel@lamb.mcmillan.net.nz> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.9.1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/212 +X-Sequence-Number: 7270 + +--=-rsKlli/hvj26Fqtk1EKU +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Fri, 2004-06-18 at 19:51 -0700, Patrick Hatcher wrote: +>=20 +> Thanks! +>=20=20 +> My effective_cache_size =3D 625000 +>=20=20 +> I thought that having the shared_buffers above 2k or 3k didn't gain +> any performance and may in fact degrade it? + +Hi Patrick, + + +Quoting from: +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html + +shared_buffers + Sets the size of PostgreSQL's' memory buffer where queries are + held before being fed into the Kernel buffer of the host system. + It's very important to remember that this is only a holding + area, and not the total memory available for the server. As + such, resist the urge to set this number to a large portion of + your RAM, as this will actually degrade performance on many + operating systems. Members of the pgsql-performance mailing list + have found useful values in the range of 1000-6000, depending on + available RAM, database size, and number of concurrent queries. + For servers with very large amounts of available RAM (more than + 1 GB) increasing this setting to 6-15% or available RAM has + worked well for some users. The real analysis of the precise + best setting is not fully understood and is more readily + determined through testing than calculation.=20=20 +=20=20=20=20=20=20=20=20 + As a rule of thumb, observe shared memory usage of PostgreSQL + with tools like ipcs and determine the setting. Remember that + this is only half the story. You also need to set + effective_cache_size so that postgreSQL will use available + memory optimally. + +Using this conservatively, on an 8G system, 6% would be roughly 60,000 +pages - considerably higher than 2-3000... + +One day when I wasn't timid (well, OK, I was desperate :-), I did see a +_dramatic_ performance improvement in a single very narrow activity by +setting shared_buffers to 300000 on a 4G RAM system (I was rolling back +a transaction involving an update to 2.8 million rows) , but afterwards +I set shared_buffers back to 10000, which I have now increased to 20000 +on that system. + + +You may also want to look at: +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +Or indeed, peruse the articles regularly as they appear: +http://www.varlena.com/varlena/GeneralBits/ + +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 + Tomorrow will be cancelled due to lack of interest. +------------------------------------------------------------------------- + +--=-rsKlli/hvj26Fqtk1EKU +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD4DBQBA1rRkjJA0f48GgBIRAsedAJiY9VyXDUEIyQtjD2rPXzOoZlroAKCwdSWn +vsecos2tWn99gvpgm/ruWg== +=A+kz +-----END PGP SIGNATURE----- + +--=-rsKlli/hvj26Fqtk1EKU-- + + +From pgsql-performance-owner@postgresql.org Mon Jun 21 07:35:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CCDA1D1B1AB + for ; + Mon, 21 Jun 2004 07:35: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 28496-09 + for ; + Mon, 21 Jun 2004 10:35:11 +0000 (GMT) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id BAFA6D1B170 + for ; + Mon, 21 Jun 2004 07:35:07 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BcM8D-000IGk-0Y; Mon, 21 Jun 2004 11:34:30 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id D477F16987; Mon, 21 Jun 2004 11:34:28 +0100 (BST) +Message-ID: <40D6B9B4.4000209@archonet.com> +Date: Mon, 21 Jun 2004 11:34:28 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Thanks +Cc: pgsql-performance@postgresql.org +Subject: Re: pg_fetch_array +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/213 +X-Sequence-Number: 7271 + +Thanks wrote: +> Hello.... +> +> I would like to know the performance of pg_fetch_array. Cosider the code: +> +> $query = "select * from foo"; +> $result = pg_query( $db, $query ); +> +> while ($row = pg_fetch_array($result)) +> { +> $a = $row["a"]; +> $b = $row["b"]; +> $c = $row["c"]; +> $d = $row["d"]; +> } +> +> Does php need to read database everytime when pg_fetch_array is executed in +> the while loop or all the rows have been in the memory after pg_query? + +Not knowing anything in detail about the PHP drivers, I'm almost certain +that all rows are returned to PHP and then pg_fetch_array() reads that +from memory. + +> If read database is needed, is there any method to copy all the rows into +> memory by using other command? (because I have a application which needs +> large amount database update/retrieval and I wish the performance of the +> overall applications run faster.) +> +> or other method you would like to recommend in order to make the faster +> response time? + +Are you sure that pg_fetch_array() is the problem? Can you give an +example of what you're trying to do with the data? + +PS - there's a PHP list too. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Jun 21 12:35:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 899D5D1B17A; + Mon, 21 Jun 2004 12:35: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 68153-08; Mon, 21 Jun 2004 15:35:33 +0000 (GMT) +Received: from fdd00lnhub.federated.fds (external.fds.com [208.15.90.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B3B6D1B503; + Mon, 21 Jun 2004 12:35:28 -0300 (ADT) +In-Reply-To: <1087812709.1748.41.camel@lamb.mcmillan.net.nz> +To: "Andrew McMillan +Cc: pgsql-performance@postgresql.org, + pgsql-performance-owner@postgresql.org +Subject: Re: Slow vacuum performance +MIME-Version: 1.0 +X-Mailer: Lotus Notes Release 6.5 September 18, 2003 +Message-ID: + +From: Patrick Hatcher +Date: Mon, 21 Jun 2004 08:24:14 -0700 +X-MIMETrack: Serialize by Router on FDD00LNHUB/FSG/SVR/FDD(Release + 6.0|September 26, 2002) at 06/21/2004 11:12:50 AM +Content-Type: multipart/mixed; boundary="=_mixed 0055A56F88256EBA_=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=3.1 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE, HTML_TAG_BALANCE_TABLE, TO_HAS_SPACES +X-Spam-Level: *** +X-Archive-Number: 200406/214 +X-Sequence-Number: 7272 + +--=_mixed 0055A56F88256EBA_= +Content-Type: multipart/alternative; + boundary="=_alternative 0055A56F88256EBA_=" + +--=_alternative 0055A56F88256EBA_= +Content-Type: text/plain; charset="US-ASCII" + +Thanks! + + +Patrick Hatcher + + + + +Andrew McMillan +Sent by: pgsql-performance-owner@postgresql.org +06/21/04 03:11 AM + +To +Patrick Hatcher +cc +pgsql-performance@postgresql.org +Subject +Re: [PERFORM] Slow vacuum performance + + + + + + +On Fri, 2004-06-18 at 19:51 -0700, Patrick Hatcher wrote: +> +> Thanks! +> +> My effective_cache_size = 625000 +> +> I thought that having the shared_buffers above 2k or 3k didn't gain +> any performance and may in fact degrade it? + +Hi Patrick, + + +Quoting from: +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html + +shared_buffers + Sets the size of PostgreSQL's' memory buffer where queries are + held before being fed into the Kernel buffer of the host system. + It's very important to remember that this is only a holding + area, and not the total memory available for the server. As + such, resist the urge to set this number to a large portion of + your RAM, as this will actually degrade performance on many + operating systems. Members of the pgsql-performance mailing list + have found useful values in the range of 1000-6000, depending on + available RAM, database size, and number of concurrent queries. + For servers with very large amounts of available RAM (more than + 1 GB) increasing this setting to 6-15% or available RAM has + worked well for some users. The real analysis of the precise + best setting is not fully understood and is more readily + determined through testing than calculation. + + As a rule of thumb, observe shared memory usage of PostgreSQL + with tools like ipcs and determine the setting. Remember that + this is only half the story. You also need to set + effective_cache_size so that postgreSQL will use available + memory optimally. + +Using this conservatively, on an 8G system, 6% would be roughly 60,000 +pages - considerably higher than 2-3000... + +One day when I wasn't timid (well, OK, I was desperate :-), I did see a +_dramatic_ performance improvement in a single very narrow activity by +setting shared_buffers to 300000 on a 4G RAM system (I was rolling back +a transaction involving an update to 2.8 million rows) , but afterwards +I set shared_buffers back to 10000, which I have now increased to 20000 +on that system. + + +You may also want to look at: +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +Or indeed, peruse the articles regularly as they appear: +http://www.varlena.com/varlena/GeneralBits/ + +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 + Tomorrow will be cancelled due to lack of interest. +------------------------------------------------------------------------- + + +--=_alternative 0055A56F88256EBA_= +Content-Type: text/html; charset="US-ASCII" + + +
Thanks! +
+
+Patrick Hatcher
+
+
+
+
+
+ +
Andrew McMillan <andrew@catalyst.net.nz> + +
Sent by: pgsql-performance-owner@postgresql.org +

06/21/04 03:11 AM +

+ + + + +
+
To
+
Patrick Hatcher <PHatcher@macys.com> +
+
cc
+
pgsql-performance@postgresql.org +
+
Subject
+
Re: [PERFORM] Slow vacuum +performance
+
+ + +
+
+
+
+
+
On Fri, 2004-06-18 at 19:51 -0700, Patrick Hatcher +wrote:
+>
+> Thanks!
+>  
+> My effective_cache_size = 625000
+>  
+> I thought that having the shared_buffers above 2k or 3k didn't gain
+> any performance and may in fact degrade it?
+
+Hi Patrick,
+
+
+Quoting from:
+http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html
+
+shared_buffers
+        Sets the size of PostgreSQL's' memory buffer +where queries are
+        held before being fed into the Kernel buffer +of the host system.
+        It's very important to remember that this is +only a holding
+        area, and not the total memory available for +the server. As
+        such, resist the urge to set this number to +a large portion of
+        your RAM, as this will actually degrade performance +on many
+        operating systems. Members of the pgsql-performance +mailing list
+        have found useful values in the range of 1000-6000, +depending on
+        available RAM, database size, and number of +concurrent queries.
+        For servers with very large amounts of available +RAM (more than
+        1 GB) increasing this setting to 6-15% or available +RAM has
+        worked well for some users. The real analysis +of the precise
+        best setting is not fully understood and is +more readily
+        determined through testing than calculation. + 
+        
+        As a rule of thumb, observe shared memory usage +of PostgreSQL
+        with tools like ipcs and determine the setting. +Remember that
+        this is only half the story. You also need +to set
+        effective_cache_size so that postgreSQL will +use available
+        memory optimally.
+
+Using this conservatively, on an 8G system, 6% would be roughly 60,000
+pages - considerably higher than 2-3000...
+
+One day when I wasn't timid (well, OK, I was desperate :-), I did see a
+_dramatic_ performance improvement in a single very narrow activity by
+setting shared_buffers to 300000 on a 4G RAM system (I was rolling back
+a transaction involving an update to 2.8 million rows) , but afterwards
+I set shared_buffers back to 10000, which I have now increased to 20000
+on that system.
+
+
+You may also want to look at:
+http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html
+
+Or indeed, peruse the articles regularly as they appear:
+http://www.varlena.com/varlena/GeneralBits/
+
+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
+           Tomorrow will be cancelled due to lack +of interest.
+-------------------------------------------------------------------------
+
+
+--=_alternative 0055A56F88256EBA_=-- + +--=_mixed 0055A56F88256EBA_= +Content-Type: text/plain; name="signature.asc" +Content-Disposition: attachment; filename="signature.asc" +Content-Transfer-Encoding: base64 + +LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0NClZlcnNpb246IEdudVBH +IHYxLjIuNCAoR05VL0xpbnV4KQ0KDQppRDREQlFCQTFyUmtqSkEwZjQ4R2dC +SVJBc2VkQUppWTlWeVhEVUVJeVF0akQyclBYek9vWmxyb0FLQ3dkU1duDQp2 +c2Vjb3MydFduOTlndnBnbS9ydVdnPT0NCj1BK2t6DQotLS0tLUVORCBQR1Ag +U0lHTkFUVVJFLS0tLS0NCg== + +--=_mixed 0055A56F88256EBA_=-- + +From pgsql-performance-owner@postgresql.org Mon Jun 21 14:58:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB46FD1B19A + for ; + Mon, 21 Jun 2004 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 34814-08 + for ; + Mon, 21 Jun 2004 17:58:07 +0000 (GMT) +Received: from mail.libertyrms.com (unknown [207.219.45.62]) + by svr1.postgresql.org (Postfix) with ESMTP id 83AA7D1B1B7 + for ; + Mon, 21 Jun 2004 14:58:05 -0300 (ADT) +Received: from dba4.int.libertyrms.com ([10.1.3.13] ident=ahammond) + by mail.libertyrms.com with esmtp (Exim 4.22) id 1BcT3W-0003ia-0I + for pgsql-performance@postgresql.org; Mon, 21 Jun 2004 13:58:06 -0400 +Message-ID: <40D722CC.8000905@ca.afilias.info> +Date: Mon, 21 Jun 2004 14:02:52 -0400 +From: Andrew Hammond +Organization: Afilias Canada Corp. +User-Agent: Mozilla Thunderbird 0.6 (X11/20040512) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Postgres over Linux NBD or NFS +X-Enigmail-Version: 0.83.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------000302040002080202090002" +X-SA-Exim-Mail-From: ahammond@ca.afilias.info +X-SA-Exim-Scanned: No; SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/215 +X-Sequence-Number: 7273 + +This is a multi-part message in MIME format. +--------------000302040002080202090002 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +We're looking for an alternative to fiber-channel disk arrays for mass +storage. One of the ideas that we're exploring would involve having the +cluster on an NFS mounted filesystem. Another technology we're looking +at is the Linux NBD (Network Block Device). + +Has anyone had any experience with running postgres over either of these +technologies? What issues do we need to know about / pay attention to? + +- -- +Andrew Hammond 416-673-4138 ahammond@ca.afilias.info +Database Administrator, Afilias Canada Corp. +CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFA1yK6gfzn5SevSpoRAtYAAKCrghfAKV5kVuiTd/2TOwEbr4Q7hACgr3rT +mEvFi8AOHX9I43T45fH1e0U= +=1Cs9 +-----END PGP SIGNATURE----- + +--------------000302040002080202090002 +Content-Type: text/x-vcard; charset=utf8; + name="ahammond.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="ahammond.vcf" + +begin:vcard +fn:Andrew Hammond +n:Hammond;Andrew +org:Afilias Canada Corp.;Operations +adr:Suite 204;;4141 Yonge Street;North York;Ontario;M2P 2A8;Canada +email;internet:ahammond@ca.afilias.info +title:Database Administrator +tel;work:416-673-4138 +tel;fax:416-646-1541 +tel;home:416-214-1109 +tel;cell:647-285-7106 +note;quoted-printable:I sign all emails with my GPG key. Fingerprint is:=0D=0A= + CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +x-mozilla-html:TRUE +url:http://www.afilias.info/ +version:2.1 +end:vcard + + +--------------000302040002080202090002-- + +From pgsql-performance-owner@postgresql.org Mon Jun 21 16:42:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 44582D1B18C + for ; + Mon, 21 Jun 2004 16:42: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 00646-01 + for ; + Mon, 21 Jun 2004 19:42:10 +0000 (GMT) +Received: from mail.libertyrms.com (unknown [207.219.45.62]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FBFBD1B169 + for ; + Mon, 21 Jun 2004 16:42:07 -0300 (ADT) +Received: from dba4.int.libertyrms.com ([10.1.3.13] ident=ahammond) + by mail.libertyrms.com with esmtp (Exim 4.22) + id 1BcUgB-0006fr-M3; Mon, 21 Jun 2004 15:42:07 -0400 +Message-ID: <40D73B2F.40708@ca.afilias.info> +Date: Mon, 21 Jun 2004 15:46:55 -0400 +From: Andrew Hammond +Organization: Afilias Canada Corp. +User-Agent: Mozilla Thunderbird 0.6 (X11/20040512) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: marcus@coldfeetcreative.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Pl/Pgsql Functions running simultaneously +References: <200406021608.56919.marcus@coldfeetcreative.com> + <200406031638.03409.marcus@coldfeetcreative.com> +In-Reply-To: <200406031638.03409.marcus@coldfeetcreative.com> +X-Enigmail-Version: 0.83.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------040107020200000105030501" +X-SA-Exim-Mail-From: ahammond@ca.afilias.info +X-SA-Exim-Scanned: No; SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/216 +X-Sequence-Number: 7274 + +This is a multi-part message in MIME format. +--------------040107020200000105030501 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Marcus Whitney wrote: +| Am I on the wrong list to ask this question, or does this list usually +have +| low activity? Just asking because I am new and I need to know where +to ask +| this question. Thanks. + +Your .sig may hold the reason why people are not responding. You seem +like an intelligent guy and you asked an interesting question, but... + +| cold feet presents emma +| +| email marketing for discriminating +| ^^^^^^^^^^^^^^^ +| organizations everywhere +| +| visit www.myemma.com + +- -- +Andrew Hammond 416-673-4138 ahammond@ca.afilias.info +Database Administrator, Afilias Canada Corp. +CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFA1zstgfzn5SevSpoRApgdAKCtjL4qMwNQ9mZN57RHmHJi5Ana0wCggXhb +7HYFtE3S9zQ2hSGR9vYdXYQ= +=Kfqd +-----END PGP SIGNATURE----- + +--------------040107020200000105030501 +Content-Type: text/x-vcard; charset=utf8; + name="ahammond.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="ahammond.vcf" + +begin:vcard +fn:Andrew Hammond +n:Hammond;Andrew +org:Afilias Canada Corp.;Operations +adr:Suite 204;;4141 Yonge Street;North York;Ontario;M2P 2A8;Canada +email;internet:ahammond@ca.afilias.info +title:Database Administrator +tel;work:416-673-4138 +tel;fax:416-646-1541 +tel;home:416-214-1109 +tel;cell:647-285-7106 +note;quoted-printable:I sign all emails with my GPG key. Fingerprint is:=0D=0A= + CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +x-mozilla-html:TRUE +url:http://www.afilias.info/ +version:2.1 +end:vcard + + +--------------040107020200000105030501-- + +From pgsql-performance-owner@postgresql.org Mon Jun 21 22:33:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F504D1B289 + for ; + Mon, 21 Jun 2004 22:33: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 32376-04 + for ; + Tue, 22 Jun 2004 01:33: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 9B4AAD1B1B6 + for ; + Mon, 21 Jun 2004 22:32:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5M1X1n1008682; + Mon, 21 Jun 2004 21:33:01 -0400 (EDT) +To: Andrew Hammond +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres over Linux NBD or NFS +In-reply-to: <40D722CC.8000905@ca.afilias.info> +References: <40D722CC.8000905@ca.afilias.info> +Comments: In-reply-to Andrew Hammond + message dated "Mon, 21 Jun 2004 14:02:52 -0400" +Date: Mon, 21 Jun 2004 21:33:01 -0400 +Message-ID: <8681.1087867981@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/217 +X-Sequence-Number: 7275 + +Andrew Hammond writes: +> We're looking for an alternative to fiber-channel disk arrays for mass +> storage. One of the ideas that we're exploring would involve having the +> cluster on an NFS mounted filesystem. Another technology we're looking +> at is the Linux NBD (Network Block Device). + +There are a lot of horror stories concerning running databases (not only +Postgres) over NFS. I wouldn't recommend it. Dunno anything about NBD +though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jun 21 23:44:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A0F2D1B1EC + for ; + Mon, 21 Jun 2004 23:44: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 58517-03 + for ; + Tue, 22 Jun 2004 02:44:55 +0000 (GMT) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 5AFA3D1B1E0 + for ; + Mon, 21 Jun 2004 23:44:50 -0300 (ADT) +Received: from [10.4.3.101] (unknown [10.4.3.101]) + by steelhead.ravensfield.com (Postfix) with ESMTP + id 115BD6614A; Mon, 21 Jun 2004 22:44:54 -0400 (EDT) +In-Reply-To: <40D722CC.8000905@ca.afilias.info> +References: <40D722CC.8000905@ca.afilias.info> +Mime-Version: 1.0 (Apple Message framework v618) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <644E3D69-C3F6-11D8-8816-000393A47FCC@ravensfield.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: Re: Postgres over Linux NBD or NFS +Date: Mon, 21 Jun 2004 22:46:41 -0400 +To: Andrew Hammond +X-Mailer: Apple Mail (2.618) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/218 +X-Sequence-Number: 7276 + + +On Jun 21, 2004, at 2:02 PM, Andrew Hammond wrote: + +> -----BEGIN PGP SIGNED MESSAGE----- +> Hash: SHA1 +> +> We're looking for an alternative to fiber-channel disk arrays for mass +> storage. One of the ideas that we're exploring would involve having the +> cluster on an NFS mounted filesystem. Another technology we're looking +> at is the Linux NBD (Network Block Device). +> + +No idea about NBDs, but its generally accepted that running over NFS +would significantly +decrease reliability and performance, i.e. it would be a Bad Move (tm). +Not sure what you +think to gain. I sure wouldn't trust NFS with a production database. + +What exactly are you trying to gain, avoid, or do? + +> Has anyone had any experience with running postgres over either of +> these +> technologies? What issues do we need to know about / pay attention to? +> +> - -- +> Andrew Hammond 416-673-4138 ahammond@ca.afilias.info +> Database Administrator, Afilias Canada Corp. +> CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +> -----BEGIN PGP SIGNATURE----- +> Version: GnuPG v1.2.4 (GNU/Linux) +> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org +> +> iD8DBQFA1yK6gfzn5SevSpoRAtYAAKCrghfAKV5kVuiTd/2TOwEbr4Q7hACgr3rT +> mEvFi8AOHX9I43T45fH1e0U= +> =1Cs9 +> -----END PGP SIGNATURE----- +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to +> majordomo@postgresql.org) +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 00:46:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BD44D1B1C8 + for ; + Tue, 22 Jun 2004 00:46: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 84501-04 + for ; + Tue, 22 Jun 2004 03:45:58 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id 35828D1B191 + for ; + Tue, 22 Jun 2004 00:45:57 -0300 (ADT) +Received: (qmail 4493 invoked by uid 0); 22 Jun 2004 03:17:07 -0000 +Received: from mpls-pop-07.inet.qwest.net (63.231.195.7) + by mpls-qmqp-03.inet.qwest.net with QMQP; 22 Jun 2004 03:17:07 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-07.inet.qwest.net with SMTP; 22 Jun 2004 03:45:56 -0000 +Date: Mon, 21 Jun 2004 21:46:45 -0600 +Message-Id: <1087876005.1187.941.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Andrew Rawnsley" +Cc: "Andrew Hammond" , + pgsql-performance@postgresql.org +Subject: Re: Postgres over Linux NBD or NFS +In-Reply-To: <644E3D69-C3F6-11D8-8816-000393A47FCC@ravensfield.com> +References: <40D722CC.8000905@ca.afilias.info> + <644E3D69-C3F6-11D8-8816-000393A47FCC@ravensfield.com> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/219 +X-Sequence-Number: 7277 + +On Mon, 2004-06-21 at 20:46, Andrew Rawnsley wrote: +> On Jun 21, 2004, at 2:02 PM, Andrew Hammond wrote: +> +> > -----BEGIN PGP SIGNED MESSAGE----- +> > Hash: SHA1 +> > +> > We're looking for an alternative to fiber-channel disk arrays for mass +> > storage. One of the ideas that we're exploring would involve having the +> > cluster on an NFS mounted filesystem. Another technology we're looking +> > at is the Linux NBD (Network Block Device). +> > +> +> No idea about NBDs, but its generally accepted that running over NFS +> would significantly +> decrease reliability and performance, i.e. it would be a Bad Move (tm). +> Not sure what you +> think to gain. I sure wouldn't trust NFS with a production database. +> +> What exactly are you trying to gain, avoid, or do? + +I've gotten good performance over NFS using switched 100, then later +gigabit. But I wouldn't trust it for diddly. + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 12:44:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CF674D1B209 + for ; + Tue, 22 Jun 2004 02:12: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 13626-06 + for ; + Tue, 22 Jun 2004 05:12:50 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B59CD1B1CF + for ; + Tue, 22 Jun 2004 02:12:48 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i5M5CmQC046504 + for ; Tue, 22 Jun 2004 05:12:48 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i5M4ki8m040101 + for pgsql-performance@postgresql.org; Tue, 22 Jun 2004 04:46:44 GMT +From: "Mischa Sandberg" +X-Newsgroups: comp.databases.postgresql.performance +References: <20040618132554.72968.qmail@web25103.mail.ukl.yahoo.com> + <20412.1087570627@sss.pgh.pa.us> + <20040618163003.GM11196@ns.snowman.net> + <22514.1087578111@sss.pgh.pa.us> +Subject: Re: Major differences between oracle and postgres performance - what + can I do ? +Lines: 31 +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +Message-ID: +Date: Tue, 22 Jun 2004 04:46:44 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200406/296 +X-Sequence-Number: 7354 + +Don't know about Oracle, but select-distinct in MSSQL2K will indeed throw +away duplicates, which chops the CPU time. Very easy to see in the graphic +query plan, both in terms of CPU and the number of rows retrieved from a +single-node or nested-loop subtree. Definitely a worthwhile optimization. + +"Tom Lane" wrote in message +news:22514.1087578111@sss.pgh.pa.us... +> Stephen Frost writes: +> > * Tom Lane (tgl@sss.pgh.pa.us) wrote: +> >> [... thinks for awhile ...] It seems possible that they may use sort +> >> code that knows it is performing a DISTINCT operation and discards +> >> duplicates on sight. Given that there are only 534 distinct values, +> >> the sort would easily stay in memory if that were happening. +> +> > Could this optimization be added to PostgreSQL? It sounds like a very +> > reasonable thing to do. +> +> That's what I was wondering about too. But first I'd like to get +> some kind of reading on how effective it would be. If someone can +> demonstrate that Oracle can do sort-and-drop-dups a lot faster than +> it can do a straight sort of the same amount of input data, that +> would be a strong indication that it's worth doing. At this point +> we don't know if that's the source of their win or not. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> + + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 12:44:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2093AD1B2D9 + for ; + Tue, 22 Jun 2004 08:26: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 76430-01 + for ; + Tue, 22 Jun 2004 11:26:03 +0000 (GMT) +Received: from planae.com.br (nat.planae.com.br [200.210.129.190]) + by svr1.postgresql.org (Postfix) with SMTP id 54E56D1B20E + for ; + Tue, 22 Jun 2004 08:25:57 -0300 (ADT) +Received: (qmail 38674 invoked by uid 85); 22 Jun 2004 11:29:10 -0000 +Received: from unknown (HELO smannote) (192.168.0.207) + by 192.168.0.3 with SMTP; 22 Jun 2004 11:29:06 -0000 +Message-ID: <00c201c4584b$b6f09c70$cf00a8c0@smannote> +From: "Carlos Eduardo Smanioto" +To: "Scott Marlowe" , + "Andrew Rawnsley" +Cc: "Andrew Hammond" , + +References: <40D722CC.8000905@ca.afilias.info> + <644E3D69-C3F6-11D8-8816-000393A47FCC@ravensfield.com> + <1087876005.1187.941.camel@localhost.localdomain> +Subject: Re: Postgres over Linux NBD or NFS +Date: Tue, 22 Jun 2004 08:25:38 -0300 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit +X-Priority: 1 +X-MSMail-Priority: High +X-Mailer: Microsoft Outlook Express 6.00.3718.0 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3718.0 +X-Virus-Scanned: by AMaViS 0.3.12 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 + tests=X_MSMAIL_PRIORITY_HIGH, X_PRIORITY_HIGH +X-Spam-Level: * +X-Archive-Number: 200406/297 +X-Sequence-Number: 7355 + +Anselmo bom dia! + +N�o � custoso monstar um Cluster (Storage caseiro) em PostgreSQL, Est� em +discuss�o no forum da PostgreSQL a poss�bilidade de usar o NFS (Network file +system) ou o NBD (Network Block Device), ambos consistem em "Mapear" a +parti��o de dados do PostgreSQL em uma OUTRA m�quina com PostgreSQL a fim de +que os as duas m�quinas trabalhem com a mesma base de dados. + +Carlos Eduardo Smanioto +Infra Estrutura - Servidores e Seguran�a +Planae - Tecnologia da Informa��o +Fone/Fax +55 14 3224-3066 Ramal 207 +www.planae.com.br + +----- Original Message ----- +From: "Scott Marlowe" +To: "Andrew Rawnsley" +Cc: "Andrew Hammond" ; + +Sent: Tuesday, June 22, 2004 12:46 AM +Subject: Re: [PERFORM] Postgres over Linux NBD or NFS + + +> On Mon, 2004-06-21 at 20:46, Andrew Rawnsley wrote: +> > On Jun 21, 2004, at 2:02 PM, Andrew Hammond wrote: +> > +> > > -----BEGIN PGP SIGNED MESSAGE----- +> > > Hash: SHA1 +> > > +> > > We're looking for an alternative to fiber-channel disk arrays for mass +> > > storage. One of the ideas that we're exploring would involve having +the +> > > cluster on an NFS mounted filesystem. Another technology we're looking +> > > at is the Linux NBD (Network Block Device). +> > > +> > +> > No idea about NBDs, but its generally accepted that running over NFS +> > would significantly +> > decrease reliability and performance, i.e. it would be a Bad Move (tm). +> > Not sure what you +> > think to gain. I sure wouldn't trust NFS with a production database. +> > +> > What exactly are you trying to gain, avoid, or do? +> +> I've gotten good performance over NFS using switched 100, then later +> gigabit. But I wouldn't trust it for diddly. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 09:12:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7843FD1B1A0 + for ; + Tue, 22 Jun 2004 09:12: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 00180-02 + for ; + Tue, 22 Jun 2004 12:12:53 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id B34C7D1B1BC + for ; + Tue, 22 Jun 2004 09:12:49 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i5MCCmQC033536 + for ; Tue, 22 Jun 2004 12:12:48 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i5MBoXIi028251 + for pgsql-performance@postgresql.org; Tue, 22 Jun 2004 11:50:33 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Postgres over Linux NBD or NFS +Date: Tue, 22 Jun 2004 07:50:34 -0400 +Organization: cbbrowne Computing Inc +Lines: 58 +Message-ID: +References: <40D722CC.8000905@ca.afilias.info> + <644E3D69-C3F6-11D8-8816-000393A47FCC@ravensfield.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:MRPQytklXo31g2J3nrqkcOo5wZ0= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/220 +X-Sequence-Number: 7278 + +In an attempt to throw the authorities off his trail, ronz@ravensfield.com (Andrew Rawnsley) transmitted: +> On Jun 21, 2004, at 2:02 PM, Andrew Hammond wrote: +>> We're looking for an alternative to fiber-channel disk arrays for mass +>> storage. One of the ideas that we're exploring would involve having the +>> cluster on an NFS mounted filesystem. Another technology we're looking +>> at is the Linux NBD (Network Block Device). +> +> No idea about NBDs, but its generally accepted that running over NFS +> would significantly decrease reliability and performance, i.e. it +> would be a Bad Move (tm). Not sure what you think to gain. I sure +> wouldn't trust NFS with a production database. +> +> What exactly are you trying to gain, avoid, or do? + +The point of the exercise is to try to come up with something that is +a near-substitute for a SAN. + +With a SAN, you have a box with a whole lot of disk in it, and then +your database servers connect to that box, typically via something +like fibrechannel. + +One of the goals is for this to allow trying out Opterons at low risk. +Should performance turn out to suck or there be some other +disqualification, it's simple to hook the disk up to something else +instead. + +The other goal is to be able to stick LOTS of disk into one box, and +dole it out to multiple servers. It's more expensive to set up and +manage 3 RAID arrays than it is to set up and manage just 1, because +you have to manage 3 sets of disk hardware rather than 1. + +But I'm getting convinced that the attempt to get this clever about it +is counterproductive unless you have outrageous amounts of money to +throw at it. + +- NFS may well be acceptable if you buy into something with potent FS + semantics, as with NetApp boxes. But they're REALLY expensive. + +- FibreChannel offers interesting options in conjunction with a fairly + smart SAN box and Veritas, where you could have 5TB of storage in + one box, and then assign 2TB apiece to two servers, and the other + 1TB to a third. But the pricing premium again leaps out at ya. + +The "poor man's approach" involves trying to fake this by building a +"disk box" running Linux that exports the storage either as a +filesystem (using NFS) or as disk blocks (NBD). NFS clearly doesn't +provide the filesystem semantics needed to get decent reliability; +with NBD, it's not clear what happens :-(. + +Barring that, it means building a separate RAID array for each server, +and living with the limitation that a full set of disk hardware has to +be devoted to each DB server. +-- +wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','acm.org'). +http://www3.sympatico.ca/cbbrowne/ +Rules of the Evil Overlord #46. "If an advisor says to me "My liege, +he is but one man. What can one man possibly do?", I will reply +"This." and kill the advisor." + +From pgsql-performance-owner@postgresql.org Tue Jun 22 09:47:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 925C8D1B21B + for ; + Tue, 22 Jun 2004 09:47: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 16549-04 + for ; + Tue, 22 Jun 2004 12:47:46 +0000 (GMT) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 90D31D1B209 + for ; + Tue, 22 Jun 2004 09:47:39 -0300 (ADT) +Received: from [10.1.2.5] (unknown [10.1.2.5]) + by steelhead.ravensfield.com (Postfix) with ESMTP + id A013C6614A; Tue, 22 Jun 2004 08:47:42 -0400 (EDT) +In-Reply-To: +References: <40D722CC.8000905@ca.afilias.info> + <644E3D69-C3F6-11D8-8816-000393A47FCC@ravensfield.com> + +Mime-Version: 1.0 (Apple Message framework v618) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <9B0A994C-C44A-11D8-BF71-000393A47FCC@ravensfield.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: Re: Postgres over Linux NBD or NFS +Date: Tue, 22 Jun 2004 08:49:31 -0400 +To: Christopher Browne +X-Mailer: Apple Mail (2.618) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/221 +X-Sequence-Number: 7279 + + +There are some less expensive baby-SAN options coming out now - Dell +has an +rebranded EMC baby SAN (which of course doesn't work with any other EMC +system...) that starts at about $6000 or so. Just read the announcement +- don't know +anything else. While there have been some reports of undewhelming +performance for +database applications, the Apple XRaid has a sweet price point, +particularly if you're +in an industry that they want some exposure in (we're in financial +services, they almost +gave it to us...$7000 for 2TB, batteries, accessory kits, etc), and a +decent feature +set. It works with non-Apple stuff.. + +The baby-SANs don't necessarily do many of the things that you can get +out of a full-blown +EMC/NetApp rig, but then again, you're not paying for it either. + +There are a lot of lower-cost storage options popping up now, as +IDE/SATA disks arrays +proliferate. You can get external RAID boxes that talk SCSI or fiber +with IDE disks for +dirt these days. Small, too. Portable. I'm see little need to buy +massive boxes with +internal storage arrays anymore. + + +On Jun 22, 2004, at 7:50 AM, Christopher Browne wrote: + +> In an attempt to throw the authorities off his trail, +> ronz@ravensfield.com (Andrew Rawnsley) transmitted: +>> On Jun 21, 2004, at 2:02 PM, Andrew Hammond wrote: +>>> We're looking for an alternative to fiber-channel disk arrays for +>>> mass +>>> storage. One of the ideas that we're exploring would involve having +>>> the +>>> cluster on an NFS mounted filesystem. Another technology we're +>>> looking +>>> at is the Linux NBD (Network Block Device). +>> +>> No idea about NBDs, but its generally accepted that running over NFS +>> would significantly decrease reliability and performance, i.e. it +>> would be a Bad Move (tm). Not sure what you think to gain. I sure +>> wouldn't trust NFS with a production database. +>> +>> What exactly are you trying to gain, avoid, or do? +> +> The point of the exercise is to try to come up with something that is +> a near-substitute for a SAN. +> +> With a SAN, you have a box with a whole lot of disk in it, and then +> your database servers connect to that box, typically via something +> like fibrechannel. +> +> One of the goals is for this to allow trying out Opterons at low risk. +> Should performance turn out to suck or there be some other +> disqualification, it's simple to hook the disk up to something else +> instead. +> +> The other goal is to be able to stick LOTS of disk into one box, and +> dole it out to multiple servers. It's more expensive to set up and +> manage 3 RAID arrays than it is to set up and manage just 1, because +> you have to manage 3 sets of disk hardware rather than 1. +> +> But I'm getting convinced that the attempt to get this clever about it +> is counterproductive unless you have outrageous amounts of money to +> throw at it. +> +> - NFS may well be acceptable if you buy into something with potent FS +> semantics, as with NetApp boxes. But they're REALLY expensive. +> +> - FibreChannel offers interesting options in conjunction with a fairly +> smart SAN box and Veritas, where you could have 5TB of storage in +> one box, and then assign 2TB apiece to two servers, and the other +> 1TB to a third. But the pricing premium again leaps out at ya. +> +> The "poor man's approach" involves trying to fake this by building a +> "disk box" running Linux that exports the storage either as a +> filesystem (using NFS) or as disk blocks (NBD). NFS clearly doesn't +> provide the filesystem semantics needed to get decent reliability; +> with NBD, it's not clear what happens :-(. +> +> Barring that, it means building a separate RAID array for each server, +> and living with the limitation that a full set of disk hardware has to +> be devoted to each DB server. +> -- +> wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','acm.org'). +> http://www3.sympatico.ca/cbbrowne/ +> Rules of the Evil Overlord #46. "If an advisor says to me "My liege, +> he is but one man. What can one man possibly do?", I will reply +> "This." and kill the advisor." +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 10:21:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 742AED1B1CB + for ; + Tue, 22 Jun 2004 10:21: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 27180-07 + for ; + Tue, 22 Jun 2004 13:21:22 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E3F2D1B169 + for ; + Tue, 22 Jun 2004 10:21:16 -0300 (ADT) +Received: from solent (82-68-95-1.dsl.in-addr.zen.co.uk [82.68.95.1]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id 25CD49E123; Tue, 22 Jun 2004 14:21:18 +0100 (BST) +From: "Matt Clark" +To: "'Christopher Browne'" , + +Subject: Re: Postgres over Linux NBD or NFS +Date: Tue, 22 Jun 2004 14:21:10 +0100 +Message-ID: <000001c4585b$caac3c50$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +Importance: Normal +In-Reply-To: +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/222 +X-Sequence-Number: 7280 + +How about iSCSI? This is exactly what it's for - presenting a bunch of +remote SCSI hardware as if it were local.=20=20 + +There are several reference implementations on SourceForge from Intel, Cisco +& others. + +I've never tried it myself, but I would if I had the need. And let's face +it there are some very big players selling very pricey kit that uses it, so +you should have pretty high confidence that the fundamentals are strong. + +M + + + +> The other goal is to be able to stick LOTS of disk into one=20 +> box, and dole it out to multiple servers. It's more=20 +> expensive to set up and manage 3 RAID arrays than it is to=20 +> set up and manage just 1, because you have to manage 3 sets=20 +> of disk hardware rather than 1. +[snip] +> The "poor man's approach" involves trying to fake this by=20 +> building a "disk box" running Linux that exports the storage=20 +> either as a filesystem (using NFS) or as disk blocks (NBD).=20=20 +> NFS clearly doesn't provide the filesystem semantics needed=20 +> to get decent reliability; with NBD, it's not clear what happens :-(. + + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 10:34:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3C0CD1B199 + for ; + Tue, 22 Jun 2004 10:34: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 40787-06 + for ; + Tue, 22 Jun 2004 13:34:53 +0000 (GMT) +Received: from xtecnica.com (host154-218.pool80206.interbusiness.it + [80.206.218.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 32981D1B191 + for ; + Tue, 22 Jun 2004 10:34:47 -0300 (ADT) +Received: from DOMENICO2K by xtecnica.com (MDaemon.PRO.v7.1.1.R) + with ESMTP id md50000022851.msg + for ; Tue, 22 Jun 2004 15:34:54 +0200 +Message-ID: <004d01c4585d$83bc1200$70c8007e@xtecnica.it> +Reply-To: "Domenico Sgarbossa" +From: "Domenico Sgarbossa" +To: +References: <003c01c44fbd$c84a6af0$2500fa0a@CardServices.TCI.com> + <004c01c44fc3$d7cdeaf0$70c8007e@xtecnica.it> + <87pt8616i3.fsf@asmodeus.mcnaught.org> + <1087226647.1775.14.camel@kaos> + <011101c4553b$c1967130$70c8007e@xtecnica.it> + <20554.1087571463@sss.pgh.pa.us> + <1087582040.28062.13.camel@localhost.localdomain> + <40D338BC.7080705@commandprompt.com> + <1087585107.28062.16.camel@localhost.localdomain> +Subject: Re: [BULK] Problems with vacuum! +Date: Tue, 22 Jun 2004 15:33:33 +0200 +Organization: XTECNICA srl +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 1 +X-MSMail-Priority: High +X-Mailer: Microsoft Outlook Express 5.50.4927.1200 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 +X-Authenticated-Sender: domenico@xtecnica.com +X-Spam-Processed: xtecnica.com, Tue, 22 Jun 2004 15:34:54 +0200 + (not processed: message from valid local sender) +X-MDRemoteIP: 126.0.200.112 +X-Return-Path: domenico@xtecnica.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: xtecnica.com, Tue, 22 Jun 2004 15:34:54 +0200 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 + tests=X_MSMAIL_PRIORITY_HIGH, X_PRIORITY_HIGH +X-Spam-Level: * +X-Archive-Number: 200406/223 +X-Sequence-Number: 7281 + +As you suggets I've tried to upgrade to the kernel 2.4.28, but it seems that +nothing change! +I built a new machine with Red Hat 8 (kernel 2.4.28) a 1GB RAM using the +same parameters i've been used before. +After the boot, i've got 800Mb of free memory, if a launch a pg_dump then +the system swap (only 1 or 2 mb.....) and the +free memory become 20mb. +Now, if I tried a vacuumdb the system use partially the cached memory then +begin to swap again.... with 700mb of cached +memory it's very strange that the system swap again.... + +anyone know why this happend? + +Distinti Saluti + +Sgarbossa Domenico +X Tecnica S.R.L. +www.xtecnica.com +Tel: 049/9409154 - 049/5970297 +Fax: 049/9400288 + +----- Original Message ----- +From: "Scott Marlowe" +To: "Joshua D. Drake" +Cc: "Tom Lane" ; "Domenico Sgarbossa" +; +Sent: Friday, June 18, 2004 8:58 PM +Subject: Re: [PERFORM] [BULK] Problems with vacuum! + + +> I believe it was more like the kernel was tuned to make it less common, +> but certain things can still trigger it. I know the problem was still +> there in the 2.4.24 on the last server I was playing with, but it was a +> lot less of a problem than it had been under 2.4.9 on an earlier machine +> with the same basic amount of memory. +> +> On Fri, 2004-06-18 at 12:47, Joshua D. Drake wrote: +> > Hello, +> > +> > I would have to double check BUT I believe this is fixed in later 2.4.x +> > kernels as well. If you don't want to go through the hassle of 2.6 +> > (although it really is a nice kernel) then upgrade to 2.4.26. +> > +> > Sincerely, +> > +> > Joshau D. Drake +> > +> > Scott Marlowe wrote: +> > > On Fri, 2004-06-18 at 09:11, Tom Lane wrote: +> > > +> > >>"Domenico Sgarbossa" writes: +> > >> +> > >>>so when the users go home, i've got something like 15/20000kb free +ram, the +> > >>>rest is cached and 0kb of swap... +> > >>>It seems that when pg_dump starts the cached memory isn't released so +the +> > >>>system begin to swap, +> > >> +> > >>A sane kernel should drop disk buffers rather than swapping. We heard +> > >>recently about a bug in some versions of the Linux kernel that cause +it +> > >>to prefer swapping to discarding disk cache, though. It sounds like +> > >>that's what you're hitting. Look into newer kernels ... +> > > +> > > +> > > This was a common problem in the linux 2.4 series kernels, but has +> > > supposedly been fixed in the 2.6 kernels. Having lots of memory and +> > > turning off swap will "fix" the problem in 2.4, but if you run out of +> > > real mem, you're hosed. +> > > +> > > +> > > ---------------------------(end of +broadcast)--------------------------- +> > > TIP 4: Don't 'kill -9' the postmaster +> > +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> +> + + + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 10:44:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 38B9FD1B20D + for ; + Tue, 22 Jun 2004 10:44: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 45681-05 + for ; + Tue, 22 Jun 2004 13:44:21 +0000 (GMT) +Received: from mail.libertyrms.com (unknown [207.219.45.62]) + by svr1.postgresql.org (Postfix) with ESMTP id 99A23D1B1CF + for ; + Tue, 22 Jun 2004 10:44:15 -0300 (ADT) +Received: from dba4.int.libertyrms.com ([10.1.3.13] ident=ahammond) + by mail.libertyrms.com with esmtp (Exim 4.22) + id 1BclZT-0001yf-9N; Tue, 22 Jun 2004 09:44:19 -0400 +Message-ID: <40D838DB.7030707@ca.afilias.info> +Date: Tue, 22 Jun 2004 09:49:15 -0400 +From: Andrew Hammond +Organization: Afilias Canada Corp. +User-Agent: Mozilla Thunderbird 0.6 (X11/20040512) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andrew Rawnsley +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres over Linux NBD or NFS +References: <40D722CC.8000905@ca.afilias.info> + <644E3D69-C3F6-11D8-8816-000393A47FCC@ravensfield.com> +In-Reply-To: <644E3D69-C3F6-11D8-8816-000393A47FCC@ravensfield.com> +X-Enigmail-Version: 0.83.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------060900080508020500080105" +X-SA-Exim-Mail-From: ahammond@ca.afilias.info +X-SA-Exim-Scanned: No; SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/224 +X-Sequence-Number: 7282 + +This is a multi-part message in MIME format. +--------------060900080508020500080105 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +|> What exactly are you trying to gain, avoid, or do? + +Gain: seperate database storage from processing. This lets me move +clusters from one server to another easily. Just stop the postgres +instance on server A and unmount it's filesystem. Then mount it on +server B and start postgres instance on server B. It gives me some +fail-over capability as well as scalability and a lot of flexibility in +balancing load over multiple servers. + +Avoid: paying for brutally expensive FC gear. + +- -- +Andrew Hammond 416-673-4138 ahammond@ca.afilias.info +Database Administrator, Afilias Canada Corp. +CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFA2Djagfzn5SevSpoRAj+bAKDFFgrhX+G1gkZRrydow3j/j35VaACbBN3Y +C/0nWmqcwo/UlqvYpng06Ks= +=k2vg +-----END PGP SIGNATURE----- + +--------------060900080508020500080105 +Content-Type: text/x-vcard; charset=utf8; + name="ahammond.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="ahammond.vcf" + +begin:vcard +fn:Andrew Hammond +n:Hammond;Andrew +org:Afilias Canada Corp.;Operations +adr:Suite 204;;4141 Yonge Street;North York;Ontario;M2P 2A8;Canada +email;internet:ahammond@ca.afilias.info +title:Database Administrator +tel;work:416-673-4138 +tel;fax:416-646-1541 +tel;home:416-214-1109 +tel;cell:647-285-7106 +note;quoted-printable:I sign all emails with my GPG key. Fingerprint is:=0D=0A= + CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +x-mozilla-html:TRUE +url:http://www.afilias.info/ +version:2.1 +end:vcard + + +--------------060900080508020500080105-- + +From pgsql-performance-owner@postgresql.org Tue Jun 22 11:28:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 10D8FD1B220 + for ; + Tue, 22 Jun 2004 11:28: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 75070-08 + for ; + Tue, 22 Jun 2004 14:28:45 +0000 (GMT) +Received: from math.uchicago.edu (math.uchicago.edu [128.135.72.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 58929D1B199 + for ; + Tue, 22 Jun 2004 11:28:40 -0300 (ADT) +Received: from billnotebook (wireless-197-223.uchicago.edu [128.135.197.223]) + by math.uchicago.edu (8.12.10/8.12.10) with SMTP id i5MESffM016537 + for ; Tue, 22 Jun 2004 09:28:45 -0500 +Message-ID: <004001c45865$59cc9f20$dfc58780@billnotebook> +From: "Bill" +To: +Subject: postgresql and openmosix migration +Date: Tue, 22 Jun 2004 09:29:39 -0500 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_003D_01C4583B.70D68C00" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200406/225 +X-Sequence-Number: 7283 + +This is a multi-part message in MIME format. + +------=_NextPart_000_003D_01C4583B.70D68C00 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, I am trying to make a cluster out of any database, postgresql or mysql = +or any other free database. I have looked at openmosix patched with the mi= +gshm patch for shared memory support and it seems that neither work fully. = + Postgresql in particular uses "shared memory but not the system semaphores= + for locking it". Thus apparently it won't benefit from an openmosix clust= +er. In addition mysql doesn't seem to migrate because it is multithreaded.= + Any ideas of how I can cluster my database (around 800 GB in size so even= + partial replication is not really practical)? + +If interested this is my source for openmosix and migshm information http:/= +/howto.ipng.be/MigSHM-openMosix/x90.html + +Thanks. +------=_NextPart_000_003D_01C4583B.70D68C00 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi, I am trying to make a cluster out of a= +ny=20 +database, postgresql or mysql or any other free database.  I have look= +ed at=20 +openmosix patched with the migshm patch for shared memory support and it se= +ems=20 +that neither work fully.  Postgresql in particular uses "shared memory= + but=20 +not the system semaphores for locking it".  Thus apparently it won't= +=20 +benefit from an openmosix cluster.  In addition mysql doesn't seem to= +=20 +migrate because it is multithreaded.  Any ideas of how I can cluster m= +y=20 +database (around 800 GB in size so even partial replication is not really= +=20 +practical)?
+
 
+
If interested this is my source for openmo= +six and=20 +migshm information http://howto.ipng.b= +e/MigSHM-openMosix/x90.html
+
 
+
Thanks.
+ +------=_NextPart_000_003D_01C4583B.70D68C00-- + + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 12:00:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A0FA7D1B191 + for ; + Tue, 22 Jun 2004 12:00: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 96534-06 + for ; + Tue, 22 Jun 2004 15:00:48 +0000 (GMT) +Received: from web13125.mail.yahoo.com (web13125.mail.yahoo.com + [216.136.174.143]) + by svr1.postgresql.org (Postfix) with SMTP id 5A413D1B737 + for ; + Tue, 22 Jun 2004 12:00:44 -0300 (ADT) +Message-ID: <20040622150042.77663.qmail@web13125.mail.yahoo.com> +Received: from [63.78.248.48] by web13125.mail.yahoo.com via HTTP; + Tue, 22 Jun 2004 08:00:42 PDT +Date: Tue, 22 Jun 2004 08:00:42 -0700 (PDT) +From: Litao Wu +Subject: Re: reindex and copy - deadlock? +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <18172.1086985673@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/226 +X-Sequence-Number: 7284 + +Hi, + +I have changed "reindex table my_table" to: +psql ... + -c "drop index my_index; create index my_index;" + +We still experience the same "hang" problem. + +I was told that this time, the process is +"create index my_index;" before the PG server is +bounced. + +When I login the database, I found the +my_index is still there. + +I do not know what caused this happen, and I +am also confused. If create index my_index is killed +by "-9", then my_index should not present in the +database because it has been dropped before creating. + +On the other hand, if "drop index my_index;" is +killed, then how drop index (which is DDL, right?) +can be blocked? There must be other process(es) +has/have execlusive lock on my_index, which +is not our case from pg_locks. + +Tom, we are in the process of installing +the backend with --enable-debug. + +Thanks, + + +--- Tom Lane wrote: +> Litao Wu writes: +> > One difference between these two databases +> > is the one having REINDEX problem is using +> > NTFS file system. +> +> Oh? That's interesting. +> +> > Is it possible the root of problem? +> +> I would not expect it to show this particular +> symptom --- if the +> backtrace is accurate. But there are nearby places +> that might have +> FS-dependent behavior. Can you do anything about my +> request for +> a stack trace from a debug-enabled build? +> +> regards, tom lane + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail - Helps protect you from nasty viruses. +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Tue Jun 22 13:24:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B9B56D1B19C + for ; + Tue, 22 Jun 2004 13:24: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 43207-09 + for ; + Tue, 22 Jun 2004 16:24:02 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id A5F65D1B1C8 + for ; + Tue, 22 Jun 2004 13:24:01 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5450198; Tue, 22 Jun 2004 09:25:40 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Janio Rosa da Silva" , + +Subject: Re: Hi! +Date: Tue, 22 Jun 2004 09:23:26 -0700 +User-Agent: KMail/1.4.3 +References: <039601c456e5$437b4c70$0200a8c0@pc02> +In-Reply-To: <039601c456e5$437b4c70$0200a8c0@pc02> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200406220923.26779.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/227 +X-Sequence-Number: 7285 + +Janio, + +> I am trying install the postgresql-7.4.3 simple installation. I did +> ./configure command at the postgresql directory source. While the +> configuring proccess I receiving the follow message: + +This is the wrong list for this question. Please try PGSQL-ADMIN. You're +much more likely to get help there. + +Sorry! + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Jun 22 13:27:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A7E5D1B209 + for ; + Tue, 22 Jun 2004 13:26: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 47313-01 + for ; + Tue, 22 Jun 2004 16:26: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 8EBFAD1B18F + for ; + Tue, 22 Jun 2004 13:26:08 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5MGQ82N018876; + Tue, 22 Jun 2004 12:26:08 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: reindex and copy - deadlock? +In-reply-to: <20040622150042.77663.qmail@web13125.mail.yahoo.com> +References: <20040622150042.77663.qmail@web13125.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Tue, 22 Jun 2004 08:00:42 -0700" +Date: Tue, 22 Jun 2004 12:26:08 -0400 +Message-ID: <18875.1087921568@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/228 +X-Sequence-Number: 7286 + +Litao Wu writes: +> I have changed "reindex table my_table" to: +> psql ... +> -c "drop index my_index; create index my_index;" + +> I do not know what caused this happen, and I +> am also confused. If create index my_index is killed +> by "-9", then my_index should not present in the +> database because it has been dropped before creating. + +I believe that the above executes the two commands in a single +transaction. So if you kill it midway through the CREATE, everything +rolls back and the index is still there. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 22 13:34:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 162ADD1B1C9 + for ; + Tue, 22 Jun 2004 13:32: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 41934-09 + for ; + Tue, 22 Jun 2004 16:31:59 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id F1998D1B1B6 + for ; + Tue, 22 Jun 2004 13:31:58 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5450260; Tue, 22 Jun 2004 09:33:37 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Bill" , + +Subject: Re: postgresql and openmosix migration +Date: Tue, 22 Jun 2004 09:31:23 -0700 +User-Agent: KMail/1.4.3 +References: <004001c45865$59cc9f20$dfc58780@billnotebook> +In-Reply-To: <004001c45865$59cc9f20$dfc58780@billnotebook> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200406220931.23780.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/229 +X-Sequence-Number: 7287 + +Bill, + +> Any ideas of how I can cluster my database (around 800 GB +> in size so even partial replication is not really practical)? + +Um, raise $150,000 to pay for a clustering implementation? + +Various techniques of "shared memory clustering" have been tried with +PostgreSQL, and none work. Neither does LinuxLabs "ClusGres", which is +based on similar principles -- unfortunately. (at least, LL repeatedly +postponed the demo they said they'd give me. I've yet to see anything +working ...) + +Frankly, we're waiting for a well-funded corporation to jump in and decide +they want PostgreSQL clustering. Database server clustering is a "big +ticket item" requiring roughly 1,000 hours of programming and +troubleshooting. As such, you're not likely to see it come out of the OSS +community unaided. + +Oh, and FYI, MySQL's "clustering" doesn't work either. It requires your +entire database to fit into available RAM .... + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Jun 29 12:51:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 34593D1B169 + for ; + Tue, 22 Jun 2004 14: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 70830-07 + for ; + Tue, 22 Jun 2004 17:16:04 +0000 (GMT) +Received: from ms-smtp-05.tampabay.rr.com (ms-smtp-05-smtplb.tampabay.rr.com + [65.32.5.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 76A10D1B1C9 + for ; + Tue, 22 Jun 2004 14:16:00 -0300 (ADT) +Received: from MATTSPC (222-60.26-24.tampabay.rr.com [24.26.60.222]) + by ms-smtp-05.tampabay.rr.com (8.12.10/8.12.7) with ESMTP id + i5MHFuJI015547; Tue, 22 Jun 2004 13:15:57 -0400 (EDT) +Message-Id: <200406221715.i5MHFuJI015547@ms-smtp-05.tampabay.rr.com> +From: "Matthew Nuzum" +To: "'Andrew Hammond'" +Cc: +Subject: Re: Postgres over Linux NBD or NFS +Date: Tue, 22 Jun 2004 13:15:53 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +In-reply-to: <40D838DB.7030707@ca.afilias.info> +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Thread-Index: AcRYYOjbahNpJ84MSJaUejYeJL3F4QAGtGmw +X-Virus-Scanned: Symantec AntiVirus Scan Engine +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.2 tagged_above=0.0 required=5.0 tests=EARN_MONEY, + RCVD_IN_SORBS +X-Spam-Level: * +X-Archive-Number: 200406/298 +X-Sequence-Number: 7356 + +I just got the BigAdmin newsletter from Sun today... interestingly enough it +had a link to an article described as: + +> Database Performance with NAS: Optimizing Oracle on NFS +> This paper discusses the operation of relational databases with network +> attached storage (NAS). Management implications and performance +> expectations for databases using NAS are presented. +The link points to: http://www.sun.com/bigadmin/content/nas/ + +I read just enough to see if it is relevant. Here is the first part of the +summary: + +> IT departments are increasingly utilizing Network Attached Storage (NAS) +> and the Network File System (NFS) to meet the storage needs of mission- +> critical relational databases. Reasons for this adoption include improved +> storage virtualization, ease of storage deployment, decreased complexity, +> and decreased total cost of ownership. This paper directly examines the +> performance of databases with NAS. In laboratory tests comparing NFS with +> local storage, NFS is shown capable of sustaining the same workload level +> as local storage. Under similar workload conditions, NFS does consume an +> increased number of CPU cycles; however, the proven benefits of NFS and +> NAS outweigh this penalty in most production environments. + +Matthew Nuzum | ISPs: Make $200 - $5,000 per referral by +www.followers.net | recomending Elite CMS to your customers! +matt@followers.net | http://www.followers.net/isp + + + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 14:30:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D70D6D1B18F + for ; + Tue, 22 Jun 2004 14:30: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 75487-07 + for ; + Tue, 22 Jun 2004 17:30:27 +0000 (GMT) +Received: from math.uchicago.edu (math.uchicago.edu [128.135.72.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C665D1B1E0 + for ; + Tue, 22 Jun 2004 14:30:21 -0300 (ADT) +Received: from billnotebook (wireless-199-135.uchicago.edu [128.135.199.135]) + by math.uchicago.edu (8.12.10/8.12.10) with SMTP id i5MHUHfM019307; + Tue, 22 Jun 2004 12:30:20 -0500 +Message-ID: <008201c4587e$b8856510$dfc58780@billnotebook> +From: "Bill" +To: "Josh Berkus" +Cc: +References: <004001c45865$59cc9f20$dfc58780@billnotebook> + <200406220931.23780.josh@agliodbs.com> +Subject: Re: postgresql and openmosix migration +Date: Tue, 22 Jun 2004 12:31:15 -0500 +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.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/230 +X-Sequence-Number: 7288 + +Ok, so maybe someone on this group will have a better idea. We have a +database of financial information, and this has literally millions of +entries. I have installed indicies, but for the rather computationally +demanding processes we like to use, like a select query to find the +commodity with the highest monthly or annual returns, the computer generally +runs unacceptably slow. So, other than clustring, how could I achieve a +speed increase in these complex queries? Is this better in mysql or +postgresql? + +Thanks. +----- Original Message ----- +From: "Josh Berkus" +To: "Bill" ; +Sent: Tuesday, June 22, 2004 11:31 AM +Subject: Re: [PERFORM] postgresql and openmosix migration + + +> Bill, +> +> > Any ideas of how I can cluster my database (around 800 GB +> > in size so even partial replication is not really practical)? +> +> Um, raise $150,000 to pay for a clustering implementation? +> +> Various techniques of "shared memory clustering" have been tried with +> PostgreSQL, and none work. Neither does LinuxLabs "ClusGres", which is +> based on similar principles -- unfortunately. (at least, LL repeatedly +> postponed the demo they said they'd give me. I've yet to see anything +> working ...) +> +> Frankly, we're waiting for a well-funded corporation to jump in and decide +> they want PostgreSQL clustering. Database server clustering is a "big +> ticket item" requiring roughly 1,000 hours of programming and +> troubleshooting. As such, you're not likely to see it come out of the +OSS +> community unaided. +> +> Oh, and FYI, MySQL's "clustering" doesn't work either. It requires your +> entire database to fit into available RAM .... +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> + + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 14:47:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 228A4D1B1B9 + for ; + Tue, 22 Jun 2004 14:47: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 81790-08 + for ; + Tue, 22 Jun 2004 17:47:11 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 258B0D1B1C8 + for ; + Tue, 22 Jun 2004 14:47:09 -0300 (ADT) +Received: (qmail 20271 invoked by uid 500); 22 Jun 2004 17:53:28 -0000 +Date: Tue, 22 Jun 2004 12:53:28 -0500 +From: Bruno Wolff III +To: Bill +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: postgresql and openmosix migration +Message-ID: <20040622175328.GA20086@wolff.to> +Mail-Followup-To: Bill , + Josh Berkus , pgsql-performance@postgresql.org +References: <004001c45865$59cc9f20$dfc58780@billnotebook> + <200406220931.23780.josh@agliodbs.com> + <008201c4587e$b8856510$dfc58780@billnotebook> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <008201c4587e$b8856510$dfc58780@billnotebook> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/231 +X-Sequence-Number: 7289 + +On Tue, Jun 22, 2004 at 12:31:15 -0500, + Bill wrote: +> Ok, so maybe someone on this group will have a better idea. We have a +> database of financial information, and this has literally millions of +> entries. I have installed indicies, but for the rather computationally +> demanding processes we like to use, like a select query to find the +> commodity with the highest monthly or annual returns, the computer generally +> runs unacceptably slow. So, other than clustring, how could I achieve a +> speed increase in these complex queries? Is this better in mysql or +> postgresql? + +Queries using max (or min) can often be rewritten as queries using ORDER BY +and LIMIT so that they can take advantage of indexes. Doing this might help +with some of the problems you are seeing. +If you commonly query on aggregated data it might be better to create +derived tables of the aggregated data maintained by triggers, and query +against them. If you do lots of selects relative to inserts and updates, +this could be a big win. + +From pgsql-performance-owner@postgresql.org Tue Jun 22 14:58:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F110D1B209 + for ; + Tue, 22 Jun 2004 14:57: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 93966-03 + for ; + Tue, 22 Jun 2004 17:57:22 +0000 (GMT) +Received: from corpmsx.gaiam.com (unknown [12.147.81.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 62010D1B173 + for ; + Tue, 22 Jun 2004 14:57:19 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.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 and openmosix migration +Date: Tue, 22 Jun 2004 11:58:39 -0600 +Message-ID: <8D36D5916571CB4489C2E4D0CAD6E89301BEE630@corpmsx.gaiam.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] postgresql and openmosix migration +Thread-Index: AcRYfv5jy4Hw+zAxRROAx38bzoyvUAAADmMw +From: +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200406/232 +X-Sequence-Number: 7290 + +Sounds like an issue I have experienced in Oracle as well. If you can +you might want consider breaking out your database into oltp (on line +transaction processing) and data warehouse db. You run you any reports +you can nightly into a set of warehouse tables and save your daytime +cpus for incoming info and special real-time (hottest commodity of the +day) reports that you have tuned the best you can. Anything you can +calculate in advance that won't change over time, should be saved in the +warehouse tables, so you don't waste cpus, re-working data in real time. +Pre-running your reports won't speed them up but your users won't be +waiting for a report to calculate while they are looking at the screen.=20 + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Bill +Sent: Tuesday, June 22, 2004 11:31 AM +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] postgresql and openmosix migration + +Ok, so maybe someone on this group will have a better idea. We have a +database of financial information, and this has literally millions of +entries. I have installed indicies, but for the rather computationally +demanding processes we like to use, like a select query to find the +commodity with the highest monthly or annual returns, the computer +generally +runs unacceptably slow. So, other than clustring, how could I achieve a +speed increase in these complex queries? Is this better in mysql or +postgresql? + +Thanks. +----- Original Message -----=20 +From: "Josh Berkus" +To: "Bill" ; +Sent: Tuesday, June 22, 2004 11:31 AM +Subject: Re: [PERFORM] postgresql and openmosix migration + + +> Bill, +> +> > Any ideas of how I can cluster my database (around 800 GB +> > in size so even partial replication is not really practical)? +> +> Um, raise $150,000 to pay for a clustering implementation? +> +> Various techniques of "shared memory clustering" have been tried with +> PostgreSQL, and none work. Neither does LinuxLabs "ClusGres", which +is +> based on similar principles -- unfortunately. (at least, LL repeatedly +> postponed the demo they said they'd give me. I've yet to see anything +> working ...) +> +> Frankly, we're waiting for a well-funded corporation to jump in and +decide +> they want PostgreSQL clustering. Database server clustering is a +"big +> ticket item" requiring roughly 1,000 hours of programming and +> troubleshooting. As such, you're not likely to see it come out of +the +OSS +> community unaided. +> +> Oh, and FYI, MySQL's "clustering" doesn't work either. It requires +your +> entire database to fit into available RAM .... +> +> --=20 +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> + + + +---------------------------(end of broadcast)--------------------------- +TIP 7: don't forget to increase your free space map settings + +From pgsql-performance-owner@postgresql.org Tue Jun 22 15:16:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 81E1DD1B170 + for ; + Tue, 22 Jun 2004 15:10: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 01552-01 + for ; + Tue, 22 Jun 2004 18:10:04 +0000 (GMT) +Received: from krusty-motorsports.com (krusty-motorsports.com [192.94.170.8]) + by svr1.postgresql.org (Postfix) with ESMTP id 81F46D1B169 + for ; + Tue, 22 Jun 2004 15:10:03 -0300 (ADT) +Received: from [24.194.112.77] (helo=skipper.averillpark.net) + by krusty-motorsports.com with asmtp (TLSv1:DES-CBC3-SHA:168) + (Exim 4.22) id 1Bcpib-00086T-TJ + for pgsql-performance@postgresql.org; Tue, 22 Jun 2004 18:10:01 +0000 +Received: from [127.0.0.1] (helo=localhost) + by skipper.averillpark.net with esmtp (Exim 4.22) id 1Bcpgo-0006dc-KV + for pgsql-performance@postgresql.org; Tue, 22 Jun 2004 14:08:10 -0400 +Date: Tue, 22 Jun 2004 14:08:10 -0400 (EDT) +From: Richard Welty +Subject: Re: postgresql and openmosix migration +To: pgsql-performance@postgresql.org +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; CHARSET=US-ASCII +Content-Disposition: INLINE +References: <004001c45865$59cc9f20$dfc58780@billnotebook> + <200406220931.23780.josh@agliodbs.com> + <008201c4587e$b8856510$dfc58780@billnotebook> +In-Reply-To: <008201c4587e$b8856510$dfc58780@billnotebook> +Organization: Averill Park Networking +X-Mailer: Mahogany 0.66.0 'Clio', compiled for Linux 2.4.18-14 i686 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/233 +X-Sequence-Number: 7291 + +On Tue, 22 Jun 2004 12:31:15 -0500 Bill wrote: +> I have installed indicies, + +but are there any statistics? vacuum analyze is your friend + +> but for the rather computationally +> demanding processes we like to use, like a select query to find the +> commodity with the highest monthly or annual returns, the computer generally +> runs unacceptably slow. So, other than clustring, how could I achieve a +> speed increase in these complex queries? + +1) have you gone to the effort to tune the values in postgresql.conf? + +2) have you tried using explain to find out what the query planner is + up to? + +> Is this better in mysql or +> postgresql? + +if there is any complexity to the queries, postgresql will serve you better +if you learn how to use it properly. + +richard +-- +Richard Welty rwelty@averillpark.net +Averill Park Networking 518-573-7592 + Java, PHP, PostgreSQL, Unix, Linux, IP Network Engineering, Security + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 15:43:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 81F94D1B209 + for ; + Tue, 22 Jun 2004 15:43: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 10501-10 + for ; + Tue, 22 Jun 2004 18:43:10 +0000 (GMT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 83CADD1B1C8 + for ; + Tue, 22 Jun 2004 15:43:01 -0300 (ADT) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: after using pg_resetxlog, db lost +Date: Tue, 22 Jun 2004 14:42:56 -0400 +Message-ID: <644D07D3D59D8F408CD01AC2F833D8C62B9209@cisxa.cmc.int.ec.gc.ca> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Disappointing performance in db migrated from MS SQL +Thread-Index: AcPxphvY7k9/YNnkRAyCpV0qFdA8dxmwpf8g +From: "Shea,Dan [CIS]" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/234 +X-Sequence-Number: 7292 + +The pg_resetxlog was run as root. It caused ownership problems of +pg_control and xlog files. +Now we have no access to the data now through psql. The data is still +there under /var/lib/pgsql/data/base/17347 (PWFPM_DEV DB name). But +there is no reference to 36 of our tables in pg_class. Also the 18 +other tables that are reported in this database have no data in them. +Is there anyway to have the database resync or make it aware of the data +under /var/lib/pgsql/data/base/17347? +How can this problem be resolved? + +There is actually 346 db files adding up to 134 GB in this database. + + +Below are error messages of when the database trying to be started. I +am not sure of the when pg_resetxlog was run. I suspect it was run to +get rid ot the "invalid primary checkpoint record". + +The postgresql DB had an error trying to be started up.=20=20 +The error was +Jun 22 13:17:53 murphy postgres[27430]: [4-1] LOG: invalid primary +checkpoint record +Jun 22 13:17:53 murphy postgres[27430]: [5-1] LOG: could not open file +"/var/lib/pgsql/data/pg_xlog/0000000000000000" (log file 0, segment 0): +No such file or directory +Jun 22 13:18:49 murphy postgres[28778]: [6-1] LOG: invalid secondary +checkpoint record +Jun 22 13:18:49 murphy postgres[28778]: [7-1] PANIC: could not locate a +valid checkpoint record + + +Jun 22 13:26:01 murphy postgres[30770]: [6-1] LOG: database system is +ready +Jun 22 13:26:02 murphy postgresql: Starting postgresql service: +succeeded +Jun 22 13:26:20 murphy postgres[30789]: [2-1] PANIC: could not access +status of transaction 553 +Jun 22 13:26:20 murphy postgres[30789]: [2-2] DETAIL: could not open +file "/var/lib/pgsql/data/pg_clog/0000": No such file or directory +Jun 22 13:26:20 murphy postgres[30789]: [2-3] STATEMENT: COMMIT + +and +Jun 22 13:26:20 murphy postgres[30791]: [10-1] LOG: redo starts at +0/2000050 +Jun 22 13:26:20 murphy postgres[30791]: [11-1] LOG: file +"/var/lib/pgsql/data/pg_clog/0000" doesn't exist, reading as zeroes +Jun 22 13:26:20 murphy postgres[30791]: [12-1] LOG: record with zero +length at 0/2000E84 +Jun 22 13:26:20 murphy postgres[30791]: [13-1] LOG: redo done at +0/2000E60 +Jun 22 13:26:20 murphy postgres[30791]: [14-1] WARNING: xlog flush +request 213/7363F354 is not satisfied --- flushed only to 0/2000E84 +Jun 22 13:26:20 murphy postgres[30791]: [14-2] CONTEXT: writing block +840074 of relation 17347/356768772 +Jun 22 13:26:20 murphy postgres[30791]: [15-1] WARNING: xlog flush +request 213/58426648 is not satisfied --- flushed only to 0/2000E84 + +and +Jun 22 13:38:23 murphy postgres[1460]: [2-1] ERROR: xlog flush request +210/E757F150 is not satisfied --- flushed only to 0/2074CA0 +Jun 22 13:38:23 murphy postgres[1460]: [2-2] CONTEXT: writing block +824605 of relation 17347/356768772 + +We are using a san for our storage device. + +From pgsql-performance-owner@postgresql.org Tue Jun 22 15:50:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F11B1D1B19C + for ; + Tue, 22 Jun 2004 15: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 22101-01 + for ; + Tue, 22 Jun 2004 18:50:12 +0000 (GMT) +Received: from ms-smtp-02.tampabay.rr.com (ms-smtp-02-smtplb.tampabay.rr.com + [65.32.5.132]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CD00D1B191 + for ; + Tue, 22 Jun 2004 15:50:09 -0300 (ADT) +Received: from MATTSPC (222-60.26-24.tampabay.rr.com [24.26.60.222]) + by ms-smtp-02.tampabay.rr.com (8.12.10/8.12.7) with ESMTP id + i5MInpnb027568; Tue, 22 Jun 2004 14:49:52 -0400 (EDT) +Message-Id: <200406221849.i5MInpnb027568@ms-smtp-02.tampabay.rr.com> +From: "Matthew Nuzum" +To: "'Bill'" +Cc: +Subject: Re: postgresql and openmosix migration +Date: Tue, 22 Jun 2004 14:49:48 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +In-reply-to: <008201c4587e$b8856510$dfc58780@billnotebook> +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Thread-Index: AcRYf3uKWWOFXR3HQby3OJJ6Deo82gABLDkg +X-Virus-Scanned: Symantec AntiVirus Scan Engine +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=BE_AMAZED, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/235 +X-Sequence-Number: 7293 + +Hi Bill, I am more often in the "needing help" category than the "giving +help" when it comes to advise about using postgresql. I have found it to be +an extremely powerful tool and by far the best performance/price for my +work. + +I think you will get some excellent answers and help to your performance +questions if you send the list details about specific queries that are +running too slow. If you are willing to throw more/bigger hardware at the +problem, let people know that when you ask and they will tell you if your +bottleneck can be alleviated through more ram, disks, cpu or whatever. +Having been watching this list for some time now, I suspect most of the +performance problems can be improved using non-intuitive query or +configuration modifications (for example, replacing min()/max() as suggested +by Mr. Wolf). + +The heavy hitters on the list will usually ask for an "explain analyze" of +your query. If your query is "select * from foo", then change it to +"EXPLAIN ANALYZE select * from foo" and post the output. It will look +something like this: + QUERY PLAN + +---------------------------------------------------------------------------- +------------------------------- + Seq Scan on foo (cost=0.00..1.04 rows=4 width=44) (actual time=8.46..8.47 +rows=4 loops=1) + Total runtime: 19.63 msec +(2 rows) + +I'm sure your data is confidential; mine is too. The good news is that none +of your data is included in the query. Only technical details about what the +database is doing. + +If your problem might involve the application that works with the data, give +some details about that. For example, if you're using a Java application, +let people know what driver version you use, what jvm and other related +info. There are lurkers on this list using just about every programming +language imaginable on more platforms than you can shake a stick at (I don't +care how good you are at shaking sticks, either). + +The more details you give the better help you're going to get and you'd be +amazed at the results I've seen people get with a judicious amount of +tweaking. The other day someone had a query that took hours decrease to less +than 10 minutes by using some techniques prescribed by members on the list. +Bringing 30 - 60 second queries down to 2-3 seconds is commonplace. + +You seem to be ready to throw money at the problem by investing in new +hardware but I would suggest digging into the performance problems first. +Too many times we've seen people on the list say, "I've just spent $x0,000 +on a new xyz and I'm still having problems with this query." Often times +the true solution is rewriting queries, tweaking config parameters, adding +RAM and upgrading disks (in that order I believe). + +As I found out even today on the SQL list, it's best to ask questions in +this form: +"I want to do this... I've been trying this... I'm getting this... which +is problematic because..." + +The more clearly you state the abstract goal the more creative answers +you'll get with people often suggesting things you'd never considered. + +I hope this helps and I hope that you achieve your goals of a well +performing application. + +Matthew Nuzum | Makers of "Elite Content Management System" +www.followers.net | View samples of Elite CMS in action +matt@followers.net | http://www.followers.net/portfolio/ + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance- +> owner@postgresql.org] On Behalf Of Bill +> Sent: Tuesday, June 22, 2004 1:31 PM +> To: Josh Berkus +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] postgresql and openmosix migration +> +> Ok, so maybe someone on this group will have a better idea. We have a +> database of financial information, and this has literally millions of +> entries. I have installed indicies, but for the rather computationally +> demanding processes we like to use, like a select query to find the +> commodity with the highest monthly or annual returns, the computer +> generally +> runs unacceptably slow. So, other than clustring, how could I achieve a +> speed increase in these complex queries? Is this better in mysql or +> postgresql? +> +> Thanks. + + +From pgsql-performance-owner@postgresql.org Tue Jun 22 16:36:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A804D1B16A + for ; + Tue, 22 Jun 2004 16:36: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 37759-08 + for ; + Tue, 22 Jun 2004 19:36: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 D4874D1B1A5 + for ; + Tue, 22 Jun 2004 16:36:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5MJa3Xg021116; + Tue, 22 Jun 2004 15:36:03 -0400 (EDT) +To: "Shea,Dan [CIS]" +Cc: pgsql-performance@postgresql.org +Subject: Re: after using pg_resetxlog, db lost +In-reply-to: <644D07D3D59D8F408CD01AC2F833D8C62B9209@cisxa.cmc.int.ec.gc.ca> +References: <644D07D3D59D8F408CD01AC2F833D8C62B9209@cisxa.cmc.int.ec.gc.ca> +Comments: In-reply-to "Shea,Dan [CIS]" + message dated "Tue, 22 Jun 2004 14:42:56 -0400" +Date: Tue, 22 Jun 2004 15:36:03 -0400 +Message-ID: <21115.1087932963@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/236 +X-Sequence-Number: 7294 + +"Shea,Dan [CIS]" writes: +> The pg_resetxlog was run as root. It caused ownership problems of +> pg_control and xlog files. +> Now we have no access to the data now through psql. The data is still +> there under /var/lib/pgsql/data/base/17347 (PWFPM_DEV DB name). But +> there is no reference to 36 of our tables in pg_class. Also the 18 +> other tables that are reported in this database have no data in them. +> Is there anyway to have the database resync or make it aware of the data +> under /var/lib/pgsql/data/base/17347? +> How can this problem be resolved? + +What this sounds like is that you reset the transaction counter along +with the xlog, so that those tables appear to have been created by +transactions "in the future". This could be repaired by doing +pg_resetxlog with a more appropriate initial transaction ID, but +figuring out what that value should be is not easy :-( + +What I'd suggest is grabbing pg_filedump from +http://sources.redhat.com/rhdb/ +and using it to look through pg_class (which will be file +$PGDATA/base/yourdbnumber/1259) to see the highest transaction ID +mentioned in any row of pg_class. Then pg_resetxlog with a value +a bit larger than that. Now you should be able to see all the rows +in pg_class ... but this doesn't get you out of the woods yet, unless +there are very-recently-created tables shown in pg_class. I'd suggest +next looking through whichever tables you know to be recently modified +to find the highest transaction ID mentioned in them, and finally doing +another pg_resetxlog with a value a few million greater than that. Then +you should be okay. + +The reason you need to do this in two steps is that you'll need to look +at pg_class.relfilenode to get the file names of your recently-modified +tables. Do NOT modify the database in any way while you are running +with the intermediate transaction ID setting. + +> Jun 22 13:38:23 murphy postgres[1460]: [2-1] ERROR: xlog flush request +> 210/E757F150 is not satisfied --- flushed only to 0/2074CA0 + +Looks like you also need a larger initial WAL offset in your +pg_resetxlog command. Unlike the case with transaction IDs, there's +no need to try to be somewhat accurate in the setting --- I'd just +use a number WAY beyond what you had, maybe like 10000/0. + +Finally, the fact that all this happened suggests that you lost the +contents of pg_control (else pg_resetxlog would have picked up the right +values from it). Be very sure that you run pg_resetxlog under the same +locale settings (LC_COLLATE,LC_CTYPE) that you initially initdb'd with. +Otherwise you're likely to have nasty index-corruption problems later. + +Good luck. Next time, don't let amateurs fool with pg_resetxlog (and +anyone who'd run it as root definitely doesn't know what they're doing). +It is a wizard's tool. Get knowledgeable advice from the PG lists +before you use it rather than after. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 22 17:05:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F3030D1B209 + for ; + Tue, 22 Jun 2004 17:05: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 59277-02 + for ; + Tue, 22 Jun 2004 20:05:11 +0000 (GMT) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 00393D1B1C9 + for ; + Tue, 22 Jun 2004 17:05:07 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BcrW0-000605-0Z; Tue, 22 Jun 2004 21:05:08 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 8540F17360; Tue, 22 Jun 2004 21:05:07 +0100 (BST) +Message-ID: <40D890F3.8090208@archonet.com> +Date: Tue, 22 Jun 2004 21:05:07 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: "Shea,Dan [CIS]" , + pgsql-performance@postgresql.org +Subject: Re: after using pg_resetxlog, db lost +References: <644D07D3D59D8F408CD01AC2F833D8C62B9209@cisxa.cmc.int.ec.gc.ca> + <21115.1087932963@sss.pgh.pa.us> +In-Reply-To: <21115.1087932963@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/237 +X-Sequence-Number: 7295 + +Tom Lane wrote: +> "Shea,Dan [CIS]" writes: +> +>>The pg_resetxlog was run as root. It caused ownership problems of +>>pg_control and xlog files. +>>Now we have no access to the data now through psql. The data is still +>>there under /var/lib/pgsql/data/base/17347 (PWFPM_DEV DB name). But +>>there is no reference to 36 of our tables in pg_class. Also the 18 +>>other tables that are reported in this database have no data in them. +>>Is there anyway to have the database resync or make it aware of the data +>>under /var/lib/pgsql/data/base/17347? +>>How can this problem be resolved? +> +> +> What this sounds like is that you reset the transaction counter along +> with the xlog, so that those tables appear to have been created by +> transactions "in the future". This could be repaired by doing +> pg_resetxlog with a more appropriate initial transaction ID, but +> figuring out what that value should be is not easy :-( + +Tom - would there be any value in adding this to a pg_dump? I'm assuming +the numbers attached to tables etc are their OIDs anyway, so it might be +a useful reference in cases like this. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Jun 22 17:25:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EDADDD1B1BC + for ; + Tue, 22 Jun 2004 17:25: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 59277-10 + for ; + Tue, 22 Jun 2004 20:25:25 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 50D83D1B262 + for ; + Tue, 22 Jun 2004 17:25:22 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5MKPJKf021595; + Tue, 22 Jun 2004 16:25:19 -0400 (EDT) +To: Richard Huxton +Cc: "Shea,Dan [CIS]" , + pgsql-performance@postgresql.org +Subject: Re: after using pg_resetxlog, db lost +In-reply-to: <40D890F3.8090208@archonet.com> +References: <644D07D3D59D8F408CD01AC2F833D8C62B9209@cisxa.cmc.int.ec.gc.ca> + <21115.1087932963@sss.pgh.pa.us> <40D890F3.8090208@archonet.com> +Comments: In-reply-to Richard Huxton + message dated "Tue, 22 Jun 2004 21:05:07 +0100" +Date: Tue, 22 Jun 2004 16:25:19 -0400 +Message-ID: <21594.1087935919@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/238 +X-Sequence-Number: 7296 + +Richard Huxton writes: +> Tom Lane wrote: +>> This could be repaired by doing +>> pg_resetxlog with a more appropriate initial transaction ID, but +>> figuring out what that value should be is not easy :-( + +> Tom - would there be any value in adding this to a pg_dump? + +Possibly. CVS tip pg_dump has been changed to not output OIDs by +default, as a result of gripes from people who wanted to be able to +"diff" dumps from different servers and not have the diff cluttered +by irrelevant OID differences. But a single header line showing +current XID and OID values doesn't seem like it would be a big problem. +We could put current timestamp there too, which was another recent topic +of discussion. + +Bring it up on pghackers and see if anyone has an objection... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 22 22:25:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1264BD1B269 + for ; + Tue, 22 Jun 2004 22:25: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 91443-08 + for ; + Wed, 23 Jun 2004 01:25:16 +0000 (GMT) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E625D1B170 + for ; + Tue, 22 Jun 2004 22:25:12 -0300 (ADT) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1846306; Tue, 22 Jun 2004 18:17:29 -0700 +Message-ID: <40D8DBFC.2090208@joeconway.com> +Date: Tue, 22 Jun 2004 18:25:16 -0700 +From: Joe Conway +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bill +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: postgresql and openmosix migration +References: <004001c45865$59cc9f20$dfc58780@billnotebook> + <200406220931.23780.josh@agliodbs.com> + <008201c4587e$b8856510$dfc58780@billnotebook> +In-Reply-To: <008201c4587e$b8856510$dfc58780@billnotebook> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/239 +X-Sequence-Number: 7297 + +Bill wrote: +> Ok, so maybe someone on this group will have a better idea. We have a +> database of financial information, and this has literally millions of +> entries. I have installed indicies, but for the rather computationally +> demanding processes we like to use, like a select query to find the +> commodity with the highest monthly or annual returns, the computer generally +> runs unacceptably slow. So, other than clustring, how could I achieve a +> speed increase in these complex queries? Is this better in mysql or +> postgresql? + +If the bottleneck is really computational, not I/O, you might try PL/R +in conjunction with the rpvm R package. rpvm allows R to make use of pvm +to split its load among a cluster. See: + +R: + http://www.r-project.org/ + +PL/R: + http://www.joeconway.com/plr/ + +rpvm: + http://cran.r-project.org/src/contrib/Descriptions/rpvm.html + http://cran.r-project.org/doc/packages/rpvm.pdf + +I haven't had a chance to play with this myself yet, but I hope to +relatively soon. + +HTH, + +Joe + +From pgsql-performance-owner@postgresql.org Wed Jun 23 11:50:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D39A9D1B18F + for ; + Wed, 23 Jun 2004 11:42: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 62813-02 + for ; + Wed, 23 Jun 2004 14:42:16 +0000 (GMT) +Received: from mail.libertyrms.com (unknown [207.219.45.62]) + by svr1.postgresql.org (Postfix) with ESMTP id B20F2D1BAAF + for ; + Wed, 23 Jun 2004 11:42:08 -0300 (ADT) +Received: from dba4.int.libertyrms.com ([10.1.3.13] ident=ahammond) + by mail.libertyrms.com with esmtp (Exim 4.22) + id 1Bd8x2-00062i-IR; Wed, 23 Jun 2004 10:42:12 -0400 +Message-ID: <40D997F9.7000700@ca.afilias.info> +Date: Wed, 23 Jun 2004 10:47:21 -0400 +From: Andrew Hammond +Organization: Afilias Canada Corp. +User-Agent: Mozilla Thunderbird 0.6 (X11/20040512) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: postgresql and openmosix migration +References: <004001c45865$59cc9f20$dfc58780@billnotebook> + <200406220931.23780.josh@agliodbs.com> + <008201c4587e$b8856510$dfc58780@billnotebook> +In-Reply-To: <008201c4587e$b8856510$dfc58780@billnotebook> +X-Enigmail-Version: 0.83.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------020507050102040004020805" +X-SA-Exim-Mail-From: ahammond@ca.afilias.info +X-SA-Exim-Scanned: No; SAEximRunCond expanded to false +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/240 +X-Sequence-Number: 7298 + +This is a multi-part message in MIME format. +--------------020507050102040004020805 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Bill wrote: +| Ok, so maybe someone on this group will have a better idea. We have a +| database of financial information, and this has literally millions of +| entries. I have installed indicies, but for the rather computationally +| demanding processes we like to use, like a select query to find the +| commodity with the highest monthly or annual returns, the computer +generally +| runs unacceptably slow. So, other than clustring, how could I achieve a +| speed increase in these complex queries? Is this better in mysql or +| postgresql? + +Postgres generally beats MySQL on complex queries. The easiest solution +to speed issues is to throw hardware at it. Generally, you're first +bound by disk, RAM then CPU. + +1) Move your data over to an array of smallish 15kRPM disks. The more +spindles the better. +2) Use a 64 bit platform and take advantage of >4 GB memory. + +There are dozens of options for the disk array. For the processing +platform, I'd recommend looking at Opteron. I've heard only good things +and their price is much more reasonable than the other options. + +- -- +Andrew Hammond 416-673-4138 ahammond@ca.afilias.info +Database Administrator, Afilias Canada Corp. +CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFA2Zf3gfzn5SevSpoRAr0HAJ0S/uVjuqYEuhMgdSAI3rfHK0ga1wCgwpHl +g+yuBYpAt58vnJWtX+wii1s= +=2fGN +-----END PGP SIGNATURE----- + +--------------020507050102040004020805 +Content-Type: text/x-vcard; charset=utf8; + name="ahammond.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="ahammond.vcf" + +begin:vcard +fn:Andrew Hammond +n:Hammond;Andrew +org:Afilias Canada Corp.;Operations +adr:Suite 204;;4141 Yonge Street;North York;Ontario;M2P 2A8;Canada +email;internet:ahammond@ca.afilias.info +title:Database Administrator +tel;work:416-673-4138 +tel;fax:416-646-1541 +tel;home:416-214-1109 +tel;cell:647-285-7106 +note;quoted-printable:I sign all emails with my GPG key. Fingerprint is:=0D=0A= + CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A +x-mozilla-html:TRUE +url:http://www.afilias.info/ +version:2.1 +end:vcard + + +--------------020507050102040004020805-- + +From pgsql-performance-owner@postgresql.org Wed Jun 23 13:04:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 54F2FD1B175 + for ; + Wed, 23 Jun 2004 13:02: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 12349-06 + for ; + Wed, 23 Jun 2004 16:02:34 +0000 (GMT) +Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id C9E67D1B1EC + for ; + Wed, 23 Jun 2004 13:02:26 -0300 (ADT) +Received: from [127.0.0.1] (helo=localhost) + by stan.aopsys.com with esmtp (Exim 4.30) id 1BdACd-00074T-Rs + for pgsql-performance@postgresql.org; Wed, 23 Jun 2004 18:02:23 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Traduc Party +References: <1087930157.10632.14.camel@localhost> + <20040623112038.3350b5f9.matthieu.compin@parinux.org> + <1087983833.31174.16.camel@bugsbunny.mipsys.com> + <20040623130644.6bc4e86d.matthieu.compin@parinux.org> + <1087990354.31174.31.camel@bugsbunny.mipsys.com> + <20040623135214.0fa8e375.matthieu.compin@parinux.org> + <1087992537.2981.3.camel@bugsbunny.mipsys.com> + <20040623150732.667f80f2.matthieu.compin@parinux.org> +From: Laurent Martelli +Organization: Parinux +Date: Wed, 23 Jun 2004 18:02:23 +0200 +In-Reply-To: <20040623150732.667f80f2.matthieu.compin@parinux.org> (Matthieu + Compin's message of "Wed, 23 Jun 2004 15:07:32 +0200") +Message-ID: <87smcm9sa8.fsf@stan.aopsys.com> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/241 +X-Sequence-Number: 7299 + +>>>>> "Matthieu" == Matthieu Compin writes: + +[...] + + >> mais je r�it�re ma proposition de m'occuper de la partie qui a + >> pos� probl�me cette fois-ci, c'est � dire la prise de contact + >> avec les diff�rentes personnes qui pourraient �tre int�ress�es. + + Matthieu> La balle est dans ton camps. Prend contact avec Les + Matthieu> Projets Importants, fixe moi une date et je te trouve des + Matthieu> salles et du r�seau. + + Matthieu> On a donc la possibilit� de faire une belle grossse + Matthieu> manifestation maitenant et tu peux pas dire non ;) + +Ouf! Je suis soulag� de la tournure que �a prends. + +-- +Laurent Martelli vice-pr�sident de Parinux +http://www.bearteam.org/~laurent/ http://www.parinux.org/ +laurent@bearteam.org + + +From pgsql-performance-owner@postgresql.org Wed Jun 23 13:36:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DC9ADD1B170 + for ; + Wed, 23 Jun 2004 13:34: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 34225-05 + for ; + Wed, 23 Jun 2004 16:34:45 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 0359BD1B175 + for ; + Wed, 23 Jun 2004 13:34:41 -0300 (ADT) +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 and openmosix migration +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Wed, 23 Jun 2004 12:34:42 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AE73@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] postgresql and openmosix migration +Thread-Index: AcRYf2kMuvf/7wxrQTWMFqa/O2pfkwAvfBJA +From: "Merlin Moncure" +To: "Bill" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/242 +X-Sequence-Number: 7300 + +Bill wrote: +> Ok, so maybe someone on this group will have a better idea. We have a +> database of financial information, and this has literally millions of +> entries. I have installed indicies, but for the rather +computationally +> demanding processes we like to use, like a select query to find the +> commodity with the highest monthly or annual returns, the computer +> generally +> runs unacceptably slow. So, other than clustring, how could I achieve +a +> speed increase in these complex queries? Is this better in mysql or +> postgresql? + +This is a very broad question. Optimizing your SQL to run fast as on +any other database is something of an art form. This is a very broad +topic that could fill a book. For example, a common performance killer +is not having enough sort memory for large ordered result sets. + +A critical skill is being able to figure out if the planner is +optimizing your queries badly. Knowing this is a mixture of observation +and intuition that comes with experience. The absolute best case +performance of a query is roughly defined by the data that is looked at +to generate the result set and the size of the result set itself when +the query is pulling data from the cache. The cache problem is +compromisable by throwing more money at the problem but a poorly planned +query will run slowly on any hardware. + +I would suggest isolating particular problems and posting them to the +list. (explain analyze works wonders). + +Merlin + +From pgsql-performance-owner@postgresql.org Wed Jun 23 14:32:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 87252D1B241 + for ; + Wed, 23 Jun 2004 14:32: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 43523-08 + for ; + Wed, 23 Jun 2004 17:32:29 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B299D1B18F + for ; + Wed, 23 Jun 2004 14:32:27 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5462042; Wed, 23 Jun 2004 10:34:08 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Bill" +Subject: Re: postgresql and openmosix migration +Date: Wed, 23 Jun 2004 10:31:45 -0700 +User-Agent: KMail/1.4.3 +Cc: +References: <004001c45865$59cc9f20$dfc58780@billnotebook> + <200406220931.23780.josh@agliodbs.com> + <008201c4587e$b8856510$dfc58780@billnotebook> +In-Reply-To: <008201c4587e$b8856510$dfc58780@billnotebook> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200406231031.45401.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/243 +X-Sequence-Number: 7301 + +Bill, + +> Ok, so maybe someone on this group will have a better idea. We have a +> database of financial information, and this has literally millions of +> entries. I have installed indicies, but for the rather computationally +> demanding processes we like to use, like a select query to find the +> commodity with the highest monthly or annual returns, the computer +> generally runs unacceptably slow. So, other than clustring, how could I +> achieve a speed increase in these complex queries? + +Well, you can do this 2 ways: +1) you can pick out one query at a time, and send us complete information on +it, like Matt's really nice e-mail describes. People on this list will +help you troubleshoot it. It will take a lot of time, but no money. + +2) You can hire a PG database expert. This will be much faster, but cost +you a lot of money. + +>Is this better in mysql +> or postgresql? + +Complex queries? Large databases? That's us. MySQL is obtimized for +simple queries on small databases. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Jun 23 14:54:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5351FD1B199 + for ; + Wed, 23 Jun 2004 14:54: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 56480-02 + for ; + Wed, 23 Jun 2004 17:54:16 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 678BFD1B33D + for ; + Wed, 23 Jun 2004 14:54:14 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 7C81076C0B; Wed, 23 Jun 2004 13:52:43 -0400 (EDT) +Subject: Re: postgresql and openmosix migration +From: Rod Taylor +To: Josh Berkus +Cc: Bill , + Postgresql Performance +In-Reply-To: <200406231031.45401.josh@agliodbs.com> +References: <004001c45865$59cc9f20$dfc58780@billnotebook> + <200406220931.23780.josh@agliodbs.com> + <008201c4587e$b8856510$dfc58780@billnotebook> + <200406231031.45401.josh@agliodbs.com> +Content-Type: text/plain +Message-Id: <1088013159.95078.21.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 23 Jun 2004 13:52:39 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/244 +X-Sequence-Number: 7302 + +> 2) You can hire a PG database expert. This will be much faster, but cost +> you a lot of money. + +I wouldn't exactly say "a lot of money". Lots of consulters out there +are willing to put in a weeks worth of effort, on site, for +significantly less than a support contract with most commercial DB +organizations (including MySQL) -- and often give better results since +they're on-site rather than over phone or via email. + +But yes, doing it via this mailing list is probably the cheapest option. + + + +From pgsql-performance-owner@postgresql.org Wed Jun 23 15:22:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FDEED1B1A9 + for ; + Wed, 23 Jun 2004 15:22: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 67820-04 + for ; + Wed, 23 Jun 2004 18:22:07 +0000 (GMT) +Received: from krusty-motorsports.com (krusty-motorsports.com [192.94.170.8]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DC4CD1B170 + for ; + Wed, 23 Jun 2004 15:22:05 -0300 (ADT) +Received: from [24.194.112.77] (helo=skipper.averillpark.net) + by krusty-motorsports.com with asmtp (TLSv1:DES-CBC3-SHA:168) + (Exim 4.22) id 1BdCNp-0004rZ-Kq + for pgsql-performance@postgresql.org; Wed, 23 Jun 2004 18:22:05 +0000 +Received: from [127.0.0.1] (helo=localhost) + by skipper.averillpark.net with esmtp (Exim 4.22) id 1BdCMC-0007p8-9M + for pgsql-performance@postgresql.org; Wed, 23 Jun 2004 14:20:24 -0400 +Date: Wed, 23 Jun 2004 14:20:24 -0400 (EDT) +From: Richard Welty +Subject: Re: postgresql and openmosix migration +To: Postgresql Performance +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; CHARSET=US-ASCII +Content-Disposition: INLINE +References: + <004001c45865$59cc9f20$dfc58780@billnotebook><200406220931.23780.josh@agliodbs.com><008201c4587e$b8856510$dfc58780@billnotebook><200406231031.45401.josh@agliodbs.com> + <1088013159.95078.21.camel@jester> +In-Reply-To: <1088013159.95078.21.camel@jester> +Organization: Averill Park Networking +X-Mailer: Mahogany 0.66.0 'Clio', compiled for Linux 2.4.18-14 i686 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/245 +X-Sequence-Number: 7303 + +On Wed, 23 Jun 2004 13:52:39 -0400 Rod Taylor wrote: +> But yes, doing it via this mailing list is probably the cheapest option. + +yes, he just needs to decide how big a hurry he's in. + +also, if he does decide to hire a consultant, i suggest he pop over +to pgsql-jobs and ask there. + +richard +-- +Richard Welty rwelty@averillpark.net +Averill Park Networking 518-573-7592 + Java, PHP, PostgreSQL, Unix, Linux, IP Network Engineering, Security + + +From pgsql-performance-owner@postgresql.org Wed Jun 23 15:47:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 245DED1B388 + for ; + Wed, 23 Jun 2004 15: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 82544-04 + for ; + Wed, 23 Jun 2004 18:47:10 +0000 (GMT) +Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EDBCD1B1B3 + for ; + Wed, 23 Jun 2004 15:47:07 -0300 (ADT) +Received: from [127.0.0.1] (helo=localhost) + by stan.aopsys.com with esmtp (Exim 4.30) id 1BdCm1-0007Fn-3D + for pgsql-performance@postgresql.org; Wed, 23 Jun 2004 20:47:05 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Traduc Party +References: <1087930157.10632.14.camel@localhost> + <20040623112038.3350b5f9.matthieu.compin@parinux.org> + <1087983833.31174.16.camel@bugsbunny.mipsys.com> + <20040623130644.6bc4e86d.matthieu.compin@parinux.org> + <1087990354.31174.31.camel@bugsbunny.mipsys.com> + <20040623135214.0fa8e375.matthieu.compin@parinux.org> + <1087992537.2981.3.camel@bugsbunny.mipsys.com> + <20040623150732.667f80f2.matthieu.compin@parinux.org> + <87smcm9sa8.fsf@stan.aopsys.com> +From: Laurent Martelli +Date: Wed, 23 Jun 2004 20:47:04 +0200 +In-Reply-To: <87smcm9sa8.fsf@stan.aopsys.com> (Laurent Martelli's message of + "Wed, 23 Jun 2004 18:02:23 +0200") +Message-ID: <87k6xy9knr.fsf@stan.aopsys.com> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/246 +X-Sequence-Number: 7304 + + +How in hell did could this mail be sent to pgsql-performance ??? I +must have inadvertently hit a fatal and obscure keystroke in +Emacs/Gnus. + +Sorry for the noise. + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-performance-owner@postgresql.org Thu Jun 24 00:14:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 860CCD1CA32 + for ; + Thu, 24 Jun 2004 00:05: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 63558-09 + for ; + Thu, 24 Jun 2004 03:05:12 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id BA4A7D1CE13 + for ; + Thu, 24 Jun 2004 00:04:33 -0300 (ADT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr4.postgresql.org (Postfix) with ESMTP id 7C4A65AF866 + for ; + Wed, 23 Jun 2004 23:20:13 +0000 (GMT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BdGq8-0004K1-0U; Thu, 24 Jun 2004 00:07:36 +0100 +Date: Thu, 24 Jun 2004 00:07:32 +0100 +From: Paul Thomas +To: Laurent Martelli +Cc: pgsql-performance@postgresql.org +Subject: Re: Traduc Party +Message-ID: <20040624000732.A3327@bacon> +References: <1087930157.10632.14.camel@localhost> + <20040623112038.3350b5f9.matthieu.compin@parinux.org> + <1087983833.31174.16.camel@bugsbunny.mipsys.com> + <20040623130644.6bc4e86d.matthieu.compin@parinux.org> + <1087990354.31174.31.camel@bugsbunny.mipsys.com> + <20040623135214.0fa8e375.matthieu.compin@parinux.org> + <1087992537.2981.3.camel@bugsbunny.mipsys.com> + <20040623150732.667f80f2.matthieu.compin@parinux.org> + <87smcm9sa8.fsf@stan.aopsys.com> <87k6xy9knr.fsf@stan.aopsys.com> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <87k6xy9knr.fsf@stan.aopsys.com>; + from laurent@aopsys.com on Wed, Jun 23, 2004 at 19:47:04 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 20 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/248 +X-Sequence-Number: 7306 + + +On 23/06/2004 19:47 Laurent Martelli wrote: +> +> How in hell did could this mail be sent to pgsql-performance ??? I +> must have inadvertently hit a fatal and obscure keystroke in +> Emacs/Gnus. + +That sort of implies that there are Emacs keystrokes which aren't obsure. +I've been using it dayly for 2 years now and have yet to discover any key +sequence which makes any sense. But then I don't do drugs so my perseption +is probably at odds with the origators of Emacs ;) + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Jun 23 23:47:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B413D1B489 + for ; + Wed, 23 Jun 2004 23: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 50731-06 + for ; + Thu, 24 Jun 2004 02:47:00 +0000 (GMT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 729D7D1B297 + for ; + Wed, 23 Jun 2004 23:46:48 -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 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: after using pg_resetxlog, db lost +Date: Wed, 23 Jun 2004 22:46:49 -0400 +Message-ID: <644D07D3D59D8F408CD01AC2F833D8C62B9210@cisxa.cmc.int.ec.gc.ca> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] after using pg_resetxlog, db lost +Thread-Index: AcRYkCsxlh2/T+1gTb2lZ8UqP9UHoQBBLe8Q +From: "Shea,Dan [CIS]" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/247 +X-Sequence-Number: 7305 + +Tom I see you from past emails that you reference using -i -f with pg_filed= +ump. I have tried this, but do not know what I am looking at. What would = +be the the transaction id? What parameter am I supposed to pass to find it? + + +******************************************************************* +* PostgreSQL File/Block Formatted Dump Utility - Version 3.0 +* +* File: /npmu_base/data/base/17347/1259 +* Options used: -i -f +* +* Dump created on: Thu Jun 24 02:44:59 2004 +******************************************************************* + +Block 0 ******************************************************** +
----- + Block Offset: 0x00000000 Offsets: Lower 232 (0x00e8) + Block: Size 8192 Version 1 Upper 268 (0x010c) + LSN: logid 0 recoff 0x00632c08 Special 8192 (0x2000) + Items: 53 Free Space: 36 + Length (including item array): 236 + + 0000: 00000000 082c6300 0b000000 e8000c01 .....,c......... + 0010: 00200120 c4908801 00908801 3c8f8801 . . ........<... + 0020: 788e8801 b48d8801 f08c8801 2c8c8801 x...........,... + 0030: 689f3001 688b8801 a48a8801 e0898801 h.0.h........... + 0040: 1c898801 58888801 94878801 d0868801 ....X........... + 0050: 3c862801 a8852801 e4848801 50842801 <.(...(.....P.(. + 0060: bc832801 f8828801 64822801 d0812801 ..(.....d.(...(. + 0070: 0c818801 6c110000 d8100000 44100000 ....l.......D... + 0080: b00f0000 1c0f0000 d49e2801 409e2801 ..........(.@.(. + 0090: ac9d2801 189d2801 849c2801 f09b2801 ..(...(...(...(. + 00a0: 5c9b2801 c89a2801 349a2801 a0992801 \.(...(.4.(...(. + 00b0: 0c992801 78982801 e4972801 50972801 ..(.x.(...(.P.(. + 00c0: bc962801 28962801 94952801 00952801 ..(.(.(...(...(. + 00d0: 6c942801 d8932801 44932801 b0922801 l.(...(.D.(...(. + 00e0: 1c922801 88912801 00000000 ..(...(..... + + ------ + Item 1 -- Length: 196 Offset: 4292 (0x10c4) Flags: USED + XID: min (2) CMIN|XMAX: 211 CMAX|XVAC: 469 + Block Id: 0 linp Index: 1 Attributes: 24 Size: 28 + infomask: 0x2912 (HASVARWIDTH|HASOID|XMIN_COMMITTED|XMAX_INVALID|UPDATED) + + 10c4: 02000000 d3000000 d5010000 00000000 ................ + 10d4: 01001800 12291c00 cc420000 7461626c .....)...B..tabl + 10e4: 655f636f 6e737472 61696e74 73000000 e_constraints... + 10f4: 00000000 00000000 00000000 00000000 ................ + 1104: 00000000 00000000 00000000 00000000 ................ + 1114: 00000000 00000000 00000000 51420000 ............QB.. + 1124: cd420000 01000000 00000000 cc420000 .B...........B.. + 1134: 00000000 00000000 00000000 00000000 ................ + 1144: 00007600 09000000 00000000 00000000 ..v............. + 1154: 00000100 30000000 01000000 00000000 ....0........... + 1164: 09040000 02000000 00000000 01000000 ................ + 1174: 01000000 7f803f40 00000000 01000000 ......?@........ + 1184: 02000000 .... + + Item 2 -- Length: 196 Offset: 4096 (0x1000) Flags: USED + XID: min (2) CMIN|XMAX: 215 CMAX|XVAC: 469 + Block Id: 0 linp Index: 2 Attributes: 24 Size: 28 + infomask: 0x2912 (HASVARWIDTH|HASOID|XMIN_COMMITTED|XMAX_INVALID|UPDATED) + + 1000: 02000000 d7000000 d5010000 00000000 ................ + 1010: 02001800 12291c00 d0420000 7461626c .....)...B..tabl + 1020: 655f7072 6976696c 65676573 00000000 e_privileges.... + 1030: 00000000 00000000 00000000 00000000 ................ + 1040: 00000000 00000000 00000000 00000000 ................ + 1050: 00000000 00000000 00000000 51420000 ............QB.. + 1060: d1420000 01000000 00000000 d0420000 .B...........B.. + 1070: 00000000 00000000 00000000 00000000 ................ + 1080: 00007600 08000000 00000000 00000000 ..v............. + 1090: 00000100 30000000 01000000 00000000 ....0........... + 10a0: 09040000 02000000 00000000 01000000 ................ + 10b0: 01000000 7f803f40 00000000 01000000 ......?@........ + 10c0: 02000000 .... + + Item 3 -- Length: 196 Offset: 3900 (0x0f3c) Flags: USED + XID: min (2) CMIN|XMAX: 219 CMAX|XVAC: 469 + Block Id: 0 linp Index: 3 Attributes: 24 Size: 28 + +Dan. +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Tuesday, June 22, 2004 3:36 PM +To: Shea,Dan [CIS] +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] after using pg_resetxlog, db lost=20 + + +"Shea,Dan [CIS]" writes: +> The pg_resetxlog was run as root. It caused ownership problems of +> pg_control and xlog files. +> Now we have no access to the data now through psql. The data is still +> there under /var/lib/pgsql/data/base/17347 (PWFPM_DEV DB name). But +> there is no reference to 36 of our tables in pg_class. Also the 18 +> other tables that are reported in this database have no data in them. +> Is there anyway to have the database resync or make it aware of the data +> under /var/lib/pgsql/data/base/17347? +> How can this problem be resolved? + +What this sounds like is that you reset the transaction counter along +with the xlog, so that those tables appear to have been created by +transactions "in the future". This could be repaired by doing +pg_resetxlog with a more appropriate initial transaction ID, but +figuring out what that value should be is not easy :-( + +What I'd suggest is grabbing pg_filedump from +http://sources.redhat.com/rhdb/ +and using it to look through pg_class (which will be file +$PGDATA/base/yourdbnumber/1259) to see the highest transaction ID +mentioned in any row of pg_class. Then pg_resetxlog with a value +a bit larger than that. Now you should be able to see all the rows +in pg_class ... but this doesn't get you out of the woods yet, unless +there are very-recently-created tables shown in pg_class. I'd suggest +next looking through whichever tables you know to be recently modified +to find the highest transaction ID mentioned in them, and finally doing +another pg_resetxlog with a value a few million greater than that. Then +you should be okay. + +The reason you need to do this in two steps is that you'll need to look +at pg_class.relfilenode to get the file names of your recently-modified +tables. Do NOT modify the database in any way while you are running +with the intermediate transaction ID setting. + +> Jun 22 13:38:23 murphy postgres[1460]: [2-1] ERROR: xlog flush request +> 210/E757F150 is not satisfied --- flushed only to 0/2074CA0 + +Looks like you also need a larger initial WAL offset in your +pg_resetxlog command. Unlike the case with transaction IDs, there's +no need to try to be somewhat accurate in the setting --- I'd just +use a number WAY beyond what you had, maybe like 10000/0. + +Finally, the fact that all this happened suggests that you lost the +contents of pg_control (else pg_resetxlog would have picked up the right +values from it). Be very sure that you run pg_resetxlog under the same +locale settings (LC_COLLATE,LC_CTYPE) that you initially initdb'd with. +Otherwise you're likely to have nasty index-corruption problems later. + +Good luck. Next time, don't let amateurs fool with pg_resetxlog (and +anyone who'd run it as root definitely doesn't know what they're doing). +It is a wizard's tool. Get knowledgeable advice from the PG lists +before you use it rather than after. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 24 00:41:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EEBAD1B8EB + for ; + Thu, 24 Jun 2004 00:41: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 78975-05 + for ; + Thu, 24 Jun 2004 03:41:30 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B87D4D1B8BB + for ; + Thu, 24 Jun 2004 00:41:29 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5O3fQLW008398; + Wed, 23 Jun 2004 23:41:26 -0400 (EDT) +To: "Shea,Dan [CIS]" +Cc: pgsql-performance@postgresql.org +Subject: Re: after using pg_resetxlog, db lost +In-reply-to: <644D07D3D59D8F408CD01AC2F833D8C62B9210@cisxa.cmc.int.ec.gc.ca> +References: <644D07D3D59D8F408CD01AC2F833D8C62B9210@cisxa.cmc.int.ec.gc.ca> +Comments: In-reply-to "Shea,Dan [CIS]" + message dated "Wed, 23 Jun 2004 22:46:49 -0400" +Date: Wed, 23 Jun 2004 23:41:26 -0400 +Message-ID: <8397.1088048486@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/249 +X-Sequence-Number: 7307 + +"Shea,Dan [CIS]" writes: +> Tom I see you from past emails that you reference using -i -f with +> pg_filedump. I have tried this, but do not know what I am looking at. + +What you want to look at is valid XMIN and XMAX values. In this +example: + +> Item 1 -- Length: 196 Offset: 4292 (0x10c4) Flags: USED +> XID: min (2) CMIN|XMAX: 211 CMAX|XVAC: 469 +> Block Id: 0 linp Index: 1 Attributes: 24 Size: 28 +> infomask: 0x2912 (HASVARWIDTH|HASOID|XMIN_COMMITTED|XMAX_INVALID|UPDATED) + +the infomask shows XMIN_COMMITTED, so xmin (here 2) is valid, but it also +shows XMAX_INVALID, so the putative XMAX (211) should be ignored. + +In general the xmin field should be valid, but xmax shares storage with +cmin and so you have to look at the infomask bits to know whether to +believe that the cmin/xmax field represents a transaction ID. + +The cmax/xvac field could also hold a transaction ID. If I had only +the above data to go on, I'd guess that the current transaction counter +is at least 469. + +Under normal circumstances, command counter values (cmin or cmax) are +unlikely to exceed a few hundred, while the transaction IDs you are +looking for are likely to be much larger. So you could get away with +just computing the max of *all* the numbers you see in xmin, cmin/xmax, +or cmax/cvac, and then using something a million or so bigger for safety +factor. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 24 09:25:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A39F2D1B7C3 + for ; + Thu, 24 Jun 2004 09:25: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 17059-08 + for ; + Thu, 24 Jun 2004 12:25:36 +0000 (GMT) +Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id 15E5BD1B7DA + for ; + Thu, 24 Jun 2004 09:25:30 -0300 (ADT) +Received: from [127.0.0.1] (helo=localhost) + by stan.aopsys.com with esmtp (Exim 4.30) id 1BdTIL-0007rZ-U3 + for pgsql-performance@postgresql.org; Thu, 24 Jun 2004 14:25:33 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Pas la samedi +References: <20040618163600.GA7764@lhullier.org> + <20040622105255.0db6c0aa.matthieu.compin@parinux.org> + <200406221959.27100.gianny@parinux.org> + <200406222036.32593.laurent@parinux.org> +From: Laurent Martelli +Organization: Parinux +Date: Thu, 24 Jun 2004 14:25:33 +0200 +In-Reply-To: <200406222036.32593.laurent@parinux.org> (Laurent Rathle's + message of "Tue, 22 Jun 2004 20:36:32 +0200") +Message-ID: <87y8md87nm.fsf@stan.aopsys.com> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/250 +X-Sequence-Number: 7308 + +>>>>> "Laurent" == Laurent Rathle writes: + + Laurent> Le mardi 22 Juin 2004 19:59, Giancarlo a �crit�: + >> 1ere r�gle: il n'y a pas de CVS chez Parinux 2eme r�gle: il n'y a + >> pas de CVS chez Parinux, et... 3eme r�gle: il n'y a pas de CVS + >> chez Parinux + >> + >> ;-) + >> + >> Bon en fait c plus compliqu� que ca, pour r�sumer: c'�tait trop + >> le foutoir dans l'arbo du site, il faudrait faire du m�nage (afin + >> notement de pouvoir faire des modules) + + Laurent> Et subversion ? + +Puisqu'on a pas d'existant sous CVS � migrer, je suis aussi plut�t +commencer directement avec subversion, qui est un CVS en mieux. + +-- +Laurent Martelli vice-pr�sident de Parinux +http://www.bearteam.org/~laurent/ http://www.parinux.org/ +laurent@bearteam.org + + +From pgsql-performance-owner@postgresql.org Thu Jun 24 13:15:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E9D7D1B750 + for ; + Thu, 24 Jun 2004 13:15: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 55538-07 + for ; + Thu, 24 Jun 2004 16:15:10 +0000 (GMT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 55EACD1B1B3 + for ; + Thu, 24 Jun 2004 13:15:03 -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 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: after using pg_resetxlog, db lost +Date: Thu, 24 Jun 2004 12:14:54 -0400 +Message-ID: <644D07D3D59D8F408CD01AC2F833D8C62B9217@cisxa.cmc.int.ec.gc.ca> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] after using pg_resetxlog, db lost +Thread-Index: AcRZnSKI11TVGS7wRYOttYg4xmM5OQAaF4Sw +From: "Shea,Dan [CIS]" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/251 +X-Sequence-Number: 7309 + +I determined the largest was 12,293,162 and set it to=20 +pg_resetxlog -x 15000000 /var/lib/pgsql/data + +I am now able to see all the data. + +I actually checked the log for the previous successfull startup before it t= +he pg_control file was reset and it reported=20 +Jun 22 11:55:44 pascal postgres[24993]: [5-1] LOG: next transaction ID: 14= +820367; next OID: 727013114 + +So I entered=20 +pg_resetxlog -o 750000000 /var/lib/pgsql/data Setting oid value + +I couldn't set 10000/0, so tried below +pg_resetxlog -l 10000,0 /var/lib/pgsql/data=20=20=20=20=20 + +This seems to be wrong because the databse is complaining and shutting down +Jun 24 15:02:05 murphy postgres[28061]: [6-1] LOG: checkpoint record is at= + 2710/1000050 +Jun 24 15:02:05 murphy postgres[28061]: [7-1] LOG: redo record is at 2710/= +1000050; undo record is at 0/0; shutdown TRUE +Jun 24 15:02:05 murphy postgres[28061]: [8-1] LOG: next transaction ID: 15= +000010; next OID: 750000000 +Jun 24 15:02:05 murphy postgres[28061]: [9-1] LOG: database system was not= + properly shut down; automatic recovery in progress +Jun 24 15:02:05 murphy postgres[28062]: [5-1] FATAL: the database system i= +s starting up +Jun 24 15:02:05 murphy postgres[28063]: [5-1] FATAL: the database system i= +s starting up +Jun 24 15:02:05 murphy postgres[28061]: [10-1] LOG: redo starts at 2710/10= +00090 +Jun 24 15:02:05 murphy postgres[28061]: [11-1] PANIC: could not access sta= +tus of transaction 15000030 +Jun 24 15:02:05 murphy postgres[28061]: [11-2] DETAIL: could not read from= + file "/var/lib/pgsql/data/pg_clog/000E" at offset 73728: Success +Jun 24 15:02:05 murphy postgres[24771]: [5-1] LOG: startup process (PID 28= +061) was terminated by signal 6 +Jun 24 15:02:05 murphy postgres[24771]: [6-1] LOG: aborting startup due to= + startup process failure +Jun 24 15:50:51 murphy sshd(pam_unix)[690]: session opened for user root by= + (uid=3D0) +Jun 24 15:54:47 murphy su(pam_unix)[1541]: session opened for user postgres= + by root(uid=3D0) +Jun 24 16:03:47 murphy su(pam_unix)[2911]: session opened for user postgres= + by root(uid=3D0) +Jun 24 16:03:48 murphy su(pam_unix)[2911]: session closed for user postgres +Jun 24 16:03:48 murphy postgres[3182]: [1-1] LOG: could not create IPv6 so= +cket: Address family not supported by protocol +Jun 24 16:03:48 murphy postgres[3188]: [2-1] LOG: database system was inte= +rrupted while in recovery at 2004-06-24 15:02:05 GMT +Jun 24 16:03:48 murphy postgres[3188]: [2-2] HINT: This probably means tha= +t some data is corrupted and you will have to use the last backup for recov= +ery. +Jun 24 16:03:48 murphy postgres[3188]: [3-1] LOG: checkpoint record is at = +2710/1000050 +Jun 24 16:03:48 murphy postgres[3188]: [4-1] LOG: redo record is at 2710/1= +000050; undo record is at 0/0; shutdown TRUE +Jun 24 16:03:48 murphy postgres[3188]: [5-1] LOG: next transaction ID: 150= +00010; next OID: 750000000 +Jun 24 16:03:48 murphy postgres[3188]: [6-1] LOG: database system was not = +properly shut down; automatic recovery in progress +Jun 24 16:03:48 murphy postgres[3188]: [7-1] LOG: redo starts at 2710/1000= +090 +Jun 24 16:03:48 murphy postgres[3188]: [8-1] PANIC: could not access statu= +s of transaction 15000030 +Jun 24 16:03:48 murphy postgres[3188]: [8-2] DETAIL: could not read from f= +ile "/var/lib/pgsql/data/pg_clog/000E" at offset 73728: Success +Jun 24 16:03:48 murphy postgres[3182]: [2-1] LOG: startup process (PID 318= +8) was terminated by signal 6 +Jun 24 16:03:48 murphy postgres[3182]: [3-1] LOG: aborting startup due to = +startup process failure + +How do I set the xlog properly, or rather to 10000/0? +Dan. +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Wednesday, June 23, 2004 11:41 PM +To: Shea,Dan [CIS] +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] after using pg_resetxlog, db lost=20 + + +"Shea,Dan [CIS]" writes: +> Tom I see you from past emails that you reference using -i -f with +> pg_filedump. I have tried this, but do not know what I am looking at. + +What you want to look at is valid XMIN and XMAX values. In this +example: + +> Item 1 -- Length: 196 Offset: 4292 (0x10c4) Flags: USED +> XID: min (2) CMIN|XMAX: 211 CMAX|XVAC: 469 +> Block Id: 0 linp Index: 1 Attributes: 24 Size: 28 +> infomask: 0x2912 (HASVARWIDTH|HASOID|XMIN_COMMITTED|XMAX_INVALID|UPDATED) + +the infomask shows XMIN_COMMITTED, so xmin (here 2) is valid, but it also +shows XMAX_INVALID, so the putative XMAX (211) should be ignored. + +In general the xmin field should be valid, but xmax shares storage with +cmin and so you have to look at the infomask bits to know whether to +believe that the cmin/xmax field represents a transaction ID. + +The cmax/xvac field could also hold a transaction ID. If I had only +the above data to go on, I'd guess that the current transaction counter +is at least 469. + +Under normal circumstances, command counter values (cmin or cmax) are +unlikely to exceed a few hundred, while the transaction IDs you are +looking for are likely to be much larger. So you could get away with +just computing the max of *all* the numbers you see in xmin, cmin/xmax, +or cmax/cvac, and then using something a million or so bigger for safety +factor. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 24 13:34:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 52402D1B267 + for ; + Thu, 24 Jun 2004 13:33: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 64842-10 + for ; + Thu, 24 Jun 2004 16:33:45 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0336ED1B262 + for ; + Thu, 24 Jun 2004 13:33:44 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5OGXgGs015231; + Thu, 24 Jun 2004 12:33:42 -0400 (EDT) +To: "Shea,Dan [CIS]" +Cc: pgsql-performance@postgresql.org +Subject: Re: after using pg_resetxlog, db lost +In-reply-to: <644D07D3D59D8F408CD01AC2F833D8C62B9217@cisxa.cmc.int.ec.gc.ca> +References: <644D07D3D59D8F408CD01AC2F833D8C62B9217@cisxa.cmc.int.ec.gc.ca> +Comments: In-reply-to "Shea,Dan [CIS]" + message dated "Thu, 24 Jun 2004 12:14:54 -0400" +Date: Thu, 24 Jun 2004 12:33:41 -0400 +Message-ID: <15230.1088094821@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/252 +X-Sequence-Number: 7310 + +"Shea,Dan [CIS]" writes: +> I determined the largest was 12,293,162 and set it to +> pg_resetxlog -x 15000000 /var/lib/pgsql/data + +Okay, but it looks like you will also need to adjust pg_clog to cover +that transaction ID range. (I had thought pg_resetxlog would handle +this for you, but it looks like not.) + +> Jun 24 15:02:05 murphy postgres[28061]: [11-1] PANIC: could not access status of transaction 15000030 +> Jun 24 15:02:05 murphy postgres[28061]: [11-2] DETAIL: could not read from file "/var/lib/pgsql/data/pg_clog/000E" at offset 73728: Success + +You need to append zeroes (8K at a time) to +/var/lib/pgsql/data/pg_clog/000E until it's longer than 73728 bytes. +I'd use something like + dd bs=8k count=1 >/var/lib/pgsql/data/pg_clog/000E +assuming that your system has /dev/zero. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Jun 24 14:17:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BF51D1B74E + for ; + Thu, 24 Jun 2004 14:17: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 95354-02 + for ; + Thu, 24 Jun 2004 17:17:24 +0000 (GMT) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 15FAFD1B745 + for ; + Thu, 24 Jun 2004 14:17:22 -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 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: after using pg_resetxlog, db lost +Date: Thu, 24 Jun 2004 13:17:13 -0400 +Message-ID: <644D07D3D59D8F408CD01AC2F833D8C62B9218@cisxa.cmc.int.ec.gc.ca> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] after using pg_resetxlog, db lost +Thread-Index: AcRaCQSwfjMRqqknRHibsrnwr2tmaQABdBbg +From: "Shea,Dan [CIS]" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/253 +X-Sequence-Number: 7311 + +Tom, thank you for your help. +I increased 000E to 81920 and the databse is working now. +We are using RHAS 3.0 and it does have /dev/zero. + +Dan. + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Thursday, June 24, 2004 12:34 PM +To: Shea,Dan [CIS] +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] after using pg_resetxlog, db lost=20 + + +"Shea,Dan [CIS]" writes: +> I determined the largest was 12,293,162 and set it to=20 +> pg_resetxlog -x 15000000 /var/lib/pgsql/data + +Okay, but it looks like you will also need to adjust pg_clog to cover +that transaction ID range. (I had thought pg_resetxlog would handle +this for you, but it looks like not.) + +> Jun 24 15:02:05 murphy postgres[28061]: [11-1] PANIC: could not access s= +tatus of transaction 15000030 +> Jun 24 15:02:05 murphy postgres[28061]: [11-2] DETAIL: could not read fr= +om file "/var/lib/pgsql/data/pg_clog/000E" at offset 73728: Success + +You need to append zeroes (8K at a time) to +/var/lib/pgsql/data/pg_clog/000E until it's longer than 73728 bytes. +I'd use something like=20 + dd bs=3D8k count=3D1 >/var/lib/pgsql/data/pg_clog/000E +assuming that your system has /dev/zero. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 29 17:06:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EBC23D1B1B8 + for ; + Thu, 24 Jun 2004 18:43: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 22303-08 + for ; + Thu, 24 Jun 2004 21:43:24 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AC32D1B196 + for ; + Thu, 24 Jun 2004 18:43:21 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i5OLhLQC097201 + for ; Thu, 24 Jun 2004 21:43:21 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i5OLOtHR092741 + for pgsql-performance@postgresql.org; Thu, 24 Jun 2004 21:24:55 GMT +From: "Mischa Sandberg" +X-Newsgroups: comp.databases.postgresql.performance +Subject: Range query optimization +Lines: 27 +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +Message-ID: +Date: Thu, 24 Jun 2004 21:24:58 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200406/313 +X-Sequence-Number: 7371 + +I'm trying to make a (qua-technical, qua-business) case for switching from +MS SQL, and one of the types of query that really doesn't sit well with MS +SQL2K is: + +-- All fields integers or equivalent. +-- Table T(k, x: nonkey fields...) +-- Table U(k, a, z: m) -- for each value of (k) a set of non-intersecting +ranges [a,z) that map to (m) values. + + select T.*, U.m from T join U on T.k=U.k and T.x >= U.a and T.x < U.z + +Typically there are are about 1000-2000 U rows per value of (k), about 100K +values of (k) and about 50M +values of T. + +By itself, this type of query grinds the CPU to dust. A clustered index on +fields of U (take your pick) barely halves the problem of the loop through +1000-2000 rows of U for each row of T. Hash join likewise. +The current workaround is a 'manual' radix index on top of the range table, +but it's something of a hack. + +Would the geometric of extensions handle such queries efficiently? I'm not +familiar with applying R-trees to linear range problems. +---- +"Dreams come true, not free." -- S.Sondheim + + + +From pgsql-performance-owner@postgresql.org Fri Jun 25 04:00:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F2D5ED1B1C9 + for ; + Fri, 25 Jun 2004 03:59: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 27523-06 + for ; + Fri, 25 Jun 2004 06:59:42 +0000 (GMT) +Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.244]) + by svr1.postgresql.org (Postfix) with SMTP id 59E24D1B7D1 + for ; + Fri, 25 Jun 2004 03:59:32 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id w29so5698868cwb + for ; + Thu, 24 Jun 2004 23:59:32 -0700 (PDT) +Received: by 10.38.164.51 with SMTP id m51mr49212rne; + Thu, 24 Jun 2004 23:59:32 -0700 (PDT) +Message-ID: +Date: Thu, 24 Jun 2004 23:59:32 -0700 +From: Chris Cheston +To: pgsql-performance@postgresql.org +Subject: postgres 7.4 at 100% +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/254 +X-Sequence-Number: 7312 + +Hi all, + +I was running Postgres 7.3 and it was running at about 15% with my +application. On Postgres 7.4 on another box, it was running at 100%... +My settings are default on both boxes I think. + +There are only about 20 inserts per second, which is really low. +Anyone have any ideas as to something I have to do to Postgres 7.4 to +change it from the default so that it's not eating up all my CPU? I +have no clue how to debug this... + +Help please!!!! Should I downgrade to 7.3 to see what happens? BTW +I'm running Postgres 7.3.2 on: + +Linux box 2.4.25-040218 #1 SMP Wed Feb 18 17:59:29 CET 2004 i686 i686 +i386 GNU/Linux + +on a single processor P4 1.4GHz, 512 MB RAM. Does the SMP kernel do +something with the single processor CPU? or should this not affect +psql? + +Thanks in advance!!! +Chris + +From pgsql-performance-owner@postgresql.org Fri Jun 25 06:10:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CCD4BD1B267 + for ; + Fri, 25 Jun 2004 06:10: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 79973-05 + for ; + Fri, 25 Jun 2004 09:09:55 +0000 (GMT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EB71D1BB13 + for ; + Fri, 25 Jun 2004 06:09:52 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BdmiX-0008l4-0V; Fri, 25 Jun 2004 10:09:53 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 11AF616364; Fri, 25 Jun 2004 10:09:52 +0100 (BST) +Message-ID: <40DBEBDF.3090605@archonet.com> +Date: Fri, 25 Jun 2004 10:09:51 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Cheston +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/255 +X-Sequence-Number: 7313 + +Chris Cheston wrote: +> Hi all, +> +> I was running Postgres 7.3 and it was running at about 15% with my +> application. On Postgres 7.4 on another box, it was running at 100%... + +People are going to need more information. Are you talking about +CPU/disk IO/memory? + +> My settings are default on both boxes I think. + +Doubtful - PG crawls with the default settings. Check your old +postgresql.conf file and compare. Also, read the tuning article at: + http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php + +> There are only about 20 inserts per second, which is really low. +> Anyone have any ideas as to something I have to do to Postgres 7.4 to +> change it from the default so that it's not eating up all my CPU? I +> have no clue how to debug this... + +What does top/vmstat/iostat show during heavy usage? + +> Help please!!!! Should I downgrade to 7.3 to see what happens? BTW +> I'm running Postgres 7.3.2 on: +> +> Linux box 2.4.25-040218 #1 SMP Wed Feb 18 17:59:29 CET 2004 i686 i686 +> i386 GNU/Linux +> +> on a single processor P4 1.4GHz, 512 MB RAM. Does the SMP kernel do +> something with the single processor CPU? or should this not affect +> psql? + +Don't know about the SMP thing. Unlikely that one of the big +distributions would mess that up much though. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Jun 25 16:37:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FDA6D1BAF8 + for ; + Fri, 25 Jun 2004 16:37: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 74969-02 + for ; + Fri, 25 Jun 2004 19:37:54 +0000 (GMT) +Received: from smtp-out1.xs4all.nl (smtp-out1.xs4all.nl [194.109.24.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 2628FD1BAA5 + for ; + Fri, 25 Jun 2004 16:37:49 -0300 (ADT) +Received: from faranth.bluehorizon.nl (pmg.xs4all.nl [80.127.73.103]) + by smtp-out1.xs4all.nl (8.12.10/8.12.10) with ESMTP id i5PJbokh042859 + for ; + Fri, 25 Jun 2004 21:37:50 +0200 (CEST) +Subject: How can one see what queries are running withing a postgres instance? +From: "P.A.M. van Dam" +Reply-To: pam@pmg.xs4all.nl +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Message-Id: <1088192269.6490.3.camel@localhost> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.5.2 +Date: Fri, 25 Jun 2004 21:37:49 +0200 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/256 +X-Sequence-Number: 7314 + + +Hi! + +I'd like to know if there is a way to see what queries are running +within a certain postgres instance and how much resources (cpu/memory) +etc. they are using. Right now it's impossible to see what is happening +within postgres when it's binaries are using 100% CPU. + +In Sybase there is a command which let's you view what 'processes' are +running within the server and how much cpu (according to Sybase) they +are using. It also provides you with a stored procedure to kill off some +bad behaving queries. How can one do this within postgres? + +Thanks in advance! + +Best regards, + + Pascal + + +From pgsql-performance-owner@postgresql.org Wed Jun 30 22:50:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DBBFD1CA44 + for ; + Fri, 25 Jun 2004 17:01: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 85127-03 + for ; + Fri, 25 Jun 2004 20:01:09 +0000 (GMT) +Received: from mailman.paccomsys.com (mail.musicreports.com [64.161.179.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 83DD4D1CA3C + for ; + Fri, 25 Jun 2004 17:01:05 -0300 (ADT) +Received: from musicreports.com ([192.168.20.69]) + by mailman.paccomsys.com (8.12.9-20030917/8.12.9) with ESMTP id + i5PJ06CT007164; Fri, 25 Jun 2004 12:00:07 -0700 +Message-ID: <40DC83F9.3030801@musicreports.com> +Date: Fri, 25 Jun 2004 12:58:49 -0700 +From: Roger Ging +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pam@pmg.xs4all.nl +Cc: pgsql-performance@postgresql.org +Subject: Re: How can one see what queries are running withing a +References: <1088192269.6490.3.camel@localhost> +In-Reply-To: <1088192269.6490.3.camel@localhost> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-PacComSys-MailScanner-Information: Please contact the ISP for more + information +X-PacComSys-MailScanner: Found to be clean +X-MailScanner-From: roger@musicreports.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/331 +X-Sequence-Number: 7389 + + + +P.A.M. van Dam wrote: + +>Hi! +> +>I'd like to know if there is a way to see what queries are running +>within a certain postgres instance and how much resources (cpu/memory) +>etc. they are using. Right now it's impossible to see what is happening +>within postgres when it's binaries are using 100% CPU. +> +>In Sybase there is a command which let's you view what 'processes' are +>running within the server and how much cpu (according to Sybase) they +>are using. It also provides you with a stored procedure to kill off some +>bad behaving queries. How can one do this within postgres? +> +>Thanks in advance! +> +>Best regards, +> +> Pascal +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Don't 'kill -9' the postmaster +> +> +select * from pg_stat_activity. If you want to see the command that was +run, you will need to turn on stats_command_string = true in +postgresql.conf and re-start server. PID shows up, so you can kill bad +queries from terminal and see CUP % in top + +Roger Ging +V.P., Information Technology +Music Reports, Inc. + + +From pgsql-performance-owner@postgresql.org Fri Jun 25 17:51:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DA250D1B7D1 + for ; + Fri, 25 Jun 2004 17:51: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 05002-03 + for ; + Fri, 25 Jun 2004 20:51:23 +0000 (GMT) +Received: from mx.noos.fr (pm-mx4.mgn.net [195.46.220.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BC74D1B18E + for ; + Fri, 25 Jun 2004 17:51:19 -0300 (ADT) +Received: from noos.fr (pm-mnet3.mgn.net [195.46.220.218]) + by mx.noos.fr (Postfix) with SMTP + id AB74627821; Fri, 25 Jun 2004 22:51:10 +0200 (MEST) +X-Mailbox-Line: From footcow@noos.fr Fri Jun 25 22:51:10 2004 +Received: from e115.dhcp212-198-145.noos.fr (e115.dhcp212-198-145.noos.fr + [212.198.145.115]) by pm-mnet3.mgn.net with ESMTP; + Fri, 25 Jun 2004 22:51:10 (MEST) +From: =?iso-8859-15?q?Herv=E9_Piedvache?= +To: pgsql-performance@postgresql.org, pam@pmg.xs4all.nl +Subject: Re: How can one see what queries are running withing a postgres + instance? +Date: Fri, 25 Jun 2004 22:51:09 +0200 +User-Agent: KMail/1.6.2 +References: <1088192269.6490.3.camel@localhost> +In-Reply-To: <1088192269.6490.3.camel@localhost> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200406252251.09228.footcow@noos.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/257 +X-Sequence-Number: 7315 + +Let see in contrib/ the application pg_who ... you will see the process, th= +e=20 +queries, and the CPU ... ;o) + +Regards, + +Le vendredi 25 Juin 2004 21:37, P.A.M. van Dam a =E9crit : +> Hi! +> +> I'd like to know if there is a way to see what queries are running +> within a certain postgres instance and how much resources (cpu/memory) +> etc. they are using. Right now it's impossible to see what is happening +> within postgres when it's binaries are using 100% CPU. +> +> In Sybase there is a command which let's you view what 'processes' are +> running within the server and how much cpu (according to Sybase) they +> are using. It also provides you with a stored procedure to kill off some +> bad behaving queries. How can one do this within postgres? +> +> Thanks in advance! +> +> Best regards, +> +> Pascal +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + +--=20 +Bill Footcow + + +From pgsql-performance-owner@postgresql.org Sat Jun 26 04:27:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DEB85D1B19F + for ; + Sat, 26 Jun 2004 04:27: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 73969-02 + for ; + Sat, 26 Jun 2004 07:27:17 +0000 (GMT) +Received: from mx.noos.fr (pm-mx3.mgn.net [195.46.220.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 680F8D1B1B3 + for ; + Sat, 26 Jun 2004 04:27:13 -0300 (ADT) +Received: from noos.fr (pm-mnet2.mgn.net [195.46.220.219]) + by mx.noos.fr (Postfix) with SMTP + id 1FC7526B54; Sat, 26 Jun 2004 09:27:14 +0200 (MEST) +X-Mailbox-Line: From footcow@noos.fr Sat Jun 26 09:27:13 2004 +Received: from e115.dhcp212-198-145.noos.fr (e115.dhcp212-198-145.noos.fr + [212.198.145.115]) by pm-mnet2.mgn.net with ESMTP; + Sat, 26 Jun 2004 09:27:13 (MEST) +From: =?iso-8859-15?q?Herv=E9_Piedvache?= +To: pgsql-performance@postgresql.org +Subject: Re: How can one see what queries are running withing a postgres + instance? +Date: Sat, 26 Jun 2004 09:27:12 +0200 +User-Agent: KMail/1.6.2 +Cc: pam@pmg.xs4all.nl +References: <1088192269.6490.3.camel@localhost> + <200406252251.09228.footcow@noos.fr> +In-Reply-To: <200406252251.09228.footcow@noos.fr> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200406260927.12812.footcow@noos.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/258 +X-Sequence-Number: 7316 + +Sorry It's not in the contrib folder of PostgreSQL ... but you will find it= + on=20 +gborg.postgresql.org ! + +Regards, + +Le vendredi 25 Juin 2004 22:51, Herv=E9 Piedvache a =E9crit : +> Let see in contrib/ the application pg_who ... you will see the process, +> the queries, and the CPU ... ;o) +> +> Regards, +> +> Le vendredi 25 Juin 2004 21:37, P.A.M. van Dam a =E9crit : +> > Hi! +> > +> > I'd like to know if there is a way to see what queries are running +> > within a certain postgres instance and how much resources (cpu/memory) +> > etc. they are using. Right now it's impossible to see what is happening +> > within postgres when it's binaries are using 100% CPU. +> > +> > In Sybase there is a command which let's you view what 'processes' are +> > running within the server and how much cpu (according to Sybase) they +> > are using. It also provides you with a stored procedure to kill off some +> > bad behaving queries. How can one do this within postgres? +> > +> > Thanks in advance! +> > +> > Best regards, +> > +> > Pascal +> > +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 4: Don't 'kill -9' the postmaster + +--=20 +Bill Footcow + + +From pgsql-performance-owner@postgresql.org Sat Jun 26 05:09:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5211ED1B8A9 + for ; + Sat, 26 Jun 2004 05:09: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 81299-09 + for ; + Sat, 26 Jun 2004 08:08:59 +0000 (GMT) +Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.252]) + by svr1.postgresql.org (Postfix) with SMTP id 09EDBD1B503 + for ; + Sat, 26 Jun 2004 05:08:55 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id w41so269998cwb + for ; + Sat, 26 Jun 2004 01:08:57 -0700 (PDT) +Received: by 10.38.79.55 with SMTP id c55mr63147rnb; + Sat, 26 Jun 2004 01:08:57 -0700 (PDT) +Message-ID: +Date: Sat, 26 Jun 2004 01:08:57 -0700 +From: Chris Cheston +To: Richard Huxton +Subject: Re: postgres 7.4 at 100% +Cc: pgsql-performance@postgresql.org +In-Reply-To: <40DBEBDF.3090605@archonet.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <40DBEBDF.3090605@archonet.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 + tests=LINES_OF_YELLING, LINES_OF_YELLING_2 +X-Spam-Level: +X-Archive-Number: 200406/259 +X-Sequence-Number: 7317 + +Hi Richard, +Thanks so much for replying. Pls see below. +Thanks in advance for any advice, +Chris + +> People are going to need more information. Are you talking about +> CPU/disk IO/memory? + +## CPU is at 100%. + +> +> > My settings are default on both boxes I think. +> +> Doubtful - PG crawls with the default settings. Check your old +> postgresql.conf file and compare. Also, read the tuning article at: +> http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +> +> > There are only about 20 inserts per second, which is really low. +> > Anyone have any ideas as to something I have to do to Postgres 7.4 to +> > change it from the default so that it's not eating up all my CPU? I +> > have no clue how to debug this... +> +> What does top/vmstat/iostat show during heavy usage? +> +TOP: + +137 processes: 135 sleeping, 2 running, 0 zombie, 0 stopped +CPU states: 81.4% user 17.9% system 0.0% nice 0.0% iowait 0.5% idle +Mem: 507036k av, 500244k used, 6792k free, 0k shrd, 68024k buff + 133072k active, 277368k inactive +Swap: 787176k av, 98924k used, 688252k free 232500k cached + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND +20734 postgres 15 0 4028 4028 3244 R 83.6 0.7 348:03 0 postmaster +21249 numnet 9 0 78060 76M 8440 S 7.5 15.3 32:51 0 myapp +18478 user 12 0 1224 1224 884 S 5.7 0.2 57:01 0 top + +[root@live root]# vmstat + 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 98924 5980 68024 233528 4 3 6 22 28 10 13 6 24 + +iostat: +Time: 03:18:18 AM +Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn +dev3-0 11.00 0.80 142.40 4 712 + +Time: 03:18:23 AM +Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn +dev3-0 10.60 0.00 143.20 0 716 + +or blocks: + +Time: 03:20:58 AM +Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn +dev3-0 25.40 3.20 756.80 16 3784 + +Time: 03:21:03 AM +Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn +dev3-0 30.20 3.20 841.60 16 4208 + +extended: + +Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s +avgrq-sz avgqu-sz await svctm %util +/dev/hda3 0.00 79.20 0.60 30.60 4.80 878.40 2.40 439.20 + 28.31 0.36 1.15 0.45 1.40 + +avg-cpu: %user %nice %sys %idle + 31.00 0.00 18.20 50.80 + +Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s +avgrq-sz avgqu-sz await svctm %util +/dev/hda3 0.00 45.80 0.00 10.80 0.00 452.80 0.00 226.40 + 41.93 0.08 0.74 0.37 0.40 + +avg-cpu: %user %nice %sys %idle + 83.20 0.00 16.60 0.20 + +Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s +avgrq-sz avgqu-sz await svctm %util +/dev/hda 0.00 28.20 0.00 10.10 0.00 315.20 0.00 157.60 + 31.21 4294917.33 0.30 99.01 100.00 +/dev/hda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 + 0.00 0.00 0.00 0.00 0.00 +/dev/hda2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 + 0.00 0.00 0.00 0.00 0.00 +/dev/hda3 0.00 28.20 0.00 10.10 0.00 315.20 0.00 157.60 + 31.21 0.03 0.30 0.20 0.20 + +My conf file: + +[root@live setup]# cat /var/lib/pgsql/data/postgresql.conf +# ----------------------------- +# PostgreSQL configuration file +# ----------------------------- +# +# This file consists of lines of the form: +# +# name = value +# +# (The '=' is optional.) White space may be used. Comments are introduced +# with '#' anywhere on a line. The complete list of option names and +# allowed values can be found in the PostgreSQL documentation. The +# commented-out settings shown in this file represent the default values. +# +# Any option can also be given as a command line switch to the +# postmaster, e.g. 'postmaster -c log_connections=on'. Some options +# can be changed at run-time with the 'SET' SQL command. +# +# This file is read on postmaster startup and when the postmaster +# receives a SIGHUP. If you edit the file on a running system, you have +# to SIGHUP the postmaster for the changes to take effect, or use +# "pg_ctl reload". + + +#--------------------------------------------------------------------------- +# CONNECTIONS AND AUTHENTICATION +#--------------------------------------------------------------------------- + +# - Connection Settings - + +tcpip_socket = true +max_connections = 20 + # note: increasing max_connections costs about 500 bytes of shared + # memory per connection slot, in addition to costs from shared_buffers + # and max_locks_per_transaction. +#superuser_reserved_connections = 2 +#port = 5432 +#unix_socket_directory = '' +#unix_socket_group = '' +#unix_socket_permissions = 0777 # octal +#virtual_host = '' # what interface to listen on; defaults to any +#rendezvous_name = '' # defaults to the computer name + +# - Security & Authentication - + +#authentication_timeout = 60 # 1-600, in seconds +#ssl = false +#password_encryption = true +#krb_server_keyfile = '' +#db_user_namespace = false + + +#--------------------------------------------------------------------------- +# RESOURCE USAGE (except WAL) +#--------------------------------------------------------------------------- + +# - Memory - + +shared_buffers = 40 # min 16, at least max_connections*2, 8KB each +#sort_mem = 1024 # min 64, size in KB +#vacuum_mem = 8192 # min 1024, size in KB + +# - Free Space Map - + +#max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each +#max_fsm_relations = 1000 # min 100, ~50 bytes each + +# - Kernel Resource Usage - + +#max_files_per_process = 1000 # min 25 +#preload_libraries = '' + + +#--------------------------------------------------------------------------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +#fsync = true # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or open_datasync +#wal_buffers = 8 # min 4, 8KB each + +# - Checkpoints - + +#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each +#checkpoint_timeout = 300 # range 30-3600, in seconds +#checkpoint_warning = 30 # 0 is off, in seconds +#commit_delay = 0 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 + + +#--------------------------------------------------------------------------- +# QUERY TUNING +#--------------------------------------------------------------------------- + +# - Planner Method Enabling - + +#enable_hashagg = true +#enable_hashjoin = true +#enable_indexscan = true +#enable_mergejoin = true +#enable_nestloop = true +#enable_seqscan = true +#enable_sort = true +#enable_tidscan = true + +# - Planner Cost Constants - + +#effective_cache_size = 1000 # typically 8KB each +#random_page_cost = 4 # units are one sequential page fetch cost +#cpu_tuple_cost = 0.01 # (same) +#cpu_index_tuple_cost = 0.001 # (same) +#cpu_operator_cost = 0.0025 # (same) + +# - Genetic Query Optimizer - + +#geqo = true +#geqo_threshold = 11 +#geqo_effort = 1 +#geqo_generations = 0 +#geqo_pool_size = 0 # default based on tables in statement, + # range 128-1024 +#geqo_selection_bias = 2.0 # range 1.5-2.0 + +# - Other Planner Options - + +#default_statistics_target = 10 # range 1-1000 +#from_collapse_limit = 8 +#join_collapse_limit = 8 # 1 disables collapsing of explicit JOINs + + +#--------------------------------------------------------------------------- +# ERROR REPORTING AND LOGGING +#--------------------------------------------------------------------------- + +# - Syslog - + +syslog = 0 # range 0-2; 0=stdout; 1=both; 2=syslog +syslog_facility = 'LOCAL0' +syslog_ident = 'postgres' + +# - When to Log - + +client_min_messages = warning # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # log, info, notice, warning, error + +log_min_messages = log # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, log, fatal, + # panic + +log_error_verbosity = default # terse, default, or verbose messages + +log_min_error_statement = warning # Values in order of increasing severity: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, panic(off) + +#log_min_duration_statement = -1 # Log all statements whose + # execution time exceeds the value, in + # milliseconds. Zero prints all queries. + # Minus-one disables. + +#silent_mode = false # DO NOT USE without Syslog! + +# - What to Log - + +#debug_print_parse = false +#debug_print_rewritten = false +#debug_print_plan = false +#debug_pretty_print = false +#log_connections = false +#log_duration = false +#log_pid = false +#log_statement = false +#log_timestamp = false +#log_hostname = false +#log_source_port = false + + +#--------------------------------------------------------------------------- +# RUNTIME STATISTICS +#--------------------------------------------------------------------------- + +# - Statistics Monitoring - + +#log_parser_stats = false +#log_planner_stats = false +#log_executor_stats = false +#log_statement_stats = false + +# - Query/Index Statistics Collector - + +#stats_start_collector = true +#stats_command_string = false +#stats_block_level = false +#stats_row_level = false +#stats_reset_on_server_start = true + + +#--------------------------------------------------------------------------- +# CLIENT CONNECTION DEFAULTS +#--------------------------------------------------------------------------- + +# - Statement Behavior - + +#search_path = '$user,public' # schema names +#check_function_bodies = true +#default_transaction_isolation = 'read committed' +#default_transaction_read_only = false +#statement_timeout = 0 # 0 is disabled, in milliseconds + +# - Locale and Formatting - + +#datestyle = 'iso, mdy' +#timezone = unknown # actually, defaults to TZ environment setting +#australian_timezones = false +#extra_float_digits = 0 # min -15, max 2 +#client_encoding = sql_ascii # actually, defaults to database encoding + +# These settings are initialized by initdb -- they may be changed +lc_messages = 'en_US.UTF-8' # locale for system error +message strings +lc_monetary = 'en_US.UTF-8' # locale for monetary formatting +lc_numeric = 'en_US.UTF-8' # locale for number formatting +lc_time = 'en_US.UTF-8' # locale for time formatting + +# - Other Defaults - + +#explain_pretty_print = true +#dynamic_library_path = '$libdir' +#max_expr_depth = 10000 # min 10 + + +#--------------------------------------------------------------------------- +# LOCK MANAGEMENT +#--------------------------------------------------------------------------- + +#deadlock_timeout = 1000 # in milliseconds +#max_locks_per_transaction = 64 # min 10, ~260*max_connections bytes each + + +#--------------------------------------------------------------------------- +# VERSION/PLATFORM COMPATIBILITY +#--------------------------------------------------------------------------- + +# - Previous Postgres Versions - + +#add_missing_from = true +#regex_flavor = advanced # advanced, extended, or basic +#sql_inheritance = true + +# - Other Platforms & Clients - + +#transform_null_equals = false + +From pgsql-performance-owner@postgresql.org Sat Jun 26 05:58:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B6DD2D1B8BB + for ; + Sat, 26 Jun 2004 05:58: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 90717-09 + for ; + Sat, 26 Jun 2004 08:58:19 +0000 (GMT) +Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) + by svr1.postgresql.org (Postfix) with ESMTP id DC84CD1B215 + for ; + Sat, 26 Jun 2004 05:58:15 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id BC3A4101339; + Sat, 26 Jun 2004 16:58:16 +0800 (WST) +Received: from [192.168.1.9] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan02.westnet.com.au (Postfix) with ESMTP id 8E654101329; + Sat, 26 Jun 2004 16:58:15 +0800 (WST) +Message-ID: <40DD3AA8.3040708@familyhealth.com.au> +Date: Sat, 26 Jun 2004 16:58:16 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-15?Q?Herv=E9_Piedvache?= +Cc: pgsql-performance@postgresql.org, pam@pmg.xs4all.nl +Subject: Re: How can one see what queries are running withing a +References: <1088192269.6490.3.camel@localhost> + <200406252251.09228.footcow@noos.fr> + <200406260927.12812.footcow@noos.fr> +In-Reply-To: <200406260927.12812.footcow@noos.fr> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/260 +X-Sequence-Number: 7318 + + +>>Let see in contrib/ the application pg_who ... you will see the process, +>>the queries, and the CPU ... ;o) + +Even easier: + +SELECT * FROM pg_stat_activity; + +As a superuser. + +Chris + +From pgsql-performance-owner@postgresql.org Sat Jun 26 10:32:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 659C6D1CA62 + for ; + Sat, 26 Jun 2004 10:32: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 53628-03 + for ; + Sat, 26 Jun 2004 13:32:11 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CA2AD1CA4D + for ; + Sat, 26 Jun 2004 10:32:07 -0300 (ADT) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1BeDHv-0004U7-00 + for ; Sat, 26 Jun 2004 15:32:11 +0200 +Received: from sp-260-1.net4.netcentrix.net ([4.21.254.118]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Sat, 26 Jun 2004 15:32:11 +0200 +Received: from doug by sp-260-1.net4.netcentrix.net with local (Gmexim 0.1 + (Debian)) id 1AlnuQ-0007hv-00 + for ; Sat, 26 Jun 2004 15:32:11 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Doug McNaught +Subject: Re: postgres 7.4 at 100% +Date: Sat, 26 Jun 2004 09:32:08 -0400 +Lines: 8 +Message-ID: <87llia78dj.fsf@asmodeus.mcnaught.org> +References: + <40DBEBDF.3090605@archonet.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: sp-260-1.net4.netcentrix.net +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +Cancel-Lock: sha1:oQauYJcg6k2/pMb/ZgSmfqHAGTo= +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/261 +X-Sequence-Number: 7319 + +Chris Cheston writes: + +> shared_buffers = 40 # min 16, at least max_connections*2, 8KB each + +This is ridiculously low for any kind of production server. Try +something like 5000-10000 for a start. + +-Doug + + +From pgsql-performance-owner@postgresql.org Sat Jun 26 11:16:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 24EB6D1B7D6 + for ; + Sat, 26 Jun 2004 11:16: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 62861-08 + for ; + Sat, 26 Jun 2004 14:16:11 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 93C83D1B19F + for ; + Sat, 26 Jun 2004 11:16:06 -0300 (ADT) +Received: from commandprompt.com (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i5QEG9o27778; + Sat, 26 Jun 2004 07:16:09 -0700 +Message-ID: <40DD8425.3080108@commandprompt.com> +Date: Sat, 26 Jun 2004 07:11:49 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Doug McNaught +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +References: + <40DBEBDF.3090605@archonet.com> + + <87llia78dj.fsf@asmodeus.mcnaught.org> +In-Reply-To: <87llia78dj.fsf@asmodeus.mcnaught.org> +Content-Type: multipart/alternative; + boundary="------------050501070906010906040608" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: * +X-Archive-Number: 200406/262 +X-Sequence-Number: 7320 + +This is a multi-part message in MIME format. +--------------050501070906010906040608 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Hello, + +Not to mention upping your effective_cache. + +Doug McNaught wrote: + +>Chris Cheston writes: +> +> +> +>>shared_buffers = 40 # min 16, at least max_connections*2, 8KB each +>> +>> +> +>This is ridiculously low for any kind of production server. Try +>something like 5000-10000 for a start. +> +>-Doug +> +> +>---------------------------(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 +> +> + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +--------------050501070906010906040608 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Hello,
+
+Not to mention upping your effective_cache.
+
+Doug McNaught wrote:
+
+
Chris Cheston <ccheston@gmail.com> writes:
+
+  
+
+
shared_buffers = 40             # min 16, at least max_connections*2, 8KB each
+    
+
+

+This is ridiculously low for any kind of production server.  Try
+something like 5000-10000 for a start.
+
+-Doug
+
+
+---------------------------(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
+  
+
+
+
+
-- 
+Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
+Postgresql support, programming shared hosting and dedicated hosting.
++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
+PostgreSQL Replicator -- production quality replication for PostgreSQL
+ + + +--------------050501070906010906040608-- + +From pgsql-performance-owner@postgresql.org Sat Jun 26 11:46:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E65FCD1B196 + for ; + Sat, 26 Jun 2004 11: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 69356-05 + for ; + Sat, 26 Jun 2004 14:46: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 4C5BAD1B7D1 + for ; + Sat, 26 Jun 2004 11:46:02 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5QEjvqg009874; + Sat, 26 Jun 2004 10:45:58 -0400 (EDT) +To: Christopher Kings-Lynne +Cc: =?ISO-8859-15?Q?Herv=E9_Piedvache?= , + pgsql-performance@postgresql.org, pam@pmg.xs4all.nl +Subject: Re: How can one see what queries are running withing a +In-reply-to: <40DD3AA8.3040708@familyhealth.com.au> +References: <1088192269.6490.3.camel@localhost> + <200406252251.09228.footcow@noos.fr> + <200406260927.12812.footcow@noos.fr> + <40DD3AA8.3040708@familyhealth.com.au> +Comments: In-reply-to Christopher Kings-Lynne + message dated "Sat, 26 Jun 2004 16:58:16 +0800" +Date: Sat, 26 Jun 2004 10:45:57 -0400 +Message-ID: <9873.1088261157@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/263 +X-Sequence-Number: 7321 + +Christopher Kings-Lynne writes: +> Even easier: +> SELECT * FROM pg_stat_activity; + +But note you must enable stats_command_string to make this very useful. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Jun 26 20:03:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64429D1B191 + for ; + Sat, 26 Jun 2004 20:03: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 09316-03 + for ; + Sat, 26 Jun 2004 23:03:21 +0000 (GMT) +Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.251]) + by svr1.postgresql.org (Postfix) with SMTP id E9523D1B19C + for ; + Sat, 26 Jun 2004 20:03:16 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id w41so813539cwb + for ; + Sat, 26 Jun 2004 16:03:19 -0700 (PDT) +Received: by 10.38.164.51 with SMTP id m51mr68807rne; + Sat, 26 Jun 2004 16:03:19 -0700 (PDT) +Message-ID: +Date: Sat, 26 Jun 2004 16:03:19 -0700 +From: Chris Cheston +To: "Joshua D. Drake" +Subject: Re: postgres 7.4 at 100% +Cc: Doug McNaught , + pgsql-performance@postgresql.org +In-Reply-To: <40DD8425.3080108@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <40DBEBDF.3090605@archonet.com> + + <87llia78dj.fsf@asmodeus.mcnaught.org> + <40DD8425.3080108@commandprompt.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/264 +X-Sequence-Number: 7322 + +Hi all, + +I upped effective_cache to 16000 KB and I could only up the +shared_buffers to 3000. Anything more and postgres would not start. + +Postmaster is still using lots of CPU. pg_stat_activity shows only +query is happening at a time so the requests are probably queueing on +this one thread. Is this the right way to go? + +Any other suggestions for me to figure out why Postmaster is using so much CPU? + +Thanks in advance, +Chris + +numnet=# select * from pg_stat_activity; + datid | datname | procpid | usesysid | usename | + + current_query + + | query_start +-------+---------+---------+----------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------- + 17144 | numnet | 26120 | 103 | numnet | + + + + | 2004-06-26 18:01:24.02042-04 + 17144 | numnet | 26121 | 103 | numnet | + + + + | 2004-06-26 18:01:24.026025-04 + 17144 | numnet | 26122 | 103 | numnet | + + + + | 2004-06-26 18:01:24.030917-04 + 17144 | numnet | 26123 | 103 | numnet | + + + + | 2004-06-26 18:01:24.036266-04 + 17144 | numnet | 26124 | 103 | numnet | + + + + | 2004-06-26 18:01:24.041551-04 + 17144 | numnet | 26125 | 103 | numnet | + + + + | 2004-06-26 18:01:24.046449-04 + 17144 | numnet | 26126 | 103 | numnet | + + + + | 2004-06-26 18:01:24.051666-04 + 17144 | numnet | 26127 | 103 | numnet | + + + + | 2004-06-26 18:01:24.057398-04 + 17144 | numnet | 26128 | 103 | numnet | + + + + | 2004-06-26 18:01:24.06225-04 + 17144 | numnet | 26129 | 103 | numnet | SELECT id,name,number, +systemid,pin,last,to,from,lastest,start,end,continue,type,status,duration +FROM logs WHERE (((from= 'me') and (to= 'you')) and (serverip= +'23.6.6.33 + 17144 | numnet | 26147 | 103 | numnet | + + + + | 2004-06-26 18:03:46.175789-04 +(11 rows) + + + + +----- Original Message ----- +From: Joshua D. Drake +Date: Sat, 26 Jun 2004 07:11:49 -0700 +Subject: Re: [PERFORM] postgres 7.4 at 100% +To: Doug McNaught +Cc: pgsql-performance@postgresql.org + + +Hello, + +Not to mention upping your effective_cache. + + +Doug McNaught wrote: + +Chris Cheston writes: + + +shared_buffers = 40 # min 16, at least max_connections*2, 8KB each + This is ridiculously low for any kind of production server. Try +something like 5000-10000 for a start. + +-Doug + + +---------------------------(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 + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + +From pgsql-performance-owner@postgresql.org Sun Jun 27 02:33:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AEEDFD1B182 + for ; + Sun, 27 Jun 2004 02:33: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 23729-04 + for ; + Sun, 27 Jun 2004 05:33:27 +0000 (GMT) +Received: from vscan01.westnet.com.au (vscan01.westnet.com.au [203.10.1.131]) + by svr1.postgresql.org (Postfix) with ESMTP id 905FAD1B232 + for ; + Sun, 27 Jun 2004 02:33:25 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id D3E2C509AB; + Sun, 27 Jun 2004 13:33:24 +0800 (WST) +Received: from [192.168.1.9] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan01.westnet.com.au (Postfix) with ESMTP id 4FCB050A27; + Sun, 27 Jun 2004 13:33:22 +0800 (WST) +Message-ID: <40DE5C25.6070805@familyhealth.com.au> +Date: Sun, 27 Jun 2004 13:33:25 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Cheston +Cc: "Joshua D. Drake" , + Doug McNaught , pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +References: + <40DBEBDF.3090605@archonet.com> + + <87llia78dj.fsf@asmodeus.mcnaught.org> + <40DD8425.3080108@commandprompt.com> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/265 +X-Sequence-Number: 7323 + +> I upped effective_cache to 16000 KB and I could only up the +> shared_buffers to 3000. Anything more and postgres would not start. + +You need to greatly incrase the shared memory max setting on your +machine so that you can use at the very least, 10000 shared buffers. + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Jun 30 23:52:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 84730D1B19F + for ; + Sun, 27 Jun 2004 14:31: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 36674-05 + for ; + Sun, 27 Jun 2004 17:31:16 +0000 (GMT) +Received: from smtp-out1.xs4all.nl (smtp-out1.xs4all.nl [194.109.24.11]) + by svr1.postgresql.org (Postfix) with ESMTP id AA3E2D1B1BE + for ; + Sun, 27 Jun 2004 14:31:13 -0300 (ADT) +Received: from uucp1.xs4all.nl (uucp1.xs4all.nl [194.109.21.51]) + by smtp-out1.xs4all.nl (8.12.10/8.12.10) with ESMTP id i5RHV7xq007649; + Sun, 27 Jun 2004 19:31:08 +0200 (CEST) +Received: from uucp1.xs4all.nl (localhost [127.0.0.1]) + by uucp1.xs4all.nl (8.12.9/8.12.9) with ESMTP id i5RHV6E7076205; + Sun, 27 Jun 2004 19:31:07 +0200 (CEST) +Received: from ramoth.UUCP (uucp@localhost) + by uucp1.xs4all.nl (8.12.9/8.12.9/Submit) with UUCP id i5RHV56x076204; + Sun, 27 Jun 2004 19:31:05 +0200 (CEST) +Received: by ladystrange.bluehorizon.nl id m1BedP6-000gcbC + (Debian Smail-3.2.0.115 2003-Jun-18 #2); + Sun, 27 Jun 2004 19:25:20 +0200 (CEST) +From: "P.A.M. van Dam " +Date: Sun, 27 Jun 2004 19:25:20 +0200 +To: Christopher Kings-Lynne +Cc: Herv? Piedvache , + pgsql-performance@postgresql.org +Subject: Re: How can one see what queries are running withing a +Message-ID: <20040627172520.GA3038@pmg.xs4all.nl> +References: <1088192269.6490.3.camel@localhost> + <200406252251.09228.footcow@noos.fr> + <200406260927.12812.footcow@noos.fr> + <40DD3AA8.3040708@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <40DD3AA8.3040708@familyhealth.com.au> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by XS4ALL Virus Scanner +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/333 +X-Sequence-Number: 7391 + +On Sat, Jun 26, 2004 at 04:58:16PM +0800, Christopher Kings-Lynne wrote: +> +> >>Let see in contrib/ the application pg_who ... you will see the process, +> >>the queries, and the CPU ... ;o) +> +> Even easier: +> +> SELECT * FROM pg_stat_activity; +> +> As a superuser. + +Thanks! + +That works as needed! + +Best regards, + + Pascal + +> +> Chris +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html + +From pgsql-performance-owner@postgresql.org Sun Jun 27 21:35:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B035D1B215 + for ; + Sun, 27 Jun 2004 21: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 64492-01 + for ; + Mon, 28 Jun 2004 00:35:22 +0000 (GMT) +Received: from smtp.wp.pl (smtp.wp.pl [212.77.101.160]) + by svr1.postgresql.org (Postfix) with ESMTP id E0423D1B20D + for ; + Sun, 27 Jun 2004 21:35:17 -0300 (ADT) +Received: (wp-smtpd mta-1 26549 invoked from network); + 28 Jun 2004 02:35:19 +0200 +Received: from cmn108.neoplus.adsl.tpnet.pl (HELO wp.pl) + (jim.jim@[83.31.141.108]) (envelope-sender ) + by mta-1 (wp-smtpd) with SMTP + for ; 28 Jun 2004 02:35:19 +0200 +Message-ID: <40DF684D.9060207@wp.pl> +Date: Mon, 28 Jun 2004 02:37:33 +0200 +From: Jim +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; pl-PL; + rv:1.6) Gecko/20040113 +X-Accept-Language: pl, en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: SQL stupid query plan... terrible performance ! +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AntiVirus: skaner antywirusowy poczty Wirtualnej Polski S. A. [wersja 2.0c] +X-WP-AntySpam-Rezultat: NIE-SPAM +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/266 +X-Sequence-Number: 7324 + +Hi, + +I have one performance issue... and realy have no idea what's going on... +When I set enable_seqscan to 0, query2 runs the same way... + +upload => 60667 entities +uploadfield => 506316 entities + +Query1: +select count(*) from Upload NATURAL JOIN UploadField Where Upload.ShopID += 123123; + +181.944 ms + +Query2: +select count(*) from Upload NATURAL JOIN UploadField Where +Upload.UploadID = 123123; + +1136.024 ms + +Greetings, +Jim J. + + +------- +Details: +PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.2 +20030222 (Red Hat Linux 3.2.2-5) + + QUERY1 PLAN +-------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=1972.50..1972.50 rows=1 width=0) (actual +time=181.657..181.658 rows=1 loops=1) + -> Nested Loop (cost=0.00..1972.46 rows=17 width=0) (actual +time=181.610..181.610 rows=0 loops=1) + -> Seq Scan on upload (cost=0.00..1945.34 rows=2 width=8) +(actual time=181.597..181.597 rows=0 loops=1) + Filter: (shopid = 123123) + -> Index Scan using relationship_3_fk on uploadfield +(cost=0.00..13.44 rows=10 width=8) (never executed) + Index Cond: ("outer".uploadid = uploadfield.uploadid) + Total runtime: 181.944 ms + + QUERY2 PLAN +---------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=15886.74..15886.74 rows=1 width=0) (actual +time=1135.804..1135.806 rows=1 loops=1) + -> Nested Loop (cost=1945.34..15886.69 rows=20 width=0) (actual +time=1135.765..1135.765 rows=0 loops=1) + -> Seq Scan on uploadfield (cost=0.00..13940.95 rows=10 +width=8) (actual time=1135.754..1135.754 rows=0 loops=1) + Filter: (123123 = uploadid) + -> Materialize (cost=1945.34..1945.36 rows=2 width=8) (never +executed) + -> Seq Scan on upload (cost=0.00..1945.34 rows=2 +width=8) (never executed) + Filter: (uploadid = 123123) + Total runtime: 1136.024 ms + + + Table "public.upload" + Column | Type | Modifiers +------------+------------------------+----------- + uploadid | bigint | not null + nativedb | text | not null + shopid | bigint | not null +Indexes: + "pk_upload" primary key, btree (uploadid) + "nativedb" btree (nativedb) + "uploadshopid" btree (shopid) + + Table "public.uploadfield" + Column | Type | Modifiers +---------------+----------+----------- + uploadfieldid | bigint | not null + fieldnameid | smallint | not null + uploadid | bigint | not null + +Indexes: + "pk_uploadfield" primary key, btree (uploadfieldid) + "relationship_3_fk" btree (uploadid) + "relationship_4_fk" btree (fieldnameid) +Foreign-key constraints: + "fk_uploadfi_fieldname_fieldnam" FOREIGN KEY (fieldnameid) +REFERENCES fieldname(fieldnameid) ON UPDATE RESTRICT ON DELETE RESTRICT + "fk_uploadfi_uploadfie_upload" FOREIGN KEY (uploadid) REFERENCES +upload(uploadid) ON UPDATE RESTRICT ON DELETE RESTRICT + + +From pgsql-performance-owner@postgresql.org Sun Jun 27 23:47:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 09ADCD1B18A + for ; + Sun, 27 Jun 2004 23: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 00772-08 + for ; + Mon, 28 Jun 2004 02:47:24 +0000 (GMT) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id EA86DD1B1A9 + for ; + Sun, 27 Jun 2004 23:47:17 -0300 (ADT) +Received: from jefftrout.com ([24.128.241.68]) + by comcast.net (sccrmhc13) with SMTP + id <20040628024720016005p6ife>; Mon, 28 Jun 2004 02:47:21 +0000 +Received: (qmail 85664 invoked from network); 28 Jun 2004 02:47:29 -0000 +Received: from unknown (HELO ?192.168.0.103?) (10.10.10.176) + by 10.10.10.10 with SMTP; 28 Jun 2004 02:47:29 -0000 +In-Reply-To: <40DF684D.9060207@wp.pl> +References: <40DF684D.9060207@wp.pl> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <9ADF62CA-C8AD-11D8-A320-000D9366F0C4@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff +Subject: Re: SQL stupid query plan... terrible performance ! +Date: Sun, 27 Jun 2004 22:48:16 -0400 +To: Jim +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/267 +X-Sequence-Number: 7325 + + +On Jun 27, 2004, at 8:37 PM, Jim wrote: + +> Hi, +> +> I have one performance issue... and realy have no idea what's going +> on... +> When I set enable_seqscan to 0, query2 runs the same way... +> +> upload => 60667 entities +> uploadfield => 506316 entities +> + +Have you vacuum analyze'd recently? + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Mon Jun 28 00:28:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 947F7D1B23C + for ; + Mon, 28 Jun 2004 00:26: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 21027-01 + for ; + Mon, 28 Jun 2004 03:26:15 +0000 (GMT) +Received: from bill.fefferman.org (dsl081-139-018.chi1.dsl.speakeasy.net + [64.81.139.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D823D1B233 + for ; + Mon, 28 Jun 2004 00:26:13 -0300 (ADT) +Received: from billnotebook ([192.168.1.21]) by bill.fefferman.org with + Microsoft SMTPSVC(6.0.3790.0); Sun, 27 Jun 2004 22:26:14 -0500 +From: "Bill" +To: +Subject: Query performance +Date: Sun, 27 Jun 2004 22:26:19 -0500 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0001_01C45C95.C4BA4240" +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Thread-Index: AcRcv5muswl0fDZXQhqcyfGmT78eHw== +Message-ID: +X-OriginalArrivalTime: 28 Jun 2004 03:26:14.0421 (UTC) + FILETIME=[AA9E0C50:01C45CBF] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200406/268 +X-Sequence-Number: 7326 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0001_01C45C95.C4BA4240 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit + +Actually, I have some queries that are slow, however I was wondering if you +could help me write a query that is rather simple, but I, as a true database +novice, can't seem to conjure. So we have stocks, as I have previously +said, and I have a huge table which contains all of the opening and closing +prices of some stocks from each day. What I like to do, in English, for +each stock in each day is find a ratio: abs(closing-opening)/opening. Then +I would like to average all of the ratios of each day of each individual +stock together to find a final ratio for each stock, then I would like to +find the highest average, to find the best performing stock. So what query +can I use, and (as is appropriate for this group), how can it be optimized +to run the fastest? + + + + +------=_NextPart_000_0001_01C45C95.C4BA4240 +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +
+ +

Actually, I have some +queries that are slow, however I was wondering if you could help me write a +query that is rather simple, but I, as a true database novice, can't seem to +conjure.  So we have stocks, as I have previously said, and I have a h= +uge table +which contains all of the opening and closing prices of some stocks from ea= +ch +day.  What I like to do, in English, for each stock in each day is fin= +d a +ratio: abs(closing-opening)/opening.  Then I would like to average all= + of the +ratios of each day of each individual stock together to find a final ratio = +for +each stock, then I would like to find the highest average, to find the best +performing stock.  So what query can I use, and (as is appropriate for= + this group), +how can it be optimized to run the fastest?

+ +

 

+ +
+ + + + + +------=_NextPart_000_0001_01C45C95.C4BA4240-- + + +From pgsql-performance-owner@postgresql.org Mon Jun 28 00:31:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 01131D1B174 + for ; + Mon, 28 Jun 2004 00:29: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 19558-09 + for ; + Mon, 28 Jun 2004 03:29: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 4174BD1B241 + for ; + Mon, 28 Jun 2004 00:29:47 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5S3TkMg016909; + Sun, 27 Jun 2004 23:29:47 -0400 (EDT) +To: Jim +Cc: pgsql-performance@postgresql.org +Subject: Re: SQL stupid query plan... terrible performance ! +In-reply-to: <40DF684D.9060207@wp.pl> +References: <40DF684D.9060207@wp.pl> +Comments: In-reply-to Jim + message dated "Mon, 28 Jun 2004 02:37:33 +0200" +Date: Sun, 27 Jun 2004 23:29:46 -0400 +Message-ID: <16908.1088393386@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/269 +X-Sequence-Number: 7327 + +Jim writes: +> I have one performance issue... and realy have no idea what's going on... + +[yawn...] Cast the constants to bigint. See previous discussions. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jun 28 01:47:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F9E5D1B196 + for ; + Mon, 28 Jun 2004 01:47: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 44143-09 + for ; + Mon, 28 Jun 2004 04:47:09 +0000 (GMT) +Received: from mail.praemunio.com (mail.praemunio.com [66.179.47.216]) + by svr1.postgresql.org (Postfix) with SMTP id 32AE8D1B187 + for ; + Mon, 28 Jun 2004 01:47:05 -0300 (ADT) +Received: from localhost (HELO mail.knobbe.us) + by localhost with SMTP; 27 Jun 2004 23:47:04 -0500 +Received: from localhost (HELO ??) + by localhost with SMTP; 27 Jun 2004 23:47:01 -0500 +Subject: Re: postgres 7.4 at 100% +From: Frank Knobbe +To: Christopher Kings-Lynne +Cc: pgsql-performance@postgresql.org +In-Reply-To: <40DE5C25.6070805@familyhealth.com.au> +References: + <40DBEBDF.3090605@archonet.com> + + <87llia78dj.fsf@asmodeus.mcnaught.org> + <40DD8425.3080108@commandprompt.com> + + <40DE5C25.6070805@familyhealth.com.au> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-c14bXWLYqKeKySi/hCZM" +Message-Id: <1088397641.1105.10.camel@localhost> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Sun, 27 Jun 2004 23:46:58 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/270 +X-Sequence-Number: 7328 + +--=-c14bXWLYqKeKySi/hCZM +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Sun, 2004-06-27 at 00:33, Christopher Kings-Lynne wrote: +> > I upped effective_cache to 16000 KB and I could only up the +> > shared_buffers to 3000. Anything more and postgres would not start. +>=20 +> You need to greatly incrase the shared memory max setting on your=20 +> machine so that you can use at the very least, 10000 shared buffers. + + +Doug said the same, yet the PG Tuning article recommends not make this +too large as it is just temporary used by the query queue or so. (I +guess the system would benefit using more memory for file system cache) + +So who is correct? The tuning article or big-honking-shared-mem +proponents? + +FWIW: I have a box with 512 MB RAM and see no different between 4096 and +32758 shared buffers... + +Regards, +Frank + + +--=-c14bXWLYqKeKySi/hCZM +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (FreeBSD) + +iD4DBQBA36FJJjGc5ftAw8wRAn8AAJiGwf9Yy6lBXO1BwfgXMZkm55G0AKCLSJuM +lP6gBaVD1ssMfYElPDwLEg== +=CYVa +-----END PGP SIGNATURE----- + +--=-c14bXWLYqKeKySi/hCZM-- + + +From pgsql-performance-owner@postgresql.org Mon Jun 28 02:20:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D8CF8D1B174 + for ; + Mon, 28 Jun 2004 02:19: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 53343-07 + for ; + Mon, 28 Jun 2004 05:19: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 F2E85D1B170 + for ; + Mon, 28 Jun 2004 02:19:46 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5S5JgNb017885; + Mon, 28 Jun 2004 01:19:42 -0400 (EDT) +To: Frank Knobbe +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +In-reply-to: <1088397641.1105.10.camel@localhost> +References: + <40DBEBDF.3090605@archonet.com> + + <87llia78dj.fsf@asmodeus.mcnaught.org> + <40DD8425.3080108@commandprompt.com> + + <40DE5C25.6070805@familyhealth.com.au> + <1088397641.1105.10.camel@localhost> +Comments: In-reply-to Frank Knobbe + message dated "Sun, 27 Jun 2004 23:46:58 -0500" +Date: Mon, 28 Jun 2004 01:19:42 -0400 +Message-ID: <17884.1088399982@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/271 +X-Sequence-Number: 7329 + +Frank Knobbe writes: +> On Sun, 2004-06-27 at 00:33, Christopher Kings-Lynne wrote: +>>> I upped effective_cache to 16000 KB and I could only up the +>>> shared_buffers to 3000. Anything more and postgres would not start. + +>> You need to greatly incrase the shared memory max setting on your +>> machine so that you can use at the very least, 10000 shared buffers. + +> Doug said the same, yet the PG Tuning article recommends not make this +> too large as it is just temporary used by the query queue or so. + +The original report was that the guy had it set to 40 (!?), which is +clearly far below the minimum reasonable value. But I'd not expect a +huge difference between 3000 and 10000 --- in my experience, 1000 is +enough to get you over the "knee" of the performance curve and into +the domain of marginal improvements. + +So while he surely should not go back to 40, it seems there's another +factor involved here that we've not recognized yet. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Jun 30 23:51:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C13F7D1B248 + for ; + Mon, 28 Jun 2004 02:44: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 62250-04 + for ; + Mon, 28 Jun 2004 05:44:09 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 127C0D1B1F8 + for ; + Mon, 28 Jun 2004 02:44:07 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i5S5i6QC077021 + for ; Mon, 28 Jun 2004 05:44:06 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i5S5Nr58069913 + for pgsql-performance@postgresql.org; Mon, 28 Jun 2004 05:23:53 GMT +From: "Mischa Sandberg" +X-Newsgroups: comp.databases.postgresql.performance +References: +Subject: Re: Query performance +Lines: 156 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_004C_01C45C95.6EC8EA80" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +Message-ID: +Date: Mon, 28 Jun 2004 05:23:53 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.8 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE, PRIORITY_NO_NAME, WEIRD_QUOTING +X-Spam-Level: * +X-Archive-Number: 200406/332 +X-Sequence-Number: 7390 + +This is a multi-part message in MIME format. + +------=_NextPart_000_004C_01C45C95.6EC8EA80 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Usually, when you post a request like this, you should provide something a = +little more concrete (the CREATE TABLE statement for that table, with=20 +Since you didn't, I'll posit something that sounds like what you're using, = +and take a stab at your problem. + +TABLE Prices ( + stock VARCHAR(9) + ,asof DATE, + ,opening MONEY + ,closing MONEY + ,PRIMARY KEY (stock, asof) + ) + +SELECT stock, AVG((closing-opening)/opening) as ratio +FROM Prices=20 +GROUP BY stock +ORDER BY ratio DESC LIMIT 10; -- top 10 best-performing stocks. + +""Bill"" wrote in message news:BILLSA1XvpFVjCRGryW= +00000002@bill.fefferman.org... + Actually, I have some queries that are slow, however I was wondering if y= +ou could help me write a query that is rather simple, but I, as a true data= +base novice, can't seem to conjure. So we have stocks, as I have previousl= +y said, and I have a huge table which contains all of the opening and closi= +ng prices of some stocks from each day. What I like to do, in English, for= + each stock in each day is find a ratio: abs(closing-opening)/opening. The= +n I would like to average all of the ratios of each day of each individual = +stock together to find a final ratio for each stock, then I would like to f= +ind the highest average, to find the best performing stock. So what query = +can I use, and (as is appropriate for this group), how can it be optimized = +to run the fastest? + +=20=20=20 + +------=_NextPart_000_004C_01C45C95.6EC8EA80 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Usually, when you post a request like this, you should = +provide=20 +something a little more concrete (the CREATE TABLE statement for that table= +,=20 +with
+
Since you didn't, I'll posit something that sounds like= + what=20 +you're using, and take a stab at your problem.
+
 
+
TABLE Prices (
+
    stock   =20 +VARCHAR(9)
+
    ,asof    =20 +    DATE,
+
    ,opening   MONEY +
    ,closing   =20 +MONEY
+
    ,PRIMARY KEY (stock, asof) +
    )
+
 
+
SELECT    stock, AVG((closing-opening)/o= +pening)=20 +as ratio
+
FROM    Prices
+
GROUP BY stock
+
ORDER BY ratio DESC LIMIT 10;    -- top = +10=20 +best-performing stocks.
+
 
+
""Bill"" <bill@math.uchicago.edu> wrote= + in=20 +message news:BILLSA1Xv= +pFVjCRGryW00000002@bill.fefferman.org...
+
+
+

Actually, I have so= +me=20 + queries that are slow, however I was wondering if you could help me write= + a=20 + query that is rather simple, but I, as a true database novice, can't seem= + to=20 + conjure.  So we have stocks, as I have previously said, and I have a= + huge=20 + table which contains all of the opening and closing prices of some stocks= + from=20 + each day.  What I like to do, in English, for each stock in each day= + is=20 + find a ratio: abs(closing-opening)/opening.  Then I would like to av= +erage=20 + all of the ratios of each day of each individual stock together to find a= +=20 + final ratio for each stock, then I would like to find the highest average= +, to=20 + find the best performing stock.  So what query can I use, and (as is= +=20 + appropriate for this group), how can it be optimized to run the=20 + fastest?

+

 

+ +------=_NextPart_000_004C_01C45C95.6EC8EA80-- + + +From pgsql-performance-owner@postgresql.org Mon Jun 28 02:22:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 04E59D1B25F + for ; + Mon, 28 Jun 2004 02:21: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 55835-04 + for ; + Mon, 28 Jun 2004 05:21:53 +0000 (GMT) +Received: from mailhub2.une.edu.au (mailhub2.une.edu.au [129.180.1.142]) + by svr1.postgresql.org (Postfix) with ESMTP id AA503D1B258 + for ; + Mon, 28 Jun 2004 02:21:51 -0300 (ADT) +Received: from icarus.une.edu.au (icarus.une.edu.au [129.180.47.120]) + by mailhub2.une.edu.au (Postfix) with ESMTP id B7ED17ECD + for ; + Mon, 28 Jun 2004 15:21:50 +1000 (EST) +Received: from kgb (kgb.une.edu.au [129.180.47.225]) + by icarus.une.edu.au (8.12.8/8.12.8) with SMTP id i5S5QaNv008311 + for ; Mon, 28 Jun 2004 15:26:36 +1000 +Date: Mon, 28 Jun 2004 15:29:57 +1000 +From: Klint Gore +To: pgsql-performance@postgresql.org +Subject: Re: SQL stupid query plan... terrible performance ! +In-Reply-To: <16908.1088393386@sss.pgh.pa.us> +References: <40DF684D.9060207@wp.pl> <16908.1088393386@sss.pgh.pa.us> +Message-Id: <40DFACD5345.1020KG@129.180.47.120> +MIME-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Mailer: Becky! ver 1.25.06 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/272 +X-Sequence-Number: 7330 + +On Sun, 27 Jun 2004 23:29:46 -0400, Tom Lane wrote: +> Jim writes: +> > I have one performance issue... and realy have no idea what's going on... +> +> [yawn...] Cast the constants to bigint. See previous discussions. +> +> regards, tom lane + +Would there be any way of adding some sort of indicator to the plan as +to why sequential was chosen? + +eg + Seq Scan on upload (type mismatch) (cost....) + Seq Scan on upload (statistics) (cost....) + Seq Scan on upload (catch-all) (cost....) + +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 Jun 28 02:49:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C3DF3D1B215 + for ; + Mon, 28 Jun 2004 02: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 63207-07 + for ; + Mon, 28 Jun 2004 05:48: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 D5C69D1B1D9 + for ; + Mon, 28 Jun 2004 02:48:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5S5miwL018212; + Mon, 28 Jun 2004 01:48:44 -0400 (EDT) +To: Klint Gore +Cc: pgsql-performance@postgresql.org +Subject: Re: SQL stupid query plan... terrible performance ! +In-reply-to: <40DFACD5345.1020KG@129.180.47.120> +References: <40DF684D.9060207@wp.pl> <16908.1088393386@sss.pgh.pa.us> + <40DFACD5345.1020KG@129.180.47.120> +Comments: In-reply-to Klint Gore + message dated "Mon, 28 Jun 2004 15:29:57 +1000" +Date: Mon, 28 Jun 2004 01:48:43 -0400 +Message-ID: <18211.1088401723@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/273 +X-Sequence-Number: 7331 + +Klint Gore writes: +> On Sun, 27 Jun 2004 23:29:46 -0400, Tom Lane wrote: +>> [yawn...] Cast the constants to bigint. See previous discussions. + +> Would there be any way of adding some sort of indicator to the plan as +> to why sequential was chosen? + +Not really ... the plan that's presented is the one that looked the +cheapest out of the feasible plans. How are you going to identify a +single reason as to why any other plan was not generated or lost out +on a cost-estimate basis? Humans might be able to do so (note that +the above quote is an off-the-cuff estimate, not something I'd care +to defend rigorously) but I don't think software can do it. + +FWIW, the particular problem here should be fixed in 7.5. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Jun 28 06:14:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0120DD1B347 + for ; + Mon, 28 Jun 2004 06:14: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 51185-02 + for ; + Mon, 28 Jun 2004 09:14:14 +0000 (GMT) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id C0558D1B2BD + for ; + Mon, 28 Jun 2004 06:14:11 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BesDN-0007o0-0W; Mon, 28 Jun 2004 10:14:13 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 6DB0716C93; Mon, 28 Jun 2004 10:14:12 +0100 (BST) +Message-ID: <40DFE163.8000107@archonet.com> +Date: Mon, 28 Jun 2004 10:14:11 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/274 +X-Sequence-Number: 7332 + +Bill wrote: +> Actually, I have some queries that are slow, however I was wondering if you +> could help me write a query that is rather simple, but I, as a true database +> novice, can't seem to conjure. So we have stocks, as I have previously +> said, and I have a huge table which contains all of the opening and closing +> prices of some stocks from each day. + +Schemas, Bill - show us your table definitions so people can see exactly +where they stand. + + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Jun 28 13:49:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B6F22D1B33F + for ; + Mon, 28 Jun 2004 13:49: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 76180-06 + for ; + Mon, 28 Jun 2004 16:49:23 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id D0C4ED1B2D9 + for ; + Mon, 28 Jun 2004 13:49:21 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5531585; Mon, 28 Jun 2004 09:51:03 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane , Frank Knobbe +Subject: Re: postgres 7.4 at 100% +Date: Mon, 28 Jun 2004 09:47:59 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> +In-Reply-To: <17884.1088399982@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200406280947.59420.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/275 +X-Sequence-Number: 7333 + +Tom, + +> So while he surely should not go back to 40, it seems there's another +> factor involved here that we've not recognized yet. + +I'd agree. Actually, the first thing I'd do, were it my machine, is reboot it +and run memtest86 overnight. CPU thrashing like that may indicate bad RAM. + +If the RAM checks out, I'd like to see the EXPLAIN ANALYZE for some of the +longest-running queries, and for those INSERTS. + +Also, is the new machine running Software RAID? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Jun 28 14:03:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 44399D1B1A9 + for ; + Mon, 28 Jun 2004 14:02: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 85498-05 + for ; + Mon, 28 Jun 2004 17:02:39 +0000 (GMT) +Received: from math.uchicago.edu (math.uchicago.edu [128.135.72.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 6ABCBD1B174 + for ; + Mon, 28 Jun 2004 14:02:36 -0300 (ADT) +Received: from billnotebook (wireless-199-208.uchicago.edu [128.135.199.208]) + by math.uchicago.edu (8.12.10/8.12.10) with ESMTP id i5SH2YfL013269 + for ; + Mon, 28 Jun 2004 12:02:36 -0500 +Message-Id: <200406281702.i5SH2YfL013269@math.uchicago.edu> +From: "Bill" +To: +Subject: Re: Query performance +Date: Mon, 28 Jun 2004 12:02:40 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +In-Reply-To: <40DFE163.8000107@archonet.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Thread-Index: AcRc8SMpS+jFDE1lQ1KaBvEuUe1v6AAQEUUg +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/276 +X-Sequence-Number: 7334 + +Ok....so here lies the output of oclh (i.e "\d oclh") + + Table "public.oclh" + Column | Type | Modifiers +--------+-----------------------+------------------------------- + symbol | character varying(10) | not null default '' + date | date | not null default '0001-01-01' + open | numeric(12,2) | not null default '0.00' + close | numeric(12,2) | not null default '0.00' + low | numeric(12,2) | not null default '0.00' + high | numeric(12,2) | not null default '0.00' +Indexes: symbol_2_oclh_index btree (symbol, date), + symbol_oclh_index btree (symbol, date) + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Richard Huxton +Sent: Monday, June 28, 2004 4:14 AM +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Query performance + +Bill wrote: +> Actually, I have some queries that are slow, however I was wondering if +you +> could help me write a query that is rather simple, but I, as a true +database +> novice, can't seem to conjure. So we have stocks, as I have previously +> said, and I have a huge table which contains all of the opening and +closing +> prices of some stocks from each day. + +Schemas, Bill - show us your table definitions so people can see exactly +where they stand. + + +-- + Richard Huxton + Archonet Ltd + +---------------------------(end of broadcast)--------------------------- +TIP 4: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Mon Jun 28 14:42:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B7EC8D1B174 + for ; + Mon, 28 Jun 2004 14: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 12974-01 + for ; + Mon, 28 Jun 2004 17:41:54 +0000 (GMT) +Received: from smtp.wp.pl (smtp.wp.pl [212.77.101.160]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B48DD1B28B + for ; + Mon, 28 Jun 2004 14:41:51 -0300 (ADT) +Received: (wp-smtpd mta-1 723 invoked from network); + 28 Jun 2004 19:41:50 +0200 +Received: from cnn2.neoplus.adsl.tpnet.pl (HELO wp.pl) (jim.jim@[83.31.167.2]) + (envelope-sender ) by mta-1 (wp-smtpd) with SMTP + for ; 28 Jun 2004 19:41:50 +0200 +Message-ID: <40E058E3.5060608@wp.pl> +Date: Mon, 28 Jun 2004 19:44:03 +0200 +From: Jim +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; pl-PL; + rv:1.6) Gecko/20040113 +X-Accept-Language: pl, en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: SQL stupid query plan... terrible performance ! +References: <40DF684D.9060207@wp.pl> <16908.1088393386@sss.pgh.pa.us> + <40DFACD5345.1020KG@129.180.47.120> + <18211.1088401723@sss.pgh.pa.us> +In-Reply-To: <18211.1088401723@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit +X-AntiVirus: skaner antywirusowy poczty Wirtualnej Polski S. A. [wersja 2.0c] +X-WP-AntySpam-Rezultat: NIE-SPAM +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/277 +X-Sequence-Number: 7335 + + 2004-06-28 07:48, Tom Lane wrote: + +>Klint Gore writes: +>> On Sun, 27 Jun 2004 23:29:46 -0400, Tom Lane wrote: +>>> [yawn...] Cast the constants to bigint. See previous discussions. +> +> +[cuuuut] + +Thanks a lot guys. The term "Cast the constants to bigint" It is what I +was looking for. I add explicitly ::data_type in my queries and +everything works fine now. + +One more thanks to Tom Lane - After your answer I found your post on the +newsgroup about this problem... the date of the post is 2001 year... You +are really patience man.... :) + +But I really have no idea what term I could use to force goggle to give +me solution ;) + +Greetings, +Jim J. + +From pgsql-performance-owner@postgresql.org Mon Jun 28 16:41:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 06345D1B1A9 + for ; + Mon, 28 Jun 2004 16:40: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 76636-05 + for ; + Mon, 28 Jun 2004 19:40:12 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 66F9BD1B1D2 + for ; + Mon, 28 Jun 2004 16:40:09 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5533388; Mon, 28 Jun 2004 12:41:49 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Frank Knobbe +Subject: Re: postgres 7.4 at 100% +Date: Mon, 28 Jun 2004 12:40:02 -0700 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: + <40DE5C25.6070805@familyhealth.com.au> + <1088397641.1105.10.camel@localhost> +In-Reply-To: <1088397641.1105.10.camel@localhost> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406281240.02954.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200406/278 +X-Sequence-Number: 7336 + +Frank, + +> Doug said the same, yet the PG Tuning article recommends not make this +> too large as it is just temporary used by the query queue or so. (I +> guess the system would benefit using more memory for file system cache) + +As one of the writers of that article, let me point out: + +" -- Medium size data set and 256-512MB available RAM: 16-32MB (2048-4096) +-- Large dataset and lots of available RAM (1-4GB): 64-256MB (8192-32768) " + +While this is probably a little conservative, it's still way bigger than 40. + +I would disagree with the folks who suggest 32,000 as a setting for you. On +Linux, that's a bit too large; I've never seen performance improvements with +shared_buffers greater than 18% of *available* RAM. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Jun 28 18:48:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB1BBD1B1BE + for ; + Mon, 28 Jun 2004 18:47: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 46937-07 + for ; + Mon, 28 Jun 2004 21:47:05 +0000 (GMT) +Received: from mail.praemunio.com (mail.praemunio.com [66.179.47.216]) + by svr1.postgresql.org (Postfix) with SMTP id 265AFD1B18A + for ; + Mon, 28 Jun 2004 18:47:00 -0300 (ADT) +Received: from localhost (HELO mail.knobbe.us) + by localhost with SMTP; 28 Jun 2004 16:46:59 -0500 +Received: from localhost (HELO ??) + by localhost with SMTP; 28 Jun 2004 16:46:58 -0500 +Subject: Re: postgres 7.4 at 100% +From: Frank Knobbe +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200406281240.02954.josh@agliodbs.com> +References: + <40DE5C25.6070805@familyhealth.com.au> + <1088397641.1105.10.camel@localhost> + <200406281240.02954.josh@agliodbs.com> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-99TmdPzWsPKlJ1X4XhCX" +Message-Id: <1088459215.551.18.camel@localhost> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 28 Jun 2004 16:46:55 -0500 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/279 +X-Sequence-Number: 7337 + +--=-99TmdPzWsPKlJ1X4XhCX +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Mon, 2004-06-28 at 14:40, Josh Berkus wrote: +> As one of the writers of that article, let me point out: +>=20 +> " -- Medium size data set and 256-512MB available RAM: 16-32MB (2048-4096= +)=20 +> -- Large dataset and lots of available RAM (1-4GB): 64-256MB (8192-32768)= + " +>=20 +> While this is probably a little conservative, it's still way bigger than = +40. + +I agree that 40 is a bit weak :) Chris' system has only 512 MB of RAM +though. I thought the quick response "..for any kind of production +server, try 5000-10000..." -- without considering how much memory he has +-- was a bit... uhm... eager. + +Besides, if the shared memory is used to queue client requests, +shouldn't that memory be sized according to workload (i.e. amount of +clients, transactions per second, etc) instead of just taking a +percentage of the total amount of memory? If there only a few +connections, why waste shared memory on that when the memory could be +better used as file system cache to prevent PG from going to the disk so +often?=20 + +I understand tuning PG is almost an art form, yet it should be based on +actual usage patterns, not just by system dimensions, don't you agree? + +Regards, +Frank + + + + + +--=-99TmdPzWsPKlJ1X4XhCX +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (FreeBSD) + +iD8DBQBA4JHPJjGc5ftAw8wRAiVmAKCNNXVuHGZRqKTBBuGboJekcXF+1QCfQHL2 +diFMDEKJWZXA7hwtT+OcWsM= +=EdpX +-----END PGP SIGNATURE----- + +--=-99TmdPzWsPKlJ1X4XhCX-- + + +From pgsql-performance-owner@postgresql.org Mon Jun 28 19:48:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BAB65D1B18E + for ; + Mon, 28 Jun 2004 19:47: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 72944-05 + for ; + Mon, 28 Jun 2004 22:47:46 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 01E11D1B17B + for ; + Mon, 28 Jun 2004 19:47:42 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5535134; Mon, 28 Jun 2004 15:49:26 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Frank Knobbe +Subject: Re: postgres 7.4 at 100% +Date: Mon, 28 Jun 2004 15:47:38 -0700 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: + <200406281240.02954.josh@agliodbs.com> + <1088459215.551.18.camel@localhost> +In-Reply-To: <1088459215.551.18.camel@localhost> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406281547.38742.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200406/280 +X-Sequence-Number: 7338 + +Frank, + +> I understand tuning PG is almost an art form, yet it should be based on +> actual usage patterns, not just by system dimensions, don't you agree? + +Well, it's both. It's more that available RAM determines your *upper* limit; +that is, on Linux, you don't really want to have more than 20% allocated to +the shared_buffers or you'll be taking memory away from the kernel. + +Within that limit, data size, query complexity and volume, and whether or not +you have long-running procedures tell you whether you're at the low end or +the high end. + +To futher complicate things, these calculations are all going to change with +7.5. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 03:41:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0265BD1B187 + for ; + Tue, 29 Jun 2004 03:41: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 50734-06 + for ; + Tue, 29 Jun 2004 06:41:33 +0000 (GMT) +Received: from pc7.berlin.powerweb.de (pc7.berlin.powerweb.de [62.67.228.13]) + by svr1.postgresql.org (Postfix) with ESMTP id 16BD7D1B1C8 + for ; + Tue, 29 Jun 2004 03:41:26 -0300 (ADT) +Received: from spock (p508409B6.dip0.t-ipconnect.de [80.132.9.182]) + by pc7.berlin.powerweb.de (8.9.3p3/8.9.3) with SMTP id IAA09141 + for ; Tue, 29 Jun 2004 08:41:23 +0200 +Message-ID: <007d01c45da4$3726dcd0$6602a8c0@spock> +From: "Harald Lau (Sector-X)" +To: +Subject: no index-usage on aggregate-functions? +Date: Tue, 29 Jun 2004 08:42:14 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/281 +X-Sequence-Number: 7339 + +Hi, + +I've experienced that PG up to current release does not make use of an inde= +x when aggregating. Which of course may result in unacceptable answering ti= +mes + +This behaviour is reproducable on any table with any aggregat function in a= +ll of my databases on every machine (PostgreSQL 7.4.2 on i386-redhat-linux-= +gnu and PostgreSQL 7.2.1 on i686-pc-linux-gnu) + +f.e. querying against a 2.8-mio-records (2.800.000) table the_table +SELECT count(*) FROM the_table +=3D> Seq scan -> takes about 12 sec + +SELECT Avg(num_found) AS NumFound FROM the_table --(index on num_found) +=3D> Seq scan -> takes about 10 sec + +SELECT Sum(num_found) AS TotalFound FROM the_table --(index on num_found) +=3D> Seq scan -> takes about 11 sec + +SELECT Max(date_) AS LatestDate FROM the_table --(index on date_) +=3D> Seq scan -> takes about 14 sec + +But +SELECT date_ AS LatestDate FROM the_table ORDER BY date_ DESC LIMIT 1; +=3D> Index scan -> takes 0.18 msec + +MS SQLServer 2000: Use of an appropriate index _whenever_ aggregating. + +Am I doing something wrong? + +Greetings Harald + +From pgsql-performance-owner@postgresql.org Tue Jun 29 04:24:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F3667D1B17B + for ; + Tue, 29 Jun 2004 04:24: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 68387-08 + for ; + Tue, 29 Jun 2004 07:24:10 +0000 (GMT) +Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net + [63.231.195.115]) + by svr1.postgresql.org (Postfix) with SMTP id 99474D1B181 + for ; + Tue, 29 Jun 2004 04:24:07 -0300 (ADT) +Received: (qmail 12788 invoked by uid 0); 29 Jun 2004 07:24:08 -0000 +Received: from mpls-pop-12.inet.qwest.net (63.231.195.12) + by mpls-qmqp-04.inet.qwest.net with QMQP; 29 Jun 2004 07:24:08 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-12.inet.qwest.net with SMTP; 29 Jun 2004 07:24:08 -0000 +Date: Tue, 29 Jun 2004 01:25:03 -0600 +Message-Id: <1088493903.12350.5.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Harald Lau (Sector-X)" +Cc: pgsql-performance@postgresql.org +Subject: Re: no index-usage on aggregate-functions? +In-Reply-To: <007d01c45da4$3726dcd0$6602a8c0@spock> +References: <007d01c45da4$3726dcd0$6602a8c0@spock> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/282 +X-Sequence-Number: 7340 + +On Tue, 2004-06-29 at 00:42, Harald Lau (Sector-X) wrote: +> Hi, +> +> I've experienced that PG up to current release does not make use of an index when aggregating. Which of course may result in unacceptable answering times +> +> This behaviour is reproducable on any table with any aggregat function in all of my databases on every machine (PostgreSQL 7.4.2 on i386-redhat-linux-gnu and PostgreSQL 7.2.1 on i686-pc-linux-gnu) +> +> f.e. querying against a 2.8-mio-records (2.800.000) table the_table +> SELECT count(*) FROM the_table +> => Seq scan -> takes about 12 sec +> +> SELECT Avg(num_found) AS NumFound FROM the_table --(index on num_found) +> => Seq scan -> takes about 10 sec +> +> SELECT Sum(num_found) AS TotalFound FROM the_table --(index on num_found) +> => Seq scan -> takes about 11 sec +> +> SELECT Max(date_) AS LatestDate FROM the_table --(index on date_) +> => Seq scan -> takes about 14 sec +> +> But +> SELECT date_ AS LatestDate FROM the_table ORDER BY date_ DESC LIMIT 1; +> => Index scan -> takes 0.18 msec +> +> MS SQLServer 2000: Use of an appropriate index _whenever_ aggregating. +> +> Am I doing something wrong? + +Yes, you're expecting an MVCC database to behave like a row locking +database. + +Due to the way PostgreSQL is put together, it can't count on an index +giving it values, only pointers to values, so to speak. This means it +can use an index, but it will still go to the table to get the right +value. + +On the other hand, the trade off is that MVCC can handle much higher +parallel loads, usually. + +Note that if you're aggregate is on sub subset of a table, then an index +scan can often be a big win, such as: + +create table z(a int, b int); +insert into z values (1,1); (repeat a couple thousand times) +select avg(b) from z where a=3; <-- this can use the index + +But note that in the above, the table's rows will still have to be +accessed to get the right values. + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 04:28:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C5F3D1B1B6 + for ; + Tue, 29 Jun 2004 04:28: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 72772-02 + for ; + Tue, 29 Jun 2004 07:28:30 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id BDCC2D1B26E + for ; + Tue, 29 Jun 2004 04:28:26 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i5T7SQOf007342; Tue, 29 Jun 2004 15:28:26 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <40E11BF0.3020109@familyhealth.com.au> +Date: Tue, 29 Jun 2004 15:36:16 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Harald Lau (Sector-X)" +Cc: pgsql-performance@postgresql.org +Subject: Re: no index-usage on aggregate-functions? +References: <007d01c45da4$3726dcd0$6602a8c0@spock> +In-Reply-To: <007d01c45da4$3726dcd0$6602a8c0@spock> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/283 +X-Sequence-Number: 7341 + +> f.e. querying against a 2.8-mio-records (2.800.000) table the_table +> SELECT count(*) FROM the_table +> => Seq scan -> takes about 12 sec + +This cannot be made O(1) in postgres due to MVCC. You just have to live +with it. + +> SELECT Avg(num_found) AS NumFound FROM the_table --(index on num_found) +> => Seq scan -> takes about 10 sec +> +> SELECT Sum(num_found) AS TotalFound FROM the_table --(index on num_found) +> => Seq scan -> takes about 11 sec + +Average and sum can never use an index AFAIK, in any db server. You +need information from every row. + +> SELECT Max(date_) AS LatestDate FROM the_table --(index on date_) +> => Seq scan -> takes about 14 sec + +Yep, that's due to postgresql's type extensibility. You should use th +workaround you point out below. + +> But +> SELECT date_ AS LatestDate FROM the_table ORDER BY date_ DESC LIMIT 1; +> => Index scan -> takes 0.18 msec +> +> MS SQLServer 2000: Use of an appropriate index _whenever_ aggregating. +> +> Am I doing something wrong? + +Nope. + +Chris + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 05:00:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BA2AED1B1B6 + for ; + Tue, 29 Jun 2004 05:00: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 86483-02 + for ; + Tue, 29 Jun 2004 08:00:13 +0000 (GMT) +Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.241]) + by svr1.postgresql.org (Postfix) with SMTP id CFA78D1B1EC + for ; + Tue, 29 Jun 2004 05:00:09 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id q44so599570cwc + for ; + Tue, 29 Jun 2004 01:00:11 -0700 (PDT) +Received: by 10.38.79.48 with SMTP id c48mr99042rnb; + Tue, 29 Jun 2004 01:00:10 -0700 (PDT) +Message-ID: +Date: Tue, 29 Jun 2004 01:00:10 -0700 +From: Chris Cheston +To: Josh Berkus +Subject: Re: postgres 7.4 at 100% +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200406280947.59420.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/284 +X-Sequence-Number: 7342 + +Wow, this simple query is taking 676.24 ms to execute! it only takes +18 ms on our other machine. + +This table has 150,000 rows. Is this normal? + +no, the machine is not running software RAID. Anyone have any ideas +next as to what I should do to debug this? I'm really wondering if the +Linux OS running SMP is the cause. + +Thanks, +Chris + +live=# explain analyze SELECT id FROM calllogs WHERE from = 'you'; + QUERY PLAN +---------------------------------------------------------------------------------------------------------- + Seq Scan on calllogs (cost=0.00..136.11 rows=24 width=4) (actual +time=0.30..574.72 rows=143485 loops=1) + Filter: (from = 'you'::character varying) + Total runtime: 676.24 msec +(3 rows) + +explain analyze for inserts is fast too. + + +On Mon, 28 Jun 2004 09:47:59 -0700, Josh Berkus wrote: +> +> Tom, +> +> > So while he surely should not go back to 40, it seems there's another +> > factor involved here that we've not recognized yet. +> +> I'd agree. Actually, the first thing I'd do, were it my machine, is reboot it +> and run memtest86 overnight. CPU thrashing like that may indicate bad RAM. +> +> If the RAM checks out, I'd like to see the EXPLAIN ANALYZE for some of the +> longest-running queries, and for those INSERTS. +> +> Also, is the new machine running Software RAID? +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +From pgsql-performance-owner@postgresql.org Tue Jun 29 05:14:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D07C0D1B241 + for ; + Tue, 29 Jun 2004 05:14: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 91103-07 + for ; + Tue, 29 Jun 2004 08:13:59 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BA89D1B252 + for ; + Tue, 29 Jun 2004 05:13:56 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i5T8D9Of020390; Tue, 29 Jun 2004 16:13:10 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <40E1266D.3040607@familyhealth.com.au> +Date: Tue, 29 Jun 2004 16:21:01 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Cheston +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/285 +X-Sequence-Number: 7343 + +> live=# explain analyze SELECT id FROM calllogs WHERE from = 'you'; +> QUERY PLAN +> ---------------------------------------------------------------------------------------------------------- +> Seq Scan on calllogs (cost=0.00..136.11 rows=24 width=4) (actual +> time=0.30..574.72 rows=143485 loops=1) +> Filter: (from = 'you'::character varying) +> Total runtime: 676.24 msec +> (3 rows) + +Have you got an index on calllogs(from)? + +Have you vacuumed and analyzed that table recently? + +Chris + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 05:37:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F495D1B248 + for ; + Tue, 29 Jun 2004 05:37: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 02566-07 + for ; + Tue, 29 Jun 2004 08:37:32 +0000 (GMT) +Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.240]) + by svr1.postgresql.org (Postfix) with SMTP id 6FC00D1B1D2 + for ; + Tue, 29 Jun 2004 05:37:29 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id w29so557412cwb + for ; + Tue, 29 Jun 2004 01:37:30 -0700 (PDT) +Received: by 10.38.104.46 with SMTP id b46mr51523rnc; + Tue, 29 Jun 2004 01:37:30 -0700 (PDT) +Message-ID: +Date: Tue, 29 Jun 2004 01:37:30 -0700 +From: Chris Cheston +To: Christopher Kings-Lynne +Subject: Re: postgres 7.4 at 100% +Cc: pgsql-performance@postgresql.org +In-Reply-To: <40E1266D.3040607@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + + <40E1266D.3040607@familyhealth.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/286 +X-Sequence-Number: 7344 + +ok i just vacuumed it and it's taking slightly longer now to execute +(only about 8 ms longer, to around 701 ms). + +Not using indexes for calllogs(from)... should I? The values for +calllogs(from) are not unique (sorry if I'm misunderstanding your +point). + +Thanks, + +Chris + +On Tue, 29 Jun 2004 16:21:01 +0800, Christopher Kings-Lynne + wrote: +> +> > live=# explain analyze SELECT id FROM calllogs WHERE from = 'you'; +> > QUERY PLAN +> > ---------------------------------------------------------------------------------------------------------- +> > Seq Scan on calllogs (cost=0.00..136.11 rows=24 width=4) (actual +> > time=0.30..574.72 rows=143485 loops=1) +> > Filter: (from = 'you'::character varying) +> > Total runtime: 676.24 msec +> > (3 rows) +> +> Have you got an index on calllogs(from)? +> +> Have you vacuumed and analyzed that table recently? +> +> Chris +> +> + +From pgsql-performance-owner@postgresql.org Tue Jun 29 05:38:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EEC9FD1B211 + for ; + Tue, 29 Jun 2004 05:37: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 02892-04 + for ; + Tue, 29 Jun 2004 08:37:53 +0000 (GMT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id CB929D1B258 + for ; + Tue, 29 Jun 2004 05:37:50 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BfE7j-000PTe-0U; Tue, 29 Jun 2004 09:37:51 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 09E5316C60; Tue, 29 Jun 2004 09:37:50 +0100 (BST) +Message-ID: <40E12A5D.70007@archonet.com> +Date: Tue, 29 Jun 2004 09:37:49 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance +References: <200406281702.i5SH2YfL013269@math.uchicago.edu> +In-Reply-To: <200406281702.i5SH2YfL013269@math.uchicago.edu> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/287 +X-Sequence-Number: 7345 + +Bill wrote: +> Ok....so here lies the output of oclh (i.e "\d oclh") +> +> Table "public.oclh" +> Column | Type | Modifiers +> --------+-----------------------+------------------------------- +> symbol | character varying(10) | not null default '' +> date | date | not null default '0001-01-01' +> open | numeric(12,2) | not null default '0.00' +> close | numeric(12,2) | not null default '0.00' +> low | numeric(12,2) | not null default '0.00' +> high | numeric(12,2) | not null default '0.00' +> Indexes: symbol_2_oclh_index btree (symbol, date), +> symbol_oclh_index btree (symbol, date) + +Well, I'm not sure why the two indexes on the same columns, and I'm not +sure it makes sense to have defaults for _any_ of the columns there. + +So - you want: +1. ratio = abs(closing-opening)/opening +2. average = all the ratios of each day of each stock +3. Highest average + +Well, I don't know what you mean by #2, but #1 is just: + +SELECT + symbol, + "date", + abs(close - open)/open AS ratio +FROM + oclh +GROUP BY + symbol, date; + +I'd probably fill in a summary table with this and use that as the basis +for your further queries. Presumably from "yesterday" back, the +ratios/averages won't change. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Jun 29 05:45:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96204D1B243 + for ; + Tue, 29 Jun 2004 05:45: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 07412-05 + for ; + Tue, 29 Jun 2004 08:45:39 +0000 (GMT) +Received: from pc7.berlin.powerweb.de (pc7.berlin.powerweb.de [62.67.228.13]) + by svr1.postgresql.org (Postfix) with ESMTP id C1A7ED1B232 + for ; + Tue, 29 Jun 2004 05:45:35 -0300 (ADT) +Received: from spock (p508409B6.dip0.t-ipconnect.de [80.132.9.182]) + by pc7.berlin.powerweb.de (8.9.3p3/8.9.3) with SMTP id KAA18793 + for ; Tue, 29 Jun 2004 10:45:36 +0200 +Message-ID: <00b801c45db5$914330e0$6602a8c0@spock> +From: "Harald Lau (Sector-X)" +To: +References: <007d01c45da4$3726dcd0$6602a8c0@spock> + <40E11BF0.3020109@familyhealth.com.au> +Subject: Re: no index-usage on aggregate-functions? +Date: Tue, 29 Jun 2004 10:46:27 +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.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/288 +X-Sequence-Number: 7346 + +@Chris: + +> > SELECT count(*) FROM the_table +> > =3D> Seq scan -> takes about 12 sec +> This cannot be made O(1) in postgres due to MVCC. You just have to live= +=20 +> with it. + +bad news +BTW: in this case you could workaround +select reltuples from pg_class where relname=3D'the_table' +(yes, I know: presumes a regular vacuum analyse) + +> Average and sum can never use an index AFAIK, in any db server. You=20 +> need information from every row. + +Take a look at the SQLSrv-pendant: +create index x_1 on the_table (num_found) +select avg(num_found) from the_table +-> Index Scan(OBJECT:([midata].[dbo].[THE_TABLE].[x_1]) + +(I'm not sure what Oracle does - have to re-install it first ...) + + +@Scott: +> Yes, you're expecting an MVCC database to behave like a row locking +> database. + +hmmmm... +So, it seems that PG is not soooo well suited for a datawarehouse and/or pe= +rforming extensive statistics/calculations/reportings on large tables, is i= +t? + +Greetings Harald + +From pgsql-performance-owner@postgresql.org Tue Jun 29 08:49:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65988D1B27A + for ; + Tue, 29 Jun 2004 08:49: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 04322-08 + for ; + Tue, 29 Jun 2004 11:49:57 +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 DE52FD1B23E + for ; + Tue, 29 Jun 2004 08:49:50 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 196FE88E9; Tue, 29 Jun 2004 13:49:52 +0200 (CEST) +Date: Tue, 29 Jun 2004 13:49:52 +0200 (CEST) +From: Dennis Bjorklund +To: "Harald Lau (Sector-X)" +Cc: pgsql-performance@postgresql.org +Subject: Re: no index-usage on aggregate-functions? +In-Reply-To: <00b801c45db5$914330e0$6602a8c0@spock> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/289 +X-Sequence-Number: 7347 + +On Tue, 29 Jun 2004, Harald Lau (Sector-X) wrote: + +> > Average and sum can never use an index AFAIK, in any db server. You +> > need information from every row. +> +> Take a look at the SQLSrv-pendant: +> create index x_1 on the_table (num_found) +> select avg(num_found) from the_table +> -> Index Scan(OBJECT:([midata].[dbo].[THE_TABLE].[x_1]) + +But is it really faster is the question? + +This sum needs all the values in that column. As far as I know it uses the +index because it uses less space on disk and thus is a little faster due +to less IO. In pg the index doesn't work like that, so in pg it's faster +to sum all values using the table itself. + +If you have a WHERE clause to only sum some values, then pg will use an +index (if applicable) and you will see a speedup. + +For min and max the situation is different, there an index can give you +the answer without scanning all rows. For that the workaround exist in pg. +The pg aggregate functions are very general and no one have special cased +min/max yet. Until that happen the work around works and is fast. + +> So, it seems that PG is not soooo well suited for a datawarehouse and/or +> performing extensive statistics/calculations/reportings on large tables, +> is it? + +I don't see how you can say that from your example. Just because it uses +an index for the sum above does not mean that it is a lot faster. It still +have to do as many additions as pg has to do. + +Sure, mvcc is best when you have both read and writes. But it should still +be comparable in speed even if you only do reads. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 09:30:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 597EAD1B1DC + for ; + Tue, 29 Jun 2004 09: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 28263-01 + for ; + Tue, 29 Jun 2004 12:30:49 +0000 (GMT) +Received: from mx.mall.cz (mx.mall.cz [81.30.232.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 05C47D1B1C8 + for ; + Tue, 29 Jun 2004 09:30:44 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mx.mall.cz (Postfix) with ESMTP + id C8B214811E; Tue, 29 Jun 2004 14:30:45 +0200 (CEST) +Received: from mx.mall.cz ([127.0.0.1]) + by localhost (posta [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 03283-08; Tue, 29 Jun 2004 14:30:31 +0200 (CEST) +Message-ID: <40E160E6.4080105@taborsky.cz> +Date: Tue, 29 Jun 2004 14:30:30 +0200 +From: =?ISO-8859-2?Q?Michal_T=E1borsk=FD?= +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Slow INSERT +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/290 +X-Sequence-Number: 7348 + +I am experiencing rather slow INSERTs on loaded server. The table I am +inserting to is: + +CREATE TABLE pagestats +( + page_id int4 NOT NULL, + viewed timestamptz DEFAULT now(), + session int4 NOT NULL +) WITH OIDS; + +The table is populated with 700k rows. It is VACUUM ANALYZED every +night, though it is only INSERTED to and SELECTED from, no UPDATES or +DELETES. There are no indices, triggers or constraints attached to it. +There are about 5 inserts pre second (sometimes more, but 10/s max). + +The INSERT is: +INSERT INTO pagestats (page_id,session) VALUES (5701,1147421823) + +Sometimes, it takes as long as 1300ms! Other queries are quite swift, +even compplex SELECTS and most of the INSERTS run fast. But occasionally +(every 50th or 100th INSERT) it takes forever (and stalls the webpage +from loading). The only special thing about this table is, it does not +have a PRIMARY KEY, but I should think that this constraint would only +slow it down even more. + +Any ideas what can be wrong? + +-- +Michal Taborsky +http://www.taborsky.cz + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 10:22:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 56C8CD1B248 + for ; + Tue, 29 Jun 2004 10:21: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 56167-01 + for ; + Tue, 29 Jun 2004 13:21:40 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 88E88D1B252 + for ; + Tue, 29 Jun 2004 10:21:35 -0300 (ADT) +Received: (qmail 28122 invoked by uid 500); 29 Jun 2004 13:28:13 -0000 +Date: Tue, 29 Jun 2004 08:28:13 -0500 +From: Bruno Wolff III +To: Chris Cheston +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +Message-ID: <20040629132813.GA28041@wolff.to> +Mail-Followup-To: Chris Cheston , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + + <40E1266D.3040607@familyhealth.com.au> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/291 +X-Sequence-Number: 7349 + +On Tue, Jun 29, 2004 at 01:37:30 -0700, + Chris Cheston wrote: +> ok i just vacuumed it and it's taking slightly longer now to execute +> (only about 8 ms longer, to around 701 ms). +> +> Not using indexes for calllogs(from)... should I? The values for +> calllogs(from) are not unique (sorry if I'm misunderstanding your +> point). + +If you are hoping for some other plan than a sequential scan through +all of the records you are going to need an index. You can have an +index on a column (or function) that isn't unique for all rows. + +From pgsql-performance-owner@postgresql.org Tue Jun 29 10:37:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C563D1B1B4 + for ; + Tue, 29 Jun 2004 10:37: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 63003-08 + for ; + Tue, 29 Jun 2004 13:37:32 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 9EB14D1B1AA + for ; + Tue, 29 Jun 2004 10:37:28 -0300 (ADT) +Received: (qmail 28310 invoked by uid 500); 29 Jun 2004 13:44:06 -0000 +Date: Tue, 29 Jun 2004 08:44:06 -0500 +From: Bruno Wolff III +To: "Harald Lau (Sector-X)" +Cc: pgsql-performance@postgresql.org +Subject: Re: no index-usage on aggregate-functions? +Message-ID: <20040629134406.GC28041@wolff.to> +Mail-Followup-To: "Harald Lau (Sector-X)" , + pgsql-performance@postgresql.org +References: <007d01c45da4$3726dcd0$6602a8c0@spock> + <40E11BF0.3020109@familyhealth.com.au> + <00b801c45db5$914330e0$6602a8c0@spock> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <00b801c45db5$914330e0$6602a8c0@spock> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/292 +X-Sequence-Number: 7350 + +On Tue, Jun 29, 2004 at 10:46:27 +0200, + "Harald Lau (Sector-X)" wrote: +> +> hmmmm... +> So, it seems that PG is not soooo well suited for a datawarehouse and/or performing extensive statistics/calculations/reportings on large tables, is it? + +If you are doing lots of selects of aggregates relative to the number of +updates, you can cache the values of interest in derived tables and use +triggers to keep those tables up to date. + +From pgsql-performance-owner@postgresql.org Tue Jun 29 10:52:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2828BD1B1D0 + for ; + Tue, 29 Jun 2004 10: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 69865-06 + for ; + Tue, 29 Jun 2004 13:50:35 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id BE44CD1B1CD + for ; + Tue, 29 Jun 2004 10:50:31 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5TDoXce028631; + Tue, 29 Jun 2004 09:50:33 -0400 (EDT) +To: Chris Cheston +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +In-reply-to: +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + +Comments: In-reply-to Chris Cheston + message dated "Tue, 29 Jun 2004 01:00:10 -0700" +Date: Tue, 29 Jun 2004 09:50:32 -0400 +Message-ID: <28630.1088517032@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/293 +X-Sequence-Number: 7351 + +Chris Cheston writes: +> Wow, this simple query is taking 676.24 ms to execute! it only takes +> 18 ms on our other machine. + +> This table has 150,000 rows. Is this normal? + +> live=# explain analyze SELECT id FROM calllogs WHERE from = 'you'; +> QUERY PLAN +> ---------------------------------------------------------------------------------------------------------- +> Seq Scan on calllogs (cost=0.00..136.11 rows=24 width=4) (actual +> time=0.30..574.72 rows=143485 loops=1) +> Filter: (from = 'you'::character varying) +> Total runtime: 676.24 msec +> (3 rows) + +So the query is pulling 140K+ rows out of a table with 150K entries? +No chance that an index will help for that. You're fortunate that the +thing did not try to use an index though, because it thinks there are +only 24 rows matching 'you', which is one of the more spectacular +statistical failures I've seen lately. I take it you haven't ANALYZEd +this table in a long time? + +It is hard to believe that your other machine can pull 140K+ rows in +18 msec, though. Are you sure the table contents are the same in both +cases? + +If they are, the only reason I can think of for the discrepancy is a +large amount of dead space in this copy of the table. What does VACUUM +VERBOSE show for it, and how does that compare to what you see on the +other machine? Try a CLUSTER or VACUUM FULL to see if you can shrink +the table's physical size (number of pages). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 29 11:33:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BEECCD1B1B4 + for ; + Tue, 29 Jun 2004 11:30: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 97404-04 + for ; + Tue, 29 Jun 2004 14:30: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 30A92D1B199 + for ; + Tue, 29 Jun 2004 11:30:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5TEUk72029096; + Tue, 29 Jun 2004 10:30:46 -0400 (EDT) +To: =?ISO-8859-2?Q?Michal_T=E1borsk=FD?= +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow INSERT +In-reply-to: <40E160E6.4080105@taborsky.cz> +References: <40E160E6.4080105@taborsky.cz> +Comments: In-reply-to =?ISO-8859-2?Q?Michal_T=E1borsk=FD?= + + message dated "Tue, 29 Jun 2004 14:30:30 +0200" +Date: Tue, 29 Jun 2004 10:30:46 -0400 +Message-ID: <29095.1088519446@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/294 +X-Sequence-Number: 7352 + +=?ISO-8859-2?Q?Michal_T=E1borsk=FD?= writes: +> I am experiencing rather slow INSERTs on loaded server. +> ... There are no indices, triggers or constraints attached to it. + +It's hard to see how inserting to such a simple table would be slow. + +> Sometimes, it takes as long as 1300ms! Other queries are quite swift, +> even compplex SELECTS and most of the INSERTS run fast. But occasionally +> (every 50th or 100th INSERT) it takes forever (and stalls the webpage +> from loading). + +Is the number of inserts between slowdowns perfectly repeatable? My +first thought is that the fast case is associated with inserting onto a +page that is the same one last inserted to, and the slow case is +associated with finding a new page to insert onto (which, given that you +never UPDATE or DELETE, will always mean extending the file). Given +that the table rows are fixed width, the number of rows that fit on a +page should be constant, so this theory cannot be right if the number of +inserts between slowdowns varies. + +Also, are all the inserts being issued by the same server process, or +are they scattered across multiple processes? I'm not sure this theory +holds water unless all the inserts are done in the same process. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 29 12:18:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D44AFD1B297 + for ; + Tue, 29 Jun 2004 12:09: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 18772-09 + for ; + Tue, 29 Jun 2004 15:09:49 +0000 (GMT) +Received: from mx.mall.cz (mx.mall.cz [81.30.232.20]) + by svr1.postgresql.org (Postfix) with ESMTP id D462AD1B266 + for ; + Tue, 29 Jun 2004 12:09:47 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mx.mall.cz (Postfix) with ESMTP + id 6119B48477; Tue, 29 Jun 2004 17:09:45 +0200 (CEST) +Received: from mx.mall.cz ([127.0.0.1]) + by localhost (posta [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 06400-03; Tue, 29 Jun 2004 17:09:40 +0200 (CEST) +Message-ID: <40E1863B.9070208@taborsky.cz> +Date: Tue, 29 Jun 2004 17:09:47 +0200 +From: Michal Taborsky +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow INSERT +References: <40E160E6.4080105@taborsky.cz> <29095.1088519446@sss.pgh.pa.us> +In-Reply-To: <29095.1088519446@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/295 +X-Sequence-Number: 7353 + +Tom Lane wrote: +> It's hard to see how inserting to such a simple table would be slow. + +Indeed. + +> Is the number of inserts between slowdowns perfectly repeatable? My +> first thought is that the fast case is associated with inserting onto a +> page that is the same one last inserted to, and the slow case is +> associated with finding a new page to insert onto (which, given that you +> never UPDATE or DELETE, will always mean extending the file). Given +> that the table rows are fixed width, the number of rows that fit on a +> page should be constant, so this theory cannot be right if the number of +> inserts between slowdowns varies. + +I ran some tests to support this hypothesis. Every 500th insert is a tad +slower, but it is insignificant (normally the INSERT lasts 1.5ms, every +500th is 9ms). During my tests (10 runs of 1000 INSERTS) I had +experienced only one "slow" insert (2000ms). It is clearly caused by +other processes running on this server, but such degradation of +performance is highly suspicious, because the server very rarely goes +over load 1.0. Just for the record, it is FreeBSD 4.9 and the system +never swaps. + +> Also, are all the inserts being issued by the same server process, or +> are they scattered across multiple processes? I'm not sure this theory +> holds water unless all the inserts are done in the same process. + +Nope. It is a webserver, so these requests are pushed through several +persistent connections (20-30, depends on current load). This insert +occurs only once per pageload. + +-- +Michal Taborsky +http://www.taborsky.cz + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 13:12:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EA00CD1B18A + for ; + Tue, 29 Jun 2004 12:22: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 31532-04 + for ; + Tue, 29 Jun 2004 15:22:50 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id ED90DD1B182 + for ; + Tue, 29 Jun 2004 12:22:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5TFMmg9029836; + Tue, 29 Jun 2004 11:22:49 -0400 (EDT) +To: Michal Taborsky +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow INSERT +In-reply-to: <40E1863B.9070208@taborsky.cz> +References: <40E160E6.4080105@taborsky.cz> <29095.1088519446@sss.pgh.pa.us> + <40E1863B.9070208@taborsky.cz> +Comments: In-reply-to Michal Taborsky + message dated "Tue, 29 Jun 2004 17:09:47 +0200" +Date: Tue, 29 Jun 2004 11:22:48 -0400 +Message-ID: <29835.1088522568@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/303 +X-Sequence-Number: 7361 + +Michal Taborsky writes: +> I ran some tests to support this hypothesis. Every 500th insert is a tad +> slower, but it is insignificant (normally the INSERT lasts 1.5ms, every +> 500th is 9ms). During my tests (10 runs of 1000 INSERTS) I had +> experienced only one "slow" insert (2000ms). It is clearly caused by +> other processes running on this server, but such degradation of +> performance is highly suspicious, because the server very rarely goes +> over load 1.0. + +Actually, the simpler theory is that the slowdown is caused by +background checkpoint operations. Now a checkpoint would slow +*everything* down not only this one insert, so maybe that's not +the right answer either, but it's my next idea. You could check +this to some extent by manually issuing a CHECKPOINT command and +seeing if you get an insert hiccup. Note though that closely +spaced checkpoints will have less effect, because less I/O will +be triggered when not much has changed since the last one. So +you'd want to wait a bit between experiments. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 29 13:00:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 99072D1B1A5 + for ; + Tue, 29 Jun 2004 12:47: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 45343-08 + for ; + Tue, 29 Jun 2004 15:47:37 +0000 (GMT) +Received: from mx.mall.cz (mx.mall.cz [81.30.232.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D432D1B19F + for ; + Tue, 29 Jun 2004 12:47:35 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mx.mall.cz (Postfix) with ESMTP + id D3EDC4814A; Tue, 29 Jun 2004 17:47:34 +0200 (CEST) +Received: from mx.mall.cz ([127.0.0.1]) + by localhost (posta [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 06924-07; Tue, 29 Jun 2004 17:47:27 +0200 (CEST) +Message-ID: <40E18F14.4000600@taborsky.cz> +Date: Tue, 29 Jun 2004 17:47:32 +0200 +From: Michal Taborsky +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow INSERT +References: <40E160E6.4080105@taborsky.cz> <29095.1088519446@sss.pgh.pa.us> + <40E1863B.9070208@taborsky.cz> <29835.1088522568@sss.pgh.pa.us> +In-Reply-To: <29835.1088522568@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/300 +X-Sequence-Number: 7358 + +Tom Lane wrote: +> Actually, the simpler theory is that the slowdown is caused by +> background checkpoint operations. Now a checkpoint would slow +> *everything* down not only this one insert, so maybe that's not +> the right answer either, but it's my next idea. You could check +> this to some extent by manually issuing a CHECKPOINT command and +> seeing if you get an insert hiccup. Note though that closely +> spaced checkpoints will have less effect, because less I/O will +> be triggered when not much has changed since the last one. So +> you'd want to wait a bit between experiments. + +Aha! This is really the case. I've let the test run and issued manual +CHECKPOINT command. The command itself took about 3 secs and during that +time I had some slow INSERTS. So we know the reason. + +I've read the discussion in "Trying to minimize the impact of +checkpoints" thread and I get it, that there is nothing I can do about +it. Well, we'll have to live with that, at least until 7.5. + +Thanks of the help all the same. + +-- +Michal Taborsky +http://www.taborsky.cz + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 12:54:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A82ED1B1D2 + for ; + Tue, 29 Jun 2004 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 47355-06 + for ; + Tue, 29 Jun 2004 15:52:29 +0000 (GMT) +Received: from ludojad.itpp.pl (ludojad.itpp.pl [193.41.112.10]) + by svr1.postgresql.org (Postfix) with ESMTP id EAB63D1B18A + for ; + Tue, 29 Jun 2004 12:52:27 -0300 (ADT) +Received: by ludojad.itpp.pl (Postfix, from userid 1111) + id 8ADB4712EA; Tue, 29 Jun 2004 17:55:37 +0200 (CEST) +Date: Tue, 29 Jun 2004 17:55:37 +0200 +From: eleven@ludojad.itpp.pl +To: pgsql-performance@postgresql.org +Subject: High load average with PostgreSQL 7.4.2 on debian/ibm eserver. +Message-ID: <20040629155537.GA5465@ludojad.itpp.pl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200406/299 +X-Sequence-Number: 7357 + +Hello, + +I'm using PostgreSQL 7.4.2 (package from backports.org) +on a Debian (woody) box. The machine is IBM eServer 345 +with two 2.8 Xeon CPUs, it has 1024MB of RAM and +two 15k RPM SCSI disks running in hardware RAID1, which +is provided by the onboard LSI Logic controller (LSI53C1030). + +The database consists of two rather large tables +(currently about 15 million rows in one table +and about 5 million in the other one). Both tables +have 5 indexes (4 btree/1 hash). +Application running on the server INSERTs a lot of +stuff to the tables (which is not the target use of +the DB, it'll add data periodically, about +300 rows per 10 minutes). Queries (SELECTs) run perfectly +fine on the database, thanks to the indexes we have +here probably. + +Performance issue, I'm experiencing here, is somewhat +weird - server gets high average load (from 5 up to 15, +8 on average). Standard performance monitoring +utilities (like top) show that CPUs are not loaded +(below 20%, often near zero). +With kernel 2.6.x which I was using earlier, +top showed very high "wa" values (which indicate I/O waiting, AFAIK). +I've googled some issues with 2.6 kernels and LSI Logic controllers +running RAID, so I've downgraded the kernel to 2.4.26. +The machine started to behave a bit better, but still high +load states look weird. Unfortunately, top with 2.4 kernels +does not show "wa" column, so I can't be sure if the load is +caused by waiting for disks, but high idle values and high average +load would suggest it. With kernel 2.6 swap was almost always 100% free, +with 2.4.26 Linux eats below 5 megabytes of swapspace. +PostgreSQL is running with shared_mem set to 48000, +sort_mem = 4096, fsync off. + +Whole config is available here: +http://ludojad.itpp.pl/~eleven/pg-high-load.conf + +I've also made some iostat report (using iostat 3 1000 as +suggested in one of the posts): +http://ludojad.itpp.pl/~eleven/iostat.log + +Any solutions I should consider? +I'd be grateful getting some hints on this. + +-- +11. + +From pgsql-performance-owner@postgresql.org Tue Jun 29 13:03:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8388FD1B18F + for ; + Tue, 29 Jun 2004 13:03: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 58336-01 + for ; + Tue, 29 Jun 2004 16:03: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 CB3D4D1B1D2 + for ; + Tue, 29 Jun 2004 13:02:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5TG2vFf001473; + Tue, 29 Jun 2004 12:02:58 -0400 (EDT) +To: Michal Taborsky +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow INSERT +In-reply-to: <40E18F14.4000600@taborsky.cz> +References: <40E160E6.4080105@taborsky.cz> <29095.1088519446@sss.pgh.pa.us> + <40E1863B.9070208@taborsky.cz> <29835.1088522568@sss.pgh.pa.us> + <40E18F14.4000600@taborsky.cz> +Comments: In-reply-to Michal Taborsky + message dated "Tue, 29 Jun 2004 17:47:32 +0200" +Date: Tue, 29 Jun 2004 12:02:57 -0400 +Message-ID: <1472.1088524977@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/301 +X-Sequence-Number: 7359 + +Michal Taborsky writes: +> I've read the discussion in "Trying to minimize the impact of +> checkpoints" thread and I get it, that there is nothing I can do about +> it. Well, we'll have to live with that, at least until 7.5. + +You could experiment with the checkpoint interval (checkpoint_timeout). +A shorter interval will mean more total I/O (the same page will get +written out more often) but it should reduce the amount of I/O done by +any one checkpoint. You might find that the extra overhead is worth it +to reduce the spikes. + +But 7.5 should provide a much better answer, yes. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Jun 29 13:08:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 08833D1B23E + for ; + Tue, 29 Jun 2004 13: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 56288-07 + for ; + Tue, 29 Jun 2004 16:03:55 +0000 (GMT) +Received: from tetra.ehpg.net (tetra.ehpg.net [216.218.206.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 564EED1B1EC + for ; + Tue, 29 Jun 2004 13:03:54 -0300 (ADT) +Received: from adsl-67-122-136-119.dsl.irvnca.pacbell.net ([172.16.1.35]) + [67.122.136.119]by tetra.ehpg.netwith asmtp(Exim 4.34 #1 + (Gentoo Linux 1.4))id 1BfL6H-000245-PT; + Tue, 29 Jun 2004 09:04:50 -0700 +Message-ID: <40E192CC.90707@ehpg.net> +Date: Tue, 29 Jun 2004 09:03:24 -0700 +From: "Gavin M. Roy" +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Cheston +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + + <40E1266D.3040607@familyhealth.com.au> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Antivirus-Scanned: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/302 +X-Sequence-Number: 7360 + +Is the from field nullable? If not, try "create index calllogs_from on +calllogs ( from );" and then do an explain analyze of your query. + +Gavin + + +Chris Cheston wrote: + +>ok i just vacuumed it and it's taking slightly longer now to execute +>(only about 8 ms longer, to around 701 ms). +> +>Not using indexes for calllogs(from)... should I? The values for +>calllogs(from) are not unique (sorry if I'm misunderstanding your +>point). +> +>Thanks, +> +>Chris +> +>On Tue, 29 Jun 2004 16:21:01 +0800, Christopher Kings-Lynne +> wrote: +> +> +>>>live=# explain analyze SELECT id FROM calllogs WHERE from = 'you'; +>>> QUERY PLAN +>>>---------------------------------------------------------------------------------------------------------- +>>> Seq Scan on calllogs (cost=0.00..136.11 rows=24 width=4) (actual +>>>time=0.30..574.72 rows=143485 loops=1) +>>> Filter: (from = 'you'::character varying) +>>> Total runtime: 676.24 msec +>>>(3 rows) +>>> +>>> +>>Have you got an index on calllogs(from)? +>> +>>Have you vacuumed and analyzed that table recently? +>> +>>Chris +>> +>> +>> +>> +> +>---------------------------(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 Jun 29 13:19:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 39F87D1B241 + for ; + Tue, 29 Jun 2004 13:17: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 64612-08 + for ; + Tue, 29 Jun 2004 16:17:44 +0000 (GMT) +Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.242]) + by svr1.postgresql.org (Postfix) with SMTP id CEE2CD1B187 + for ; + Tue, 29 Jun 2004 13:17:42 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id u22so421691cwc + for ; + Tue, 29 Jun 2004 09:17:36 -0700 (PDT) +Received: by 10.38.181.22 with SMTP id d22mr43514rnf; + Tue, 29 Jun 2004 09:17:36 -0700 (PDT) +Message-ID: <9662496504062909172bf8034b@mail.gmail.com> +Date: Tue, 29 Jun 2004 09:17:36 -0700 +From: Marc +To: "eleven@ludojad.itpp.pl" +Subject: Re: High load average with PostgreSQL 7.4.2 on debian/ibm eserver. +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20040629155537.GA5465@ludojad.itpp.pl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <20040629155537.GA5465@ludojad.itpp.pl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200406/304 +X-Sequence-Number: 7362 + +On Tue, 29 Jun 2004 17:55:37 +0200, eleven@ludojad.itpp.pl + wrote: + +> Performance issue, I'm experiencing here, is somewhat +> weird - server gets high average load (from 5 up to 15, +> 8 on average). Standard performance monitoring +> utilities (like top) show that CPUs are not loaded +> (below 20%, often near zero). + +So ... you never actually say what the performance issue you +experience is. Having a high load average is not necessarily a +performance issue. + +What is it that you want to fix? + +From pgsql-performance-owner@postgresql.org Tue Jun 29 13:59:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 15CC1D1B241 + for ; + Tue, 29 Jun 2004 13: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 69323-05 + for ; + Tue, 29 Jun 2004 16:22:48 +0000 (GMT) +Received: from snowwhite.lulu.com (stymie.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id F41DED1B196 + for ; + Tue, 29 Jun 2004 13:22:45 -0300 (ADT) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) (authenticated) + by snowwhite.lulu.com (8.11.6/8.11.6) with ESMTP id i5TGNB715143; + Tue, 29 Jun 2004 12:23:11 -0400 +Message-ID: <40E19752.7040509@lulu.com> +Date: Tue, 29 Jun 2004 12:22:42 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: eleven@ludojad.itpp.pl +Subject: Re: High load average with PostgreSQL 7.4.2 on debian/ibm +References: <20040629155537.GA5465@ludojad.itpp.pl> +In-Reply-To: <20040629155537.GA5465@ludojad.itpp.pl> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/305 +X-Sequence-Number: 7363 + +eleven@ludojad.itpp.pl wrote: + +> <>I'm using PostgreSQL 7.4.2 (package from backports.org) +> on a Debian (woody) box. The machine is IBM eServer 345 +> with two 2.8 Xeon CPUs, it has 1024MB of RAM and +> two 15k RPM SCSI disks running in hardware RAID1, which +> is provided by the onboard LSI Logic controller (LSI53C1030). + + + +> <>With kernel 2.6.x which I was using earlier, +> top showed very high "wa" values (which indicate I/O waiting, AFAIK) + + +It sounds like you are very much bound by disk I/O. Your iostat output +indicates a good amount of I/O going on--I bet an iostat -x /dev/sdX +would show very high await times (time in ms before an IO request to the +device is serviced). + +If your RAID controller has a battery-backed cache, check that you have +write-back (as opposed to write-through) enabled. This will cause the +controller to report data written only to RAID cache and not yet flushed +to disk as sync'd. You can experience large gains in write performance +this way. + +If write-back is already enabled, or enabling it does not give a large +enough performance boost, you may need to buy more disks. In general, if +you have the budget for lots of disks, RAID 10 is the best you can do +performance-wise; if your budget for disks is limited, RAID 5 is the +next best thing. Also, you will get more bang for your buck with a +larger number of 10k disks than a smaller number of 15k disks. + +Good luck, + +Bill Montgomery + +From pgsql-performance-owner@postgresql.org Tue Jun 29 14:42:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 59865D1B1EC + for ; + Tue, 29 Jun 2004 13: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 87355-04 + for ; + Tue, 29 Jun 2004 16:51:49 +0000 (GMT) +Received: from mail.zeomega.com (unknown [203.195.223.18]) + by svr1.postgresql.org (Postfix) with ESMTP id CDFC1D1B1AA + for ; + Tue, 29 Jun 2004 13:51:48 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.zeomega.com (Postfix) with ESMTP id 4F21610CC3 + for ; + Tue, 29 Jun 2004 22:25:02 +0530 (IST) +Received: from mail.zeomega.com ([127.0.0.1]) + by localhost (mail.zeomega.org [127.0.0.1]) (amavisd-new, port 10024) + with SMTP id 31949-09 for ; + Tue, 29 Jun 2004 22:24:59 +0530 (IST) +Received: from mail.zeomega.com (localhost.localdomain [127.0.0.1]) + by mail.zeomega.com (Postfix) with SMTP id 456C010468 + for ; + Tue, 29 Jun 2004 22:24:59 +0530 (IST) +Received: from 202.142.94.6 (SquirrelMail authenticated user mohana) + by mail.zeomega.com with HTTP; Tue, 29 Jun 2004 22:24:59 +0530 (IST) +Message-ID: <3439.202.142.94.6.1088528099.squirrel@mail.zeomega.com> +Date: Tue, 29 Jun 2004 22:24:59 +0530 (IST) +Subject: suggestions to improve performace +From: "Mohan A" +To: pgsql-performance@postgresql.org +Reply-To: mohana@zeomega.com +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +X-Priority: 3 +Importance: Normal +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at zeomega.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200406/308 +X-Sequence-Number: 7366 + +Hello All, + + We are building a web based application which is database +intensive (we intend to use postgresql). Expect about 600 +concurrent users. We are using Zope and python with postgresql on +RedHat Enterprise Linux. Our server has dual intel xeon 2.4 GHz +and 2 Gig Ram with lots of disk space with hardware raid. + + I would appreciate all help to get the best possible performance +from postgresql, we will be using a lot of views and a lot of +pl/pgsql procedures. + + I am looking at good rules to use for memory, WAL, SQL Transaction +Isolation Levels and cache configuration along with anything else +that I have missed. + + +Thank you in advance for all your help, + +Mohan A. + +From pgsql-performance-owner@postgresql.org Tue Jun 29 14:24:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A65ED1B1B6 + for ; + Tue, 29 Jun 2004 14:21: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 05278-01 + for ; + Tue, 29 Jun 2004 17:21:07 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id CDD38D1B198 + for ; + Tue, 29 Jun 2004 14:21:03 -0300 (ADT) +Received: (qmail 58323 invoked by uid 0); 29 Jun 2004 17:21:04 -0000 +Received: from unknown (63.231.195.15) + by mpls-qmqp-01.inet.qwest.net with QMQP; 29 Jun 2004 17:21:04 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-15.inet.qwest.net with SMTP; 29 Jun 2004 17:21:03 -0000 +Date: Tue, 29 Jun 2004 11:21:58 -0600 +Message-Id: <1088529718.12350.35.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Harald Lau (Sector-X)" +Cc: pgsql-performance@postgresql.org +Subject: Re: no index-usage on aggregate-functions? +In-Reply-To: <00b801c45db5$914330e0$6602a8c0@spock> +References: <007d01c45da4$3726dcd0$6602a8c0@spock> + <40E11BF0.3020109@familyhealth.com.au> + <00b801c45db5$914330e0$6602a8c0@spock> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/306 +X-Sequence-Number: 7364 + +On Tue, 2004-06-29 at 02:46, Harald Lau (Sector-X) wrote: +> @Chris: +> +> > > SELECT count(*) FROM the_table +> > > => Seq scan -> takes about 12 sec +> > This cannot be made O(1) in postgres due to MVCC. You just have to live +> > with it. +> +> bad news +> BTW: in this case you could workaround +> select reltuples from pg_class where relname='the_table' +> (yes, I know: presumes a regular vacuum analyse) + +Note that there ARE other options. While the inability to provide a +speedy count is a "cost" of using an MVCC system, the ability to allow +thousands of readers to run while updates are happening underneath them +more than makes up for the slower aggregate performance. + +The other options to this problem involve maintaining another table that +has a single (visible) row that is maintained by a trigger on the main +table that fires and updates that single row to reflect the count of the +table. This is costly on updates, but may be worth doing for certain +situations. Personally, I haven't had a great need to do a count(*) on +my tables that much. And on large tables, approximations are usually +fine. + +> > Average and sum can never use an index AFAIK, in any db server. You +> > need information from every row. +> +> Take a look at the SQLSrv-pendant: +> create index x_1 on the_table (num_found) +> select avg(num_found) from the_table +> -> Index Scan(OBJECT:([midata].[dbo].[THE_TABLE].[x_1]) +> +> (I'm not sure what Oracle does - have to re-install it first ...) + +There's a good chance Oracle can use the index too. That's because both +Oracle is still a row locked database at heart. It's MVCC system sits +on top of it in roll back segments. So, the main store is serialized +and can be indexed, while the updates live in the rollback segment. + +This, however, is not paradise. This limits Oracle's performance for +things like long running transactions and makes it slower as the amount +of information in the rollback segment grows. Meanwhile, PostgreSQL +uses an in store MVCC mechanism. This system means that all index +accesses must then hit the actual MVCC storage, since indexes aren't +easily serialized. + +> @Scott: +> > Yes, you're expecting an MVCC database to behave like a row locking +> > database. +> +> hmmmm... +> So, it seems that PG is not soooo well suited for a datawarehouse and/or performing extensive statistics/calculations/reportings on large tables, is it? + +On the contrary, it makes it GREAT for datawarehousing. Not because any +one child process will be super fast, but because ALL the child +processes will run reasonably fast, even under very heavy read and write +load. Note that if you've got the memory for the hash agg algo to fire +into shared memory, it's pretty darned fast now, so if the data (mostly) +fit into kernel cache you're gold. And 12 gig Intel boxes aren't that +expensive, compared to an Oracle license. + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 14:32:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 14F8ED1B1CD + for ; + Tue, 29 Jun 2004 14:30: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 07676-07 + for ; + Tue, 29 Jun 2004 17:30:40 +0000 (GMT) +Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id 61689D1B17B + for ; + Tue, 29 Jun 2004 14:30:35 -0300 (ADT) +Received: from [127.0.0.1] (helo=localhost) + by stan.aopsys.com with esmtp (Exim 4.30) id 1BfMRB-0003MY-H9 + for pgsql-performance@postgresql.org; Tue, 29 Jun 2004 19:30:29 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: =?iso-8859-1?q?Vid=E9oProj?= -> RMLL +References: <20040628081459.GA1774@lhullier.org> + <200406290159.49669.laurent@parinux.org> +From: Laurent Martelli +Organization: Parinux +Date: Tue, 29 Jun 2004 19:30:29 +0200 +In-Reply-To: <200406290159.49669.laurent@parinux.org> (Laurent Rathle's + message of "Tue, 29 Jun 2004 01:59:49 +0200") +Message-ID: <87lli66zm2.fsf@stan.aopsys.com> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/307 +X-Sequence-Number: 7365 + +>>>>> "Laurent" == Laurent Rathle writes: + + Laurent> Le lundi 28 Juin 2004 10:14, Sylvain Lhullier a �crit�: + >> � �Pour info, le vid�o-proj de Parinux devrait rejoindre les RMLL + >> (sauf opposition du CA). + >> + >> � �Nous sommes en train de trouver un moyen de l'y apporter + >> (sachant que je d�tiens ce pr�cieux vid�o-proj et que je ne vais + >> pas aux RMLL). + + Laurent> Je n'y vois pas d'opposition, sauf qu� mon avis, il ne sera + Laurent> pas assur�. Il a �t� achet� d'occasion sans facture et je + Laurent> vois mal une assurance accepter de rembourser un appareil + Laurent> sans cet �l�ment. + +De m�moire, le gars nous avait fil� la facture lorsqu'il nous l'a vendu. + + + +-- +Laurent Martelli vice-pr�sident de Parinux +http://www.bearteam.org/~laurent/ http://www.parinux.org/ +laurent@bearteam.org + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 15:31:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64188D1B1B4 + for ; + Tue, 29 Jun 2004 14: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 09655-04 + for ; + Tue, 29 Jun 2004 17:33:48 +0000 (GMT) +Received: from math.uchicago.edu (math.uchicago.edu [128.135.72.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 33A6DD1B1AA + for ; + Tue, 29 Jun 2004 14:33:46 -0300 (ADT) +Received: from billnotebook (wireless-197-223.uchicago.edu [128.135.197.223]) + by math.uchicago.edu (8.12.10/8.12.10) with ESMTP id i5THXkfL031311 + for ; + Tue, 29 Jun 2004 12:33:46 -0500 +Message-Id: <200406291733.i5THXkfL031311@math.uchicago.edu> +From: "Bill" +To: +Subject: Re: Query performance +Date: Tue, 29 Jun 2004 12:33:51 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +In-Reply-To: <40E12A5D.70007@archonet.com> +Thread-Index: AcRdtTtifCTAR38tQAerxJIonFzvKQASJpwg +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/311 +X-Sequence-Number: 7369 + +Ok, thanks. So let me explain the query number 2 as this is the more +difficult to write. So I have a list of stocks, this table contains the +price of all of the stocks at the open and close date. Ok, now we have a +ratio from query (1) that returns at least a very rough index of the daily +performance of a given stock, with each ratio representing the stock's +performance in one day. Now we need to average this with the same stock's +ratio every day, to get a total average for each stock contained in the +database. Now I would simply like to find a ratio like this that represents +the average of every stock in the table and simply find the greatest ratio. +Sorry about the lousy explanation before, is this a bit better? + +Here is an example if needed. + +Say we have a stock by the name of YYY + +I know, due to query 1 that stock YYY has a abs(close-open)/open price ratio +of for example, 1.3 on Dec 1 and (for simplicity let's say we only have two +dates) and Dec 2 the ratio for YYY is 1.5. So the query averages and gets +1.4. Now it needs to do this for all of the stocks in the table and sort by +increasing ratio. + + +Thanks. + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Richard Huxton +Sent: Tuesday, June 29, 2004 3:38 AM +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Query performance + +Bill wrote: +> Ok....so here lies the output of oclh (i.e "\d oclh") +> +> Table "public.oclh" +> Column | Type | Modifiers +> --------+-----------------------+------------------------------- +> symbol | character varying(10) | not null default '' +> date | date | not null default '0001-01-01' +> open | numeric(12,2) | not null default '0.00' +> close | numeric(12,2) | not null default '0.00' +> low | numeric(12,2) | not null default '0.00' +> high | numeric(12,2) | not null default '0.00' +> Indexes: symbol_2_oclh_index btree (symbol, date), +> symbol_oclh_index btree (symbol, date) + +Well, I'm not sure why the two indexes on the same columns, and I'm not +sure it makes sense to have defaults for _any_ of the columns there. + +So - you want: +1. ratio = abs(closing-opening)/opening +2. average = all the ratios of each day of each stock +3. Highest average + +Well, I don't know what you mean by #2, but #1 is just: + +SELECT + symbol, + "date", + abs(close - open)/open AS ratio +FROM + oclh +GROUP BY + symbol, date; + +I'd probably fill in a summary table with this and use that as the basis +for your further queries. Presumably from "yesterday" back, the +ratios/averages won't change. + +-- + Richard Huxton + Archonet Ltd + +---------------------------(end of broadcast)--------------------------- +TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 14:53:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 28A11D1B298 + for ; + Tue, 29 Jun 2004 14: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 18174-05 + for ; + Tue, 29 Jun 2004 17:49:18 +0000 (GMT) +Received: from ludojad.itpp.pl (ludojad.itpp.pl [193.41.112.10]) + by svr1.postgresql.org (Postfix) with ESMTP id E32ADD1B258 + for ; + Tue, 29 Jun 2004 14:49:15 -0300 (ADT) +Received: by ludojad.itpp.pl (Postfix, from userid 1111) + id E8DBC712EA; Tue, 29 Jun 2004 19:52:27 +0200 (CEST) +Date: Tue, 29 Jun 2004 19:52:27 +0200 +From: eleven@ludojad.itpp.pl +To: pgsql-performance@postgresql.org +Subject: Re: High load average with PostgreSQL 7.4.2 on debian/ibm eserver. +Message-ID: <20040629175227.GA11658@ludojad.itpp.pl> +References: <20040629155537.GA5465@ludojad.itpp.pl> + <9662496504062909172bf8034b@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +In-Reply-To: <9662496504062909172bf8034b@mail.gmail.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200406/309 +X-Sequence-Number: 7367 + +On Tue, Jun 29, 2004 at 09:17:36AM -0700, Marc wrote: + +> > Performance issue, I'm experiencing here, is somewhat +> > weird - server gets high average load (from 5 up to 15, +> > 8 on average). Standard performance monitoring +> > utilities (like top) show that CPUs are not loaded +> > (below 20%, often near zero). +> So ... you never actually say what the performance issue you +> experience is. Having a high load average is not necessarily a +> performance issue. + +Well, if the server's CPUs are idle and the machine +is starting to hog itself, one can +suspect something bad going on. + +> What is it that you want to fix? + +Basically, I'm wondering if I'm already on the edge of +performance capabilities of this machine/configuration, or maybe +there's some abnormal behaviour happening (which +could be noticed by somebody from this mailing list, hopefully). + +In particular - could someone tell me if those iostat +values can tell if I'm close to upper performance boundary +of fast SCSI (Ultra 320, 15k RPM) disks? + +-- +11. + +From pgsql-performance-owner@postgresql.org Tue Jun 29 15:22:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4189CD1B1AA + for ; + Tue, 29 Jun 2004 15:15: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 31014-06 + for ; + Tue, 29 Jun 2004 18:15:44 +0000 (GMT) +Received: from pc7.berlin.powerweb.de (pc7.berlin.powerweb.de [62.67.228.13]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D723D1B17B + for ; + Tue, 29 Jun 2004 15:15:42 -0300 (ADT) +Received: from spock (p508409B6.dip0.t-ipconnect.de [80.132.9.182]) + by pc7.berlin.powerweb.de (8.9.3p3/8.9.3) with SMTP id UAA04409; + Tue, 29 Jun 2004 20:15:38 +0200 +Message-ID: <004e01c45e05$3401b0f0$6602a8c0@spock> +From: "Harald Lau (Sector-X)" +To: "Scott Marlowe" +Cc: +References: <007d01c45da4$3726dcd0$6602a8c0@spock> + <40E11BF0.3020109@familyhealth.com.au> + <00b801c45db5$914330e0$6602a8c0@spock> + <1088529718.12350.35.camel@localhost.localdomain> +Subject: Re: no index-usage on aggregate-functions? +Date: Tue, 29 Jun 2004 20:16:30 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/310 +X-Sequence-Number: 7368 + +> Note that there ARE other options. While the inability to provide a +> speedy count is a "cost" of using an MVCC system, the ability to allow +> thousands of readers to run while updates are happening underneath them +> more than makes up for the slower aggregate performance. + +IMO this depends on the priority of your application resp. the customers in= +tentions and wishes + +> This, however, is not paradise. + +you can't have it all ;-) + +> On the contrary, it makes it GREAT for datawarehousing. Not because any +> one child process will be super fast, but because ALL the child +> processes will run reasonably fast, even under very heavy read and write +> load. + +What I meant with datawarehouse are many db's at many locations whose data = +are to be collected in one central db in order to mix em up, sum up or do a= +nything equivalent. +But in fact my quite heavy-read/write-accessed db is running really fast si= +nce 1 1/2 years now +Even though still on PG 7.2 +The one and only bottleneck are the statistics and the reports - and the ta= +bles are getting larger and larger ... + +> Note that if you've got the memory for the hash agg algo to fire +> into shared memory, it's pretty darned fast now, + +yes, I've noticed here on the testing server + +> so if the data (mostly) +> fit into kernel cache you're gold. And 12 gig Intel boxes aren't that +> expensive, compared to an Oracle license. + +*that's* the point ... + +Anyway: Greetings and thanks for your answers +Harald + +From pgsql-performance-owner@postgresql.org Tue Jun 29 16:57:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E252D1B182 + for ; + Tue, 29 Jun 2004 16:03: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 55866-03 + for ; + Tue, 29 Jun 2004 19:03:30 +0000 (GMT) +Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 643CDD1B258 + for ; + Tue, 29 Jun 2004 16:03:27 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BfNt9-0007ZU-0b; Tue, 29 Jun 2004 20:03:27 +0100 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id C4ABB16520; Tue, 29 Jun 2004 20:03:26 +0100 (BST) +Message-ID: <40E1BCFD.9090401@archonet.com> +Date: Tue, 29 Jun 2004 20:03:25 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance +References: <200406291733.i5THXkfL031311@math.uchicago.edu> +In-Reply-To: <200406291733.i5THXkfL031311@math.uchicago.edu> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/312 +X-Sequence-Number: 7370 + +Bill wrote: +> Ok, thanks. So let me explain the query number 2 as this is the more +> difficult to write. So I have a list of stocks, this table contains the +> price of all of the stocks at the open and close date. Ok, now we have a +> ratio from query (1) that returns at least a very rough index of the daily +> performance of a given stock, with each ratio representing the stock's +> performance in one day. Now we need to average this with the same stock's +> ratio every day, to get a total average for each stock contained in the +> database. Now I would simply like to find a ratio like this that represents +> the average of every stock in the table and simply find the greatest ratio. +> Sorry about the lousy explanation before, is this a bit better? +> +> Here is an example if needed. +> +> Say we have a stock by the name of YYY +> +> I know, due to query 1 that stock YYY has a abs(close-open)/open price ratio +> of for example, 1.3 on Dec 1 and (for simplicity let's say we only have two +> dates) and Dec 2 the ratio for YYY is 1.5. So the query averages and gets +> 1.4. Now it needs to do this for all of the stocks in the table and sort by +> increasing ratio. + +Well, the simplest would be something like: + +CREATE VIEW my_ratios AS SELECT ...(select details we used for #1 +previously) + +Query #1 then becomes: +SELECT * FROM my_ratios; + +Then you could do: +SELECT + symbol, + avg(ratio) as ratio_avg +FROM + my_ratios +GROUP BY + symbol +ORDER BY + avg(ratio) +; + +Now, in practice, I'd probably create a symbol_ratio table and fill that +one day at a time. Then #2,#3 would be easier. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Jun 29 18:11:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C07ED1B1D2 + for ; + Tue, 29 Jun 2004 16:45: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 77015-05 + for ; + Tue, 29 Jun 2004 19:44:57 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id D04C5D1B179 + for ; + Tue, 29 Jun 2004 16:44:54 -0300 (ADT) +Received: (qmail 1689 invoked by uid 500); 29 Jun 2004 19:51:30 -0000 +Date: Tue, 29 Jun 2004 14:51:30 -0500 +From: Bruno Wolff III +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance +Message-ID: <20040629195130.GA1513@wolff.to> +Mail-Followup-To: Bill , + pgsql-performance@postgresql.org +References: <40E12A5D.70007@archonet.com> + <200406291733.i5THXkfL031311@math.uchicago.edu> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200406291733.i5THXkfL031311@math.uchicago.edu> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/314 +X-Sequence-Number: 7372 + +On Tue, Jun 29, 2004 at 12:33:51 -0500, + Bill wrote: +> Ok, thanks. So let me explain the query number 2 as this is the more +> difficult to write. So I have a list of stocks, this table contains the +> price of all of the stocks at the open and close date. Ok, now we have a +> ratio from query (1) that returns at least a very rough index of the daily +> performance of a given stock, with each ratio representing the stock's +> performance in one day. Now we need to average this with the same stock's +> ratio every day, to get a total average for each stock contained in the +> database. Now I would simply like to find a ratio like this that represents +> the average of every stock in the table and simply find the greatest ratio. +> Sorry about the lousy explanation before, is this a bit better? + +You can do something like: + +SELECT symbol, avg((open-close)/open) GROUP BY symbol + ORDER BY avg((open-close)/open) DESC LIMIT 1; + +If you aren't interested in the variance of the daily change, it seems like +you would be best off using the opening price for the first day you have +recorded for the stock and the closing price on the last day and looking +at the relative change. + +From pgsql-performance-owner@postgresql.org Thu Jul 1 16:20:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E1D0ED1B196 + for ; + Tue, 29 Jun 2004 18:56: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 46836-01 + for ; + Tue, 29 Jun 2004 21:56:40 +0000 (GMT) +Received: from mail.and.org (code.and.org [63.113.167.33]) + by svr1.postgresql.org (Postfix) with ESMTP id C34C3D1B188 + for ; + Tue, 29 Jun 2004 18:56:34 -0300 (ADT) +Received: from james by mail.and.org with local (Exim 4.30) id + 1BfQai-0006WE-7o + for pgsql-performance@postgresql.org; Tue, 29 Jun 2004 17:56:36 -0400 +To: pgsql-performance@postgresql.org +Subject: Query gets slow when where clause increases +From: James Antill +Content-Type: text/plain; charset=US-ASCII +Date: Tue, 29 Jun 2004 17:56:36 -0400 +Message-ID: +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200407/3 +X-Sequence-Number: 7394 + + + I have a problem where a query gets _much_ slower if I add statements +to the where clause than if I just get everything and filter in the +code. I expected the query to be faster as the where clause gets +bigger (and thus the data to return gets lower). + + I've put inline the SQL and explain analyze of both the general and +specific queries. I assume the problem is something to do with the +fact that in the specific query "ticket_groups" is uses an index and +is assumed to return 5 rows, but actually returns 604 and in the +generic case it doesn't use an index and is assumed to return 3.5-4 +thousand and does? Is this right, and if so is it possible to get +postgres to re-think using an index in this case (or possible up it's +estimated row count)? + Any help appreciated. + +----------------------- GENERIC ------------------------------------- + +SELECT g.assigned_to, g.opened AS escalated, t.tid, t.opened, + e.userid AS commiter, e.eid, e.performed_on, e.status + FROM (events e JOIN (ticket_groups g JOIN tickets t USING(tid)) USING(tid)) + WHERE (g.gid = '37' AND + (e.performed_on <= CAST('1088480270' AS bigint)) AND + ((t.modified >= CAST('1086875491' AS bigint)) OR + (t.status != '4' AND + t.status != '5' AND + t.status != '9'))) + ORDER BY e.userid, t.tid, e.performed_on; + + Sort (cost=28017.06..28054.97 rows=15166 width=58) (actual time=2057.25..2076.12 rows=26594 loops=1) + Sort Key: e.userid, t.tid, e.performed_on + -> Merge Join (cost=1251.59..26963.93 rows=15166 width=58) (actual time=231.81..1972.29 rows=26594 loops=1) + Merge Cond: ("outer".tid = "inner".tid) + -> Index Scan using idx_tid_events on events e (cost=0.00..18943.61 rows=268784 width=26) (actual time=11.48..1358.15 rows=268803 loops=1) + Filter: (performed_on <= 1088480270::bigint) + -> Materialize (cost=7160.00..7160.00 rows=1725 width=32) (actual time=217.14..237.94 rows=26592 loops=1) + -> Merge Join (cost=1251.59..7160.00 rows=1725 width=32) (actual time=63.14..214.75 rows=983 loops=1) + Merge Cond: ("outer".tid = "inner".tid) + -> Index Scan using idx_tickets_tid on tickets t (cost=0.00..5820.13 rows=18823 width=12) (actual time=2.97..135.57 rows=6020 loops=1) + Filter: (((status <> 4::smallint) OR (modified >= 1086875491::bigint)) AND ((status <> 5::smallint) OR (modified >= 1086875491::bigint)) AND ((status <> 9::smallint) OR (modified >= 1086875491::bigint))) + -> Sort (cost=1251.59..1261.38 rows=3915 width=20) (actual time=60.13..62.96 rows=3699 loops=1) + Sort Key: g.tid + -> Seq Scan on ticket_groups g (cost=0.00..1017.94 rows=3915 width=20) (actual time=0.05..53.02 rows=3699 loops=1) + Filter: (gid = 37) + Total runtime: 2100.75 msec + +--------------------- SPECIFIC ------------------------------------- + +SELECT g.assigned_to, g.opened AS escalated, t.tid, t.opened, + e.userid AS commiter, e.eid, e.performed_on, e.status + FROM (events e JOIN (ticket_groups g JOIN tickets t USING(tid)) USING(tid)) + WHERE (g.gid = '37' AND + (e.performed_on <= CAST('1088480270' AS bigint)) AND + ((t.modified >= CAST('1086875491' AS bigint)) OR + (t.status != '4' AND + t.status != '5' AND + t.status != '9')) AND (g.assigned_to IS NOT NULL AND g.assigned_to='1540') AND e.userid='1540') + ORDER BY e.userid, t.tid, e.performed_on; + + Sort (cost=5079.17..5079.18 rows=1 width=58) (actual time=218121.00..218122.02 rows=1441 loops=1) + Sort Key: e.userid, t.tid, e.performed_on + -> Nested Loop (cost=0.00..5079.16 rows=1 width=58) (actual time=85.28..218115.36 rows=1441 loops=1) + Join Filter: ("outer".tid = "inner".tid) + -> Nested Loop (cost=0.00..305.53 rows=1 width=46) (actual time=0.22..261.78 rows=2420 loops=1) + -> Index Scan using idx_ticket_groups_assigned on ticket_groups g (cost=0.00..241.76 rows=5 width=20) (actual time=0.13..12.67 rows=604 loops=1) + Index Cond: (assigned_to = 1540) + Filter: ((gid = 37) AND (assigned_to IS NOT NULL)) + -> Index Scan using idx_tid_events on events e (cost=0.00..12.50 rows=1 width=26) (actual time=0.11..0.38 rows=4 loops=604) + Index Cond: (e.tid = "outer".tid) + Filter: ((performed_on <= 1088480270::bigint) AND (userid = 1540)) + -> Seq Scan on tickets t (cost=0.00..4538.35 rows=18823 width=12) (actual time=0.16..83.53 rows=6020 loops=2420) + Filter: (((status <> 4::smallint) OR (modified >= 1086875491::bigint)) AND ((status <> 5::smallint) OR (modified >= 1086875491::bigint)) AND ((status <> 9::smallint) OR (modified >= 1086875491::bigint))) + Total runtime: 218123.24 msec + + +-- +James Antill -- james@and.org +Need an efficient and powerful string library for C? +http://www.and.org/vstr/ + +From pgsql-performance-owner@postgresql.org Tue Jun 29 19:38:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 94241D1B196 + for ; + Tue, 29 Jun 2004 19:36: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 63150-05 + for ; + Tue, 29 Jun 2004 22:36:01 +0000 (GMT) +Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net + [63.231.195.115]) + by svr1.postgresql.org (Postfix) with SMTP id E56AED1B1CD + for ; + Tue, 29 Jun 2004 19:35:56 -0300 (ADT) +Received: (qmail 88598 invoked by uid 0); 29 Jun 2004 22:35:59 -0000 +Received: from mpls-pop-04.inet.qwest.net (63.231.195.4) + by mpls-qmqp-04.inet.qwest.net with QMQP; 29 Jun 2004 22:35:59 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-04.inet.qwest.net with SMTP; 29 Jun 2004 22:35:59 -0000 +Date: Tue, 29 Jun 2004 16:36:55 -0600 +Message-Id: <1088548615.12350.44.camel@localhost.localdomain> +From: "Scott Marlowe" +To: eleven@ludojad.itpp.pl +Cc: pgsql-performance@postgresql.org +Subject: Re: High load average with PostgreSQL 7.4.2 on +In-Reply-To: <20040629155537.GA5465@ludojad.itpp.pl> +References: <20040629155537.GA5465@ludojad.itpp.pl> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200406/315 +X-Sequence-Number: 7373 + +On Tue, 2004-06-29 at 09:55, eleven@ludojad.itpp.pl wrote: +> Hello, +> +> I'm using PostgreSQL 7.4.2 (package from backports.org) +> on a Debian (woody) box. The machine is IBM eServer 345 +> with two 2.8 Xeon CPUs, it has 1024MB of RAM and +> two 15k RPM SCSI disks running in hardware RAID1, which +> is provided by the onboard LSI Logic controller (LSI53C1030). +> +> The database consists of two rather large tables +> (currently about 15 million rows in one table +> and about 5 million in the other one). Both tables +> have 5 indexes (4 btree/1 hash). +> Application running on the server INSERTs a lot of +> stuff to the tables (which is not the target use of +> the DB, it'll add data periodically, about +> 300 rows per 10 minutes). Queries (SELECTs) run perfectly +> fine on the database, thanks to the indexes we have +> here probably. +> +> Performance issue, I'm experiencing here, is somewhat +> weird - server gets high average load (from 5 up to 15, +> 8 on average). Standard performance monitoring +> utilities (like top) show that CPUs are not loaded +> (below 20%, often near zero). + +Anytime you have high load but low CPU utilization, you usually have an +I/O bound system. + +Ad disks to your RAID (big RAID 5 or RAID 1+0) and make sure you have +battery backed cache set to write back. also, put as memory as you can +in the machine. Jumping up to 2 Gigs may help quite a bit as well. + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 20:30:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DC5F6D1B1C9 + for ; + Tue, 29 Jun 2004 20:30: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 84203-09 + for ; + Tue, 29 Jun 2004 23:29:58 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 37FA1D1B174 + for ; + Tue, 29 Jun 2004 20:29:54 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5546691; Tue, 29 Jun 2004 16:31:38 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: mohana@zeomega.com, pgsql-performance@postgresql.org +Subject: Re: suggestions to improve performace +Date: Tue, 29 Jun 2004 16:29:51 -0700 +User-Agent: KMail/1.5.4 +References: <3439.202.142.94.6.1088528099.squirrel@mail.zeomega.com> +In-Reply-To: <3439.202.142.94.6.1088528099.squirrel@mail.zeomega.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406291629.51699.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200406/316 +X-Sequence-Number: 7374 + +Mohan, + +> I am looking at good rules to use for memory, WAL, SQL Transaction +> Isolation Levels and cache configuration along with anything else +> that I have missed. + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +For anything beyond that, you're asking for a service I charge $155/hour +for .... + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Jun 29 20:35:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 03F5DD1B179 + for ; + Tue, 29 Jun 2004 20:34: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 88742-02 + for ; + Tue, 29 Jun 2004 23:34:53 +0000 (GMT) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D503D1B2D9 + for ; + Tue, 29 Jun 2004 20:34:50 -0300 (ADT) +Received: from [64.81.245.111] (HELO 192.168.1.102) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 5546715; Tue, 29 Jun 2004 16:36:34 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: eleven@ludojad.itpp.pl, pgsql-performance@postgresql.org +Subject: Re: High load average with PostgreSQL 7.4.2 on debian/ibm eserver. +Date: Tue, 29 Jun 2004 16:34:48 -0700 +User-Agent: KMail/1.5.4 +References: <20040629155537.GA5465@ludojad.itpp.pl> + <9662496504062909172bf8034b@mail.gmail.com> + <20040629175227.GA11658@ludojad.itpp.pl> +In-Reply-To: <20040629175227.GA11658@ludojad.itpp.pl> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-2" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200406291634.48909.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 + tests=RCVD_NUMERIC_HELO +X-Spam-Level: +X-Archive-Number: 200406/317 +X-Sequence-Number: 7375 + +Eleven, + +> In particular - could someone tell me if those iostat +> values can tell if I'm close to upper performance boundary +> of fast SCSI (Ultra 320, 15k RPM) disks? + +It's quite possible that you need to improve your disk array; certainly I +would have spec'd a lot more disk than you're using (like raid 0+1 with 6 +disks or RAID 5 with seven disks). + +However, there's the other end as well; it's quite possible that your queries +are doing seq scans and other disk-intensive operations that could be +avoided. Have you analyed this at all? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Jun 30 04:19:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 67BD6D1B252 + for ; + Wed, 30 Jun 2004 04:19: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 85089-02 + for ; + Wed, 30 Jun 2004 07:19:06 +0000 (GMT) +Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.246]) + by svr1.postgresql.org (Postfix) with SMTP id 1B619D1B1CE + for ; + Wed, 30 Jun 2004 04:19:03 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id w29so1631718cwb + for ; + Wed, 30 Jun 2004 00:19:04 -0700 (PDT) +Received: by 10.38.164.38 with SMTP id m38mr31243rne; + Wed, 30 Jun 2004 00:19:04 -0700 (PDT) +Message-ID: +Date: Wed, 30 Jun 2004 00:19:04 -0700 +From: Chris Cheston +To: "Gavin M. Roy" +Subject: Re: postgres 7.4 at 100% +Cc: pgsql-performance@postgresql.org +In-Reply-To: <40E192CC.90707@ehpg.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + + <40E1266D.3040607@familyhealth.com.au> + + <40E192CC.90707@ehpg.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/318 +X-Sequence-Number: 7376 + +Oh my, creating an index has absolutely reduced the times it takes to +query from around 700 ms to less than 1 ms! + +Thanks so much for all your help. You've saved me! + +One question: + +Why would I or would I not create multiple indexes in a table? I +created another index in the same table an it's improved performance +even more. + +Thanks, +Chris + +On Tue, 29 Jun 2004 09:03:24 -0700, Gavin M. Roy wrote: +> +> Is the from field nullable? If not, try "create index calllogs_from on +> calllogs ( from );" and then do an explain analyze of your query. +> +> Gavin +> +> +> +> Chris Cheston wrote: +> +> >ok i just vacuumed it and it's taking slightly longer now to execute +> >(only about 8 ms longer, to around 701 ms). +> > +> >Not using indexes for calllogs(from)... should I? The values for +> >calllogs(from) are not unique (sorry if I'm misunderstanding your +> >point). +> > +> >Thanks, +> > +> >Chris +> > +> >On Tue, 29 Jun 2004 16:21:01 +0800, Christopher Kings-Lynne +> > wrote: +> > +> > +> >>>live=# explain analyze SELECT id FROM calllogs WHERE from = 'you'; +> >>> QUERY PLAN +> >>>---------------------------------------------------------------------------------------------------------- +> >>> Seq Scan on calllogs (cost=0.00..136.11 rows=24 width=4) (actual +> >>>time=0.30..574.72 rows=143485 loops=1) +> >>> Filter: (from = 'you'::character varying) +> >>> Total runtime: 676.24 msec +> >>>(3 rows) +> >>> +> >>> +> >>Have you got an index on calllogs(from)? +> >> +> >>Have you vacuumed and analyzed that table recently? +> >> +> >>Chris +> >> +> >> +> >> +> >> +> > +> >---------------------------(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 Wed Jun 30 04:30:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9114BD1B198 + for ; + Wed, 30 Jun 2004 04:30: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 90085-02 + for ; + Wed, 30 Jun 2004 07:30:51 +0000 (GMT) +Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) + by svr1.postgresql.org (Postfix) with ESMTP id DD4CCD1B182 + for ; + Wed, 30 Jun 2004 04:30:46 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id EEEA41009AF; + Wed, 30 Jun 2004 15:30:46 +0800 (WST) +Received: from [192.168.1.9] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan02.westnet.com.au (Postfix) with ESMTP id 7743910059A; + Wed, 30 Jun 2004 15:30:46 +0800 (WST) +Message-ID: <40E26C2C.9080601@familyhealth.com.au> +Date: Wed, 30 Jun 2004 15:30:52 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Cheston +Cc: "Gavin M. Roy" , pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + + <40E1266D.3040607@familyhealth.com.au> + + <40E192CC.90707@ehpg.net> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/319 +X-Sequence-Number: 7377 + + +> Why would I or would I not create multiple indexes in a table? I +> created another index in the same table an it's improved performance +> even more. + +You create indexes when you need indexes. Indexes are most helpful when +they match the WHERE clause of your selects. + +So, if you commonly do one query that selects on one column, and another +query that selects on two other columns - then create one index on the +first column and another index over the second two columns. + +Chris + +From pgsql-performance-owner@postgresql.org Wed Jun 30 04:35:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9ACD3D1B198 + for ; + Wed, 30 Jun 2004 04:34: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 91187-06 + for ; + Wed, 30 Jun 2004 07:34:54 +0000 (GMT) +Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.243]) + by svr1.postgresql.org (Postfix) with SMTP id 6BA8DD1B193 + for ; + Wed, 30 Jun 2004 04:34:51 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id w29so1639365cwb + for ; + Wed, 30 Jun 2004 00:34:52 -0700 (PDT) +Received: by 10.38.164.38 with SMTP id m38mr31505rne; + Wed, 30 Jun 2004 00:34:52 -0700 (PDT) +Message-ID: +Date: Wed, 30 Jun 2004 00:34:52 -0700 +From: Chris Cheston +To: Christopher Kings-Lynne +Subject: Re: postgres 7.4 at 100% +Cc: pgsql-performance@postgresql.org +In-Reply-To: <40E26C2C.9080601@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + + <40E1266D.3040607@familyhealth.com.au> + + <40E192CC.90707@ehpg.net> + + <40E26C2C.9080601@familyhealth.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/320 +X-Sequence-Number: 7378 + +I see - thanks very much. I created an index for column 'oid' which I +was using in a WHERE. So rule of thumb- create an index for column(s) +which I use in WHERE queries. + +Thanks, +Chis + +On Wed, 30 Jun 2004 15:30:52 +0800, Christopher Kings-Lynne + wrote: +> +> +> > Why would I or would I not create multiple indexes in a table? I +> > created another index in the same table an it's improved performance +> > even more. +> +> You create indexes when you need indexes. Indexes are most helpful when +> they match the WHERE clause of your selects. +> +> So, if you commonly do one query that selects on one column, and another +> query that selects on two other columns - then create one index on the +> first column and another index over the second two columns. +> +> Chris +> + +From pgsql-performance-owner@postgresql.org Wed Jun 30 07:02:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 25A38D1B33F + for ; + Wed, 30 Jun 2004 07:02: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 63125-04 + for ; + Wed, 30 Jun 2004 10:02:47 +0000 (GMT) +Received: from vscan01.westnet.com.au (vscan01.westnet.com.au [203.10.1.131]) + by svr1.postgresql.org (Postfix) with ESMTP id 1031ED1B348 + for ; + Wed, 30 Jun 2004 07:02:44 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id 552FB5097F; + Wed, 30 Jun 2004 18:02:45 +0800 (WST) +Received: from [192.168.1.9] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan01.westnet.com.au (Postfix) with ESMTP id DA3A650972; + Wed, 30 Jun 2004 18:02:44 +0800 (WST) +Message-ID: <40E28FCA.4010409@familyhealth.com.au> +Date: Wed, 30 Jun 2004 18:02:50 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Cheston +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +References: + <1088397641.1105.10.camel@localhost> + <17884.1088399982@sss.pgh.pa.us> + <200406280947.59420.josh@agliodbs.com> + + <40E1266D.3040607@familyhealth.com.au> + + <40E192CC.90707@ehpg.net> + + <40E26C2C.9080601@familyhealth.com.au> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/321 +X-Sequence-Number: 7379 + +> I see - thanks very much. I created an index for column 'oid' which I +> was using in a WHERE. So rule of thumb- create an index for column(s) +> which I use in WHERE queries. + +So to speak. They can also sometimes assist in sorting. The OID column +is special. I suggest adding a unique index to that column. In +postgresql it is _possible_ for the oid counter to wraparound, hence if +you rely on oids (not necessarily a good idea), it's best to put a +unique index on the oid column. + +I _strongly_ suggest that you read this: + +http://www.postgresql.org/docs/7.4/static/indexes.html + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Jun 30 10:47:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 930D6D1B184 + for ; + Wed, 30 Jun 2004 10:46: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 71125-05 + for ; + Wed, 30 Jun 2004 13:46:56 +0000 (GMT) +Received: from math.uchicago.edu (math.uchicago.edu [128.135.72.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 7611FD1B172 + for ; + Wed, 30 Jun 2004 10:46:51 -0300 (ADT) +Received: from billnotebook (wireless-197-223.uchicago.edu [128.135.197.223]) + by math.uchicago.edu (8.12.10/8.12.10) with ESMTP id i5UDktfL013134 + for ; + Wed, 30 Jun 2004 08:46:55 -0500 +Message-Id: <200406301346.i5UDktfL013134@math.uchicago.edu> +From: "Bill" +To: +Subject: Re: Query performance +Date: Wed, 30 Jun 2004 08:47:03 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +In-Reply-To: <20040629195130.GA1513@wolff.to> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Thread-Index: AcReEY+bwr8Aj6a5SVG7hH5fF/GZ0QAlvmYg +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/322 +X-Sequence-Number: 7380 + +Thanks this query works for what I want. So here is an output of the +explain analyze: + QUERY +PLAN +---------------------------------------------------------------------------- +------------------------------------------------------------------------ + Limit (cost=2421582.59..2421582.65 rows=25 width=29) (actual +time=1985800.32..1985800.44 rows=25 loops=1) + -> Sort (cost=2421582.59..2424251.12 rows=1067414 width=29) (actual +time=1985800.31..1985800.35 rows=26 loops=1) + Sort Key: avg(((open - "close") / (open + 1::numeric))) + -> Aggregate (cost=2200163.04..2280219.09 rows=1067414 width=29) +(actual time=910291.94..1984972.93 rows=22362 loops=1) + -> Group (cost=2200163.04..2253533.74 rows=10674140 +width=29) (actual time=910085.96..1105064.28 rows=10674140 loops=1) + -> Sort (cost=2200163.04..2226848.39 rows=10674140 +width=29) (actual time=910085.93..988909.94 rows=10674140 loops=1) + Sort Key: symbol + -> Seq Scan on oclh (cost=0.00..228404.40 +rows=10674140 width=29) (actual time=20.00..137720.61 rows=10674140 loops=1) + Total runtime: 1986748.44 msec +(9 rows) + +Can I get any better performance? + +Thanks. + +-----Original Message----- +From: Bruno Wolff III [mailto:bruno@wolff.to] +Sent: Tuesday, June 29, 2004 2:52 PM +To: Bill +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Query performance + +On Tue, Jun 29, 2004 at 12:33:51 -0500, + Bill wrote: +> Ok, thanks. So let me explain the query number 2 as this is the more +> difficult to write. So I have a list of stocks, this table contains the +> price of all of the stocks at the open and close date. Ok, now we have a +> ratio from query (1) that returns at least a very rough index of the daily +> performance of a given stock, with each ratio representing the stock's +> performance in one day. Now we need to average this with the same stock's +> ratio every day, to get a total average for each stock contained in the +> database. Now I would simply like to find a ratio like this that +represents +> the average of every stock in the table and simply find the greatest +ratio. +> Sorry about the lousy explanation before, is this a bit better? + +You can do something like: + +SELECT symbol, avg((open-close)/open) GROUP BY symbol + ORDER BY avg((open-close)/open) DESC LIMIT 1; + +If you aren't interested in the variance of the daily change, it seems like +you would be best off using the opening price for the first day you have +recorded for the stock and the closing price on the last day and looking +at the relative change. + + +From pgsql-performance-owner@postgresql.org Wed Jun 30 11:32:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F6CED1B26E + for ; + Wed, 30 Jun 2004 11:27: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 95765-02 + for ; + Wed, 30 Jun 2004 14:27:28 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CCF6DD1B252 + for ; + Wed, 30 Jun 2004 11:27:21 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 0646076AAA; Wed, 30 Jun 2004 10:27:28 -0400 (EDT) +Subject: Re: Query performance +From: Rod Taylor +To: Bill +Cc: Postgresql Performance +In-Reply-To: <200406301346.i5UDktfL013134@math.uchicago.edu> +References: <200406301346.i5UDktfL013134@math.uchicago.edu> +Content-Type: text/plain +Message-Id: <1088605644.12340.10.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 30 Jun 2004 10:27:25 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/323 +X-Sequence-Number: 7381 + +> Can I get any better performance? + +You can try bumping your sort memory way up (for this query only). + +Another method would be to cluster the table by the symbol column +(eliminates the expensive sort). + +If you could run a very simple calculation against open & close numbers +to eliminate a majority of symbols early, that would be useful as well. + + + +From pgsql-performance-owner@postgresql.org Wed Jun 30 12:19:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F38AD1B1B0 + for ; + Wed, 30 Jun 2004 12:08: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 20943-01 + for ; + Wed, 30 Jun 2004 15:08:18 +0000 (GMT) +Received: from web13121.mail.yahoo.com (web13121.mail.yahoo.com + [216.136.174.83]) + by svr1.postgresql.org (Postfix) with SMTP id 56C97D1B193 + for ; + Wed, 30 Jun 2004 12:08:17 -0300 (ADT) +Message-ID: <20040630150816.96381.qmail@web13121.mail.yahoo.com> +Received: from [63.78.248.48] by web13121.mail.yahoo.com via HTTP; + Wed, 30 Jun 2004 08:08:16 PDT +Date: Wed, 30 Jun 2004 08:08:16 -0700 (PDT) +From: Litao Wu +Subject: Re: reindex and copy - deadlock? +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <18172.1086985673@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HOT_NASTY +X-Spam-Level: +X-Archive-Number: 200406/324 +X-Sequence-Number: 7382 + +Hi All, + +It happened again. +This time it hangs when we drop/create index. + +Here is gdb info with --enable-debug postgres. + +Thank you for your help! + +postgres 24533 24327 2 Jun28 ? 00:39:11 +postgres: postgres +xxx xxx.xxx.x.xxx COPY waiting +postgres 23508 24327 0 03:23 ? 00:00:00 +postgres: postgres +xxx xxx.xxx.x.xx SELECT waiting +root 23662 22727 0 03:24 ? 00:00:00 +/xxx/bin/psql -t -A -q xxx -U postgres -c set +sort_mem=131072; DROP INDEX xxx_mod_ac_did_cre_idx; +CREATE INDEX xxx_mod_ac_did_cre_idx ON +xxx_module_action USING btree (domain_id, created); +postgres 23663 24327 2 03:24 ? 00:04:40 +postgres: postgres +xxx [local] CREATE INDEX +postgres 24252 24327 0 03:26 ? 00:00:00 +postgres: postgres +xxx xxx.xxx.x.xx SELECT waiting + +bash-2.05a$ gdb /xxx/bin/postgres +GNU gdb Red Hat Linux (5.2-2) +Copyright 2002 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General +Public License, and you +are +welcome to change it and/or distribute copies of it +under certain +conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show +warranty" for +details. +This GDB was configured as "i386-redhat-linux"... +(gdb) attach 23663 +Attaching to program: /xxx/bin.Linux/postgres, process +23663 +Reading symbols from /usr/lib/libz.so.1...done. +Loaded symbols for /usr/lib/libz.so.1 +Reading symbols from /usr/lib/libreadline.so.4...done. +Loaded symbols for /usr/lib/libreadline.so.4 +Reading symbols from /lib/libtermcap.so.2...done. +Loaded symbols for /lib/libtermcap.so.2 +Reading symbols from /lib/libcrypt.so.1...done. +Loaded symbols for /lib/libcrypt.so.1 +Reading symbols from /lib/libresolv.so.2...done. +Loaded symbols for /lib/libresolv.so.2 +Reading symbols from /lib/libnsl.so.1...done. +Loaded symbols for /lib/libnsl.so.1 +Reading symbols from /lib/libdl.so.2...done. +Loaded symbols for /lib/libdl.so.2 +Reading symbols from /lib/i686/libm.so.6...done. +Loaded symbols for /lib/i686/libm.so.6 +Reading symbols from /lib/i686/libc.so.6...done. +Loaded symbols for /lib/i686/libc.so.6 +Reading symbols from /lib/ld-linux.so.2...done. +Loaded symbols for /lib/ld-linux.so.2 +Reading symbols from /lib/libnss_files.so.2...done. +Loaded symbols for /lib/libnss_files.so.2 +0x420e8bb2 in semop () from /lib/i686/libc.so.6 +(gdb) bt +#0 0x420e8bb2 in semop () from /lib/i686/libc.so.6 +#1 0x080ff954 in PGSemaphoreLock (sema=0x4a2d83e8, +interruptOK=0 '\0') +at pg_sema.c:434 +#2 0x0811635e in LWLockAcquire (lockid=21335, +mode=LW_EXCLUSIVE) at +lwlock.c:312 +#3 0x0810f49e in LockBuffer (buffer=10657, mode=2) at +bufmgr.c:1848 +#4 0x0807dea3 in _bt_getbuf (rel=0x40141b10, +blkno=4294967295, +access=2) at nbtpage.c:337 +#5 0x080813d8 in _bt_blnewpage (index=0x40141b10, +buf=0xbfffe724, +page=0xbfffe728, flags=1) at nbtsort.c:188 +#6 0x08081692 in _bt_buildadd (index=0x40141b10, +state=0x4e0b3e30, +bti=0x4fe20cb8) at nbtsort.c:373 +#7 0x08081b77 in _bt_load (index=0x40141b10, +btspool=0x82bf7b8, +btspool2=0x0) at nbtsort.c:638 +#8 0x080813b8 in _bt_leafbuild (btspool=0x82bf7b8, +btspool2=0x0) at +nbtsort.c:171 +#9 0x0807e1d0 in btbuild (fcinfo=0xbfffe820) at +nbtree.c:165 +#10 0x081630d7 in OidFunctionCall3 (functionId=338, +arg1=1075019120, +arg2=1075059472, arg3=137095072) + at fmgr.c:1275 +#11 0x08092093 in index_build +(heapRelation=0x40137d70, +indexRelation=0x40141b10, indexInfo=0x82be7a0) + at index.c:1447 +#12 0x080913d7 in index_create (heapRelationId=17618, +indexRelationName=0x82b9648 "xxx_mod_ac_did_cre_idx", + indexInfo=0x82be7a0, accessMethodObjectId=403, +classObjectId=0x82be578, primary=0 '\0', +isconstraint=0 '\0', + allow_system_table_mods=0 '\0') at index.c:765 +#13 0x080b88ae in DefineIndex (heapRelation=0x82b9698, +indexRelationName=0x82b9648 "xxx_mod_ac_did_cre_idx", + accessMethodName=0x82b96c0 "btree", +attributeList=0x82b9718, +unique=0 '\0', primary=0 '\0', + isconstraint=0 '\0', predicate=0x0, +rangetable=0x0) at +indexcmds.c:211 +#14 0x0811b250 in ProcessUtility (parsetree=0x82b9788, +dest=Remote, +completionTag=0xbfffea80 "") at utility.c:620 +#15 0x08118df6 in pg_exec_query_string +(query_string=0x82b91e0, +dest=Remote, parse_context=0x82ade58) + at postgres.c:789 +#16 0x08119f0d in PostgresMain (argc=4, +argv=0xbfffecb0, +username=0x8240679 "postgres") at postgres.c:2013 +#17 0x08102078 in DoBackend (port=0x8240548) at +postmaster.c:2302 +#18 0x081019ca in BackendStartup (port=0x8240548) at +postmaster.c:1924 +#19 0x08100bcd in ServerLoop () at postmaster.c:1009 +#20 0x0810078e in PostmasterMain (argc=1, +argv=0x8227468) at +postmaster.c:788 +#21 0x080dee2b in main (argc=1, argv=0xbffff644) at +main.c:210 +#22 0x42017589 in __libc_start_main () from +/lib/i686/libc.so.6 +(gdb) quit +The program is running. Quit anyway (and detach it)? +(y or n) y +Detaching from program: /xxx/bin.Linux/postgres, +process 23663 + + + +--- Tom Lane wrote: +> Litao Wu writes: +> > One difference between these two databases +> > is the one having REINDEX problem is using +> > NTFS file system. +> +> Oh? That's interesting. +> +> > Is it possible the root of problem? +> +> I would not expect it to show this particular +> symptom --- if the +> backtrace is accurate. But there are nearby places +> that might have +> FS-dependent behavior. Can you do anything about my +> request for +> a stack trace from a debug-enabled build? +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to +majordomo@postgresql.org + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail Address AutoComplete - You start. We finish. +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Wed Jun 30 12:46:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B4F2D1B1B0 + for ; + Wed, 30 Jun 2004 12:43: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 34370-09 + for ; + Wed, 30 Jun 2004 15:43: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 A3174D1B1D2 + for ; + Wed, 30 Jun 2004 12:43:39 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5UFhdBh009420; + Wed, 30 Jun 2004 11:43:39 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: reindex and copy - deadlock? +In-reply-to: <20040630150816.96381.qmail@web13121.mail.yahoo.com> +References: <20040630150816.96381.qmail@web13121.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Wed, 30 Jun 2004 08:08:16 -0700" +Date: Wed, 30 Jun 2004 11:43:38 -0400 +Message-ID: <9419.1088610218@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/325 +X-Sequence-Number: 7383 + +Litao Wu writes: +> It happened again. +> This time it hangs when we drop/create index. +> Here is gdb info with --enable-debug postgres. + +Well, that pretty much removes all doubt: something has left the buffer +context lock (cntx_lock) set on a buffer that certainly ought to be free. + +The problem here is that REINDEX (or CREATE INDEX in this case) is the +victim, not the perpetrator, so we still don't know exactly what's +causing the error. We need to go backwards in time, so to speak, to +identify the code that's leaving the buffer locked when it shouldn't. +I don't offhand have a good idea about how to do that. Is there another +process that is also getting stuck when REINDEX does (if so please get +a backtrace from it too)? + +BTW, what Postgres version are you using again? The line numbers in +your trace don't square with any current version of bufmgr.c ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Jun 30 14:18:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 72531D1B26E + for ; + Wed, 30 Jun 2004 13:17: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 57357-05 + for ; + Wed, 30 Jun 2004 16:17:48 +0000 (GMT) +Received: from web13121.mail.yahoo.com (web13121.mail.yahoo.com + [216.136.174.83]) + by svr1.postgresql.org (Postfix) with SMTP id AE977D1B27C + for ; + Wed, 30 Jun 2004 13:17:46 -0300 (ADT) +Message-ID: <20040630161746.10572.qmail@web13121.mail.yahoo.com> +Received: from [63.78.248.48] by web13121.mail.yahoo.com via HTTP; + Wed, 30 Jun 2004 09:17:46 PDT +Date: Wed, 30 Jun 2004 09:17:46 -0700 (PDT) +From: Litao Wu +Subject: Re: reindex and copy - deadlock? +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9419.1088610218@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/327 +X-Sequence-Number: 7385 + +Hi Tom, + +Our PG version is 7.3.2. + +The copy process is always there. Besides copy +process, there are many select processes wait also +(it is understandable only when reindex, +but how come selects wait when drop/create index? +>From Postgres doc: +Note: Another approach to dealing with a corrupted +user-table index is just to drop and recreate it. This +may in fact be preferable if you would like to +maintain some semblance of normal operation on the +table meanwhile. REINDEX acquires exclusive lock on +the table, while CREATE INDEX only locks out writes +not reads of the table. +) + +Each time, whan this happened, it might hang +on the different index. + +But one thing is sure: +reindex or create index is granted lock while +others wait. If reindex/create index is not +the perpetrator, how can PG grants it lock +but not others, like COPY? + +Forgive me I had not provided the full table and +index names, IP address, etc. for security reason. + +Here is the copy of my the first post on June 8: +Hi, + +We often experience with the problem that reindex +cannot be finished in our production database. +It's typically done with 30 minutes. However, +sometimes, when there is another "COPY" process, +reindex will not finish. By monitoring the CPU +time reindex takes, it does not increase at all. +That seems a deadlock. But the following query shows +only reindex process (23127)is granted lock while +COPY process (3149) is not. + +Last time when we have this problem and kill +reindex process and COPY process does not work. +We had to bounce the database server. + +As you know, when reindex is running, nobody can +access the table. +Can someone kindly help? + +Thanks, + + + +Here is lock info from database: + + replace | database | transaction | pid + | mode | granted +-----------------------+----------+-------------+-------+---------------------+--------- + email | 17613 | | +3149 | RowExclusiveLock | f + email_cre_dom_idx | 17613 | | +23127 | ExclusiveLock | t + email_cid_cre_idx | 17613 | | +23127 | ShareLock | t + email_cid_cre_idx | 17613 | | +23127 | AccessExclusiveLock | t + email | 17613 | | +23127 | ShareLock | t + email | 17613 | | +23127 | AccessExclusiveLock | t + email_cid_cre_dom_idx | 17613 | | +23127 | ShareLock | t + email_cid_cre_dom_idx | 17613 | | +23127 | AccessExclusiveLock | t + email_did_cre_idx | 17613 | | +23127 | ShareLock | t + email_did_cre_idx | 17613 | | +23127 | AccessExclusiveLock | t + email_cre_dom_idx | 17613 | | +23127 | AccessExclusiveLock | t +(11 rows) + + +Here are the processes of 3149 and 23127 from OS: + +postgres 3149 1.3 6.4 154104 134444 ? S +Jun03 92:04 postgres: postgres db1 xx.xx.xx.xx COPY +waiting + +postgres 23127 3.2 9.3 228224 194512 ? S +03:35 15:03 postgres: postgres db1 [local] REINDEX + +Here are queries from database: +23127 | REINDEX table email + + 3149 | COPY email (...) FROM stdin + + + +--- Tom Lane wrote: +> Litao Wu writes: +> > It happened again. +> > This time it hangs when we drop/create index. +> > Here is gdb info with --enable-debug postgres. +> +> Well, that pretty much removes all doubt: something +> has left the buffer +> context lock (cntx_lock) set on a buffer that +> certainly ought to be free. +> +> The problem here is that REINDEX (or CREATE INDEX in +> this case) is the +> victim, not the perpetrator, so we still don't know +> exactly what's +> causing the error. We need to go backwards in time, +> so to speak, to +> identify the code that's leaving the buffer locked +> when it shouldn't. +> I don't offhand have a good idea about how to do +> that. Is there another +> process that is also getting stuck when REINDEX does +> (if so please get +> a backtrace from it too)? +> +> BTW, what Postgres version are you using again? The +> line numbers in +> your trace don't square with any current version of +> bufmgr.c ... +> +> regards, tom lane +> +> ---------------------------(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 +> + + + + + +__________________________________ +Do you Yahoo!? +New and Improved Yahoo! Mail - 100MB free storage! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Wed Jun 30 14:05:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EA33CD1B285 + for ; + Wed, 30 Jun 2004 13:32: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 63962-05 + for ; + Wed, 30 Jun 2004 16:32:53 +0000 (GMT) +Received: from mailbox.maricopa.gov (mailbox.maricopa.gov [156.42.4.109]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F102D1B179 + for ; + Wed, 30 Jun 2004 13:32:50 -0300 (ADT) +Received: from maricopa_xcng2.maricopa.gov (maricopa_xcng2.maricopa.gov + [156.42.103.174] (may be forged)) + by mailbox.maricopa.gov (8.8.6 (PHNE_17190)/8.8.6) with ESMTP id + JAA03345; Wed, 30 Jun 2004 09:25:57 -0700 (MST) +Received: by maricopa_xcng2 with Internet Mail Service (5.5.2657.72) + id ; Wed, 30 Jun 2004 09:32:45 -0700 +Message-ID: <64EDC403A1417B4299488BAE87CA7CBF01CD0EA9@maricopa_xcng0> +From: Duane Lee - EGOVX +To: "'Chris Cheston'" , + "Gavin M. Roy" +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres 7.4 at 100% +Date: Wed, 30 Jun 2004 09:32:42 -0700 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C45EBF.DDF1C3B0" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200406/326 +X-Sequence-Number: 7384 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C45EBF.DDF1C3B0 +Content-Type: text/plain; + charset="iso-8859-1" + +Creating indexes on a table affects insert performance depending on the +number of indexes that have to be populated. From a query standpoint, +indexes are a godsend in most cases. + +Duane + +-----Original Message----- +From: Chris Cheston [mailto:ccheston@gmail.com] +Sent: Wednesday, June 30, 2004 12:19 AM +To: Gavin M. Roy +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] postgres 7.4 at 100% + + +Oh my, creating an index has absolutely reduced the times it takes to +query from around 700 ms to less than 1 ms! + +Thanks so much for all your help. You've saved me! + +One question: + +Why would I or would I not create multiple indexes in a table? I +created another index in the same table an it's improved performance +even more. + +Thanks, +Chris + +On Tue, 29 Jun 2004 09:03:24 -0700, Gavin M. Roy wrote: +> +> Is the from field nullable? If not, try "create index calllogs_from on +> calllogs ( from );" and then do an explain analyze of your query. +> +> Gavin +> +> +> +> Chris Cheston wrote: +> +> >ok i just vacuumed it and it's taking slightly longer now to execute +> >(only about 8 ms longer, to around 701 ms). +> > +> >Not using indexes for calllogs(from)... should I? The values for +> >calllogs(from) are not unique (sorry if I'm misunderstanding your +> >point). +> > +> >Thanks, +> > +> >Chris +> > +> >On Tue, 29 Jun 2004 16:21:01 +0800, Christopher Kings-Lynne +> > wrote: +> > +> > +> >>>live=# explain analyze SELECT id FROM calllogs WHERE from = 'you'; +> >>> QUERY PLAN +> +>>>------------------------------------------------------------------------- +--------------------------------- +> >>> Seq Scan on calllogs (cost=0.00..136.11 rows=24 width=4) (actual +> >>>time=0.30..574.72 rows=143485 loops=1) +> >>> Filter: (from = 'you'::character varying) +> >>> Total runtime: 676.24 msec +> >>>(3 rows) +> >>> +> >>> +> >>Have you got an index on calllogs(from)? +> >> +> >>Have you vacuumed and analyzed that table recently? +> >> +> >>Chris +> >> +> >> +> >> +> >> +> > +> >---------------------------(end of broadcast)--------------------------- +> >TIP 2: you can get off all lists at once with the unregister command +> > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> > +> > +> +> + +---------------------------(end of broadcast)--------------------------- +TIP 5: Have you checked our extensive FAQ? + + http://www.postgresql.org/docs/faqs/FAQ.html + +------_=_NextPart_001_01C45EBF.DDF1C3B0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] postgres 7.4 at 100% + + + +

Creating indexes on a table affects insert performance de= +pending on the number of indexes that have to be populated.  From a qu= +ery standpoint, indexes are a godsend in most cases.

+ +

Duane +

+ +

-----Original Message----- +
From: Chris Cheston [mailto:ccheston@gmail.com] +
Sent: Wednesday, June 30, 2004 12:19 AM +
To: Gavin M. Roy +
Cc: pgsql-performance@postgresql.org +
Subject: Re: [PERFORM] postgres 7.4 at 100% +

+
+ +

Oh my, creating an index has absolutely reduced the times= + it takes to +
query from around 700 ms to less than 1 ms! +

+ +

Thanks so much for all your help.  You've saved me!<= +/FONT> +

+ +

One question: +

+ +

Why would I or would I not create multiple indexes in a t= +able? I +
created another index in the same table an it's improved= + performance +
even more. +

+ +

Thanks, +
Chris +

+ +

On Tue, 29 Jun 2004 09:03:24 -0700, Gavin M. Roy <gmr@= +ehpg.net> wrote: +
> +
> Is the from field nullable?  If not, try "= +;create index calllogs_from on +
> calllogs ( from );" and then do an explain ana= +lyze of your query. +
> +
> Gavin +
> +
> +
> +
> Chris Cheston wrote: +
> +
> >ok i just vacuumed it and it's taking slightly = +longer now to execute +
> >(only about 8 ms longer, to around 701 ms). +
> > +
> >Not using indexes for calllogs(from)... should = +I?  The values for +
> >calllogs(from) are not unique (sorry if I'm mis= +understanding your +
> >point). +
> > +
> >Thanks, +
> > +
> >Chris +
> > +
> >On Tue, 29 Jun 2004 16:21:01 +0800, Christopher= + Kings-Lynne +
> ><chriskl@familyhealth.com.au> wrote: +
> > +
> > +
> >>>live=3D# explain analyze SELECT id FROM= + calllogs WHERE from =3D 'you'; +
> >>>      &nb= +sp;            = +            &nb= +sp;            = +    QUERY PLAN +
> >>>---------------------------------------= +------------------------------------------------------------------- +
> >>> Seq Scan on calllogs  (cost=3D0.0= +0..136.11 rows=3D24 width=3D4) (actual +
> >>>time=3D0.30..574.72 rows=3D143485 loops= +=3D1) +
> >>>   Filter: (from =3D 'you'::c= +haracter varying) +
> >>> Total runtime: 676.24 msec +
> >>>(3 rows) +
> >>> +
> >>> +
> >>Have you got an index on calllogs(from)? +
> >> +
> >>Have you vacuumed and analyzed that table r= +ecently? +
> >> +
> >>Chris +
> >> +
> >> +
> >> +
> >> +
> > +
> >---------------------------(end of broadcast)--= +------------------------- +
> >TIP 2: you can get off all lists at once with t= +he unregister command +
> >    (send "unregister YourE= +mailAddressHere" to majordomo@postgresql.org) +
> > +
> > +
> +
> +

+ +

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

+ +

         &nb= +sp;     http://www.postgresql.org/docs/faqs/FAQ.html +

+ + + +------_=_NextPart_001_01C45EBF.DDF1C3B0-- + +From pgsql-performance-owner@postgresql.org Wed Jun 30 14:46:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 90C7FD1B2A6 + for ; + Wed, 30 Jun 2004 14:07: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 83299-06 + for ; + Wed, 30 Jun 2004 17:06:59 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B6B9D1B182 + for ; + Wed, 30 Jun 2004 14:06:57 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5UH6vKs010245; + Wed, 30 Jun 2004 13:06:57 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: reindex and copy - deadlock? +In-reply-to: <20040630161746.10572.qmail@web13121.mail.yahoo.com> +References: <20040630161746.10572.qmail@web13121.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Wed, 30 Jun 2004 09:17:46 -0700" +Date: Wed, 30 Jun 2004 13:06:57 -0400 +Message-ID: <10244.1088615217@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/328 +X-Sequence-Number: 7386 + +Litao Wu writes: +> Our PG version is 7.3.2. + +Hmm. On general principles you should be using 7.3.6, but I do not see +anything in the 7.3.* change logs that looks very likely to cure this. + +> The copy process is always there. Besides copy +> process, there are many select processes wait also +> (it is understandable only when reindex, +> but how come selects wait when drop/create index? + +DROP INDEX would lock out selects (it has no other way to be sure no +select is trying to *use* the index). Once you're past that, selects +would work, but if you try something like + begin; drop index; create index; commit; +then the drop's lock will be held till commit. + +I'm not sure about whether COPY is related. In your original post, the +COPY was waiting to acquire RowExclusiveLock on the table, so it hadn't +actually done anything yet and really couldn't be holding a buffer lock +AFAICS. + +> But one thing is sure: +> reindex or create index is granted lock while +> others wait. If reindex/create index is not +> the perpetrator, how can PG grants it lock +> but not others, like COPY? + +The point is that it's waiting for a lower-level lock (namely a buffer +LWLock). There's no deadlock detection for LWLocks, because they're not +supposed to be used in ways that could cause a deadlock. + +Assuming for the moment that indeed this is a deadlock, you could learn +something the next time it happens with some manual investigation. +You'll need to keep using the debug-enabled build. When you next get a +lockup, proceed as follows: + +1. Attach to the REINDEX or CREATE INDEX process and find out which +LWLock number it is blocked on. (This is the lockid argument of +LWLockAcquire, 21335 in your trace of today.) + +2. For *each* live backend process (including the REINDEX itself), +attach with gdb and look at the held-locks status of lwlock.c. +This would go something like + + gdb> p num_held_lwlocks +if greater than zero: + gdb> x/10d held_lwlocks +(replace "10" by the value of num_held_lwlocks) + +If you find a backend that is holding the lock number that REINDEX +wants, print out its call stack with "bt", and look in pg_locks to see +what lockmanager locks it is holding or waiting for. If you do not find +one, then the deadlock theory is disproved, and we're back to square +one. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Jun 30 15:45:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C9177D1B211 + for ; + Wed, 30 Jun 2004 15:45: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 32474-04 + for ; + Wed, 30 Jun 2004 18:45:20 +0000 (GMT) +Received: from web13122.mail.yahoo.com (web13122.mail.yahoo.com + [216.136.174.126]) + by svr1.postgresql.org (Postfix) with SMTP id 4C651D1B182 + for ; + Wed, 30 Jun 2004 15:45:17 -0300 (ADT) +Message-ID: <20040630184518.89025.qmail@web13122.mail.yahoo.com> +Received: from [63.78.248.48] by web13122.mail.yahoo.com via HTTP; + Wed, 30 Jun 2004 11:45:18 PDT +Date: Wed, 30 Jun 2004 11:45:18 -0700 (PDT) +From: Litao Wu +Subject: Re: reindex and copy - deadlock? +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <10244.1088615217@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/329 +X-Sequence-Number: 7387 + +Thanks! + +OK, we will do this exceise next time. + +TSince there are multiple databases and +there are 170 postgres processes this morning, +60 of them are access the problem database, +and 57 of 60 are non-idle. + +We only need to gdb those 57 processes, or +we need gdb 60 or 170? + +Thanks again! + +--- Tom Lane wrote: +> Litao Wu writes: +> > Our PG version is 7.3.2. +> +> Hmm. On general principles you should be using +> 7.3.6, but I do not see +> anything in the 7.3.* change logs that looks very +> likely to cure this. +> +> > The copy process is always there. Besides copy +> > process, there are many select processes wait also +> > (it is understandable only when reindex, +> > but how come selects wait when drop/create index? +> +> DROP INDEX would lock out selects (it has no other +> way to be sure no +> select is trying to *use* the index). Once you're +> past that, selects +> would work, but if you try something like +> begin; drop index; create index; commit; +> then the drop's lock will be held till commit. +> +> I'm not sure about whether COPY is related. In your +> original post, the +> COPY was waiting to acquire RowExclusiveLock on the +> table, so it hadn't +> actually done anything yet and really couldn't be +> holding a buffer lock +> AFAICS. +> +> > But one thing is sure: +> > reindex or create index is granted lock while +> > others wait. If reindex/create index is not +> > the perpetrator, how can PG grants it lock +> > but not others, like COPY? +> +> The point is that it's waiting for a lower-level +> lock (namely a buffer +> LWLock). There's no deadlock detection for LWLocks, +> because they're not +> supposed to be used in ways that could cause a +> deadlock. +> +> Assuming for the moment that indeed this is a +> deadlock, you could learn +> something the next time it happens with some manual +> investigation. +> You'll need to keep using the debug-enabled build. +> When you next get a +> lockup, proceed as follows: +> +> 1. Attach to the REINDEX or CREATE INDEX process and +> find out which +> LWLock number it is blocked on. (This is the lockid +> argument of +> LWLockAcquire, 21335 in your trace of today.) +> +> 2. For *each* live backend process (including the +> REINDEX itself), +> attach with gdb and look at the held-locks status of +> lwlock.c. +> This would go something like +> +> gdb> p num_held_lwlocks +> if greater than zero: +> gdb> x/10d held_lwlocks +> (replace "10" by the value of num_held_lwlocks) +> +> If you find a backend that is holding the lock +> number that REINDEX +> wants, print out its call stack with "bt", and look +> in pg_locks to see +> what lockmanager locks it is holding or waiting for. +> If you do not find +> one, then the deadlock theory is disproved, and +> we're back to square +> one. +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + + + + +__________________________________ +Do you Yahoo!? +New and Improved Yahoo! Mail - Send 10MB messages! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Wed Jun 30 16:33:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E5B50D1B1B6 + for ; + Wed, 30 Jun 2004 16:33: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 56351-04 + for ; + Wed, 30 Jun 2004 19:33:05 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 02482D1B18C + for ; + Wed, 30 Jun 2004 16:33:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i5UJX3HK013106; + Wed, 30 Jun 2004 15:33:03 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: reindex and copy - deadlock? +In-reply-to: <20040630184518.89025.qmail@web13122.mail.yahoo.com> +References: <20040630184518.89025.qmail@web13122.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Wed, 30 Jun 2004 11:45:18 -0700" +Date: Wed, 30 Jun 2004 15:33:02 -0400 +Message-ID: <13105.1088623982@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200406/330 +X-Sequence-Number: 7388 + +Litao Wu writes: +> Since there are multiple databases and +> there are 170 postgres processes this morning, +> 60 of them are access the problem database, +> and 57 of 60 are non-idle. + +> We only need to gdb those 57 processes, or +> we need gdb 60 or 170? + +Potentially the deadlock could be anywhere :-(. You should definitely +not assume it must be one of the processes connected to the problem +database, because the buffer pool is cluster-wide. + +Might be worth setting up a shell script to help. + + regards, tom lane +