From pgsql-performance-owner@postgresql.org Sat Mar 1 18:30:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4F28D474E44 for ; Sat, 1 Mar 2003 18:30:35 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 48941-06 for ; Sat, 1 Mar 2003 18:30:06 -0500 (EST) Received: from 61.59.32.52 (unknown [61.236.232.12]) by postgresql.org (Postfix) with SMTP id B295E474E61 for ; Sat, 1 Mar 2003 18:29:36 -0500 (EST) Received: from unknown (185.176.53.24) by rly-yk05.mx.aol.com with local; Mar, 01 2003 4:08:32 PM +1200 Received: from [174.223.185.169] by rly-xl05.mx.aol.com with NNFMP; Mar, 01 2003 3:33:34 PM -0100 From: Orito To: Elena@postgresql.org Subject: Re: ABOUT YOUR CREDIT........... eyr Mime-Version: 1.0 Content-Type: text/html; charset="iso-8859-1" Date: Sat, 1 Mar 2003 17:36:46 -0600 X-Mailer: Microsoft Outlook Express 5.50.4133.2400 Message-Id: <20030301232936.B295E474E61@postgresql.org> X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/1 X-Sequence-Number: 1299

We can fix your credit. We are very successful at getting bankruptcies, judgments, tax liens, foreclosures, late payments, charge-offs, repossessions, and even student loans removed from a persons credit report. To find out more go to http://www.cjlinc.net.

If you no longer want to receive information from us just go to tallrhe@cs.com.

  jppqcwvxbucxknjykmaickbeaprregekfrvwt From pgsql-performance-owner@postgresql.org Tue Mar 4 00:48:50 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8930C475F18 for ; Tue, 4 Mar 2003 00:48:47 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 63151-05 for ; Tue, 4 Mar 2003 00:48:45 -0500 (EST) Received: from kootenai.aretesystems.com (h-66-166-23-162.SNVACAID.covad.net [66.166.23.162]) by postgresql.org (Postfix) with ESMTP id 5A4F8475EF7 for ; Tue, 4 Mar 2003 00:48:45 -0500 (EST) Received: from sinopah.home.aretesystems.com ([192.168.10.10] helo=aretesystems.com) by kootenai.aretesystems.com with asmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.10) id HB7MTE-000JZJ-00 for pgsql-performance@postgresql.org; Mon, 03 Mar 2003 21:48:50 -0800 Date: Mon, 3 Mar 2003 21:48:49 -0800 Mime-Version: 1.0 (Apple Message framework v551) Content-Type: text/plain; delsp=yes; charset=US-ASCII; format=flowed Subject: Slow performance with join on many fields From: Alex Johnson To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/2 X-Sequence-Number: 1300 Hello- I'm working with a MS Access database that a client wants to turn into a multi-user database. I'm evaluating PostgreSQL for that purpose (I'd _really_ like to be able to recommend and open-source solution to them). However, I'm running into a performance-related issue that I was hoping this list could help me with. I have three tables: tbl_samples (~2000 rows), tbl_tests (~4000 rows), and tbl_results (~20,000 rows), with one-to-many relationships between them (cascading, in the order given - table definitions are attached below). I'm looking at the following query that joins these three tables: SELECT tbl_samples.station_id, tbl_samples.samp_date, tbl_samples.matrix, tbl_samples.samp_type_code, tbl_samples.samp_no, tbl_samples.field_samp_id, tbl_tests.method, tbl_tests.lab, tbl_results.par_code, tbl_results.val_qualifier, tbl_results.value, tbl_results.units, tbl_results.mdl, tbl_results.date_anal FROM (tbl_samples INNER JOIN tbl_tests USING (station_id, samp_date, matrix, samp_type_code, samp_no, samp_bdepth, samp_edepth) ) INNER JOIN tbl_results USING (station_id, samp_date, matrix, samp_type_code, samp_no, samp_bdepth, samp_edepth, method); In Access, this query runs in about a second. In PostgreSQL on the same machine, it takes about 12-15 seconds for the initial rows to be returned, and about 45 seconds to returns all rows. (This is consistent whether I use psql, use the pgAdminII SQL window, or use Access with the ODBC driver.) This is the output from EXPLAIN: Nested Loop (cost=437.73..1216.02 rows=1 width=245) Join Filter: ("outer".method = "inner".method) -> Merge Join (cost=437.73..461.38 rows=125 width=131) Merge Cond: (("outer".matrix = "inner".matrix) AND ("outer".samp_edepth = "inner".samp_edepth) AND ("outer".samp_bdepth = "inner".samp_bdepth) AND ("outer".samp_no = "inner".samp_no) AND ("outer".samp_type_code = "inner".samp_type_code) AND ("outer".samp_date = "inner".samp_date) AND ("outer".station_id = "inner".station_id)) -> Sort (cost=117.51..120.77 rows=1304 width=63) Sort Key: tbl_samples.matrix, tbl_samples.samp_edepth, tbl_samples.samp_bdepth, tbl_samples.samp_no, tbl_samples.samp_type_code, tbl_samples.samp_date, tbl_samples.station_id -> Seq Scan on tbl_samples (cost=0.00..50.04 rows=1304 width=63) -> Sort (cost=320.22..328.68 rows=3384 width=68) Sort Key: tbl_tests.matrix, tbl_tests.samp_edepth, tbl_tests.samp_bdepth, tbl_tests.samp_no, tbl_tests.samp_type_code, tbl_tests.samp_date, tbl_tests.station_id -> Seq Scan on tbl_tests (cost=0.00..121.84 rows=3384 width=68) -> Index Scan using tbl_results_pkey on tbl_results (cost=0.00..5.99 rows=1 width=114) Index Cond: (("outer".station_id = tbl_results.station_id) AND ("outer".samp_date = tbl_results.samp_date) AND ("outer".matrix = tbl_results.matrix) AND ("outer".samp_type_code = tbl_results.samp_type_code) AND ("outer".samp_no = tbl_results.samp_no) AND ("outer".samp_bdepth = tbl_results.samp_bdepth) AND ("outer".samp_edepth = tbl_results.samp_edepth)) I've done the following to try to improve performance: -postgresql.conf: increased shared_buffers to 384 increased sort_mem to 2048 -clustered all tables on the pkey index -made sure the joined fields are indexed (they are through the pkeys) As a note, vm_stat shows no paging while the query is run. Also, I realize that these keys are large (as in the number of fields). I'll be condensing these down to sequential IDs (e.g. a SERIAL type) for a further test, but I'm curious why Access seems to outperform Postgres in this instance. My question is, am I missing anything? PostgreSQL will be a hard sell if they have to take a performance hit. Thanks for any suggestions you can provide. Sorry for the long e-mail, but I wanted to provide enough info to diagnose the issue. Alex Johnson ________________________________ Table defs: CREATE TABLE tbl_Samples ( Station_ID VARCHAR (25) NOT NULL, Samp_Date TIMESTAMP WITH TIME ZONE NOT NULL, Matrix VARCHAR (10) NOT NULL, Samp_Type_Code VARCHAR (5) NOT NULL, Samp_No INTEGER NOT NULL, Samp_BDepth DOUBLE PRECISION NOT NULL, Samp_EDepth DOUBLE PRECISION NOT NULL, Depth_units VARCHAR (3), Samp_start_time TIME, Samp_end_time TIME, Field_Samp_ID VARCHAR (20), Lab_Samp_ID VARCHAR (20), Samp_Meth VARCHAR (20), ...snip... PRIMARY KEY (Station_ID,Samp_Date,Matrix,Samp_Type_Code,Samp_No,Samp_BDepth,Samp_EDe pth) ); CREATE TABLE tbl_Tests ( Station_ID VARCHAR (25) NOT NULL, Samp_Date TIMESTAMP WITH TIME ZONE NOT NULL, Matrix VARCHAR (10) NOT NULL, Samp_Type_Code VARCHAR (5) NOT NULL, Samp_No INTEGER NOT NULL, Samp_BDepth DOUBLE PRECISION NOT NULL, Samp_EDepth DOUBLE PRECISION NOT NULL, Method VARCHAR (50) NOT NULL, Lab VARCHAR (10) NOT NULL, Date_Rec TIMESTAMP WITH TIME ZONE, ...snip... PRIMARY KEY (Station_ID,Samp_Date,Matrix,Samp_Type_Code,Samp_No,Samp_BDepth,Samp_EDe pth,Method) ); CREATE TABLE tbl_Results ( Station_ID VARCHAR (25) NOT NULL, Samp_Date TIMESTAMP WITH TIME ZONE NOT NULL, Matrix VARCHAR (10) NOT NULL, Samp_Type_Code VARCHAR (5) NOT NULL, Samp_No INTEGER NOT NULL, Samp_BDepth DOUBLE PRECISION NOT NULL, Samp_EDepth DOUBLE PRECISION NOT NULL, Method VARCHAR (50) NOT NULL, Par_code VARCHAR (50) NOT NULL, Val_Qualifier VARCHAR (50) NOT NULL, Value DECIMAL (20,9) NOT NULL, ...snip... PRIMARY KEY (Station_ID,Samp_Date,Matrix,Samp_Type_Code,Samp_No,Samp_BDepth,Samp_EDe pth,Method,Par_code) ); ALTER TABLE tbl_Tests ADD CONSTRAINT REL_1 FOREIGN KEY (Station_ID,Samp_Date,Matrix,Samp_Type_Code,Samp_No,Samp_BDepth,Samp_EDe pth) REFERENCES tbl_Samples ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE tbl_Results ADD CONSTRAINT REL_2 FOREIGN KEY (Station_ID,Samp_Date,Matrix,Samp_Type_Code,Samp_No,Samp_BDepth,Samp_EDe pth,Method) REFERENCES tbl_Tests ON DELETE CASCADE ON UPDATE CASCADE; ________________________________________________________________________ ______ A r e t e S y s t e m s Alexander M. Johnson, P.E. From pgsql-performance-owner@postgresql.org Tue Mar 4 01:27:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9CF5B475F28 for ; Tue, 4 Mar 2003 01:27:48 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 78096-05 for ; Tue, 4 Mar 2003 01:27:44 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id DF0DE475F23 for ; Tue, 4 Mar 2003 01:27:43 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h246Rgx6020976; Tue, 4 Mar 2003 01:27:42 -0500 (EST) To: Alex Johnson Cc: pgsql-performance@postgresql.org Subject: Re: Slow performance with join on many fields In-reply-to: References: Comments: In-reply-to Alex Johnson message dated "Mon, 03 Mar 2003 21:48:49 -0800" Date: Tue, 04 Mar 2003 01:27:42 -0500 Message-ID: <20975.1046759262@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/3 X-Sequence-Number: 1301 Alex Johnson writes: > I'm looking at the following query that joins these three > tables: > SELECT ... > FROM > (tbl_samples > INNER JOIN tbl_tests USING ... > ) > INNER JOIN tbl_results USING ... You're forcing the join order; perhaps another order is preferable? See http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/explicit-joins.html > This is the output from EXPLAIN: EXPLAIN ANALYZE output would've been more useful (it would have shown whether a different join order would be better, for one thing). > I've done the following to try to improve performance: > increased shared_buffers to 384 That's on the picayune side yet. 1000 buffers or so is where you want to be, I think. Also, have you run ANALYZE or VACUUM ANALYZE lately? regards, tom lane From pgsql-performance-owner@postgresql.org Tue Mar 4 02:46:42 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 03516475F81 for ; Tue, 4 Mar 2003 02:46:41 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 12093-08 for ; Tue, 4 Mar 2003 02:46:39 -0500 (EST) Received: from kootenai.aretesystems.com (h-66-166-23-162.SNVACAID.covad.net [66.166.23.162]) by postgresql.org (Postfix) with ESMTP id 540AC475FBD for ; Tue, 4 Mar 2003 02:46:39 -0500 (EST) Received: from sinopah.home.aretesystems.com ([192.168.10.10] helo=aretesystems.com) by kootenai.aretesystems.com with asmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.10) id HB7S9R-000K07-00; Mon, 03 Mar 2003 23:46:39 -0800 Date: Mon, 3 Mar 2003 23:46:38 -0800 Subject: Re: Slow performance with join on many fields Content-Type: text/plain; delsp=yes; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: pgsql-performance@postgresql.org To: Tom Lane From: Alex Johnson In-Reply-To: <20975.1046759262@sss.pgh.pa.us> Message-Id: <6E7231D8-4E15-11D7-85B6-000502FCE08D@aretesystems.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/4 X-Sequence-Number: 1302 Tom- Thanks for the speedy reply. > That's on the picayune side yet. 1000 buffers or so is where you want > to be, I think. Also, have you run ANALYZE or VACUUM ANALYZE lately? VACUUM ANALYSE did it.... (doh!...now I feel stupid). I had run VACUUM and VACUUM ANALYZE from pgAdmin, yesterday. After running it from the command line now, It's much improved (~ 2-3 secs). I'm now looking into getting my kernel to increase the SHMAX parameter so I can bump up the shared buffers some more. Thanks again for the speedy help, and sorry for the obvious goof. Alex Johnson ________________________________________________________________________ ______ A r e t e S y s t e m s Alexander Johnson, P.E. From pgsql-performance-owner@postgresql.org Tue Mar 4 09:44:50 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4DD5247611E for ; Tue, 4 Mar 2003 09:44:49 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 01446-10 for ; Tue, 4 Mar 2003 09:44:47 -0500 (EST) Received: from relay.firstnet.net.uk (inbound.firstnet.net.uk [212.103.224.21]) by postgresql.org (Postfix) with SMTP id 99B0447611C for ; Tue, 4 Mar 2003 09:44:46 -0500 (EST) Received: (qmail 18724 invoked from network); 4 Mar 2003 14:44:35 -0000 Received: from unknown (HELO paulspc) (62.105.89.252) by tulyar.first with SMTP; 4 Mar 2003 14:44:35 -0000 From: "Paul McKay" To: Subject: Slow query performance on large table Date: Tue, 4 Mar 2003 14:45:18 -0000 Message-ID: <000001c2e25c$ad506170$0c64a8c0@paulspc> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01C2E25C.AD51E810" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/5 X-Sequence-Number: 1303 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C2E25C.AD51E810 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, I am executing a query on a table: Table "public.measurement" Column | Type | Modifiers ------------+-----------------------+----------- assessment | integer | time | integer | value | character varying(50) | Indexes: idx_measurement_assessment btree (assessment), idx_measurement_time btree ("time") The primary key of the table is a combination of assessment and time, and there are indexes on both assessment and time. The query I am executing is Select time,value >From measurement Where assessment = ? And time between ? and ? This used to run like a rocket before my database got a little larger. There are now around 15 million rows in the table and it is taking a long time to execute queries that get a fair number of rows back (c.300) The database is 'VACUUM ANALYZED' regularly, and I've upped the shared buffers to a significant amount. I've tried it on various machine configurations now. A dual processor Linux/Intel Machine with 1G of Memory, (0.5G shared buffers). A single processor Linux/Intel Machine (0.25G shared buffers) , and a Solaris machine (0.25G shared buffers). I'm getting similar performance on all of them. Anybody see anything I've obviously done wrong? Any ways of improving the performance of this query? Thanks in advance. Paul McKay. ====================================== Paul Mckay Consultant Partner Servicing Division Clearwater-IT e:paul_mckay@clearwater-it.co.uk t:0161 877 6090 m: 07713 510946 ====================================== ------=_NextPart_000_0001_01C2E25C.AD51E810 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi,

 

I am executing a query on a table:

 

         &n= bsp; Table "public.measurement"

   Column   |         Type          | Modifiers

------------+-----------------------+-----------<= /font>

 assessment | integer           &n= bsp;   |

 time       | integer           &n= bsp;   |

 value      | character varying(50) |

Indexes: idx_measurement_assessment btree (assessment),<= /span>

         idx_mea= surement_time btree ("time")

 

The primary key of the table is a combination of assessm= ent and time, and there are indexes on both assessment and time.<= /p>

 

The query I am executing is

 

Select time,value

From measurement

Where assessment =3D ?

And time between ? and ?

 

This used to run like a rocket before my database got a little larger.  There are now around 15 million rows in the table and = it is taking a long time to execute queries that get a fair number of rows back (c.300)

 

The database is  ‘VACUUM ANALYZED’ regu= larly, and I’ve upped the shared buffers to a significant amount.

 

I’ve tried it on various machine configurations no= w. A dual processor Linux/Intel Machine with 1G of Memory, (0.5G shared buffers).  A single processor Linux/Intel Machine (0.25G shared buffer= s) , and a Solaris machine (0.25G shared buffers).  I’m getting simil= ar performance on all of them.

 

Anybody see anything I’ve obviously done wrong?&nb= sp; Any ways of improving the performance of this query?

 

Thanks in advance.

 

Paul McKay.

 

 

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<= /p>

Paul Mckay

Consultant Partner

Servicing Division

Clearwater-IT

e:paul_mckay@clearwater-it.co.u= k

t:0161 877 6090

m: 07713 510946

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<= /p>

 

------=_NextPart_000_0001_01C2E25C.AD51E810-- From pgsql-performance-owner@postgresql.org Tue Mar 4 10:09:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 15934476149 for ; Tue, 4 Mar 2003 10:09:50 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 06483-08 for ; Tue, 4 Mar 2003 10:09:33 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 320D7475DBD for ; Tue, 4 Mar 2003 10:09:33 -0500 (EST) Received: from klaster.net (pc139.krakow.cvx.ppp.tpnet.pl [213.76.38.139]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 5C1C02B896; Tue, 4 Mar 2003 16:07:47 +0100 (CET) Message-ID: <3E64C1BF.4080704@klaster.net> Date: Tue, 04 Mar 2003 16:09:51 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Paul McKay Cc: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table References: <000001c2e25c$ad506170$0c64a8c0@paulspc> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/6 X-Sequence-Number: 1304 Paul McKay wrote: > Hi, > > > > I am executing a query on a table: > > > > Table "public.measurement" > > Column | Type | Modifiers > > ------------+-----------------------+----------- > > assessment | integer | > > time | integer | > > value | character varying(50) | > > Indexes: idx_measurement_assessment btree (assessment), > > idx_measurement_time btree ("time") > > > > The primary key of the table is a combination of assessment and time, > and there are indexes on both assessment and time. > > > > The query I am executing is > > > > Select time,value > > From measurement > > Where assessment = ? > > And time between ? and ? Changing 2 indexes into one both-fields index should improve performance much. create index ind_meas on measurement (assessment,time). Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Tue Mar 4 10:13:01 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3B3DA47611E for ; Tue, 4 Mar 2003 10:13:00 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 06483-10 for ; Tue, 4 Mar 2003 10:12:58 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 65BA2475DBD for ; Tue, 4 Mar 2003 10:12:58 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h24FD1x6023082; Tue, 4 Mar 2003 10:13:01 -0500 (EST) To: "Paul McKay" Cc: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table In-reply-to: <000001c2e25c$ad506170$0c64a8c0@paulspc> References: <000001c2e25c$ad506170$0c64a8c0@paulspc> Comments: In-reply-to "Paul McKay" message dated "Tue, 04 Mar 2003 14:45:18 +0000" Date: Tue, 04 Mar 2003 10:13:01 -0500 Message-ID: <23081.1046790781@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/7 X-Sequence-Number: 1305 "Paul McKay" writes: > The query I am executing is > Select time,value > From measurement > Where assessment = ? > And time between ? and ? EXPLAIN ANALYZE would help you investigate this. Is it using an indexscan? On which index? Does forcing use of the other index (by temporarily dropping the preferred one) improve matters? Possibly a two-column index on both assessment and time would be an improvement, but it's hard to guess without knowing anything about the selectivity of the two WHERE clauses. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Mar 4 10:15:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A0ED0476176 for ; Tue, 4 Mar 2003 10:15:29 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 06985-10 for ; Tue, 4 Mar 2003 10:15:25 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id E999A476170 for ; Tue, 4 Mar 2003 10:15:24 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18qE8f-0000BO-00 for ; Tue, 04 Mar 2003 10:15:29 -0500 Date: Tue, 4 Mar 2003 10:15:29 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table Message-ID: <20030304101529.D32416@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <000001c2e25c$ad506170$0c64a8c0@paulspc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <000001c2e25c$ad506170$0c64a8c0@paulspc>; from paul_mckay@clearwater-it.co.uk on Tue, Mar 04, 2003 at 02:45:18PM -0000 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/8 X-Sequence-Number: 1306 On Tue, Mar 04, 2003 at 02:45:18PM -0000, Paul McKay wrote: > > Select time,value > > >From measurement > > Where assessment = ? > > And time between ? and ? > Please run this with EXPLAIN ANALYSE with values that slow the query down. By bet is that you have an index which needs wider statistics setting on the column to be useful, but without the output from EXAPLIN ANALYSE it'll be hard to tell. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Mar 4 11:10:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D84DC476130 for ; Tue, 4 Mar 2003 11:10:45 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 20395-06 for ; Tue, 4 Mar 2003 11:10:41 -0500 (EST) Received: from relay.firstnet.net.uk (inbound.firstnet.net.uk [212.103.224.21]) by postgresql.org (Postfix) with SMTP id 0A415475ED1 for ; Tue, 4 Mar 2003 11:10:41 -0500 (EST) Received: (qmail 23261 invoked from network); 4 Mar 2003 16:10:37 -0000 Received: from unknown (HELO paulspc) (62.105.89.252) by meld.first with SMTP; 4 Mar 2003 16:10:37 -0000 From: "Paul McKay" To: "'Tom Lane'" Cc: Subject: Re: Slow query performance on large table Date: Tue, 4 Mar 2003 16:11:20 -0000 Message-ID: <000001c2e268$b1e47210$0c64a8c0@paulspc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 Importance: Normal In-Reply-To: <23081.1046790781@sss.pgh.pa.us> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/9 X-Sequence-Number: 1307 The results were clearview=# explain analyse clearview-# select assessment,time clearview-# from measurement clearview-# where assessment = 53661 clearview-# and time between 1046184261 and 1046335461; NOTICE: QUERY PLAN: Index Scan using idx_measurement_assessment on measurement (cost=0.00..34668.61 rows=261 width=8) (actual time=26128.07..220584.69 rows=503 loops=1) Total runtime: 220587.06 msec EXPLAIN After adding the index kindly suggested by yourself and Tomasz I get, clearview=# explain analyse clearview-# select assessment,time clearview-# from measurement clearview-# where assessment = 53661 clearview-# and time between 1046184261 and 1046335461; NOTICE: QUERY PLAN: Index Scan using ind_measurement_ass_time on measurement (cost=0.00..1026.92 rows=261 width=8) (actual time=15.37..350.46 rows=503 loops=1) Total runtime: 350.82 msec EXPLAIN I vaguely recall doing a bit of a reorganize on this database a bit back and it looks like I lost the primary Key index. No wonder it was going slow. Thanks a lot for your help. Paul Mckay. ====================================== Paul Mckay Consultant Partner Servicing Division Clearwater-IT e:paul_mckay@clearwater-it.co.uk t:0161 877 6090 m: 07713 510946 ====================================== -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: 04 March 2003 15:13 To: Paul McKay Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query performance on large table "Paul McKay" writes: > The query I am executing is > Select time,value > From measurement > Where assessment = ? > And time between ? and ? EXPLAIN ANALYZE would help you investigate this. Is it using an indexscan? On which index? Does forcing use of the other index (by temporarily dropping the preferred one) improve matters? Possibly a two-column index on both assessment and time would be an improvement, but it's hard to guess without knowing anything about the selectivity of the two WHERE clauses. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Mar 4 11:38:41 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 21801476154 for ; Tue, 4 Mar 2003 11:38:39 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 29649-05 for ; Tue, 4 Mar 2003 11:38:37 -0500 (EST) Received: from smtp.web.de (smtp02.web.de [217.72.192.151]) by postgresql.org (Postfix) with ESMTP id 5E457475ED1 for ; Tue, 4 Mar 2003 11:38:37 -0500 (EST) Received: from p508186ad.dip0.t-ipconnect.de ([80.129.134.173] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 18qFRA-0002Xu-00 for pgsql-performance@postgresql.org; Tue, 04 Mar 2003 17:38:40 +0100 Message-ID: <3E64D694.9050309@web.de> Date: Tue, 04 Mar 2003 17:38:44 +0100 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table References: <000001c2e25c$ad506170$0c64a8c0@paulspc> <23081.1046790781@sss.pgh.pa.us> In-Reply-To: <23081.1046790781@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/10 X-Sequence-Number: 1308 Tom Lane wrote: >"Paul McKay" writes: > > >>The query I am executing is >>Select time,value >>From measurement >>Where assessment = ? >>And time between ? and ? >> >> > >EXPLAIN ANALYZE would help you investigate this. Is it using an >indexscan? On which index? Does forcing use of the other index >(by temporarily dropping the preferred one) improve matters? > >Possibly a two-column index on both assessment and time would be >an improvement, but it's hard to guess without knowing anything >about the selectivity of the two WHERE clauses. > > regards, tom lane > >---------------------------(end of broadcast)--------------------------- > > Tom, does this mean that a primary key alone might not be enough? As far as I understood Paul, the PK looks quite as the newly created index does, so "create index ind_meas on measurement (assessment,time)" should perform the same as "... primary key(assessment,time)". Do possibly non-optimal indices (only assessment, only time as Paul described earlier) screw up the optimizer, igoring the better option usiing the PK? Obviously, the index used should be combined of (assessment,time) but IMHO a PK should be enough. regards, Andreas From pgsql-performance-owner@postgresql.org Tue Mar 4 12:02:41 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7CFF947619B for ; Tue, 4 Mar 2003 12:02:40 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 36044-05 for ; Tue, 4 Mar 2003 12:02:39 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id 69F8F476154 for ; Tue, 4 Mar 2003 12:02:37 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h24HWV6P023850; Tue, 4 Mar 2003 12:32:33 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id h24H2Up03967; Tue, 4 Mar 2003 12:02:31 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id F3HTH0NK; Tue, 4 Mar 2003 12:02:29 -0500 Subject: Re: Slow query performance on large table From: Robert Treat To: Paul McKay Cc: "'Tom Lane'" , pgsql-performance@postgresql.org In-Reply-To: <000001c2e268$b1e47210$0c64a8c0@paulspc> References: <000001c2e268$b1e47210$0c64a8c0@paulspc> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 04 Mar 2003 12:02:29 -0500 Message-Id: <1046797349.16957.20.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/11 X-Sequence-Number: 1309 On Tue, 2003-03-04 at 11:11, Paul McKay wrote: > The results were > > clearview=# explain analyse > clearview-# select assessment,time > clearview-# from measurement > clearview-# where assessment = 53661 > clearview-# and time between 1046184261 and 1046335461; > > NOTICE: QUERY PLAN: > > Index Scan using idx_measurement_assessment on measurement > (cost=0.00..34668.61 rows=261 width=8) (actual time=26128.07..220584.69 > rows=503 loops=1) > Total runtime: 220587.06 msec > > EXPLAIN > > After adding the index kindly suggested by yourself and Tomasz I get, > > clearview=# explain analyse > clearview-# select assessment,time > clearview-# from measurement > clearview-# where assessment = 53661 > clearview-# and time between 1046184261 and 1046335461; > NOTICE: QUERY PLAN: > > Index Scan using ind_measurement_ass_time on measurement > (cost=0.00..1026.92 rows=261 width=8) (actual time=15.37..350.46 > rows=503 loops=1) > Total runtime: 350.82 msec > > EXPLAIN > > > I vaguely recall doing a bit of a reorganize on this database a bit back > and it looks like I lost the primary Key index. No wonder it was going > slow. > Maybe it's just me, but I get the feeling you need to work some regular reindexing into your maintenance schedule. Given your query is using between, I don't think it would use the index on the time field anyway (and explain analyze seems to be supporting this). Rewrite it so that you have a and time > foo and time < bar and I think you'll see a difference. With that in mind, I think your speedier query results are due more to having a non-bloated index freshly created than the fact that it being a dual column index. Robert Treat From pgsql-performance-owner@postgresql.org Tue Mar 4 12:15:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E091B476228 for ; Tue, 4 Mar 2003 12:15:25 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 36450-08 for ; Tue, 4 Mar 2003 12:15:24 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 1B372476224 for ; Tue, 4 Mar 2003 12:15:24 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2879411; Tue, 04 Mar 2003 09:15:13 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Paul McKay" , "'Tom Lane'" Subject: Re: Slow query performance on large table Date: Tue, 4 Mar 2003 09:14:44 -0800 User-Agent: KMail/1.4.3 Cc: References: <000001c2e268$b1e47210$0c64a8c0@paulspc> In-Reply-To: <000001c2e268$b1e47210$0c64a8c0@paulspc> MIME-Version: 1.0 Message-Id: <200303040914.44390.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/12 X-Sequence-Number: 1310 Paul, > Index Scan using idx_measurement_assessment on measurement > (cost=3D0.00..34668.61 rows=3D261 width=3D8) (actual time=3D26128.07..220= 584.69 > rows=3D503 loops=3D1) > Total runtime: 220587.06 msec These query results say to me that you need to do both a VACUUM FULL and a= =20 REINDEX on this table. The 26-second delay before returning the first row= =20 says "table/index with lots of dead pages" to me. For the future, you should consider dramatically increasing your FSM settin= gs=20 and working a regular VACUUM FULL and REINDEX into your maintainence jobs. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Mar 4 12:18:25 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7F4D74761D8 for ; Tue, 4 Mar 2003 12:18:24 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 38166-09 for ; Tue, 4 Mar 2003 12:18:19 -0500 (EST) Received: from relay.firstnet.net.uk (inbound.firstnet.net.uk [212.103.224.21]) by postgresql.org (Postfix) with SMTP id 1A66B4761C4 for ; Tue, 4 Mar 2003 12:18:19 -0500 (EST) Received: (qmail 2563 invoked from network); 4 Mar 2003 17:18:20 -0000 Received: from unknown (HELO paulspc) (62.105.89.252) by meld.first with SMTP; 4 Mar 2003 17:18:20 -0000 From: "Paul McKay" To: "'Robert Treat'" Cc: "'Tom Lane'" , Subject: Re: Slow query performance on large table Date: Tue, 4 Mar 2003 17:19:03 -0000 Message-ID: <000601c2e272$27985900$0c64a8c0@paulspc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 Importance: Normal In-Reply-To: <1046797349.16957.20.camel@camel> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/13 X-Sequence-Number: 1311 I used the between .. and in a vain attempt to improve performance! Running with < and > improves the performance again by about 10 times. The explain's below were ran on a test server I was using (not the live server) where I had recreated the database in order to investigate matters, so all the indexes were newly created anyway. The dual column index was the key (literally). ====================================== Paul Mckay Consultant Partner Servicing Division Clearwater-IT e:paul_mckay@clearwater-it.co.uk t:0161 877 6090 m: 07713 510946 ====================================== -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Robert Treat Sent: 04 March 2003 17:02 To: Paul McKay Cc: 'Tom Lane'; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query performance on large table On Tue, 2003-03-04 at 11:11, Paul McKay wrote: > The results were > > clearview=# explain analyse > clearview-# select assessment,time > clearview-# from measurement > clearview-# where assessment = 53661 > clearview-# and time between 1046184261 and 1046335461; > > NOTICE: QUERY PLAN: > > Index Scan using idx_measurement_assessment on measurement > (cost=0.00..34668.61 rows=261 width=8) (actual time=26128.07..220584.69 > rows=503 loops=1) > Total runtime: 220587.06 msec > > EXPLAIN > > After adding the index kindly suggested by yourself and Tomasz I get, > > clearview=# explain analyse > clearview-# select assessment,time > clearview-# from measurement > clearview-# where assessment = 53661 > clearview-# and time between 1046184261 and 1046335461; > NOTICE: QUERY PLAN: > > Index Scan using ind_measurement_ass_time on measurement > (cost=0.00..1026.92 rows=261 width=8) (actual time=15.37..350.46 > rows=503 loops=1) > Total runtime: 350.82 msec > > EXPLAIN > > > I vaguely recall doing a bit of a reorganize on this database a bit back > and it looks like I lost the primary Key index. No wonder it was going > slow. > Maybe it's just me, but I get the feeling you need to work some regular reindexing into your maintenance schedule. Given your query is using between, I don't think it would use the index on the time field anyway (and explain analyze seems to be supporting this). Rewrite it so that you have a and time > foo and time < bar and I think you'll see a difference. With that in mind, I think your speedier query results are due more to having a non-bloated index freshly created than the fact that it being a dual column index. Robert Treat ---------------------------(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 Mar 4 12:20:31 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D108B4761AD for ; Tue, 4 Mar 2003 12:20:29 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 40204-07 for ; Tue, 4 Mar 2003 12:20:27 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D4CAE476224 for ; Tue, 4 Mar 2003 12:20:22 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h24HKQx6025726; Tue, 4 Mar 2003 12:20:26 -0500 (EST) To: Robert Treat Cc: Paul McKay , pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table In-reply-to: <1046797349.16957.20.camel@camel> References: <000001c2e268$b1e47210$0c64a8c0@paulspc> <1046797349.16957.20.camel@camel> Comments: In-reply-to Robert Treat message dated "04 Mar 2003 12:02:29 -0500" Date: Tue, 04 Mar 2003 12:20:26 -0500 Message-ID: <25725.1046798426@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/14 X-Sequence-Number: 1312 Robert Treat writes: > Maybe it's just me, but I get the feeling you need to work some regular > reindexing into your maintenance schedule. Or at least, more vacuuming... > Given your query is using > between, I don't think it would use the index on the time field anyway > (and explain analyze seems to be supporting this). Rewrite it so that > you have a and time > foo and time < bar and I think you'll see a > difference. No, you won't, because that's exactly what BETWEEN is. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Mar 4 12:20:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EB081476245 for ; Tue, 4 Mar 2003 12:20:44 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 40606-07 for ; Tue, 4 Mar 2003 12:20:33 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 0E542476243 for ; Tue, 4 Mar 2003 12:20:33 -0500 (EST) Received: from klaster.net (pa160.krakow.cvx.ppp.tpnet.pl [213.76.36.160]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 41A892B88F; Tue, 4 Mar 2003 18:18:52 +0100 (CET) Message-ID: <3E64E079.8050807@klaster.net> Date: Tue, 04 Mar 2003 18:20:57 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Andreas Pflug Cc: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table References: <000001c2e25c$ad506170$0c64a8c0@paulspc> <23081.1046790781@sss.pgh.pa.us> <3E64D694.9050309@web.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/15 X-Sequence-Number: 1313 Andreas Pflug wrote: > Tom, > > does this mean that a primary key alone might not be enough? As far as I > understood Paul, the PK looks quite as the newly created index does, so > "create index ind_meas on measurement (assessment,time)" should perform > the same as "... primary key(assessment,time)". > Do possibly non-optimal indices (only assessment, only time as Paul > described earlier) screw up the optimizer, igoring the better option > usiing the PK? Obviously, the index used should be combined of > (assessment,time) but IMHO a PK should be enough. > > regards, > > Andreas You are right - primary key should be ok, but Paul lost it. psql \d shows primary key indexes, but in this case there was no such primary key. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Tue Mar 4 12:30:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2785647629F for ; Tue, 4 Mar 2003 12:30:32 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 44002-07 for ; Tue, 4 Mar 2003 12:30:27 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 32B5A476291 for ; Tue, 4 Mar 2003 12:30:09 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2879453; Tue, 04 Mar 2003 09:29:58 -0800 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Organization: Aglio Database Solutions To: michael@linuxmagic.com Subject: PostgreSQL Performance Issue on Mail Server Date: Tue, 4 Mar 2003 09:29:28 -0800 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Message-Id: <200303040929.28743.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/17 X-Sequence-Number: 1315 Mr. Peddermors, "We have a postgres backend to our Mail Server product, and encountering=20 performance issues. Simple selects are taking 7-10 seconds..=20 We have of course applied all the suggested performance settings for Postgr= es,=20 (We are running on Debian Stable/Linux BTW) We moved the database to a standalone server, but still having the problems. With app 100,000 users authenticating pop mail, plus all of the smtp=20 verfications, the server is expected to perform snappy queries, else mail= =20 delivery/pickup is inordintaely long, or can't occur, and loads snowball.." I've cc'd your question to PGSQL-Performance list. Can you give us a f= ew=20 examples of EXPLAIN ANALYZE output for the queries which are running slow?= =20 (as well as the queries themeselves)? It's possible that you have a=20 platform issue on Debian, but far more likely that this is a garden-variety= =20 performance tuning issue. If this is a business-critical issue, I suggest that you retain a PostgreSQ= L=20 consultant, such as PostgreSQL Inc., myself, or Justin Clift. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Mar 4 12:29:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 404FC47625C for ; Tue, 4 Mar 2003 12:29:13 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 43465-04 for ; Tue, 4 Mar 2003 12:29:11 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 1FF0C47624C for ; Tue, 4 Mar 2003 12:29:11 -0500 (EST) Received: from klaster.net (pa160.krakow.cvx.ppp.tpnet.pl [213.76.36.160]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 774252B88F; Tue, 4 Mar 2003 18:27:29 +0100 (CET) Message-ID: <3E64E27A.3050708@klaster.net> Date: Tue, 04 Mar 2003 18:29:30 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Robert Treat Cc: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table References: <000001c2e268$b1e47210$0c64a8c0@paulspc> <1046797349.16957.20.camel@camel> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/16 X-Sequence-Number: 1314 Robert Treat wrote: > Maybe it's just me, but I get the feeling you need to work some regular > reindexing into your maintenance schedule. Given your query is using > between, I don't think it would use the index on the time field anyway > (and explain analyze seems to be supporting this). Rewrite it so that > you have a and time > foo and time < bar and I think you'll see a > difference. With that in mind, I think your speedier query results are > due more to having a non-bloated index freshly created than the fact > that it being a dual column index. > > Robert Treat Do you know anything about between, what should we know? I made some tests, and there was no noticable difference between them: pvwatch=# EXPLAIN analyze * from stats where hostid=1 and stp between 1 and 2; QUERY PLAN ---------------------------------------------------------------------------------------------------------------- Index Scan using ind_stats on stats (cost=0.00..6.01 rows=1 width=28) (actual time=0.00..0.00 rows=0 loops=1) Index Cond: ((hostid = 1) AND (stp >= 1) AND (stp <= 2)) Total runtime: 0.00 msec (3 rows) pvwatch=# EXPLAIN analyze SELECT * from stats where hostid=1 and stp> 1 and stp<2; QUERY PLAN ---------------------------------------------------------------------------------------------------------------- Index Scan using ind_stats on stats (cost=0.00..6.01 rows=1 width=28) (actual time=0.00..0.00 rows=0 loops=1) Index Cond: ((hostid = 1) AND (stp > 1) AND (stp < 2)) Total runtime: 0.00 msec (3 rows) Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Tue Mar 4 12:53:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 14443476262 for ; Tue, 4 Mar 2003 12:53:13 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 52076-04 for ; Tue, 4 Mar 2003 12:53:11 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 642AB476228 for ; Tue, 4 Mar 2003 12:53:08 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h24HrDx6027570; Tue, 4 Mar 2003 12:53:13 -0500 (EST) To: Andreas Pflug Cc: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table In-reply-to: <3E64D694.9050309@web.de> References: <000001c2e25c$ad506170$0c64a8c0@paulspc> <23081.1046790781@sss.pgh.pa.us> <3E64D694.9050309@web.de> Comments: In-reply-to Andreas Pflug message dated "Tue, 04 Mar 2003 17:38:44 +0100" Date: Tue, 04 Mar 2003 12:53:13 -0500 Message-ID: <27569.1046800393@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/18 X-Sequence-Number: 1316 Andreas Pflug writes: > "create index ind_meas on measurement (assessment,time)" should perform > the same as "... primary key(assessment,time)". Sure. > Do possibly non-optimal indices (only assessment, only time as Paul > described earlier) screw up the optimizer, igoring the better option > usiing the PK? One would like to think the optimizer will make the right choice. But using a two-column index just because it's there isn't necessarily the right choice. The two-column index will certainly be bulkier and more expensive to scan, so if there's a one-column index that's nearly as selective, it might be a better choice. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Mar 5 01:34:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A5212488412 for ; Tue, 4 Mar 2003 23:45:49 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 72029-02 for ; Tue, 4 Mar 2003 23:45:41 -0500 (EST) Received: from smtp.web.de (smtp03.web.de [217.72.192.158]) by postgresql.org (Postfix) with ESMTP id 0CCE34C9DF5 for ; Tue, 4 Mar 2003 16:45:30 -0500 (EST) Received: from p508187e9.dip0.t-ipconnect.de ([80.129.135.233] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 18qKE6-0004DD-00 for pgsql-performance@postgresql.org; Tue, 04 Mar 2003 22:45:31 +0100 Message-ID: <3E651E80.9070807@web.de> Date: Tue, 04 Mar 2003 22:45:36 +0100 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table References: <000001c2e25c$ad506170$0c64a8c0@paulspc> <23081.1046790781@sss.pgh.pa.us> <3E64D694.9050309@web.de> <3E64E079.8050807@klaster.net> In-Reply-To: <3E64E079.8050807@klaster.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/19 X-Sequence-Number: 1317 Tomasz Myrta wrote: > You are right - primary key should be ok, but Paul lost it. psql \d > shows primary key indexes, but in this case there was no such primary > key. > > Regards, > Tomasz Myrta > Ok, then my view of the world is all right again. Re Tom Lane > One would like to think the optimizer will make the right choice. But > using a two-column index just because it's there isn't necessarily the > right choice. The two-column index will certainly be bulkier and more > expensive to scan, so if there's a one-column index that's nearly as > selective, it might be a better choice. If I know that the access pattern of my app looks as if it will need a multipart index I should create it. If the optimizer finds out, a simpler one will fit better, all right, it knows better (if properly VACUUMed :-). But it's still good practice to offer complete indices. Will pgsql use a multipart index as efficiently for simpler queries as a shorter one covering only the first columns? In this example, the (assessment, time) index could replace the (accessment) index, but certainly not the (time) index. I tend to design longer indices with hopefully valuable columns. In this context: From MSSQL, I know "covering indices". Imagine a table t with many columns, and an index on (a,b,c). in MSSQL, SELECT c from t where (a ... AND b...) will use that index to retrieve the c column value also without touching the row data. In a sense, the index is used as an alternative table. Does pgsql profit from this kind of indices also? Regards, Andreas From pgsql-performance-owner@postgresql.org Wed Mar 5 04:49:58 2003 X-Original-To: pgsql-performance@postgresql.org Received: from relay.firstnet.net.uk (inbound.firstnet.net.uk [212.103.224.21]) by postgresql.org (Postfix) with SMTP id 37FC4476510 for ; Wed, 5 Mar 2003 04:47:16 -0500 (EST) Received: (qmail 21917 invoked from network); 5 Mar 2003 09:47:11 -0000 Received: from unknown (HELO paulspc) (62.105.89.252) by meld.first with SMTP; 5 Mar 2003 09:47:11 -0000 From: "Paul McKay" To: Subject: Re: Slow query performance on large table Date: Wed, 5 Mar 2003 09:47:51 -0000 Message-ID: <000001c2e2fc$4a13c200$0c64a8c0@paulspc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 Importance: Normal In-Reply-To: <3E64E079.8050807@klaster.net> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Archive-Number: 200303/20 X-Sequence-Number: 1318 Hopefully you guys can help me with another query I've got that's running slow. This time it's across two tables I have clearview=# \d panconversation Table "panconversation" Column | Type | Modifiers -------------+---------+----------- assessment | integer | not null interface | integer | source | integer | destination | integer | protocol | integer | Indexes: idx_panconversation_destination, idx_panconversation_interface, idx_panconversation_protocol, idx_panconversation_source Primary key: panconversation_pkey Unique keys: unq_panconversation Triggers: RI_ConstraintTrigger_52186648, RI_ConstraintTrigger_52186654, RI_ConstraintTrigger_52186660, RI_ConstraintTrigger_52186666 Primary key is assessment Along with the table I was dealing with before, with the index I'd mislaid put back in clearview=# \d measurement Table "measurement" Column | Type | Modifiers ------------+-----------------------+----------- assessment | integer | time | integer | value | character varying(50) | Indexes: idx_measurement_assessment, idx_measurement_time, ind_measurement_ass_time The 'explain analyse' of the query I am running is rather evil. clearview=# explain analyse select source,value clearview-# from measurement, PANConversation clearview-# where PANConversation.assessment = measurement.assessment clearview-# and Interface = 11 clearview-# and Time > 1046184261 and Time < 1046335461 clearview-# ; NOTICE: QUERY PLAN: Hash Join (cost=1532.83..345460.73 rows=75115 width=23) (actual time=1769.84..66687.11 rows=16094 loops=1) -> Seq Scan on measurement (cost=0.00..336706.07 rows=418859 width=15) (actual time=1280.11..59985.47 rows=455788 loops=1) -> Hash (cost=1498.21..1498.21 rows=13848 width=8) (actual time=253.49..253.49 rows=0 loops=1) -> Seq Scan on panconversation (cost=0.00..1498.21 rows=13848 width=8) (actual time=15.64..223.18 rows=13475 loops=1) Total runtime: 66694.82 msec EXPLAIN Anybody shed any light on why the indexes I created aren't being used, and I have these nasty sequential scans? Thanks in advance, Paul. ====================================== Paul Mckay Consultant Partner Servicing Division Clearwater-IT e:paul_mckay@clearwater-it.co.uk t:0161 877 6090 m: 07713 510946 ====================================== -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tomasz Myrta Sent: 04 March 2003 17:21 To: Andreas Pflug Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query performance on large table Andreas Pflug wrote: > Tom, > > does this mean that a primary key alone might not be enough? As far as I > understood Paul, the PK looks quite as the newly created index does, so > "create index ind_meas on measurement (assessment,time)" should perform > the same as "... primary key(assessment,time)". > Do possibly non-optimal indices (only assessment, only time as Paul > described earlier) screw up the optimizer, igoring the better option > usiing the PK? Obviously, the index used should be combined of > (assessment,time) but IMHO a PK should be enough. > > regards, > > Andreas You are right - primary key should be ok, but Paul lost it. psql \d shows primary key indexes, but in this case there was no such primary key. Regards, Tomasz Myrta ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Wed Mar 5 05:04:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 6657147682D for ; Wed, 5 Mar 2003 05:04:28 -0500 (EST) Received: from klaster.net (pi106.krakow.cvx.ppp.tpnet.pl [217.99.209.106]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id EC05E2B88F; Wed, 5 Mar 2003 11:02:30 +0100 (CET) Message-ID: <3E65CBBE.4090803@klaster.net> Date: Wed, 05 Mar 2003 11:04:46 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Paul McKay Cc: pgsql-performance@postgresql.org Subject: Re: Slow query performance on large table References: <000001c2e2fc$4a13c200$0c64a8c0@paulspc> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/21 X-Sequence-Number: 1319 Paul McKay wrote: > Hopefully you guys can help me with another query I've got that's > running slow. > > This time it's across two tables I have > > clearview=# \d panconversation > Table "panconversation" > Column | Type | Modifiers > -------------+---------+----------- > assessment | integer | not null > interface | integer | > source | integer | > destination | integer | > protocol | integer | > Indexes: idx_panconversation_destination, > idx_panconversation_interface, > idx_panconversation_protocol, > idx_panconversation_source > Primary key: panconversation_pkey > Unique keys: unq_panconversation > Triggers: RI_ConstraintTrigger_52186648, > RI_ConstraintTrigger_52186654, > RI_ConstraintTrigger_52186660, > RI_ConstraintTrigger_52186666 > > Primary key is assessment > > Along with the table I was dealing with before, with the index I'd > mislaid put back in > > clearview=# \d measurement > Table "measurement" > Column | Type | Modifiers > ------------+-----------------------+----------- > assessment | integer | > time | integer | > value | character varying(50) | > Indexes: idx_measurement_assessment, > idx_measurement_time, > ind_measurement_ass_time > > The 'explain analyse' of the query I am running is rather evil. > > clearview=# explain analyse select source,value > clearview-# from measurement, PANConversation > clearview-# where PANConversation.assessment = > measurement.assessment > clearview-# and Interface = 11 > clearview-# and Time > 1046184261 and Time < 1046335461 > clearview-# ; > NOTICE: QUERY PLAN: > > Hash Join (cost=1532.83..345460.73 rows=75115 width=23) (actual > time=1769.84..66687.11 rows=16094 loops=1) > -> Seq Scan on measurement (cost=0.00..336706.07 rows=418859 > width=15) (actual time=1280.11..59985.47 rows=455788 loops=1) > -> Hash (cost=1498.21..1498.21 rows=13848 width=8) (actual > time=253.49..253.49 rows=0 loops=1) > -> Seq Scan on panconversation (cost=0.00..1498.21 rows=13848 > width=8) (actual time=15.64..223.18 rows=13475 loops=1) > Total runtime: 66694.82 msec > > EXPLAIN > > Anybody shed any light on why the indexes I created aren't being used, > and I have these nasty sequential scans? Measurement is sequentially scaned, because probably "interface=12" results in lot of records. Please, check how many rows you have - all rows in measurement/panconversation, - rows in measurement with "Interface"=12 - rows in panconversation between your time. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Wed Mar 5 05:26:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from relay.firstnet.net.uk (inbound.firstnet.net.uk [212.103.224.21]) by postgresql.org (Postfix) with SMTP id 6CA61477501 for ; Wed, 5 Mar 2003 05:26:41 -0500 (EST) Received: (qmail 26997 invoked from network); 5 Mar 2003 10:26:47 -0000 Received: from unknown (HELO paulspc) (62.105.89.252) by meld.first with SMTP; 5 Mar 2003 10:26:47 -0000 From: "Paul McKay" To: "'Tomasz Myrta'" Cc: Subject: Re: Slow query performance on large table Date: Wed, 5 Mar 2003 10:27:27 -0000 Message-ID: <000201c2e301$d1cc3a10$0c64a8c0@paulspc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 Importance: Normal In-Reply-To: <3E65CBBE.4090803@klaster.net> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Archive-Number: 200303/22 X-Sequence-Number: 1320 clearview=# select count(*) from measurement; count ---------- 15302138 (1 row) clearview=# select count(*) from panconversation; count ------- 77217 (1 row) clearview=# select count(*) from panconversation where interface = 11; count ------- 13475 (1 row) clearview=# select count(*) from measurement where time > 1046184261 and time < 1046335461; count -------- 455788 (1 row) ====================================== Paul Mckay Consultant Partner Servicing Division Clearwater-IT e:paul_mckay@clearwater-it.co.uk t:0161 877 6090 m: 07713 510946 ====================================== -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Tomasz Myrta Sent: 05 March 2003 10:05 To: Paul McKay Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query performance on large table Paul McKay wrote: > Hopefully you guys can help me with another query I've got that's > running slow. > > This time it's across two tables I have > > clearview=# \d panconversation > Table "panconversation" > Column | Type | Modifiers > -------------+---------+----------- > assessment | integer | not null > interface | integer | > source | integer | > destination | integer | > protocol | integer | > Indexes: idx_panconversation_destination, > idx_panconversation_interface, > idx_panconversation_protocol, > idx_panconversation_source > Primary key: panconversation_pkey > Unique keys: unq_panconversation > Triggers: RI_ConstraintTrigger_52186648, > RI_ConstraintTrigger_52186654, > RI_ConstraintTrigger_52186660, > RI_ConstraintTrigger_52186666 > > Primary key is assessment > > Along with the table I was dealing with before, with the index I'd > mislaid put back in > > clearview=# \d measurement > Table "measurement" > Column | Type | Modifiers > ------------+-----------------------+----------- > assessment | integer | > time | integer | > value | character varying(50) | > Indexes: idx_measurement_assessment, > idx_measurement_time, > ind_measurement_ass_time > > The 'explain analyse' of the query I am running is rather evil. > > clearview=# explain analyse select source,value > clearview-# from measurement, PANConversation > clearview-# where PANConversation.assessment = > measurement.assessment > clearview-# and Interface = 11 > clearview-# and Time > 1046184261 and Time < 1046335461 > clearview-# ; > NOTICE: QUERY PLAN: > > Hash Join (cost=1532.83..345460.73 rows=75115 width=23) (actual > time=1769.84..66687.11 rows=16094 loops=1) > -> Seq Scan on measurement (cost=0.00..336706.07 rows=418859 > width=15) (actual time=1280.11..59985.47 rows=455788 loops=1) > -> Hash (cost=1498.21..1498.21 rows=13848 width=8) (actual > time=253.49..253.49 rows=0 loops=1) > -> Seq Scan on panconversation (cost=0.00..1498.21 rows=13848 > width=8) (actual time=15.64..223.18 rows=13475 loops=1) > Total runtime: 66694.82 msec > > EXPLAIN > > Anybody shed any light on why the indexes I created aren't being used, > and I have these nasty sequential scans? Measurement is sequentially scaned, because probably "interface=12" results in lot of records. Please, check how many rows you have - all rows in measurement/panconversation, - rows in measurement with "Interface"=12 - rows in panconversation between your time. Regards, Tomasz Myrta ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster From pgsql-performance-owner@postgresql.org Wed Mar 5 06:14:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by postgresql.org (Postfix) with ESMTP id 8F1CB477330 for ; Wed, 5 Mar 2003 06:14:05 -0500 (EST) 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 18qWqd-0004TV-0U for pgsql-performance@postgresql.org; Wed, 05 Mar 2003 11:14:07 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 73AC71756C for ; Wed, 5 Mar 2003 11:14:06 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id D2E4D161D7 for ; Wed, 5 Mar 2003 11:14:05 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" From: Richard Huxton Organization: Archonet Ltd To: Subject: Planner matching constants across tables in a join Date: Wed, 5 Mar 2003 11:13:14 +0000 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303051113.14320.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Archive-Number: 200303/23 X-Sequence-Number: 1321 I know this has been covered on one of the lists in the past, but I'm damne= d=20 if I can find the keywords to locate it. If I join two tables with a comparison to a constant on one, why can't the= =20 planner see that the comparison applies to both tables: SELECT a.id FROM a JOIN b ON a.id=3Db.id WHERE a.id=3D1; runs much slower than SELECT a.id FROM a JOIN b ON a.id=3Db.id WHERE a.id=3D1 AND b.id=3D1; It's not a real problem since it's easy to work around, but I was wondering= =20 what the difficulties are for the planner in seeing that query 1 is the sam= e=20 as query 2. Note that it doesn't seem related to JOIN forcing the planner's= =20 hand, the same applies just using WHERE a.id=3Db.id --=20 Richard Huxton From pgsql-performance-owner@postgresql.org Wed Mar 5 07:42:20 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id B75CD4764D7 for ; Wed, 5 Mar 2003 07:42:16 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id 1FF8E137F61; Wed, 5 Mar 2003 07:42:19 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18qYDy-0001Zg-00; Wed, 05 Mar 2003 07:42:18 -0500 To: Richard Huxton Cc: Subject: Re: Planner matching constants across tables in a join References: <200303051113.14320.dev@archonet.com> In-Reply-To: <200303051113.14320.dev@archonet.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 05 Mar 2003 07:42:18 -0500 Message-ID: <87bs0q9e8l.fsf@stark.dyndns.tv> Lines: 25 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200303/24 X-Sequence-Number: 1322 Richard Huxton writes: > I know this has been covered on one of the lists in the past, but I'm damned > if I can find the keywords to locate it. > > If I join two tables with a comparison to a constant on one, why can't the > planner see that the comparison applies to both tables: It sure does. Postgres does an impressive job of tracing equality clauses around for just this purpose. > SELECT a.id FROM a JOIN b ON a.id=b.id WHERE a.id=1; > > runs much slower than > > SELECT a.id FROM a JOIN b ON a.id=b.id WHERE a.id=1 AND b.id=1; Really? They produce virtually the same plan for me. Why do you think it'll run slower? What query are you actually finding slow? -- greg From pgsql-performance-owner@postgresql.org Wed Mar 5 08:55:00 2003 X-Original-To: pgsql-performance@postgresql.org Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 32014475EFB for ; Wed, 5 Mar 2003 08:54:58 -0500 (EST) Received: from DU150.N224.ResNet.QueensU.CA (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id BA86A1E10; Wed, 5 Mar 2003 08:55:01 -0500 (EST) Subject: Re: OIDs as keys From: Neil Conway To: Tom Lane Cc: Christopher Kings-Lynne , daniel alvarez , Richard Huxton , PostgreSQL Performance In-Reply-To: <9227.1046331043@sss.pgh.pa.us> References: <200302261358.53730.dev@archonet.com> <24135.1046271575@www36.gmx.net> <29871.1046274964@sss.pgh.pa.us> <032301c2de14$c64ccf70$6500a8c0@fhp.internal> <8927.1046327718@sss.pgh.pa.us> <040a01c2de2d$dac03780$6500a8c0@fhp.internal> <9113.1046329568@sss.pgh.pa.us> <044801c2de30$93d71ca0$6500a8c0@fhp.internal> <9227.1046331043@sss.pgh.pa.us> Content-Type: text/plain Organization: Message-Id: <1046872498.10615.17.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 05 Mar 2003 08:54:58 -0500 Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/25 X-Sequence-Number: 1323 On Thu, 2003-02-27 at 02:30, Tom Lane wrote: > It's moving in the wrong direction. We've been slowly eliminating > unnecessary nonstandardisms in pg_dump output; this puts in a new one > in a quite fundamental place. You could perhaps expect another DB > to drop commands it didn't understand like SET SEARCH_PATH ... but if > it drops all your CREATE TABLEs, you ain't got much dump left to load. Rather than specifying the use of OIDs by WITH OIDS clauses for each CREATE TABLE in a dump, couldn't we do it by adding a SET command that toggles the 'use_oids' GUC option prior to every CREATE TABLE? That way, a user concerned with portability could fairly easily strip out (or just ignore) the SET commands. Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-performance-owner@postgresql.org Wed Mar 5 09:29:40 2003 X-Original-To: pgsql-performance@postgresql.org Received: from jester.inquent.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id 7D08C4762C7 for ; Wed, 5 Mar 2003 09:29:38 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.inquent.com (8.12.6/8.12.6) with ESMTP id h25E5uve019457; Wed, 5 Mar 2003 09:05:56 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: OIDs as keys From: Rod Taylor To: Neil Conway Cc: Tom Lane , Christopher Kings-Lynne , daniel alvarez , Richard Huxton , Postgresql Performance In-Reply-To: <1046872498.10615.17.camel@tokyo> References: <200302261358.53730.dev@archonet.com> <24135.1046271575@www36.gmx.net> <29871.1046274964@sss.pgh.pa.us> <032301c2de14$c64ccf70$6500a8c0@fhp.internal> <8927.1046327718@sss.pgh.pa.us> <040a01c2de2d$dac03780$6500a8c0@fhp.internal> <9113.1046329568@sss.pgh.pa.us> <044801c2de30$93d71ca0$6500a8c0@fhp.internal> <9227.1046331043@sss.pgh.pa.us> <1046872498.10615.17.camel@tokyo> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-F4o8UT4G/32APyIkhcxj" Organization: Message-Id: <1046873156.18094.3.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 05 Mar 2003 09:05:56 -0500 X-Archive-Number: 200303/27 X-Sequence-Number: 1325 --=-F4o8UT4G/32APyIkhcxj Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-03-05 at 08:54, Neil Conway wrote: > On Thu, 2003-02-27 at 02:30, Tom Lane wrote: > > It's moving in the wrong direction. We've been slowly eliminating > > unnecessary nonstandardisms in pg_dump output; this puts in a new one > > in a quite fundamental place. You could perhaps expect another DB > > to drop commands it didn't understand like SET SEARCH_PATH ... but if > > it drops all your CREATE TABLEs, you ain't got much dump left to load. >=20 > Rather than specifying the use of OIDs by WITH OIDS clauses for each > CREATE TABLE in a dump, couldn't we do it by adding a SET command that > toggles the 'use_oids' GUC option prior to every CREATE TABLE? That way, > a user concerned with portability could fairly easily strip out (or just > ignore) the SET commands. Toggling the SET command prior to each table creation? Thats an excellent idea. It should also allow us to easily transition to the default being off after a release or two. --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-F4o8UT4G/32APyIkhcxj Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+ZgRD6DETLow6vwwRAsoHAJ0ZijQXntIDczzG5Bfo26KWVXDiPACeKgV2 z0bUAlCriwk/edBUoZYYQ70= =MSKt -----END PGP SIGNATURE----- --=-F4o8UT4G/32APyIkhcxj-- From pgsql-performance-owner@postgresql.org Wed Mar 5 09:25:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by postgresql.org (Postfix) with ESMTP id 56961475A6D for ; Wed, 5 Mar 2003 09:25:03 -0500 (EST) 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.36 #2) id 18qZpR-0000Th-0Z; Wed, 05 Mar 2003 14:25:05 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 4699F16393; Wed, 5 Mar 2003 14:25:04 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 7FB8716286; Wed, 5 Mar 2003 14:25:03 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Greg Stark Subject: Re: Planner matching constants across tables in a join Date: Wed, 5 Mar 2003 14:24:12 +0000 User-Agent: KMail/1.4.3 Cc: References: <200303051113.14320.dev@archonet.com> <87bs0q9e8l.fsf@stark.dyndns.tv> In-Reply-To: <87bs0q9e8l.fsf@stark.dyndns.tv> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303051424.12351.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Archive-Number: 200303/26 X-Sequence-Number: 1324 On Wednesday 05 Mar 2003 12:42 pm, Greg Stark wrote: > Really? They produce virtually the same plan for me. > > Why do you think it'll run slower? > What query are you actually finding slow? The actual query uses three tables, but isn't very complicated. Apologies f= or=20 the wrapping on the explain. EXPLAIN ANALYSE SELECT a.line_id, a.start_time, a.call_dur, i.cam_id, i.prod_id, i.chg_per_min, i.rev_per_min FROM campaign_items i, campaign c, activity a WHERE i.cam_id=3Dc.id AND a.line_id=3Di.line_id AND a.start_time BETWEEN c.cam_from AND c.cam_to AND a.line_id=3D'0912345 0004' AND i.line_id=3D'0912345 0004'; =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 QUERY PLAN ---------- Merge Join (cost=3D348.01..348.72 rows=3D1 width=3D72) (actual time=3D115= .43..116.27=20 rows=3D21 loops=3D1) Merge Cond: ("outer".id =3D "inner".cam_id) Join Filter: (("outer".line_id)::text =3D ("inner".line_id)::text) -> Sort (cost=3D245.45..245.75 rows=3D118 width=3D40) (actual time=3D8= 3.98..84.10=20 rows=3D94 loops=3D1) Sort Key: c.id -> Nested Loop (cost=3D0.00..241.40 rows=3D118 width=3D40) (actu= al=20 time=3D3.83..83.27 rows=3D94 loops=3D1) Join Filter: (("outer".start_time >=3D=20 ("inner".cam_from)::timestamp without time zone) AND ("outer".start_time <= =3D=20 ("inner".cam_to)::timestamp without time zone)) -> Seq Scan on activity a (cost=3D0.00..199.00 rows=3D11= =20 width=3D28) (actual time=3D3.06..54.14 rows=3D19 loops=3D1) Filter: ((line_id)::text =3D '0912345 0004'::text) -> Seq Scan on campaign c (cost=3D0.00..2.00 rows=3D100 wi= dth=3D12)=20 (actual time=3D0.02..0.84 rows=3D100 loops=3D19) -> Sort (cost=3D102.56..102.57 rows=3D5 width=3D32) (actual time=3D31.= 36..31.39=20 rows=3D20 loops=3D1) Sort Key: i.cam_id -> Seq Scan on campaign_items i (cost=3D0.00..102.50 rows=3D5 wi= dth=3D32)=20 (actual time=3D17.16..31.11 rows=3D6 loops=3D1) Filter: ((line_id)::text =3D '0912345 0004'::text) Total runtime: 117.08 msec (15 rows) and this is the plan where I just check the one line_id: EXPLAIN ANALYSE SELECT a.line_id, a.start_time, a.call_dur, i.cam_id,=20 i.prod_id, i.chg_per_min, i.rev_per_min FROM campaign_items i, campaign c, activity a WHERE i.cam_id=3Dc.id AND a.line_id=3Di.line_id AND a.start_time BETWEEN c.cam_from AND c.cam_to AND i.line_id=3D'0912345 0004'; =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 QUERY PLAN --------------------------------------- Hash Join (cost=3D2.25..1623.70 rows=3D6 width=3D72) (actual time=3D48.27= ..974.30=20 rows=3D21 loops=3D1) Hash Cond: ("outer".cam_id =3D "inner".id) Join Filter: (("outer".start_time >=3D ("inner".cam_from)::timestamp wit= hout=20 time zone) AND ("outer".start_time <=3D ("inner".cam_to)::timestamp without= =20 time zone)) -> Nested Loop (cost=3D0.00..1619.87 rows=3D53 width=3D60) (actual=20 time=3D24.49..969.33 rows=3D114 loops=3D1) Join Filter: (("inner".line_id)::text =3D ("outer".line_id)::text) -> Seq Scan on campaign_items i (cost=3D0.00..102.50 rows=3D5 wi= dth=3D32)=20 (actual time=3D15.72..28.52 rows=3D6 loops=3D1) Filter: ((line_id)::text =3D '0912345 0004'::text) -> Seq Scan on activity a (cost=3D0.00..174.00 rows=3D10000 widt= h=3D28)=20 (actual time=3D0.03..101.95 rows=3D10000 loops=3D6) -> Hash (cost=3D2.00..2.00 rows=3D100 width=3D12) (actual time=3D1.54.= .1.54=20 rows=3D0 loops=3D1) -> Seq Scan on campaign c (cost=3D0.00..2.00 rows=3D100 width=3D= 12)=20 (actual time=3D0.06..0.94 rows=3D100 loops=3D1) Total runtime: 975.13 msec (11 rows) Table campaign has 100 rows, campaign_items 5000, activity 10000. My guess = is=20 that the planner starts with "campaign" because of the low number of rows,= =20 but it still looks like filtering on "activity" would help things. Indeed,= =20 testing a.line_id instead of i.line_id does make a difference. =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 QUERY PLAN ------------------- Hash Join (cost=3D241.70..457.54 rows=3D6 width=3D72) (actual time=3D161.= 20..225.68=20 rows=3D21 loops=3D1) Hash Cond: ("outer".cam_id =3D "inner".id) Join Filter: (("inner".line_id)::text =3D ("outer".line_id)::text) -> Seq Scan on campaign_items i (cost=3D0.00..90.00 rows=3D5000 width= =3D32)=20 (actual time=3D0.03..72.00 rows=3D5000 loops=3D1) -> Hash (cost=3D241.40..241.40 rows=3D118 width=3D40) (actual time=3D8= 5.46..85.46=20 rows=3D0 loops=3D1) -> Nested Loop (cost=3D0.00..241.40 rows=3D118 width=3D40) (actu= al=20 time=3D3.80..84.66 rows=3D94 loops=3D1) Join Filter: (("outer".start_time >=3D=20 ("inner".cam_from)::timestamp without time zone) AND ("outer".start_time <= =3D=20 ("inner".cam_to)::timestamp without time zone)) -> Seq Scan on activity a (cost=3D0.00..199.00 rows=3D11= =20 width=3D28) (actual time=3D3.03..54.48 rows=3D19 loops=3D1) Filter: ((line_id)::text =3D '0912345 0004'::text) -> Seq Scan on campaign c (cost=3D0.00..2.00 rows=3D100 wi= dth=3D12)=20 (actual time=3D0.03..0.89 rows=3D100 loops=3D19) Total runtime: 226.51 msec (11 rows) --=20 Richard Huxton From pgsql-performance-owner@postgresql.org Wed Mar 5 10:02:22 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id D82E54761C0 for ; Wed, 5 Mar 2003 10:02:19 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id 55AEA13808F; Wed, 5 Mar 2003 10:02:20 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18qaPS-000245-00; Wed, 05 Mar 2003 10:02:18 -0500 To: Richard Huxton Cc: Greg Stark , Subject: Re: Planner matching constants across tables in a join References: <200303051113.14320.dev@archonet.com> <87bs0q9e8l.fsf@stark.dyndns.tv> <200303051424.12351.dev@archonet.com> In-Reply-To: <200303051424.12351.dev@archonet.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 05 Mar 2003 10:02:17 -0500 Message-ID: <87llzt97ra.fsf@stark.dyndns.tv> Lines: 17 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200303/28 X-Sequence-Number: 1326 Richard Huxton writes: > Filter: ((line_id)::text = '0912345 0004'::text) So I think this means that line_id is being casted to "text". Though I'm not clear why it would be choosing "text" for the constant if line_id wasn't text to begin with. In any case my plans here look like: > Filter: (aa = 'x'::text) so it looks like there's something extra going on in your plan. what does your table definition look like? -- greg From pgsql-performance-owner@postgresql.org Wed Mar 5 10:08:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 4E8944762F9 for ; Wed, 5 Mar 2003 10:08:39 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h25F8dx6019226; Wed, 5 Mar 2003 10:08:39 -0500 (EST) To: Greg Stark Cc: Richard Huxton , pgsql-performance@postgresql.org Subject: Re: Planner matching constants across tables in a join In-reply-to: <87bs0q9e8l.fsf@stark.dyndns.tv> References: <200303051113.14320.dev@archonet.com> <87bs0q9e8l.fsf@stark.dyndns.tv> Comments: In-reply-to Greg Stark message dated "05 Mar 2003 07:42:18 -0500" Date: Wed, 05 Mar 2003 10:08:38 -0500 Message-ID: <19225.1046876918@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/29 X-Sequence-Number: 1327 Greg Stark writes: > Richard Huxton writes: >> If I join two tables with a comparison to a constant on one, why can't the >> planner see that the comparison applies to both tables: > It sure does. Postgres does an impressive job of tracing equality clauses > around for just this purpose. CVS tip does. Existing releases don't... regards, tom lane From pgsql-performance-owner@postgresql.org Wed Mar 5 10:21:00 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 60FA84762FA for ; Wed, 5 Mar 2003 10:20:54 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h25FKfx6019294; Wed, 5 Mar 2003 10:20:41 -0500 (EST) To: Neil Conway Cc: Christopher Kings-Lynne , daniel alvarez , Richard Huxton , PostgreSQL Performance Subject: Re: OIDs as keys In-reply-to: <1046872498.10615.17.camel@tokyo> References: <200302261358.53730.dev@archonet.com> <24135.1046271575@www36.gmx.net> <29871.1046274964@sss.pgh.pa.us> <032301c2de14$c64ccf70$6500a8c0@fhp.internal> <8927.1046327718@sss.pgh.pa.us> <040a01c2de2d$dac03780$6500a8c0@fhp.internal> <9113.1046329568@sss.pgh.pa.us> <044801c2de30$93d71ca0$6500a8c0@fhp.internal> <9227.1046331043@sss.pgh.pa.us> <1046872498.10615.17.camel@tokyo> Comments: In-reply-to Neil Conway message dated "05 Mar 2003 08:54:58 -0500" Date: Wed, 05 Mar 2003 10:20:40 -0500 Message-ID: <19293.1046877640@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/30 X-Sequence-Number: 1328 Neil Conway writes: > Rather than specifying the use of OIDs by WITH OIDS clauses for each > CREATE TABLE in a dump, couldn't we do it by adding a SET command that > toggles the 'use_oids' GUC option prior to every CREATE TABLE? Seems better than cluttering the CREATE TABLE itself with them, I guess. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Mar 5 11:13:04 2003 X-Original-To: pgsql-performance@postgresql.org Received: from anchor-post-39.mail.demon.net (anchor-post-39.mail.demon.net [194.217.242.80]) by postgresql.org (Postfix) with ESMTP id 3DCE24762B8 for ; Wed, 5 Mar 2003 11:12:59 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-39.mail.demon.net with esmtp (Exim 3.36 #2) id 18qbVv-0004xQ-0d; Wed, 05 Mar 2003 16:13:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 42DCC1784E; Wed, 5 Mar 2003 16:13:02 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 8E2C31646A; Wed, 5 Mar 2003 16:13:01 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Greg Stark Subject: Re: Planner matching constants across tables in a join Date: Wed, 5 Mar 2003 16:12:09 +0000 User-Agent: KMail/1.4.3 Cc: Greg Stark , References: <200303051113.14320.dev@archonet.com> <200303051424.12351.dev@archonet.com> <87llzt97ra.fsf@stark.dyndns.tv> In-Reply-To: <87llzt97ra.fsf@stark.dyndns.tv> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303051612.09558.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Archive-Number: 200303/31 X-Sequence-Number: 1329 On Wednesday 05 Mar 2003 3:02 pm, Greg Stark wrote: > Richard Huxton writes: > > Filter: ((line_id)::text =3D '0912345 0004'::text) > > So I think this means that line_id is being casted to "text". Though I'm > not clear why it would be choosing "text" for the constant if line_id > wasn't text to begin with. A domain defined as varchar() actually - which is why it's not using an ind= ex,=20 but that's neither here nor there regarding the constant issue. > In any case my plans here look like: > > Filter: (aa =3D 'x'::text) > > so it looks like there's something extra going on in your plan. > > what does your table definition look like? rms=3D> \d campaign Table "rms.campaign" Column | Type | Modifiers ----------+-----------+----------- id | integer | not null title | item_name | cam_from | date | cam_to | date | owner | integer | Indexes: campaign_pkey primary key btree (id), campaign_from_idx btree (cam_from), campaign_to_idx btree (cam_to) rms=3D> \d campaign_items Table "rms.campaign_items" Column | Type | Modifiers -------------+---------+----------- cam_id | integer | not null line_id | tel_num | not null prod_id | integer | not null chg_per_min | integer | rev_per_min | integer | Indexes: campaign_items_pkey primary key btree (cam_id, line_id, prod_id), cam_item_line_idx btree (line_id) Foreign Key constraints: $1 FOREIGN KEY (cam_id) REFERENCES campaign(id) ON= =20 UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (line_id) REFERENCES line(telno) ON= =20 UPDATE NO ACTION ON DELETE NO ACTION, $3 FOREIGN KEY (prod_id) REFERENCES product(id) ON= =20 UPDATE NO ACTION ON DELETE NO ACTION rms=3D> \d activity Table "rms.activity" Column | Type | Modifiers ------------+-----------------------------+----------- line_id | tel_num | not null start_time | timestamp without time zone | not null call_dur | integer | Indexes: activity_pkey primary key btree (line_id, start_time), activity_start_idx btree (start_time) Foreign Key constraints: $1 FOREIGN KEY (line_id) REFERENCES line(telno) ON= =20 UPDATE NO ACTION ON DELETE NO ACTION --=20 Richard Huxton From pgsql-performance-owner@postgresql.org Wed Mar 5 14:00:47 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 6934B475CE5 for ; Wed, 5 Mar 2003 14:00:44 -0500 (EST) Received: from [216.135.165.74] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2881474; Wed, 05 Mar 2003 11:00:23 -0800 From: "Josh Berkus" Subject: Re: Planner matching constants across tables in a To: Richard Huxton , Greg Stark Cc: Greg Stark , X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Wed, 05 Mar 2003 11:00:23 -0800 Message-ID: In-Reply-To: <200303051612.09558.dev@archonet.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200303/32 X-Sequence-Number: 1330 Richard, > A domain defined as varchar() actually - which is why it's not using > an index, > but that's neither here nor there regarding the constant issue. You might improve your performance overall if you cast the constant to tel_num before doing the comparison in the query. Right now, the parser is casting the whole column to text instead, because it can't tell that the constant you supply is a valid tel_num. -Josh From pgsql-performance-owner@postgresql.org Wed Mar 5 14:26:39 2003 X-Original-To: pgsql-performance@postgresql.org Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by postgresql.org (Postfix) with ESMTP id A992A476302 for ; Wed, 5 Mar 2003 14:26:36 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 18qeXE-000ATP-0X; Wed, 05 Mar 2003 19:26:36 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 6A4901797B; Wed, 5 Mar 2003 19:26:35 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id C6A071797A; Wed, 5 Mar 2003 19:26:34 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: "Josh Berkus" , Greg Stark Subject: Re: Planner matching constants across tables in a Date: Wed, 5 Mar 2003 19:25:43 +0000 User-Agent: KMail/1.4.3 Cc: Greg Stark , References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303051925.43178.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Archive-Number: 200303/33 X-Sequence-Number: 1331 On Wednesday 05 Mar 2003 7:00 pm, Josh Berkus wrote: > Richard, > > > A domain defined as varchar() actually - which is why it's not using > > an index, > > but that's neither here nor there regarding the constant issue. > > You might improve your performance overall if you cast the constant to > tel_num before doing the comparison in the query. Right now, the > parser is casting the whole column to text instead, because it can't > tell that the constant you supply is a valid tel_num. That's what I thought, but... rms=3D> EXPLAIN ANALYSE SELECT * FROM line WHERE telno=3D'0912345 0004'::te= l_num; QUERY PLAN ---------------------------------------------------------------------------= ------------------- Seq Scan on line (cost=3D0.00..20.50 rows=3D1 width=3D28) (actual time=3D= 0.10..5.28=20 rows=3D1 loops=3D1) Filter: ((telno)::text =3D ('0912345 0004'::character varying)::text) Total runtime: 5.43 msec rms=3D> EXPLAIN ANALYSE SELECT * FROM line WHERE telno=3D'0912345 0004'::va= rchar; QUERY PLAN ---------------------------------------------------------------------------= -------------------------------------- Index Scan using line_pkey on line (cost=3D0.00..5.78 rows=3D1 width=3D28= ) (actual=20 time=3D14.03..14.03 rows=3D1 loops=3D1) Index Cond: ((telno)::character varying =3D '0912345 0004'::character=20 varying) Total runtime: 14.28 msec Ignoring the times (fake data on my test box) it seems like there's an issu= e=20 in comparing against DOMAIN defined types. Or maybe it's in the index=20 definition, although I don't know how to find out the type of an index. --=20 Richard Huxton From pgsql-performance-owner@postgresql.org Wed Mar 5 14:32:39 2003 X-Original-To: pgsql-performance@postgresql.org Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by postgresql.org (Postfix) with ESMTP id 4D64F475CE5 for ; Wed, 5 Mar 2003 14:32:38 -0500 (EST) 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.36 #2) id 18qed3-0005sr-0Z; Wed, 05 Mar 2003 19:32:38 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 25D6C1797B; Wed, 5 Mar 2003 19:32:37 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 7C18017978; Wed, 5 Mar 2003 19:32:36 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: "Josh Berkus" , Greg Stark Subject: Re: Planner matching constants across tables in a Date: Wed, 5 Mar 2003 19:31:44 +0000 User-Agent: KMail/1.4.3 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303051931.44701.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Archive-Number: 200303/34 X-Sequence-Number: 1332 On Wednesday 05 Mar 2003 7:00 pm, Josh Berkus wrote: > You might improve your performance overall if you cast the constant to > tel_num before doing the comparison in the query.=20 Stranger and stranger... richardh=3D# CREATE DOMAIN intdom int4; richardh=3D# CREATE DOMAIN textdom text; richardh=3D# CREATE TABLE domtest (a intdom, b textdom); richardh=3D# CREATE INDEX domtest_a_idx ON domtest (a); richardh=3D# CREATE INDEX domtest_b_idx ON domtest (b); richardh=3D# INSERT INTO domtest VALUES (1,'aaa'); richardh=3D# INSERT INTO domtest VALUES (2,'bbb'); richardh=3D# INSERT INTO domtest VALUES (3,'ccc'); richardh=3D# EXPLAIN ANALYSE SELECT * FROM domtest WHERE a=3D1::intdom; ---------------------------------------------------------------------------= ---------------------- Seq Scan on domtest (cost=3D0.00..22.50 rows=3D5 width=3D36) (actual=20 time=3D0.08..0.11 rows=3D1 loops=3D1) Filter: ((a)::oid =3D 1::oid) richardh=3D# EXPLAIN ANALYSE SELECT * FROM domtest WHERE a=3D1::int4; ---------------------------------------------------------------------------= -------------------------------------------- Index Scan using domtest_a_idx on domtest (cost=3D0.00..17.07 rows=3D5 wi= dth=3D36)=20 (actual time=3D0.09..0.11 rows=3D1 loops=3D1) Index Cond: ((a)::integer =3D 1) richardh=3D# EXPLAIN ANALYSE SELECT * FROM domtest WHERE b=3D'aaa'::textdom; ---------------------------------------------------------------------------= -------------------------------------------- Index Scan using domtest_b_idx on domtest (cost=3D0.00..17.07 rows=3D5 wi= dth=3D36)=20 (actual time=3D0.09..0.11 rows=3D1 loops=3D1) Index Cond: ((b)::text =3D 'aaa'::text) richardh=3D# EXPLAIN ANALYSE SELECT * FROM domtest WHERE b=3D'aaa'::text; ---------------------------------------------------------------------------= -------------------------------------------- Index Scan using domtest_b_idx on domtest (cost=3D0.00..17.07 rows=3D5 wi= dth=3D36)=20 (actual time=3D0.10..0.12 rows=3D1 loops=3D1) Index Cond: ((b)::text =3D 'aaa'::text) Can't think why we're getting casts to type "oid" in the first example - I'= d=20 have thought int4 would be the default. I'm guessing the text domain always= =20 works because that's the default cast. --=20 Richard Huxton From pgsql-performance-owner@postgresql.org Wed Mar 5 16:11:31 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id DFF554762E1 for ; Wed, 5 Mar 2003 16:11:28 -0500 (EST) Received: from [216.135.165.74] (HELO lazarus) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP-TLS id 2881705; Wed, 05 Mar 2003 13:11:09 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Tim Mohler" , Subject: Re: Batch copying of databases Date: Wed, 5 Mar 2003 11:37:39 -0800 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303051137.39517.josh@agliodbs.com> X-Archive-Number: 200303/36 X-Sequence-Number: 1334 Tim, > I'm new to Postgres, and am not even the DBA for the system. I'm just a > sysadmin trying to make things run faster. Every month, we copy over a 25 > million row table from the production server to the reporting server. Tot= al > size is something like 40 gigabytes. Are you doing this through COPY files, or some other means? --=20 Josh Berkus josh@agliodbs.com Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Mar 5 15:26:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from nycsmtp1out.rdc-nyc.rr.com (nycsmtp1out.rdc-nyc.rr.com [24.29.99.222]) by postgresql.org (Postfix) with ESMTP id 9B5014762B8 for ; Wed, 5 Mar 2003 15:26:46 -0500 (EST) Received: from ibmlaptop (24-29-154-100.nyc.rr.com [24.29.154.100]) by nycsmtp1out.rdc-nyc.rr.com (8.12.1/Road Runner SMTP Server 1.0) with SMTP id h25KQlk5007516 for ; Wed, 5 Mar 2003 15:26:47 -0500 (EST) From: "Tim Mohler" To: Subject: Batch copying of databases Date: Wed, 5 Mar 2003 15:26:27 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Importance: Normal X-Archive-Number: 200303/35 X-Sequence-Number: 1333 Hi all, I'm new to Postgres, and am not even the DBA for the system. I'm just a sysadmin trying to make things run faster. Every month, we copy over a 25 million row table from the production server to the reporting server. Total size is something like 40 gigabytes. The copy in takes close to 24 hours, and I see the disks being hammered by hundreds of small writes every second. The system is mostly waiting on I/O. Is there any facility in Postgres to force batching of the I/O transactions to something more reasonable than 8K? Thanks for any advice, Tim From pgsql-committers-owner@postgresql.org Wed Mar 5 22:16:57 2003 X-Original-To: pgsql-committers@postgresql.org Received: by postgresql.org (Postfix, from userid 1116) id 1876F4762E0; Wed, 5 Mar 2003 22:16:56 -0500 (EST) To: pgsql-committers@postgresql.org Subject: pgsql-server/ /configure /configure.in rc/incl ... Message-Id: <20030306031656.1876F4762E0@postgresql.org> Date: Wed, 5 Mar 2003 22:16:56 -0500 (EST) From: tgl@postgresql.org (Tom Lane) X-Archive-Number: 200303/14 X-Sequence-Number: 9257 CVSROOT: /cvsroot Module name: pgsql-server Changes by: tgl@postgresql.org 03/03/05 22:16:56 Modified files: . : configure configure.in src/include : pg_config.h.in src/interfaces/libpq: fe-misc.c Log message: Use poll(2) in preference to select(2), if available. This solves problems in applications that may have a large number of files open, such that libpq's socket number exceeds the range supported by fd_set. From Chris Brown. From pgsql-committers-owner@postgresql.org Wed Mar 5 22:30:06 2003 X-Original-To: pgsql-committers@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id 964FD476302 for ; Wed, 5 Mar 2003 22:30:01 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h263U4V40523 for pgsql-committers@postgresql.org; Thu, 6 Mar 2003 11:30:04 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h263U2740478; Thu, 6 Mar 2003 11:30:02 +0800 (WST) Message-ID: <032f01c2e390$b1842b20$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: , "Tom Lane" References: <20030306031656.1876F4762E0@postgresql.org> Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Date: Thu, 6 Mar 2003 11:30:11 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/15 X-Sequence-Number: 9258 Has anyone ever thought about adding kqueue (for *BSD) support to Postgres, instead of using select? LIBRARY Standard C Library (libc, -lc) SYNOPSIS #include #include #include int kqueue(void); int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); EV_SET(&kev, ident, filter, flags, fflags, data, udata); DESCRIPTION kqueue() provides a generic method of notifying the user when an event happens or a condition holds, based on the results of small pieces of kernel code termed filters. A kevent is identified by the (ident, fil- ter) pair; there may only be one unique kevent per kqueue. The filter is executed upon the initial registration of a kevent in order to detect whether a preexisting condition is present, and is also exe- cuted whenever an event is passed to the filter for evaluation. If the filter determines that the condition should be reported, then the kevent is placed on the kqueue for the user to retrieve. The filter is also run when the user attempts to retrieve the kevent from the kqueue. If the filter indicates that the condition that triggered the event no longer holds, the kevent is removed from the kqueue and is not returned. Chris > CVSROOT: /cvsroot > Module name: pgsql-server > Changes by: tgl@postgresql.org 03/03/05 22:16:56 > > Modified files: > . : configure configure.in > src/include : pg_config.h.in > src/interfaces/libpq: fe-misc.c > > Log message: > Use poll(2) in preference to select(2), if available. This solves > problems in applications that may have a large number of files open, > such that libpq's socket number exceeds the range supported by fd_set. > From Chris Brown. From pgsql-committers-owner@postgresql.org Wed Mar 5 22:34:29 2003 X-Original-To: pgsql-committers@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 7E052474E53 for ; Wed, 5 Mar 2003 22:34:27 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h263YRx6011078; Wed, 5 Mar 2003 22:34:27 -0500 (EST) To: "Christopher Kings-Lynne" Cc: pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... In-reply-to: <032f01c2e390$b1842b20$6500a8c0@fhp.internal> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> Comments: In-reply-to "Christopher Kings-Lynne" message dated "Thu, 06 Mar 2003 11:30:11 +0800" Date: Wed, 05 Mar 2003 22:34:27 -0500 Message-ID: <11077.1046921667@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/16 X-Sequence-Number: 9259 "Christopher Kings-Lynne" writes: > Has anyone ever thought about adding kqueue (for *BSD) support to Postgres, > instead of using select? Why? poll() is standard. kqueue isn't, AFAIK. regards, tom lane From pgsql-committers-owner@postgresql.org Wed Mar 5 22:42:36 2003 X-Original-To: pgsql-committers@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id 741BF476120 for ; Wed, 5 Mar 2003 22:42:33 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h263gbA41274 for pgsql-committers@postgresql.org; Thu, 6 Mar 2003 11:42:37 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h263gX741184; Thu, 6 Mar 2003 11:42:33 +0800 (WST) Message-ID: <033f01c2e392$71476570$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: "Tom Lane" Cc: References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Date: Thu, 6 Mar 2003 11:42:42 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/17 X-Sequence-Number: 9260 > "Christopher Kings-Lynne" writes: > > Has anyone ever thought about adding kqueue (for *BSD) support to Postgres, > > instead of using select? > > Why? poll() is standard. kqueue isn't, AFAIK. It's supposed be a whole heap faster - there is no polling involved... Chris From pgsql-committers-owner@postgresql.org Wed Mar 5 22:47:54 2003 X-Original-To: pgsql-committers@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3A9CE475FEE for ; Wed, 5 Mar 2003 22:47:52 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h263lqx6012229; Wed, 5 Mar 2003 22:47:52 -0500 (EST) To: "Christopher Kings-Lynne" Cc: pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... In-reply-to: <033f01c2e392$71476570$6500a8c0@fhp.internal> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> Comments: In-reply-to "Christopher Kings-Lynne" message dated "Thu, 06 Mar 2003 11:42:42 +0800" Date: Wed, 05 Mar 2003 22:47:51 -0500 Message-ID: <12228.1046922471@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/18 X-Sequence-Number: 9261 "Christopher Kings-Lynne" writes: >>> Has anyone ever thought about adding kqueue (for *BSD) support to >>> Postgres, instead of using select? >> >> Why? poll() is standard. kqueue isn't, AFAIK. > It's supposed be a whole heap faster - there is no polling involved... Supposed by whom? Faster than what? And how would it not poll? The way libpq uses this call, it's either probing for current status (timeout=0) or it's willing to block, possibly indefinitely, until the desired condition arises. It does not sit there in a busy-wait loop. I can't see any reason to think that an OS-specific API would give any marked difference in performance. regards, tom lane From pgsql-committers-owner@postgresql.org Wed Mar 5 23:19:22 2003 X-Original-To: pgsql-committers@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D4FE5474E53 for ; Wed, 5 Mar 2003 23:19:17 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h264JHx6012401; Wed, 5 Mar 2003 23:19:17 -0500 (EST) To: "Christopher Kings-Lynne" Cc: pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... In-reply-to: <033f01c2e392$71476570$6500a8c0@fhp.internal> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> Comments: In-reply-to "Christopher Kings-Lynne" message dated "Thu, 06 Mar 2003 11:42:42 +0800" Date: Wed, 05 Mar 2003 23:19:16 -0500 Message-ID: <12400.1046924356@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/19 X-Sequence-Number: 9262 "Christopher Kings-Lynne" writes: > It's supposed be a whole heap faster - there is no polling involved... I looked into this more. AFAICT, the scenario in which kqueue is said to be faster involves watching a large number of file descriptors simultaneously. Since libpq is only watching one descriptor, I don't see the benefit of adopting kqueue ... regards, tom lane From pgsql-committers-owner@postgresql.org Wed Mar 5 23:33:51 2003 X-Original-To: pgsql-committers@postgresql.org Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id AE365474E53 for ; Wed, 5 Mar 2003 23:33:46 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h264XaQ11718; Wed, 5 Mar 2003 23:33:36 -0500 (EST) From: Bruce Momjian Message-Id: <200303060433.h264XaQ11718@candle.pha.pa.us> Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... In-Reply-To: <12228.1046922471@sss.pgh.pa.us> To: Tom Lane Date: Wed, 5 Mar 2003 23:33:36 -0500 (EST) Cc: Christopher Kings-Lynne , pgsql-committers@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200303/20 X-Sequence-Number: 9263 I assume he just assumed poll() actually polls. I doesn't. It is just like select(). --------------------------------------------------------------------------- Tom Lane wrote: > "Christopher Kings-Lynne" writes: > >>> Has anyone ever thought about adding kqueue (for *BSD) support to > >>> Postgres, instead of using select? > >> > >> Why? poll() is standard. kqueue isn't, AFAIK. > > > It's supposed be a whole heap faster - there is no polling involved... > > Supposed by whom? Faster than what? And how would it not poll? > > The way libpq uses this call, it's either probing for current status > (timeout=0) or it's willing to block, possibly indefinitely, until the > desired condition arises. It does not sit there in a busy-wait loop. > I can't see any reason to think that an OS-specific API would give > any marked difference in performance. > > 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 > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Thu Mar 6 01:53:01 2003 X-Original-To: pgsql-performance@postgresql.org Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 8E654476178 for ; Thu, 6 Mar 2003 01:52:58 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h266qvq01166 for ; Thu, 6 Mar 2003 12:22:57 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h266quW01159 for ; Thu, 6 Mar 2003 12:22:57 +0530 From: "Shridhar Daithankar" To: Date: Thu, 06 Mar 2003 12:23:42 +0530 MIME-Version: 1.0 Subject: Re: Batch copying of databases Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3E673DCE.24575.352CED2@localhost> In-reply-to: X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Archive-Number: 200303/37 X-Sequence-Number: 1335 On 5 Mar 2003 at 15:26, Tim Mohler wrote: > Hi all, > > I'm new to Postgres, and am not even the DBA for the system. I'm just a > sysadmin trying to make things run faster. Every month, we copy over a 25 > million row table from the production server to the reporting server. Total > size is something like 40 gigabytes. > > The copy in takes close to 24 hours, and I see the disks being hammered by > hundreds of small writes every second. The system is mostly waiting on I/O. > Is there any facility in Postgres to force batching of the I/O transactions > to something more reasonable than 8K? Well, 8K has nothing to with transactions in postgresql. You need to make sure at least two things. 1. You are using copy. By default postgresql writes each inserts in it's own transaction which is seriously slow for bulk load. Copy bunches the rwos in a single transaction and is quite fast. if you need to preprocess the data, batch something like 1K-10K records in a single transaction. 2. Postgresql bulk load is not as fast as many of us would like, especially when compared to oracle. So if you know you are going to bulk load using say copy, don't load the data from a single connection. Split the data file in say 5-10 parts and start loading all of them simaltaneously. It does speed up the things. At least it certainly saturates the disk bandwidth which single load does not do many times. On a side note, for such a bulk load consider dropping any indexes and foreign key contraints. HTH Bye Shridhar -- Turnaucka's Law: The attention span of a computer is only as long as its electrical cord. From pgsql-committers-owner@postgresql.org Mon Mar 10 13:21:23 2003 X-Original-To: pgsql-committers@postgresql.org Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id E8ED0476128 for ; Thu, 6 Mar 2003 04:41:29 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id C122321059; Thu, 6 Mar 2003 01:41:17 -0800 (PST) Date: Thu, 6 Mar 2003 01:41:17 -0800 From: Sean Chittenden To: Tom Lane Cc: Christopher Kings-Lynne , pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Message-ID: <20030306094117.GA79234@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="G5yIW5EaChZ5gJdA" Content-Disposition: inline In-Reply-To: <12228.1046922471@sss.pgh.pa.us> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/55 X-Sequence-Number: 9298 --G5yIW5EaChZ5gJdA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > >>> Has anyone ever thought about adding kqueue (for *BSD) support to > >>> Postgres, instead of using select? > >>=20 > >> Why? poll() is standard. kqueue isn't, AFAIK. >=20 > > It's supposed be a whole heap faster - there is no polling involved... >=20 > Supposed by whom? Faster than what? And how would it not poll? >=20 > The way libpq uses this call, it's either probing for current status > (timeout=3D0) or it's willing to block, possibly indefinitely, until the > desired condition arises. It does not sit there in a busy-wait loop. > I can't see any reason to think that an OS-specific API would give > any marked difference in performance. Heh, kqueue is _the_ reason to use FreeBSD. http://www.kegel.com/dkftpbench/Poller_bench.html#results I've toyed with the idea of adding this because it is monstrously more efficient than select()/poll() in basically every way, shape, and form. That said, in terms of performance perks, I'd think migrating the backend to using mmap() would yield a bigger performance benefit (see Stevens) to a larger group of people than adding FreeBSD's kqueue interface (something I plan on doing at some point if no one beats me to it). mmap() + write() for FreeBSD is a zero-copy socket operation and likely is on other platforms. Reducing the number of pages that have to be copied around would be a big win in terms of sending data to clients as well as scanning through data. Files are also only mmap()'ed in the kernel once with BSD's VM system which could reduce the RAM consumed by backends considerably. mmap() would also be an interesting way of providing some kind of atomicity for MVCC (re: WAL, use msync() to have the mapped region hit the disk before the change). I was actually quite surprised when I grep'ed through the code and found that mmap() wasn't in use _anywhere_. The TODO seems to be full of messages, but not much in the way of authoritative statements. Is this one of the areas of PostgreSQL that just needs to get slowly migrated to use mmap() or are there any gaping reasons why to not use the family of system calls? -sc --=20 Sean Chittenden --G5yIW5EaChZ5gJdA Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+Zxe93ZnjH7yEs0ERAmcgAJ9zLfxB62TbCeeXby7GEsZBpOb0rACg5OR4 AanBKeFWVvARKCN0Un/xCm8= =6nPT -----END PGP SIGNATURE----- --G5yIW5EaChZ5gJdA-- From pgsql-admin-owner@postgresql.org Thu Mar 6 05:50:37 2003 X-Original-To: pgsql-admin@postgresql.org Received: from 127.0.0.1 (unknown [61.5.117.62]) by postgresql.org (Postfix) with SMTP id 5211047610A for ; Thu, 6 Mar 2003 05:50:08 -0500 (EST) From: "Mr.F" To: Subject: New Interface for Win Date: Thu, 6 Mar 2003 17:51:28 +0700 Message-ID: <000201c2e3ce$5702bac0$de00a8c0@fhf> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0003_01C2E409.03631960" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-GCMulti: 1 X-Archive-Number: 200303/46 X-Sequence-Number: 7694 This is a multi-part message in MIME format. ------=_NextPart_000_0003_01C2E409.03631960 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, =20 After two month we have been migrating from Ms-Sql Server 7 to PosgreSQL 7.3, we also build new interface to connect from client in Win base to Posgresql and it call =93PDAdmin=94. PDAdmin is a Posgresql tools to help Database Administrator (DBA) for a make a Trigger, Function, or Rule quickly because the User just could input the parameters that important only and then the program will perform frame program automatically and can generate script Trigger/Function/Rule from posgresql database just click in table or schema. =20 PDAdmin be make by concept and method difference by data tools for same PosgreSQL like PgAdmin, because first concept this program to help DBA for beginner or advance (in my team) to make transactional script to be use in PosgreSQL Version 7.3 like Trigger, Function or Rule easily, quick and flexible with show capability the editor.=20 =20 Now, we wishful to share =93PDAdmin version 1.0.5=94 in this milist =93FREE= =94 =20 Other features: -. Connection to PosgreSQL server without ODBC -. Update condition of trigger with choice checkbox or radio button. -. Available Database Explorer -. Shortcut to general function PostreSQL -. User define shortcut -. Block Execute Command -. Block Increase/Decrease Indent -. Export Trigger/Function/Rule from database to file -. Import data from Ms-Sql Server -. Freeware, No Limit, No Ads. =20 Requirements: -. Windows 95/98/Me/NT/2000/XP -. File Size 1150Kb -. Uninstaller Included: Yes -. Recommended: PosgreSQL 7.3.x =20 Download:=20 http://www.csahome.com/download/PDAdmin/PDASetup.exe =20 Screenshot: http://www.csahome.com/download/PDAdmin/pdadmin1.jpg =20 Regards, Fadjar Hamidi ------=_NextPart_000_0003_01C2E409.03631960 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi all,

 

After two month we have been migrating from Ms-Sql Serve= r 7 to PosgreSQL 7.3, we also build new interface to connect from client in Win base to Posgresql and it call “PDAdmin”. PDAdmin is a Posgresql tools to help Database Administrator (DBA) for a make a Trigger, Function, = or Rule quickly because the User just could input the parameters that important only and then the program will perform frame program automatically and can generate script Trigger/Function/Rule from posgresql database just click in table or schema.

 

PDAdmin be make by concept and method difference by data tools for same PosgreSQL like PgAdmin, because first concept this program to help DBA for beginner or advance (in my team) to make transactional script = to be use in PosgreSQL Version 7.3 like Trigger, Function or Rule easily, quick and flexible with show capability the editor.

 

Now, we wishful to share “PDAdmin version 1.0.5= 221; in this milist “FREE”

 

Other features:

-. Connection to PosgreSQL server without ODBC

-. Update condition of trigger with choice checkbox or r= adio button.

-. Available Database Explorer<= /p>

-. Shortcut to general function PostreSQL

-. User define shortcut

-. Block Execute Command

-. Block Increase/Decrease Indent

-. Export Trigger/Function/Rule from database to file

-. Import data from Ms-Sql Server

-. Freeware, No Limit, No Ads.<= /p>

 

Requirements:

-. Windows 95/98/Me/NT/2000/XP

-. File Size 1150Kb

-. Uninstaller Included: Yes

-. Recommended: PosgreSQL 7.3.x=

 

Download:

http://www.cs= ahome.com/download/PDAdmin/PDASetup.exe

 

Screenshot:

http://www.cs= ahome.com/download/PDAdmin/pdadmin1.jpg

 

Regards,

Fadjar Hamidi

------=_NextPart_000_0003_01C2E409.03631960-- From pgsql-admin-owner@postgresql.org Thu Mar 6 09:44:47 2003 X-Original-To: pgsql-admin@postgresql.org Received: from ndl1mr1-a-fixed (ndl1mr1-a-fixed.sancharnet.in [61.0.0.45]) by postgresql.org (Postfix) with ESMTP id 5DF37474E4F for ; Thu, 6 Mar 2003 09:44:45 -0500 (EST) Received: from conversion-daemon.ndl1mr1-a-fixed.sancharnet.in by ndl1mr1-a-fixed.sancharnet.in (iPlanet Messaging Server 5.2 HotFix 0.9 (built Jul 29 2002)) id <0HBC000010QTJE@ndl1mr1-a-fixed.sancharnet.in> for pgsql-admin@postgresql.org; Thu, 06 Mar 2003 20:14:47 +0530 (IST) Received: from societykotla ([61.0.95.110]) by ndl1mr1-a-fixed.sancharnet.in (iPlanet Messaging Server 5.2 HotFix 0.9 (built Jul 29 2002)) with ESMTPA id <0HBC00CVJ0Y1P1@ndl1mr1-a-fixed.sancharnet.in> for pgsql-admin@postgresql.org; Thu, 06 Mar 2003 20:14:47 +0530 (IST) Date: Thu, 06 Mar 2003 20:18:13 +0530 From: Aspire Something Subject: Re: New Interface for Win To: Pg Admin Reply-To: Aspire Something Message-id: <001b01c2e3ef$6bfb5ec0$c9c832c0@societykotla> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Mailer: Microsoft Outlook Express 6.00.2600.0000 Content-type: multipart/alternative; boundary="Boundary_(ID_bggRZKMEUU2wWlbnkurASQ)" X-Priority: 3 X-MSMail-priority: Normal References: <000201c2e3ce$5702bac0$de00a8c0@fhf> X-Archive-Number: 200303/48 X-Sequence-Number: 7696 This is a multi-part message in MIME format. --Boundary_(ID_bggRZKMEUU2wWlbnkurASQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Can U please pass on the Ip of your server my ISP's DNS do not have your websites entry ----- Original Message ----- From: Mr.F To: pgsql-admin@postgresql.org Sent: Thursday, March 06, 2003 4:21 PM Subject: [ADMIN] New Interface for Win Hi all, After two month we have been migrating from Ms-Sql Server 7 to PosgreSQL 7.3, we also build new interface to connect from client in Win base to Posgresql and it call "PDAdmin". PDAdmin is a Posgresql tools to help Database Administrator (DBA) for a make a Trigger, Function, or Rule quickly because the User just could input the parameters that important only and then the program will perform frame program automatically and can generate script Trigger/Function/Rule from posgresql database just click in table or schema. PDAdmin be make by concept and method difference by data tools for same PosgreSQL like PgAdmin, because first concept this program to help DBA for beginner or advance (in my team) to make transactional script to be use in PosgreSQL Version 7.3 like Trigger, Function or Rule easily, quick and flexible with show capability the editor. Now, we wishful to share "PDAdmin version 1.0.5" in this milist "FREE" Other features: -. Connection to PosgreSQL server without ODBC -. Update condition of trigger with choice checkbox or radio button. -. Available Database Explorer -. Shortcut to general function PostreSQL -. User define shortcut -. Block Execute Command -. Block Increase/Decrease Indent -. Export Trigger/Function/Rule from database to file -. Import data from Ms-Sql Server -. Freeware, No Limit, No Ads. Requirements: -. Windows 95/98/Me/NT/2000/XP -. File Size 1150Kb -. Uninstaller Included: Yes -. Recommended: PosgreSQL 7.3.x Download: http://www.csahome.com/download/PDAdmin/PDASetup.exe Screenshot: http://www.csahome.com/download/PDAdmin/pdadmin1.jpg Regards, Fadjar Hamidi --Boundary_(ID_bggRZKMEUU2wWlbnkurASQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Can U please pass on the Ip of y= our=20 server my ISP's DNS do not have your websites entry
 
 
 
----- Original Message -----
Fro= m:=20 Mr.F=
Sent: Thursday, March 06, 2003 4:2= 1=20 PM
Subject: [ADMIN] New Interface for= =20 Win

Hi=20 all,

 

After two month we have bee= n=20 migrating from Ms-Sql Server 7 to PosgreSQL 7.3, we also build new interf= ace=20 to connect from client in Win base to Posgresql and it call =93PDAdmin=94= . PDAdmin=20 is a Posgresql tools to help Database Administrator (DBA) for a make a=20 Trigger, Function, or Rule quickly because the User just could input the= =20 parameters that important only and then the program will perform frame pr= ogram=20 automatically and can generate script Trigger/Function/Rule from posgresq= l=20 database just click in table or schema.

 

PDAdmin be make by concept = and=20 method difference by data tools for same PosgreSQL like PgAdmin, because = first=20 concept this program to help DBA for beginner or advance (in my team) to = make=20 transactional script to be use in PosgreSQL Version 7.3 like Trigger, Fun= ction=20 or Rule easily, quick and flexible with show capability the editor.=20

 

Now, we wishful to share = =93PDAdmin=20 version 1.0.5=94 in this milist =93FREE=94

 

Other=20 features:

-. Connection to PosgreSQL = server=20 without ODBC

-. Update condition of trig= ger=20 with choice checkbox or radio button.

-. Available Database=20 Explorer

-. Shortcut to general func= tion=20 PostreSQL

-. User define=20 shortcut

-. Block Execute=20 Command

-. Block Increase/Decrease= =20 Indent

-. Export Trigger/Function/= Rule=20 from database to file

-. Import data from Ms-Sql= =20 Server

-. Freeware, No Limit, No= =20 Ads.

 

Requirements:

-.=20 Windows=20 95/98/Me/NT/2000/XP

-. File Size=20 1150Kb

-. Uninstaller Included:=20 Yes

-. Recommended: PosgreSQL= =20 7.3.x

 

Download:=20

http://www.= csahome.com/download/PDAdmin/PDASetup.exe

 

Screenshot:

http://www.= csahome.com/download/PDAdmin/pdadmin1.jpg

 

Regards,

Fadjar Hamidi

--Boundary_(ID_bggRZKMEUU2wWlbnkurASQ)-- From pgsql-performance-owner@postgresql.org Thu Mar 6 10:00:53 2003 X-Original-To: pgsql-performance@postgresql.org Received: from smtp.web.de (smtp02.web.de [217.72.192.151]) by postgresql.org (Postfix) with ESMTP id 9327E474E4F for ; Thu, 6 Mar 2003 10:00:49 -0500 (EST) Received: from p508184f7.dip0.t-ipconnect.de ([80.129.132.247] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 18qwrb-0006o1-00 for pgsql-performance@postgresql.org; Thu, 06 Mar 2003 16:00:51 +0100 Message-ID: <3E6762AA.8070206@web.de> Date: Thu, 06 Mar 2003 16:00:58 +0100 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: How to notice column changes in trigger Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/38 X-Sequence-Number: 1336 How can I detect whether a column was changed by an update command inside a trigger? create table test(a int, b int, c int, primary key(a)) b and c should be updated inside an update trigger if not modified by the statement itself 1) update test set a=0 -> trigger does its work 2) update test set a=0, b=1, c=2 -> trigger does nothing 3) update test set a=0, b=b, c=c -> trigger does nothing, but content of a and b dont change either although touched What I'm looking for is something like IF NOT COLUMN_TOUCHED(b) THEN ... For MSSQL, this would be coded as IF NOT UPDATE(b) .. Any hints? Andreas From pgsql-committers-owner@postgresql.org Thu Mar 6 10:25:49 2003 X-Original-To: pgsql-committers@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6B4FB4764B6 for ; Thu, 6 Mar 2003 10:25:44 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h26FPax6015072; Thu, 6 Mar 2003 10:25:36 -0500 (EST) To: Sean Chittenden Cc: Christopher Kings-Lynne , pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... In-reply-to: <20030306094117.GA79234@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> Comments: In-reply-to Sean Chittenden message dated "Thu, 06 Mar 2003 01:41:17 -0800" Date: Thu, 06 Mar 2003 10:25:36 -0500 Message-ID: <15071.1046964336@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/21 X-Sequence-Number: 9264 Sean Chittenden writes: > I've toyed with the idea of adding this because it is monstrously more > efficient than select()/poll() in basically every way, shape, and > form. From what I've looked at, kqueue only wins when you are watching a large number of file descriptors at the same time; which is an operation done nowhere in Postgres. I think the above would be a complete waste of effort. > Is this one of the areas of > PostgreSQL that just needs to get slowly migrated to use mmap() or are > there any gaping reasons why to not use the family of system calls? There has been much speculation on this, and no proof that it actually buys us anything to justify the portability hit. There would be some nontrivial problems to solve, such as the mechanics of accessing a large number of files from a large number of backends without running out of virtual memory. Also, is it guaranteed that multiple backends mmap'ing the same block will access the very same physical buffer, and not multiple copies? Multiple copies would be fatal. See the acrhives for more discussion. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Mar 6 11:01:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by postgresql.org (Postfix) with ESMTP id 30E5C4761BC for ; Thu, 6 Mar 2003 11:01:28 -0500 (EST) Received: from lfix.demon.co.uk ([158.152.59.127] helo=linda.lfix.co.uk) by anchor-post-35.mail.demon.net with esmtp (Exim 3.36 #2) id 18qxoJ-0005DE-0Z; Thu, 06 Mar 2003 16:01:31 +0000 Received: from localhost ([127.0.0.1] ident=olly) by linda.lfix.co.uk with esmtp (Exim 3.36 #1 (Debian)) id 18qxoD-0006w2-00; Thu, 06 Mar 2003 16:01:25 +0000 Subject: Re: How to notice column changes in trigger From: Oliver Elphick To: Andreas Pflug Cc: pgsql-performance@postgresql.org In-Reply-To: <3E6762AA.8070206@web.de> References: <3E6762AA.8070206@web.de> Content-Type: text/plain Organization: LFIX Limited Message-Id: <1046966484.20270.94.camel@linda.lfix.co.uk> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 06 Mar 2003 16:01:24 +0000 Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/39 X-Sequence-Number: 1337 On Thu, 2003-03-06 at 15:00, Andreas Pflug wrote: > How can I detect whether a column was changed by an update command > inside a trigger? > > create table test(a int, b int, c int, primary key(a)) > > b and c should be updated inside an update trigger if not modified by > the statement itself > > 1) update test set a=0 -> trigger does its work > 2) update test set a=0, b=1, c=2 -> trigger does nothing > 3) update test set a=0, b=b, c=c -> trigger does nothing, but content of > a and b dont change either although touched > > What I'm looking for is something like > IF NOT COLUMN_TOUCHED(b) THEN ... > For MSSQL, this would be coded as IF NOT UPDATE(b) .. IF NEW.b = OLD.b OR (NEW.b IS NULL AND OLD.b IS NULL) THEN -- b has not changed ... END IF; -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight, UK http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "The LORD is my light and my salvation; whom shall I fear? the LORD is the strength of my life; of whom shall I be afraid?" Psalms 27:1 From pgsql-performance-owner@postgresql.org Thu Mar 6 11:09:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from smtp.web.de (smtp03.web.de [217.72.192.158]) by postgresql.org (Postfix) with ESMTP id 83DA9476517 for ; Thu, 6 Mar 2003 11:09:28 -0500 (EST) Received: from p508184f7.dip0.t-ipconnect.de ([80.129.132.247] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 18qxw4-00072E-00 for pgsql-performance@postgresql.org; Thu, 06 Mar 2003 17:09:32 +0100 Message-ID: <3E6772C4.5010005@web.de> Date: Thu, 06 Mar 2003 17:09:40 +0100 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: How to notice column changes in trigger References: <3E6762AA.8070206@web.de> <1046966484.20270.94.camel@linda.lfix.co.uk> In-Reply-To: <1046966484.20270.94.camel@linda.lfix.co.uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/40 X-Sequence-Number: 1338 Oliver Elphick wrote: > IF NEW.b = OLD.b OR (NEW.b IS NULL AND OLD.b IS NULL) THEN > -- b has not changed > ... > END IF; > > This doesn't cover case 3, since UPDATE ... SET b=b will lead to NEW.b=OLD.b From pgsql-performance-owner@postgresql.org Thu Mar 6 12:06:36 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 0924F47655E for ; Thu, 6 Mar 2003 12:06:33 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2882891; Thu, 06 Mar 2003 09:06:23 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Andreas Pflug , pgsql-performance@postgresql.org Subject: Re: How to notice column changes in trigger Date: Thu, 6 Mar 2003 09:05:37 -0800 User-Agent: KMail/1.4.3 References: <3E6762AA.8070206@web.de> <1046966484.20270.94.camel@linda.lfix.co.uk> <3E6772C4.5010005@web.de> In-Reply-To: <3E6772C4.5010005@web.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200303060905.37760.josh@agliodbs.com> X-Archive-Number: 200303/41 X-Sequence-Number: 1339 Andreas, > This doesn't cover case 3, since UPDATE ... SET b=b will lead to > NEW.b=OLD.b Why do you care about SET b = b? And shouldn't this discussion be on the PGSQL-SQL list? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Mar 6 13:51:13 2003 X-Original-To: pgsql-performance@postgresql.org Received: from ms-smtp-02.texas.rr.com (ms-smtp-02.texas.rr.com [24.93.36.230]) by postgresql.org (Postfix) with ESMTP id A6D5C476321 for ; Thu, 6 Mar 2003 13:51:11 -0500 (EST) Received: from spaceship.com (cs24243214-140.austin.rr.com [24.243.214.140]) by ms-smtp-02.texas.rr.com (8.12.5/8.12.2) with ESMTP id h26ImKn1029954 for ; Thu, 6 Mar 2003 13:48:21 -0500 (EST) Message-ID: <3E67989F.7030001@spaceship.com> Date: Thu, 06 Mar 2003 12:51:11 -0600 From: Matt Mello User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance Subject: ISNULL performance tweaks Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/42 X-Sequence-Number: 1340 I have some existing code running in a production environment with embedded SELECTs whose WHERE's use ISNULL tests on indexed foreign key fields. This is obviously very slow. My ISNULL *queries *take anywhere from 6 to 40 seconds. These queries are used to generate reports to a device which times out at 20 seconds, so half the time these devices don't get their reports, which makes my customers VERY angry. I recall seeing an email (I believe on this list) about how to improve performance of ISNULL's with some sort of tweak or trick. However, I can't find that email anywhere, and couldn't find it searching the maillist archives. So, until I have the time to code the fixes I need to prevent the use of ISNULL, does anybody know how I can speed up this existing system? Man, I wish PG indexed nulls! Is there any plan on adding these in the future? Thanks for any help you can give! -- Matt Mello From pgsql-performance-owner@postgresql.org Thu Mar 6 14:03:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 6A8834764B3 for ; Thu, 6 Mar 2003 14:03:47 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2883163; Thu, 06 Mar 2003 11:03:32 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Matt Mello , pgsql-performance Subject: Re: ISNULL performance tweaks Date: Thu, 6 Mar 2003 11:04:33 -0800 X-Mailer: KMail [version 1.4] References: <3E67989F.7030001@spaceship.com> In-Reply-To: <3E67989F.7030001@spaceship.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303061104.33335.josh@agliodbs.com> X-Archive-Number: 200303/43 X-Sequence-Number: 1341 Matt, > I recall seeing an email (I believe on this list) about how to improve=20 > performance of ISNULL's with some sort of tweak or trick. However, I=20 > can't find that email anywhere, and couldn't find it searching the=20 > maillist archives. Easy. Create a partial index on NULLs: CREATE INDEX idx_tablename_nulls ON tablename(columname) WHERE columname IS NULL; --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Mar 6 14:11:23 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id DC0684764C0 for ; Thu, 6 Mar 2003 14:11:20 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2883187; Thu, 06 Mar 2003 11:11:06 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Matt Mello , pgsql-performance Subject: Re: ISNULL performance tweaks Date: Thu, 6 Mar 2003 11:12:07 -0800 X-Mailer: KMail [version 1.4] References: <3E67989F.7030001@spaceship.com> In-Reply-To: <3E67989F.7030001@spaceship.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303061112.07285.josh@agliodbs.com> X-Archive-Number: 200303/44 X-Sequence-Number: 1342 Matt, > Man, I wish PG indexed nulls! Is there any plan on adding these in the= =20 > future? BTW, this is a design argument. As far as a lot of SQL-geeks are concerned= =20 (and I'm one of them) use of NULLs should be minimized or eliminiated=20 entirely from well-normalized database designs. In such designs, IS NULL= =20 queries are used only for outer joins (where indexes don't matter) or for= =20 data integrity maintainence (where query speed doesn't matter).=20=20=20 As a result, the existing core team doesn't see this issue as a priority.= =20=20 What fixing it requires is a new programmer who cares enough about it to ha= ck=20 it. What would be really nice is the ability to create an index WITH NULLS= ,=20 as follows: CREATE INDEX idx_tablename_one ON tablename(column_one) WITH NULLS; --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Mar 6 15:19:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id EBBCE47634B for ; Thu, 6 Mar 2003 15:19:25 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h26KIu926973; Thu, 6 Mar 2003 15:18:56 -0500 (EST) From: Bruce Momjian Message-Id: <200303062018.h26KIu926973@candle.pha.pa.us> Subject: Re: Index File growing big. In-Reply-To: <200302271234.h1RCYCF13164@contactbda.com> To: jim@contactbda.com Date: Thu, 6 Mar 2003 15:18:56 -0500 (EST) Cc: Christopher Kings-Lynne , Tom Lane , Andrew Sullivan , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200303/45 X-Sequence-Number: 1343 Yes, the issue was that it only had places for heap and index location, not more generic. I can work with a few folks to get this done. I think it can be done in a few stages: Decide on syntax/functionality Update grammer to support it Update system catalogs to hold information Update storage manager to handle storage locations If folks can decide on the first item, I can do the second and third ones. --------------------------------------------------------------------------- Jim Buttafuoco wrote: > All, > > I was the person who submitted the patch. I tried to a generic syntax. I also tried to keep the tablespace concept > simple. See my posting on HACKERS/GENERAL from a week or 2 ago about the syntax. I am still interested in working on > this patch with others. I have many system here that are 500+ gigabytes and growing. It is a real pain to add more > disk space (I have to backup, drop database(s), rebuild raid set (I am using raid 10) and reload data). > > Jim > > > > > > > You should note that someone already has sent in a patch for > > tablespaces, it > > > > hasn't been acted on though - can't quite remember why. Maybe we should > > > > resurrect it... > > > > > > It's been awhile, but my recollection is that the patch had restricted > > > functionality (which would be okay for a first cut) and it invented SQL > > > syntax that seemed to lock us into that restricted functionality > > > permanently (not so okay). Details are fuzzy though... > > > > Well, I'll resurrect it and see if it can be improved. Tablespaces seem to > > be a requested feature these days... > > > > Chris > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Thu Mar 6 16:11:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 28B0047639F for ; Thu, 6 Mar 2003 16:11:41 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h26LB5J03462; Thu, 6 Mar 2003 16:11:05 -0500 (EST) From: Bruce Momjian Message-Id: <200303062111.h26LB5J03462@candle.pha.pa.us> Subject: Re: OIDs as keys In-Reply-To: <9227.1046331043@sss.pgh.pa.us> To: Tom Lane Date: Thu, 6 Mar 2003 16:11:05 -0500 (EST) Cc: Christopher Kings-Lynne , daniel alvarez , Richard Huxton , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200303/46 X-Sequence-Number: 1344 Tom Lane wrote: > "Christopher Kings-Lynne" writes: > >> As I recall, one thing people did not want was for pg_dump to plaster > >> WITH OIDS or WITHOUT OIDS on every single CREATE TABLE, as this would > >> pretty much destroy any shot at loading PG dumps into any other > >> database. > > > Ummm...what about SERIAL columns, ALTER TABLE / SET STATS, SET STORAGE, > > custom types, 'btree' in CREATE INDEX, SET SEARCH_PATH, '::" cast operator, > > stored procedures, rules, etc. - how is adding WITH OIDS going to change > > that?! > > It's moving in the wrong direction. We've been slowly eliminating > unnecessary nonstandardisms in pg_dump output; this puts in a new one > in a quite fundamental place. You could perhaps expect another DB > to drop commands it didn't understand like SET SEARCH_PATH ... but if > it drops all your CREATE TABLEs, you ain't got much dump left to load. Why was the schema path called search_path rather than schema_path? Standards? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Thu Mar 6 16:13:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id B65684763BD for ; Thu, 6 Mar 2003 16:13:33 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h26LDCP03630; Thu, 6 Mar 2003 16:13:12 -0500 (EST) From: Bruce Momjian Message-Id: <200303062113.h26LDCP03630@candle.pha.pa.us> Subject: Re: OIDs as keys In-Reply-To: <19293.1046877640@sss.pgh.pa.us> To: Tom Lane Date: Thu, 6 Mar 2003 16:13:12 -0500 (EST) Cc: Neil Conway , Christopher Kings-Lynne , daniel alvarez , Richard Huxton , PostgreSQL Performance X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200303/47 X-Sequence-Number: 1345 Tom Lane wrote: > Neil Conway writes: > > Rather than specifying the use of OIDs by WITH OIDS clauses for each > > CREATE TABLE in a dump, couldn't we do it by adding a SET command that > > toggles the 'use_oids' GUC option prior to every CREATE TABLE? > > Seems better than cluttering the CREATE TABLE itself with them, I guess. It would be good to somehow SET the use_oids GUC value on restore start, and just use SET when the table is different than the default, but then there is no mechanism to do that when you restore a single table. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Thu Mar 6 16:14:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id DB938476445 for ; Thu, 6 Mar 2003 16:14:43 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h26LEXx6018206; Thu, 6 Mar 2003 16:14:33 -0500 (EST) To: Bruce Momjian Cc: Christopher Kings-Lynne , daniel alvarez , Richard Huxton , pgsql-performance@postgresql.org Subject: Re: OIDs as keys In-reply-to: <200303062111.h26LB5J03462@candle.pha.pa.us> References: <200303062111.h26LB5J03462@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Thu, 06 Mar 2003 16:11:05 -0500" Date: Thu, 06 Mar 2003 16:14:33 -0500 Message-ID: <18205.1046985273@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/48 X-Sequence-Number: 1346 Bruce Momjian writes: > Why was the schema path called search_path rather than schema_path? Nobody suggested anything different ... it's a bit late now ... regards, tom lane From pgsql-performance-owner@postgresql.org Thu Mar 6 16:16:42 2003 X-Original-To: pgsql-performance@postgresql.org Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id CF6B847647B for ; Thu, 6 Mar 2003 16:16:39 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h26LGMP03992; Thu, 6 Mar 2003 16:16:22 -0500 (EST) From: Bruce Momjian Message-Id: <200303062116.h26LGMP03992@candle.pha.pa.us> Subject: Re: OIDs as keys In-Reply-To: <18205.1046985273@sss.pgh.pa.us> To: Tom Lane Date: Thu, 6 Mar 2003 16:16:22 -0500 (EST) Cc: Christopher Kings-Lynne , daniel alvarez , Richard Huxton , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200303/49 X-Sequence-Number: 1347 Tom Lane wrote: > Bruce Momjian writes: > > Why was the schema path called search_path rather than schema_path? > > Nobody suggested anything different ... it's a bit late now ... I started to think about it when we were talking about a config_path variable. Search path then looked confusing. :-( -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Thu Mar 6 16:23:13 2003 X-Original-To: pgsql-performance@postgresql.org Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 168D1476447 for ; Thu, 6 Mar 2003 16:23:08 -0500 (EST) Received: from DU150.N224.ResNet.QueensU.CA (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 944CF1F2A; Thu, 6 Mar 2003 16:23:03 -0500 (EST) Subject: Re: OIDs as keys From: Neil Conway To: Bruce Momjian Cc: Tom Lane , Christopher Kings-Lynne , daniel alvarez , Richard Huxton , PostgreSQL Performance In-Reply-To: <200303062113.h26LDCP03630@candle.pha.pa.us> References: <200303062113.h26LDCP03630@candle.pha.pa.us> Content-Type: text/plain Organization: Message-Id: <1046985774.10528.57.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 06 Mar 2003 16:22:54 -0500 Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/50 X-Sequence-Number: 1348 On Thu, 2003-03-06 at 16:13, Bruce Momjian wrote: > It would be good to somehow SET the use_oids GUC value on restore start, > and just use SET when the table is different than the default, but then > there is no mechanism to do that when you restore a single table. What if the default value changes? IMHO, running a SET per CREATE TABLE isn't too ugly... Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-performance-owner@postgresql.org Thu Mar 6 18:35:29 2003 X-Original-To: pgsql-performance@postgresql.org Received: from jester.inquent.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id BBDED47647B for ; Thu, 6 Mar 2003 18:35:25 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.inquent.com (8.12.6/8.12.6) with ESMTP id h26NZuhn028169; Thu, 6 Mar 2003 18:36:06 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: Write ahead logging From: Rod Taylor To: Matthias Meixner Cc: Mario Weilguni , Manfred Koizar , Postgresql Performance In-Reply-To: <3E55E8E0.60201@dvs1.informatik.tu-darmstadt.de> References: <3E5494DA.20003@dvs1.informatik.tu-darmstadt.de> <000b01c2d8c2$54008350$8f01c00a@icomedias.com> <3E55E8E0.60201@dvs1.informatik.tu-darmstadt.de> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-doG/irtiL5snTvCvWKzR" Organization: Message-Id: <1046993755.487.86.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 06 Mar 2003 18:35:56 -0500 X-Archive-Number: 200303/51 X-Sequence-Number: 1349 --=-doG/irtiL5snTvCvWKzR Content-Type: text/plain Content-Transfer-Encoding: quoted-printable What were you using to measure the latency. Don't suppose you could send it over. The admins locally don't like what I used to do the test with -- they don't want to turn off write-caching for other reasons. On Fri, 2003-02-21 at 03:52, Matthias Meixner wrote: > Mario Weilguni wrote: > >>>So the question is: has anybody verified, that the log is written to d= isk > >>>before returning from commit? > >> > >>Some (or all?) IDE disks are known to lie: they report success as > >>soon as the data have reached the drive's RAM. > >=20 > >=20 > > under linux, hdparm -W can turn off the write cache of IDE disk, maybe = you > > should try with write-caching turned off. >=20 > Yes, that made a big difference. Latency went up to 25-95ms. >=20 > Regards, >=20 > Matthias Meixner --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-doG/irtiL5snTvCvWKzR Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+Z9tb6DETLow6vwwRAkv+AJ0T7dk6RtoZ1UNB/c2nwNHTtdtzPgCfX65I jm5fX4T0QEG7ORaDGgaaRgY= =/IjU -----END PGP SIGNATURE----- --=-doG/irtiL5snTvCvWKzR-- From pgsql-committers-owner@postgresql.org Thu Mar 6 19:37:03 2003 X-Original-To: pgsql-committers@postgresql.org Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id 3120E47646F; Thu, 6 Mar 2003 19:36:58 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 9CBE42105B; Thu, 6 Mar 2003 16:36:40 -0800 (PST) Date: Thu, 6 Mar 2003 16:36:40 -0800 From: Sean Chittenden To: Tom Lane Cc: Christopher Kings-Lynne , pgsql-committers@postgresql.org, pgsql-performance@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Message-ID: <20030307003640.GF79234@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <15071.1046964336@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HjNkcEWJ4DMx36DP" Content-Disposition: inline In-Reply-To: <15071.1046964336@sss.pgh.pa.us> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/30 X-Sequence-Number: 9273 --HjNkcEWJ4DMx36DP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [moving to -performance, please drop -committers from replies] > > I've toyed with the idea of adding this because it is monstrously more > > efficient than select()/poll() in basically every way, shape, and > > form. >=20 > From what I've looked at, kqueue only wins when you are watching a > large number of file descriptors at the same time; which is an > operation done nowhere in Postgres. I think the above would be a > complete waste of effort. It scales very well to many thousands of descriptors, but it also works well on small numbers as well. kqueue is about 5x faster than select() or poll() on the low end of number of fd's. As I said earlier, I don't think there is _much_ to gain in this regard, but I do think that it would be a speed improvement but only to one OS supported by PostgreSQL. I think that there are bigger speed improvements to be had elsewhere in the code. > > Is this one of the areas of PostgreSQL that just needs to get > > slowly migrated to use mmap() or are there any gaping reasons why > > to not use the family of system calls? >=20 > There has been much speculation on this, and no proof that it > actually buys us anything to justify the portability hit. Actually, I think that it wouldn't be that big of a portability hit because you still would read() and write() as always, but in performance sensitive areas, an #ifdef HAVE_MMAP section would have the appropriate mmap() calls. If the system doesn't have mmap(), there isn't much to loose and we're in the same position we're in now. > There would be some nontrivial problems to solve, such as the > mechanics of accessing a large number of files from a large number > of backends without running out of virtual memory. Also, is it > guaranteed that multiple backends mmap'ing the same block will > access the very same physical buffer, and not multiple copies? > Multiple copies would be fatal. See the acrhives for more > discussion. Have read through the archives. Making a call to madvise() will speed up access to the pages as it gives hints to the VM about what order the pages are accessed/used. Here are a few bits from the BSD mmap() and madvise() man pages: mmap(2): MAP_NOSYNC Causes data dirtied via this VM map to be flushed to physical media only when necessary (usually by the pager) rather then gratuitously. Typically this pre- vents the update daemons from flushing pages dirtied through such maps and thus allows efficient sharing = of memory across unassociated processes using a file- backed shared memory map. Without this option any VM pages you dirty may be flushed to disk every so often (every 30-60 seconds usually) which can create perfo= r- mance problems if you do not need that to occur (such as when you are using shared file-backed mmap regions for IPC purposes). Note that VM/filesystem coherency is maintained whether you use MAP_NOSYNC or not. Th= is option is not portable across UNIX platforms (yet), though some may implement the same behavior by defau= lt. WARNING! Extending a file with ftruncate(2), thus c= re- ating a big hole, and then filling the hole by modif= y- ing a shared mmap() can lead to severe file fragment= a- tion. In order to avoid such fragmentation you shou= ld always pre-allocate the file's backing store by write()ing zero's into the newly extended area prior= to modifying the area via your mmap(). The fragmentati= on problem is especially sensitive to MAP_NOSYNC pages, because pages may be flushed to disk in a totally ra= n- dom order. The same applies when using MAP_NOSYNC to implement a file-based shared memory store. It is recommended t= hat you create the backing store by write()ing zero's to the backing file rather then ftruncate()ing it. You can test file fragmentation by observing the KB/t (kilobytes per transfer) results from an ``iostat 1'' while reading a large file sequentially, e.g. using ``dd if=3Dfilename of=3D/dev/null bs=3D32k''. The fsync(2) function will flush all dirty data and metadata associated with a file, including dirty NOS= YNC VM data, to physical media. The sync(8) command and sync(2) system call generally do not flush dirty NOS= YNC VM data. The msync(2) system call is obsolete since BSD implements a coherent filesystem buffer cache. However, it may be used to associate dirty VM pages with filesystem buffers and thus cause them to be flushed to physical media sooner rather then later. madvise(2): MADV_NORMAL Tells the system to revert to the default paging beha= v- ior. MADV_RANDOM Is a hint that pages will be accessed randomly, and prefetching is likely not advantageous. MADV_SEQUENTIAL Causes the VM system to depress the priority of pages immediately preceding a given page when it is faulted in. mprotect(2): The mprotect() system call changes the specified pages to have protect= ion prot. Not all implementations will guarantee protection on a page bas= is; the granularity of protection changes may be as large as an entire region. A region is the virtual address space defined by the start and end addresses of a struct vm_map_entry. Currently these protection bits are known, which can be combined, OR'd together: PROT_NONE No permissions at all. PROT_READ The pages can be read. PROT_WRITE The pages can be written. PROT_EXEC The pages can be executed. msync(2): The msync() system call writes any modified pages back to the filesyst= em and updates the file modification time. If len is 0, all modified pag= es within the region containing addr will be flushed; if len is non-zero, only those pages containing addr and len-1 succeeding locations will be examined. The flags argument may be specified as follows: MS_ASYNC Return immediately MS_SYNC Perform synchronous writes MS_INVALIDATE Invalidate all cached data A few thoughts come to mind: 1) backends could share buffers by mmap()'ing shared regions of data. While I haven't seen any numbers to reflect this, I'd wager that mmap() is a faster interface than ipc. 2) It looks like while there are various file IO schemes scattered all over the place, the bulk of the critical routines that would need to be updated are in backend/storage/file/fd.c, more specifically: *) fileNameOpenFile() would need the appropriate mmap() call made to it. *) FileTruncate() would need some attention to avoid fragmentation. *) a new "sync" GUC would have to be introduced to handle msync (affects only pg_fsync() and pg_fdatasync()). 3) There's a bit of code in pgsql/src/backend/storage/smgr that could be gutted/removed. Which of those storage types are even used any more? There's a reference in the code to PostgreSQL 3.0. :) And I think that'd be it. The LRU code could be used if necessary to help manage the amount of mmap()'ed in the VM at any one time, at the very least that could be a handled by a shm var that various backends would increment/decrement as files are open()'ed/close()'ed. I didn't spend too long looking at this, but I _think_ that'd cover 80% of PostgreSQL's disk access needs. The next bit to possibly add would be passing a flag on FileOpen operations that'd act as a hint to madvise() that way the VM could proactively react to PostgreSQL's needs. I don't have my copy of Steven's handy (it's some 700mi away atm otherwise I'd cite it), but if Tom or someone else has it handy, look up the example re: the performance gain from read()'ing an mmap()'ed file versus a non-mmap()'ed file. The difference is non-trivial and _WELL_ worth the time given the speed increase. The same speed benefit held true for writes as well, iirc. It's been a while, but I think it was around page 330. The index has it listed and it's not that hard of an example to find. -sc --=20 Sean Chittenden --HjNkcEWJ4DMx36DP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+Z+mY3ZnjH7yEs0ERAjVkAJwMI1V7+HvMAA5ODadD5znsekI8TQCgvH0C KwvG7YLsJ+xpsTUS67KD+4M= =w8/7 -----END PGP SIGNATURE----- --HjNkcEWJ4DMx36DP-- From pgsql-performance-owner@postgresql.org Thu Mar 6 19:47:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 22EA447638C for ; Thu, 6 Mar 2003 19:47:54 -0500 (EST) Received: from DU150.N224.ResNet.QueensU.CA (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id CF93F1F27; Thu, 6 Mar 2003 19:47:56 -0500 (EST) Subject: Re: [COMMITTERS] pgsql-server/ /configure /configure.in rc/incl ... From: Neil Conway To: Sean Chittenden Cc: Tom Lane , Christopher Kings-Lynne , PostgreSQL Performance In-Reply-To: <20030307003640.GF79234@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <15071.1046964336@sss.pgh.pa.us> <20030307003640.GF79234@perrin.int.nxad.com> Content-Type: text/plain Organization: Message-Id: <1046998072.10527.67.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 06 Mar 2003 19:47:52 -0500 Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/53 X-Sequence-Number: 1351 On Thu, 2003-03-06 at 19:36, Sean Chittenden wrote: > I don't have my copy of Steven's handy (it's some 700mi away atm > otherwise I'd cite it), but if Tom or someone else has it handy, look > up the example re: the performance gain from read()'ing an mmap()'ed > file versus a non-mmap()'ed file. The difference is non-trivial and > _WELL_ worth the time given the speed increase. Can anyone confirm this? If so, one easy step we could take in this direction would be adapting COPY FROM to use mmap(). Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-performance-owner@postgresql.org Thu Mar 6 20:51:19 2003 X-Original-To: pgsql-performance@postgresql.org Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 2803E476368 for ; Thu, 6 Mar 2003 20:51:15 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h271oaW02436; Thu, 6 Mar 2003 20:50:36 -0500 (EST) From: Bruce Momjian Message-Id: <200303070150.h271oaW02436@candle.pha.pa.us> Subject: Re: OIDs as keys In-Reply-To: <1046985774.10528.57.camel@tokyo> To: Neil Conway Date: Thu, 6 Mar 2003 20:50:36 -0500 (EST) Cc: Tom Lane , Christopher Kings-Lynne , daniel alvarez , Richard Huxton , PostgreSQL Performance X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200303/54 X-Sequence-Number: 1352 Neil Conway wrote: > On Thu, 2003-03-06 at 16:13, Bruce Momjian wrote: > > It would be good to somehow SET the use_oids GUC value on restore start, > > and just use SET when the table is different than the default, but then > > there is no mechanism to do that when you restore a single table. > > What if the default value changes? > > IMHO, running a SET per CREATE TABLE isn't too ugly... Not ugly, but a little noisy. However, my idea of having a single SET at the top is never going to work, so I don't have a better idea. The killer for me is that you are never going to know the GUC default when you are loading, so we are _always_ going to have that SET for each table. I suppose we could set the default to off, and set it ON in the dump only when we want OID. If they set GUC to on, they will get oid's from the load, but it will cut down on the cruft and over time, they will only have the SET for cases where they really want an oid. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-admin-owner@postgresql.org Fri Mar 7 00:37:58 2003 X-Original-To: pgsql-admin@postgresql.org Received: from ndl1mr1-a-fixed (ndl1mr1-a-fixed.sancharnet.in [61.0.0.45]) by postgresql.org (Postfix) with ESMTP id 56FBE47655D; Fri, 7 Mar 2003 00:37:43 -0500 (EST) Received: from conversion-daemon.ndl1mr1-a-fixed.sancharnet.in by ndl1mr1-a-fixed.sancharnet.in (iPlanet Messaging Server 5.2 HotFix 0.9 (built Jul 29 2002)) id <0HBD00A015UCBP@ndl1mr1-a-fixed.sancharnet.in>; Fri, 07 Mar 2003 11:07:47 +0530 (IST) Received: from societykotla ([61.0.95.125]) by ndl1mr1-a-fixed.sancharnet.in (iPlanet Messaging Server 5.2 HotFix 0.9 (built Jul 29 2002)) with ESMTPA id <0HBD001M76APHN@ndl1mr1-a-fixed.sancharnet.in>; Fri, 07 Mar 2003 11:07:47 +0530 (IST) Date: Fri, 07 Mar 2003 11:03:14 +0530 From: Aspire Something Subject: Re: New Interface for Win To: php-db , PG Performance , pgsql-novice , Pg Admin Reply-To: Aspire Something Message-id: <002a01c2e46c$33a5cce0$c9c832c0@societykotla> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Mailer: Microsoft Outlook Express 6.00.2600.0000 Content-type: multipart/alternative; boundary="Boundary_(ID_hByawvmqD/DPphgpYdxaXQ)" X-Priority: 3 X-MSMail-priority: Normal References: <000201c2e3ce$5702bac0$de00a8c0@fhf> X-Archive-Number: 200303/55 X-Sequence-Number: 7703 This is a multi-part message in MIME format. --Boundary_(ID_hByawvmqD/DPphgpYdxaXQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Hi all PostgreSQL users, I would recomend PDAdmin. It's a great tool for windows user it has, 1. Good interface 2. Support for Creating functions and Trgers and MORE >>> What it avoid is the dirty interface of PGadmin2 It's nearly equivilant to the EMS Postgresql Tool. Give it a try V Kashyap ----- Original Message ----- From: Mr.F To: pgsql-admin@postgresql.org Sent: Thursday, March 06, 2003 4:21 PM Subject: [ADMIN] New Interface for Win Hi all, After two month we have been migrating from Ms-Sql Server 7 to PosgreSQL 7.3, we also build new interface to connect from client in Win base to Posgresql and it call "PDAdmin". PDAdmin is a Posgresql tools to help Database Administrator (DBA) for a make a Trigger, Function, or Rule quickly because the User just could input the parameters that important only and then the program will perform frame program automatically and can generate script Trigger/Function/Rule from posgresql database just click in table or schema. PDAdmin be make by concept and method difference by data tools for same PosgreSQL like PgAdmin, because first concept this program to help DBA for beginner or advance (in my team) to make transactional script to be use in PosgreSQL Version 7.3 like Trigger, Function or Rule easily, quick and flexible with show capability the editor. Now, we wishful to share "PDAdmin version 1.0.5" in this milist "FREE" Other features: -. Connection to PosgreSQL server without ODBC -. Update condition of trigger with choice checkbox or radio button. -. Available Database Explorer -. Shortcut to general function PostreSQL -. User define shortcut -. Block Execute Command -. Block Increase/Decrease Indent -. Export Trigger/Function/Rule from database to file -. Import data from Ms-Sql Server -. Freeware, No Limit, No Ads. Requirements: -. Windows 95/98/Me/NT/2000/XP -. File Size 1150Kb -. Uninstaller Included: Yes -. Recommended: PosgreSQL 7.3.x Download: http://www.csahome.com/download/PDAdmin/PDASetup.exe Screenshot: http://www.csahome.com/download/PDAdmin/pdadmin1.jpg Regards, Fadjar Hamidi --Boundary_(ID_hByawvmqD/DPphgpYdxaXQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable
Hi all PostgreSQL users,<= /DIV>
 
I would recomend PDAdmin. It's a= great=20 tool for windows user it has,
1. Good interface
2. Support for Creating function= s and=20 Trgers and MORE >>>
What it avoid is  the dirty interface of=20 PGadmin2
It's nearly equivilant to the EM= S=20 Postgresql Tool.
 
Give it a try
 
V Kashyap
 
----- Original Message -----
Fro= m:=20 Mr.F=
Sent: Thursday, March 06, 2003 4:2= 1=20 PM
Subject: [ADMIN] New Interface for= =20 Win

Hi=20 all,

 

After two month we have bee= n=20 migrating from Ms-Sql Server 7 to PosgreSQL 7.3, we also build new interf= ace=20 to connect from client in Win base to Posgresql and it call =93PDAdmin=94= . PDAdmin=20 is a Posgresql tools to help Database Administrator (DBA) for a make a=20 Trigger, Function, or Rule quickly because the User just could input the= =20 parameters that important only and then the program will perform frame pr= ogram=20 automatically and can generate script Trigger/Function/Rule from posgresq= l=20 database just click in table or schema.

 

PDAdmin be make by concept = and=20 method difference by data tools for same PosgreSQL like PgAdmin, because = first=20 concept this program to help DBA for beginner or advance (in my team) to = make=20 transactional script to be use in PosgreSQL Version 7.3 like Trigger, Fun= ction=20 or Rule easily, quick and flexible with show capability the editor.=20

 

Now, we wishful to share = =93PDAdmin=20 version 1.0.5=94 in this milist =93FREE=94

 

Other=20 features:

-. Connection to PosgreSQL = server=20 without ODBC

-. Update condition of trig= ger=20 with choice checkbox or radio button.

-. Available Database=20 Explorer

-. Shortcut to general func= tion=20 PostreSQL

-. User define=20 shortcut

-. Block Execute=20 Command

-. Block Increase/Decrease= =20 Indent

-. Export Trigger/Function/= Rule=20 from database to file

-. Import data from Ms-Sql= =20 Server

-. Freeware, No Limit, No= =20 Ads.

 

Requirements:

-.=20 Windows=20 95/98/Me/NT/2000/XP

-. File Size=20 1150Kb

-. Uninstaller Included:=20 Yes

-. Recommended: PosgreSQL= =20 7.3.x

 

Download:=20

http://www.= csahome.com/download/PDAdmin/PDASetup.exe

 

Screenshot:

http://www.= csahome.com/download/PDAdmin/pdadmin1.jpg

 

Regards,

Fadjar Hamidi

--Boundary_(ID_hByawvmqD/DPphgpYdxaXQ)-- From pgsql-performance-owner@postgresql.org Fri Mar 7 01:05:50 2003 X-Original-To: pgsql-performance@postgresql.org Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id F16034768E2 for ; Fri, 7 Mar 2003 01:04:33 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 7969A21065; Thu, 6 Mar 2003 22:04:12 -0800 (PST) Date: Thu, 6 Mar 2003 22:04:12 -0800 From: Sean Chittenden To: Neil Conway Cc: Tom Lane , Christopher Kings-Lynne , PostgreSQL Performance Subject: Re: [COMMITTERS] pgsql-server/ /configure /configure.in rc/incl ... Message-ID: <20030307060412.GA19138@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <15071.1046964336@sss.pgh.pa.us> <20030307003640.GF79234@perrin.int.nxad.com> <1046998072.10527.67.camel@tokyo> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline In-Reply-To: <1046998072.10527.67.camel@tokyo> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/56 X-Sequence-Number: 1354 --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > > I don't have my copy of Steven's handy (it's some 700mi away atm > > otherwise I'd cite it), but if Tom or someone else has it handy, look > > up the example re: the performance gain from read()'ing an mmap()'ed > > file versus a non-mmap()'ed file. The difference is non-trivial and > > _WELL_ worth the time given the speed increase. >=20 > Can anyone confirm this? If so, one easy step we could take in this > direction would be adapting COPY FROM to use mmap(). Weeee! Alright, so I got to have some fun writing out some simple tests with mmap() and friends tonight. Are the results interesting? Absolutely! Is this a simple benchmark? Yup. Do I think it simulates PostgreSQL? Eh, not particularly. Does it demonstrate that mmap() is a win and something worth implementing? I sure hope so. Is this a test program to demonstrate the ideal use of mmap() in PostgreSQL? No. Is it a place to start a factual discussion? I hope so. I have here four tests that are conditionalized by cpp. # The first one uses read() and write() but with the buffer size set # to the same size as the file. gcc -O3 -finline-functions -fkeep-inline-functions -funroll-loops -o test-= mmap test-mmap.c /usr/bin/time ./test-mmap > /dev/null Beginning tests with file: services Page size: 4096 File read size is the same as the file size Number of iterations: 100000 Start time: 1047013002.412516 Time: 82.88178 Completed tests 82.09 real 2.13 user 68.98 sys # The second one uses read() and write() with the default buffer size: # 65536 gcc -O3 -finline-functions -fkeep-inline-functions -funroll-loops -DDEFAUL= T_READSIZE=3D1 -o test-mmap test-mmap.c /usr/bin/time ./test-mmap > /dev/null Beginning tests with file: services Page size: 4096 File read size is default read size: 65536 Number of iterations: 100000 Start time: 1047013085.16204 Time: 18.155511 Completed tests 18.16 real 0.90 user 14.79 sys # Please note this is significantly faster, but that's expected # The third test uses mmap() + madvise() + write() gcc -O3 -finline-functions -fkeep-inline-functions -funroll-loops -DDEFAUL= T_READSIZE=3D1 -DDO_MMAP=3D1 -o test-mmap test-mmap.c /usr/bin/time ./test-mmap > /dev/null Beginning tests with file: services Page size: 4096 File read size is the same as the file size Number of iterations: 100000 Start time: 1047013103.859818 Time: 8.4294203644 Completed tests 7.24 real 0.41 user 5.92 sys # Faster still, and twice as fast as the normal read() case # The last test only calls mmap()'s once when the file is opened and # only msync()'s, munmap()'s, close()'s the file once at exit. gcc -O3 -finline-functions -fkeep-inline-functions -funroll-loops -DDEFAUL= T_READSIZE=3D1 -DDO_MMAP=3D1 -DDO_MMAP_ONCE=3D1 -o test-mmap test-mmap.c /usr/bin/time ./test-mmap > /dev/null Beginning tests with file: services Page size: 4096 File read size is the same as the file size Number of iterations: 100000 Start time: 1047013111.623712 Time: 1.174076 Completed tests 1.18 real 0.09 user 0.92 sys # Substantially faster Obviously this isn't perfect, but reading and writing data is faster (specifically moving pages through the VM/OS). Doing partial writes from mmap()'ed data should be faster along with scanning through mmap()'ed portions of - or completely mmap()'ed - files because the pages are already loaded in the VM. PostgreSQL's LRU file descriptor cache could easily be adjusted to add mmap()'ing of frequently accessed files (specifically, system catalogs come to mind). It's not hard to figure out how often particular files are accessed and to either _avoid_ mmap()'ing a file that isn't accessed often, or to mmap() files that _are_ accessed often. mmap() does have a cost, but I'd wager that mmap()'ing the same file a second or third time from a different process would be more efficient. The speedup of searching through an mmap()'ed file may be worth it, however, to mmap() all files if the system is under a tunable resource limit (max_mmaped_bytes?). If someone is so inclined or there's enough interest, I can reverse this test case so that data is written to an mmap()'ed file, but the same performance difference should hold true (assuming this isn't a write to a tape drive ::grin::). The URL for the program used to generate the above tests is at: http://people.freebsd.org/~seanc/mmap_test/ Please ask if you have questions. -sc --=20 Sean Chittenden --KsGdsel6WgEHnImy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+aDZc3ZnjH7yEs0ERAid6AJ9/TAYMUx2+ZcD2680OlKJBj5FzrACgquIG PBNCzM0OegBXrPROJ/uIKDM= =y7O6 -----END PGP SIGNATURE----- --KsGdsel6WgEHnImy-- From pgsql-admin-owner@postgresql.org Fri Mar 7 01:46:38 2003 X-Original-To: pgsql-admin@postgresql.org Received: from 127.0.0.1 (unknown [61.5.117.33]) by postgresql.org (Postfix) with SMTP id 6EC1F476375 for ; Fri, 7 Mar 2003 01:46:29 -0500 (EST) From: "Mr.F" To: "'Pg Admin'" , "'Aspire Something'" Subject: Re: New Interface for Win Date: Fri, 7 Mar 2003 13:47:32 +0700 Message-ID: <000c01c2e475$6d9baa60$de00a8c0@fhf> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000D_01C2E4B0.19FA8260" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 In-Reply-To: <002a01c2e46c$33a5cce0$c9c832c0@societykotla> Importance: Normal X-GCMulti: 1 X-Archive-Number: 200303/56 X-Sequence-Number: 7704 This is a multi-part message in MIME format. ------=_NextPart_000_000D_01C2E4B0.19FA8260 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Thanks for your support specially for publishing PDAdmin to the posgresql users. Please send me email if you have any idea or advice to make it better. Regards, Fadjar Hamidi Another URL to download: http://www.geocities.com/fadjarh -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Aspire Something Sent: 07 Maret 2003 12:33 To: php-db; PG Performance; pgsql-novice; Pg Admin Subject: Re: [ADMIN] New Interface for Win Hi all PostgreSQL users, I would recomend PDAdmin. It's a great tool for windows user it has, 1. Good interface 2. Support for Creating functions and Trgers and MORE >>> What it avoid is the dirty interface of PGadmin2 It's nearly equivilant to the EMS Postgresql Tool. Give it a try V Kashyap ------=_NextPart_000_000D_01C2E4B0.19FA8260 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ------=_NextPart_000_000D_01C2E4B0.19FA8260-- From pgsql-performance-owner@postgresql.org Fri Mar 7 03:44:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mailserver1.hrz.tu-darmstadt.de (mailserver1.hrz.tu-darmstadt.de [130.83.126.41]) by postgresql.org (Postfix) with ESMTP id 3AA694760CC for ; Fri, 7 Mar 2003 03:44:42 -0500 (EST) Received: from paris (paris.dvs1.informatik.tu-darmstadt.de [130.83.27.43]) by mailserver1.hrz.tu-darmstadt.de (8.12.8/8.12.8) with ESMTP id h278iNEq004951; Fri, 7 Mar 2003 09:44:24 +0100 Received: from dvs1.informatik.tu-darmstadt.de (bali [130.83.27.100]) by paris (Postfix) with ESMTP id 2949FFF05; Fri, 7 Mar 2003 09:44:23 +0100 (MET) Message-ID: <3E685BE6.4090008@dvs1.informatik.tu-darmstadt.de> Date: Fri, 07 Mar 2003 09:44:22 +0100 From: Matthias Meixner User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: de, en MIME-Version: 1.0 To: Rod Taylor Cc: Mario Weilguni , Manfred Koizar , Postgresql Performance Subject: Re: Write ahead logging References: <3E5494DA.20003@dvs1.informatik.tu-darmstadt.de> <000b01c2d8c2$54008350$8f01c00a@icomedias.com> <3E55E8E0.60201@dvs1.informatik.tu-darmstadt.de> <1046993755.487.86.camel@jester> In-Reply-To: <1046993755.487.86.camel@jester> X-Enigmail-Version: 0.71.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-MailScanner: Found to be clean X-Archive-Number: 200303/57 X-Sequence-Number: 1355 Rod Taylor wrote: > What were you using to measure the latency. Don't suppose you could > send it over. The admins locally don't like what I used to do the test > with -- they don't want to turn off write-caching for other reasons. I am doing an insert of few bytes, so that the amount of data does not significantly affect the measured time. And for measuring time without cache, I temporarily switched it off. That was the code used (nothing unusual): #include "timeval.h" main() { Timeval start,end; EXEC SQL WHENEVER sqlerror sqlprint; EXEC SQL WHENEVER not found sqlprint; EXEC SQL CONNECT TO user@localhost; start=Timeval::Time(); EXEC SQL BEGIN; EXEC SQL INSERT INTO test values ('qwertz'); EXEC SQL COMMIT; end=Timeval::Time(); end-=start; printf("time: %d.%06d\n",end.tv_sec,end.tv_usec); } - Matthias Meixner -- Matthias Meixner meixner@informatik.tu-darmstadt.de Technische Universit�t Darmstadt Datenbanken und Verteilte Systeme Telefon (+49) 6151 16 6232 Wilhelminenstra�e 7, D-64283 Darmstadt, Germany Fax (+49) 6151 16 6229 From pgsql-performance-owner@postgresql.org Fri Mar 7 09:29:52 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 4847E475F53 for ; Fri, 7 Mar 2003 09:29:49 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h27ETkx6029934; Fri, 7 Mar 2003 09:29:46 -0500 (EST) To: Sean Chittenden Cc: Neil Conway , Christopher Kings-Lynne , PostgreSQL Performance Subject: Re: [COMMITTERS] pgsql-server/ /configure /configure.in rc/incl ... In-reply-to: <20030307060412.GA19138@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <15071.1046964336@sss.pgh.pa.us> <20030307003640.GF79234@perrin.int.nxad.com> <1046998072.10527.67.camel@tokyo> <20030307060412.GA19138@perrin.int.nxad.com> Comments: In-reply-to Sean Chittenden message dated "Thu, 06 Mar 2003 22:04:12 -0800" Date: Fri, 07 Mar 2003 09:29:46 -0500 Message-ID: <29933.1047047386@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/58 X-Sequence-Number: 1356 Sean Chittenden writes: > Absolutely! Is this a simple benchmark? Yup. Do I think it > simulates PostgreSQL? Eh, not particularly. This would be on what OS? What hardware? What size test file? Do the "iterations" mean so many reads of the entire file, or so many buffer-sized read requests? Did the mmap case actually *read* anything, or just map and unmap the file? Also, what did you do to normalize for the effects of the test file being already in kernel disk cache after the first test? regards, tom lane From pgsql-performance-owner@postgresql.org Fri Mar 7 16:09:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from pd2mo3so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by postgresql.org (Postfix) with ESMTP id A58F247622E for ; Fri, 7 Mar 2003 16:09:53 -0500 (EST) Received: from pd3mr3so.prod.shaw.ca (pd3mr3so-ser.prod.shaw.ca [10.0.141.179]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0HBE00CJZDGIZ6@l-daemon> for pgsql-performance@postgresql.org; Fri, 07 Mar 2003 14:09:54 -0700 (MST) Received: from pn2ml2so.prod.shaw.ca (pn2ml2so-qfe0.prod.shaw.ca [10.0.121.146]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0HBE00DFMDGIK6@l-daemon> for pgsql-performance@postgresql.org; Fri, 07 Mar 2003 14:09:54 -0700 (MST) Received: from power ([24.80.229.122]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0HBE00K9BDGIBJ@l-daemon> for pgsql-performance@postgresql.org; Fri, 07 Mar 2003 14:09:54 -0700 (MST) Date: Fri, 07 Mar 2003 13:21:09 -0800 From: Daniel Bruce Lynes Subject: Stored Procedures and compiling To: PostgreSQL Performance Message-id: <200303071321.09981.dlynes@shaw.ca> MIME-version: 1.0 X-Mailer: KMail [version 1.4] Content-type: text/plain; charset=gb2312 Content-transfer-encoding: 7BIT X-Archive-Number: 200303/59 X-Sequence-Number: 1357 Hello. I am curious if there is any planned support for full stored procedure compiling? I've seen that PostgreSQL does not compile the SQL code inside plpgsql code. It is merely interpreted when the procedure gets called. This is also documented in the main html documentation. What I am wondering specifically is if stored procedure compiling will work similar to Oracle's stored procedure compilation in the future? Thanks From pgsql-performance-owner@postgresql.org Fri Mar 7 16:46:54 2003 X-Original-To: pgsql-performance@postgresql.org Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id 913B5474E44 for ; Fri, 7 Mar 2003 16:46:50 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id A55392105B; Fri, 7 Mar 2003 13:46:30 -0800 (PST) Date: Fri, 7 Mar 2003 13:46:30 -0800 From: Sean Chittenden To: Tom Lane Cc: Neil Conway , Christopher Kings-Lynne , PostgreSQL Performance Subject: Re: [COMMITTERS] pgsql-server/ /configure /configure.in rc/incl ... Message-ID: <20030307214630.GI79234@perrin.int.nxad.com> References: <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <15071.1046964336@sss.pgh.pa.us> <20030307003640.GF79234@perrin.int.nxad.com> <1046998072.10527.67.camel@tokyo> <20030307060412.GA19138@perrin.int.nxad.com> <29933.1047047386@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TALVG7vV++YnpwZG" Content-Disposition: inline In-Reply-To: <29933.1047047386@sss.pgh.pa.us> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/60 X-Sequence-Number: 1358 --TALVG7vV++YnpwZG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > > Absolutely! Is this a simple benchmark? Yup. Do I think it > > simulates PostgreSQL? Eh, not particularly. I think quite a few of these Q's would have been answered by reading the code/Makefile.... > This would be on what OS? FreeBSD, but it shouldn't matter. Any reasonably written VM should have similar numbers (though BSD is generally regarded as having the best VM, which, I think Linux poached not that long ago, iirc ::grimace::). > What hardware? My ultra-pathetic laptop with some fine - overly-noisy and can hardly buildworld - IDE drives. > What size test file? In this case, only 72K. I've just updated the test program to use an array of files though. > Do the "iterations" mean so many reads of the entire file, or so > many buffer-sized read requests? In some cases, yes. With the file mmap()'ed, sorta. One of the test cases (the one that did it in ~8s), mmap()'ed and munmap()'ed the file every iteration and was twice as fast as the vanilla read() call. > Did the mmap case actually *read* anything, or just map and unmap > the file? Nope, read it and wrote it out to stdout (which was redirected to /dev/null). > Also, what did you do to normalize for the effects of the test file > being already in kernel disk cache after the first test? That honestly doesn't matter too much since I wasn't testing the rate of reading in files from my hard drive, only the OS's ability to read/write pages of data around. In any case, I've updated my test case to iterate through an array of files instead of just reading in a copy of /etc/services. My laptop is generally a poor benchmark for disk read performance given it takes 8hrs to buildworld, over 12hrs to build mozilla, 18 for KDE, and about 48hrs for Open Office. :) Someone with faster disks may want to try this and report back, but it doesn't matter much in terms of relevancy for considering the benefits of mmap(). The point is that there are calls that can be used that substantially speed up read()'s and write()'s by allowing the VM to align pages of data and give hints about its usage. For the sake of argument re: the previously done tests, I'll reverse the order in which I ran them and I bet dime to dollar that the times will be identical. % make = ~/open_source/mmap_test cp -f /etc/services ./services gcc -O3 -finline-functions -fkeep-inline-functions -funroll-loops -DDEFAUL= T_READSIZE=3D1 -DDO_MMAP=3D1 -DDO_MMAP_ONCE=3D1 -o mmap-test mmap-test.c /usr/bin/time ./mmap-test > /dev/null Beginning tests with file: services Page size: 4096 File read size is the same as the file size Number of iterations: 100000 Start time: 1047064672.276544 Time: 1.281477 Completed tests 1.29 real 0.10 user 0.92 sys gcc -O3 -finline-functions -fkeep-inline-functions -funroll-loops -DDEFAUL= T_READSIZE=3D1 -DDO_MMAP=3D1 -o mmap-test mmap-test.c /usr/bin/time ./mmap-test > /dev/null Beginning tests with file: services Page size: 4096 File read size is the same as the file size Number of iterations: 100000 Start time: 1047064674.266191 Time: 7.486622 Completed tests 7.49 real 0.41 user 6.01 sys gcc -O3 -finline-functions -fkeep-inline-functions -funroll-loops -DDEFAUL= T_READSIZE=3D1 -o mmap-test mmap-test.c /usr/bin/time ./mmap-test > /dev/null Beginning tests with file: services Page size: 4096 File read size is default read size: 65536 Number of iterations: 100000 Start time: 1047064682.288637 Time: 19.35214 Completed tests 19.04 real 0.88 user 15.43 sys gcc -O3 -finline-functions -fkeep-inline-functions -funroll-loops -o mmap-= test mmap-test.c /usr/bin/time ./mmap-test > /dev/null Beginning tests with file: services Page size: 4096 File read size is the same as the file size Number of iterations: 100000 Start time: 1047064701.867031 Time: 82.4294540875 Completed tests 81.57 real 2.10 user 69.55 sys Here's the updated test that iterates through. Ooh! One better, the files I've used are actual data files from ~pgsql. The new benchmark iterates through the list of files and and calls bench() once for each file and restarts at the first file after reaching the end of its list (ARGV). Whoa, if these tests are even close to real world, then we at the very least should be mmap()'ing the file every time we read it (assuming we're reading more than just a handful of bytes): find /usr/local/pgsql/data -type f | /usr/bin/xargs /usr/bin/time ./mmap-te= st > /dev/null Page size: 4096 File read size is the same as the file size Number of iterations: 100000 Start time: 1047071143.463360 Time: 12.109530 Completed tests 12.11 real 0.36 user 6.80 sys find /usr/local/pgsql/data -type f | /usr/bin/xargs /usr/bin/time ./mmap-te= st > /dev/null Page size: 4096 File read size is default read size: 65536 Number of iterations: 100000 .... [been waiting here for >40min now....] Ah well, if these tests finish this century, I'll post the results in a bit, but it's pretty clearly a win. In terms of the data that I'm copying, I'm copying ~700MB of data from my test DB on my laptop. I only have 256MB of RAM so I can pretty much promise you that the data isn't in my system buffers. If anyone else would like to run the tests or look at the results, please check it out: o1 and o2 should be the only targets used if FILES is bigger than the RAM on the system. o3's by far and away the fastest, but only in rare cases will a DBA have more RAM than data. But, as mentioned earlier, the LRU cache could easily be modified to munmap() infrequently accessed files to keep the size of mmap()'ed data down to a reasonable level. The updated test programs are at: http://people.FreeBSD.org/~seanc/mmap_test/ -sc --=20 Sean Chittenden --TALVG7vV++YnpwZG Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: Sean Chittenden iD8DBQE+aRM23ZnjH7yEs0ERAoqhAKCFgmhpvNMqe9tucoFvK1H6J50z2QCeIZEI mgBHwu/H1pe1sXIX9UG2V+I= =cFRQ -----END PGP SIGNATURE----- --TALVG7vV++YnpwZG-- From pgsql-performance-owner@postgresql.org Fri Mar 7 19:15:47 2003 X-Original-To: pgsql-performance@postgresql.org Received: from OLYMPIA.breakwater.net (mail.breakwater.net [198.202.150.6]) by postgresql.org (Postfix) with ESMTP id ED366474E44 for ; Fri, 7 Mar 2003 19:15:44 -0500 (EST) Received: by OLYMPIA.breakwater.net with Internet Mail Service (5.5.2650.21) id ; Fri, 7 Mar 2003 16:15:42 -0800 Message-ID: <3D6F4C287380B1419D7427E111FA3207C68863@OLYMPIA.breakwater.net> From: Lucas Adamski To: "Postgresql Performance Mailing list (E-mail)" Subject: Index / Performance issues Date: Fri, 7 Mar 2003 16:15:42 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2E507.DAF007F4" X-Archive-Number: 200303/61 X-Sequence-Number: 1359 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_01C2E507.DAF007F4 Content-Type: text/plain; charset="ISO-8859-1" Hi all, I've been using pgsql heavily for about 2 years now, and I keep running into some index-related wierdness that's rather puzzling. This is for release 7.2.1, so if a more recent release has solved these, great! Never the less: I have a table with about 170,000 rows, each of them a network event. I also have a serial 8 primary key set up, with a corresponding (unique) btree index. The primary key is basically sequential, being incremented dynamically at insert time. The problems I've had revolve around selecting an individual entry, or trying to figure out the current maximum ID in the table. In both cases, the results are rather counter-intuitive. Example below, with my comments in bold. I've had this problem using functions such as max(), etc. For example: Obvious way, using max(): # explain analyze select max(my_e_id) from my_events; Aggregate (cost=68132.85..68132.85 rows=1 width=8) (actual time=16103.03..16103.03 rows=1 loops=1) -> Seq Scan on my_events (cost=0.00..67699.28 rows=173428 width=8) (actual time=0.09..15932.27 rows=173480 loops=1) Total runtime: 16103.11 msec Obtuse way, using ORDER BY DESC/LIMIT # explain analyze select my_e_id from sn_events ORDER BY my_e_id DESC LIMIT 1; Limit (cost=0.00..1.48 rows=1 width=8) (actual time=36.02..36.03 rows=1 loops=1) -> Index Scan Backward using my_events_pkey on my_events (cost=0.00..256931.94 rows=173428 width=8) (actual time=36.02..36.02 rows=2 loops= 1) Total runtime: 36.09 msec In this case, the obtuse way is faster... 446 times faster, in fact. I'd understand if this was a corner cases, but this has been the situation with ever PGSQL db I've built. Here's another example, just trying to pick out a single random entry out of a 170,000. First, the simple approach (status quo): # explain analyze select * from my_events WHERE my_e_id = 10800000; Seq Scan on my_events (cost=0.00..68132.85 rows=1 width=771) (actual time=15916.75..16337.31 rows=1 loops=1) Total runtime: 16337.42 msec Pretty darned slow.. (16 secs in fact, ouch). So now lets try our idea with limiting the query by order it in reverse order, and limiting to 1 result (even though the limit is unnecessary, but performance is identical without it) # explain analyze select * from my_events WHERE my_e_id = 10800000 ORDER BY my_e_id DESC LIMIT 1; Limit (cost=68132.86..68132.86 rows=1 width=771) (actual time=16442.42..16442.43 rows=1 loops=1) -> Sort (cost=68132.86..68132.86 rows=1 width=771) (actual time=16442.42..16442.42 rows=1 loops=1) -> Seq Scan on my_events (cost=0.00..68132.85 rows=1 width=771) (actual time=16009.50..16441.91 rows=1 loops=1) Total runtime: 16442.70 msec Well, that's not any better... over a few runs, sometimes this was even slower that the status quo. Well, at this point there was only one thing left to try... put in a <= in place of =, and see if it made a difference. # explain analyze select * from my_events WHERE my_e_id <= 10800000 ORDER BY my_e_id DESC LIMIT 1; Limit (cost=0.00..5.52 rows=1 width=771) (actual time=474.40..474.42 rows=1 loops=1) -> Index Scan Backward using my_events_pkey on my_events (cost=0.00..257365.51 rows=46663 width=771) (actual time=474.39..474.41 rows=2 loo ps=1) Total runtime: 474.55 msec Oddly enough, it did... note the "Index Scan Backward"... finally! So for whatever reason, the DB decides not to use an index scan unless there's a greater or less than comparison operator in conjunction with an ORDER BY/LIMIT. Now it takes half a second, instead of 16. # explain analyze select * from my_events WHERE my_e_id >= 10800000 ORDER BY my_e_id LIMIT 1; Limit (cost=0.00..2.03 rows=1 width=771) (actual time=1379.74..1379.76 rows=1 loops=1) -> Index Scan using my_events_pkey on my_events (cost=0.00..257365.51 rows=126765 width=771) (actual time=1379.73..1379.75 rows=2 loops=1) Total runtime: 1380.10 msec Just for fun, run it in regular order (front to back, versus back to front, looking for >=). Sure enough, still far better than the scan... 1.4 seconds vs 16. So even the worst case index scan is still far better than the default approach. Note that I tried using "set enable_seqscan=off", and it STILL insisted on scanning the table, but even slower this time. Am I missing something really obvious? Is there a proven way to consistantly encourage it to use indexes for these sorts of (rather obvious) queries? Several runs of the above resulted in some variations in run time, but the corresponding orders of difference performance stayed pretty consistant. I'm just confused as to why I have to go through such convoluted methods to force it to use the index when its obviously a FAR more efficient route to go regardless of which order it scans it in (forwards or backwards). Any thoughts are appreciated. Thanks! Lucas. ------_=_NextPart_001_01C2E507.DAF007F4 Content-Type: text/html; charset="ISO-8859-1"
Hi all,
 
I've been using pgsql heavily for about 2 years now, and I keep running into some index-related wierdness that's rather puzzling.  This is for release 7.2.1, so if a more recent release has solved these, great!  Never the less:
 
I have a table with about 170,000 rows, each of them a network event.  I also have a serial 8 primary key set up, with a corresponding (unique) btree index.  The primary key is basically sequential, being incremented dynamically at insert time.  The problems I've had revolve around selecting an individual entry, or trying to figure out the current maximum ID in the table.  In both cases, the results are rather counter-intuitive.  Example below, with my comments in bold.

I've had this problem using functions such as max(), etc.  For example:

Obvious way, using max():

# explain analyze select max(my_e_id) from my_events;
Aggregate  (cost=68132.85..68132.85 rows=1 width=8) (actual time=16103.03..16103.03 rows=1 loops=1)
  ->  Seq Scan on my_events  (cost=0.00..67699.28 rows=173428 width=8) (actual time=0.09..15932.27 rows=173480 loops=1)
Total runtime: 16103.11 msec

Obtuse way, using ORDER BY DESC/LIMIT

# explain analyze select my_e_id from sn_events ORDER BY my_e_id DESC LIMIT 1;
Limit  (cost=0.00..1.48 rows=1 width=8) (actual time=36.02..36.03 rows=1 loops=1)
  ->  Index Scan Backward using my_events_pkey on my_events  (cost=0.00..256931.94 rows=173428 width=8) (actual time=36.02..36.02 rows=2 loops=
1)
Total runtime: 36.09 msec

In this case, the obtuse way is faster... 446 times faster, in fact.  I'd understand if this was a corner cases, but this has been the situation with ever PGSQL db I've built.

Here's another example, just trying to pick out a single random entry out of a 170,000. 
First, the simple approach (status quo):

# explain analyze select * from my_events WHERE my_e_id = 10800000;                                                                    
Seq Scan on my_events  (cost=0.00..68132.85 rows=1 width=771) (actual time=15916.75..16337.31 rows=1 loops=1)
Total runtime: 16337.42 msec

Pretty darned slow.. (16 secs in fact, ouch).  So now lets try our idea with limiting the query by order it in reverse order, and limiting to 1 result (even though the limit is unnecessary, but performance is identical without it)

# explain analyze select * from my_events WHERE my_e_id = 10800000 ORDER BY my_e_id DESC LIMIT 1;
Limit  (cost=68132.86..68132.86 rows=1 width=771) (actual time=16442.42..16442.43 rows=1 loops=1)
  ->  Sort  (cost=68132.86..68132.86 rows=1 width=771) (actual time=16442.42..16442.42 rows=1 loops=1)
        ->  Seq Scan on my_events  (cost=0.00..68132.85 rows=1 width=771) (actual time=16009.50..16441.91 rows=1 loops=1)
Total runtime: 16442.70 msec

Well, that's not any better... over a few runs, sometimes this was even slower that the status quo.  Well, at this point there was only one thing left to try... put in a <= in place of =, and see if it made a difference.

# explain analyze select * from my_events WHERE my_e_id <= 10800000 ORDER BY my_e_id DESC LIMIT 1;
Limit  (cost=0.00..5.52 rows=1 width=771) (actual time=474.40..474.42 rows=1 loops=1)
  ->  Index Scan Backward using my_events_pkey on my_events  (cost=0.00..257365.51 rows=46663 width=771) (actual time=474.39..474.41 rows=2 loo
ps=1)
Total runtime: 474.55 msec

Oddly enough, it did... note the "Index Scan Backward"... finally!  So for whatever reason, the DB decides not to use an index scan unless there's a greater or less than comparison operator in conjunction with an ORDER BY/LIMIT.  Now it takes half a second, instead of 16.

# explain analyze select * from my_events WHERE my_e_id >= 10800000 ORDER BY my_e_id LIMIT 1;
Limit  (cost=0.00..2.03 rows=1 width=771) (actual time=1379.74..1379.76 rows=1 loops=1)
  ->  Index Scan using my_events_pkey on my_events  (cost=0.00..257365.51 rows=126765 width=771) (actual time=1379.73..1379.75 rows=2 loops=1)
Total runtime: 1380.10 msec

Just for fun, run it in regular order (front to back, versus back to front, looking for >=).  Sure enough, still far better than the scan... 1.4 seconds vs 16.  So even the worst case index scan is still far better than the default approach.  Note that I tried using "set enable_seqscan=off", and it STILL insisted on scanning the table, but even slower this time.

Am I missing something really obvious?  Is there a proven way to consistantly encourage it to use indexes for these sorts of (rather obvious) queries?

Several runs of the above resulted in some variations in run time, but the corresponding orders of difference performance stayed pretty consistant.  I'm just confused as to why I have to go through such convoluted methods to force it to use the index when its obviously a FAR more efficient route to go regardless of which order it scans it in (forwards or backwards).  Any thoughts are appreciated.  Thanks!

  Lucas.

------_=_NextPart_001_01C2E507.DAF007F4-- From pgsql-performance-owner@postgresql.org Fri Mar 7 19:34:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 81171474E44 for ; Fri, 7 Mar 2003 19:34:32 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.8/8.12.8) with ESMTP id h280Wb8T018118; Fri, 7 Mar 2003 17:32:37 -0700 (MST) Date: Fri, 7 Mar 2003 17:33:26 -0700 (MST) From: "scott.marlowe" To: Lucas Adamski Cc: "Postgresql Performance Mailing list (E-mail)" Subject: Re: Index / Performance issues In-Reply-To: <3D6F4C287380B1419D7427E111FA3207C68863@OLYMPIA.breakwater.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Archive-Number: 200303/62 X-Sequence-Number: 1360 Hi Lucas, you are running into two fairly common postgresql tuning issues. When you run max(), you are literally asking the database to look at every value and find the highest one. while 'select max(field) from table' seems like a simple one to optimize, how about 'select max(field) from table where id<=800000 and size='m' isn't so obivious anymore. As the max() queries get more complex, the ability to optimize them quickly disappears. Things get more complex in a multi-user environment, where different folks can see different things. While the limit offset solution seems like a hack, it is actually asking the question in a more easily optimized way. The second problem you're running into is that postgresql doesn't automatically match int8 to int4, and it assumes ints without '' around them are int4. the easy solution is to enclose your id number inside '' marks, so you have : select * from table where 8bitintfield='123456789'; and that will force the planner to convert your number to int8. On Fri, 7 Mar 2003, Lucas Adamski wrote: > Hi all, > > I've been using pgsql heavily for about 2 years now, and I keep running into > some index-related wierdness that's rather puzzling. This is for release > 7.2.1, so if a more recent release has solved these, great! Never the less: > > I have a table with about 170,000 rows, each of them a network event. I > also have a serial 8 primary key set up, with a corresponding (unique) btree > index. The primary key is basically sequential, being incremented > dynamically at insert time. The problems I've had revolve around selecting > an individual entry, or trying to figure out the current maximum ID in the > table. In both cases, the results are rather counter-intuitive. Example > below, with my comments in bold. > I've had this problem using functions such as max(), etc. For example: > > Obvious way, using max(): > > # explain analyze select max(my_e_id) from my_events; > Aggregate (cost=68132.85..68132.85 rows=1 width=8) (actual > time=16103.03..16103.03 rows=1 loops=1) > -> Seq Scan on my_events (cost=0.00..67699.28 rows=173428 width=8) > (actual time=0.09..15932.27 rows=173480 loops=1) > Total runtime: 16103.11 msec > > Obtuse way, using ORDER BY DESC/LIMIT > > # explain analyze select my_e_id from sn_events ORDER BY my_e_id DESC LIMIT > 1; > Limit (cost=0.00..1.48 rows=1 width=8) (actual time=36.02..36.03 rows=1 > loops=1) > -> Index Scan Backward using my_events_pkey on my_events > (cost=0.00..256931.94 rows=173428 width=8) (actual time=36.02..36.02 rows=2 > loops= > 1) > Total runtime: 36.09 msec > > In this case, the obtuse way is faster... 446 times faster, in fact. I'd > understand if this was a corner cases, but this has been the situation with > ever PGSQL db I've built. > > Here's another example, just trying to pick out a single random entry out of > a 170,000. > First, the simple approach (status quo): "urn:schemas-microsoft-com:office:office" /> > > # explain analyze select * from my_events WHERE my_e_id = 10800000; > > Seq Scan on my_events (cost=0.00..68132.85 rows=1 width=771) (actual > time=15916.75..16337.31 rows=1 loops=1) > Total runtime: 16337.42 msec > > Pretty darned slow.. (16 secs in fact, ouch). So now lets try our idea with > limiting the query by order it in reverse order, and limiting to 1 result > (even though the limit is unnecessary, but performance is identical without > it) > > # explain analyze select * from my_events WHERE my_e_id = 10800000 ORDER BY > my_e_id DESC LIMIT 1; > Limit (cost=68132.86..68132.86 rows=1 width=771) (actual > time=16442.42..16442.43 rows=1 loops=1) > -> Sort (cost=68132.86..68132.86 rows=1 width=771) (actual > time=16442.42..16442.42 rows=1 loops=1) > -> Seq Scan on my_events (cost=0.00..68132.85 rows=1 width=771) > (actual time=16009.50..16441.91 rows=1 loops=1) > Total runtime: 16442.70 msec > > Well, that's not any better... over a few runs, sometimes this was even > slower that the status quo. Well, at this point there was only one thing > left to try... put in a <= in place of =, and see if it made a difference. > > # explain analyze select * from my_events WHERE my_e_id <= 10800000 ORDER BY > my_e_id DESC LIMIT 1; > Limit (cost=0.00..5.52 rows=1 width=771) (actual time=474.40..474.42 rows=1 > loops=1) > -> Index Scan Backward using my_events_pkey on my_events > (cost=0.00..257365.51 rows=46663 width=771) (actual time=474.39..474.41 > rows=2 loo > ps=1) > Total runtime: 474.55 msec > > Oddly enough, it did... note the "Index Scan Backward"... finally! So for > whatever reason, the DB decides not to use an index scan unless there's a > greater or less than comparison operator in conjunction with an ORDER > BY/LIMIT. Now it takes half a second, instead of 16. > > # explain analyze select * from my_events WHERE my_e_id >= 10800000 ORDER BY > my_e_id LIMIT 1; > Limit (cost=0.00..2.03 rows=1 width=771) (actual time=1379.74..1379.76 > rows=1 loops=1) > -> Index Scan using my_events_pkey on my_events (cost=0.00..257365.51 > rows=126765 width=771) (actual time=1379.73..1379.75 rows=2 loops=1) > Total runtime: 1380.10 msec > > Just for fun, run it in regular order (front to back, versus back to front, > looking for >=). Sure enough, still far better than the scan... 1.4 seconds > vs 16. So even the worst case index scan is still far better than the > default approach. Note that I tried using "set enable_seqscan=off", and it > STILL insisted on scanning the table, but even slower this time. > > Am I missing something really obvious? Is there a proven way to > consistantly encourage it to use indexes for these sorts of (rather obvious) > queries? > > Several runs of the above resulted in some variations in run time, but the > corresponding orders of difference performance stayed pretty consistant. > I'm just confused as to why I have to go through such convoluted methods to > force it to use the index when its obviously a FAR more efficient route to > go regardless of which order it scans it in (forwards or backwards). Any > thoughts are appreciated. Thanks! > > Lucas. > > From pgsql-performance-owner@postgresql.org Fri Mar 7 21:39:13 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id 0CE95474E44 for ; Fri, 7 Mar 2003 21:39:12 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id BB4BE13809E; Fri, 7 Mar 2003 21:39:09 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18rUEv-0002Ib-00; Fri, 07 Mar 2003 21:39:09 -0500 To: "scott.marlowe" Cc: Lucas Adamski , "Postgresql Performance Mailing list (E-mail)" Subject: Re: Index / Performance issues References: In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 07 Mar 2003 21:39:09 -0500 Message-ID: <877kbalgz6.fsf@stark.dyndns.tv> Lines: 15 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200303/63 X-Sequence-Number: 1361 "scott.marlowe" writes: > select * from table where 8bitintfield='123456789'; Or: select * from table where 8bitintfield=123456789::int8 I'm not sure which is aesthetically more pleasing. -- greg From pgsql-performance-owner@postgresql.org Fri Mar 7 22:13:23 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3B5ED474E44 for ; Fri, 7 Mar 2003 22:13:21 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h283DOub003241; Fri, 7 Mar 2003 22:13:25 -0500 (EST) To: Daniel Bruce Lynes Cc: PostgreSQL Performance Subject: Re: Stored Procedures and compiling In-reply-to: <200303071321.09981.dlynes@shaw.ca> References: <200303071321.09981.dlynes@shaw.ca> Comments: In-reply-to Daniel Bruce Lynes message dated "Fri, 07 Mar 2003 13:21:09 -0800" Date: Fri, 07 Mar 2003 22:13:24 -0500 Message-ID: <3240.1047093204@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/64 X-Sequence-Number: 1362 Daniel Bruce Lynes writes: > I am curious if there is any planned support for full stored procedure > compiling? I've seen that PostgreSQL does not compile the SQL code inside > plpgsql code. It is merely interpreted when the procedure gets called. This > is also documented in the main html documentation. > What I am wondering specifically is if stored procedure compiling will work > similar to Oracle's stored procedure compilation in the future? What exactly do you consider "compiling", and why do you think that whatever Oracle does (which you didn't bother to explain) is superior to what plpgsql does? regards, tom lane From pgsql-performance-owner@postgresql.org Sat Mar 8 05:15:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from email05.aon.at (WARSL401PIP4.highway.telekom.at [195.3.96.79]) by postgresql.org (Postfix) with SMTP id 9074C475921 for ; Sat, 8 Mar 2003 05:15:47 -0500 (EST) Received: (qmail 411826 invoked from network); 8 Mar 2003 10:15:39 -0000 Received: from m156p025.dipool.highway.telekom.at (HELO cantor) ([62.46.9.121]) (envelope-sender ) by qmail5rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 8 Mar 2003 10:15:39 -0000 From: Manfred Koizar To: "Paul McKay" Cc: Subject: Re: Slow query performance on large table Date: Sat, 08 Mar 2003 11:15:56 +0100 Message-ID: <2agj6vc16t42rar0hou13e0e2qcplqe9rj@4ax.com> References: <3E64E079.8050807@klaster.net> <000001c2e2fc$4a13c200$0c64a8c0@paulspc> In-Reply-To: <000001c2e2fc$4a13c200$0c64a8c0@paulspc> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/65 X-Sequence-Number: 1363 On Wed, 5 Mar 2003 09:47:51 -0000, "Paul McKay" wrote: >Hash Join (cost=1532.83..345460.73 rows=75115 width=23) (actual >time=1769.84..66687.11 rows=16094 loops=1) > -> Seq Scan on measurement (cost=0.00..336706.07 rows=418859 >width=15) (actual time=1280.11..59985.47 rows=455788 loops=1) > -> Hash (cost=1498.21..1498.21 rows=13848 width=8) (actual >time=253.49..253.49 rows=0 loops=1) > -> Seq Scan on panconversation (cost=0.00..1498.21 rows=13848 >width=8) (actual time=15.64..223.18 rows=13475 loops=1) >Total runtime: 66694.82 msec |clearview=# select count(*) from measurement; | 15302138 |clearview=# select count(*) from panconversation; | 77217 Paul, you seem to have a lot of dead tuples in your tables. VACUUM FULL VERBOSE ANALYZE panconversation; VACUUM FULL VERBOSE ANALYZE measurement; This should cut your query time to ca. one third. If you could migrate to 7.3 and create your tables WITHOUT OIDS, I'd expect a further speed increase of ~ 15%. Servus Manfred From pgsql-performance-owner@postgresql.org Sat Mar 8 13:22:39 2003 X-Original-To: pgsql-performance@postgresql.org Received: from pd4mo2so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by postgresql.org (Postfix) with ESMTP id B4C06475CA9 for ; Sat, 8 Mar 2003 13:22:37 -0500 (EST) Received: from pd5mr2so.prod.shaw.ca (pd5mr2so-qfe3.prod.shaw.ca [10.0.141.233]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0HBG00MK40DPV2@l-daemon> for pgsql-performance@postgresql.org; Sat, 08 Mar 2003 11:22:37 -0700 (MST) Received: from pn2ml8so.prod.shaw.ca (pn2ml8so-qfe0.prod.shaw.ca [10.0.121.152]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0HBG00LNE0DPQN@l-daemon> for pgsql-performance@postgresql.org; Sat, 08 Mar 2003 11:22:37 -0700 (MST) Received: from power ([24.80.229.122]) by l-daemon (iPlanet Messaging Server 5.1 HotFix 0.8 (built May 12 2002)) with ESMTP id <0HBG002KH0DOJJ@l-daemon> for pgsql-performance@postgresql.org; Sat, 08 Mar 2003 11:22:37 -0700 (MST) Date: Sat, 08 Mar 2003 10:34:01 -0800 From: Daniel Bruce Lynes Subject: Re: Stored Procedures and compiling In-reply-to: <3240.1047093204@sss.pgh.pa.us> To: PostgreSQL Performance Message-id: <200303081034.01935.dlynes@shaw.ca> MIME-version: 1.0 X-Mailer: KMail [version 1.4] Content-type: text/plain; charset=gb2312 Content-transfer-encoding: 7BIT References: <200303071321.09981.dlynes@shaw.ca> <3240.1047093204@sss.pgh.pa.us> X-Archive-Number: 200303/66 X-Sequence-Number: 1364 On Friday 07 March 2003 19:13, Tom Lane wrote: > What exactly do you consider "compiling", and why do you think that > whatever Oracle does (which you didn't bother to explain) is superior > to what plpgsql does? When you run a script to place a stored procedure into Oracle, it checks the entire script to ensure that there are no syntax errors in both the procedural code and the SQL code. However, with PostgreSQL, if there are errors in the code, I usually don't find out about it until I reach that branch in the logic upon execution of the stored procedure from client code. As I understand it, Oracle also compiles the stored procedure into pcode (internally), the first time it is called so that it runs faster. You can compile stored procedures into pcode manually also, and store the pcode in the database, rather than the pl/sql code. From pgsql-performance-owner@postgresql.org Sat Mar 8 15:01:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by postgresql.org (Postfix) with SMTP id 1CA414758C9 for ; Sat, 8 Mar 2003 15:01:32 -0500 (EST) Received: (qmail 11849 invoked by uid 0); 8 Mar 2003 20:01:32 -0000 Date: Sat, 8 Mar 2003 21:01:32 +0100 (MET) From: daniel alvarez To: Bruce Momjian Cc: neilc@samurai.com, tgl@sss.pgh.pa.us, chriskl@familyhealth.com.au, dev@archonet.com, pgsql-performance@postgresql.org MIME-Version: 1.0 References: <200303070150.h271oaW02436@candle.pha.pa.us> Subject: Re: OIDs as keys X-Priority: 3 (Normal) X-Authenticated-Sender: #0002681999@gmx.net X-Authenticated-IP: [217.185.184.254] Message-ID: <26462.1047153692@www68.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200303/67 X-Sequence-Number: 1365 > Neil Conway wrote: > > On Thu, 2003-03-06 at 16:13, Bruce Momjian wrote: > > > It would be good to somehow SET the use_oids GUC value on restore > start, > > > and just use SET when the table is different than the default, but > then > > > there is no mechanism to do that when you restore a single table. > > > > What if the default value changes? > > > > IMHO, running a SET per CREATE TABLE isn't too ugly... > > Not ugly, but a little noisy. However, my idea of having a single SET > at the top is never going to work, so I don't have a better idea. Why isn't this done on a per-session basis? Having a session setting for the common case and a CREATE-TABLE clause for the specifics sounds natural. When a single table needs to be restored all one needs to to is changing the session setting before running the CREATE command. The alternative clause in CREATE-TABLE statements would be used as a cleaner way of expressing the same thing without affecting the session, when the statement's text can be entered manually (as opposed to loading it from an existing dumpfile). The default for the session setting could be set in the configuration file then. regards, Daniel Alvarez Arribas -- +++ GMX - Mail, Messaging & more http://www.gmx.net +++ Bitte l�cheln! Fotogalerie online mit GMX ohne eigene Homepage! From pgsql-performance-owner@postgresql.org Sat Mar 8 15:09:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id DD472475EE2 for ; Sat, 8 Mar 2003 15:09:35 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h28K9Fub010511; Sat, 8 Mar 2003 15:09:15 -0500 (EST) To: daniel alvarez Cc: Bruce Momjian , neilc@samurai.com, chriskl@familyhealth.com.au, dev@archonet.com, pgsql-performance@postgresql.org Subject: Re: OIDs as keys In-reply-to: <26462.1047153692@www68.gmx.net> References: <200303070150.h271oaW02436@candle.pha.pa.us> <26462.1047153692@www68.gmx.net> Comments: In-reply-to daniel alvarez message dated "Sat, 08 Mar 2003 21:01:32 +0100" Date: Sat, 08 Mar 2003 15:09:15 -0500 Message-ID: <10510.1047154155@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/68 X-Sequence-Number: 1366 daniel alvarez writes: >> Not ugly, but a little noisy. However, my idea of having a single SET >> at the top is never going to work, so I don't have a better idea. > Why isn't this done on a per-session basis? Because pg_dump can't know what the session default will be when the dump is reloaded. The scheme you are proposing will only succeed in making pg_dump unreliable. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Mar 8 15:16:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by postgresql.org (Postfix) with SMTP id 9EBD3474E42 for ; Sat, 8 Mar 2003 15:16:32 -0500 (EST) Received: (qmail 22581 invoked by uid 0); 8 Mar 2003 20:16:32 -0000 Date: Sat, 8 Mar 2003 21:16:32 +0100 (MET) From: daniel alvarez To: Tom Lane Cc: pgman@candle.pha.pa.us, neilc@samurai.com, chriskl@familyhealth.com.au, dev@archonet.com, pgsql-performance@postgresql.org MIME-Version: 1.0 References: <10510.1047154155@sss.pgh.pa.us> Subject: Re: OIDs as keys X-Priority: 3 (Normal) X-Authenticated-Sender: #0002681999@gmx.net X-Authenticated-IP: [217.185.184.254] Message-ID: <19376.1047154592@www68.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200303/69 X-Sequence-Number: 1367 > daniel alvarez writes: > >> Not ugly, but a little noisy. However, my idea of having a single SET > >> at the top is never going to work, so I don't have a better idea. > > > Why isn't this done on a per-session basis? > > Because pg_dump can't know what the session default will be when the > dump is reloaded. The scheme you are proposing will only succeed in > making pg_dump unreliable. Ouch. Why is this? Doesn't it read the config because of portability reasons? -- +++ GMX - Mail, Messaging & more http://www.gmx.net +++ Bitte l�cheln! Fotogalerie online mit GMX ohne eigene Homepage! From pgsql-performance-owner@postgresql.org Mon Mar 10 11:05:52 2003 X-Original-To: pgsql-performance@postgresql.org Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 61FD5475C15 for ; Mon, 10 Mar 2003 11:05:50 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h2AG5La28728; Mon, 10 Mar 2003 11:05:21 -0500 (EST) From: Bruce Momjian Message-Id: <200303101605.h2AG5La28728@candle.pha.pa.us> Subject: Re: OIDs as keys In-Reply-To: <19376.1047154592@www68.gmx.net> To: daniel alvarez Date: Mon, 10 Mar 2003 11:05:21 -0500 (EST) Cc: Tom Lane , neilc@samurai.com, chriskl@familyhealth.com.au, dev@archonet.com, pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200303/70 X-Sequence-Number: 1368 daniel alvarez wrote: > > daniel alvarez writes: > > >> Not ugly, but a little noisy. However, my idea of having a single SET > > >> at the top is never going to work, so I don't have a better idea. > > > > > Why isn't this done on a per-session basis? > > > > Because pg_dump can't know what the session default will be when the > > dump is reloaded. The scheme you are proposing will only succeed in > > making pg_dump unreliable. > > Ouch. Why is this? Doesn't it read the config because of portability > reasons? Remember the dump output is just an SQL script, so there is no 'logic' in the script, and it can be loaded right into psql. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Mon Mar 10 11:56:23 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id E77A74760E3 for ; Mon, 10 Mar 2003 11:56:20 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.8/8.12.8) with ESMTP id h2AGtQ8T015701; Mon, 10 Mar 2003 09:55:26 -0700 (MST) Date: Mon, 10 Mar 2003 09:55:53 -0700 (MST) From: "scott.marlowe" To: Greg Stark Cc: Lucas Adamski , "Postgresql Performance Mailing list (E-mail)" Subject: Re: Index / Performance issues In-Reply-To: <877kbalgz6.fsf@stark.dyndns.tv> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Archive-Number: 200303/71 X-Sequence-Number: 1369 On 7 Mar 2003, Greg Stark wrote: > > > "scott.marlowe" writes: > > > select * from table where 8bitintfield='123456789'; > > Or: > > select * from table where 8bitintfield=123456789::int8 > > > I'm not sure which is aesthetically more pleasing. The cast is self documenting, so it's probably a better choice for most setups. On the other hand, it's not as likely to be portable. From pgsql-performance-owner@postgresql.org Mon Mar 10 13:57:24 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mailrelay (technicacorp.com [216.181.29.134]) by postgresql.org (Postfix) with ESMTP id CCC4D4768F9 for ; Mon, 10 Mar 2003 13:55:02 -0500 (EST) thread-index: AcLnNnfFrWGYq6kSSF6KqZb0roRZow== Content-Transfer-Encoding: 7bit Received: from WWWSERVER.technicacorp.com ([216.181.29.149]) by mailrelay with Microsoft SMTPSVC(5.0.2195.5329); Mon, 10 Mar 2003 13:54:23 -0500 Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Received: by wwwserver with Internet Mail Service (5.5.2656.59) id ; Mon, 10 Mar 2003 13:58:27 -0500 Message-ID: <71F044551C53974EB0735B3737EFE2FC088628@wwwserver> From: "Scott Buchan" To: Subject: Large difference between elapsed time and run time for queries Date: Mon, 10 Mar 2003 13:58:26 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2E737.08116350" X-OriginalArrivalTime: 10 Mar 2003 18:54:23.0136 (UTC) FILETIME=[770C9A00:01C2E736] X-Archive-Number: 200303/72 X-Sequence-Number: 1370 This is a multi-part message in MIME format. ------_=_NextPart_001_01C2E737.08116350 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="iso-8859-1" Hello, While running benchmarks for my database, I am seeing a large difference in the elapsed time (from stats collected in the logs) and run time (running explain analyze on the query using ./psql ) for each of my queries. The database is being ran on a sunfire 880 with 4 750mhz processors with 8 G RAM running solaris 8 I am simulating 200 user connections each running 6 select queries on 1 indexed table with 50,000 records. The elapsed time for the queries average around 2.5 seconds while if I run the query using explain analyze while the test is running, the run time is around 300 ms although it takes much longer (few seconds) to display the results. If I reduce the number of concurrent connections to 100 then the run time and elapsed time for the queries are the same. I have tried numerous configurations in the postgresql.conf file. I have set the shared_buffers with values ranging from 75 MB to 4000MB with no luck. I have also tried increasing the sort_mem with no luck. When the test is running, the cpu is well over 50% idle and iostat shows that the processes are not waiting for i/o and disk usage percentage is low. Any help would be appreciated. Thanks. ------_=_NextPart_001_01C2E737.08116350 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset="iso-8859-1"

Hello,

 

While running benchmarks for my database, I am seeing a large difference in the elapsed time (from stats collected in the logs) and run time (running explain analyze on the query using ./psql <database>) for each of my queries.  The database is being ran on a sunfire 880 with 4 750mhz processors with 8 G RAM running solaris 8

 

I am simulating 200 user connections each running 6 select queries on 1 indexed table with 50,000 records. The elapsed time for the queries average around 2.5 seconds while if I run the query using explain analyze while the test is running, the run time is around 300 ms although it takes much longer (few seconds) to display the results.  If I reduce the number of concurrent connections to 100 then the run time and elapsed time for the queries are the same.

 

I have tried numerous configurations in the postgresql.conf file.  I have set the shared_buffers with values ranging from 75 MB to 4000MB with no luck.  I have also tried increasing the sort_mem with no luck.

 

 

When the test is running, the cpu is well over 50% idle and iostat shows that the processes are not waiting for i/o and disk usage percentage is low.

 

Any help would be appreciated.

 

Thanks.

------_=_NextPart_001_01C2E737.08116350-- From pgsql-performance-owner@postgresql.org Mon Mar 10 15:07:55 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 5B479475FC8 for ; Mon, 10 Mar 2003 15:07:54 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2AK7sub019605; Mon, 10 Mar 2003 15:07:55 -0500 (EST) To: "Scott Buchan" Cc: pgsql-performance@postgresql.org Subject: Re: Large difference between elapsed time and run time for queries In-reply-to: <71F044551C53974EB0735B3737EFE2FC088628@wwwserver> References: <71F044551C53974EB0735B3737EFE2FC088628@wwwserver> Comments: In-reply-to "Scott Buchan" message dated "Mon, 10 Mar 2003 13:58:26 -0500" Date: Mon, 10 Mar 2003 15:07:54 -0500 Message-ID: <19604.1047326874@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/73 X-Sequence-Number: 1371 "Scott Buchan" writes: > I am simulating 200 user connections each running 6 select queries on 1 > indexed table with 50,000 records. The elapsed time for the queries average > around 2.5 seconds while if I run the query using explain analyze while the > test is running, the run time is around 300 ms although it takes much longer > (few seconds) to display the results. How many rows are these queries returning? AFAICS the differential must be the cost of transmitting the data to the frontend, which of course does not happen when you use explain analyze. (I think, but am not completely sure, that explain analyze also suppresses the CPU effort of converting the data to text form, as would normally be done before transmitting it. But given that you don't see a problem at 100 connections, that's probably not where the issue lies.) > The database is being ran on a sunfire 880 with 4 750mhz > processors with 8 G RAM running solaris 8 We have seen some other weird performance problems on Solaris (their standard qsort apparently is very bad, for example). Might be that you need to be looking at kernel behavior, not at Postgres. regards, tom lane From pgsql-committers-owner@postgresql.org Mon Mar 10 21:51:06 2003 X-Original-To: pgsql-committers@postgresql.org Received: from hub.org (unknown [64.117.224.146]) by postgresql.org (Postfix) with ESMTP id 4421C475FC6 for ; Mon, 10 Mar 2003 21:51:04 -0500 (EST) Received: from [64.117.224.146] (unknown [64.117.224.146]) by hub.org (Postfix) with ESMTP id 23FD5103ADAD; Mon, 10 Mar 2003 22:51:02 -0400 (AST) Date: Mon, 10 Mar 2003 22:50:59 -0400 (AST) From: "Marc G. Fournier" To: Sean Chittenden Cc: Tom Lane , Christopher Kings-Lynne , pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... In-Reply-To: <20030306094117.GA79234@perrin.int.nxad.com> Message-ID: <20030310224706.T35660@hub.org> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200303/57 X-Sequence-Number: 9300 yOn Thu, 6 Mar 2003, Sean Chittenden wrote: > > >>> Has anyone ever thought about adding kqueue (for *BSD) support to > > >>> Postgres, instead of using select? > > >> > > >> Why? poll() is standard. kqueue isn't, AFAIK. > > > > > It's supposed be a whole heap faster - there is no polling involved... > > > > Supposed by whom? Faster than what? And how would it not poll? > > > > The way libpq uses this call, it's either probing for current status > > (timeout=0) or it's willing to block, possibly indefinitely, until the > > desired condition arises. It does not sit there in a busy-wait loop. > > I can't see any reason to think that an OS-specific API would give > > any marked difference in performance. > > Heh, kqueue is _the_ reason to use FreeBSD. > > http://www.kegel.com/dkftpbench/Poller_bench.html#results > > I've toyed with the idea of adding this because it is monstrously more > efficient than select()/poll() in basically every way, shape, and > form. I would personally be interested in seeing patches ... what would be involved? From pgsql-performance-owner@postgresql.org Mon Mar 10 22:44:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id 3FB2947592C for ; Mon, 10 Mar 2003 22:44:32 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Mon, 10 Mar 2003 19:44:36 -0800 Date: Mon, 10 Mar 2003 19:44:36 -0800 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: Index / Performance issues Message-ID: <20030311034436.GG1847@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <877kbalgz6.fsf@stark.dyndns.tv> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Organization: Frobozzco International X-Archive-Number: 200303/74 X-Sequence-Number: 1372 scott.marlowe wrote: > > select * from table where 8bitintfield=123456789::int8 > > > > > > I'm not sure which is aesthetically more pleasing. > > The cast is self documenting, so it's probably a better choice for most > setups. On the other hand, it's not as likely to be portable. May as well make it as portable as possible, though: select * from table where 8bitintfield = CAST(123456789 AS bigint) -- Kevin Brown kevin@sysexperts.com From pgsql-committers-owner@postgresql.org Mon Mar 10 23:12:06 2003 X-Original-To: pgsql-committers@postgresql.org Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id A35F547592C for ; Mon, 10 Mar 2003 23:12:05 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id B90FF21068; Mon, 10 Mar 2003 20:11:33 -0800 (PST) Date: Mon, 10 Mar 2003 20:11:33 -0800 From: Sean Chittenden To: "Marc G. Fournier" Cc: Tom Lane , Christopher Kings-Lynne , pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Message-ID: <20030311041133.GC79234@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <20030310224706.T35660@hub.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030310224706.T35660@hub.org> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/58 X-Sequence-Number: 9301 > > Heh, kqueue is _the_ reason to use FreeBSD. > > > > http://www.kegel.com/dkftpbench/Poller_bench.html#results > > > > I've toyed with the idea of adding this because it is monstrously more > > efficient than select()/poll() in basically every way, shape, and > > form. > > I would personally be interested in seeing patches ... what would be > involved? Whoa! Surprisingly, much less than I expected!!! A small shim would have to be put in place to abstract away returning valid file descriptors that are ready to be read()/write(). What's really cool, is there are only a handful of places that'd have to be updated (as far as I can tell): src/backend/access/transam/xact.c src/backend/postmaster/pgstat.c src/backend/postmaster/postmaster.c src/backend/storage/lmgr/s_lock.c src/bin/pg_dump/pg_dump.c src/interfaces/libpq/fe-misc.c Then it'd be possible to have clients/servers switch between kqueue, poll, select, or whatever the new flavor of alerting from available IO fd's. I've added it to my personal TODO list of things to work on. If someone beats me to it, cool, it's just something that one day I'll get to (hopefully). -sc -- Sean Chittenden From pgsql-committers-owner@postgresql.org Mon Mar 10 23:17:48 2003 X-Original-To: pgsql-committers@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id E6091475C15 for ; Mon, 10 Mar 2003 23:17:43 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h2B4Hmn10386 for pgsql-committers@postgresql.org; Tue, 11 Mar 2003 12:17:48 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h2B4Hg710206; Tue, 11 Mar 2003 12:17:42 +0800 (WST) Message-ID: <018201c2e785$2c12c750$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: "Sean Chittenden" , "Marc G. Fournier" Cc: "Tom Lane" , References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <20030310224706.T35660@hub.org> <20030311041133.GC79234@perrin.int.nxad.com> Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Date: Tue, 11 Mar 2003 12:17:46 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/59 X-Sequence-Number: 9302 > > I would personally be interested in seeing patches ... what would be > > involved? > > Whoa! Surprisingly, much less than I expected!!! A small shim would > have to be put in place to abstract away returning valid file > descriptors that are ready to be read()/write(). What's really cool, > is there are only a handful of places that'd have to be updated (as > far as I can tell): It would be nice to have this support there, however Tom was correct in saying it really only applies to network apps that are handling thousands of connections, all really, really fast. Postgres doesn't. I say you'd have to do the work, then do the benchmarking to see if it makes a difference. Chris From pgsql-committers-owner@postgresql.org Mon Mar 10 23:42:34 2003 X-Original-To: pgsql-committers@postgresql.org Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id AFFF447592C for ; Mon, 10 Mar 2003 23:42:31 -0500 (EST) Received: from DU150.N224.ResNet.QueensU.CA (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 5F0CD1EDE; Mon, 10 Mar 2003 23:42:36 -0500 (EST) Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... From: Neil Conway To: Christopher Kings-Lynne Cc: Sean Chittenden , "Marc G. Fournier" , Tom Lane , pgsql-committers@postgresql.org In-Reply-To: <018201c2e785$2c12c750$6500a8c0@fhp.internal> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <20030310224706.T35660@hub.org> <20030311041133.GC79234@perrin.int.nxad.com> <018201c2e785$2c12c750$6500a8c0@fhp.internal> Content-Type: text/plain Organization: Message-Id: <1047357755.357.1.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 10 Mar 2003 23:42:35 -0500 Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/60 X-Sequence-Number: 9303 On Mon, 2003-03-10 at 23:17, Christopher Kings-Lynne wrote: > It would be nice to have this support there, however Tom was correct in > saying it really only applies to network apps that are handling thousands of > connections, all really, really fast. Postgres doesn't. I say you'd have > to do the work, then do the benchmarking to see if it makes a difference. ... and if it doesn't make a significant difference, I'd oppose including it in the mainline source. Performance optimization is one thing; performance "optimization" that doesn't actually improve performance is another :-) Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-committers-owner@postgresql.org Mon Mar 10 23:53:04 2003 X-Original-To: pgsql-committers@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id EF97A475C15 for ; Mon, 10 Mar 2003 23:53:00 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h2B4r5411585 for pgsql-committers@postgresql.org; Tue, 11 Mar 2003 12:53:05 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h2B4qu711358; Tue, 11 Mar 2003 12:52:56 +0800 (WST) Message-ID: <01a001c2e78a$18bfa0b0$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: "Neil Conway" Cc: "Sean Chittenden" , "Marc G. Fournier" , "Tom Lane" , References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <20030310224706.T35660@hub.org> <20030311041133.GC79234@perrin.int.nxad.com> <018201c2e785$2c12c750$6500a8c0@fhp.internal> <1047357755.357.1.camel@tokyo> Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Date: Tue, 11 Mar 2003 12:53:01 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/61 X-Sequence-Number: 9304 > > It would be nice to have this support there, however Tom was correct in > > saying it really only applies to network apps that are handling thousands of > > connections, all really, really fast. Postgres doesn't. I say you'd have > > to do the work, then do the benchmarking to see if it makes a difference. > > ... and if it doesn't make a significant difference, I'd oppose > including it in the mainline source. Performance optimization is one > thing; performance "optimization" that doesn't actually improve > performance is another :-) That was the unsaid implication... :) Chris From pgsql-committers-owner@postgresql.org Mon Mar 10 23:56:33 2003 X-Original-To: pgsql-committers@postgresql.org Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id 78C98475C15 for ; Mon, 10 Mar 2003 23:56:32 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id DF2A62105B; Mon, 10 Mar 2003 20:56:10 -0800 (PST) Date: Mon, 10 Mar 2003 20:56:10 -0800 From: Sean Chittenden To: Neil Conway Cc: Christopher Kings-Lynne , "Marc G. Fournier" , Tom Lane , pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Message-ID: <20030311045610.GF79234@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <20030310224706.T35660@hub.org> <20030311041133.GC79234@perrin.int.nxad.com> <018201c2e785$2c12c750$6500a8c0@fhp.internal> <1047357755.357.1.camel@tokyo> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1047357755.357.1.camel@tokyo> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/62 X-Sequence-Number: 9305 > > It would be nice to have this support there, however Tom was > > correct in saying it really only applies to network apps that are > > handling thousands of connections, all really, really fast. > > Postgres doesn't. I say you'd have to do the work, then do the > > benchmarking to see if it makes a difference. > > ... and if it doesn't make a significant difference, I'd oppose > including it in the mainline source. Performance optimization is one > thing; performance "optimization" that doesn't actually improve > performance is another :-) ::sigh:: Well, I'm not about to argue one way or another on this beyond saying: kqueue is better than select/poll, but there are much bigger, much lower, and much easier pieces of fruit to pick off the optimization tree given the cost/benefit for the amount of network IO PostgreSQL does. That said, what was the performance gain of moving from select() to poll()? It wasn't the biggest optimization in PostgreSQL history, nor the smallest, but it was a step forward. -sc -- Sean Chittenden From pgsql-committers-owner@postgresql.org Tue Mar 11 02:32:41 2003 X-Original-To: pgsql-committers@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id C22BE47617D for ; Tue, 11 Mar 2003 00:06:19 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2B56Fub002774; Tue, 11 Mar 2003 00:06:15 -0500 (EST) To: Sean Chittenden Cc: Neil Conway , Christopher Kings-Lynne , "Marc G. Fournier" , pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... In-reply-to: <20030311045610.GF79234@perrin.int.nxad.com> References: <20030306031656.1876F4762E0@postgresql.org> <032f01c2e390$b1842b20$6500a8c0@fhp.internal> <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <20030310224706.T35660@hub.org> <20030311041133.GC79234@perrin.int.nxad.com> <018201c2e785$2c12c750$6500a8c0@fhp.internal> <1047357755.357.1.camel@tokyo> <20030311045610.GF79234@perrin.int.nxad.com> Comments: In-reply-to Sean Chittenden message dated "Mon, 10 Mar 2003 20:56:10 -0800" Date: Tue, 11 Mar 2003 00:06:14 -0500 Message-ID: <2773.1047359174@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/64 X-Sequence-Number: 9307 Sean Chittenden writes: > That said, what was the performance gain of moving > from select() to poll()? It wasn't the biggest optimization in > PostgreSQL history, nor the smallest, but it was a step forward. -sc That change was not sold as a performance improvement; I doubt that it is one. It was sold as not failing when libpq runs inside an application that has thousands of open files (i.e., more than select() can cope with). "Faster" is debatable, "fails" is not... regards, tom lane From pgsql-committers-owner@postgresql.org Tue Mar 11 00:30:56 2003 X-Original-To: pgsql-committers@postgresql.org Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id D4082475E82 for ; Tue, 11 Mar 2003 00:30:54 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id A7BA42105B; Mon, 10 Mar 2003 21:30:33 -0800 (PST) Date: Mon, 10 Mar 2003 21:30:33 -0800 From: Sean Chittenden To: Tom Lane Cc: Neil Conway , Christopher Kings-Lynne , "Marc G. Fournier" , pgsql-committers@postgresql.org Subject: Re: pgsql-server/ /configure /configure.in rc/incl ... Message-ID: <20030311053033.GH79234@perrin.int.nxad.com> References: <11077.1046921667@sss.pgh.pa.us> <033f01c2e392$71476570$6500a8c0@fhp.internal> <12228.1046922471@sss.pgh.pa.us> <20030306094117.GA79234@perrin.int.nxad.com> <20030310224706.T35660@hub.org> <20030311041133.GC79234@perrin.int.nxad.com> <018201c2e785$2c12c750$6500a8c0@fhp.internal> <1047357755.357.1.camel@tokyo> <20030311045610.GF79234@perrin.int.nxad.com> <2773.1047359174@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2773.1047359174@sss.pgh.pa.us> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/63 X-Sequence-Number: 9306 > > That said, what was the performance gain of moving from select() > > to poll()? It wasn't the biggest optimization in PostgreSQL > > history, nor the smallest, but it was a step forward. -sc > > That change was not sold as a performance improvement; I doubt that > it is one. It was sold as not failing when libpq runs inside an > application that has thousands of open files (i.e., more than > select() can cope with). "Faster" is debatable, "fails" is not... Well, I've only heard through 2nd hand sources (dillion) the kind of hellish conditions that Mark has on his boxen, but "faster and more efficient in the kernel" is "faster and more efficient in the kernel" no matter how 'ya slice it and I know that every last bit helps a loaded system. I'm not stating that most people, or even 90% of people, will notice. Hopefully 100% of the universe runs their boxen under ideal conditions (like most databases should, right? ::wink wink, nudge nudge:: For those that don't, however, and get to watch things run in the red with a load average over 20, the use of kqueue or more efficient system calls is likely very appreciated. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Tue Mar 11 03:46:38 2003 X-Original-To: pgsql-performance@postgresql.org Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id E851A475D0F for ; Tue, 11 Mar 2003 03:46:34 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Tue, 11 Mar 2003 08:46:33 -0000 Message-ID: From: Nikk Anderson To: 'Scott Buchan' , pgsql-performance@postgresql.org Subject: Re: Large difference between elapsed time and run time Date: Tue, 11 Mar 2003 08:46:32 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2E7AA.B7121F70" X-Archive-Number: 200303/75 X-Sequence-Number: 1373 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_01C2E7AA.B7121F70 Content-Type: text/plain; charset="iso-8859-1" Hi, I have noted similar issues in the past - and seemed then that most of the overhead bottleneck was due to establishing a new connection in the front end. As soon as I started using connection pooling, with connections made when the app initialises, and then recycled for each request (i.e. the connections never close) then the execution time was far quicker. I have also noticed that sparc processor speed, num processors, disk space and memory seems to makes little difference with postgres (for us anyway!) performance - e.g. performance no better with dual sparc 450mhz, 2 scsi disks, 1Gb mem - than on a single processor 400 mhz Netra, 256Mb ram with a single IDE disk! Nikk -----Original Message----- From: Scott Buchan [mailto:sbuchan@technicacorp.com] Sent: 10 March 2003 18:58 To: pgsql-performance@postgresql.org Subject: [PERFORM] Large difference between elapsed time and run time for queries Hello, While running benchmarks for my database, I am seeing a large difference in the elapsed time (from stats collected in the logs) and run time (running explain analyze on the query using ./psql ) for each of my queries. The database is being ran on a sunfire 880 with 4 750mhz processors with 8 G RAM running solaris 8 I am simulating 200 user connections each running 6 select queries on 1 indexed table with 50,000 records. The elapsed time for the queries average around 2.5 seconds while if I run the query using explain analyze while the test is running, the run time is around 300 ms although it takes much longer (few seconds) to display the results. If I reduce the number of concurrent connections to 100 then the run time and elapsed time for the queries are the same. I have tried numerous configurations in the postgresql.conf file. I have set the shared_buffers with values ranging from 75 MB to 4000MB with no luck. I have also tried increasing the sort_mem with no luck. When the test is running, the cpu is well over 50% idle and iostat shows that the processes are not waiting for i/o and disk usage percentage is low. Any help would be appreciated. Thanks. ------_=_NextPart_001_01C2E7AA.B7121F70 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] Large difference between elapsed time and run time for= queries

Hi,

I have noted similar issues in the past - and seemed then= that most of the overhead bottleneck was due to establishing a new connect= ion in the front end.  As soon as I started using connection pooling, = with connections made when the app initialises, and then recycled for each = request (i.e. the connections never close) then the execution time was far = quicker.

I have also noticed that sparc processor speed, num proce= ssors, disk space and memory seems to makes little difference with postgres= (for us anyway!) performance - e.g. performance no better with dual sparc = 450mhz, 2 scsi disks, 1Gb mem - than on a single processor 400 mhz Netra, 2= 56Mb ram with a single IDE disk!

Nikk


Hello,

While running benchmarks for my database, I am seeing a l= arge difference in the elapsed time (from stats collected in the logs) and = run time (running explain analyze on the query using ./psql <database>= ;) for each of my queries.  The database is being ran on a sunfire 880= with 4 750mhz processors with 8 G RAM running solaris 8

I am simulating 200 user connections each running 6 selec= t queries on 1 indexed table with 50,000 records. The elapsed time for the = queries average around 2.5 seconds while if I run the query using explain a= nalyze while the test is running, the run time is around 300 ms although it= takes much longer (few seconds) to display the results.  If I reduce = the number of concurrent connections to 100 then the run time and elapsed t= ime for the queries are the same.

I have tried numerous configurations in the postgresql.co= nf file.  I have set the shared_buffers with values ranging from 75 MB= to 4000MB with no luck.  I have also tried increasing the sort_mem wi= th no luck.


When the test is running, the cpu is well over 50% idle a= nd iostat shows that the processes are not waiting for i/o and disk usage p= ercentage is low.

Any help would be appreciated.

Thanks.

------_=_NextPart_001_01C2E7AA.B7121F70-- From pgsql-performance-owner@postgresql.org Tue Mar 11 09:17:12 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id 86917475CE5 for ; Tue, 11 Mar 2003 09:17:07 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h2BE7co29797; Tue, 11 Mar 2003 09:07:38 -0500 Message-ID: <00fb01c2e7d9$e804bfa0$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: "Nikk Anderson" , "'Scott Buchan'" , References: Subject: Re: Large difference between elapsed time and run time Date: Tue, 11 Mar 2003 09:24:20 -0500 Organization: A Basic Marketing Company MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00F8_01C2E7AF.FF0B9F40" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200303/76 X-Sequence-Number: 1374 This is a multi-part message in MIME format. ------=_NextPart_000_00F8_01C2E7AF.FF0B9F40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] Large difference between elapsed time and run time for querie= sExcuse me for butting into this conversation but I would LOVE to know exac= tly how you manage that pooling because I have this same issue. When I run= a test selection using psql I get sub-second response time and when I use = the online (a separate machine dedicated to http) and do a pg_connect to th= e database using PHP4 I hit 45-50 second response times. I even tried chan= ging the connection to a persistent connection with pg_pconnect and I get t= he same thing. I installed the database on the http machine and the respon= ses are much quicker, but still not quite ideal. My question is how are you accomplishing the connection pooling? Jeff=20 ----- Original Message -----=20 From: Nikk Anderson=20 To: 'Scott Buchan' ; pgsql-performance@postgresql.org=20 Sent: Tuesday, March 11, 2003 3:46 AM Subject: Re: [PERFORM] Large difference between elapsed time and run time= =20 Hi,=20 I have noted similar issues in the past - and seemed then that most of th= e overhead bottleneck was due to establishing a new connection in the front= end. As soon as I started using connection pooling, with connections made= when the app initialises, and then recycled for each request (i.e. the con= nections never close) then the execution time was far quicker.=20 I have also noticed that sparc processor speed, num processors, disk spac= e and memory seems to makes little difference with postgres (for us anyway!= ) performance - e.g. performance no better with dual sparc 450mhz, 2 scsi d= isks, 1Gb mem - than on a single processor 400 mhz Netra, 256Mb ram with a = single IDE disk! Nikk=20 -----Original Message-----=20 From: Scott Buchan [mailto:sbuchan@technicacorp.com]=20 Sent: 10 March 2003 18:58=20 To: pgsql-performance@postgresql.org=20 Subject: [PERFORM] Large difference between elapsed time and run time for= queries=20 Hello,=20 While running benchmarks for my database, I am seeing a large difference = in the elapsed time (from stats collected in the logs) and run time (runnin= g explain analyze on the query using ./psql ) for each of my quer= ies. The database is being ran on a sunfire 880 with 4 750mhz processors w= ith 8 G RAM running solaris 8 I am simulating 200 user connections each running 6 select queries on 1 i= ndexed table with 50,000 records. The elapsed time for the queries average = around 2.5 seconds while if I run the query using explain analyze while the= test is running, the run time is around 300 ms although it takes much long= er (few seconds) to display the results. If I reduce the number of concurr= ent connections to 100 then the run time and elapsed time for the queries a= re the same. I have tried numerous configurations in the postgresql.conf file. I have= set the shared_buffers with values ranging from 75 MB to 4000MB with no lu= ck. I have also tried increasing the sort_mem with no luck. When the test is running, the cpu is well over 50% idle and iostat shows = that the processes are not waiting for i/o and disk usage percentage is low. Any help would be appreciated.=20 Thanks.=20 ------=_NextPart_000_00F8_01C2E7AF.FF0B9F40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] Large difference between elapsed time and = run time for queries
Excuse me for butting into this conversation but= I=20 would LOVE to know exactly how you manage that pooling because I have this = same=20 issue.  When I run a test selection using psql I get sub-second respon= se=20 time and when I use the online (a separate machine dedicated to http) = and=20 do a pg_connect to the database using PHP4 I hit 45-50 second response=20 times.  I even tried changing the connection to a persistent connectio= n=20 with pg_pconnect and I get the same thing.  I installed the datab= ase=20 on the http machine and the responses are much quicker, but still not quite= =20 ideal.
 
My question is how are you accomplishing the con= nection=20 pooling?
 
     Jeff
----- Original Message -----
Fro= m:=20 Nikk Anderson
To: 'Scott Buchan' ; pgsql-performance@postgr= esql.org=20
Sent: Tuesday, March 11, 2003 3:46= =20 AM
Subject: Re: [PERFORM] Large diffe= rence=20 between elapsed time and run time

Hi,

I have noted similar issues in the past - and seemed th= en that=20 most of the overhead bottleneck was due to establishing a new connection = in=20 the front end.  As soon as I started using connection pooling, with= =20 connections made when the app initialises, and then recycled for each req= uest=20 (i.e. the connections never close) then the execution time was far quicke= r.=20

I have also noticed that sparc processor speed, num=20 processors, disk space and memory seems to makes little difference with= =20 postgres (for us anyway!) performance - e.g. performance no better with d= ual=20 sparc 450mhz, 2 scsi disks, 1Gb mem - than on a single processor 400 mhz= =20 Netra, 256Mb ram with a single IDE disk!

Nikk

-----Original Message-----
Fr= om: Scott=20 Buchan [mailto:sbuchan@technicacorp.com<= /A>]=20
Sent: 10 March 2003 18:58
To= :=20 pgsql-performance@postgresql.org
Subject: [PERF= ORM]=20 Large difference between elapsed time and run time for queries

Hello,

While running benchmarks for my database, I am seeing a= large=20 difference in the elapsed time (from stats collected in the logs) and run= time=20 (running explain analyze on the query using ./psql <database>) for = each=20 of my queries.  The database is being ran on a sunfire 880 with 4 75= 0mhz=20 processors with 8 G RAM running solaris 8

I am simulating 200 user connections each running 6 sel= ect=20 queries on 1 indexed table with 50,000 records. The elapsed time for the= =20 queries average around 2.5 seconds while if I run the query using explain= =20 analyze while the test is running, the run time is around 300 ms although= it=20 takes much longer (few seconds) to display the results.  If I reduce= the=20 number of concurrent connections to 100 then the run time and elapsed tim= e for=20 the queries are the same.

I have tried numerous configurations in the postgresql.= conf=20 file.  I have set the shared_buffers with values ranging from 75 MB = to=20 4000MB with no luck.  I have also tried increasing the sort_mem with= no=20 luck.


When the test is running, the cpu is well over 50% idle= and=20 iostat shows that the processes are not waiting for i/o and disk usage=20 percentage is low.

Any help would be appreciated.

Thanks.

------=_NextPart_000_00F8_01C2E7AF.FF0B9F40-- From pgsql-performance-owner@postgresql.org Tue Mar 11 09:30:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id 5DFCF475F3D for ; Tue, 11 Mar 2003 09:30:42 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Tue, 11 Mar 2003 14:30:45 -0000 Message-ID: From: Nikk Anderson To: "'Jeffrey D. Brower'" , pgsql-performance@postgresql.org Subject: Re: Large difference between elapsed time and run time Date: Tue, 11 Mar 2003 14:30:45 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2E7DA.CD6C7880" X-Archive-Number: 200303/77 X-Sequence-Number: 1375 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_01C2E7DA.CD6C7880 Content-Type: text/plain; charset="iso-8859-1" Hi, -----Original Message----- From: Jeffrey D. Brower [mailto:jeff@pointhere.net] Sent: 11 March 2003 14:24 To: Nikk Anderson; 'Scott Buchan'; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Large difference between elapsed time and run time >My question is how are you accomplishing the connection pooling? I have programmed a connection pool in Java - I am sure something similar is possible in most other languages. Very basically, the concept is as follows: > Application initialisation >>> 1) Create X number of connections to the database >>> 2) Store connections in an Object >>> 3) Create an array of free and busy connections - put all new connections in free connection array >>> 4) Object is visible to all components of web application > Request for a connection >>> 4) Code asks for a connection from the pool object (3). >>> 5) Pool object moves connection from free array, to the busy array. >>> 5) Connection is used to do queries >>> 6) Connection is sent back to pool object (3). >>> 7) Pool object moves the connection from the busy array, back to the free array I hope that helps! Nikk ------_=_NextPart_001_01C2E7DA.CD6C7880 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] Large difference between elapsed time and run time </T= ITLE> </HEAD> <BODY> <P><FONT SIZE=3D2>Hi, </FONT> </P> <P><FONT SIZE=3D2>-----Original Message-----</FONT> <BR><FONT SIZE=3D2>From: Jeffrey D. Brower [<A HREF=3D"mailto:jeff@pointher= e.net">mailto:jeff@pointhere.net</A>]</FONT> <BR><FONT SIZE=3D2>Sent: 11 March 2003 14:24</FONT> <BR><FONT SIZE=3D2>To: Nikk Anderson; 'Scott Buchan'; pgsql-performance@pos= tgresql.org</FONT> <BR><FONT SIZE=3D2>Subject: Re: [PERFORM] Large difference between elapsed = time and run time </FONT> </P> <P><FONT SIZE=3D2>>My question is how are you accomplishing the connecti= on pooling?</FONT> </P> <BR> <P><FONT SIZE=3D2>I have programmed a connection pool in Java - I am sure s= omething similar is possible in most other languages. </FONT> </P> <P><FONT SIZE=3D2>Very basically, the concept is as follows:</FONT> </P> <P><FONT SIZE=3D2>> Application initialisation</FONT> <BR>        <FONT SIZE=3D2>>>> = 1) Create X number of connections to the database</FONT> <BR>        <FONT SIZE=3D2>>>> = 2) Store connections in an Object</FONT> <BR>        <FONT SIZE=3D2>>>> = 3) Create an array of free and busy connections - put all new connections i= n free connection array</FONT> <BR>        <FONT SIZE=3D2>>>> = 4) Object is visible to all components of web application</FONT> </P> <P><FONT SIZE=3D2>> Request for a connection</FONT> <BR>        <FONT SIZE=3D2>>>> = 4) Code asks for a connection from the pool object (3).  </FONT> <BR>        <FONT SIZE=3D2>>>> = 5) Pool object moves connection from free array, to the busy array.</FONT> <BR>        <FONT SIZE=3D2>>>> = 5) Connection is used to do queries</FONT> <BR>        <FONT SIZE=3D2>>>> = 6) Connection is sent back to pool object (3).  </FONT> <BR>        <FONT SIZE=3D2>>>> = 7) Pool object moves the connection from the busy array, back to the free a= rray</FONT> </P> <BR> <P><FONT SIZE=3D2>I hope that helps!</FONT> </P> <P><FONT SIZE=3D2>Nikk</FONT> </P> </BODY> </HTML> ------_=_NextPart_001_01C2E7DA.CD6C7880-- From pgsql-performance-owner@postgresql.org Tue Mar 11 09:47:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id B8EC847601F for <pgsql-performance@postgresql.org>; Tue, 11 Mar 2003 09:47:31 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h2BEb3o30298; Tue, 11 Mar 2003 09:37:04 -0500 Message-ID: <011d01c2e7de$0451c960$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" <jeff@pointhere.net> From: "Jeffrey D. Brower" <jeff@pointhere.net> To: "Nikk Anderson" <Nikk.Anderson@parallel.ltd.uk>, <pgsql-performance@postgresql.org> References: <DA1274E682D3734B8802904A9B36124C298CD8@nic-nts1.nic.parallel.ltd.uk> Subject: Re: Large difference between elapsed time and run time Date: Tue, 11 Mar 2003 09:53:45 -0500 Organization: A Basic Marketing Company MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_011A_01C2E7B4.1B64DE00" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200303/78 X-Sequence-Number: 1376 This is a multi-part message in MIME format. ------=_NextPart_000_011A_01C2E7B4.1B64DE00 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] Large difference between elapsed time and run timeYes, this h= elps a lot. Obviously this is far more complicated than just a simple pg_p= connect to accomplish a speedy reply. I really thought that a persistent c= onnection was supposed to eliminate the overhead time in a connection (well= , other than the first time through). But even if I am the only person on = the machine it still takes forever to get a response every time I use http.= I wondered if I was supposed to have a php program that had its own pconn= ect and every http call to the PostgreSQL database went to that php program= rather than handling it by itself, but I found no indication of that while= RTFM. I will give this a try and see if I can get the speed to anything r= easonable. Thanks for the quick reply! Jeff ----- Original Message -----=20 From: Nikk Anderson=20 To: 'Jeffrey D. Brower' ; pgsql-performance@postgresql.org=20 Sent: Tuesday, March 11, 2003 9:30 AM Subject: Re: [PERFORM] Large difference between elapsed time and run time= =20 Hi,=20 -----Original Message-----=20 From: Jeffrey D. Brower [mailto:jeff@pointhere.net]=20 Sent: 11 March 2003 14:24=20 To: Nikk Anderson; 'Scott Buchan'; pgsql-performance@postgresql.org=20 Subject: Re: [PERFORM] Large difference between elapsed time and run time= =20 >My question is how are you accomplishing the connection pooling?=20 I have programmed a connection pool in Java - I am sure something similar= is possible in most other languages.=20 Very basically, the concept is as follows:=20 > Application initialisation=20 >>> 1) Create X number of connections to the database=20 >>> 2) Store connections in an Object=20 >>> 3) Create an array of free and busy connections - put all new= connections in free connection array=20 >>> 4) Object is visible to all components of web application=20 > Request for a connection=20 >>> 4) Code asks for a connection from the pool object (3).=20=20 >>> 5) Pool object moves connection from free array, to the busy = array.=20 >>> 5) Connection is used to do queries=20 >>> 6) Connection is sent back to pool object (3).=20=20 >>> 7) Pool object moves the connection from the busy array, back= to the free array=20 I hope that helps!=20 Nikk=20 ------=_NextPart_000_011A_01C2E7B4.1B64DE00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>RE: [PERFORM] Large difference between elapsed time and = run time
Yes, this helps a lot.  Obviously this is f= ar more=20 complicated than just a simple pg_pconnect to accomplish a speedy reply.&nb= sp; I=20 really thought that a persistent connection was supposed to eliminate the= =20 overhead time in a connection (well, other than the first time through).&nb= sp;=20 But even if I am the only person on the machine it still takes forever to g= et a=20 response every time I use http.  I wondered if I was supposed to have = a php=20 program that had its own pconnect and every http call to the PostgreSQL=20 database went to that php program rather than handling it by itself, b= ut I=20 found no indication of that while RTFM.  I will give this a try and se= e if=20 I can get the speed to anything reasonable.  Thanks for the quick=20 reply!
 
     Jeff

-----Original Message-----
From: Scott Buchan [
mailto:sbuchan@technicacorp.com]
Sent: 10 March 2003 18:58
To: pgsql-performance@postgresql.org
Subject: [PERFORM] Large difference between elapsed time= and run time for queries

----- Original Message -----
Fro= m:=20 Nikk Anderson
To: 'Jeffrey D. Brower' ; pgsql-performance@postgr= esql.org=20
Sent: Tuesday, March 11, 2003 9:30= =20 AM
Subject: Re: [PERFORM] Large diffe= rence=20 between elapsed time and run time

Hi,

-----Original Message-----
Fr= om:=20 Jeffrey D. Brower [mailto:jeff@pointhere.net]= =20
Sent: 11 March 2003 14:24
To= : Nikk=20 Anderson; 'Scott Buchan'; pgsql-performance@postgr= esql.org=20
Subject: Re: [PERFORM] Large difference between elapse= d time=20 and run time

>My question is how are you accomplishing the connec= tion=20 pooling?


I have programmed a connection pool in Java - I am sure= =20 something similar is possible in most other languages.

Very basically, the concept is as follows:

> Application initialisation=20
        >>>= ; 1)=20 Create X number of connections to the database=20
        >>>= ; 2)=20 Store connections in an Object=20
        >>>= ; 3)=20 Create an array of free and busy connections - put all new connections in= free=20 connection array
        >>> 4) Object is visible to all components of web=20 application

> Request for a connection=20
        >>>= ; 4)=20 Code asks for a connection from the pool object (3). =20
        >>> 5) Pool object moves connection from free array, to= the=20 busy array.

        >>> 5) Connection is used to do queries
=20
        >>>= ; 6)=20 Connection is sent back to pool object (3). =20
        >>> 7) Pool object moves the connection from the busy a= rray,=20 back to the free array


I hope that helps!

Nikk

------=_NextPart_000_011A_01C2E7B4.1B64DE00-- From pgsql-performance-owner@postgresql.org Tue Mar 11 15:23:52 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mailrelay (technicacorp.com [216.181.29.134]) by postgresql.org (Postfix) with ESMTP id BB4D2476178 for ; Tue, 11 Mar 2003 13:20:05 -0500 (EST) thread-index: AcLn+sGq2G9w81juTlSzJozTp1pQ7Q== Content-Transfer-Encoding: 7bit Received: from WWWSERVER.technicacorp.com ([216.181.29.149]) by mailrelay with Microsoft SMTPSVC(5.0.2195.5329); Tue, 11 Mar 2003 13:19:28 -0500 Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Received: by wwwserver with Internet Mail Service (5.5.2656.59) id ; Tue, 11 Mar 2003 13:23:31 -0500 Message-ID: <71F044551C53974EB0735B3737EFE2FC08862B@wwwserver> From: "Scott Buchan" To: Subject: Re: Large difference between elapsed time and run time for queries Date: Tue, 11 Mar 2003 13:23:21 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: text/plain; charset="iso-8859-1" X-OriginalArrivalTime: 11 Mar 2003 18:19:28.0911 (UTC) FILETIME=[C134F9F0:01C2E7FA] X-Archive-Number: 200303/79 X-Sequence-Number: 1377 Thanks for the quick reply. I just upgraded from 7.2 to 7.3 since 7.3 uses a different qsort (BSD-licensed). After running a few tests, I have noticed some performance gains. I think another problem that I was having was due to the way I was performing the tests. I was using the tool "The Grinder" to simulate 300 connections (through JDBC) to the database each running 6 queries without any connection pooling. Once I figure out how to use connection pooling with the Grinder, I will try running the tests again. Do you know of any other performance issues with using Solaris? Thanks for the help, Scott -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Monday, March 10, 2003 3:08 PM To: Scott Buchan Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Large difference between elapsed time and run time for queries "Scott Buchan" writes: > I am simulating 200 user connections each running 6 select queries on 1 > indexed table with 50,000 records. The elapsed time for the queries average > around 2.5 seconds while if I run the query using explain analyze while the > test is running, the run time is around 300 ms although it takes much longer > (few seconds) to display the results. How many rows are these queries returning? AFAICS the differential must be the cost of transmitting the data to the frontend, which of course does not happen when you use explain analyze. (I think, but am not completely sure, that explain analyze also suppresses the CPU effort of converting the data to text form, as would normally be done before transmitting it. But given that you don't see a problem at 100 connections, that's probably not where the issue lies.) > The database is being ran on a sunfire 880 with 4 750mhz > processors with 8 G RAM running solaris 8 We have seen some other weird performance problems on Solaris (their standard qsort apparently is very bad, for example). Might be that you need to be looking at kernel behavior, not at Postgres. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Mar 11 15:52:19 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 8B055476304 for ; Tue, 11 Mar 2003 15:52:17 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.8/8.12.8) with ESMTP id h2BKoB8T014204; Tue, 11 Mar 2003 13:50:12 -0700 (MST) Date: Tue, 11 Mar 2003 13:50:30 -0700 (MST) From: "scott.marlowe" To: "Jeffrey D. Brower" Cc: Nikk Anderson , "'Scott Buchan'" , Subject: Re: Large difference between elapsed time and run time In-Reply-To: <00fb01c2e7d9$e804bfa0$0b02a8c0@pointhere.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Archive-Number: 200303/80 X-Sequence-Number: 1378 On Tue, 11 Mar 2003, Jeffrey D. Brower wrote: > RE: [PERFORM] Large difference between elapsed time and run time for > queriesExcuse me for butting into this conversation but I would LOVE to > know exactly how you manage that pooling because I have this same issue. > When I run a test selection using psql I get sub-second response time > and when I use the online (a separate machine dedicated to http) and do > a pg_connect to the database using PHP4 I hit 45-50 second response > times. I even tried changing the connection to a persistent connection > with pg_pconnect and I get the same thing. I installed the database on > the http machine and the responses are much quicker, but still not quite > ideal. > > My question is how are you accomplishing the connection pooling? In PHP, you do NOT have the elegant connection pooling that jdbc and AOLServer have. It's easy to build an apache/php/postgresql server that collapses under load if you don't know how to configure it to make sure apache runs out of children before postgresql runs out of resources. You have a connection for each apache child, and they are per database and per users, so if you connect as frank to db1, then the next page connects as jenny to db2, it can't reuse that connection. The setting in php.ini that says max persistant connects is PER PROCESS, not total, so if you have that set to 5, and max apache children to 150, you could theoretically wind up with 749 idle connections after a while. Not good. If your machine is taking more than a few milliseconds to connect to postgresql, something is very wrong with it. It could be you're running out of memory and having a swap storm, or that postgresql front ends are crashing, or any other problem. What does top or free show when you are connecting? i.e. how much memory is used by swap, how much is cache, how much is shared, all that jazz. From pgsql-performance-owner@postgresql.org Wed Mar 12 15:49:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from hm61.locaweb.com.br (hm61.locaweb.com.br [200.213.197.161]) by postgresql.org (Postfix) with SMTP id AE9874758E6 for ; Wed, 12 Mar 2003 15:49:02 -0500 (EST) Received: (qmail 17969 invoked from network); 12 Mar 2003 20:51:27 -0000 Received: from hm20.locaweb.com.br (200.246.179.120) by hm61.locaweb.com.br with QMTP; 12 Mar 2003 20:51:27 -0000 Received: (qmail 11721 invoked from network); 12 Mar 2003 20:50:56 -0000 Received: from unknown (HELO fabio) (contato@enix.com.br@200.207.117.104) by hm20.locaweb.com.br with SMTP; 12 Mar 2003 20:50:56 -0000 Message-ID: <000701c2e8d8$95637b60$02ada8c0@enix> From: =?iso-8859-1?Q?Enix_Empreendimentos_e_Constru=E7=F5es_Ltda.?= To: Subject: Postgresql performance Date: Wed, 12 Mar 2003 17:47:23 -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.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Archive-Number: 200303/81 X-Sequence-Number: 1379 Hi everybody. I am a newbie to Postgresql, trying to migrate an application from MSAccess. I am quite dissapointed with the problems I am facing with some queries containing multiple joins. I confess it has been hard for someone that is not a DBA to figure out which are the problems. Just to ilustrate, I have some queries that provide a reasonable query plan (at least from my point of view), but that return no result: keep running on and on. My system description is: Postgresql 7.1.3, Linux RedHat 7.1 (all patches applied), 160Mb RAM. Is the performance of the mentioned Postgresql version much slower than the 7.3.1? All advice will be more than appeciated. Regards. Fabio --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.461 / Virus Database: 260 - Release Date: 10/03/2003 From pgsql-performance-owner@postgresql.org Wed Mar 12 16:39:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from utahisp.com (mail.cyber-wire.com [66.239.12.3]) by postgresql.org (Postfix) with ESMTP id 9B79B4769F8 for ; Wed, 12 Mar 2003 16:38:15 -0500 (EST) Received: from chad [63.230.8.76] by utahisp.com (SMTPD32-7.14) id A84DBC59027E; Wed, 12 Mar 2003 14:36:13 -0700 Message-ID: <0c8a01c2e8df$b205a2a0$32021aac@chad> From: "Chad Thompson" To: =?iso-8859-1?Q?Enix_Empreendimentos_e_Constru=E7=F5es_Ltda.?= , References: <000701c2e8d8$95637b60$02ada8c0@enix> Subject: Re: Postgresql performance Date: Wed, 12 Mar 2003 14:38:16 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Declude-Sender: chad@weblinkservices.com [63.230.8.76] X-Note: This E-mail was scanned by Declude JunkMail (www.declude.com) for spam. X-Archive-Number: 200303/82 X-Sequence-Number: 1380 There are a lot of things that can be done to speed up your queries. Especially if you are using the kludge that Access puts out. Post some of them and we can help. As far as the difference between 7.1.3 and 7.3.2 there are a lot of optimizations as well as bug fixes, its always a good idea to upgrade. HTH Chad ----- Original Message ----- From: "Enix Empreendimentos e Constru��es Ltda." To: Sent: Wednesday, March 12, 2003 1:47 PM Subject: [PERFORM] Postgresql performance > Hi everybody. > > I am a newbie to Postgresql, trying to migrate an application from MSAccess. > > I am quite dissapointed with the problems I am facing with some queries > containing multiple joins. I confess it has been hard for someone that is > not a DBA to figure out which are the problems. Just to ilustrate, I have > some queries that provide a reasonable query plan (at least from my point of > view), but that return no result: keep running on and on. > > My system description is: Postgresql 7.1.3, Linux RedHat 7.1 (all patches > applied), 160Mb RAM. > > Is the performance of the mentioned Postgresql version much slower than the > 7.3.1? > > All advice will be more than appeciated. > > Regards. > > Fabio > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.461 / Virus Database: 260 - Release Date: 10/03/2003 > > > ---------------------------(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 Wed Mar 12 16:49:00 2003 X-Original-To: pgsql-performance@postgresql.org Received: from jester.inquent.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id 5A1EF476543 for ; Wed, 12 Mar 2003 16:46:08 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.inquent.com (8.12.6/8.12.6) with ESMTP id h2CLjqTw057551; Wed, 12 Mar 2003 16:45:53 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: Postgresql performance From: Rod Taylor To: Enix Empreendimentos e =?ISO-8859-1?Q?Constru=E7=F5es?= "Ltda." Cc: Postgresql Performance In-Reply-To: <000701c2e8d8$95637b60$02ada8c0@enix> References: <000701c2e8d8$95637b60$02ada8c0@enix> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-29YHuXkyj8AJWUHrVYwm" Organization: Message-Id: <1047505552.55840.56.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 12 Mar 2003 16:45:52 -0500 X-Archive-Number: 200303/83 X-Sequence-Number: 1381 --=-29YHuXkyj8AJWUHrVYwm Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > Is the performance of the mentioned Postgresql version much slower than t= he > 7.3.1? Somewhat, but not significantly. Standard questions: Have you run VACUUM? Have you run ANALYZE? What does EXPLAIN ANALYZE output for the slow queries? If performance is still poor after the first 2, send the results of EXPLAIN here and we'll tell you which index you're missing ;) --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-29YHuXkyj8AJWUHrVYwm Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+b6qP6DETLow6vwwRAr7CAJsGf2qKawsn3DQF0XcLsFR7YTgQ3ACeKk4D gb3qpzwd1I2PEJc0pUObMD4= =/DeV -----END PGP SIGNATURE----- --=-29YHuXkyj8AJWUHrVYwm-- From pgsql-performance-owner@postgresql.org Wed Mar 12 17:38:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from cat (adsl-66-123-169-52.dsl.sntc01.pacbell.net [66.123.169.52]) by postgresql.org (Postfix) with ESMTP id F0526476345 for ; Wed, 12 Mar 2003 17:38:10 -0500 (EST) Received: by cat (Postfix, from userid 501) id 4EF7FB6D69; Wed, 12 Mar 2003 14:38:11 -0800 (PST) Date: Wed, 12 Mar 2003 14:38:11 -0800 From: Max Baker To: PostgreSQL Performance Mailing List Subject: speeding up COUNT and DISTINCT queries Message-ID: <20030312223811.GM30411@warped.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.3i X-Archive-Number: 200303/84 X-Sequence-Number: 1382 I'm looking for a general method to speed up DISTINCT and COUNT queries. mydatabase=> EXPLAIN ANALYZE select distinct(mac) from node; NOTICE: QUERY PLAN: Unique (cost=110425.67..110514.57 rows=3556 width=6) (actual time=45289.78..45598.62 rows=25334 loops=1) -> Sort (cost=110425.67..110425.67 rows=35561 width=6) (actual time=45289.77..45411.53 rows=34597 loops=1) -> Seq Scan on node (cost=0.00..107737.61 rows=35561 width=6) (actual time=6.73..44383.57 rows=34597 loops=1) Total runtime: 45673.19 msec ouch. I run VACCUUM ANALYZE once a day. Thanks, max From pgsql-performance-owner@postgresql.org Wed Mar 12 17:52:22 2003 X-Original-To: pgsql-performance@postgresql.org Received: from jester.inquent.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id B24D047634E for ; Wed, 12 Mar 2003 17:52:17 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.inquent.com (8.12.6/8.12.6) with ESMTP id h2CMqJ9n057811; Wed, 12 Mar 2003 17:52:20 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: speeding up COUNT and DISTINCT queries From: Rod Taylor To: Max Baker Cc: PostgreSQL Performance Mailing List In-Reply-To: <20030312223811.GM30411@warped.org> References: <20030312223811.GM30411@warped.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-sjRzIqqzFPTrNPe6cg49" Organization: Message-Id: <1047509538.57729.4.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 12 Mar 2003 17:52:19 -0500 X-Archive-Number: 200303/85 X-Sequence-Number: 1383 --=-sjRzIqqzFPTrNPe6cg49 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-03-12 at 17:38, Max Baker wrote: > I'm looking for a general method to=20 > speed up DISTINCT and COUNT queries.=20 >=20 >=20 > mydatabase=3D> EXPLAIN ANALYZE select distinct(mac) from node; > NOTICE: QUERY PLAN: >=20 > Unique (cost=3D110425.67..110514.57 rows=3D3556 width=3D6) (actual > time=3D45289.78..45598.62 rows=3D25334 loops=3D1) > -> Sort (cost=3D110425.67..110425.67 rows=3D35561 width=3D6) (actual > time=3D45289.77..45411.53 rows=3D34597 loops=3D1) > -> Seq Scan on node (cost=3D0.00..107737.61 rows=3D35561 > width=3D6) (actual time=3D6.73..44383.57 rows=3D34597 loops=3D1) >=20 > Total runtime: 45673.19 msec > ouch.=20 >=20 > I run VACCUUM ANALYZE once a day.=20=20 Thats not going to do anything for that query, as there only is one possible plan at the moment :) I don't think you can do much about that query, other than buy a faster harddisk or more ram. Nearly all the time seems to be used pulling the data off the disk (in the Seq Scan). --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-sjRzIqqzFPTrNPe6cg49 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+b7oi6DETLow6vwwRAsYHAJ9/PCLkwUwutS0ubA2l5dP/UzJmfACggv7P hIWtgjnKP1BDYSw2S4h/bCc= =bBdq -----END PGP SIGNATURE----- --=-sjRzIqqzFPTrNPe6cg49-- From pgsql-performance-owner@postgresql.org Wed Mar 12 17:55:07 2003 X-Original-To: pgsql-performance@postgresql.org Received: from utahisp.com (utahisp.com [66.239.12.3]) by postgresql.org (Postfix) with ESMTP id E3123476347 for ; Wed, 12 Mar 2003 17:55:05 -0500 (EST) Received: from chad [63.230.8.76] by utahisp.com (SMTPD32-7.14) id AA513C0284; Wed, 12 Mar 2003 15:53:05 -0700 Message-ID: <0ca601c2e8ea$6f7783d0$32021aac@chad> From: "Chad Thompson" To: "Max Baker" , "PostgreSQL Performance Mailing List" References: <20030312223811.GM30411@warped.org> Subject: Re: speeding up COUNT and DISTINCT queries Date: Wed, 12 Mar 2003 15:55:09 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Declude-Sender: chad@weblinkservices.com [63.230.8.76] X-Note: This E-mail was scanned by Declude JunkMail (www.declude.com) for spam. X-Archive-Number: 200303/86 X-Sequence-Number: 1384 Ive found that group by works faster than distinct. Try EXPLAIN ANALYZE select mac from node group by mac; HTH Chad ----- Original Message ----- From: "Max Baker" To: "PostgreSQL Performance Mailing List" Sent: Wednesday, March 12, 2003 3:38 PM Subject: [PERFORM] speeding up COUNT and DISTINCT queries > I'm looking for a general method to > speed up DISTINCT and COUNT queries. > > > mydatabase=> EXPLAIN ANALYZE select distinct(mac) from node; > NOTICE: QUERY PLAN: > > Unique (cost=110425.67..110514.57 rows=3556 width=6) (actual > time=45289.78..45598.62 rows=25334 loops=1) > -> Sort (cost=110425.67..110425.67 rows=35561 width=6) (actual > time=45289.77..45411.53 rows=34597 loops=1) > -> Seq Scan on node (cost=0.00..107737.61 rows=35561 > width=6) (actual time=6.73..44383.57 rows=34597 loops=1) > > Total runtime: 45673.19 msec > ouch. > > I run VACCUUM ANALYZE once a day. > > Thanks, > max > > ---------------------------(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 Mar 12 18:39:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id 7247E4758E6 for ; Wed, 12 Mar 2003 18:39:31 -0500 (EST) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id SAA07170; Wed, 12 Mar 2003 18:39:28 -0500 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma007168; Wed, 12 Mar 03 18:39:17 -0500 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id SAA23885; Wed, 12 Mar 2003 18:35:05 -0500 Message-ID: <3E6FC574.F15D9930@nsd.ca> Date: Wed, 12 Mar 2003 18:40:36 -0500 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: Max Baker Cc: PostgreSQL Performance Mailing List Subject: Re: speeding up COUNT and DISTINCT queries References: <20030312223811.GM30411@warped.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/87 X-Sequence-Number: 1385 Do you have an index on mac? Max Baker wrote: > > I'm looking for a general method to > speed up DISTINCT and COUNT queries. > > mydatabase=> EXPLAIN ANALYZE select distinct(mac) from node; > NOTICE: QUERY PLAN: > > Unique (cost=110425.67..110514.57 rows=3556 width=6) (actual > time=45289.78..45598.62 rows=25334 loops=1) > -> Sort (cost=110425.67..110425.67 rows=35561 width=6) (actual > time=45289.77..45411.53 rows=34597 loops=1) > -> Seq Scan on node (cost=0.00..107737.61 rows=35561 > width=6) (actual time=6.73..44383.57 rows=34597 loops=1) > > Total runtime: 45673.19 msec > ouch. > > I run VACCUUM ANALYZE once a day. > > Thanks, > max > > ---------------------------(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 Mar 12 18:49:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from email05.aon.at (WARSL401PIP4.highway.telekom.at [195.3.96.79]) by postgresql.org (Postfix) with SMTP id 48A94476345 for ; Wed, 12 Mar 2003 18:49:30 -0500 (EST) Received: (qmail 238034 invoked from network); 12 Mar 2003 23:49:32 -0000 Received: from m160p030.dipool.highway.telekom.at (HELO cantor) ([62.46.9.254]) (envelope-sender ) by qmail5rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 12 Mar 2003 23:49:32 -0000 From: Manfred Koizar To: Max Baker Cc: PostgreSQL Performance Mailing List Subject: Re: speeding up COUNT and DISTINCT queries Date: Thu, 13 Mar 2003 00:48:27 +0100 Message-ID: References: <20030312223811.GM30411@warped.org> In-Reply-To: <20030312223811.GM30411@warped.org> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/88 X-Sequence-Number: 1386 On Wed, 12 Mar 2003 14:38:11 -0800, Max Baker wrote: > -> Seq Scan on node (cost=0.00..107737.61 rows=35561 > width=6) (actual time=6.73..44383.57 rows=34597 loops=1) 35000 tuples in 100000 pages? >I run VACCUUM ANALYZE once a day. Try VACUUM FULL VERBOSE ANALAYZE; this should bring back your table to a reasonable size. If the table starts growing again, VACUUM more often. Servus Manfred From pgsql-performance-owner@postgresql.org Wed Mar 12 20:00:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from cat (adsl-66-123-169-52.dsl.sntc01.pacbell.net [66.123.169.52]) by postgresql.org (Postfix) with ESMTP id 8E77C476356 for ; Wed, 12 Mar 2003 20:00:17 -0500 (EST) Received: by cat (Postfix, from userid 501) id 45973B6D69; Wed, 12 Mar 2003 17:00:19 -0800 (PST) Date: Wed, 12 Mar 2003 17:00:19 -0800 From: Max Baker To: Chad Thompson Cc: PostgreSQL Performance Mailing List Subject: Re: speeding up COUNT and DISTINCT queries Message-ID: <20030313010018.GN30411@warped.org> References: <20030312223811.GM30411@warped.org> <0ca601c2e8ea$6f7783d0$32021aac@chad> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0ca601c2e8ea$6f7783d0$32021aac@chad> User-Agent: Mutt/1.5.3i X-Archive-Number: 200303/89 X-Sequence-Number: 1387 On Wed, Mar 12, 2003 at 03:55:09PM -0700, Chad Thompson wrote: > Ive found that group by works faster than distinct. > > Try > EXPLAIN ANALYZE select mac from node group by mac; This was about 25% faster, thanks! That will work for distinct() only calls, but I still am looking for a way to speed up the count() command. Maybe an internal counter of rows, and triggers? -m From pgsql-performance-owner@postgresql.org Wed Mar 12 20:55:41 2003 X-Original-To: pgsql-performance@postgresql.org Received: from cat (adsl-66-123-169-52.dsl.sntc01.pacbell.net [66.123.169.52]) by postgresql.org (Postfix) with ESMTP id D3DCF475A4B for ; Wed, 12 Mar 2003 20:55:39 -0500 (EST) Received: by cat (Postfix, from userid 501) id 59C78B6D69; Wed, 12 Mar 2003 17:55:41 -0800 (PST) Date: Wed, 12 Mar 2003 17:55:40 -0800 From: Max Baker To: Manfred Koizar Cc: PostgreSQL Performance Mailing List Subject: Re: speeding up COUNT and DISTINCT queries Message-ID: <20030313015540.GP30411@warped.org> References: <20030312223811.GM30411@warped.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.3i X-Archive-Number: 200303/90 X-Sequence-Number: 1388 On Thu, Mar 13, 2003 at 12:48:27AM +0100, Manfred Koizar wrote: > On Wed, 12 Mar 2003 14:38:11 -0800, Max Baker wrote: > > -> Seq Scan on node (cost=0.00..107737.61 rows=35561 > > width=6) (actual time=6.73..44383.57 rows=34597 loops=1) > > 35000 tuples in 100000 pages? > > >I run VACCUUM ANALYZE once a day. > > Try VACUUM FULL VERBOSE ANALAYZE; this should bring back your table > to a reasonable size. If the table starts growing again, VACUUM more > often. Manfred, Thanks for the help. I guess i'm not clear on why there is so much extra cruft. Does postgres leave a little bit behind every time it does an update? Because this table is updated constantly. Check out the results, 1.5 seconds compared to 46 seconds : mydb=> vacuum full verbose analyze node; NOTICE: --Relation node-- NOTICE: Pages 107589: Changed 0, reaped 107588, Empty 0, New 0; Tup 34846: Vac 186847, Keep/VTL 0/0, UnUsed 9450103, MinLen 88, MaxLen 104; Re-using: Free/Avail. Space 837449444/837449368; EndEmpty/Avail. Pages 0/107588. CPU 15.32s/0.51u sec elapsed 30.89 sec. NOTICE: Index node_pkey: Pages 10412; Tuples 34846: Deleted 186847. CPU 3.67s/2.48u sec elapsed 77.06 sec. NOTICE: Index idx_node_switch_port: Pages 54588; Tuples 34846: Deleted 186847. CPU 9.59s/2.42u sec elapsed 273.50 sec. NOTICE: Index idx_node_switch: Pages 50069; Tuples 34846: Deleted 186847. CPU 8.46s/2.08u sec elapsed 258.62 sec. NOTICE: Index idx_node_mac: Pages 6749; Tuples 34846: Deleted 186847. CPU 2.19s/1.59u sec elapsed 56.05 sec. NOTICE: Index idx_node_switch_port_active: Pages 51138; Tuples 34846: Deleted 186847. CPU 8.58s/2.99u sec elapsed 273.03 sec. NOTICE: Index idx_node_mac_active: Pages 6526; Tuples 34846: Deleted 186847. CPU 1.75s/1.90u sec elapsed 46.70 sec. NOTICE: Rel node: Pages: 107589 --> 399; Tuple(s) moved: 34303. CPU 83.49s/51.73u sec elapsed 1252.35 sec. NOTICE: Index node_pkey: Pages 10412; Tuples 34846: Deleted 34303. CPU 3.65s/1.64u sec elapsed 72.99 sec. NOTICE: Index idx_node_switch_port: Pages 54650; Tuples 34846: Deleted 34303. CPU 10.77s/2.05u sec elapsed 278.46 sec. NOTICE: Index idx_node_switch: Pages 50114; Tuples 34846: Deleted 34303. CPU 9.95s/1.65u sec elapsed 266.55 sec. NOTICE: Index idx_node_mac: Pages 6749; Tuples 34846: Deleted 34303. CPU 1.75s/1.13u sec elapsed 52.78 sec. NOTICE: Index idx_node_switch_port_active: Pages 51197; Tuples 34846: Deleted 34303. CPU 10.48s/1.89u sec elapsed 287.46 sec. NOTICE: Index idx_node_mac_active: Pages 6526; Tuples 34846: Deleted 34303. CPU 2.16s/0.96u sec elapsed 48.67 sec. NOTICE: --Relation pg_toast_64458-- NOTICE: Pages 0: Changed 0, reaped 0, Empty 0, New 0; Tup 0: Vac 0, Keep/VTL 0/0, UnUsed 0, MinLen 0, MaxLen 0; Re-using: Free/Avail. Space 0/0; EndEmpty/Avail. Pages 0/0. CPU 0.00s/0.00u sec elapsed 0.00 sec. NOTICE: Index pg_toast_64458_idx: Pages 1; Tuples 0. CPU 0.00s/0.00u sec elapsed 0.00 sec. NOTICE: Analyzing node VACUUM mydb=> EXPLAIN ANALYZE select distinct(mac) from node; NOTICE: QUERY PLAN: Unique (cost=3376.37..3463.48 rows=3485 width=6) (actual time=1049.09..1400.45 rows=25340 loops=1) -> Sort (cost=3376.37..3376.37 rows=34846 width=6) (actual time=1049.07..1190.58 rows=34846 loops=1) -> Seq Scan on node (cost=0.00..747.46 rows=34846 width=6) (actual time=0.14..221.18 rows=34846 loops=1) Total runtime: 1491.56 msec EXPLAIN now that's results =] -m From pgsql-performance-owner@postgresql.org Wed Mar 12 21:00:11 2003 X-Original-To: pgsql-performance@postgresql.org Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by postgresql.org (Postfix) with ESMTP id AEDF8476358 for ; Wed, 12 Mar 2003 21:00:08 -0500 (EST) Received: from [192.168.5.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.4) with ESMTP-TLS id 1662409; Wed, 12 Mar 2003 18:36:03 -0800 Message-ID: <3E6FE59E.1050602@joeconway.com> Date: Wed, 12 Mar 2003 17:57:50 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Max Baker Cc: Manfred Koizar , PostgreSQL Performance Mailing List Subject: Re: speeding up COUNT and DISTINCT queries References: <20030312223811.GM30411@warped.org> <20030313015540.GP30411@warped.org> In-Reply-To: <20030313015540.GP30411@warped.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/91 X-Sequence-Number: 1389 Max Baker wrote: > Thanks for the help. I guess i'm not clear on why there is so much > extra cruft. Does postgres leave a little bit behind every time it does > an update? Because this table is updated constantly. > Yes. See: http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/routine-vacuuming.html Joe From pgsql-performance-owner@postgresql.org Wed Mar 12 21:05:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from cat (adsl-66-123-169-52.dsl.sntc01.pacbell.net [66.123.169.52]) by postgresql.org (Postfix) with ESMTP id 4FA6A476350 for ; Wed, 12 Mar 2003 21:05:45 -0500 (EST) Received: by cat (Postfix, from userid 501) id 449C7B6D69; Wed, 12 Mar 2003 18:05:47 -0800 (PST) Date: Wed, 12 Mar 2003 18:05:47 -0800 From: Max Baker To: Joe Conway Cc: Manfred Koizar , PostgreSQL Performance Mailing List Subject: Re: speeding up COUNT and DISTINCT queries Message-ID: <20030313020546.GQ30411@warped.org> References: <20030312223811.GM30411@warped.org> <20030313015540.GP30411@warped.org> <3E6FE59E.1050602@joeconway.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E6FE59E.1050602@joeconway.com> User-Agent: Mutt/1.5.3i X-Archive-Number: 200303/92 X-Sequence-Number: 1390 On Wed, Mar 12, 2003 at 05:57:50PM -0800, Joe Conway wrote: > Max Baker wrote: > >Thanks for the help. I guess i'm not clear on why there is so much > >extra cruft. Does postgres leave a little bit behind every time it does > >an update? Because this table is updated constantly. > > > > Yes. See: > http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/routine-vacuuming.html That would explain why once a night isn't enough. Thanks. The contents of this table get refreshed every 4 hours. I'll add a vacuum after every refresh and comapre the results in a couple days. -m From pgsql-performance-owner@postgresql.org Wed Mar 12 21:19:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id CFAA14758E6 for ; Wed, 12 Mar 2003 21:19:52 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h2D2JtX01227 for pgsql-performance@postgresql.org; Thu, 13 Mar 2003 10:19:55 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h2D2Jo701134; Thu, 13 Mar 2003 10:19:50 +0800 (WST) Message-ID: <099c01c2e907$0ede0770$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: "Max Baker" , "PostgreSQL Performance Mailing List" References: <20030312223811.GM30411@warped.org> Subject: Re: speeding up COUNT and DISTINCT queries Date: Thu, 13 Mar 2003 10:20:04 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/93 X-Sequence-Number: 1391 Try setting up a trigger to maintain a separate table containing only the distinct values... Chris ----- Original Message ----- From: "Max Baker" To: "PostgreSQL Performance Mailing List" Sent: Thursday, March 13, 2003 6:38 AM Subject: [PERFORM] speeding up COUNT and DISTINCT queries > I'm looking for a general method to > speed up DISTINCT and COUNT queries. > > > mydatabase=> EXPLAIN ANALYZE select distinct(mac) from node; > NOTICE: QUERY PLAN: > > Unique (cost=110425.67..110514.57 rows=3556 width=6) (actual > time=45289.78..45598.62 rows=25334 loops=1) > -> Sort (cost=110425.67..110425.67 rows=35561 width=6) (actual > time=45289.77..45411.53 rows=34597 loops=1) > -> Seq Scan on node (cost=0.00..107737.61 rows=35561 > width=6) (actual time=6.73..44383.57 rows=34597 loops=1) > > Total runtime: 45673.19 msec > ouch. > > I run VACCUUM ANALYZE once a day. > > Thanks, > max > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > From pgsql-performance-owner@postgresql.org Thu Mar 13 10:43:01 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id 070E0476369 for ; Thu, 13 Mar 2003 10:42:59 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id C779F137F15; Thu, 13 Mar 2003 10:42:56 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18tUrA-0004ZO-00; Thu, 13 Mar 2003 10:42:56 -0500 To: Max Baker Cc: Joe Conway , Manfred Koizar , PostgreSQL Performance Mailing List Subject: Re: speeding up COUNT and DISTINCT queries References: <20030312223811.GM30411@warped.org> <20030313015540.GP30411@warped.org> <3E6FE59E.1050602@joeconway.com> <20030313020546.GQ30411@warped.org> In-Reply-To: <20030313020546.GQ30411@warped.org> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 13 Mar 2003 10:42:55 -0500 Message-ID: <874r67ff28.fsf@stark.dyndns.tv> Lines: 45 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200303/94 X-Sequence-Number: 1392 Max Baker writes: > On Wed, Mar 12, 2003 at 05:57:50PM -0800, Joe Conway wrote: > > Max Baker wrote: > > >Thanks for the help. I guess i'm not clear on why there is so much > > >extra cruft. Does postgres leave a little bit behind every time it does > > >an update? Because this table is updated constantly. > > > > > > > Yes. See: > > http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/routine-vacuuming.html > > That would explain why once a night isn't enough. Thanks. > The contents of this table get refreshed every 4 hours. I'll add a > vacuum after every refresh and comapre the results in a couple days. If it gets completely refreshed, ie, every tuple is updated or deleted and re-inserted in a big batch job then VACUUM might never be enough without boosting some config values a lot. You might need to do a VACUUM FULL after the refresh. VACUUM FULL locks the table though which might be unfortunate. VACUUM FULL should be sufficient but you might want to consider instead TRUNCATE-ing the table and then reinserting records rather than deleting if that's what you're doing. Or alternatively building the new data in a new table and then doing a switcheroo with ALTER TABLE RENAME. However ALTER TABLE (and possible TRUNCATE as well?) will invalidate functions and other objects that refer to the table. Regarding the original question: . 7.4 will probably be faster than 7.3 at least if you stick with GROUP BY. . You could try building an index on mac, but I suspect even then it'll choose the sequential scan. But try it with an index and enable_seqscan = off to see if it's even worth trying to get it to use the index. If so you'll have to lower random_page_cost and/or play with cpu_tuple_cost and other variables to get it to do so. . You might also want to cluster the table on that index. You would have to recluster it every time you do your refresh and it's not clear how much it would help if any. But it might be worth trying. -- greg From pgsql-performance-owner@postgresql.org Thu Mar 13 15:05:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id B6EA44758F1 for ; Thu, 13 Mar 2003 15:05:42 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h2DKbf6P030427; Thu, 13 Mar 2003 15:37:41 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id h2DK5Up03833; Thu, 13 Mar 2003 15:05:30 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id F3HTJCH7; Thu, 13 Mar 2003 15:05:29 -0500 Subject: Re: speeding up COUNT and DISTINCT queries From: Robert Treat To: Greg Stark Cc: Max Baker , Joe Conway , Manfred Koizar , PostgreSQL Performance Mailing List In-Reply-To: <874r67ff28.fsf@stark.dyndns.tv> References: <20030312223811.GM30411@warped.org> <20030313015540.GP30411@warped.org> <3E6FE59E.1050602@joeconway.com> <20030313020546.GQ30411@warped.org> <874r67ff28.fsf@stark.dyndns.tv> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 13 Mar 2003 15:05:30 -0500 Message-Id: <1047585930.23128.913.camel@camel> Mime-Version: 1.0 X-Archive-Number: 200303/95 X-Sequence-Number: 1393 On Thu, 2003-03-13 at 10:42, Greg Stark wrote: > Max Baker writes: > > On Wed, Mar 12, 2003 at 05:57:50PM -0800, Joe Conway wrote: > > That would explain why once a night isn't enough. Thanks. > > The contents of this table get refreshed every 4 hours. I'll add a > > vacuum after every refresh and comapre the results in a couple days. > > If it gets completely refreshed, ie, every tuple is updated or deleted and > re-inserted in a big batch job then VACUUM might never be enough without > boosting some config values a lot. You might need to do a VACUUM FULL after > the refresh. VACUUM FULL locks the table though which might be unfortunate. > hmm... approx 35,000 records, getting updated every 4 hours. so.. 35000 / (4*60) =~ 145 tuples per minute. Lets assume we want to keep any overhead at 10% or less, so we need to lazy vacuum every 3500 updates. so... 3500 tuples / 145 tpm =~ 25 minutes. So, set up a cron job to lazy vacuum every 20 minutes and see how that works for you. Robert Treat From pgsql-performance-owner@postgresql.org Thu Mar 13 15:22:57 2003 X-Original-To: pgsql-performance@postgresql.org Received: from cat (adsl-66-123-169-52.dsl.sntc01.pacbell.net [66.123.169.52]) by postgresql.org (Postfix) with ESMTP id 4207747580B for ; Thu, 13 Mar 2003 15:22:56 -0500 (EST) Received: by cat (Postfix, from userid 501) id 5151EB6D69; Thu, 13 Mar 2003 12:22:54 -0800 (PST) Date: Thu, 13 Mar 2003 12:22:54 -0800 From: Max Baker To: Robert Treat Cc: Greg Stark , Joe Conway , Manfred Koizar , PostgreSQL Performance Mailing List Subject: Re: speeding up COUNT and DISTINCT queries Message-ID: <20030313202254.GD30411@warped.org> References: <20030312223811.GM30411@warped.org> <20030313015540.GP30411@warped.org> <3E6FE59E.1050602@joeconway.com> <20030313020546.GQ30411@warped.org> <874r67ff28.fsf@stark.dyndns.tv> <1047585930.23128.913.camel@camel> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1047585930.23128.913.camel@camel> User-Agent: Mutt/1.5.3i X-Archive-Number: 200303/96 X-Sequence-Number: 1394 On Thu, Mar 13, 2003 at 03:05:30PM -0500, Robert Treat wrote: > On Thu, 2003-03-13 at 10:42, Greg Stark wrote: > > Max Baker writes: > > > On Wed, Mar 12, 2003 at 05:57:50PM -0800, Joe Conway wrote: > > > That would explain why once a night isn't enough. Thanks. > > > The contents of this table get refreshed every 4 hours. I'll add a > > > vacuum after every refresh and comapre the results in a couple days. > > > > If it gets completely refreshed, ie, every tuple is updated or deleted and > > re-inserted in a big batch job then VACUUM might never be enough without > > boosting some config values a lot. You might need to do a VACUUM FULL after > > the refresh. VACUUM FULL locks the table though which might be unfortunate. I'm not starting with fresh data every time, I'm usually checking for an existing record, then setting a timestamp and a boolean flag. I've run some profiling and it's about 8000-10,000 UPDATEs every 4 hours. These are accompanied by about 800-1000 INSERTs. > hmm... approx 35,000 records, getting updated every 4 hours. so.. > > 35000 / (4*60) =~ 145 tuples per minute. > > Lets assume we want to keep any overhead at 10% or less, so we need to > lazy vacuum every 3500 updates. so... > > 3500 tuples / 145 tpm =~ 25 minutes. > > So, set up a cron job to lazy vacuum every 20 minutes and see how that > works for you. I'm now having VACUUM ANALYZE run after each of these updates. The data comes in in spurts -- a 90 minute batch job that runs every 4 hours. thanks folks, -m From pgsql-performance-owner@postgresql.org Thu Mar 13 17:27:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from fuji.krosing.net (unknown [194.204.44.118]) by postgresql.org (Postfix) with ESMTP id AC17F475AE4 for ; Thu, 13 Mar 2003 17:27:31 -0500 (EST) Received: from fuji.krosing.net (lo [127.0.0.1]) by fuji.krosing.net (8.12.7/8.12.7) with ESMTP id h2DMQLaG002067; Fri, 14 Mar 2003 00:26:21 +0200 Received: (from hannu@localhost) by fuji.krosing.net (8.12.7/8.12.7/Submit) id h2DMQKZl002065; Fri, 14 Mar 2003 00:26:20 +0200 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: Postgresql performance From: Hannu Krosing To: Enix Empreendimentos e =?ISO-8859-1?Q?Constru=E7=F5es?= "Ltda." Cc: pgsql-performance@postgresql.org In-Reply-To: <000701c2e8d8$95637b60$02ada8c0@enix> References: <000701c2e8d8$95637b60$02ada8c0@enix> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Organization: Message-Id: <1047594379.1709.98.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-1) Date: 14 Mar 2003 00:26:20 +0200 X-Archive-Number: 200303/97 X-Sequence-Number: 1395 Enix Empreendimentos e Constru=E7=F5es Ltda. kirjutas K, 12.03.2003 kell 22:47: > Hi everybody. >=20 > I am a newbie to Postgresql, trying to migrate an application from MSAcce= ss. >=20 > I am quite dissapointed with the problems I am facing with some queries > containing multiple joins. Postgres currently does *not* optimize join order for explicit joins (this is currently left as a cludge for users to hand-optimize query plans). To get the benefits form optimiser you have to rewrite FROM TA JOIN TB ON TA.CB=3DTB.CB to=20 FROM A,B WHERE TA.CB=3DTB.CB > I confess it has been hard for someone that is > not a DBA to figure out which are the problems. Just to ilustrate, I have > some queries that provide a reasonable query plan (at least from my point= of > view), but that return no result: keep running on and on. Could you try to explain it in other words (or give an example). I am not native english speaker and I can read your text in at least 5 different ways ;( > Is the performance of the mentioned Postgresql version much slower than t= he > 7.3.1? It can be slower. It may also be a little faster in some very specific cases ;) -------------- Hannu From pgsql-performance-owner@postgresql.org Fri Mar 14 12:12:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 84144475E4D for ; Fri, 14 Mar 2003 12:12:03 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2899651; Fri, 14 Mar 2003 09:11:55 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Max Baker , Robert Treat Subject: Re: speeding up COUNT and DISTINCT queries Date: Fri, 14 Mar 2003 09:10:06 -0800 User-Agent: KMail/1.4.3 Cc: Greg Stark , Joe Conway , Manfred Koizar , PostgreSQL Performance Mailing List References: <20030312223811.GM30411@warped.org> <1047585930.23128.913.camel@camel> <20030313202254.GD30411@warped.org> In-Reply-To: <20030313202254.GD30411@warped.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200303140910.06416.josh@agliodbs.com> X-Archive-Number: 200303/98 X-Sequence-Number: 1396 Max, > I'm not starting with fresh data every time, I'm usually checking for > an existing record, then setting a timestamp and a boolean flag. > > I've run some profiling and it's about 8000-10,000 UPDATEs every 4 > hours. These are accompanied by about 800-1000 INSERTs. If these are wide records (i.e. large text fields or lots of columns ) you may want to consider raising your max_fsm_relation in postgresql.conf slightly, to about 15,000. You can get a better idea of a good FSM setting by running VACUUM FULL VERBOSE after your next batch (this will lock the database temporarily) and seeing how many data pages are "reclaimed", in total, by the vacuum. Then set your FSM to at least that level. And has anyone mentioned REINDEX on this thread? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Mar 16 01:01:32 2003 X-Original-To: pgsql-performance@postgresql.org Received: from citidel1 (elaine.dlib.vt.edu [128.173.49.40]) by postgresql.org (Postfix) with ESMTP id 8C32647580B for ; Sun, 16 Mar 2003 01:01:30 -0500 (EST) Received: from akrowne by citidel1 with local (Exim 3.34 #1 (Debian)) id 18uRD3-0002qe-00; Sun, 16 Mar 2003 01:01:25 -0500 Date: Sun, 16 Mar 2003 01:01:25 -0500 From: Aaron Krowne To: pgsql-performance@postgresql.org Cc: akrowne@vt.edu Subject: postgresql meltdown on PlanetMath.org Message-ID: <20030316060125.GD19570@vt.edu> Reply-To: Aaron Krowne Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.27i X-Archive-Number: 200303/99 X-Sequence-Number: 1397 Hi all. As the topic suggests, I am having fairly critical troubles with postgresql on PlanetMath.org (a site which I run). You can go there and try to pull up some entries and you will see the problem: everything is incredibly slow. It is hard to pinpoint when this began happening, but I've tried a variety of optimizations to fix it, all of which have failed. First: the machine. The machine is not too spectactular, but it is not so bad that the performance currently witnessed should be happening. It is a dual PIII-650 with 512MB of RAM and a 20gb IDE drive (yes, DMA is on). There is plenty of free space on the drive. Now, the optimisations I have tried: - Using hash indices everywhere. A few months ago, I did this, and there was a dramatic and instant speed up. However, this began degenerating. I also noticed in the logs that there was deadlock happening all over the place. The server response time was intolerable so I figured the deadlock might have something to do with this, and eliminated all hash indices (replaced with normal BTree indices). - Going back to BTrees yielded a temporary respite, but soon enough the server was back to half a minute to pull up an already-cached entry, which is of course crazy. - I then tried increasing the machines shared memory max to 75% of the physical memory, and scaled postgresql's buffers accordingly. This also sped things up for a while, but again resulted in eventual degeneration. Even worse, there were occasional crashes due to running out of memory that (according to my calculations) shouldn't have been happening. - Lastly, I tried reducing the shared memory max and limiting postgresql to more conservative values, although still not to the out-of-box values. Right now shared memory max on the system is 128mb, postgres's shared buffers are at 64mb, sort_mem is at 16mb, and effective cache size is at 10mb. For perspective, the size of the PlanetMath database dump is 24mb. It should be able to fit in memory easily, so I'm not sure what I'm doing wrong regarding the caching. For the most trivial request, Postgresql takes up basically all the CPU for the duration of the request. The load average of the machine is over-unity at all times, sometimes as bad as being the 30's. None of this happens without postgres running, so it is definitely the culprit. The site averages about one hit every twenty seconds. This should not be an overwhelming load, especially for what is just pulling up cached information 99% of the time. Given this scenario, can anyone advise? I am particularly puzzled as to why everything I tried initially helped, but always degenerated rather rapidly to a near standstill. It seems to me that everything should be able to be cached in memory with no problem, perhaps I need to force this more explicitly. My next step, if I cannot fix this, is to try mysql =( Anyway, whoever helps would be doing a great service to many who use PlanetMath =) It'd be much appreciated. Aaron Krowne From pgsql-performance-owner@postgresql.org Sun Mar 16 01:12:50 2003 X-Original-To: pgsql-performance@postgresql.org Received: from perrin.int.nxad.com (unknown [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id DBACA474E42 for ; Sun, 16 Mar 2003 01:12:48 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 5489521069; Sat, 15 Mar 2003 22:12:08 -0800 (PST) Date: Sat, 15 Mar 2003 22:12:08 -0800 From: Sean Chittenden To: Aaron Krowne Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030316061208.GA62529@perrin.int.nxad.com> References: <20030316060125.GD19570@vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030316060125.GD19570@vt.edu> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/100 X-Sequence-Number: 1398 > As the topic suggests, I am having fairly critical troubles with > postgresql on PlanetMath.org (a site which I run). You can go there and > try to pull up some entries and you will see the problem: everything is > incredibly slow. Have you read the following? http://developer.postgresql.org/docs/postgres/performance-tips.html > First: the machine. The machine is not too spectactular, but it is not > so bad that the performance currently witnessed should be happening. It > is a dual PIII-650 with 512MB of RAM and a 20gb IDE drive (yes, DMA is > on). There is plenty of free space on the drive. This shouldn't be an issue for the load you describe. A p-100 should be okay, but it depends on your queries that you're performing. > Now, the optimisations I have tried: *) Stick with btree's. > - I then tried increasing the machines shared memory max to 75% of the > physical memory, and scaled postgresql's buffers accordingly. This > also sped things up for a while, but again resulted in eventual > degeneration. Even worse, there were occasional crashes due to > running out of memory that (according to my calculations) shouldn't > have been happening. *) Don't do this, go back to near default levels. I bet this is hurting your setup. > - Lastly, I tried reducing the shared memory max and limiting postgresql > to more conservative values, although still not to the out-of-box > values. Right now shared memory max on the system is 128mb, > postgres's shared buffers are at 64mb, sort_mem is at 16mb, and > effective cache size is at 10mb. *) You shouldn't have to do this either. > For perspective, the size of the PlanetMath database dump is 24mb. > It should be able to fit in memory easily, so I'm not sure what I'm > doing wrong regarding the caching. I hate to say this, but this sounds like a config error. :-/ > For the most trivial request, Postgresql takes up basically all the > CPU for the duration of the request. The load average of the > machine is over-unity at all times, sometimes as bad as being the > 30's. None of this happens without postgres running, so it is > definitely the culprit. *) Send an EXPLAIN statement as specified here: http://developer.postgresql.org/docs/postgres/performance-tips.html#USING-EXPLAIN > The site averages about one hit every twenty seconds. This should not > be an overwhelming load, especially for what is just pulling up cached > information 99% of the time. *) Have you done a vacuum analyze? http://developer.postgresql.org/docs/postgres/populate.html#POPULATE-ANALYZE > Given this scenario, can anyone advise? I am particularly puzzled > as to why everything I tried initially helped, but always > degenerated rather rapidly to a near standstill. It seems to me > that everything should be able to be cached in memory with no > problem, perhaps I need to force this more explicitly. *) Send the EXPLAIN output and we can work from there. > My next step, if I cannot fix this, is to try mysql =( Bah, don't throw down the gauntlet, it's pretty clear this is a local issue and not a problem with the DB. :) -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Sun Mar 16 01:26:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 7C19C474E42 for ; Sun, 16 Mar 2003 01:26:33 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2G6QXub018636; Sun, 16 Mar 2003 01:26:33 -0500 (EST) To: Aaron Krowne Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-reply-to: <20030316060125.GD19570@vt.edu> References: <20030316060125.GD19570@vt.edu> Comments: In-reply-to Aaron Krowne message dated "Sun, 16 Mar 2003 01:01:25 -0500" Date: Sun, 16 Mar 2003 01:26:32 -0500 Message-ID: <18635.1047795992@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/101 X-Sequence-Number: 1399 Aaron Krowne writes: > As the topic suggests, I am having fairly critical troubles with > postgresql on PlanetMath.org (a site which I run). Um ... not meaning to insult your intelligence, but how often do you vacuum? Also, exactly what Postgres version are you running? Can you show us EXPLAIN ANALYZE results for some of the slow queries? regards, tom lane From pgsql-performance-owner@postgresql.org Sun Mar 16 01:39:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by postgresql.org (Postfix) with ESMTP id 0F72F474E42 for ; Sun, 16 Mar 2003 01:39:32 -0500 (EST) Received: from [192.168.5.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.4) with ESMTP-TLS id 1665493; Sat, 15 Mar 2003 23:15:30 -0800 Message-ID: <3E741B93.1090203@joeconway.com> Date: Sat, 15 Mar 2003 22:37:07 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Aaron Krowne Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org References: <20030316060125.GD19570@vt.edu> In-Reply-To: <20030316060125.GD19570@vt.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/102 X-Sequence-Number: 1400 Aaron Krowne wrote: > Given this scenario, can anyone advise? I am particularly puzzled as to > why everything I tried initially helped, but always degenerated rather > rapidly to a near standstill. It seems to me that everything should be > able to be cached in memory with no problem, perhaps I need to force > this more explicitly. Basic guidance: - Keep shared memory use reasonable; your final settings of 64M shared buffers and 16M sort_mem sound OK. In any case, be sure you're not disk-swapping. - If you don't already, run VACUUM ANALYZE on some regular schedule (how often depends on your data turnover rate) - Possibly consider running REINDEX periodically - Post the SQL and EXPLAIN ANALYZE output for the queries causing the worst of your woes to the list Explanations of these can be found by searching the list archives and reading the related sections of the manual. A few questions: - What version of Postgres? - Have you run VACUUM FULL ANALYZE lately (or at least VACUUM ANALYZE)? - Does the database see mostly SELECTs and INSERTs, or are there many UPDATEs and/or DELETEs too? - Are all queries slow, or particular ones? HTH, Joe From pgsql-performance-owner@postgresql.org Sun Mar 16 02:52:13 2003 X-Original-To: pgsql-performance@postgresql.org Received: from citidel1 (elaine.dlib.vt.edu [128.173.49.40]) by postgresql.org (Postfix) with ESMTP id E24CE474E42 for ; Sun, 16 Mar 2003 02:52:11 -0500 (EST) Received: from akrowne by citidel1 with local (Exim 3.34 #1 (Debian)) id 18uSwA-00035w-00; Sun, 16 Mar 2003 02:52:06 -0500 Date: Sun, 16 Mar 2003 02:52:06 -0500 From: Aaron Krowne To: Joe Conway Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030316075206.GE19570@vt.edu> Reply-To: Aaron Krowne References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E741B93.1090203@joeconway.com> User-Agent: Mutt/1.3.27i X-Archive-Number: 200303/103 X-Sequence-Number: 1401 > - Keep shared memory use reasonable; your final settings of 64M shared > buffers and 16M sort_mem sound OK. In any case, be sure you're not > disk-swapping. Yeah, those seem like reasonable values to me. But I am not sure I'm not disk-swapping, in fact it is almost certainly going on here bigtime. > - If you don't already, run VACUUM ANALYZE on some regular schedule > (how often depends on your data turnover rate) I've done it here and there, especially when things seem slow. Never seems to help much; the data turnover isn't high. > - Possibly consider running REINDEX periodically Ok thats a new one, I'll try that out. > - Post the SQL and EXPLAIN ANALYZE output for the queries causing the > worst of your woes to the list > - Are all queries slow, or particular ones? I'm grouping two separate things together to reply to, because the second point answers the first: there's really no single culprit. Every SELECT has a lag on the scale of a second; resolving all of the foreign keys in various tables to construct a typical data-rich page piles up many of these. I'm assuming the badness of this depends on how much swapping is going on. > Explanations of these can be found by searching the list archives and > reading the related sections of the manual. Will check that out, thanks. > A few questions: > - What version of Postgres? 7.2.1 > - Have you run VACUUM FULL ANALYZE lately (or at least VACUUM ANALYZE)? Yes, after a particularly bad slowdown... it didn't seem to fix things. > - Does the database see mostly SELECTs and INSERTs, or are there many > UPDATEs and/or DELETEs too? Almost exclusively SELECTs. OK, I have just run a VACUUM FULL ANALYZE and things seem much better... which would be the first time its really made a difference =) I tried comparing an EXPLAIN ANALYZE of a single row select on the main objects table before and after the vacuum, and the plan didn't change (sequential scan still), but the response time went from ~1 second to ~5msec! I'm not really sure what could have happened here behind-the-scenes since it didn't start using the index, and there probably weren't more than 10% updated/added rows since the last VACUUM. I actually thought I had a task scheduled which was running a VACUUM periodically, but maybe it broke for some reason or another. Still, I have not been getting consistent results from running VACUUMs, so I'm not entirely confident that the book is closed on the problem. Thanks for your help. apk From pgsql-performance-owner@postgresql.org Sun Mar 16 03:06:12 2003 X-Original-To: pgsql-performance@postgresql.org Received: from citidel1 (elaine.dlib.vt.edu [128.173.49.40]) by postgresql.org (Postfix) with ESMTP id AFB22474E42 for ; Sun, 16 Mar 2003 03:06:10 -0500 (EST) Received: from akrowne by citidel1 with local (Exim 3.34 #1 (Debian)) id 18uT9d-0003Vv-00; Sun, 16 Mar 2003 03:06:01 -0500 Date: Sun, 16 Mar 2003 03:06:01 -0500 From: Aaron Krowne To: Sean Chittenden Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030316080601.GF19570@vt.edu> Reply-To: Aaron Krowne References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030316061208.GA62529@perrin.int.nxad.com> User-Agent: Mutt/1.3.27i X-Archive-Number: 200303/104 X-Sequence-Number: 1402 > Have you read the following? > http://developer.postgresql.org/docs/postgres/performance-tips.html Yup. I would never go and bother real people without first checking the manual, but I bet you get a lot of that =) > This shouldn't be an issue for the load you describe. A p-100 should > be okay, but it depends on your queries that you're performing. Mostly just gather-retrieval based on unique identifier keys in a bunch of tables. Really mundane stuff. > *) Stick with btree's. Yeah, that saddens me, though =) When I initially switched to hashes, things were blazing. This application makes heavy use of keys and equal comparisons on indices, so hashes are really the optimal index structure. I'd like to be able to go back to using them some day... if not for the concurrency issue, which seems like it should be fixable (even having mutually exclusive locking on the entire index would probably be fine for this application and would prevent deadlock). > > - I then tried increasing the machines shared memory max to 75% of the > > physical memory, and scaled postgresql's buffers accordingly. This > *) Don't do this, go back to near default levels. I bet this is > hurting your setup. > > - Lastly, I tried reducing the shared memory max and limiting postgresql > > to more conservative values, although still not to the out-of-box > > values. Right now shared memory max on the system is 128mb, > > postgres's shared buffers are at 64mb, sort_mem is at 16mb, and > > effective cache size is at 10mb. > *) You shouldn't have to do this either. Well, I've now been advised that the best way is all 3 that I have tried (among aggressive buffering, moderate buffering, and default conservative buffering). Perhaps you could explain to me why the system shouldn't be ok with the moderate set of buffer sizes on a 512mb machine? I don't really know enough about the internals of postgres to be doing anything but voodoo when I change the values. > I hate to say this, but this sounds like a config error. :-/ Thats better than a hardware error! This is what I wanted to hear =) > *) Have you done a vacuum analyze? See previous message to list (summary: it worked this time, but usually it does not help.) Thanks, Aaron Krowne From pgsql-performance-owner@postgresql.org Sun Mar 16 03:21:06 2003 X-Original-To: pgsql-performance@postgresql.org Received: from perrin.int.nxad.com (unknown [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id D724D474E42 for ; Sun, 16 Mar 2003 03:21:03 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 34DBC2107E; Sun, 16 Mar 2003 00:20:24 -0800 (PST) Date: Sun, 16 Mar 2003 00:20:24 -0800 From: Sean Chittenden To: Aaron Krowne Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030316082024.GA66903@perrin.int.nxad.com> References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> <20030316080601.GF19570@vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030316080601.GF19570@vt.edu> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/105 X-Sequence-Number: 1403 > > > - Lastly, I tried reducing the shared memory max and limiting postgresql > > > to more conservative values, although still not to the out-of-box > > > values. Right now shared memory max on the system is 128mb, > > > postgres's shared buffers are at 64mb, sort_mem is at 16mb, and > > > effective cache size is at 10mb. > > *) You shouldn't have to do this either. > > Well, I've now been advised that the best way is all 3 that I have > tried (among aggressive buffering, moderate buffering, and default > conservative buffering). > > Perhaps you could explain to me why the system shouldn't be ok with > the moderate set of buffer sizes on a 512mb machine? I don't really > know enough about the internals of postgres to be doing anything but > voodoo when I change the values. Honestly? The defaults are small, but they're not small enough to give you the lousy performance you were describing. If your buffers are too high or there are enough things that are using up KVM/system memory... contention can cause thashing/swapping which it wasn't clear that you weren't having happen. Defaults shouldn't, under any non-embedded circumstance cause problems with machines >233Mhz, they're just too conservative to do any harm. :) > > *) Have you done a vacuum analyze? > > See previous message to list (summary: it worked this time, but > usually it does not help.) Hrmm... ENOTFREEBSD, eh? http://www.freebsd.org/cgi/cvsweb.cgi/ports/databases/postgresql7/files/502.pgsql?rev=1.5&content-type=text/x-cvsweb-markup You may want to setup a nightly vacuum/backup procedure. Palle Girgensohn has written a really nice and simple script that's been in use for ages on FreeBSD PostgreSQL installations for making sure that you don't have this problem. Actually, it'd be really cool to lobby to get this script added to the base PostgreSQL installation that way you wouldn't have this problem... it'd also dramatically increase the number of nightly backups performed for folks if a default script does this along with vacuuming. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Sun Mar 16 03:30:17 2003 X-Original-To: pgsql-performance@postgresql.org Received: from citidel1 (elaine.dlib.vt.edu [128.173.49.40]) by postgresql.org (Postfix) with ESMTP id D8D52475F0D for ; Sun, 16 Mar 2003 03:30:14 -0500 (EST) Received: from akrowne by citidel1 with local (Exim 3.34 #1 (Debian)) id 18uTX1-0003bB-00; Sun, 16 Mar 2003 03:30:11 -0500 Date: Sun, 16 Mar 2003 03:30:11 -0500 From: Aaron Krowne To: Sean Chittenden Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030316083011.GG19570@vt.edu> Reply-To: Aaron Krowne References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> <20030316080601.GF19570@vt.edu> <20030316082024.GA66903@perrin.int.nxad.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030316082024.GA66903@perrin.int.nxad.com> User-Agent: Mutt/1.3.27i X-Archive-Number: 200303/106 X-Sequence-Number: 1404 > You may want to setup a nightly vacuum/backup procedure. Palle > Girgensohn has written a really nice and simple > script that's been in use for ages on FreeBSD PostgreSQL installations > for making sure that you don't have this problem. > > Actually, it'd be really cool to lobby to get this script added to the > base PostgreSQL installation that way you wouldn't have this > problem... it'd also dramatically increase the number of nightly > backups performed for folks if a default script does this along with > vacuuming. -sc *Actually*, I just double checked, and I was not hallucinating: I *do* have a nightly vacuum script... because Debian postgres comes with it =) So, either it is broken, or doing a VACUUM FULL ANALYZE rather than just VACUUM ANALYZE made all the difference. Is this possible (the latter, we know the former is possible...)? apk From pgsql-performance-owner@postgresql.org Sun Mar 16 03:36:23 2003 X-Original-To: pgsql-performance@postgresql.org Received: from perrin.int.nxad.com (unknown [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id 580F0475AD4 for ; Sun, 16 Mar 2003 03:36:17 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id E1E702107E; Sun, 16 Mar 2003 00:35:37 -0800 (PST) Date: Sun, 16 Mar 2003 00:35:37 -0800 From: Sean Chittenden To: Aaron Krowne Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030316083537.GB66903@perrin.int.nxad.com> References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> <20030316080601.GF19570@vt.edu> <20030316082024.GA66903@perrin.int.nxad.com> <20030316083011.GG19570@vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030316083011.GG19570@vt.edu> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/107 X-Sequence-Number: 1405 > > You may want to setup a nightly vacuum/backup procedure. Palle > > Girgensohn has written a really nice and simple > > script that's been in use for ages on FreeBSD PostgreSQL installations > > for making sure that you don't have this problem. > > > > Actually, it'd be really cool to lobby to get this script added to the > > base PostgreSQL installation that way you wouldn't have this > > problem... it'd also dramatically increase the number of nightly > > backups performed for folks if a default script does this along with > > vacuuming. -sc > > *Actually*, I just double checked, and I was not hallucinating: I *do* > have a nightly vacuum script... because Debian postgres comes with it =) Cool, glad to hear other installations are picking up doing this. > So, either it is broken, or doing a VACUUM FULL ANALYZE rather than just > VACUUM ANALYZE made all the difference. Is this possible (the latter, > we know the former is possible...)? You shouldn't have to do a VACUUM FULL. Upgrade your PostgreSQL installation if you can (most recent if possible), there have been many performance updates and VACUUM fixes worth noting. Check the release notes starting with your version and read through them up to the current release... you'll be amazed at all the work that's been done, some of which it looks like may affect your installation. http://developer.postgresql.org/docs/postgres/release.html -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Sun Mar 16 03:37:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 79DC1475AE5 for ; Sun, 16 Mar 2003 03:37:32 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2G8bWub019395; Sun, 16 Mar 2003 03:37:32 -0500 (EST) To: Aaron Krowne Cc: Sean Chittenden , pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-reply-to: <20030316083011.GG19570@vt.edu> References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> <20030316080601.GF19570@vt.edu> <20030316082024.GA66903@perrin.int.nxad.com> <20030316083011.GG19570@vt.edu> Comments: In-reply-to Aaron Krowne message dated "Sun, 16 Mar 2003 03:30:11 -0500" Date: Sun, 16 Mar 2003 03:37:32 -0500 Message-ID: <19394.1047803852@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/108 X-Sequence-Number: 1406 Aaron Krowne writes: > So, either it is broken, or doing a VACUUM FULL ANALYZE rather than just > VACUUM ANALYZE made all the difference. Is this possible (the latter, > we know the former is possible...)? If your FSM parameters in postgresql.conf are too small, then plain vacuums might have failed to keep up with the available free space, leading to a situation where vacuum full is essential. Did you happen to notice whether the vacuum full shrunk the database's disk footprint noticeably? regards, tom lane From pgsql-performance-owner@postgresql.org Sun Mar 16 06:31:29 2003 X-Original-To: pgsql-performance@postgresql.org Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by postgresql.org (Postfix) with ESMTP id 44F16474E42 for ; Sun, 16 Mar 2003 06:31:26 -0500 (EST) Received: from [192.168.5.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.4) with ESMTP-TLS id 1665605; Sun, 16 Mar 2003 04:07:37 -0800 Message-ID: <3E74600A.8050902@joeconway.com> Date: Sun, 16 Mar 2003 03:29:14 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Aaron Krowne Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> In-Reply-To: <20030316075206.GE19570@vt.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/109 X-Sequence-Number: 1407 Aaron Krowne wrote: >>- What version of Postgres? > 7.2.1 You should definitely look at upgrading, at least to 7.2.4 (which you can do without requiring a dump/reload cycle), but better yet to 7.3.2 (which will require a dump/reload cycle). I don't know that will fix you specific issue, but there were some critical bug fixes between 7.2.1 and 7.2.4. >>- Does the database see mostly SELECTs and INSERTs, or are there many >> UPDATEs and/or DELETEs too? > > Almost exclusively SELECTs. > > OK, I have just run a VACUUM FULL ANALYZE and things seem much better... Hmmm, do you periodically do large updates or otherwise turn over rows in batches? > which would be the first time its really made a difference =) I tried > comparing an EXPLAIN ANALYZE of a single row select on the main objects > table before and after the vacuum, and the plan didn't change > (sequential scan still), but the response time went from ~1 second to > ~5msec! I'm not really sure what could have happened here > behind-the-scenes since it didn't start using the index, and there > probably weren't more than 10% updated/added rows since the last VACUUM. If your app is mostly doing equi-lookups by primary key, and indexes aren't being used (I think I saw you mention that on another post), then something else is still wrong. Please pick one or two typical queries that are doing seq scans and post the related table definitions, indexes, SQL, and EXPLAIN ANALYZE. I'd bet you are getting bitten by a datatype mismatch or something. Joe From pgsql-performance-owner@postgresql.org Sun Mar 16 21:08:27 2003 X-Original-To: pgsql-performance@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id 4D8B4475B47 for ; Sun, 16 Mar 2003 21:08:24 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h2H28RL21189 for pgsql-performance@postgresql.org; Mon, 17 Mar 2003 10:08:27 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h2H28C721094; Mon, 17 Mar 2003 10:08:14 +0800 (WST) Message-ID: <021301c2ec2a$10cfca70$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: "Aaron Krowne" , Cc: References: <20030316060125.GD19570@vt.edu> Subject: Re: postgresql meltdown on PlanetMath.org Date: Mon, 17 Mar 2003 10:08:10 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/110 X-Sequence-Number: 1408 > - Lastly, I tried reducing the shared memory max and limiting postgresql > to more conservative values, although still not to the out-of-box > values. Right now shared memory max on the system is 128mb, > postgres's shared buffers are at 64mb, sort_mem is at 16mb, and > effective cache size is at 10mb. I found that 5000 shared buffers was best performance on my system. However, your problems are probably due to maybe not running vacuum, analyze, reindex, etc. Your queries may not be effectively indexed - EXPLAIN ANALYZE them all. Chris From pgsql-performance-owner@postgresql.org Mon Mar 17 01:10:19 2003 X-Original-To: pgsql-performance@postgresql.org Received: from perrin.int.nxad.com (unknown [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id 73F78474E53 for ; Mon, 17 Mar 2003 01:10:17 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 431AF20F01; Sun, 16 Mar 2003 22:10:11 -0800 (PST) Date: Sun, 16 Mar 2003 22:10:11 -0800 From: Sean Chittenden To: Logan Bowers Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030317061011.GH23355@perrin.int.nxad.com> References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/112 X-Sequence-Number: 1410 > I don't know what your definition of "high" is, but I do find that > turnover can degrade performance over time. Perhaps one of the devs > can enlighten me, but I have a database that turns over ~100,000 > rows/day that does appear to slowly get worse. The updates are done > in batches and I "VACUUM" and "VACUUM ANALYZE" after each batch > (three/day) but I found that over time simple queries would start to > hit the disk more and more. Creeping index syndrome. Tom recently fixed this in HEAD. Try the latest copy from the repo and see if this solves your problems. > A "select count(*) FROM tblwordidx" initially took about 1 second to > return a count of 2 million but after a few months it took several > minutes of really hard HDD grinding. That's because there are dead entries in the index that weren't being reused or cleaned up. As I said, this has been fixed. -sc PS It's good to see you around again. :) -- Sean Chittenden From pgsql-performance-owner@postgresql.org Mon Mar 17 01:05:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from neo.magick.org (bowerslc-2.student.rose-hulman.edu [137.112.146.57]) by postgresql.org (Postfix) with ESMTP id EF018474E53 for ; Mon, 17 Mar 2003 01:05:35 -0500 (EST) Received: from neo.magick.org (logan@localhost [127.0.0.1]) by neo.magick.org (8.12.7/8.12.7) with ESMTP id h2H6Cahn014783 for ; Mon, 17 Mar 2003 01:12:36 -0500 Received: from localhost (logan@localhost) by neo.magick.org (8.12.8/8.12.8/Submit) with ESMTP id h2H6CZFg014780 for ; Mon, 17 Mar 2003 01:12:35 -0500 X-Authentication-Warning: neo.magick.org: logan owned process doing -bs Date: Mon, 17 Mar 2003 01:12:34 -0500 (EST) From: Logan Bowers X-X-Sender: logan@neo.magick.org Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-Reply-To: <20030316075206.GE19570@vt.edu> Message-ID: References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200303/111 X-Sequence-Number: 1409 I don't know what your definition of "high" is, but I do find that turnover can degrade performance over time. Perhaps one of the devs can enlighten me, but I have a database that turns over ~100,000 rows/day that does appear to slowly get worse. The updates are done in batches and I "VACUUM" and "VACUUM ANALYZE" after each batch (three/day) but I found that over time simple queries would start to hit the disk more and more. A "select count(*) FROM tblwordidx" initially took about 1 second to return a count of 2 million but after a few months it took several minutes of really hard HDD grinding. Also, the database only had a couple hundred megs of data in it, but the db was taking up 8-9 GB of disk space. I'm thinking data fragmentation is ruining cache performance? When I did a dump restore and updated from 7.2.1 to 7.3.1 queries were zippy again. But, now it is starting to slow... I have yet to measure the effects of a VACUUM FULL, however. I'll try it an report back... Logan Bowers On Sun, 16 Mar 2003, Aaron Krowne wrote: > I've done it here and there, especially when things seem slow. Never > seems to help much; the data turnover isn't high. > From pgsql-performance-owner@postgresql.org Mon Mar 17 01:19:00 2003 X-Original-To: pgsql-performance@postgresql.org Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 95CF5475FD9 for ; Mon, 17 Mar 2003 01:18:59 -0500 (EST) Received: from samurai.com (localhost [127.0.0.1]) by bob.samurai.com (Postfix) with SMTP id 4DBFA1D60; Mon, 17 Mar 2003 01:18:59 -0500 (EST) Received: from du150.n224.resnet.queensu.ca ([130.15.224.150]) (SquirrelMail authenticated user neilc) by mailbox.samurai.com with HTTP; Mon, 17 Mar 2003 01:18:59 -0500 (EST) Message-ID: <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> Date: Mon, 17 Mar 2003 01:18:59 -0500 (EST) Subject: Re: postgresql meltdown on PlanetMath.org From: "Neil Conway" To: In-Reply-To: <20030317061011.GH23355@perrin.int.nxad.com> References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> <20030317061011.GH23355@perrin.int.nxad.com> X-Priority: 3 Importance: Normal Cc: , X-Mailer: SquirrelMail (version 1.2.11) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200303/113 X-Sequence-Number: 1411 Sean Chittenden said: >> A "select count(*) FROM tblwordidx" initially took about 1 second to >> return a count of 2 million but after a few months it took several >> minutes of really hard HDD grinding. > > That's because there are dead entries in the index that weren't being > reused or cleaned up. As I said, this has been fixed. That's doubtful: "select count(*) FROM foo" won't use an index. There are a bunch of other factors (e.g. dead heap tuples, changes in the pages cached in the buffer, disk fragmentation, etc.) that could effect performance in that situation, however. Cheers, Neil From pgsql-performance-owner@postgresql.org Mon Mar 17 01:29:31 2003 X-Original-To: pgsql-performance@postgresql.org Received: from perrin.int.nxad.com (unknown [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id 6510D474E53 for ; Mon, 17 Mar 2003 01:29:30 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id 425E62106B; Sun, 16 Mar 2003 22:29:29 -0800 (PST) Date: Sun, 16 Mar 2003 22:29:29 -0800 From: Sean Chittenden To: Neil Conway Cc: logan@datacurrent.com, pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030317062929.GI23355@perrin.int.nxad.com> References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> <20030317061011.GH23355@perrin.int.nxad.com> <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ X-Archive-Number: 200303/114 X-Sequence-Number: 1412 > >> A "select count(*) FROM tblwordidx" initially took about 1 second to > >> return a count of 2 million but after a few months it took several > >> minutes of really hard HDD grinding. > > > > That's because there are dead entries in the index that weren't being > > reused or cleaned up. As I said, this has been fixed. > > That's doubtful: "select count(*) FROM foo" won't use an > index. There are a bunch of other factors (e.g. dead heap tuples, > changes in the pages cached in the buffer, disk fragmentation, etc.) > that could effect performance in that situation, however. *blush* Yeah, jumped the gun on that when I read that queries were getting slower (churn of an index == slow creaping death for performance). A SELECT COUNT(*), however, wouldn't be affected by the index growth problem. Is the COUNT() on a view that uses an index? I haven't had any real problems with this kind of degredation outside of indexes. :-/ -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Mon Mar 17 01:34:29 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8D48A474E53 for ; Mon, 17 Mar 2003 01:34:27 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2H6YLub000496; Mon, 17 Mar 2003 01:34:21 -0500 (EST) To: "Neil Conway" Cc: sean@chittenden.org, logan@datacurrent.com, pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-reply-to: <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> <20030317061011.GH23355@perrin.int.nxad.com> <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> Comments: In-reply-to "Neil Conway" message dated "Mon, 17 Mar 2003 01:18:59 -0500" Date: Mon, 17 Mar 2003 01:34:20 -0500 Message-ID: <495.1047882860@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/115 X-Sequence-Number: 1413 "Neil Conway" writes: > Sean Chittenden said: > A "select count(*) FROM tblwordidx" initially took about 1 second to > return a count of 2 million but after a few months it took several > minutes of really hard HDD grinding. >> >> That's because there are dead entries in the index that weren't being >> reused or cleaned up. As I said, this has been fixed. > That's doubtful: "select count(*) FROM foo" won't use an index. To know what's going on, as opposed to guessing about it, we'd need to know something about the physical sizes of the table and its indexes. "vacuum verbose" output would be instructive... But my best theorizing-in-advance-of-the-data guess is that Logan's FSM settings are too small, causing free space to be leaked over time. If a vacuum full restores the original performance then that's probably the right answer. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 17 10:58:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id 45EBF475EDF for ; Mon, 17 Mar 2003 10:58:44 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id 580B6137FC9; Mon, 17 Mar 2003 10:58:42 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18ux0Z-0000Fc-00; Mon, 17 Mar 2003 10:58:40 -0500 To: Tom Lane Cc: Aaron Krowne , Sean Chittenden , pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> <20030316080601.GF19570@vt.edu> <20030316082024.GA66903@perrin.int.nxad.com> <20030316083011.GG19570@vt.edu> <19394.1047803852@sss.pgh.pa.us> In-Reply-To: <19394.1047803852@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 17 Mar 2003 10:58:39 -0500 Message-ID: <87hea2assw.fsf@stark.dyndns.tv> Lines: 22 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200303/116 X-Sequence-Number: 1414 Tom Lane writes: > Aaron Krowne writes: > > So, either it is broken, or doing a VACUUM FULL ANALYZE rather than just > > VACUUM ANALYZE made all the difference. Is this possible (the latter, > > we know the former is possible...)? > > If your FSM parameters in postgresql.conf are too small, then plain > vacuums might have failed to keep up with the available free space, > leading to a situation where vacuum full is essential. Did you happen > to notice whether the vacuum full shrunk the database's disk footprint > noticeably? This seems to be a frequent problem. Is there any easy way to check an existing table for lost free space? Is there any way vauum could do this check and print a warning suggesting using vaccuum full and/or increasing fsm parameters if it finds such? -- greg From pgsql-performance-owner@postgresql.org Mon Mar 17 11:11:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B42A5475FEE for ; Mon, 17 Mar 2003 11:11:02 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2HGB5ub006662; Mon, 17 Mar 2003 11:11:05 -0500 (EST) To: Greg Stark Cc: Aaron Krowne , Sean Chittenden , pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-reply-to: <87hea2assw.fsf@stark.dyndns.tv> References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> <20030316080601.GF19570@vt.edu> <20030316082024.GA66903@perrin.int.nxad.com> <20030316083011.GG19570@vt.edu> <19394.1047803852@sss.pgh.pa.us> <87hea2assw.fsf@stark.dyndns.tv> Comments: In-reply-to Greg Stark message dated "17 Mar 2003 10:58:39 -0500" Date: Mon, 17 Mar 2003 11:11:05 -0500 Message-ID: <6661.1047917465@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/117 X-Sequence-Number: 1415 Greg Stark writes: > Is there any easy way to check an existing table for lost free space? contrib/pgstattuple gives a pretty good set of statistics. (I thought VACUUM VERBOSE printed something about total free space in a table, but apparently only VACUUM FULL VERBOSE does. Maybe should change that.) > Is there any way vauum could do this check and print a warning suggesting > using vaccuum full and/or increasing fsm parameters if it finds such? In CVS tip, a whole-database VACUUM VERBOSE gives info about the free space map occupancy, eg INFO: Free space map: 224 relations, 450 pages stored; 3776 total pages needed. Allocated FSM size: 1000 relations + 20000 pages = 178 KB shared mem. If the "pages needed" number is drastically larger than the allocated FSM size, you've got a problem. (I don't think you need to panic if it's just a little larger, though. 10X bigger would be time to do something, 2X bigger maybe not.) regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 17 12:12:32 2003 X-Original-To: pgsql-performance@postgresql.org Received: from irko.smoothcorp.com (unknown [208.49.241.41]) by postgresql.org (Postfix) with ESMTP id 01301475E91 for ; Mon, 17 Mar 2003 12:12:31 -0500 (EST) Received: from taurus.ifloor.com ([10.0.1.20] helo=taurus.smoothcorp.com) by irko.smoothcorp.com with esmtp (Exim 4.12) id 18uyA7-0006yx-00 for pgsql-performance@postgresql.org; Mon, 17 Mar 2003 09:12:35 -0800 Received: from localhost (chris@localhost) by taurus.smoothcorp.com (8.11.6/8.11.6) with ESMTP id h2HHCWu07755 for ; Mon, 17 Mar 2003 09:12:32 -0800 X-Authentication-Warning: taurus.smoothcorp.com: chris owned process doing -bs Date: Mon, 17 Mar 2003 09:12:32 -0800 (PST) From: Chris Sutton To: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-Reply-To: <6661.1047917465@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SA-Exim-Rcpt-To: pgsql-performance@postgresql.org X-SA-Exim-Scanned: No; SAEximRunCond expanded to false X-Archive-Number: 200303/118 X-Sequence-Number: 1416 On Mon, 17 Mar 2003, Tom Lane wrote: > In CVS tip, a whole-database VACUUM VERBOSE gives info about the free > space map occupancy, eg > > INFO: Free space map: 224 relations, 450 pages stored; 3776 total pages needed. > Allocated FSM size: 1000 relations + 20000 pages = 178 KB shared mem. > How do you get this information? I just ran VACUUM VERBOSE and it spit out a bunch of information per relation, but nothing about total relations and FSM space. We are running 7.3.2. Chris From pgsql-performance-owner@postgresql.org Mon Mar 17 12:38:41 2003 X-Original-To: Pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 98B6A475E91 for ; Mon, 17 Mar 2003 12:38:39 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2906058 for Pgsql-performance@postgresql.org; Mon, 17 Mar 2003 09:38:33 -0800 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Organization: Aglio Database Solutions To: Pgsql-performance@postgresql.org Subject: Performance on large data transformations Date: Mon, 17 Mar 2003 09:38:38 -0800 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200303170938.38365.josh@agliodbs.com> X-Archive-Number: 200303/119 X-Sequence-Number: 1417 Folks, On one database, I have an overnight data transformation procedure that goes like: TableA has about 125,000 records. Begin Transaction: 1) Update 80% of records in TableA 2) Update 10% of records in TableA 3) Update 65% of records in TableA 4) Update 55% of records in TableA 5) Update 15% or records in TableA with references to other records in TableA 6) Flag what hasn't been updated. Commit I've found that, no matter what my FSM settings (I've gone as high as 1,000,000) by the time I reach step 4 execution has slowed down considerably, and for step 5 it takes the server more than 10 minutes to complete the update statement. During this period, CPU, RAM and disk I/O are almost idle ... the system seems to spend all of its time doing lengthy seeks. There is, for that matter, no kernel swap activity, but I'm not sure how to measure Postgres temp file activity. (FYI: Dual Athalon 1600mhz/1gb/Hardware Raid 1 with xlog on seperate SCSI drive/Red Hat Linux 8.0/PostgreSQL 7.2.4) The only way around this I've found is to break up the above into seperate transactions with VACUUMs in between, and "simulate" a transaction by making a back-up copy of the table and restoring from it if something goes wrong. I've tried enough different methods to be reasonably certain that there is no way around this in 7.2.4. The reason I bring this up is that PostgreSQL's dramatic plunge in performance in large serial updates is really problematic for us in the OLAP database market, where large data transformations, as well as extensive use of calculated temporary tables, is common. I was particularly distressed when I had to tell a client considering switching from MSSQL to Postgres for an OLAP database that they might just be trading one set of problems for another. Is there any way we can improve on this kind of operation in future versions of PostgreSQL? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Mar 17 13:33:38 2003 X-Original-To: pgsql-performance@postgresql.org Received: from cat (adsl-66-123-169-52.dsl.sntc01.pacbell.net [66.123.169.52]) by postgresql.org (Postfix) with ESMTP id 5EB2F475FD9 for ; Mon, 17 Mar 2003 13:33:29 -0500 (EST) Received: by cat (Postfix, from userid 501) id 95758B6D69; Mon, 17 Mar 2003 10:33:27 -0800 (PST) Date: Mon, 17 Mar 2003 10:33:27 -0800 From: Max Baker To: Tom Lane Cc: Aaron Krowne , Sean Chittenden , pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030317183327.GC25487@warped.org> References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> <20030316080601.GF19570@vt.edu> <20030316082024.GA66903@perrin.int.nxad.com> <20030316083011.GG19570@vt.edu> <19394.1047803852@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19394.1047803852@sss.pgh.pa.us> User-Agent: Mutt/1.5.3i X-Archive-Number: 200303/120 X-Sequence-Number: 1418 On Sun, Mar 16, 2003 at 03:37:32AM -0500, Tom Lane wrote: > Aaron Krowne writes: > > So, either it is broken, or doing a VACUUM FULL ANALYZE rather than just > > VACUUM ANALYZE made all the difference. Is this possible (the latter, > > we know the former is possible...)? > > If your FSM parameters in postgresql.conf are too small, then plain > vacuums might have failed to keep up with the available free space, > leading to a situation where vacuum full is essential. Did you happen > to notice whether the vacuum full shrunk the database's disk footprint > noticeably? I was having a similar problem a couple threads ago, and a VACUUM FULL reduced my database from 3.9 gigs to 2.1 gigs ! So my question is how to (smartly) choose an FSM size? thanks, max` From pgsql-performance-owner@postgresql.org Mon Mar 17 14:20:12 2003 X-Original-To: pgsql-performance@postgresql.org Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 10FF1475AE5 for ; Mon, 17 Mar 2003 14:20:10 -0500 (EST) Received: from samurai.com (localhost [127.0.0.1]) by bob.samurai.com (Postfix) with SMTP id 491D61D97; Mon, 17 Mar 2003 14:20:10 -0500 (EST) Received: from du150.n224.resnet.queensu.ca ([130.15.224.150]) (SquirrelMail authenticated user neilc) by mailbox.samurai.com with HTTP; Mon, 17 Mar 2003 14:20:10 -0500 (EST) Message-ID: <34144.130.15.224.150.1047928810.squirrel@mailbox.samurai.com> Date: Mon, 17 Mar 2003 14:20:10 -0500 (EST) Subject: Re: postgresql meltdown on PlanetMath.org From: "Neil Conway" To: In-Reply-To: References: <6661.1047917465@sss.pgh.pa.us> X-Priority: 3 Importance: Normal Cc: X-Mailer: SquirrelMail (version 1.2.11) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200303/121 X-Sequence-Number: 1419 Chris Sutton said: > On Mon, 17 Mar 2003, Tom Lane wrote: >> In CVS tip, a whole-database VACUUM VERBOSE gives info about the free >> space map occupancy, eg > How do you get this information? > > I just ran VACUUM VERBOSE and it spit out a bunch of information per > relation, but nothing about total relations and FSM space. We are > running 7.3.2. As Tom mentioned, that information is printed by a database-wide VACUUM VERBOSE "in CVS tip" -- i.e. in the development code that will eventually become PostgreSQL 7.4 Cheers, Neil From pgsql-performance-owner@postgresql.org Mon Mar 17 14:26:02 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id EB8CC475F09 for ; Mon, 17 Mar 2003 14:26:00 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2HJQ0ub007700; Mon, 17 Mar 2003 14:26:01 -0500 (EST) To: Chris Sutton Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-reply-to: References: Comments: In-reply-to Chris Sutton message dated "Mon, 17 Mar 2003 09:12:32 -0800" Date: Mon, 17 Mar 2003 14:26:00 -0500 Message-ID: <7699.1047929160@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/122 X-Sequence-Number: 1420 Chris Sutton writes: > On Mon, 17 Mar 2003, Tom Lane wrote: >> In CVS tip, a whole-database VACUUM VERBOSE gives info about the free >> space map occupancy, eg >> INFO: Free space map: 224 relations, 450 pages stored; 3776 total pages needed. >> Allocated FSM size: 1000 relations + 20000 pages = 178 KB shared mem. > How do you get this information? Before CVS tip, you don't. [ thinks...] Perhaps we could back-port the FSM changes into 7.3 ... it would be a larger change than I'd usually consider reasonable for a stable branch, though. Particularly considering that it would be hard to call it a bug fix. By any sane definition this is a new feature, and we have a policy against putting new features in stable branches. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 17 14:47:40 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 3DF60475FD9 for ; Mon, 17 Mar 2003 14:47:38 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18v0aA-0005pn-00 for ; Mon, 17 Mar 2003 14:47:38 -0500 Date: Mon, 17 Mar 2003 14:47:38 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030317144738.O3789@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <7699.1047929160@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <7699.1047929160@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Mon, Mar 17, 2003 at 02:26:00PM -0500 X-Archive-Number: 200303/123 X-Sequence-Number: 1421 On Mon, Mar 17, 2003 at 02:26:00PM -0500, Tom Lane wrote: > [ thinks...] Perhaps we could back-port the FSM changes into 7.3 ... For what it's worth, I think that'd be a terrible precedent. Perhaps making a patch file akin to what the Postgres-R folks do, for people who really want it. But there is just no way it's a bug fix, and one of the things I _really really_ like about Postgres is the way "stable" means stable. Introducing such a new feature to 7.3.x now smacks to me of the direction the Linux kernal has gone, where major new funcitonality gets "merged"[1] in dot-releases of the so-called stable version. [1] This is the meaning of "merge" also used in Toronto on the 401 at rush hour. 8 lanes of traffic jam and growing. -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Mon Mar 17 15:14:58 2003 X-Original-To: Pgsql-performance@postgresql.org Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id 724A7475E91 for ; Mon, 17 Mar 2003 15:14:56 -0500 (EST) Received: from ronpc [63.68.5.2] by torque.intervideoinc.com (SMTPD32-5.05) id A16640B0082; Mon, 17 Mar 2003 12:34:46 -0800 From: "Ron Mayer" To: "Josh Berkus" , Cc: Subject: Re: Performance on large data transformations Date: Mon, 17 Mar 2003 12:06:39 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 In-Reply-To: <200303170938.38365.josh@agliodbs.com> Importance: Normal X-Archive-Number: 200303/124 X-Sequence-Number: 1422 Josh Berkus wrote: > >There is, for that matter, no kernel swap activity, but I'm not >sure how to measure Postgres temp file activity. Of course you could: mv /wherever/data/base/16556/pgsql_tmp /some_other_disk/ ln -s /some_other_disk/pgsql_tmp /wherever/data/base/16556 and use "iostat" from the "systat" package to watch how much you're using the disk the temp directory's on. In fact, for OLAP stuff I've had this help performance because quite a few data warehousing operations look like: First read from main database, do a big hash-or-sort, (which gets written to pgsql_tmp), then read from this temporary table and write result to main database PS: Yes, I know this doesn't help the FSM stuff you asked about. Ron From pgsql-performance-owner@postgresql.org Mon Mar 17 15:46:07 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 55C22474E53 for ; Mon, 17 Mar 2003 15:46:06 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2HKk6ub008238; Mon, 17 Mar 2003 15:46:06 -0500 (EST) To: Andrew Sullivan Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-reply-to: <20030317144738.O3789@mail.libertyrms.com> References: <7699.1047929160@sss.pgh.pa.us> <20030317144738.O3789@mail.libertyrms.com> Comments: In-reply-to Andrew Sullivan message dated "Mon, 17 Mar 2003 14:47:38 -0500" Date: Mon, 17 Mar 2003 15:46:06 -0500 Message-ID: <8237.1047933966@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/125 X-Sequence-Number: 1423 Andrew Sullivan writes: > On Mon, Mar 17, 2003 at 02:26:00PM -0500, Tom Lane wrote: >> [ thinks...] Perhaps we could back-port the FSM changes into 7.3 ... > For what it's worth, I think that'd be a terrible precedent. Oh, I quite agree. I was just throwing up the option to see if anyone thought the issue was important enough to take risks for. I do not... regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 17 17:46:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from hotmail.com (bay1-f104.bay1.hotmail.com [65.54.245.104]) by postgresql.org (Postfix) with ESMTP id 7EA64475461 for ; Mon, 17 Mar 2003 17:46:28 -0500 (EST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 17 Mar 2003 14:46:30 -0800 Received: from 205.229.142.209 by by1fd.bay1.hotmail.msn.com with HTTP; Mon, 17 Mar 2003 22:46:30 GMT X-Originating-IP: [205.229.142.209] From: "Kendrick C. Wilson" To: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Date: Mon, 17 Mar 2003 16:46:30 -0600 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 17 Mar 2003 22:46:30.0558 (UTC) FILETIME=[0D54CBE0:01C2ECD7] X-Archive-Number: 200303/126 X-Sequence-Number: 1424 What is the structure of you table? Is the data types in the table the same as in the SQL.... Did you create the index after the loading the table? cluster the table around the most used index.... Is you web site on the same box you database is on? telnet www.planetmath.org 5432 oh, $hit... never mind........ If you have another box, please put the database on it. The web server maybe killing the database but this depends on the amount of traffic. and block the port......... How fast is you hard drive? 5400rpm :S, k=n^r/ck, SCJP _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus From pgsql-performance-owner@postgresql.org Mon Mar 17 18:14:52 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sccrmhc02.attbi.com (sccrmhc02.attbi.com [204.127.202.62]) by postgresql.org (Postfix) with ESMTP id 8314E475461 for ; Mon, 17 Mar 2003 18:14:51 -0500 (EST) Received: from ladamski (12-236-241-34.client.attbi.com[12.236.241.34]) by sccrmhc02.attbi.com (sccrmhc02) with SMTP id <2003031723145300200rpt5le>; Mon, 17 Mar 2003 23:14:53 +0000 From: "Lucas Adamski" To: "'Kendrick C. Wilson'" , Subject: Re: postgresql meltdown on PlanetMath.org Date: Mon, 17 Mar 2003 15:15:04 -0800 Message-ID: <000e01c2ecdb$0bafd1a0$0200a8c0@LADAMSKI> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 In-Reply-To: X-Archive-Number: 200303/127 X-Sequence-Number: 1425 Or at least restrict TCP/IP connections from localhost only, and use SSH tunnels if you must have direct external access (for pgAdmin, etc.) to the DB. Lucas. -----Original Message----- From: Kendrick C. Wilson [mailto:kendrick_wilson@hotmail.com] Sent: Monday, March 17, 2003 2:47 PM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] postgresql meltdown on PlanetMath.org What is the structure of you table? Is the data types in the table the same as in the SQL.... Did you create the index after the loading the table? cluster the table around the most used index.... Is you web site on the same box you database is on? telnet www.planetmath.org 5432 oh, $hit... never mind........ If you have another box, please put the database on it. The web server maybe killing the database but this depends on the amount of traffic. and block the port......... How fast is you hard drive? 5400rpm :S, k=n^r/ck, SCJP _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus ---------------------------(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 Mon Mar 17 20:34:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id A55E5475F09 for ; Mon, 17 Mar 2003 20:34:33 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h2I1Yac95711 for pgsql-performance@postgresql.org; Tue, 18 Mar 2003 09:34:36 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h2I1YW795594; Tue, 18 Mar 2003 09:34:32 +0800 (WST) Message-ID: <07b501c2ecee$8917b8c0$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: "Kendrick C. Wilson" , References: Subject: Re: postgresql meltdown on PlanetMath.org Date: Tue, 18 Mar 2003 09:34:36 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/128 X-Sequence-Number: 1426 > What is the structure of you table? > Is the data types in the table the same as in the SQL.... > > Did you create the index after the loading the table? > cluster the table around the most used index.... There is no point clustering a table around the most used index, unless access to the index is non-random. eg. you are picking up more than one consecutive entry from the index at a time. eg. Indexes on foreign keys are excellent for clustering. Chris From pgsql-performance-owner@postgresql.org Mon Mar 17 21:31:42 2003 X-Original-To: pgsql-performance@postgresql.org Received: from citidel1 (elaine.dlib.vt.edu [128.173.49.40]) by postgresql.org (Postfix) with ESMTP id 98B334762E0 for ; Mon, 17 Mar 2003 21:31:40 -0500 (EST) Received: from akrowne by citidel1 with local (Exim 3.34 #1 (Debian)) id 18v6ss-0001ef-00; Mon, 17 Mar 2003 21:31:22 -0500 Date: Mon, 17 Mar 2003 21:31:22 -0500 From: Aaron Krowne To: Tom Lane Cc: Sean Chittenden , pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Message-ID: <20030318023122.GN3703@vt.edu> Reply-To: Aaron Krowne References: <20030316060125.GD19570@vt.edu> <20030316061208.GA62529@perrin.int.nxad.com> <20030316080601.GF19570@vt.edu> <20030316082024.GA66903@perrin.int.nxad.com> <20030316083011.GG19570@vt.edu> <19394.1047803852@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19394.1047803852@sss.pgh.pa.us> User-Agent: Mutt/1.3.27i X-Archive-Number: 200303/129 X-Sequence-Number: 1427 I should have paid more attention to the disk space before... but it looks like somewhere between half a gig and a gig was freed! The disk footprint is about a gig now. Aaron Krowne On Sun, Mar 16, 2003 at 03:37:32AM -0500, Tom Lane wrote: > Aaron Krowne writes: > > So, either it is broken, or doing a VACUUM FULL ANALYZE rather than just > > VACUUM ANALYZE made all the difference. Is this possible (the latter, > > we know the former is possible...)? > > If your FSM parameters in postgresql.conf are too small, then plain > vacuums might have failed to keep up with the available free space, > leading to a situation where vacuum full is essential. Did you happen > to notice whether the vacuum full shrunk the database's disk footprint > noticeably? > > regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 17 21:34:02 2003 X-Original-To: pgsql-performance@postgresql.org Received: from neo.magick.org (bowerslc-2.student.rose-hulman.edu [137.112.146.57]) by postgresql.org (Postfix) with ESMTP id 7A247475461 for ; Mon, 17 Mar 2003 21:34:00 -0500 (EST) Received: from neo.magick.org (logan@localhost [127.0.0.1]) by neo.magick.org (8.12.7/8.12.7) with ESMTP id h2I2f8hn022359; Mon, 17 Mar 2003 21:41:08 -0500 Received: from localhost (logan@localhost) by neo.magick.org (8.12.8/8.12.8/Submit) with ESMTP id h2I2f8Nl022356; Mon, 17 Mar 2003 21:41:08 -0500 X-Authentication-Warning: neo.magick.org: logan owned process doing -bs Date: Mon, 17 Mar 2003 21:41:07 -0500 (EST) From: Logan Bowers X-X-Sender: logan@neo.magick.org To: Tom Lane Cc: Neil Conway , sean@chittenden.org, pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-Reply-To: <495.1047882860@sss.pgh.pa.us> Message-ID: References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> <20030317061011.GH23355@perrin.int.nxad.com> <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> <495.1047882860@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="1888041362-380975398-1047955267=:8636" X-Archive-Number: 200303/130 X-Sequence-Number: 1428 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --1888041362-380975398-1047955267=:8636 Content-Type: TEXT/PLAIN; charset=US-ASCII All right, I performed a VACUUM FULL last night and after about 3 hours I tried running a select count(*) FROM tblwordidx and that did help things considerably (it runs in ~20 seconds instead of 1-2 minutes). Not as good as originally, but close. But, here's the breakdown of the db: I'm using the database as a keyword based file search engine (not the most efficient method, I know, but it works well for my purposes). The biggest and most relevant tables are a table of files and of words. The basic operation that each file has a set of keywords associated with it, I do a whole word search on tblwordidx and join with tblfiles (I know, the naming scheme sucks, sorry!). Three times a day I scan the network and update the database. I insert about 180,000 rows into a temporary table and then use it to update temporary table (tbltmp). With the aid of a few other tables, I clean up tblFiles so that existing rows have an updated timestamp in tblseen and files with a timestamp older than 1 day are removed. Then, I take the new rows in tblfiles and use a perl script to add more words to tblwordidx. After each update a do a VACUUM and VACUUM ANALYZE which usually grinds for 10 to 15 minutes. I'm running this db on a celeron 450Mhz with 256MB RAM and a 60GB HDD (7200 rpm). For the most part I have the db running "well enough." Over time however, I find that performance degrades, the count(*) above is an example of a command that does worse over time. It gets run once an hour for stats collection. When I first migrated the db to v7.3.1 it would take about 5-10 seconds (which it is close to now after a VACUUM FULL) but after a few weeks it would take over a minute of really intense HDD activity. Also of note is that when I first loaded the data it would cache very well with the query taking maybe taking 15 seconds if I had just started the db after reboot, but when it was in its "slow" state repeating the query didn't noticably use the disk less (nor did it take less time). I've attached a VACUUM VERBOSE and my conf file (which is pretty vanilla, I haven't tweaked it since updating). If you have any suggestions on how I can correct this situation through config changes that would be ideal and thanks for your help, if is just a case of doing lots of VACUUM FULLs, I can definitely see it as a performance bottleneck for postgres. Fortunately I can afford the huge peroformance penalty of a VACUUM FULL, but I can certainly think of apps that can't. Logan Bowers \d tblfiles: (219,248 rows) Column | Type | Modifiers ----------+-----------------------------+------------------------------------------- fid | integer | not null default nextval('fileids'::text) hid | integer | not null pid | integer | not null name | character varying(256) | not null size | bigint | not null Indexes: temp_fid_key unique btree (fid), filediridx btree (hid, pid, name, size, fid), fileidx btree (name, hid, pid, fid), fileidxfid btree (fid, name, pid) \d tblwordidx: (1,739,481 rows) Table "public.tblwordidx" Column | Type | Modifiers --------+------------------------+----------- fid | integer | not null word | character varying(128) | not null todel | boolean | Indexes: wordidxfid btree (fid, word), wordidxfidonly btree (fid), wordidxw btree (word, fid) On Mon, 17 Mar 2003, Tom Lane wrote: > "Neil Conway" writes: > > Sean Chittenden said: > > A "select count(*) FROM tblwordidx" initially took about 1 second to > > return a count of 2 million but after a few months it took several > > minutes of really hard HDD grinding. > >> > >> That's because there are dead entries in the index that weren't being > >> reused or cleaned up. As I said, this has been fixed. > > > That's doubtful: "select count(*) FROM foo" won't use an index. > > To know what's going on, as opposed to guessing about it, we'd need to > know something about the physical sizes of the table and its indexes. > "vacuum verbose" output would be instructive... > > But my best theorizing-in-advance-of-the-data guess is that Logan's > FSM settings are too small, causing free space to be leaked over time. > If a vacuum full restores the original performance then that's probably > the right answer. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > --1888041362-380975398-1047955267=:8636 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="postgresql.conf" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="postgresql.conf" Iw0KIyBQb3N0Z3JlU1FMIGNvbmZpZ3VyYXRpb24gZmlsZQ0KIyAtLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KIw0KIyBUaGlzIGZpbGUgY29uc2lz dHMgb2YgbGluZXMgb2YgdGhlIGZvcm06DQojDQojICAgbmFtZSA9IHZhbHVl DQojDQojIChUaGUgJz0nIGlzIG9wdGlvbmFsLikgV2hpdGUgc3BhY2UgbWF5 IGJlIHVzZWQuIENvbW1lbnRzIGFyZSBpbnRyb2R1Y2VkDQojIHdpdGggJyMn IGFueXdoZXJlIG9uIGEgbGluZS4gVGhlIGNvbXBsZXRlIGxpc3Qgb2Ygb3B0 aW9uIG5hbWVzIGFuZA0KIyBhbGxvd2VkIHZhbHVlcyBjYW4gYmUgZm91bmQg aW4gdGhlIFBvc3RncmVTUUwgZG9jdW1lbnRhdGlvbi4gVGhlDQojIGNvbW1l bnRlZC1vdXQgc2V0dGluZ3Mgc2hvd24gaW4gdGhpcyBmaWxlIHJlcHJlc2Vu dCB0aGUgZGVmYXVsdCB2YWx1ZXMuDQojDQojIEFueSBvcHRpb24gY2FuIGFs c28gYmUgZ2l2ZW4gYXMgYSBjb21tYW5kIGxpbmUgc3dpdGNoIHRvIHRoZQ0K IyBwb3N0bWFzdGVyLCBlLmcuICdwb3N0bWFzdGVyIC1jIGxvZ19jb25uZWN0 aW9ucz1vbicuIFNvbWUgb3B0aW9ucw0KIyBjYW4gYmUgY2hhbmdlZCBhdCBy dW4tdGltZSB3aXRoIHRoZSAnU0VUJyBTUUwgY29tbWFuZC4NCiMNCiMgVGhp cyBmaWxlIGlzIHJlYWQgb24gcG9zdG1hc3RlciBzdGFydHVwIGFuZCB3aGVu IHRoZSBwb3N0bWFzdGVyDQojIHJlY2VpdmVzIGEgU0lHSFVQLiBJZiB5b3Ug ZWRpdCB0aGUgZmlsZSBvbiBhIHJ1bm5pbmcgc3lzdGVtLCB5b3UgaGF2ZSAN CiMgdG8gU0lHSFVQIHRoZSBwb3N0bWFzdGVyIGZvciB0aGUgY2hhbmdlcyB0 byB0YWtlIGVmZmVjdCwgb3IgdXNlIA0KIyAicGdfY3RsIHJlbG9hZCIuDQoN Cg0KIz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KDQoNCiMNCiMJQ29u bmVjdGlvbiBQYXJhbWV0ZXJzDQojDQojdGNwaXBfc29ja2V0ID0gZmFsc2UN CiNzc2wgPSBmYWxzZQ0KDQojbWF4X2Nvbm5lY3Rpb25zID0gMzINCiNzdXBl cnVzZXJfcmVzZXJ2ZWRfY29ubmVjdGlvbnMgPSAyDQoNCiNwb3J0ID0gNTQz MiANCiNob3N0bmFtZV9sb29rdXAgPSBmYWxzZQ0KI3Nob3dfc291cmNlX3Bv cnQgPSBmYWxzZQ0KDQojdW5peF9zb2NrZXRfZGlyZWN0b3J5ID0gJycNCiN1 bml4X3NvY2tldF9ncm91cCA9ICcnDQojdW5peF9zb2NrZXRfcGVybWlzc2lv bnMgPSAwNzc3CSMgb2N0YWwNCg0KI3ZpcnR1YWxfaG9zdCA9ICcnDQoNCiNr cmJfc2VydmVyX2tleWZpbGUgPSAnJw0KDQoNCiMNCiMJU2hhcmVkIE1lbW9y eSBTaXplDQojDQpzaGFyZWRfYnVmZmVycyA9IDEwMDAgCQkjIDIqbWF4X2Nv bm5lY3Rpb25zLCBtaW4gMTYsIHR5cGljYWxseSA4S0IgZWFjaA0KI21heF9m c21fcmVsYXRpb25zID0gMTAwCSMgbWluIDEwLCBmc20gaXMgZnJlZSBzcGFj ZSBtYXAsIH40MCBieXRlcw0KI21heF9mc21fcGFnZXMgPSAxMDAwMAkJIyBt aW4gMTAwMCwgZnNtIGlzIGZyZWUgc3BhY2UgbWFwLCB+NiBieXRlcw0KI21h eF9sb2Nrc19wZXJfdHJhbnNhY3Rpb24gPSA2NAkjIG1pbiAxMA0KI3dhbF9i dWZmZXJzID0gOAkJIyBtaW4gNCwgdHlwaWNhbGx5IDhLQiBlYWNoDQoNCiMN CiMJTm9uLXNoYXJlZCBNZW1vcnkgU2l6ZXMNCiMNCiNzb3J0X21lbSA9IDEw MjQJCSMgbWluIDY0LCBzaXplIGluIEtCDQojdmFjdXVtX21lbSA9IDgxOTIJ CSMgbWluIDEwMjQsIHNpemUgaW4gS0INCg0KDQojDQojCVdyaXRlLWFoZWFk IGxvZyAoV0FMKQ0KIw0KI2NoZWNrcG9pbnRfc2VnbWVudHMgPSAzCSMgaW4g bG9nZmlsZSBzZWdtZW50cywgbWluIDEsIDE2TUIgZWFjaA0KI2NoZWNrcG9p bnRfdGltZW91dCA9IDMwMAkjIHJhbmdlIDMwLTM2MDAsIGluIHNlY29uZHMN CiMNCiNjb21taXRfZGVsYXkgPSAwCQkjIHJhbmdlIDAtMTAwMDAwLCBpbiBt aWNyb3NlY29uZHMNCiNjb21taXRfc2libGluZ3MgPSA1CQkjIHJhbmdlIDEt MTAwMA0KIw0KI2ZzeW5jID0gdHJ1ZQ0KI3dhbF9zeW5jX21ldGhvZCA9IGZz eW5jCSMgdGhlIGRlZmF1bHQgdmFyaWVzIGFjcm9zcyBwbGF0Zm9ybXM6DQoj CQkJCSMgZnN5bmMsIGZkYXRhc3luYywgb3Blbl9zeW5jLCBvciBvcGVuX2Rh dGFzeW5jDQojd2FsX2RlYnVnID0gMAkJCSMgcmFuZ2UgMC0xNg0KDQoNCiMN CiMJT3B0aW1pemVyIFBhcmFtZXRlcnMNCiMNCiNlbmFibGVfc2Vxc2NhbiA9 IHRydWUNCiNlbmFibGVfaW5kZXhzY2FuID0gdHJ1ZQ0KI2VuYWJsZV90aWRz Y2FuID0gdHJ1ZQ0KI2VuYWJsZV9zb3J0ID0gdHJ1ZQ0KI2VuYWJsZV9uZXN0 bG9vcCA9IHRydWUNCiNlbmFibGVfbWVyZ2Vqb2luID0gdHJ1ZQ0KI2VuYWJs ZV9oYXNoam9pbiA9IHRydWUNCg0KI2VmZmVjdGl2ZV9jYWNoZV9zaXplID0g MTAwMAkjIHR5cGljYWxseSA4S0IgZWFjaA0KI3JhbmRvbV9wYWdlX2Nvc3Qg PSA0CQkjIHVuaXRzIGFyZSBvbmUgc2VxdWVudGlhbCBwYWdlIGZldGNoIGNv c3QNCiNjcHVfdHVwbGVfY29zdCA9IDAuMDEJCSMgKHNhbWUpDQojY3B1X2lu ZGV4X3R1cGxlX2Nvc3QgPSAwLjAwMQkjIChzYW1lKQ0KI2NwdV9vcGVyYXRv cl9jb3N0ID0gMC4wMDI1CSMgKHNhbWUpDQoNCiNkZWZhdWx0X3N0YXRpc3Rp Y3NfdGFyZ2V0ID0gMTAJIyByYW5nZSAxLTEwMDANCg0KIw0KIwlHRVFPIE9w dGltaXplciBQYXJhbWV0ZXJzDQojDQojZ2VxbyA9IHRydWUNCiNnZXFvX3Nl bGVjdGlvbl9iaWFzID0gMi4wCSMgcmFuZ2UgMS41LTIuMA0KI2dlcW9fdGhy ZXNob2xkID0gMTENCiNnZXFvX3Bvb2xfc2l6ZSA9IDAJCSMgZGVmYXVsdCBi YXNlZCBvbiB0YWJsZXMgaW4gc3RhdGVtZW50LCANCgkJCQkjIHJhbmdlIDEy OC0xMDI0DQojZ2Vxb19lZmZvcnQgPSAxDQojZ2Vxb19nZW5lcmF0aW9ucyA9 IDANCiNnZXFvX3JhbmRvbV9zZWVkID0gLTEJCSMgYXV0by1jb21wdXRlIHNl ZWQNCg0KDQojDQojCU1lc3NhZ2UgZGlzcGxheQ0KIw0KI3NlcnZlcl9taW5f bWVzc2FnZXMgPSBub3RpY2UJIyBWYWx1ZXMsIGluIG9yZGVyIG9mIGRlY3Jl YXNpbmcgZGV0YWlsOg0KCQkJCSMgICBkZWJ1ZzUsIGRlYnVnNCwgZGVidWcz LCBkZWJ1ZzIsIGRlYnVnMSwNCgkJCQkjICAgaW5mbywgbm90aWNlLCB3YXJu aW5nLCBlcnJvciwgbG9nLCBmYXRhbCwNCgkJCQkjICAgcGFuaWMNCiNjbGll bnRfbWluX21lc3NhZ2VzID0gbm90aWNlCSMgVmFsdWVzLCBpbiBvcmRlciBv ZiBkZWNyZWFzaW5nIGRldGFpbDoNCgkJCQkjICAgZGVidWc1LCBkZWJ1ZzQs IGRlYnVnMywgZGVidWcyLCBkZWJ1ZzEsDQoJCQkJIyAgIGxvZywgaW5mbywg bm90aWNlLCB3YXJuaW5nLCBlcnJvcg0KI3NpbGVudF9tb2RlID0gZmFsc2UN Cg0KI2xvZ19jb25uZWN0aW9ucyA9IGZhbHNlDQojbG9nX3BpZCA9IGZhbHNl DQojbG9nX3N0YXRlbWVudCA9IGZhbHNlDQojbG9nX2R1cmF0aW9uID0gZmFs c2UNCiNsb2dfdGltZXN0YW1wID0gZmFsc2UNCg0KI2xvZ19taW5fZXJyb3Jf c3RhdGVtZW50ID0gZXJyb3IJCSMgVmFsdWVzIGluIG9yZGVyIG9mIGluY3Jl YXNpbmcgc2V2ZXJpdHk6DQoJCQkJCQkJCQkjIGRlYnVnNSwgZGVidWc0LCBk ZWJ1ZzMsIGRlYnVnMiwgZGVidWcxLA0KCQkJCQkgICAgICAgICAgICAgICAg IyBpbmZvLCBub3RpY2UsIHdhcm5pbmcsIGVycm9yDQojZGVidWdfcHJpbnRf cGFyc2UgPSBmYWxzZQ0KI2RlYnVnX3ByaW50X3Jld3JpdHRlbiA9IGZhbHNl DQojZGVidWdfcHJpbnRfcGxhbiA9IGZhbHNlDQojZGVidWdfcHJldHR5X3By aW50ID0gZmFsc2UNCg0KI2V4cGxhaW5fcHJldHR5X3ByaW50ID0gdHJ1ZQ0K DQojIHJlcXVpcmVzIFVTRV9BU1NFUlRfQ0hFQ0tJTkcNCiNkZWJ1Z19hc3Nl cnRpb25zID0gdHJ1ZQ0KDQoNCiMNCiMJU3lzbG9nDQojDQojc3lzbG9nID0g MAkJCSMgcmFuZ2UgMC0yDQojc3lzbG9nX2ZhY2lsaXR5ID0gJ0xPQ0FMMCcN CiNzeXNsb2dfaWRlbnQgPSAncG9zdGdyZXMnDQoNCg0KIw0KIwlTdGF0aXN0 aWNzDQojDQojc2hvd19wYXJzZXJfc3RhdHMgPSBmYWxzZQ0KI3Nob3dfcGxh bm5lcl9zdGF0cyA9IGZhbHNlDQojc2hvd19leGVjdXRvcl9zdGF0cyA9IGZh bHNlDQojc2hvd19zdGF0ZW1lbnRfc3RhdHMgPSBmYWxzZQ0KDQojIHJlcXVp cmVzIEJUUkVFX0JVSUxEX1NUQVRTDQojc2hvd19idHJlZV9idWlsZF9zdGF0 cyA9IGZhbHNlDQoNCg0KIw0KIwlBY2Nlc3Mgc3RhdGlzdGljcyBjb2xsZWN0 aW9uDQojDQojc3RhdHNfc3RhcnRfY29sbGVjdG9yID0gdHJ1ZQ0KI3N0YXRz X3Jlc2V0X29uX3NlcnZlcl9zdGFydCA9IHRydWUNCiNzdGF0c19jb21tYW5k X3N0cmluZyA9IGZhbHNlDQojc3RhdHNfcm93X2xldmVsID0gZmFsc2UNCiNz dGF0c19ibG9ja19sZXZlbCA9IGZhbHNlDQoNCg0KIw0KIwlMb2NrIFRyYWNp bmcNCiMNCiN0cmFjZV9ub3RpZnkgPSBmYWxzZQ0KDQojIHJlcXVpcmVzIExP Q0tfREVCVUcNCiN0cmFjZV9sb2NrcyA9IGZhbHNlDQojdHJhY2VfdXNlcmxv Y2tzID0gZmFsc2UNCiN0cmFjZV9sd2xvY2tzID0gZmFsc2UNCiNkZWJ1Z19k ZWFkbG9ja3MgPSBmYWxzZQ0KI3RyYWNlX2xvY2tfb2lkbWluID0gMTYzODQN CiN0cmFjZV9sb2NrX3RhYmxlID0gMA0KDQoNCiMNCiMJTWlzYw0KIw0KI2F1 dG9jb21taXQgPSB0cnVlDQojZHluYW1pY19saWJyYXJ5X3BhdGggPSAnJGxp YmRpcicNCiNzZWFyY2hfcGF0aCA9ICckdXNlcixwdWJsaWMnDQojZGF0ZXN0 eWxlID0gJ2lzbywgdXMnDQojdGltZXpvbmUgPSB1bmtub3duCQkjIGFjdHVh bGx5LCBkZWZhdWx0cyB0byBUWiBlbnZpcm9ubWVudCBzZXR0aW5nDQojYXVz dHJhbGlhbl90aW1lem9uZXMgPSBmYWxzZQ0KI2NsaWVudF9lbmNvZGluZyA9 IHNxbF9hc2NpaQkjIGFjdHVhbGx5LCBkZWZhdWx0cyB0byBkYXRhYmFzZSBl bmNvZGluZw0KI2F1dGhlbnRpY2F0aW9uX3RpbWVvdXQgPSA2MAkjIDEtNjAw LCBpbiBzZWNvbmRzDQojZGVhZGxvY2tfdGltZW91dCA9IDEwMDAJIyBpbiBt aWxsaXNlY29uZHMNCiNkZWZhdWx0X3RyYW5zYWN0aW9uX2lzb2xhdGlvbiA9 ICdyZWFkIGNvbW1pdHRlZCcNCiNtYXhfZXhwcl9kZXB0aCA9IDEwMDAwCQkj IG1pbiAxMA0KI21heF9maWxlc19wZXJfcHJvY2VzcyA9IDEwMDAJIyBtaW4g MjUNCiNwYXNzd29yZF9lbmNyeXB0aW9uID0gdHJ1ZQ0KI3NxbF9pbmhlcml0 YW5jZSA9IHRydWUNCiN0cmFuc2Zvcm1fbnVsbF9lcXVhbHMgPSBmYWxzZQ0K I3N0YXRlbWVudF90aW1lb3V0ID0gMAkJIyAwIGlzIGRpc2FibGVkLCBpbiBt aWxsaXNlY29uZHMNCiNkYl91c2VyX25hbWVzcGFjZSA9IGZhbHNlDQogDQoN Cg0KIw0KIwlMb2NhbGUgc2V0dGluZ3MNCiMNCiMgKGluaXRpYWxpemVkIGJ5 IGluaXRkYiAtLSBtYXkgYmUgY2hhbmdlZCkNCkxDX01FU1NBR0VTID0gJ0Mn DQpMQ19NT05FVEFSWSA9ICdDJw0KTENfTlVNRVJJQyA9ICdDJw0KTENfVElN RSA9ICdDJw0K --1888041362-380975398-1047955267=:8636 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=VACVERB Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=VACVERB SU5GTzogIC0tUmVsYXRpb24gcHVibGljLnRibHNsb2ctLQ0KSU5GTzogIFBh Z2VzIDIxNTI6IENoYW5nZWQgMCwgRW1wdHkgMDsgVHVwIDI2Mzg5MjogVmFj IDAsIEtlZXAgMCwgVW5Vc2VkIDAuDQoJVG90YWwgQ1BVIDAuMTRzLzAuMTN1 IHNlYyBlbGFwc2VkIDAuNzQgc2VjLg0KSU5GTzogIC0tUmVsYXRpb24gcHVi bGljLnRibGhvc3RzLS0NCklORk86ICBQYWdlcyA5OiBDaGFuZ2VkIDAsIEVt cHR5IDA7IFR1cCAyMzA6IFZhYyAwLCBLZWVwIDAsIFVuVXNlZCA5MTIuDQoJ VG90YWwgQ1BVIDAuMDBzLzAuMDB1IHNlYyBlbGFwc2VkIDAuMDAgc2VjLg0K SU5GTzogIC0tUmVsYXRpb24gcHVibGljLnRibHBhdGhzLS0NCklORk86ICBQ YWdlcyA5ODogQ2hhbmdlZCAwLCBFbXB0eSAwOyBUdXAgMTA0NzQ6IFZhYyAw LCBLZWVwIDAsIFVuVXNlZCAxMDQ5Lg0KCVRvdGFsIENQVSAwLjAwcy8wLjAw dSBzZWMgZWxhcHNlZCAwLjAyIHNlYy4NCklORk86ICAtLVJlbGF0aW9uIHB1 YmxpYy50YmxzdGF0cy0tDQpJTkZPOiAgUGFnZXMgNjY6IENoYW5nZWQgMCwg RW1wdHkgMDsgVHVwIDYwMDU6IFZhYyAwLCBLZWVwIDAsIFVuVXNlZCAwLg0K CVRvdGFsIENQVSAwLjAxcy8wLjAwdSBzZWMgZWxhcHNlZCAwLjAyIHNlYy4N CklORk86ICAtLVJlbGF0aW9uIHB1YmxpYy50Ymx1bGlzdC0tDQpJTkZPOiAg UGFnZXMgMjk6IENoYW5nZWQgMCwgRW1wdHkgMDsgVHVwIDc5ODogVmFjIDAs IEtlZXAgMCwgVW5Vc2VkIDQxMzIuDQoJVG90YWwgQ1BVIDAuMDBzLzAuMDB1 IHNlYyBlbGFwc2VkIDAuMDAgc2VjLg0KSU5GTzogIC0tUmVsYXRpb24gcHVi bGljLnRibHRtcC0tDQpJTkZPOiAgUGFnZXMgMzAwNTogQ2hhbmdlZCAwLCBF bXB0eSAwOyBUdXAgMTU4MDk6IFZhYyAwLCBLZWVwIDAsIFVuVXNlZCAxNjk3 NDMuDQoJVG90YWwgQ1BVIDAuMjdzLzAuMDZ1IHNlYyBlbGFwc2VkIDAuOTAg c2VjLg0KSU5GTzogIC0tUmVsYXRpb24gcHVibGljLnRibGRsb2ctLQ0KSU5G TzogIFBhZ2VzIDEwNzIwOiBDaGFuZ2VkIDAsIEVtcHR5IDA7IFR1cCA0Nzg5 MDI6IFZhYyAwLCBLZWVwIDAsIFVuVXNlZCAwLg0KCVRvdGFsIENQVSAxLjA5 cy8wLjI4dSBzZWMgZWxhcHNlZCAyLjU5IHNlYy4NCklORk86ICAtLVJlbGF0 aW9uIHB1YmxpYy50YmxuZXdob3N0cy0tDQpJTkZPOiAgUGFnZXMgMzogQ2hh bmdlZCAwLCBFbXB0eSAwOyBUdXAgMTg5OiBWYWMgMCwgS2VlcCAwLCBVblVz ZWQgMC4NCglUb3RhbCBDUFUgMC4wMHMvMC4wMHUgc2VjIGVsYXBzZWQgMC4w MCBzZWMuDQpJTkZPOiAgLS1SZWxhdGlvbiBwdWJsaWMudGJsbmV3cGF0aHMt LQ0KSU5GTzogIFBhZ2VzIDQ6IENoYW5nZWQgMCwgRW1wdHkgMDsgVHVwIDM1 NDogVmFjIDAsIEtlZXAgMCwgVW5Vc2VkIDAuDQoJVG90YWwgQ1BVIDAuMDBz LzAuMDB1IHNlYyBlbGFwc2VkIDAuMDAgc2VjLg0KSU5GTzogIC0tUmVsYXRp b24gcHVibGljLnRibG5ld2ZpbGVzLS0NCklORk86ICBQYWdlcyAxODQ0OiBD aGFuZ2VkIDAsIEVtcHR5IDA7IFR1cCAxOTQzMjg6IFZhYyAwLCBLZWVwIDAs IFVuVXNlZCA4Mi4NCglUb3RhbCBDUFUgMC4xOXMvMC4wOHUgc2VjIGVsYXBz ZWQgMC4zOCBzZWMuDQpJTkZPOiAgLS1SZWxhdGlvbiBwdWJsaWMudGJsc2Vl bi0tDQpJTkZPOiAgUGFnZXMgMTIxOTc6IENoYW5nZWQgMCwgRW1wdHkgMDsg VHVwIDI0ODgwNzA6IFZhYyAwLCBLZWVwIDAsIFVuVXNlZCAwLg0KCVRvdGFs IENQVSAxLjEycy8wLjU2dSBzZWMgZWxhcHNlZCAxMi41MiBzZWMuDQpJTkZP OiAgLS1SZWxhdGlvbiBwdWJsaWMudGJsd29yZGlkeC0tDQpJTkZPOiAgUGFn ZXMgMTAwMTM6IENoYW5nZWQgMCwgRW1wdHkgMDsgVHVwIDE3Mzk0ODE6IFZh YyAwLCBLZWVwIDAsIFVuVXNlZCA0MDE0NC4NCglUb3RhbCBDUFUgMC45NHMv MC40NHUgc2VjIGVsYXBzZWQgNy41MCBzZWMuDQpJTkZPOiAgLS1SZWxhdGlv biBwdWJsaWMudGJsZmlsZXMtLQ0KSU5GTzogIFBhZ2VzIDI1Mzk6IENoYW5n ZWQgMCwgRW1wdHkgMDsgVHVwIDIxOTI0ODogVmFjIDAsIEtlZXAgMCwgVW5V c2VkIDMzODQ2Lg0KCVRvdGFsIENQVSAwLjI1cy8wLjA2dSBzZWMgZWxhcHNl ZCAwLjMzIHNlYy4NCg== --1888041362-380975398-1047955267=:8636-- From pgsql-performance-owner@postgresql.org Mon Mar 17 21:44:03 2003 X-Original-To: pgsql-performance@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id 8EE98475461 for ; Mon, 17 Mar 2003 21:44:00 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h2I2i3s99417 for pgsql-performance@postgresql.org; Tue, 18 Mar 2003 10:44:03 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h2I2hv799191; Tue, 18 Mar 2003 10:43:57 +0800 (WST) Message-ID: <088d01c2ecf8$3bf742e0$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: "Logan Bowers" , "Tom Lane" Cc: "Neil Conway" , , References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> <20030317061011.GH23355@perrin.int.nxad.com> <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> <495.1047882860@sss.pgh.pa.us> Subject: Re: postgresql meltdown on PlanetMath.org Date: Tue, 18 Mar 2003 10:44:01 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/131 X-Sequence-Number: 1429 > I'm running this db on a celeron 450Mhz with 256MB RAM and a 60GB HDD > (7200 rpm). For the most part I have the db running "well enough." Over > time however, I find that performance degrades, the count(*) above is an > example of a command that does worse over time. It gets run once an hour > for stats collection. When I first migrated the db to v7.3.1 it would > take about 5-10 seconds (which it is close to now after a VACUUM FULL) but > after a few weeks it would take over a minute of really intense HDD > activity. Also of note is that when I first loaded the data it would > cache very well with the query taking maybe taking 15 seconds if I had > just started the db after reboot, but when it was in its "slow" state > repeating the query didn't noticably use the disk less (nor did it take > less time). To speed up your COUNT(*), how about doing this: Create a separate table to hold a single integer. Add a trigger after insert on your table to increment the counter in the other table Add a trigger after delete on your table to decrement the counter in the other table. That way you always have an O(1) count... Chris From pgsql-performance-owner@postgresql.org Mon Mar 17 21:51:52 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id E02DC475F39 for ; Mon, 17 Mar 2003 21:51:50 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2I2pnub015805; Mon, 17 Mar 2003 21:51:50 -0500 (EST) To: Logan Bowers Cc: Neil Conway , sean@chittenden.org, pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-reply-to: References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> <20030317061011.GH23355@perrin.int.nxad.com> <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> <495.1047882860@sss.pgh.pa.us> Comments: In-reply-to Logan Bowers message dated "Mon, 17 Mar 2003 21:41:07 -0500" Date: Mon, 17 Mar 2003 21:51:49 -0500 Message-ID: <15804.1047955909@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/132 X-Sequence-Number: 1430 Logan Bowers writes: > I've attached a VACUUM VERBOSE and my conf file (which is pretty vanilla, > I haven't tweaked it since updating). You definitely need to increase the fsm shared memory parameters. The default max_fsm_relations is just plain too small (try 1000) and the default_max_fsm_pages is really only enough for perhaps a 100Mb database. I'd try bumping it to 100,000. Note you need a postmaster restart to make these changes take effect. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Mar 18 09:59:59 2003 X-Original-To: pgsql-performance@postgresql.org Received: from irko.smoothcorp.com (unknown [208.49.241.41]) by postgresql.org (Postfix) with ESMTP id C91CE475458 for ; Tue, 18 Mar 2003 09:59:56 -0500 (EST) Received: from taurus.ifloor.com ([10.0.1.20] helo=taurus.smoothcorp.com) by irko.smoothcorp.com with esmtp (Exim 4.12) id 18vIZM-0005Xb-00; Tue, 18 Mar 2003 07:00:00 -0800 Received: from localhost (chris@localhost) by taurus.smoothcorp.com (8.11.6/8.11.6) with ESMTP id h2IExuM20760; Tue, 18 Mar 2003 06:59:58 -0800 X-Authentication-Warning: taurus.smoothcorp.com: chris owned process doing -bs Date: Tue, 18 Mar 2003 06:59:56 -0800 (PST) From: Chris Sutton To: Logan Bowers Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-ID: X-SA-Exim-Rcpt-To: pgsql-performance@postgresql.org, logan@datacurrent.com X-SA-Exim-Scanned: No; SAEximRunCond expanded to false X-Archive-Number: 200303/133 X-Sequence-Number: 1431 On Mon, 17 Mar 2003, Logan Bowers wrote: > Logan Bowers > > \d tblfiles: (219,248 rows) > Column | Type | Modifiers > ----------+-----------------------------+------------------------------------------- > fid | integer | not null default > nextval('fileids'::text) > hid | integer | not null > pid | integer | not null > name | character varying(256) | not null > size | bigint | not null > Indexes: temp_fid_key unique btree (fid), > filediridx btree (hid, pid, name, size, fid), > fileidx btree (name, hid, pid, fid), > fileidxfid btree (fid, name, pid) I'm no expert on indexes, but I seem to remember reading that creating multicolumn indexes on more than 2 or 3 columns gets sort of pointless: http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/indexes-multicolumn.html There is probably a ton of disk space and CPU used to keep all these multi column indexes. Might be part of the problem. > \d tblwordidx: (1,739,481 rows) > Table "public.tblwordidx" > Column | Type | Modifiers > --------+------------------------+----------- > fid | integer | not null > word | character varying(128) | not null > todel | boolean | > Indexes: wordidxfid btree (fid, word), > wordidxfidonly btree (fid), > wordidxw btree (word, fid) > Another index question for the pros. When creating a multi-column index do you need to do it both ways: wordidxfid btree (fid, word) wordidxw btree (word, fid We have a very similar "dictonary" table here for searching. It's about 1.7 million rows, takes about 80mb of disk space. There is one multi column index on the table which uses about 50mb of disk space. To find out how much disk space you are using, the hard way is: select relfilenode from pg_class where relname='tblwordidx'; select relfilenode from pg_class where relname='wordidxw'; relfilenode is the name of the file in your data directory. I'm pretty sure there is an easier way to do this with a function I saw in contrib. Just some thoughts. Chris From pgsql-performance-owner@postgresql.org Tue Mar 18 10:19:41 2003 X-Original-To: pgsql-performance@postgresql.org Received: from hotmail.com (bay1-f102.bay1.hotmail.com [65.54.245.102]) by postgresql.org (Postfix) with ESMTP id 485E3475A9E for ; Tue, 18 Mar 2003 10:19:40 -0500 (EST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 18 Mar 2003 07:19:44 -0800 Received: from 205.229.142.209 by by1fd.bay1.hotmail.msn.com with HTTP; Tue, 18 Mar 2003 15:19:44 GMT X-Originating-IP: [205.229.142.209] From: "Kendrick C. Wilson" To: chriskl@familyhealth.com.au, pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Date: Tue, 18 Mar 2003 09:19:44 -0600 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 18 Mar 2003 15:19:44.0571 (UTC) FILETIME=[CE2188B0:01C2ED61] X-Archive-Number: 200303/134 X-Sequence-Number: 1432 Clustering is good for queries that return multiple values. select this, that from tableA where this = 'whatever'; If there are multiple values, the location of the first record is found in the indexFile. Then dataFile is scanned until this != 'whatever'; This will decrease disk activity, which is the bottle neck in database performance. k=n^r/ck, SCJP >From: "Christopher Kings-Lynne" >To: "Kendrick C. Wilson" >, >Subject: Re: [PERFORM] postgresql meltdown on PlanetMath.org Date: Tue, 18 >Mar 2003 09:34:36 +0800 >MIME-Version: 1.0 >Received: from relay2.pgsql.com ([64.49.215.143]) by >mc6-f41.law1.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Mon, 17 Mar >2003 17:34:42 -0800 >Received: from postgresql.org (postgresql.org [64.49.215.8])by >relay2.pgsql.com (Postfix) with ESMTPid 022ADE5BD; Mon, 17 Mar 2003 >20:34:36 -0500 (EST) >Received: from houston.familyhealth.com.au (unknown [203.59.48.253])by >postgresql.org (Postfix) with ESMTP id A55E5475F09for >; Mon, 17 Mar 2003 20:34:33 -0500 (EST) >Received: (from root@localhost)by houston.familyhealth.com.au >(8.11.6/8.11.6) id h2I1Yac95711for pgsql-performance@postgresql.org; Tue, >18 Mar 2003 09:34:36 +0800 (WST)(envelope-from chriskl@familyhealth.com.au) >Received: from mariner (mariner.internal [192.168.0.101])by >houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h2I1YW795594;Tue, >18 Mar 2003 09:34:32 +0800 (WST) >X-Message-Info: yilqo4+6kc64AXpUCzRAW30W84h6gtv8 >X-Original-To: pgsql-performance@postgresql.org >Message-ID: <07b501c2ecee$8917b8c0$6500a8c0@fhp.internal> >References: >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-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) >Precedence: bulk >Sender: pgsql-performance-owner@postgresql.org >Return-Path: pgsql-performance-owner+M1426@postgresql.org >X-OriginalArrivalTime: 18 Mar 2003 01:34:42.0860 (UTC) >FILETIME=[8CCFDEC0:01C2ECEE] > > > > > What is the structure of you table? > > Is the data types in the table the same as in the SQL.... > > > > Did you create the index after the loading the table? > > cluster the table around the most used index.... > >There is no point clustering a table around the most used index, unless >access to the index is non-random. eg. you are picking up more than one >consecutive entry from the index at a time. eg. Indexes on foreign keys >are >excellent for clustering. > >Chris > > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > >http://www.postgresql.org/docs/faqs/FAQ.html _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus From pgsql-performance-owner@postgresql.org Tue Mar 18 11:26:22 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id E2ACC476128 for ; Tue, 18 Mar 2003 11:26:19 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2908257; Tue, 18 Mar 2003 08:26:12 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Logan Bowers , Tom Lane Subject: Re: postgresql meltdown on PlanetMath.org Date: Tue, 18 Mar 2003 08:26:10 -0800 User-Agent: KMail/1.4.3 Cc: Neil Conway , sean@chittenden.org, pgsql-performance@postgresql.org References: <20030316060125.GD19570@vt.edu> <495.1047882860@sss.pgh.pa.us> In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200303180826.10200.josh@agliodbs.com> X-Archive-Number: 200303/135 X-Sequence-Number: 1433 Logan, > I'm running this db on a celeron 450Mhz with 256MB RAM and a 60GB HDD > (7200 rpm). For the most part I have the db running "well enough." Over Hmmm ... actually, considering your hardware, I'd say the database performance you're getting is excellent. You're facing 3 bottlenecks: 1) The Celeron II's lack of on-chip cache will slow down even moderately complex queries as much as 50% over a comparably-clocked pentium or AMD chip, in my experience. 2) 256mb RAM is small enough that if you are running Apache on the same machine, Apache & Postgres could be contesting for RAM during busy periods. 3) (most noticable) You have pretty much the bare minimum of disk. For a one-gb database, a Linux RAID array or mirror would be a lot better ... Of course, that's all relative. What I'm saying is, if you want your database to "scream" you're going to have to put some money into hardware. If you're just looking for adequate performance, then that can be had with a little tweaking and maintainence. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Mar 18 21:29:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from 210.255.76.25 (host-A025.netspeed.dion.ne.jp [210.255.76.25]) by postgresql.org (Postfix) with SMTP id 9778C475F5F for ; Tue, 18 Mar 2003 21:29:41 -0500 (EST) Received: from a231242.upc-a.chello.nl ([96.216.72.224]) by m10.grp.snv.yahoo.com with NNFMP; Mar, 18 2003 7:18:35 PM +0400 Received: from rly-xw01.mx.aol.com ([153.196.56.114]) by da001d2020.lax-ca.osd.concentric.net with SMTP; Mar, 18 2003 6:17:44 PM -0200 From: Lodovico To: pgsql-performance@postgresql.org Subject: Re: ABOUT YOUR CREDIT......... lquwj Mime-Version: 1.0 Content-Type: text/html; charset="iso-8859-1" Date: Tue, 18 Mar 2003 20:28:02 -0600 X-Mailer: Microsoft Outlook Express 5.50.4133.2400 Message-Id: <20030319022941.9778C475F5F@postgresql.org> X-Archive-Number: 200303/136 X-Sequence-Number: 1434

We can fix your credit. We are very successful at getting bankruptcies, judgments, tax liens, foreclosures, late payments, charge-offs, repossessions, and even student loans removed from a persons credit report. To find out more go to http://www.netcreditlawyer.com.

If you no longer want to receive information from us just go to tallrhe@cs.com.

  eefellsundvsttjoqtaxnhxlg From pgsql-performance-owner@postgresql.org Wed Mar 19 14:53:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from email01.aon.at (WARSL401PIP8.highway.telekom.at [195.3.96.97]) by postgresql.org (Postfix) with SMTP id 5668F474E4F for ; Wed, 19 Mar 2003 14:53:11 -0500 (EST) Received: (qmail 620460 invoked from network); 19 Mar 2003 19:53:10 -0000 Received: from m169p021.dipool.highway.telekom.at (HELO cantor) ([62.46.11.21]) (envelope-sender ) by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 19 Mar 2003 19:53:10 -0000 From: Manfred Koizar To: "Kendrick C. Wilson" Cc: chriskl@familyhealth.com.au, pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org Date: Wed, 19 Mar 2003 20:52:21 +0100 Message-ID: <00ih7vcuu5gf29oep2hi9sctrnui061ogh@4ax.com> References: In-Reply-To: X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/137 X-Sequence-Number: 1435 On Tue, 18 Mar 2003 09:19:44 -0600, "Kendrick C. Wilson" wrote: >If there are multiple values, the location of the first record is found in >the indexFile. > >Then dataFile is scanned until this != 'whatever'; Nice, but unfortunately not true for Postgres. When you do the first UPDATE after CLUSTER the new version of the changed row(s) are written to the end of the dataFile (heap relation in Postgres speech). So the *index* has to be scanned until this != 'whatever'. >Clustering is good for queries that return multiple [rows with the same search] values. Yes. With clustering you can expect that most of the tuples you want are near to each other and you find several of them in the same page. Servus Manfred From pgsql-performance-owner@postgresql.org Thu Mar 20 13:55:38 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 1ED8D474E4F for ; Thu, 20 Mar 2003 13:55:37 -0500 (EST) Received: (qmail 25281 invoked by uid 0); 20 Mar 2003 18:55:15 -0000 Received: from pD9E82E12.dip.t-dialin.net (HELO gmx.net) (217.232.46.18) by mail.gmx.net (mp015-rz3) with SMTP; 20 Mar 2003 18:55:15 -0000 Message-ID: <3E7A0E27.7040805@gmx.net> Date: Thu, 20 Mar 2003 19:53:27 +0100 From: Torsten Schulz User-Agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.4a) Gecko/20030318 X-Accept-Language: de-de, en-us MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Make PGSQL faster Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/138 X-Sequence-Number: 1436 Hi, we have a great Database with Postgres. It is a Community. We have a Dual-CPU-System with 1 GB RAM It works on Apache with PHP. But we hadn't enough Performance. What's the optimized configuration with many Database-actions on great tables in a lapp-system? Greetings Torsten From pgsql-performance-owner@postgresql.org Thu Mar 20 15:45:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from hotmail.com (bay1-f34.bay1.hotmail.com [65.54.245.34]) by postgresql.org (Postfix) with ESMTP id 672DB47634D for ; Thu, 20 Mar 2003 15:45:24 -0500 (EST) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 20 Mar 2003 12:45:24 -0800 Received: from 205.229.142.209 by by1fd.bay1.hotmail.msn.com with HTTP; Thu, 20 Mar 2003 20:45:24 GMT X-Originating-IP: [205.229.142.209] X-Originating-Email: [kendrick_wilson@hotmail.com] From: "Kendrick C. Wilson" To: pgsql-performance@postgresql.org Subject: Page Size in Future Releases Date: Thu, 20 Mar 2003 14:45:24 -0600 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 20 Mar 2003 20:45:24.0951 (UTC) FILETIME=[A1EE6670:01C2EF21] X-Archive-Number: 200303/139 X-Sequence-Number: 1437 Will a increase in the size of a data page increase performance of a database with large records? I have records about 881 byte + 40 byte (header) = 921. 8k page size / 921 bytes per record is ONLY 8 records........... Comments are welcome......... k=n^r/ck, SCJP _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus From pgsql-performance-owner@postgresql.org Thu Mar 20 16:16:02 2003 X-Original-To: pgsql-performance@postgresql.org Received: from smtp.noos.fr (nan-smtp-06.noos.net [212.198.2.75]) by postgresql.org (Postfix) with ESMTP id D782F474E4F for ; Thu, 20 Mar 2003 16:15:59 -0500 (EST) Received: (qmail 55290743 invoked by uid 0); 20 Mar 2003 21:16:00 -0000 Received: from unknown (HELO camille) ([195.132.173.79]) (envelope-sender ) by 212.198.2.75 (qmail-ldap-1.03) with SMTP for ; 20 Mar 2003 21:16:00 -0000 Message-ID: <00c301c2ef27$65d954a0$4fad84c3@camille> From: "Guillaume Houssay" To: Subject: just to get some opinion on my configuration Date: Thu, 20 Mar 2003 22:26:40 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00C0_01C2EF2F.C775E950" 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-Archive-Number: 200303/140 X-Sequence-Number: 1438 This is a multi-part message in MIME format. ------=_NextPart_000_00C0_01C2EF2F.C775E950 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am setting up a project using APache, PHP and Postgresql. This application will be used by about 30 users. The database is about this type : between 12GB and 15GB 4 tables will have 1M rows and 1000 columns with 90% of INT2 and the rest o= f float (20% of all the data will be 0) the orther tables are less than 10 000 rows Most of the queries will be SELECT being not very complicated (I think at t= his time) I have 1 question regardind the hardware configuration : DELL=20 bi-processor 2.8GHz 4GB RAM 76GB HD using Raid 5 Linux version to be defined (Redhat ?) Do you think this configuration is enough to have good performance after se= tting up properly the database ? Do you thing the big tables should be splitted in order to have less column= s. This could mean that I would have some queries with JOIN ? Thank you for your help ! ------=_NextPart_000_00C0_01C2EF2F.C775E950 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

I am setting up a project using APache, PH= P and=20 Postgresql.
This application will be used by about 30= =20 users.
 
The database is about this type :
 
between 12GB and 15GB
4 tables will have 1M rows and 1000 column= s with=20 90% of INT2 and the rest of float (20% of all the data will be 0)
the orther tables are less than 10 000=20 rows
 
Most of the queries will be SELECT being n= ot very=20 complicated (I think at this time)
 
I have 1 question regardind the hardware= =20 configuration :
 
DELL
bi-processor 2.8GHz
4GB RAM
76GB HD using Raid 5
Linux version to be defined (Redhat ?)
 
Do you think this configuration is enough = to have=20 good performance after setting up properly the database ?
 
Do you thing the big tables should be spli= tted in=20 order to have less columns. This could mean that I would have some queries = with=20 JOIN ?
 
Thank you for your help !
 
------=_NextPart_000_00C0_01C2EF2F.C775E950-- From pgsql-performance-owner@postgresql.org Thu Mar 20 16:41:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mail01.stbernard.com (mail01.stbernard.com [64.154.93.162]) by postgresql.org (Postfix) with ESMTP id C79A7475D91; Thu, 20 Mar 2003 16:41:24 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Help with LIKE Date: Thu, 20 Mar 2003 13:41:25 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Help with LIKE Thread-Index: AcLvKXUTE3v5RmpbSjiupBS4CDj5pw== From: "David Olbersen" To: Cc: X-Archive-Number: 200303/141 X-Sequence-Number: 1439 I have a table with 8,628,633 rows that I'd LIKE to search (ha ha). I have a very simple query: SELECT * FROM tableA WHERE column1 LIKE '%something%'; tableA.column1 has an index on it and the database has been vacuumed recent= ly. My problem is with the output of EXPLAIN: +----------------------------------------------------------------+ | QUERY PLAN | +----------------------------------------------------------------+ | Seq Scan on tableA (cost=3D0.00..212651.61 rows=3D13802 width=3D46) | | Filter: (column1 ~~ '%something%'::text) | +----------------------------------------------------------------+ I don't like that cost (2,12,651) at all! Is there anyway I can optimize th= is query? Make a different kind of index (it's currently btree)? Use substr= or indexof or something instead of LIKE? Thoughts? -------------------------- David Olbersen=20 iGuard Engineer 11415 West Bernardo Court=20 San Diego, CA 92127=20 1-858-676-2277 x2152 From pgsql-performance-owner@postgresql.org Thu Mar 20 16:55:38 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 24DB8476355; Thu, 20 Mar 2003 16:55:37 -0500 (EST) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2912779; Thu, 20 Mar 2003 13:55:27 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "David Olbersen" , Subject: Re: Help with LIKE Date: Thu, 20 Mar 2003 13:55:32 -0800 User-Agent: KMail/1.4.3 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303201355.32718.josh@agliodbs.com> X-Archive-Number: 200303/142 X-Sequence-Number: 1440 David, > I have a table with 8,628,633 rows that I'd LIKE to search (ha ha). >=20 > I have a very simple query: > SELECT * FROM tableA WHERE column1 LIKE '%something%'; That's what's called an "unanchored text search". That kind of query cann= ot=20 be indexed using a regular index. What you need is called "Full Text Indexing" or "Full Text Search". Check= =20 out two resources: 1) contrib/tsearch in your PostgreSQL source code; 2) OpenFTS (www.openfts.org). --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Mar 20 18:01:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from Mail.CERT.Uni-Stuttgart.DE (Mail.CERT.Uni-Stuttgart.DE [129.69.16.17]) by postgresql.org (Postfix) with ESMTP id 125A0475C15 for ; Thu, 20 Mar 2003 18:01:17 -0500 (EST) Received: from rusfw by Mail.CERT.Uni-Stuttgart.DE with local (Exim 4.10) id 18w92E-0000mB-00 for pgsql-performance@postgresql.org; Fri, 21 Mar 2003 00:01:18 +0100 To: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> <20030317061011.GH23355@perrin.int.nxad.com> <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> <495.1047882860@sss.pgh.pa.us> <15804.1047955909@sss.pgh.pa.us> From: Florian Weimer Date: Fri, 21 Mar 2003 00:01:18 +0100 In-Reply-To: <15804.1047955909@sss.pgh.pa.us> (Tom Lane's message of "Mon, 17 Mar 2003 21:51:49 -0500") Message-ID: <87fzphk5hd.fsf@Login.CERT.Uni-Stuttgart.DE> User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200303/143 X-Sequence-Number: 1441 Tom Lane writes: > You definitely need to increase the fsm shared memory parameters. The > default max_fsm_relations is just plain too small (try 1000) and the > default_max_fsm_pages is really only enough for perhaps a 100Mb > database. I'd try bumping it to 100,000. Note you need a postmaster > restart to make these changes take effect. Hmm, are there any guidelines for choosing these values? We have a database with a table into which we insert about 4,000,000 rows each day, and delete another 4,000,000 rows. The total row count is around 40 million, I guess, and the rows are about 150 bytes long. (VACUUM FULL is running at the moment, so I can't check.) The database is used as a research tool, and we run moderately complex ad-hoc queries on it. As a consequence, I don't see much room for optimization. One of the columns is time-based and indexed, so we suffer from the creeping index syndrome. A nightly index rebuild followed by a VACUUM ANALYZE isn't a problem (it takes less than six ours), but this doesn't seem to be enough (we seem to lose disk space nevertheless). I can't afford a regular VACUUM FULL because it takes down the database for over ten hours, and this starts to cut into the working hours no matter when it starts. Can you suggest some tweaks to the FSM values so that we can avoid the full VACUUM? The database runs 7.3.2 and resides on a 4-way Xeon box with 4 GB of RAM and a severely underpowered disk subsystem (Linux software RAID1 on two 10k 36 GB SCSI drives -- don't ask, this database application is nothing but an accident which happened after purchase of the box). -- Florian Weimer Weimer@CERT.Uni-Stuttgart.DE University of Stuttgart http://CERT.Uni-Stuttgart.DE/people/fw/ RUS-CERT fax +49-711-685-5898 From pgsql-performance-owner@postgresql.org Thu Mar 20 18:19:13 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mail01.stbernard.com (mail01.stbernard.com [64.154.93.162]) by postgresql.org (Postfix) with ESMTP id 28085476311; Thu, 20 Mar 2003 18:19:11 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: Help with LIKE Date: Thu, 20 Mar 2003 15:19:13 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Help with LIKE Thread-Index: AcLvK3h1qKUNPIpDSU+ZH9+33WRiaAAC1hSA From: "David Olbersen" To: Cc: X-Archive-Number: 200303/144 X-Sequence-Number: 1442 Josh, > That's what's called an "unanchored text search". That kind=20 > of query cannot be indexed using a regular index. Duh, should have tried the anchors to get what I wanted... > What you need is called "Full Text Indexing" or "Full Text=20 > Search". Check=20 > out two resources: This isn't actually what I was looking for, the anchor works better (only 5= .87 now!) Thanks for the reminder! -------------------------- David Olbersen=20 iGuard Engineer 11415 West Bernardo Court=20 San Diego, CA 92127=20 1-858-676-2277 x2152 From pgsql-performance-owner@postgresql.org Thu Mar 20 18:35:38 2003 X-Original-To: pgsql-performance@postgresql.org Received: from mail01.stbernard.com (mail01.stbernard.com [64.154.93.162]) by postgresql.org (Postfix) with ESMTP id 772F1475AFF for ; Thu, 20 Mar 2003 18:35:36 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: Help with LIKE Date: Thu, 20 Mar 2003 15:35:39 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Help with LIKE Thread-Index: AcLvK3h1qKUNPIpDSU+ZH9+33WRiaAAC1hSAAAB9JwA= From: "David Olbersen" To: X-Archive-Number: 200303/145 X-Sequence-Number: 1443 My mistake, things don't get much better. I'm selecting URLs out of a database like this: SELECT * FROM table WHERE url ~ '^http://.*something.*$'; This still uses a sequential scan but cuts the time down to 76,351 from 212= ,651 using WHERE url LIKE '%something%'; The full text indexing doesn't look quite right as there are no spaces in t= his data. Also, using something like: =20=20 WHERE position( 'something', url ) > 0 is a bit worse, giving 84,259. -------------------------- David Olbersen=20 iGuard Engineer 11415 West Bernardo Court=20 San Diego, CA 92127=20 1-858-676-2277 x2152 > -----Original Message----- > From: David Olbersen=20 > Sent: Thursday, March 20, 2003 3:19 PM > To: pgsql-sql@postgresql.org > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Help with LIKE >=20 >=20 > Josh, >=20 > > That's what's called an "unanchored text search". That kind=20 > > of query cannot be indexed using a regular index. >=20 > Duh, should have tried the anchors to get what I wanted... >=20 > > What you need is called "Full Text Indexing" or "Full Text=20 > > Search". Check=20 > > out two resources: >=20 > This isn't actually what I was looking for, the anchor works=20 > better (only 5.87 now!) >=20 > Thanks for the reminder! >=20 > -------------------------- > David Olbersen=20 > iGuard Engineer > 11415 West Bernardo Court=20 > San Diego, CA 92127=20 > 1-858-676-2277 x2152 >=20 > ---------------------------(end of=20 > broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to=20 > majordomo@postgresql.org >=20 From pgsql-performance-owner@postgresql.org Thu Mar 20 20:27:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 2192F475D91 for ; Thu, 20 Mar 2003 20:27:29 -0500 (EST) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2913050; Thu, 20 Mar 2003 17:27:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "David Olbersen" , Subject: Re: Help with LIKE Date: Thu, 20 Mar 2003 17:27:21 -0800 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303201727.21401.josh@agliodbs.com> X-Archive-Number: 200303/146 X-Sequence-Number: 1444 David, > My mistake, things don't get much better. >=20 > I'm selecting URLs out of a database like this: >=20 > SELECT * FROM table WHERE url ~ '^http://.*something.*$'; That search still requires a seq scan, since it has "gaps" in the seqence o= f=20 characters. That is, url ~ '^http://www.something.*' could use an index, but your search above= =20 cannot. You may be right that the standard OpenFTS indexing won't help you in this= =20 case, since you're really searching for fragments of a continuous text=20 string. One thing I might suggest is that you look for ways that you might be able = to=20 break out the text you're searching for with a function. For example, if y= ou=20 were searching strictly on the domain SLD name, then you could create an=20 "immutable" function called if_split_sld(TEXT) and index on that. If you are really searching for "floating" text within the string, I believ= e=20 that there are some options in tseach to help you, but they may not end up= =20 improving performance much. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Mar 20 21:06:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 965A9475AFF for ; Thu, 20 Mar 2003 21:06:19 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2L26Lub008916; Thu, 20 Mar 2003 21:06:21 -0500 (EST) To: josh@agliodbs.com Cc: "David Olbersen" , pgsql-performance@postgresql.org Subject: Re: Help with LIKE In-reply-to: <200303201727.21401.josh@agliodbs.com> References: <200303201727.21401.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Thu, 20 Mar 2003 17:27:21 -0800" Date: Thu, 20 Mar 2003 21:06:21 -0500 Message-ID: <8915.1048212381@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/147 X-Sequence-Number: 1445 Josh Berkus writes: >> SELECT * FROM table WHERE url ~ '^http://.*something.*$'; > That search still requires a seq scan, since it has "gaps" in the seqence of > characters. That is, > url ~ '^http://www.something.*' could use an index, but your search above > cannot. Actually, it *can* use an index ... but the index condition will only use the characters before the ".*", ie, "http://". Which is just about useless if you're searching a column of URLs :-( I agree that tsearch or OpenFTS are the tools to be looking at. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Mar 20 22:39:07 2003 X-Original-To: pgsql-performance@postgresql.org Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id CCDD9475AFF for ; Thu, 20 Mar 2003 22:39:02 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h2L3d6D09311 for ; Fri, 21 Mar 2003 09:09:06 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h2L3d6m09306 for ; Fri, 21 Mar 2003 09:09:06 +0530 From: "Shridhar Daithankar" To: pgsql-performance@postgresql.org Subject: Re: Page Size in Future Releases Date: Fri, 21 Mar 2003 09:09:56 +0530 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200303210909.56451.shridhar_daithankar@persistent.co.in> X-Archive-Number: 200303/148 X-Sequence-Number: 1446 On Friday 21 Mar 2003 2:15 am, Kendrick C. Wilson wrote: > Will a increase in the size of a data page increase performance of a > database with large records? > > I have records about 881 byte + 40 byte (header) = 921. > > 8k page size / 921 bytes per record is ONLY 8 records........... You can tweak it yourself at compile time in some header file and that should work but that is a point of diminising results as far as hackers are concerned. One reason I know where it would help is getting postgresql to use tons of shaerd memory. Right now postgresql can not use much beyond 250MB(??) because number of shared buffer are int or something. So if you know your reconrds are large, are often manipulated and your OS is not so good at file caching, then increasing page size might help. Given how good unices are in general in terms of file and memory handling, I woudl say you should not do it unless your average record size is greater than 8K, something like a large genome sequence or so. YMMV.. Shridhar From pgsql-performance-owner@postgresql.org Thu Mar 20 22:48:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 648BF475AFF for ; Thu, 20 Mar 2003 22:48:02 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h2L3m5O10034 for ; Fri, 21 Mar 2003 09:18:05 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h2L3m4m10024; Fri, 21 Mar 2003 09:18:05 +0530 From: "Shridhar Daithankar" To: Florian Weimer Subject: Re: postgresql meltdown on PlanetMath.org Date: Fri, 21 Mar 2003 09:18:54 +0530 User-Agent: KMail/1.5 References: <20030316060125.GD19570@vt.edu> <15804.1047955909@sss.pgh.pa.us> <87fzphk5hd.fsf@Login.CERT.Uni-Stuttgart.DE> In-Reply-To: <87fzphk5hd.fsf@Login.CERT.Uni-Stuttgart.DE> Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200303210918.54380.shridhar_daithankar@persistent.co.in> X-Archive-Number: 200303/149 X-Sequence-Number: 1447 On Friday 21 Mar 2003 4:31 am, Florian Weimer wrote: > Tom Lane writes: > > You definitely need to increase the fsm shared memory parameters. The > > default max_fsm_relations is just plain too small (try 1000) and the > > default_max_fsm_pages is really only enough for perhaps a 100Mb > > database. I'd try bumping it to 100,000. Note you need a postmaster > > restart to make these changes take effect. > > Hmm, are there any guidelines for choosing these values? > > We have a database with a table into which we insert about 4,000,000 > rows each day, and delete another 4,000,000 rows. The total row count > is around 40 million, I guess, and the rows are about 150 bytes long. > (VACUUM FULL is running at the moment, so I can't check.) I suggest you split your tables into exactly similar tables using inheritance. Your queries won't be affected as you can make them on parent table and get same result. But as far as vacuuming goes, you can probably dump a child table entirely and recreate it as a fast alternative to vacuum. Only catch is, I don't know if inherited tables would use their respective indxes other wise your queries might be slow as anything. > One of the columns is time-based and indexed, so we suffer from the > creeping index syndrome. A nightly index rebuild followed by a VACUUM > ANALYZE isn't a problem (it takes less than six ours), but this > doesn't seem to be enough (we seem to lose disk space nevertheless). I am sure a select * from table into another table; drop table; renamre temp table kind of hack would be faster than vacuuming in this case.. This is just a suggestion. Good if this works for you.. Shridhar From pgsql-performance-owner@postgresql.org Thu Mar 20 22:51:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id D3E3B475AFF for ; Thu, 20 Mar 2003 22:51:31 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id h2L3pZN23698 for pgsql-performance@postgresql.org; Fri, 21 Mar 2003 11:51:35 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id h2L3pV723599; Fri, 21 Mar 2003 11:51:31 +0800 (WST) Message-ID: <08ac01c2ef5d$3487fec0$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: , References: <200303210909.56451.shridhar_daithankar@persistent.co.in> Subject: Re: Page Size in Future Releases Date: Fri, 21 Mar 2003 11:51:51 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200303/150 X-Sequence-Number: 1448 > > I have records about 881 byte + 40 byte (header) = 921. > > > > 8k page size / 921 bytes per record is ONLY 8 records........... > > You can tweak it yourself at compile time in some header file and that should > work but that is a point of diminising results as far as hackers are > concerned. As far as I'm aware the 8k page size has nothing to do with speed and everything to do with atomic writes. You can't be guaranteed that the O/S and hard drive controller will write anything more than 8K in an atomic block... Chris From pgsql-performance-owner@postgresql.org Thu Mar 20 23:04:10 2003 X-Original-To: pgsql-performance@postgresql.org Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 40EBB475CBC for ; Thu, 20 Mar 2003 23:04:09 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2913230; Thu, 20 Mar 2003 20:04:02 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Shridhar Daithankar" , pgsql-performance@postgresql.org Subject: Re: Page Size in Future Releases Date: Thu, 20 Mar 2003 20:03:41 -0800 User-Agent: KMail/1.4.3 References: <200303210909.56451.shridhar_daithankar@persistent.co.in> In-Reply-To: <200303210909.56451.shridhar_daithankar@persistent.co.in> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200303202003.41383.josh@agliodbs.com> X-Archive-Number: 200303/151 X-Sequence-Number: 1449 Shridar, > One reason I know where it would help is getting postgresql to use tons of > shaerd memory. Right now postgresql can not use much beyond 250MB(??) > because number of shared buffer are int or something. So if you know your > reconrds are large, are often manipulated and your OS is not so good at > file caching, then increasing page size might help. Um, two fallacies: 1) You can allocate as much shared buffer ram as you want. The maxium I've tested is 300mb, personally, but I know of no hard limit. 2) However, allocating more shared buffer ram ... in fact anything beyond about 40mb ... has never been shown by anyone on this list to be helpful for any size database, and sometimes the contrary. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Mar 21 01:18:39 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B672A47637E for ; Fri, 21 Mar 2003 01:18:34 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2L6IWub010491; Fri, 21 Mar 2003 01:18:33 -0500 (EST) To: Florian Weimer Cc: pgsql-performance@postgresql.org Subject: Re: postgresql meltdown on PlanetMath.org In-reply-to: <87fzphk5hd.fsf@Login.CERT.Uni-Stuttgart.DE> References: <20030316060125.GD19570@vt.edu> <3E741B93.1090203@joeconway.com> <20030316075206.GE19570@vt.edu> <20030317061011.GH23355@perrin.int.nxad.com> <33137.130.15.224.150.1047881939.squirrel@mailbox.samurai.com> <495.1047882860@sss.pgh.pa.us> <15804.1047955909@sss.pgh.pa.us> <87fzphk5hd.fsf@Login.CERT.Uni-Stuttgart.DE> Comments: In-reply-to Florian Weimer message dated "Fri, 21 Mar 2003 00:01:18 +0100" Date: Fri, 21 Mar 2003 01:18:32 -0500 Message-ID: <10490.1048227512@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/152 X-Sequence-Number: 1450 Florian Weimer writes: > Hmm, are there any guidelines for choosing these values? > We have a database with a table into which we insert about 4,000,000 > rows each day, and delete another 4,000,000 rows. The total row count > is around 40 million, I guess, and the rows are about 150 bytes long. If you are replacing 10% of the rows in the table every day, then it's a pretty good bet that every single page of the table contains free space. Accordingly, you'd better set max_fsm_pages large enough to have a FSM slot for every page of the table. (1 page = 8Kb normally) You could possibly get away with a smaller FSM if you do (non-FULL) vacuums more often than once a day. Some people find they can run background vacuums without hurting performance too much, some don't --- I suspect it depends on how much spare disk bandwidth you have. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Mar 21 21:10:11 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8AF5E47636F for ; Fri, 21 Mar 2003 21:10:09 -0500 (EST) Received: from kant.catalyst.net.nz (203-96-145-95.adsl.paradise.net.nz [203.96.145.95]) by postgresql.org (Postfix) with ESMTP id E26B447636C for ; Fri, 21 Mar 2003 21:10:08 -0500 (EST) Received: from 127.0.0.1 (ident=unknown) by kant.catalyst.net.nz with esmtp (masqmail 0.2.19) id 18wSmJ-73c-00; Sat, 22 Mar 2003 08:06:11 +1200 Subject: Re: Make PGSQL faster From: Andrew McMillan To: Torsten Schulz Cc: pgsql-performance@postgresql.org In-Reply-To: <3E7A0E27.7040805@gmx.net> References: <3E7A0E27.7040805@gmx.net> Content-Type: text/plain Organization: Message-Id: <1048277170.32501.2459.camel@kant.mcmillan.net.nz> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 22 Mar 2003 08:06:11 +1200 Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-31.9 required=5.0 tests=DATE_IN_PAST_06_12,EMAIL_ATTRIBUTION,IN_REP_TO, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50-cvs X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50-cvs (1.172-2003-02-14-exp) X-Archive-Number: 200303/154 X-Sequence-Number: 1452 On Fri, 2003-03-21 at 06:53, Torsten Schulz wrote: > Hi, > > we have a great Database with Postgres. It is a Community. > > We have a Dual-CPU-System with 1 GB RAM > > It works on Apache with PHP. But we hadn't enough Performance. > > What's the optimized configuration with many Database-actions on great > tables in a lapp-system? It is hard to say without more information, but it may be that you should increase the buffers used by postgres - 1000 is a good starting point. My experience suggests that performance is not a 'general' thing applying to the whole application but in most cases the bad performance will be one query out of a hundred. In my applications I wrap my calls to PostgreSQL so I can log the amount of time each query took (in microseconds). Then when I have a query that takes 10mS, I know I can ignore it and concentrate on the one that takes 20000mS instead. Regards, Andrew. -- --------------------------------------------------------------------- Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267 Survey for nothing with http://survey.net.nz/ --------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Fri Mar 21 19:15:24 2003 X-Original-To: pgsql-performance@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 66995475AD4 for ; Fri, 21 Mar 2003 19:15:22 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2M0FNub016705; Fri, 21 Mar 2003 19:15:23 -0500 (EST) To: "Kendrick C. Wilson" Cc: pgsql-performance@postgresql.org Subject: Re: Page Size in Future Releases In-reply-to: References: Comments: In-reply-to "Kendrick C. Wilson" message dated "Thu, 20 Mar 2003 14:45:24 -0600" Date: Fri, 21 Mar 2003 19:15:23 -0500 Message-ID: <16704.1048292123@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/153 X-Sequence-Number: 1451 "Kendrick C. Wilson" writes: > Will a increase in the size of a data page increase performance of a > database with large records? Probably not; in fact the increased WAL overhead could make it a net loss. But feel free to try changing BLCKSZ to see how it works for you. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Mar 23 03:45:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 147FB475D3B for ; Sun, 23 Mar 2003 03:45:26 -0500 (EST) Received: from relay.icomedias.com (relay.icomedias.com [62.99.232.66]) by postgresql.org (Postfix) with ESMTP id 2DC21474E42 for ; Sun, 23 Mar 2003 03:45:25 -0500 (EST) Received: from loki.icomedias.com ([10.192.17.128]) by relay.icomedias.com (8.12.8/8.12.8) with ESMTP id h2N8jOsl010778 for ; Sun, 23 Mar 2003 09:45:24 +0100 From: Mario Weilguni To: pgsql-performance@postgresql.org Subject: Re: Page Size in Future Releases Date: Sun, 23 Mar 2003 09:46:41 +0100 User-Agent: KMail/1.5 References: <16704.1048292123@sss.pgh.pa.us> In-Reply-To: <16704.1048292123@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200303230946.41441.mweilguni@sime.com> avpresult: 0, ok, ok X-Scanned-By: MIMEDefang 2.16 (www . roaringpenguin . com / mimedefang) X-Spam-Status: No, hits=-19.6 required=5.0 tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT autolearn=ham version=2.50-cvs X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50-cvs (1.172-2003-02-14-exp) X-Archive-Number: 200303/155 X-Sequence-Number: 1453 Am Samstag, 22. M=E4rz 2003 01:15 schrieb Tom Lane: > "Kendrick C. Wilson" writes: > > Will a increase in the size of a data page increase performance of a > > database with large records? > > Probably not; in fact the increased WAL overhead could make it a net > loss. But feel free to try changing BLCKSZ to see how it works for you. I've several database with 32KB and 8KB, and though the results are not rea= lly comparable due to slight different hardware, I've the feeling that 8KB = buffers work best in most cases. The only difference I noticed are large ob= jects which seem to work slightly better with larger sizes. Regards, Mario Weilguni From pgsql-performance-owner@postgresql.org Sun Mar 23 12:38:54 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0F274474E53 for ; Sun, 23 Mar 2003 12:38:53 -0500 (EST) Received: from mxzilla1.xs4all.nl (mxzilla1.xs4all.nl [194.109.6.54]) by postgresql.org (Postfix) with ESMTP id 62C7E474E44 for ; Sun, 23 Mar 2003 12:38:52 -0500 (EST) Received: from webmail3.xs4all.nl (webmail2.xs4all.nl [194.109.127.35] (may be forged)) by mxzilla1.xs4all.nl (8.12.3/8.12.3) with ESMTP id h2NHcuh2044173 for ; Sun, 23 Mar 2003 18:38:57 +0100 (CET) Received: (from nobody@localhost) by webmail3.xs4all.nl (8.11.6/8.11.1) id h2NHcwn62885; Sun, 23 Mar 2003 18:38:58 +0100 (CET) (envelope-from bsamwel@xs4all.nl) X-Authentication-Warning: webmail3.xs4all.nl: nobody set sender to bsamwel@xs4all.nl using -f Received: from 194.109.187.67 (SquirrelMail authenticated user bsamwel) by webmail.xs4all.nl with HTTP; Sun, 23 Mar 2003 18:38:58 +0100 (CET) Message-ID: <21139.194.109.187.67.1048441138.squirrel@webmail.xs4all.nl> Date: Sun, 23 Mar 2003 18:38:58 +0100 (CET) Subject: Slow update of indexed column with many nulls From: bsamwel@xs4all.nl To: pgsql-performance@postgresql.org Reply-To: bsamwel@xs4all.nl X-Mailer: SquirrelMail (version 1.3.2 [CVS-DEVEL]) MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Spam-Status: No, hits=-0.8 required=5.0 tests=NO_REAL_NAME,X_AUTH_WARNING version=2.50-cvs X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50-cvs (1.172-2003-02-14-exp) X-Archive-Number: 200303/156 X-Sequence-Number: 1454 Hi everybody, I'm having a performance problem, PostgreSQL (7.3.2) is skipping some optimisation options that it shouldn't IMO. It can be fully reproduced as follows: create table foo( bar char(100), baz integer ); Now create a file with 1.2 million empty lines and do a \copy foo (bar) from 'thatfile'. This should fill the table with 1.2 million rows. Now do: insert into foo (baz) values (28); create index foo_idx on foo(baz); vacuum full analyze foo; Now, we would expect that PostgreSQL is fully aware that there are not many rows in foo that have "baz is not null". However: bsamwel=> explain update foo set baz=null where baz is not null; QUERY PLAN --------------------------------------------------------------- Seq Scan on foo (cost=0.00..34470.09 rows=1286146 width=110) Filter: (baz IS NOT NULL) (2 rows) So, it thinks it must do a sequential scan on foo, even though it should know by now that foo.baz is really mostly null. Even if I disable sequential scan it still chooses this option! Why doesn't it use the index? It doesn't use the index either when I try to select all rows that are not null. Just for completeness' sake I'll give you the explain analyze: bsamwel=> explain analyze update foo set baz=null where baz is not null; QUERY PLAN --------------------------------------------------------------------------------------------------------------- Seq Scan on foo (cost=0.00..34470.09 rows=1286146 width=110) (actual time=19678.82..19678.84 rows=1 loops=1) Filter: (baz IS NOT NULL) Total runtime: 19750.21 msec (3 rows) Do you guys have any idea? Regards, Bart From pgsql-performance-owner@postgresql.org Sun Mar 23 12:58:20 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5482D474E53 for ; Sun, 23 Mar 2003 12:58:18 -0500 (EST) Received: from mxzilla3.xs4all.nl (mxzilla3.xs4all.nl [194.109.6.49]) by postgresql.org (Postfix) with ESMTP id 9102F474E44 for ; Sun, 23 Mar 2003 12:58:17 -0500 (EST) Received: from webmail3.xs4all.nl (webmail2.xs4all.nl [194.109.127.35] (may be forged)) by mxzilla3.xs4all.nl (8.12.3/8.12.3) with ESMTP id h2NHwMwc047365 for ; Sun, 23 Mar 2003 18:58:22 +0100 (CET) Received: (from nobody@localhost) by webmail3.xs4all.nl (8.11.6/8.11.1) id h2NHwOE64489; Sun, 23 Mar 2003 18:58:24 +0100 (CET) (envelope-from bsamwel@xs4all.nl) X-Authentication-Warning: webmail3.xs4all.nl: nobody set sender to bsamwel@xs4all.nl using -f Received: from 194.109.187.67 (SquirrelMail authenticated user bsamwel) by webmail.xs4all.nl with HTTP; Sun, 23 Mar 2003 18:58:24 +0100 (CET) Message-ID: <20505.194.109.187.67.1048442304.squirrel@webmail.xs4all.nl> Date: Sun, 23 Mar 2003 18:58:24 +0100 (CET) Subject: Adding a foreign key constraint is extremely slow From: bsamwel@xs4all.nl To: pgsql-performance@postgresql.org Reply-To: bsamwel@xs4all.nl X-Mailer: SquirrelMail (version 1.3.2 [CVS-DEVEL]) MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Spam-Status: No, hits=-0.8 required=5.0 tests=NO_REAL_NAME,X_AUTH_WARNING version=2.50-cvs X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50-cvs (1.172-2003-02-14-exp) X-Archive-Number: 200303/157 X-Sequence-Number: 1455 Hi guys, I'm having another performance problem as well. I have two tables called "wwwlog" (about 100 bytes per row, 1.2 million records) and table called "triples" (about 20 bytes per row, 0.9 million records). Triples contains an integer foreign key to wwwlog, but it was not marked as a foreign key at the point of table creation. Now, when I do: alter table triples add foreign key(id1) references wwwlog(id); PostgreSQL starts doing heavy work for at least one and a half hour, and I broke it off at that. It is not possible to "explain" a statement like this! Probably what it does is that it will check the foreign key constraint for every field in the table. This will make it completely impossible to load my data, because: (1) I cannot set the foreign key constraints BEFORE loading the 0.9 million records, because that would cause the checks to take place during loading. (2) I cannot set the foreign key constraints AFTER loading the 0.9 million records because I've got no clue at all how long this operation is going to take. (3) Table "triples" contains two more foreign keys to the same wwwlog key. This means I've got to do the same thing two more times after the first one is finished. I find this behaviour very annoying, because it is possible to optimize a check like this very well, for instance by creating a temporary data set containing the union of all foreign keys and all primary keys of the original table, augmented with an extra field "pri" which is 1 if the record comes from the primary keys and 0 otherwise. Say this data is contained in a temporary table called "t" with columns "key" and "pri" for the data. One would then be able to do the check like this: NOT EXISTS( SELECT key,sum(pri) FROM t GROUP BY key HAVING sum(pri) = 0 ); This means that there must not exist a group of "key" values that does not have a primary key somewhere in the set. This query is extremely easy to execute and would be done in a few seconds. Does anyone know of a way of adding foreign key constraints faster in PostgreSQL? Or, if there is no solution, do you guys know of any reasons why a solution like the one I described above would or would not work, and could or could not be built into PostgreSQL at some point? Regards, Bart From pgsql-performance-owner@postgresql.org Sun Mar 23 14:30:06 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D2EA1475F16 for ; Sun, 23 Mar 2003 14:30:04 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 78CA0475F09 for ; Sun, 23 Mar 2003 14:30:04 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 5C1BBD600; Sun, 23 Mar 2003 11:30:04 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 41A835C03; Sun, 23 Mar 2003 11:30:04 -0800 (PST) Date: Sun, 23 Mar 2003 11:30:04 -0800 (PST) From: Stephan Szabo To: Cc: Subject: Re: Adding a foreign key constraint is extremely slow In-Reply-To: <20505.194.109.187.67.1048442304.squirrel@webmail.xs4all.nl> Message-ID: <20030323112241.W14634-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-19.5 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50-cvs X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50-cvs (1.172-2003-02-14-exp) X-Archive-Number: 200303/158 X-Sequence-Number: 1456 On Sun, 23 Mar 2003 bsamwel@xs4all.nl wrote: > Hi guys, > > I'm having another performance problem as well. I have two tables called > "wwwlog" (about 100 bytes per row, 1.2 million records) and table called > "triples" (about 20 bytes per row, 0.9 million records). Triples contains > an integer foreign key to wwwlog, but it was not marked as a foreign key > at the point of table creation. Now, when I do: > > alter table triples add foreign key(id1) references wwwlog(id); > > PostgreSQL starts doing heavy work for at least one and a half hour, and I > broke it off at that. It is not possible to "explain" a statement like > this! Probably what it does is that it will check the foreign key > constraint for every field in the table. This will make it completely In fact it does exactly this. It could be done using select * from fk where not exists (select * from pk where ...) or another optimized method, but noone's gotten to changing it. I didn't do it in the start becase I didn't want to duplicate the check logic if it could be helped. As a temporary workaround until something is done(assuming you know the data is valid), set the constraints before loading then turn off triggers on the tables (see pg_dump's data only output for an example), load the data and turn them back on. From pgsql-performance-owner@postgresql.org Sun Mar 23 16:55:57 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6DC4C475A4B for ; Sun, 23 Mar 2003 16:55:55 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 134D7475A45 for ; Sun, 23 Mar 2003 16:55:55 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2918859; Sun, 23 Mar 2003 13:55:46 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: bsamwel@xs4all.nl, pgsql-performance@postgresql.org Subject: Re: Slow update of indexed column with many nulls Date: Sun, 23 Mar 2003 13:55:02 -0800 User-Agent: KMail/1.4.3 References: <21139.194.109.187.67.1048441138.squirrel@webmail.xs4all.nl> In-Reply-To: <21139.194.109.187.67.1048441138.squirrel@webmail.xs4all.nl> MIME-Version: 1.0 Message-Id: <200303231355.02826.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-25.4 required=5.0 tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_KMAIL autolearn=ham version=2.50-cvs X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50-cvs (1.172-2003-02-14-exp) X-Archive-Number: 200303/159 X-Sequence-Number: 1457 Bart, > insert into foo (baz) values (28); > create index foo_idx on foo(baz); > vacuum full analyze foo; > > Now, we would expect that PostgreSQL is fully aware that there are not > many rows in foo that have "baz is not null". However: This is a known issue discussed several times on this list. Try re-creati= ng=20 your index as: create index foo_idx on foo(baz) where foo is not null; See the list archives for the reasons why. This may improve in future=20 releases of PostgreSQL. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Mar 24 13:45:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 90A4F476241 for ; Mon, 24 Mar 2003 13:45:46 -0500 (EST) Received: from Mail (mail.waterford.org [205.124.117.40]) by postgresql.org (Postfix) with ESMTP id B0D1F4761C0 for ; Mon, 24 Mar 2003 13:45:44 -0500 (EST) Received: by Mail with XWall v3.25 ; Mon, 24 Mar 2003 10:45:23 -0700 From: Oleg Lebedev To: "pgsql-performance@postgresql.org" Subject: Slow query Date: Mon, 24 Mar 2003 10:48:52 -0700 X-Assembled-By: XWall v3.25 Message-ID: <993DBE5B4D02194382EC8DF8554A5273113E5A@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb" X-Spam-Status: No, hits=-5.0 required=5.0 tests=BAYES_10,MIME_BOUND_NEXTPART,MIME_SUSPECT_NAME, TO_ADDRESS_EQ_REAL version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/160 X-Sequence-Number: 1458 This is a multi part message in MIME format. --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: multipart/alternative; boundary="_NextPart_2_pSwAJCCvjOFJEEEBjzylneexksz" --_NextPart_2_pSwAJCCvjOFJEEEBjzylneexksz Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please help me speed up the following query. It used to run in 2-5 sec., but now it takes 2-3 mins! I ran VACUUM FULL ANALYZE and REINDEX. SELECT * FROM media m WHERE m.mediatype =3D (SELECT objectid FROM mediatype WHERE medianame=3D'Audio')=20 AND EXISTS=20 (SELECT * FROM=20 (SELECT objectid AS mediaid=20 FROM media=20 WHERE activity=3D'347667'=20 UNION=20 SELECT ism.media AS mediaid=20 FROM intsetmedia ism, set s=20 WHERE ism.set =3D s.objectid=20 AND s.activity=3D'347667' ) AS a1=20 WHERE a1.mediaid =3D m.objectid=20 LIMIT 1)=20 ORDER BY medianame ASC, status DESC=20 =20 Basically it tries to find all Audios that are either explicitly attached to the given activity, or attached to the given activity via a many-to-many relationship intsetmedia which links records in table Interaction, Set, and Media. I attached the output of EXPLAIN and schemas and indexes on the tables involved. Most of the fields are not relevant to the query, but I listed them anyways. I discarded trigger information, though. Thanks for your help. =20 Oleg ************************************* This email may contain privileged or confidential material intended for the= named recipient only. If you are not the named recipient, delete this message and all attachments= .=20=20 Any review, copying, printing, disclosure or other use is prohibited. We reserve the right to monitor email sent through our network. ************************************* --_NextPart_2_pSwAJCCvjOFJEEEBjzylneexksz Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message
Please he= lp me speed=20 up the following query. It used to run in 2-5 sec., but now it takes 2-3=20 mins!
I ran VAC= UUM FULL=20 ANALYZE and REINDEX.
SELECT * = FROM media=20 m
WHERE m.m= ediatype =3D=20 (SELECT objectid FROM mediatype WHERE medianame=3D'Audio')
AND EXIST= S=20
        (SELECT * FROM=20
           =     =20 (SELECT objectid AS mediaid
           =     =20 FROM media
           =     =20 WHERE activity=3D'347667'
           =     =20 UNION
           =     =20 SELECT ism.media AS mediaid
           =     =20 FROM intsetmedia ism, set s
           =     =20 WHERE ism.set =3D s.objectid
           =     =20 AND s.activity=3D'347667' ) AS a1
        WHERE a1.mediaid =3D m.= objectid=20
        LIMIT 1) =
ORDER BY medianame ASC, status DESC
 
Basically= it tries=20 to find all Audios that are either explicitly attached to the given activit= y, or=20 attached to the given activity via a many-to-many relationship intsetmedia = which=20 links records in table Interaction, Set, and Media.
I attache= d the=20 output of EXPLAIN and schemas and indexes on the tables involved. Most of t= he=20 fields are not relevant to the query, but I listed them anyways. I discarde= d=20 trigger information, though.
Thanks fo= r your=20 help.
 
Oleg

*************************************

This email may contain privileged or confidential material intended for the= named recipient only.
If you are not the named recipient, delete this message and all attachments= .
Any review, copying, printing, disclosure or other use is prohibited.
We reserve the right to monitor email sent through our network.

*************************************

--_NextPart_2_pSwAJCCvjOFJEEEBjzylneexksz-- --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="plan.txt" Content-Disposition: attachment; filename="plan.txt" Content-Transfer-Encoding: base64 UVVFUlkgUExBTiANCiBTb3J0IChjb3N0PTU1MzY1Ny42Ni4uNTUzNjYyLjU3 IHJvd3M9MTk2MyB3aWR0aD0yMTgpIA0KICBTb3J0IEtleTogbWVkaWFuYW1l LCBzdGF0dXMgDQogIEluaXRQbGFuIA0KICAtPiBTZXEgU2NhbiBvbiBtZWRp YXR5cGUgKGNvc3Q9MC4wMC4uMS4yOSByb3dzPTEgd2lkdGg9OCkgDQogIEZp bHRlcjogKG1lZGlhbmFtZSA9ICdBdWRpbyc6OmNoYXJhY3RlciB2YXJ5aW5n KSANCiAgLT4gSW5kZXggU2NhbiB1c2luZyBtZWRpYV9tdHlwZV9pbmRleCBv biBtZWRpYSBtIChjb3N0PTAuMDAuLjU1MzU1MC4yOCByb3dzPTE5NjMgd2lk dGg9MjE4KSANCiAgSW5kZXggQ29uZDogKG1lZGlhdHlwZSA9ICQwKSANCiAg RmlsdGVyOiAoc3VicGxhbikgDQogIFN1YlBsYW4gDQogIC0+IExpbWl0IChj b3N0PTEzOC45Mi4uMTM4LjkzIHJvd3M9MSB3aWR0aD0yNCkgDQogIC0+IFN1 YnF1ZXJ5IFNjYW4gYTEgKGNvc3Q9MTM4LjkyLi4xMzguOTMgcm93cz0xIHdp ZHRoPTI0KSANCiAgLT4gVW5pcXVlIChjb3N0PTEzOC45Mi4uMTM4LjkzIHJv d3M9MSB3aWR0aD0yNCkgDQogIC0+IFNvcnQgKGNvc3Q9MTM4LjkyLi4xMzgu OTMgcm93cz0yIHdpZHRoPTI0KSANCiAgU29ydCBLZXk6IG1lZGlhaWQgDQog IC0+IEFwcGVuZCAoY29zdD0wLjAwLi4xMzguOTEgcm93cz0yIHdpZHRoPTI0 KSANCiAgLT4gU3VicXVlcnkgU2NhbiAiKlNFTEVDVCogMSIgKGNvc3Q9MC4w MC4uNS4xMSByb3dzPTEgd2lkdGg9OCkgDQogIC0+IEluZGV4IFNjYW4gdXNp bmcgbWVkaWFfcGtleSBvbiBtZWRpYSAoY29zdD0wLjAwLi41LjExIHJvd3M9 MSB3aWR0aD04KSANCiAgSW5kZXggQ29uZDogKG9iamVjdGlkID0gJDEpIA0K ICBGaWx0ZXI6IChhY3Rpdml0eSA9IDM0NzY2Nzo6YmlnaW50KSANCiAgLT4g U3VicXVlcnkgU2NhbiAiKlNFTEVDVCogMiIgKGNvc3Q9MjQuMjUuLjEzMy44 MCByb3dzPTEgd2lkdGg9MjQpIA0KICAtPiBIYXNoIEpvaW4gKGNvc3Q9MjQu MjUuLjEzMy44MCByb3dzPTEgd2lkdGg9MjQpIA0KICBIYXNoIENvbmQ6ICgi b3V0ZXIiLiJzZXQiID0gImlubmVyIi5vYmplY3RpZCkgDQogIC0+IEluZGV4 IFNjYW4gdXNpbmcgaW50c2V0bWVkaWFfbWVkaWFfaW5kZXggb24gaW50c2V0 bWVkaWEgaXNtIChjb3N0PTAuMDAuLjEwOS4yNiByb3dzPTM4IHdpZHRoPTE2 KSANCiAgSW5kZXggQ29uZDogKG1lZGlhID0gJDEpIA0KICAtPiBIYXNoIChj b3N0PTI0LjI0Li4yNC4yNCByb3dzPTYgd2lkdGg9OCkgDQogIC0+IEluZGV4 IFNjYW4gdXNpbmcgc2V0X2FjdF9pbmRleCBvbiAic2V0IiBzIChjb3N0PTAu MDAuLjI0LjI0IHJvd3M9NiB3aWR0aD04KSANCiAgSW5kZXggQ29uZDogKGFj dGl2aXR5ID0gMzQ3NjY3OjpiaWdpbnQpIA0K --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="schemas.txt" Content-Disposition: attachment; filename="schemas.txt" Content-Transfer-Encoding: base64 ICAgICBUYWJsZSAicHVibGljLmludHNldG1lZGlhIg0KICAgIENvbHVtbiAg ICAgfCAgVHlwZSAgIHwgTW9kaWZpZXJzIA0KLS0tLS0tLS0tLS0tLS0tKy0t LS0tLS0tLSstLS0tLS0tLS0tLQ0KIGludGVyYWN0aW9uICAgfCBiaWdpbnQg IHwgbm90IG51bGwNCiBzZXQgICAgICAgICAgIHwgYmlnaW50ICB8IG5vdCBu dWxsDQogbWVkaWEgICAgICAgICB8IGJpZ2ludCAgfCBub3QgbnVsbA0KIG9i amVjdGlkICAgICAgfCBiaWdpbnQgIHwgbm90IG51bGwNCiBvYmplY3R2ZXJz aW9uIHwgaW50ZWdlciB8IG5vdCBudWxsDQpJbmRleGVzOiBpbnRzZXRtZWRp YV9wa2V5IHByaW1hcnkga2V5IGJ0cmVlIChvYmplY3RpZCksDQogICAgICAg ICBpbnRzZXRtZWRpYV9pc21faW5kZXggdW5pcXVlIGJ0cmVlIChpbnRlcmFj dGlvbiwgInNldCIsIG1lZGlhKSwNCiAgICAgICAgIGludHNldG1lZGlhX21l ZGlhX2luZGV4IGJ0cmVlIChtZWRpYSksDQogICAgICAgICBpbnRzZXRtZWRp YV9zZXRfaW5kZXggYnRyZWUgKCJzZXQiKQ0KDQoNCiAgICAgICAgICAgICAg ICAgICAgVGFibGUgInB1YmxpYy5pbnRlcmFjdGlvbiINCiAgICAgQ29sdW1u ICAgICB8ICAgICAgICAgIFR5cGUgICAgICAgICAgfCAgICAgICBNb2RpZmll cnMgICAgICAgIA0KLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQogaW50ZGVzYyAg ICAgICAgfCBjaGFyYWN0ZXIgdmFyeWluZygyNTYpIHwgbm90IG51bGwgZGVm YXVsdCAnJw0KIHN0YXRlICAgICAgICAgIHwgYmlnaW50ICAgICAgICAgICAg ICAgICB8IA0KIGludHR5cGUgICAgICAgIHwgY2hhcmFjdGVyIHZhcnlpbmco MzIpICB8IG5vdCBudWxsIGRlZmF1bHQgJycNCiBudW1iZXIgICAgICAgICB8 IGludGVnZXIgICAgICAgICAgICAgICAgfCBub3QgbnVsbA0KIHZpZGVvICAg ICAgICAgIHwgYmlnaW50ICAgICAgICAgICAgICAgICB8IA0KIG5lZWRzZGF0 YXRhYmxlIHwgYm9vbGVhbiAgICAgICAgICAgICAgICB8IG5vdCBudWxsIGRl ZmF1bHQgZmFsc2UNCiBvYmplY3RpZCAgICAgICB8IGJpZ2ludCAgICAgICAg ICAgICAgICAgfCBub3QgbnVsbA0KIG9iamVjdHZlcnNpb24gIHwgaW50ZWdl ciAgICAgICAgICAgICAgICB8IG5vdCBudWxsDQpJbmRleGVzOiBpbnRlcmFj dGlvbl9wa2V5IHByaW1hcnkga2V5IGJ0cmVlIChvYmplY3RpZCkNCg0KDQoN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFRhYmxl ICJwdWJsaWMuc2V0Ig0KICAgICAgQ29sdW1uICAgICAgfCAgICAgICAgICAg IFR5cGUgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgDQpNb2Rp ZmllcnMgICAgICAgICAgICAgICAgICAgICANCi0tLS0tLS0tLS0tLS0tLS0t LSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0t LS0tLS0tLS0tLQ0KLS0tLS0tLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0K IHJlZmVyZW5jZSAgICAgICAgfCBpbnRlZ2VyICAgICAgICAgICAgICAgICAg ICAgfCBub3QgbnVsbA0KIGFjdGl2aXR5ICAgICAgICAgfCBiaWdpbnQgICAg ICAgICAgICAgICAgICAgICAgfCBub3QgbnVsbA0KIHNjZW5lICAgICAgICAg ICAgfCBiaWdpbnQgICAgICAgICAgICAgICAgICAgICAgfCANCiBzZXRkZXNj ICAgICAgICAgIHwgY2hhcmFjdGVyIHZhcnlpbmcoNDAwMCkgICAgIHwgbm90 IG51bGwgZGVmYXVsdCAnTm8gc2V0IA0KZGVzY3JpcHRpb24gYXZhaWxhYmxl LicNCiBhY3R0eXBlICAgICAgICAgIHwgYmlnaW50ICAgICAgICAgICAgICAg ICAgICAgIHwgbm90IG51bGwNCiBtZW51dHlwZSAgICAgICAgIHwgYmlnaW50 ICAgICAgICAgICAgICAgICAgICAgIHwgbm90IG51bGwNCiByZW1lZGlhdGUg ICAgICAgIHwgYm9vbGVhbiAgICAgICAgICAgICAgICAgICAgIHwgZGVmYXVs dCBmYWxzZQ0KIG5vcm1hbCAgICAgICAgICAgfCBib29sZWFuICAgICAgICAg ICAgICAgICAgICAgfCBkZWZhdWx0IGZhbHNlDQogcGxheXByYWN0aWNlICAg ICB8IGJvb2xlYW4gICAgICAgICAgICAgICAgICAgICB8IGRlZmF1bHQgZmFs c2UNCiBmaXJzdHRpbWVvbmx5ICAgIHwgYm9vbGVhbiAgICAgICAgICAgICAg ICAgICAgIHwgZGVmYXVsdCBmYWxzZQ0KIGF2ZXRpbWUgICAgICAgICAgfCBp bnRlZ2VyICAgICAgICAgICAgICAgICAgICAgfCANCiBtZW51aW1hZ2UgICAg ICAgIHwgY2hhcmFjdGVyIHZhcnlpbmcoMjU2KSAgICAgIHwgZGVmYXVsdCAn Jw0KIHNjb3JlcyAgICAgICAgICAgfCBib29sZWFuICAgICAgICAgICAgICAg ICAgICAgfCBkZWZhdWx0IGZhbHNlDQogbWlucnVuICAgICAgICAgICB8IGlu dGVnZXIgICAgICAgICAgICAgICAgICAgICB8IA0KIG1heHJ1biAgICAgICAg ICAgfCBpbnRlZ2VyICAgICAgICAgICAgICAgICAgICAgfCANCiBpZ25vcmV0 eXBlICAgICAgIHwgYm9vbGVhbiAgICAgICAgICAgICAgICAgICAgIHwgZGVm YXVsdCBmYWxzZQ0KIGF1dG9tYXRpY2l0eSAgICAgfCBpbnRlZ2VyICAgICAg ICAgICAgICAgICAgICAgfCANCiByZXZpZXcgICAgICAgICAgIHwgYm9vbGVh biAgICAgICAgICAgICAgICAgICAgIHwgZGVmYXVsdCBmYWxzZQ0KIGxlYXJu aW5nb2JqICAgICAgfCBjaGFyYWN0ZXIgdmFyeWluZygyNTYpICAgICAgfCBk ZWZhdWx0ICcnDQogc2V0bmFtZSAgICAgICAgICB8IGNoYXJhY3RlciB2YXJ5 aW5nKDY0KSAgICAgICB8IGRlZmF1bHQgJycNCiBvYmplY3RpZCAgICAgICAg IHwgYmlnaW50ICAgICAgICAgICAgICAgICAgICAgIHwgbm90IG51bGwNCiBv YmplY3R2ZXJzaW9uICAgIHwgaW50ZWdlciAgICAgICAgICAgICAgICAgICAg IHwgbm90IG51bGwNCiBpY29uICAgICAgICAgICAgIHwgY2hhcmFjdGVyIHZh cnlpbmcoNjQpICAgICAgIHwgDQogY29kZXN0YXR1cyAgICAgICB8IGJpZ2lu dCAgICAgICAgICAgICAgICAgICAgICB8IG5vdCBudWxsDQogc3RhdHVzY2hh bmdlZGF0ZSB8IHRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSB8IA0KIGNv bnNpZGVyYXRpb25zICAgfCBjaGFyYWN0ZXIgdmFyeWluZygyNTYpICAgICAg fCANCkluZGV4ZXM6IHNldF9wa2V5IHByaW1hcnkga2V5IGJ0cmVlIChvYmpl Y3RpZCksDQogICAgICAgICBzZXRfYWN0X2luZGV4IGJ0cmVlIChhY3Rpdml0 eSkNCg0KDQoNCg0KICAgICAgICAgICAgICAgICAgICAgICAgIFRhYmxlICJw dWJsaWMubWVkaWEiDQogICAgICBDb2x1bW4gICAgICB8ICAgICAgICAgICAg VHlwZSAgICAgICAgICAgICB8ICAgICAgTW9kaWZpZXJzICAgICAgDQotLS0t LS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0r LS0tLS0tLS0tLS0tLS0tLS0tLS0tDQogbWVkaWF0eXBlICAgICAgICB8IGJp Z2ludCAgICAgICAgICAgICAgICAgICAgICB8IG5vdCBudWxsDQogbWVkaWFj aGFyICAgICAgICB8IGJpZ2ludCAgICAgICAgICAgICAgICAgICAgICB8IA0K IHN0YXR1cyAgICAgICAgICAgfCBjaGFyYWN0ZXIgdmFyeWluZygzMCkgICAg ICAgfCBub3QgbnVsbCBkZWZhdWx0ICcnDQogc29ydCAgICAgICAgICAgICB8 IHJlYWwgICAgICAgICAgICAgICAgICAgICAgICB8IG5vdCBudWxsIGRlZmF1 bHQgMA0KIGZvcm1hdCAgICAgICAgICAgfCBjaGFyYWN0ZXIgdmFyeWluZygz MikgICAgICAgfCBkZWZhdWx0ICcnDQogZmlsZW5hbWUgICAgICAgICB8IGNo YXJhY3RlciB2YXJ5aW5nKDI1NikgICAgICB8IG5vdCBudWxsIGRlZmF1bHQg JycNCiBtZWRpYWRlc2MgICAgICAgIHwgY2hhcmFjdGVyIHZhcnlpbmcoNDAw MCkgICAgIHwgZGVmYXVsdCAnJw0KIG1lZGlhbmFtZSAgICAgICAgfCBjaGFy YWN0ZXIgdmFyeWluZyg0MDAwKSAgICAgfCBub3QgbnVsbCBkZWZhdWx0ICcn DQogdmlkZW8gICAgICAgICAgICB8IGJpZ2ludCAgICAgICAgICAgICAgICAg ICAgICB8IA0KIGhpZ2hsaWdodCAgICAgICAgfCBpbnRlZ2VyICAgICAgICAg ICAgICAgICAgICAgfCBkZWZhdWx0IDANCiBoaWdobGlnaHRlciAgICAgIHwg Y2hhcmFjdGVyIHZhcnlpbmcoMzIpICAgICAgIHwgZGVmYXVsdCAnJw0KIGFj dGl2aXR5ICAgICAgICAgfCBiaWdpbnQgICAgICAgICAgICAgICAgICAgICAg fCBub3QgbnVsbA0KIGxhc3R1cGRhdGVkYnkgICAgfCBjaGFyYWN0ZXIgdmFy eWluZygzMCkgICAgICAgfCBkZWZhdWx0ICcnDQogaGlnaGxpZ2h0ZWRtZWRp YSB8IGJpZ2ludCAgICAgICAgICAgICAgICAgICAgICB8IA0KIGFydHR5cGUg ICAgICAgICAgfCBiaWdpbnQgICAgICAgICAgICAgICAgICAgICAgfCANCiB3 YWl0c3luY21lZGlhICAgIHwgYmlnaW50ICAgICAgICAgICAgICAgICAgICAg IHwgDQoga2V5ICAgICAgICAgICAgICB8IGNoYXJhY3RlciB2YXJ5aW5nKDMy KSAgICAgICB8IGRlZmF1bHQgJycNCiBwcm9kdWN0aW9uY291bnQgIHwgaW50 ZWdlciAgICAgICAgICAgICAgICAgICAgIHwgZGVmYXVsdCAwDQogb2JqZWN0 aWQgICAgICAgICB8IGJpZ2ludCAgICAgICAgICAgICAgICAgICAgICB8IG5v dCBudWxsDQogb2JqZWN0dmVyc2lvbiAgICB8IGludGVnZXIgICAgICAgICAg ICAgICAgICAgICB8IG5vdCBudWxsDQogY3ZzcGF0aHN0YXR1cyAgICB8IGJp Z2ludCAgICAgICAgICAgICAgICAgICAgICB8IG5vdCBudWxsDQogdXBkYXRl ZGF0ZSAgICAgICB8IHRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSB8IA0K SW5kZXhlczogbWVkaWFfcGtleSBwcmltYXJ5IGtleSBidHJlZSAob2JqZWN0 aWQpLA0KICAgICAgICAgbWVkaWFfYWN0X2luZGV4IGJ0cmVlIChhY3Rpdml0 eSksDQogICAgICAgICBtZWRpYV9mbmFtZV9pbmRleCBidHJlZSAoZmlsZW5h bWUpLA0KICAgICAgICAgbWVkaWFfbWNoYXJfaW5kZXggYnRyZWUgKG1lZGlh Y2hhciksDQogICAgICAgICBtZWRpYV9tbmFtZV9pbmRleCBidHJlZSAobWVk aWFuYW1lKSwNCiAgICAgICAgIG1lZGlhX210eXBlX2luZGV4IGJ0cmVlICht ZWRpYXR5cGUpDQo= --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb-- From pgsql-performance-owner@postgresql.org Mon Mar 24 13:54:55 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3450647610A for ; Mon, 24 Mar 2003 13:54:54 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 8A33E475F53 for ; Mon, 24 Mar 2003 13:54:53 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2920293; Mon, 24 Mar 2003 10:54:42 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Oleg Lebedev , "pgsql-performance@postgresql.org" Subject: Re: Slow query Date: Mon, 24 Mar 2003 10:54:49 -0800 User-Agent: KMail/1.4.3 References: <993DBE5B4D02194382EC8DF8554A5273113E5A@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A5273113E5A@postoffice.waterford.org> MIME-Version: 1.0 Message-Id: <200303241054.49325.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-31.0 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,UPPERCASE_25_50,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/161 X-Sequence-Number: 1459 Oleg, > Please help me speed up the following query. It used to run in 2-5 sec., > but now it takes 2-3 mins! > I ran VACUUM FULL ANALYZE and REINDEX. > SELECT * FROM media m > WHERE m.mediatype =3D (SELECT objectid FROM mediatype WHERE This is a repost, isn't it? --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Mar 24 13:59:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 41EA547636E for ; Mon, 24 Mar 2003 13:59:25 -0500 (EST) Received: from Mail (mail.waterford.org [205.124.117.40]) by postgresql.org (Postfix) with ESMTP id 59C8E47635B for ; Mon, 24 Mar 2003 13:59:22 -0500 (EST) Received: by Mail with XWall v3.25 ; Mon, 24 Mar 2003 11:59:21 -0700 From: Oleg Lebedev To: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: Slow query Date: Mon, 24 Mar 2003 12:02:51 -0700 X-Assembled-By: XWall v3.25 Message-ID: <993DBE5B4D02194382EC8DF8554A5273113E5C@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-9.0 required=5.0 tests=BAYES_10,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/162 X-Sequence-Number: 1460 No, I don't believe so. My previous question regarding performance was solved by VACUUM FULL and REINDEX. The current one, I believe, is more related to query structure and planner stats. -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Monday, March 24, 2003 11:55 AM To: Oleg Lebedev; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query Oleg, > Please help me speed up the following query. It used to run in 2-5=20 > sec., but now it takes 2-3 mins! I ran VACUUM FULL ANALYZE and=20 > REINDEX. SELECT * FROM media m > WHERE m.mediatype =3D (SELECT objectid FROM mediatype WHERE This is a repost, isn't it? --=20 Josh Berkus Aglio Database Solutions San Francisco ************************************* This email may contain privileged or confidential material intended for the= named recipient only. If you are not the named recipient, delete this message and all attachments= .=20=20 Any review, copying, printing, disclosure or other use is prohibited. We reserve the right to monitor email sent through our network. ************************************* From pgsql-performance-owner@postgresql.org Mon Mar 24 14:03:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5DEB6474E44 for ; Mon, 24 Mar 2003 14:03:46 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 5A9E647631B for ; Mon, 24 Mar 2003 14:03:42 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 64263D62F; Mon, 24 Mar 2003 11:03:42 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 55A055C0A; Mon, 24 Mar 2003 11:03:42 -0800 (PST) Date: Mon, 24 Mar 2003 11:03:42 -0800 (PST) From: Stephan Szabo To: Oleg Lebedev Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow query In-Reply-To: <993DBE5B4D02194382EC8DF8554A5273113E5A@postoffice.waterford.org> Message-ID: <20030324110115.A25958-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/163 X-Sequence-Number: 1461 On Mon, 24 Mar 2003, Oleg Lebedev wrote: > Please help me speed up the following query. It used to run in 2-5 sec., > but now it takes 2-3 mins! EXPLAIN ANALYZE output would be useful to see where the time is actually taking place (rather than an estimate thereof). From pgsql-performance-owner@postgresql.org Mon Mar 24 14:16:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 121F9475F0D for ; Mon, 24 Mar 2003 14:16:45 -0500 (EST) Received: from Mail (mail.waterford.org [205.124.117.40]) by postgresql.org (Postfix) with ESMTP id 0E136475F09 for ; Mon, 24 Mar 2003 14:16:44 -0500 (EST) Received: by Mail with XWall v3.25 ; Mon, 24 Mar 2003 12:16:44 -0700 From: Oleg Lebedev To: Stephan Szabo Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow query Date: Mon, 24 Mar 2003 12:20:13 -0700 X-Assembled-By: XWall v3.25 Message-ID: <993DBE5B4D02194382EC8DF8554A5273113E5D@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb" X-Spam-Status: No, hits=-8.6 required=5.0 tests=BAYES_10,MIME_BOUND_NEXTPART,MIME_SUSPECT_NAME, QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/164 X-Sequence-Number: 1462 This is a multi part message in MIME format. --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable EXPLAIN ANALYZE plan is shown below. I also attached it as a file. One thing that might help is that the query produces 27 rows, which is much less than predicted 1963. QUERY PLAN=20 Sort (cost=3D553657.66..553662.57 rows=3D1963 width=3D218) (actual time=3D133036.73..133036.75 rows=3D27 loops=3D1)=20 Sort Key: medianame, status=20 InitPlan=20 -> Seq Scan on mediatype (cost=3D0.00..1.29 rows=3D1 width=3D8) (actual time=3D0.12..0.14 rows=3D1 loops=3D1)=20 Filter: (medianame =3D 'Audio'::character varying)=20 -> Index Scan using media_mtype_index on media m (cost=3D0.00..553550.28 rows=3D1963 width=3D218) (actual time=3D5153.36..133036.00 rows=3D27 loops= =3D1)=20 Index Cond: (mediatype =3D $0)=20 Filter: (subplan)=20 SubPlan=20 -> Limit (cost=3D138.92..138.93 rows=3D1 width=3D24) (actual time=3D2.92.= .2.92 rows=3D0 loops=3D44876)=20 -> Subquery Scan a1 (cost=3D138.92..138.93 rows=3D1 width=3D24) (actual time=3D2.92..2.92 rows=3D0 loops=3D44876)=20 -> Unique (cost=3D138.92..138.93 rows=3D1 width=3D24) (actual time=3D2.91..2.91 rows=3D0 loops=3D44876)=20 -> Sort (cost=3D138.92..138.93 rows=3D2 width=3D24) (actual time=3D2.91..= 2.91 rows=3D0 loops=3D44876)=20 Sort Key: mediaid=20 -> Append (cost=3D0.00..138.91 rows=3D2 width=3D24) (actual time=3D2.80..= 2.81 rows=3D0 loops=3D44876)=20 -> Subquery Scan "*SELECT* 1" (cost=3D0.00..5.11 rows=3D1 width=3D8) (act= ual time=3D0.06..0.06 rows=3D0 loops=3D44876)=20 -> Index Scan using media_pkey on media (cost=3D0.00..5.11 rows=3D1 width=3D8) (actual time=3D0.05..0.05 rows=3D0 loops=3D44876)=20 Index Cond: (objectid =3D $1)=20 Filter: (activity =3D 347667::bigint)=20 -> Subquery Scan "*SELECT* 2" (cost=3D24.25..133.80 rows=3D1 width=3D24) (actual time=3D2.73..2.73 rows=3D0 loops=3D44876)=20 -> Hash Join (cost=3D24.25..133.80 rows=3D1 width=3D24) (actual time=3D2.72..2.72 rows=3D0 loops=3D44876)=20 Hash Cond: ("outer"."set" =3D "inner".objectid)=20 -> Index Scan using intsetmedia_media_index on intsetmedia ism (cost=3D0.00..109.26 rows=3D38 width=3D16) (actual time=3D0.04..0.04 rows= =3D1 loops=3D44876)=20 Index Cond: (media =3D $1)=20 -> Hash (cost=3D24.24..24.24 rows=3D6 width=3D8) (actual time=3D0.14..0.14 rows=3D0 loops=3D44876)=20 -> Index Scan using set_act_index on "set" s (cost=3D0.00..24.24 rows=3D6 width=3D8) (actual time=3D0.11..0.13 rows=3D2 loops=3D44876)=20 Index Cond: (activity =3D 347667::bigint)=20 Total runtime: 133037.49 msec=20 -----Original Message----- From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com]=20 Sent: Monday, March 24, 2003 12:04 PM To: Oleg Lebedev Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query On Mon, 24 Mar 2003, Oleg Lebedev wrote: > Please help me speed up the following query. It used to run in 2-5=20 > sec., but now it takes 2-3 mins! EXPLAIN ANALYZE output would be useful to see where the time is actually taking place (rather than an estimate thereof). ************************************* This email may contain privileged or confidential material intended for the= named recipient only. If you are not the named recipient, delete this message and all attachments= .=20=20 Any review, copying, printing, disclosure or other use is prohibited. We reserve the right to monitor email sent through our network. ************************************* --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="plan.txt" Content-Disposition: attachment; filename="plan.txt" Content-Transfer-Encoding: base64 UVVFUlkgUExBTiANCiBTb3J0IChjb3N0PTU1MzY1Ny42Ni4uNTUzNjYyLjU3 IHJvd3M9MTk2MyB3aWR0aD0yMTgpIChhY3R1YWwgdGltZT0xMzMwMzYuNzMu LjEzMzAzNi43NSByb3dzPTI3IGxvb3BzPTEpIA0KICBTb3J0IEtleTogbWVk aWFuYW1lLCBzdGF0dXMgDQogIEluaXRQbGFuIA0KICAtPiBTZXEgU2NhbiBv biBtZWRpYXR5cGUgKGNvc3Q9MC4wMC4uMS4yOSByb3dzPTEgd2lkdGg9OCkg KGFjdHVhbCB0aW1lPTAuMTIuLjAuMTQgcm93cz0xIGxvb3BzPTEpIA0KICBG aWx0ZXI6IChtZWRpYW5hbWUgPSAnQXVkaW8nOjpjaGFyYWN0ZXIgdmFyeWlu ZykgDQogIC0+IEluZGV4IFNjYW4gdXNpbmcgbWVkaWFfbXR5cGVfaW5kZXgg b24gbWVkaWEgbSAoY29zdD0wLjAwLi41NTM1NTAuMjggcm93cz0xOTYzIHdp ZHRoPTIxOCkgKGFjdHVhbCB0aW1lPTUxNTMuMzYuLjEzMzAzNi4wMCByb3dz PTI3IGxvb3BzPTEpIA0KICBJbmRleCBDb25kOiAobWVkaWF0eXBlID0gJDAp IA0KICBGaWx0ZXI6IChzdWJwbGFuKSANCiAgU3ViUGxhbiANCiAgLT4gTGlt aXQgKGNvc3Q9MTM4LjkyLi4xMzguOTMgcm93cz0xIHdpZHRoPTI0KSAoYWN0 dWFsIHRpbWU9Mi45Mi4uMi45MiByb3dzPTAgbG9vcHM9NDQ4NzYpIA0KICAt PiBTdWJxdWVyeSBTY2FuIGExIChjb3N0PTEzOC45Mi4uMTM4LjkzIHJvd3M9 MSB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTIuOTIuLjIuOTIgcm93cz0wIGxv b3BzPTQ0ODc2KSANCiAgLT4gVW5pcXVlIChjb3N0PTEzOC45Mi4uMTM4Ljkz IHJvd3M9MSB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTIuOTEuLjIuOTEgcm93 cz0wIGxvb3BzPTQ0ODc2KSANCiAgLT4gU29ydCAoY29zdD0xMzguOTIuLjEz OC45MyByb3dzPTIgd2lkdGg9MjQpIChhY3R1YWwgdGltZT0yLjkxLi4yLjkx IHJvd3M9MCBsb29wcz00NDg3NikgDQogIFNvcnQgS2V5OiBtZWRpYWlkIA0K ICAtPiBBcHBlbmQgKGNvc3Q9MC4wMC4uMTM4LjkxIHJvd3M9MiB3aWR0aD0y NCkgKGFjdHVhbCB0aW1lPTIuODAuLjIuODEgcm93cz0wIGxvb3BzPTQ0ODc2 KSANCiAgLT4gU3VicXVlcnkgU2NhbiAiKlNFTEVDVCogMSIgKGNvc3Q9MC4w MC4uNS4xMSByb3dzPTEgd2lkdGg9OCkgKGFjdHVhbCB0aW1lPTAuMDYuLjAu MDYgcm93cz0wIGxvb3BzPTQ0ODc2KSANCiAgLT4gSW5kZXggU2NhbiB1c2lu ZyBtZWRpYV9wa2V5IG9uIG1lZGlhIChjb3N0PTAuMDAuLjUuMTEgcm93cz0x IHdpZHRoPTgpIChhY3R1YWwgdGltZT0wLjA1Li4wLjA1IHJvd3M9MCBsb29w cz00NDg3NikgDQogIEluZGV4IENvbmQ6IChvYmplY3RpZCA9ICQxKSANCiAg RmlsdGVyOiAoYWN0aXZpdHkgPSAzNDc2Njc6OmJpZ2ludCkgDQogIC0+IFN1 YnF1ZXJ5IFNjYW4gIipTRUxFQ1QqIDIiIChjb3N0PTI0LjI1Li4xMzMuODAg cm93cz0xIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9Mi43My4uMi43MyByb3dz PTAgbG9vcHM9NDQ4NzYpIA0KICAtPiBIYXNoIEpvaW4gKGNvc3Q9MjQuMjUu LjEzMy44MCByb3dzPTEgd2lkdGg9MjQpIChhY3R1YWwgdGltZT0yLjcyLi4y LjcyIHJvd3M9MCBsb29wcz00NDg3NikgDQogIEhhc2ggQ29uZDogKCJvdXRl ciIuInNldCIgPSAiaW5uZXIiLm9iamVjdGlkKSANCiAgLT4gSW5kZXggU2Nh biB1c2luZyBpbnRzZXRtZWRpYV9tZWRpYV9pbmRleCBvbiBpbnRzZXRtZWRp YSBpc20gKGNvc3Q9MC4wMC4uMTA5LjI2IHJvd3M9Mzggd2lkdGg9MTYpIChh Y3R1YWwgdGltZT0wLjA0Li4wLjA0IHJvd3M9MSBsb29wcz00NDg3NikgDQog IEluZGV4IENvbmQ6IChtZWRpYSA9ICQxKSANCiAgLT4gSGFzaCAoY29zdD0y NC4yNC4uMjQuMjQgcm93cz02IHdpZHRoPTgpIChhY3R1YWwgdGltZT0wLjE0 Li4wLjE0IHJvd3M9MCBsb29wcz00NDg3NikgDQogIC0+IEluZGV4IFNjYW4g dXNpbmcgc2V0X2FjdF9pbmRleCBvbiAic2V0IiBzIChjb3N0PTAuMDAuLjI0 LjI0IHJvd3M9NiB3aWR0aD04KSAoYWN0dWFsIHRpbWU9MC4xMS4uMC4xMyBy b3dzPTIgbG9vcHM9NDQ4NzYpIA0KICBJbmRleCBDb25kOiAoYWN0aXZpdHkg PSAzNDc2Njc6OmJpZ2ludCkgDQogVG90YWwgcnVudGltZTogMTMzMDM3LjQ5 IG1zZWMgDQo= --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb-- From pgsql-performance-owner@postgresql.org Mon Mar 24 14:47:23 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1C7E34762CF for ; Mon, 24 Mar 2003 14:47:22 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 4DF31476241 for ; Mon, 24 Mar 2003 14:47:17 -0500 (EST) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2920444; Mon, 24 Mar 2003 11:47:06 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Stephan Szabo , "pgsql-performance@postgresql.org" Subject: Re: Slow query Date: Mon, 24 Mar 2003 11:47:09 -0800 User-Agent: KMail/1.4.3 References: <993DBE5B4D02194382EC8DF8554A5273113E5A@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A5273113E5A@postoffice.waterford.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303241147.09853.josh@agliodbs.com> X-Spam-Status: No, hits=-19.2 required=5.0 tests=BAYES_20,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/165 X-Sequence-Number: 1463 Stephan, Hmmm ... I'm a bit confused by the new EXPLAIN output. Stefan, does Oleg'= s=20 output show the time for *one* subplan execution, executed for 44,000 loops= ,=20 or does it show the total time? The former would make more sense given his= =20 query, but I'm just not sure .... --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Mar 24 15:25:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 03BB6475F0D for ; Mon, 24 Mar 2003 15:25:18 -0500 (EST) Received: from Mail (mail.waterford.org [205.124.117.40]) by postgresql.org (Postfix) with ESMTP id 0D271475F09 for ; Mon, 24 Mar 2003 15:25:17 -0500 (EST) Received: by Mail with XWall v3.25 ; Mon, 24 Mar 2003 13:25:17 -0700 From: Oleg Lebedev To: "josh@agliodbs.com" , Stephan Szabo , "pgsql-performance@postgresql.org" Subject: Re: Slow query Date: Mon, 24 Mar 2003 13:28:47 -0700 X-Assembled-By: XWall v3.25 Message-ID: <993DBE5B4D02194382EC8DF8554A5273113E5E@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-5.8 required=5.0 tests=BAYES_10 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/166 X-Sequence-Number: 1464 I decided that it might help to list the cardinalities of the pertinent tables: Intsetmedia: 90,000 rows Interaction: 26,000 rows Set: 7,000 rows Media: 80,000 rows -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Monday, March 24, 2003 12:47 PM To: Stephan Szabo; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query Importance: Low Stephan, Hmmm ... I'm a bit confused by the new EXPLAIN output. Stefan, does Oleg's=20 output show the time for *one* subplan execution, executed for 44,000 loops,=20 or does it show the total time? The former would make more sense given his=20 query, but I'm just not sure .... --=20 -Josh Berkus Aglio Database Solutions San Francisco ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster ************************************* This email may contain privileged or confidential material intended for the= named recipient only. If you are not the named recipient, delete this message and all attachments= .=20=20 Any review, copying, printing, disclosure or other use is prohibited. We reserve the right to monitor email sent through our network. ************************************* From pgsql-performance-owner@postgresql.org Mon Mar 24 15:48:42 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 40E65475F5F for ; Mon, 24 Mar 2003 15:48:41 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3CE11474E44 for ; Mon, 24 Mar 2003 15:48:10 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2OKmAub020171; Mon, 24 Mar 2003 15:48:11 -0500 (EST) To: Oleg Lebedev Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow query In-reply-to: <993DBE5B4D02194382EC8DF8554A5273113E5A@postoffice.waterford.org> References: <993DBE5B4D02194382EC8DF8554A5273113E5A@postoffice.waterford.org> Comments: In-reply-to Oleg Lebedev message dated "Mon, 24 Mar 2003 10:48:52 -0700" Date: Mon, 24 Mar 2003 15:48:10 -0500 Message-ID: <20170.1048538890@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-27.9 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,UPPERCASE_25_50 autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/167 X-Sequence-Number: 1465 Oleg Lebedev writes: > SELECT * FROM media m > WHERE m.mediatype =3D (SELECT objectid FROM mediatype WHERE > medianame=3D'Audio')=20 > AND EXISTS=20 > (SELECT * FROM=20 > (SELECT objectid AS mediaid=20 > FROM media=20 > WHERE activity=3D'347667'=20 > UNION=20 > SELECT ism.media AS mediaid=20 > FROM intsetmedia ism, set s=20 > WHERE ism.set =3D s.objectid=20 > AND s.activity=3D'347667' ) AS a1=20 > WHERE a1.mediaid =3D m.objectid=20 > LIMIT 1)=20 > ORDER BY medianame ASC, status DESC=20 Well, one observation is that the LIMIT clause is useless and probably counterproductive; EXISTS takes only one row from the subselect anyway. Another is that the UNION is doing it the hard way; UNION implies doing a duplicate-elimination step, which you don't need here. UNION ALL would be a little quicker. But what I would do is split it into two EXISTS: SELECT * FROM media m WHERE m.mediatype = (SELECT objectid FROM mediatype WHERE medianame='Audio') AND ( EXISTS(SELECT 1 FROM media WHERE activity='347667' AND objectid = m.objectid) OR EXISTS(SELECT 1 FROM intsetmedia ism, set s WHERE ism.set = s.objectid AND s.activity='347667' AND ism.media = m.objectid)) ORDER BY medianame ASC, status DESC regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 24 16:42:42 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C2F90476332 for ; Mon, 24 Mar 2003 16:42:39 -0500 (EST) Received: from Mail (mail.waterford.org [205.124.117.40]) by postgresql.org (Postfix) with ESMTP id ADD75476323 for ; Mon, 24 Mar 2003 16:42:38 -0500 (EST) Received: by Mail with XWall v3.25 ; Mon, 24 Mar 2003 14:42:40 -0700 From: Oleg Lebedev To: Tom Lane Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow query Date: Mon, 24 Mar 2003 14:46:09 -0700 X-Assembled-By: XWall v3.25 Message-ID: <993DBE5B4D02194382EC8DF8554A5273113E5F@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb" X-Spam-Status: No, hits=-8.6 required=5.0 tests=BAYES_10,MIME_BOUND_NEXTPART,MIME_SUSPECT_NAME, QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/168 X-Sequence-Number: 1466 This is a multi part message in MIME format. --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I just ran the query you sent me and attached the output of EXPLAIN ANALYZE as TOMs_plan.txt It did not speed up the query significantly. It always seemed to me that UNION is faster than OR, so I tried your suggestion to use UNION ALL with the original query without counter-productive LIMIT 1 in EXISTS clause. This reduced the cost of the plan by 50%, but slowed down the query. Weird ... The plan is shown in UNION_ALL_plan.txt AFAIK, the only change I've done since the time when the query took 3 sec. to run was adding more indexes and increasing the size of data by about 25%. It sounds kind of stupid, but I remember that adding indexes sometimes slowed down my queries. I will try to drop all the indexes and add them back again one by one. Any other ideas? Thanks. Oleg -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Monday, March 24, 2003 1:48 PM To: Oleg Lebedev Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query Oleg Lebedev writes: > SELECT * FROM media m > WHERE m.mediatype =3D3D (SELECT objectid FROM mediatype WHERE=20 > medianame=3D3D'Audio')=3D20 AND EXISTS=3D20 > (SELECT * FROM=3D20 > (SELECT objectid AS mediaid=3D20 > FROM media=3D20 > WHERE activity=3D3D'347667'=3D20 > UNION=3D20 > SELECT ism.media AS mediaid=3D20 > FROM intsetmedia ism, set s=3D20 > WHERE ism.set =3D3D s.objectid=3D20 > AND s.activity=3D3D'347667' ) AS a1=3D20 > WHERE a1.mediaid =3D3D m.objectid=3D20 > LIMIT 1)=3D20 > ORDER BY medianame ASC, status DESC=3D20 Well, one observation is that the LIMIT clause is useless and probably counterproductive; EXISTS takes only one row from the subselect anyway. Another is that the UNION is doing it the hard way; UNION implies doing a duplicate-elimination step, which you don't need here. UNION ALL would be a little quicker. But what I would do is split it into two EXISTS: SELECT * FROM media m WHERE m.mediatype =3D (SELECT objectid FROM mediatype WHERE medianame=3D'Audio')=20 AND ( EXISTS(SELECT 1 FROM media=20 WHERE activity=3D'347667'=20 AND objectid =3D m.objectid) OR EXISTS(SELECT 1 FROM intsetmedia ism, set s=20 WHERE ism.set =3D s.objectid=20 AND s.activity=3D'347667' AND ism.media =3D m.objectid)) ORDER BY medianame ASC, status DESC=20 regards, tom lane ************************************* This email may contain privileged or confidential material intended for the= named recipient only. If you are not the named recipient, delete this message and all attachments= .=20=20 Any review, copying, printing, disclosure or other use is prohibited. We reserve the right to monitor email sent through our network. ************************************* --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="TOMs_plan.txt" Content-Disposition: attachment; filename="TOMs_plan.txt" Content-Transfer-Encoding: base64 VG9tJ3MgUXVlcnk6DQpTRUxFQ1QgKiBGUk9NIG1lZGlhIG0NCldIRVJFIG0u bWVkaWF0eXBlID0gKFNFTEVDVCBvYmplY3RpZCBGUk9NIG1lZGlhdHlwZSBX SEVSRQ0KbWVkaWFuYW1lPSdBdWRpbycpIA0KQU5EICggICBFWElTVFMoU0VM RUNUIDENCiAgICAgICAgICAgICAgIEZST00gbWVkaWEgDQogICAgICAgICAg ICAgICBXSEVSRSBhY3Rpdml0eT0nMzQ3NjY3JyANCiAgICAgICAgICAgICAg IEFORCBvYmplY3RpZCA9IG0ub2JqZWN0aWQpDQogICAgIE9SIEVYSVNUUyhT RUxFQ1QgMQ0KICAgICAgICAgICAgICAgRlJPTSBpbnRzZXRtZWRpYSBpc20s IHNldCBzIA0KICAgICAgICAgICAgICAgV0hFUkUgaXNtLnNldCA9IHMub2Jq ZWN0aWQgDQogICAgICAgICAgICAgICBBTkQgcy5hY3Rpdml0eT0nMzQ3NjY3 Jw0KICAgICAgICAgICAgICAgQU5EIGlzbS5tZWRpYSA9IG0ub2JqZWN0aWQp KQ0KT1JERVIgQlkgbWVkaWFuYW1lIEFTQywgc3RhdHVzIERFU0MgDQoNCg0K VG9tJ3MgUVVFUlkgUExBTiANCiBTb3J0IChjb3N0PTU1MzY0MS40My4uNTUz NjQ4LjgwIHJvd3M9Mjk0NSB3aWR0aD0yMTgpIChhY3R1YWwgdGltZT0xMjYw ODcuNzcuLjEyNjA4Ny44MCByb3dzPTI3IGxvb3BzPTEpIA0KICBTb3J0IEtl eTogbWVkaWFuYW1lLCBzdGF0dXMgDQogIEluaXRQbGFuIA0KICAtPiBTZXEg U2NhbiBvbiBtZWRpYXR5cGUgKGNvc3Q9MC4wMC4uMS4yOSByb3dzPTEgd2lk dGg9OCkgKGFjdHVhbCB0aW1lPTAuMTIuLjAuMTQgcm93cz0xIGxvb3BzPTEp IA0KICBGaWx0ZXI6IChtZWRpYW5hbWUgPSAnQXVkaW8nOjpjaGFyYWN0ZXIg dmFyeWluZykgDQogIC0+IEluZGV4IFNjYW4gdXNpbmcgbWVkaWFfbXR5cGVf aW5kZXggb24gbWVkaWEgbSAoY29zdD0wLjAwLi41NTM0NzEuNzQgcm93cz0y OTQ1IHdpZHRoPTIxOCkgKGFjdHVhbCB0aW1lPTQ4NzAuNjUuLjEyNjA4Ny4w NiByb3dzPTI3IGxvb3BzPTEpIA0KICBJbmRleCBDb25kOiAobWVkaWF0eXBl ID0gJDApIA0KICBGaWx0ZXI6ICgoc3VicGxhbikgT1IgKHN1YnBsYW4pKSAN CiAgU3ViUGxhbiANCiAgLT4gSW5kZXggU2NhbiB1c2luZyBtZWRpYV9wa2V5 IG9uIG1lZGlhIChjb3N0PTAuMDAuLjUuMTEgcm93cz0xIHdpZHRoPTApIChh Y3R1YWwgdGltZT0wLjA0Li4wLjA0IHJvd3M9MCBsb29wcz00NDg3NikgDQog IEluZGV4IENvbmQ6IChvYmplY3RpZCA9ICQxKSANCiAgRmlsdGVyOiAoYWN0 aXZpdHkgPSAzNDc2Njc6OmJpZ2ludCkgDQogIC0+IEhhc2ggSm9pbiAoY29z dD0yNC4yNS4uMTMzLjgwIHJvd3M9MSB3aWR0aD0xNikgKGFjdHVhbCB0aW1l PTIuNzEuLjIuNzEgcm93cz0wIGxvb3BzPTQ0ODUwKSANCiAgSGFzaCBDb25k OiAoIm91dGVyIi4ic2V0IiA9ICJpbm5lciIub2JqZWN0aWQpIA0KICAtPiBJ bmRleCBTY2FuIHVzaW5nIGludHNldG1lZGlhX21lZGlhX2luZGV4IG9uIGlu dHNldG1lZGlhIGlzbSAoY29zdD0wLjAwLi4xMDkuMjYgcm93cz0zOCB3aWR0 aD04KSAoYWN0dWFsIHRpbWU9MC4wNC4uMC4wNCByb3dzPTEgbG9vcHM9NDQ4 NTApIA0KICBJbmRleCBDb25kOiAobWVkaWEgPSAkMSkgDQogIC0+IEhhc2gg KGNvc3Q9MjQuMjQuLjI0LjI0IHJvd3M9NiB3aWR0aD04KSAoYWN0dWFsIHRp bWU9MC4xNC4uMC4xNCByb3dzPTAgbG9vcHM9NDQ4NTApIA0KICAtPiBJbmRl eCBTY2FuIHVzaW5nIHNldF9hY3RfaW5kZXggb24gInNldCIgcyAoY29zdD0w LjAwLi4yNC4yNCByb3dzPTYgd2lkdGg9OCkgKGFjdHVhbCB0aW1lPTAuMTEu LjAuMTMgcm93cz0yIGxvb3BzPTQ0ODUwKSANCiAgSW5kZXggQ29uZDogKGFj dGl2aXR5ID0gMzQ3NjY3OjpiaWdpbnQpIA0KIFRvdGFsIHJ1bnRpbWU6IDEy NjA4OC4zMyBtc2VjIA0K --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="UNION_ALL_plan.txt" Content-Disposition: attachment; filename="UNION_ALL_plan.txt" Content-Transfer-Encoding: base64 TmV3IFF1ZXJ5Og0KU0VMRUNUICogRlJPTSBtZWRpYSBtIA0KV0hFUkUgbS5t ZWRpYXR5cGUgPSAoU0VMRUNUIG9iamVjdGlkIEZST00gbWVkaWF0eXBlIFdI RVJFIG1lZGlhbmFtZT0nQXVkaW8nKSANCkFORCBFWElTVFMgDQooU0VMRUNU ICogRlJPTSANCihTRUxFQ1Qgb2JqZWN0aWQgQVMgbWVkaWFpZCANCkZST00g bWVkaWEgDQpXSEVSRSBhY3Rpdml0eT0nMzQ3NjY3JyANClVOSU9OIEFMTCAN ClNFTEVDVCBpc20ubWVkaWEgQVMgbWVkaWFpZCANCkZST00gaW50c2V0bWVk aWEgaXNtLCBzZXQgcyANCldIRVJFIGlzbS5zZXQgPSBzLm9iamVjdGlkIA0K QU5EIHMuYWN0aXZpdHk9JzM0NzY2NycgKSBBUyBhMSANCldIRVJFIGExLm1l ZGlhaWQgPSBtLm9iamVjdGlkIA0KKSANCk9SREVSIEJZIG1lZGlhbmFtZSBB U0MsIHN0YXR1cyBERVNDIA0KDQogDQpRVUVSWSBQTEFOOiANCiBTb3J0IChj b3N0PTI4MDg1Mi44Ni4uMjgwODU3Ljc3IHJvd3M9MTk2MyB3aWR0aD0yMTgp IChhY3R1YWwgdGltZT0xMjkzNjAuNzIuLjEyOTM2MC43MyByb3dzPTI3IGxv b3BzPTEpIA0KICBTb3J0IEtleTogbWVkaWFuYW1lLCBzdGF0dXMgDQogIElu aXRQbGFuIA0KICAtPiBTZXEgU2NhbiBvbiBtZWRpYXR5cGUgKGNvc3Q9MC4w MC4uMS4yOSByb3dzPTEgd2lkdGg9OCkgKGFjdHVhbCB0aW1lPTAuMTMuLjAu MTUgcm93cz0xIGxvb3BzPTEpIA0KICBGaWx0ZXI6IChtZWRpYW5hbWUgPSAn QXVkaW8nOjpjaGFyYWN0ZXIgdmFyeWluZykgDQogIC0+IEluZGV4IFNjYW4g dXNpbmcgbWVkaWFfbXR5cGVfaW5kZXggb24gbWVkaWEgbSAoY29zdD0wLjAw Li4yODA3NDUuNDggcm93cz0xOTYzIHdpZHRoPTIxOCkgKGFjdHVhbCB0aW1l PTU1MjMuODUuLjEyOTM1OS45NiByb3dzPTI3IGxvb3BzPTEpIA0KICBJbmRl eCBDb25kOiAobWVkaWF0eXBlID0gJDApIA0KICBGaWx0ZXI6IChzdWJwbGFu KSANCiAgU3ViUGxhbiANCiAgLT4gU3VicXVlcnkgU2NhbiBhMSAoY29zdD0w LjAwLi4xMzguOTEgcm93cz0yIHdpZHRoPTI0KSAoYWN0dWFsIHRpbWU9Mi44 NC4uMi44NCByb3dzPTAgbG9vcHM9NDQ4NzYpIA0KICAtPiBBcHBlbmQgKGNv c3Q9MC4wMC4uMTM4LjkxIHJvd3M9MiB3aWR0aD0yNCkgKGFjdHVhbCB0aW1l PTIuODQuLjIuODQgcm93cz0wIGxvb3BzPTQ0ODc2KSANCiAgLT4gU3VicXVl cnkgU2NhbiAiKlNFTEVDVCogMSIgKGNvc3Q9MC4wMC4uNS4xMSByb3dzPTEg d2lkdGg9OCkgKGFjdHVhbCB0aW1lPTAuMDYuLjAuMDYgcm93cz0wIGxvb3Bz PTQ0ODc2KSANCiAgLT4gSW5kZXggU2NhbiB1c2luZyBtZWRpYV9wa2V5IG9u IG1lZGlhIChjb3N0PTAuMDAuLjUuMTEgcm93cz0xIHdpZHRoPTgpIChhY3R1 YWwgdGltZT0wLjA0Li4wLjA0IHJvd3M9MCBsb29wcz00NDg3NikgDQogIElu ZGV4IENvbmQ6IChvYmplY3RpZCA9ICQxKSANCiAgRmlsdGVyOiAoYWN0aXZp dHkgPSAzNDc2Njc6OmJpZ2ludCkgDQogIC0+IFN1YnF1ZXJ5IFNjYW4gIipT RUxFQ1QqIDIiIChjb3N0PTI0LjI1Li4xMzMuODAgcm93cz0xIHdpZHRoPTI0 KSAoYWN0dWFsIHRpbWU9Mi43Ny4uMi43NyByb3dzPTAgbG9vcHM9NDQ4NTAp IA0KICAtPiBIYXNoIEpvaW4gKGNvc3Q9MjQuMjUuLjEzMy44MCByb3dzPTEg d2lkdGg9MjQpIChhY3R1YWwgdGltZT0yLjc2Li4yLjc2IHJvd3M9MCBsb29w cz00NDg1MCkgDQogIEhhc2ggQ29uZDogKCJvdXRlciIuInNldCIgPSAiaW5u ZXIiLm9iamVjdGlkKSANCiAgLT4gSW5kZXggU2NhbiB1c2luZyBpbnRzZXRt ZWRpYV9tZWRpYV9pbmRleCBvbiBpbnRzZXRtZWRpYSBpc20gKGNvc3Q9MC4w MC4uMTA5LjI2IHJvd3M9Mzggd2lkdGg9MTYpIChhY3R1YWwgdGltZT0wLjA0 Li4wLjA0IHJvd3M9MSBsb29wcz00NDg1MCkgDQogIEluZGV4IENvbmQ6ICht ZWRpYSA9ICQxKSANCiAgLT4gSGFzaCAoY29zdD0yNC4yNC4uMjQuMjQgcm93 cz02IHdpZHRoPTgpIChhY3R1YWwgdGltZT0wLjE0Li4wLjE0IHJvd3M9MCBs b29wcz00NDg1MCkgDQogIC0+IEluZGV4IFNjYW4gdXNpbmcgc2V0X2FjdF9p bmRleCBvbiAic2V0IiBzIChjb3N0PTAuMDAuLjI0LjI0IHJvd3M9NiB3aWR0 aD04KSAoYWN0dWFsIHRpbWU9MC4xMS4uMC4xMiByb3dzPTIgbG9vcHM9NDQ4 NTApIA0KICBJbmRleCBDb25kOiAoYWN0aXZpdHkgPSAzNDc2Njc6OmJpZ2lu dCkgDQogVG90YWwgcnVudGltZTogMTI5MzYxLjM1IG1zZWMgDQo= --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb-- From pgsql-performance-owner@postgresql.org Mon Mar 24 17:08:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AB1364761C0 for ; Mon, 24 Mar 2003 17:08:50 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D7DEE475F09 for ; Mon, 24 Mar 2003 17:08:48 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2OM8oub020750; Mon, 24 Mar 2003 17:08:50 -0500 (EST) To: Oleg Lebedev Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow query In-reply-to: <993DBE5B4D02194382EC8DF8554A5273113E5F@postoffice.waterford.org> References: <993DBE5B4D02194382EC8DF8554A5273113E5F@postoffice.waterford.org> Comments: In-reply-to Oleg Lebedev message dated "Mon, 24 Mar 2003 14:46:09 -0700" Date: Mon, 24 Mar 2003 17:08:50 -0500 Message-ID: <20749.1048543730@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/169 X-Sequence-Number: 1467 Oleg Lebedev writes: > I just ran the query you sent me and attached the output of EXPLAIN > ANALYZE as TOMs_plan.txt > It did not speed up the query significantly. Nope. I was hoping to see a faster-start plan, but given the number of rows involved I guess it won't change its mind. You're going to have to think about a more intelligent approach, rather than minor tweaks. One question: since objectid is evidently a primary key, why are you doing a subselect for the first part? Wouldn't it give the same result just to say "m.activity = '347667'" in the top-level WHERE? As for the second part, I think you'll have to try to rewrite it as a join with the media table. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 24 17:33:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EDCE3476112 for ; Mon, 24 Mar 2003 17:33:41 -0500 (EST) Received: from Mail (mail.waterford.org [205.124.117.40]) by postgresql.org (Postfix) with ESMTP id 0D176475F5F for ; Mon, 24 Mar 2003 17:33:39 -0500 (EST) Received: by Mail with XWall v3.25 ; Mon, 24 Mar 2003 15:33:40 -0700 From: Oleg Lebedev To: Tom Lane Cc: "pgsql-performance@postgresql.org" Subject: Re: Slow query Date: Mon, 24 Mar 2003 15:37:10 -0700 X-Assembled-By: XWall v3.25 Message-ID: <993DBE5B4D02194382EC8DF8554A5273113E61@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb" X-Spam-Status: No, hits=-9.4 required=5.0 tests=BAYES_01,MIME_BOUND_NEXTPART,MIME_SUSPECT_NAME, QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/170 X-Sequence-Number: 1468 This is a multi part message in MIME format. --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable You are right. I rewrote the query using JOINs and it increased performance from 123 sec. to 20msec. I betcha I screwed smth up, but I list the rewritten query below anyways. I also attached the new plan. Thank you. SELECT * FROM media m=20 JOIN=20 ((SELECT objectid AS mediaid=20 FROM media=20 WHERE activity=3D'347667')=20 UNION=20 (SELECT ism.media AS mediaid=20 FROM intsetmedia ism, set s=20 WHERE ism.set =3D s.objectid=20 AND s.activity=3D'347667' )) a1=20 ON=20 m.mediatype =3D (SELECT objectid FROM mediatype WHERE medianame=3D'Audio')= =20 AND m.objectid=3Dmediaid=20 ORDER BY medianame ASC, status DESC=20 -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Monday, March 24, 2003 3:09 PM To: Oleg Lebedev Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Slow query Oleg Lebedev writes: > I just ran the query you sent me and attached the output of EXPLAIN=20 > ANALYZE as TOMs_plan.txt It did not speed up the query significantly. Nope. I was hoping to see a faster-start plan, but given the number of rows involved I guess it won't change its mind. You're going to have to think about a more intelligent approach, rather than minor tweaks. One question: since objectid is evidently a primary key, why are you doing a subselect for the first part? Wouldn't it give the same result just to say "m.activity =3D '347667'" in the top-level WHERE? As for the second part, I think you'll have to try to rewrite it as a join with the media table. regards, tom lane ************************************* This email may contain privileged or confidential material intended for the= named recipient only. If you are not the named recipient, delete this message and all attachments= .=20=20 Any review, copying, printing, disclosure or other use is prohibited. We reserve the right to monitor email sent through our network. ************************************* --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="NEW_plan.txt" Content-Disposition: attachment; filename="NEW_plan.txt" Content-Transfer-Encoding: base64 TmV3IFF1ZXJ5Og0KU0VMRUNUICogRlJPTSBtZWRpYSBtIA0KSk9JTiANCigo U0VMRUNUIG9iamVjdGlkIEFTIG1lZGlhaWQgDQpGUk9NIG1lZGlhIA0KV0hF UkUgYWN0aXZpdHk9JzM0NzY2NycpIA0KVU5JT04gDQooU0VMRUNUIGlzbS5t ZWRpYSBBUyBtZWRpYWlkIA0KRlJPTSBpbnRzZXRtZWRpYSBpc20sIHNldCBz IA0KV0hFUkUgaXNtLnNldCA9IHMub2JqZWN0aWQgDQpBTkQgcy5hY3Rpdml0 eT0nMzQ3NjY3JyApKSBhMSANCk9OIA0KbS5tZWRpYXR5cGUgPSAoU0VMRUNU IG9iamVjdGlkIEZST00gbWVkaWF0eXBlIFdIRVJFIG1lZGlhbmFtZT0nQXVk aW8nKSANCkFORCBtLm9iamVjdGlkPW1lZGlhaWQgDQpPUkRFUiBCWSBtZWRp YW5hbWUgQVNDLCBzdGF0dXMgREVTQyANCg0KIA0KUVVFUlkgUExBTiANCiBT b3J0IChjb3N0PTE4MzEuNDcuLjE4MzEuNDcgcm93cz0xIHdpZHRoPTIyNSkg KGFjdHVhbCB0aW1lPTE5LjU2Li4xOS41OCByb3dzPTI3IGxvb3BzPTEpIA0K ICBTb3J0IEtleTogbS5tZWRpYW5hbWUsIG0uc3RhdHVzIA0KICBJbml0UGxh biANCiAgLT4gU2VxIFNjYW4gb24gbWVkaWF0eXBlIChjb3N0PTAuMDAuLjEu Mjkgcm93cz0xIHdpZHRoPTgpIChhY3R1YWwgdGltZT0wLjEwLi4wLjEyIHJv d3M9MSBsb29wcz0xKSANCiAgRmlsdGVyOiAobWVkaWFuYW1lID0gJ0F1ZGlv Jzo6Y2hhcmFjdGVyIHZhcnlpbmcpIA0KICAtPiBOZXN0ZWQgTG9vcCAoY29z dD0xNzAyLjk3Li4xODMxLjQ2IHJvd3M9MSB3aWR0aD0yMjUpIChhY3R1YWwg dGltZT0xNi40NC4uMTguOTMgcm93cz0yNyBsb29wcz0xKSANCiAgLT4gU3Vi cXVlcnkgU2NhbiBhMSAoY29zdD0xNzAyLjk3Li4xNzA0LjE5IHJvd3M9MjQg d2lkdGg9MjQpIChhY3R1YWwgdGltZT0xNi4xMC4uMTYuNzIgcm93cz01OCBs b29wcz0xKSANCiAgLT4gVW5pcXVlIChjb3N0PTE3MDIuOTcuLjE3MDQuMTkg cm93cz0yNCB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTE2LjA4Li4xNi41NiBy b3dzPTU4IGxvb3BzPTEpIA0KICAtPiBTb3J0IChjb3N0PTE3MDIuOTcuLjE3 MDMuNTggcm93cz0yNDMgd2lkdGg9MjQpIChhY3R1YWwgdGltZT0xNi4wOC4u MTYuMjUgcm93cz0yNjQgbG9vcHM9MSkgDQogIFNvcnQgS2V5OiBtZWRpYWlk IA0KICAtPiBBcHBlbmQgKGNvc3Q9MC4wMC4uMTY5My4zMiByb3dzPTI0MyB3 aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTAuMDcuLjkuMTEgcm93cz0yNjQgbG9v cHM9MSkgDQogIC0+IFN1YnF1ZXJ5IFNjYW4gIipTRUxFQ1QqIDEiIChjb3N0 PTAuMDAuLjUwNS43NiByb3dzPTE2OSB3aWR0aD04KSAoYWN0dWFsIHRpbWU9 MC4wNi4uMC42NSByb3dzPTU1IGxvb3BzPTEpIA0KICAtPiBJbmRleCBTY2Fu IHVzaW5nIG1lZGlhX2FjdF9pbmRleCBvbiBtZWRpYSAoY29zdD0wLjAwLi41 MDUuNzYgcm93cz0xNjkgd2lkdGg9OCkgKGFjdHVhbCB0aW1lPTAuMDYuLjAu NTMgcm93cz01NSBsb29wcz0xKSANCiAgSW5kZXggQ29uZDogKGFjdGl2aXR5 ID0gMzQ3NjY3OjpiaWdpbnQpIA0KICAtPiBTdWJxdWVyeSBTY2FuICIqU0VM RUNUKiAyIiAoY29zdD0wLjAwLi4xMTg3LjU3IHJvd3M9NzUgd2lkdGg9MjQp IChhY3R1YWwgdGltZT0wLjExLi44LjExIHJvd3M9MjA5IGxvb3BzPTEpIA0K ICAtPiBOZXN0ZWQgTG9vcCAoY29zdD0wLjAwLi4xMTg3LjU3IHJvd3M9NzUg d2lkdGg9MjQpIChhY3R1YWwgdGltZT0wLjEwLi43LjY4IHJvd3M9MjA5IGxv b3BzPTEpIA0KICAtPiBJbmRleCBTY2FuIHVzaW5nIHNldF9hY3RfaW5kZXgg b24gInNldCIgcyAoY29zdD0wLjAwLi4yNC4yMyByb3dzPTYgd2lkdGg9OCkg KGFjdHVhbCB0aW1lPTAuMDUuLjAuMDYgcm93cz0yIGxvb3BzPTEpIA0KICBJ bmRleCBDb25kOiAoYWN0aXZpdHkgPSAzNDc2Njc6OmJpZ2ludCkgDQogIC0+ IEluZGV4IFNjYW4gdXNpbmcgaW50c2V0bWVkaWFfc2V0X2luZGV4IG9uIGlu dHNldG1lZGlhIGlzbSAoY29zdD0wLjAwLi4yMDMuNDIgcm93cz02OCB3aWR0 aD0xNikgKGFjdHVhbCB0aW1lPTAuMDQuLjMuNTYgcm93cz0xMDQgbG9vcHM9 MikgDQogIEluZGV4IENvbmQ6IChpc20uInNldCIgPSAib3V0ZXIiLm9iamVj dGlkKSANCiAgLT4gSW5kZXggU2NhbiB1c2luZyBtZWRpYV9wa2V5IG9uIG1l ZGlhIG0gKGNvc3Q9MC4wMC4uNS4yMiByb3dzPTEgd2lkdGg9MjE3KSAoYWN0 dWFsIHRpbWU9MC4wMy4uMC4wMyByb3dzPTAgbG9vcHM9NTgpIA0KICBJbmRl eCBDb25kOiAobS5vYmplY3RpZCA9ICJvdXRlciIubWVkaWFpZCkgDQogIEZp bHRlcjogKG1lZGlhdHlwZSA9ICQwKSANCiBUb3RhbCBydW50aW1lOiAyMC4z NiBtc2VjIA0K --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb-- From pgsql-performance-owner@postgresql.org Mon Mar 24 22:26:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8586C475FBA for ; Mon, 24 Mar 2003 22:26:55 -0500 (EST) Received: from c001.snv.cp.net (h024.c001.snv.cp.net [209.228.32.139]) by postgresql.org (Postfix) with SMTP id 9E47E475F5F for ; Mon, 24 Mar 2003 22:26:54 -0500 (EST) Received: (cpmta 21322 invoked from network); 24 Mar 2003 19:26:58 -0800 Received: from 209.228.32.137 (HELO mail.dilger.cc.criticalpath.net) by smtp.register-admin.com (209.228.32.139) with SMTP; 24 Mar 2003 19:26:58 -0800 X-Sent: 25 Mar 2003 03:26:58 GMT Received: from [216.68.146.219] by mail.dilger.cc with HTTP; Mon, 24 Mar 2003 19:26:57 -0800 (PST) Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 To: oleg.lebedev@waterford.org Cc: pgsql-performance@postgresql.org From: "Nikolaus Dilger" Subject: Re: Slow query X-Sent-From: nikolaus@dilger.cc Date: Mon, 24 Mar 2003 19:26:57 -0800 (PST) X-Mailer: Web Mail 5.2.3-0_sol28 Message-Id: <20030324192658.6612.h022.c001.wm@mail.dilger.cc.criticalpath.net> X-Spam-Status: No, hits=-13.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/171 X-Sequence-Number: 1469 Oleg, My guess is that the query runs slow because by adding data you exceeded what your database can do in memory and you need to do some kind of disk sort. How about rewriting your query without the UNION and the EXISTS to something like SELECT * FROM media m WHERE m.mediatype =3D (SELECT objectid FROM mediatype=20 WHERE medianame=3D'Audio') AND ( m.activity=3D'347667' OR m.objectid IN ( SELECT s.objectid FROM intsetmedia ism, set s WHERE ism.set =3D s.objectid AND s.activity=3D'347667')) ORDER BY medianame ASC, status DESC Regards, Nikolaus Dilger On Mon, 24 Mar 2003, Oleg Lebedev wrote: Message Please help me speed=20 up the following query. It used to run in 2-5 sec., but now it takes 2-3=20 mins! I ran VACUUM FULL=20 ANALYZE and REINDEX. SELECT * FROM media=20 m WHERE m.mediatype =3D=20 (SELECT objectid FROM mediatype WHERE medianame=3D'Audio')=20 AND EXISTS=20 =A0=A0=A0=A0=A0=A0=A0 (SELECT * FROM=20 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 (SELECT objectid AS mediaid=20 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 FROM media=20 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 WHERE activity=3D'347667'=20 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 UNION=20 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 SELECT ism.media AS mediaid=20 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 FROM intsetmedia ism, set s=20 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 WHERE ism.set =3D s.objectid=20 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20 AND s.activity=3D'347667' ) AS a1=20 =A0=A0=A0=A0=A0=A0=A0 WHERE a1.mediaid =3D m.objectid=20 =A0=A0=A0=A0=A0=A0=A0 LIMIT 1)=20 ORDER BY medianame ASC, status DESC=20 =A0 Basically it tries=20 to find all Audios that are either explicitly attached to the given activity, or=20 attached to the given activity via a many-to-many relationship intsetmedia which=20 links records in table Interaction, Set, and Media. I attached the=20 output of EXPLAIN and schemas and indexes on the tables involved. Most of the=20 fields are not relevant to the query, but I listed them anyways. I discarded=20 trigger information, though. Thanks for your=20 help. =A0 Oleg ************************************* This email may contain privileged or confidential material intended for the named recipient only. If you are not the named recipient, delete this message and all attachments.=20=20 Any review, copying, printing, disclosure or other use is prohibited. We reserve the right to monitor email sent through our network. ************************************* From pgsql-performance-owner@postgresql.org Tue Mar 25 08:12:32 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C0371474E5C for ; Tue, 25 Mar 2003 08:12:31 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id CA616474E44 for ; Tue, 25 Mar 2003 08:12:30 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18xoEE-0005Pk-00 for ; Tue, 25 Mar 2003 08:12:34 -0500 Date: Tue, 25 Mar 2003 08:12:34 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Finding the PID keeping a transaction open Message-ID: <20030325081233.B18817@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Spam-Status: No, hits=-12.1 required=5.0 tests=BAYES_10,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/172 X-Sequence-Number: 1470 Hi, Using 7.2.3 and 7.2.4 (the last .3 is being retired this weekend). I'm struggling with an application which is keeping open a transaction (or, likely from the results, more than one) against a pair of frequently-updated tables. Unfortunately, the frequently-updated tables are also a performance bottleneck. These tables are small, but their physical size is very large, because of all the updates. The problem is, of course, that vacuum isn't working because _something_ is holding open the transaction. But I can't tell what. We connect to the database via JDBC; we have a pool which recycles its connections. In the next version of the pool, the autocommit foolishness (end transaction and issue immediate BEGIN) is gone, but that won't help me in the case at hand. What I'm trying to figure out is whether there is a way to learn which pids are responsible for the long-running transaction(s) that touch(es) the candidate tables. Then I can find a way of paring those processes back, so that I can get vacuum to succeed. I think there must be a way with gdb, but I'm stumped. Any suggestions? The time a process has been living is not a guide, because the connections (and hence processes) get recycled in the pool. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Mar 25 09:37:40 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C72F8475A71 for ; Tue, 25 Mar 2003 09:37:39 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0887B474E44 for ; Tue, 25 Mar 2003 09:37:39 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2PEbfub028391; Tue, 25 Mar 2003 09:37:42 -0500 (EST) To: Andrew Sullivan Cc: pgsql-performance@postgresql.org Subject: Re: Finding the PID keeping a transaction open In-reply-to: <20030325081233.B18817@mail.libertyrms.com> References: <20030325081233.B18817@mail.libertyrms.com> Comments: In-reply-to Andrew Sullivan message dated "Tue, 25 Mar 2003 08:12:34 -0500" Date: Tue, 25 Mar 2003 09:37:41 -0500 Message-ID: <28390.1048603061@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/173 X-Sequence-Number: 1471 Andrew Sullivan writes: > What I'm trying to figure out is whether there is a way to learn > which pids are responsible for the long-running transaction(s) that > touch(es) the candidate tables. In 7.3 you could look at the pg_locks system view, but I can't think of any reasonable way to do it in 7.2 :-( > I think there must be a way with gdb, but I'm stumped. The lock structures are arcane enough that manual examination with gdb would take many minutes --- which you'd have to do with the LockMgr lock held to keep them from changing underneath you. This seems quite unworkable for a production database ... It's conceivable that some version of the pg_locks code could be back-ported to 7.2 --- you'd have to settle for dumping the info to the log, probably, due to lack of table-function support, but it could be done. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Mar 25 10:30:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B86E6475A71 for ; Tue, 25 Mar 2003 10:30:46 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 7B204474E44 for ; Tue, 25 Mar 2003 10:30:45 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18xqO1-0007RP-00 for ; Tue, 25 Mar 2003 10:30:49 -0500 Date: Tue, 25 Mar 2003 10:30:49 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Finding the PID keeping a transaction open Message-ID: <20030325103049.A28249@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20030325081233.B18817@mail.libertyrms.com> <28390.1048603061@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <28390.1048603061@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Tue, Mar 25, 2003 at 09:37:41AM -0500 X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/174 X-Sequence-Number: 1472 On Tue, Mar 25, 2003 at 09:37:41AM -0500, Tom Lane wrote: > In 7.3 you could look at the pg_locks system view, but I can't think > of any reasonable way to do it in 7.2 :-( Thanks. I was afraid you'd say that. Rats. > would take many minutes --- which you'd have to do with the LockMgr lock > held to keep them from changing underneath you. This seems quite Well, then, _that's_ a non-starter. Ugh. > It's conceivable that some version of the pg_locks code could be > back-ported to 7.2 --- you'd have to settle for dumping the info to > the log, probably, due to lack of table-function support, but it > could be done. I think it's probably better just to work on making the whole thing work correctly with 7.3, instead. I'm keen to move it, and 7.3 seems stable enough, so I'm inclined just to move that up in priority. Thanks, A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From dharana@gamersmafia.com Tue Mar 25 21:34:06 2003 Received: from unknown (HELO gamersmafia.com) (80.38.119.191) by 0 with SMTP; 25 Mar 2003 20:34:05 -0000 Message-ID: <3E80BCBE.3000205@gamersmafia.com> Date: Tue, 25 Mar 2003 21:31:58 +0100 From: dharana User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: What's better: one huge database or several smaller ones? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=0.0 required=10.0 tests= version=2.20 X-Spam-Level: I'm planning to develop a website network with n network nodes. There will be a central node (website) wich will summarize information from all the network nodes. It will be also possible to use data between nodes (node A showing own data + data from node B). Table structures between nodes will be identical. So my question is: what should i do, put all the data in one huge database or spread it in several nearly identical databases? Data generated will grow at a rate of ~ 250Mb/year; 10000 rows per table (size is physical space of /var/lib/postgres/data after vacuum analyze, this dir contains only one database). Thank you in advance, dharana From pgsql-performance-owner@postgresql.org Tue Mar 25 15:32:07 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0388747610A for ; Tue, 25 Mar 2003 15:32:06 -0500 (EST) Received: from 4unrealers.com (unknown [217.172.66.233]) by postgresql.org (Postfix) with SMTP id 105C0475F26 for ; Tue, 25 Mar 2003 15:32:04 -0500 (EST) Received: (qmail 16667 invoked from network); 25 Mar 2003 20:34:05 -0000 Message-Id: <20030325203204.105C0475F26@postgresql.org> Date: Tue, 25 Mar 2003 15:32:04 -0500 (EST) From: dharana@gamersmafia.com To: undisclosed-recipients: ; X-Spam-Status: No, hits=-4.7 required=5.0 tests=BAYES_01,MSG_ID_ADDED_BY_MTA_3,NO_REAL_NAME version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/175 X-Sequence-Number: 1473 From pgsql-performance-owner@postgresql.org Wed Mar 26 09:17:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A44BD475F00 for ; Wed, 26 Mar 2003 09:17:50 -0500 (EST) Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id 04A88475CBC for ; Wed, 26 Mar 2003 09:17:46 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id 3033D1384F9; Wed, 26 Mar 2003 09:17:48 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18yBit-0001FJ-00; Wed, 26 Mar 2003 09:17:47 -0500 To: bsamwel@xs4all.nl Cc: pgsql-performance@postgresql.org Subject: Re: Adding a foreign key constraint is extremely slow References: <20505.194.109.187.67.1048442304.squirrel@webmail.xs4all.nl> In-Reply-To: <20505.194.109.187.67.1048442304.squirrel@webmail.xs4all.nl> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 26 Mar 2003 09:17:47 -0500 Message-ID: <874r5qmctw.fsf@stark.dyndns.tv> Lines: 19 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/177 X-Sequence-Number: 1475 bsamwel@xs4all.nl writes: > alter table triples add foreign key(id1) references wwwlog(id); > > PostgreSQL starts doing heavy work for at least one and a half hour, and I > broke it off at that. It is not possible to "explain" a statement like > this! Probably what it does is that it will check the foreign key > constraint for every field in the table. This will make it completely > impossible to load my data, because: > > (2) I cannot set the foreign key constraints AFTER loading the 0.9 million > records because I've got no clue at all how long this operation is going > to take. Try adding an index on wwwlog(id) so that it can check the constraint without doing a full table scan for each value being checked. -- greg From pgsql-performance-owner@postgresql.org Wed Mar 26 12:08:59 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8F97947631A for ; Wed, 26 Mar 2003 12:08:57 -0500 (EST) Received: from smtpzilla5.xs4all.nl (smtpzilla5.xs4all.nl [194.109.127.141]) by postgresql.org (Postfix) with ESMTP id 0EEA4476332 for ; Wed, 26 Mar 2003 12:08:54 -0500 (EST) Received: from liacs.nl (zappa.liacs.nl [132.229.137.201]) by smtpzilla5.xs4all.nl (8.12.0/8.12.0) with ESMTP id h2QH8r0j049051; Wed, 26 Mar 2003 18:08:56 +0100 (CET) Message-ID: <3E81DEA3.7060305@liacs.nl> Date: Wed, 26 Mar 2003 18:08:51 +0100 From: Bart Samwel User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030316 Debian/1.3-1 X-Accept-Language: en MIME-Version: 1.0 To: Greg Stark Cc: bsamwel@xs4all.nl, pgsql-performance@postgresql.org Subject: Re: Adding a foreign key constraint is extremely slow References: <20505.194.109.187.67.1048442304.squirrel@webmail.xs4all.nl> <874r5qmctw.fsf@stark.dyndns.tv> In-Reply-To: <874r5qmctw.fsf@stark.dyndns.tv> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-34.8 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/178 X-Sequence-Number: 1476 Greg Stark wrote: > bsamwel@xs4all.nl writes: > > >>alter table triples add foreign key(id1) references wwwlog(id); >> >>PostgreSQL starts doing heavy work for at least one and a half hour, and I >>broke it off at that. It is not possible to "explain" a statement like >>this! Probably what it does is that it will check the foreign key >>constraint for every field in the table. This will make it completely >>impossible to load my data, because: >> >>(2) I cannot set the foreign key constraints AFTER loading the 0.9 million >>records because I've got no clue at all how long this operation is going >>to take. > > > Try adding an index on wwwlog(id) so that it can check the constraint without > doing a full table scan for each value being checked. AFAIK, because wwwlog(id) is the primary key, this index already exists implicitly. Still, 0.9 million separate index lookups are too slow for my purposes, if for example it takes something as low as 1 ms per lookup it will still take 900 seconds (= 15 minutes) to complete. As the complete adding of the foreign key constraint took about an hour, that would suggest an average of 4 ms per lookup, which suggests that the index is, in fact, present. :) Anyway, I've actually waited for the operation to complete. The problem is out of my way for now. Bart -- Leiden Institute of Advanced Computer Science (http://www.liacs.nl) E-mail: bsamwel@liacs.nl Telephone: +31-71-5277037 Homepage: http://www.liacs.nl/~bsamwel Opinions stated in this e-mail are mine and not necessarily my employer's. From pgsql-performance-owner@postgresql.org Wed Mar 26 05:52:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4A5B3475CBC for ; Wed, 26 Mar 2003 05:52:12 -0500 (EST) Received: from khyber.enigma (mail.dpsl.net [202.144.16.187]) by postgresql.org (Postfix) with ESMTP id E68BC474E44 for ; Wed, 26 Mar 2003 05:52:09 -0500 (EST) Received: by mail.dpsl.net with Internet Mail Service (5.5.2653.19) id ; Wed, 26 Mar 2003 16:23:18 +0530 Received: from khyber.enigma (mail.dpsl.net [202.144.16.187]) by khyber.enigma with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id HPB84PWV; Wed, 26 Mar 2003 16:23:12 +0530 Received: FROM comp158 BY khyber.enigma ; Wed Mar 26 16:23:11 2003 +0500 From: Abhishek Sharma Reply-To: Abhishek Sharma To: pgsql-performance@postgresql.org Subject: Date: Wed, 26 Mar 2003 16:26:01 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Spam-Status: No, hits=-6.4 required=5.0 tests=BAYES_30,DATE_IN_FUTURE_12_24,MSGID_GOOD_EXCHANGE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/176 X-Sequence-Number: 1474 subscribe end From pgsql-performance-owner@postgresql.org Thu Mar 27 11:58:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A9EC1474E44 for ; Thu, 27 Mar 2003 11:58:02 -0500 (EST) Received: from wbs01.dbasetek.com (host210.dbasetek.com [66.134.187.210]) by postgresql.org (Postfix) with ESMTP id E26DB476331 for ; Thu, 27 Mar 2003 11:57:57 -0500 (EST) Received: from dbasetek.com (lt001.dbasetek.com [192.168.1.58]) by wbs01.dbasetek.com (8.11.6/8.11.2) with ESMTP id h2RGw2C27472 for ; Thu, 27 Mar 2003 10:58:02 -0600 Message-ID: <3E832DA0.9010604@dbasetek.com> Date: Thu, 27 Mar 2003 10:58:08 -0600 From: Robert D Oden User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: max_fsm settings Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-9.4 required=5.0 tests=BAYES_20,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/179 X-Sequence-Number: 1477 I have not been able to find any documentation on how to determine the proper settings for the max_fsm_relations and the max_fsm_pages config options. Any help would be appreciated. Thanks Doug Oden From pgsql-performance-owner@postgresql.org Thu Mar 27 16:11:00 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CE2C947580B for ; Thu, 27 Mar 2003 16:10:59 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id 7AFCD476241 for ; Thu, 27 Mar 2003 16:10:28 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h2RLjn6P019154; Thu, 27 Mar 2003 16:45:50 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id h2RLALp09124; Thu, 27 Mar 2003 16:10:23 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id F3HTK9R7; Thu, 27 Mar 2003 16:10:20 -0500 Subject: Re: max_fsm settings From: Robert Treat To: Robert D Oden Cc: pgsql-performance@postgresql.org In-Reply-To: <3E832DA0.9010604@dbasetek.com> References: <3E832DA0.9010604@dbasetek.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 27 Mar 2003 16:10:21 -0500 Message-Id: <1048799421.13798.1337.camel@camel> Mime-Version: 1.0 X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/180 X-Sequence-Number: 1478 The mail archives are a wonderful place, check out this thread and the discussion that followed. http://fts.postgresql.org/db/mw/msg.html?mid=1360953 Robert Treat On Thu, 2003-03-27 at 11:58, Robert D Oden wrote: > I have not been able to find any documentation on how to determine the > proper settings for the max_fsm_relations and the max_fsm_pages config > options. Any help would be appreciated. > > Thanks > > Doug Oden From pgsql-performance-owner@postgresql.org Fri Mar 28 10:42:50 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DD42D475ED4 for ; Fri, 28 Mar 2003 10:42:49 -0500 (EST) Received: from geek.artcobell.com (unknown [63.114.209.181]) by postgresql.org (Postfix) with SMTP id 0F19C475E77 for ; Fri, 28 Mar 2003 10:42:48 -0500 (EST) Received: (qmail 15788 invoked from network); 28 Mar 2003 15:38:52 -0000 Received: from unknown (HELO localhost) (127.0.0.1) by localhost.uu.net with SMTP; 28 Mar 2003 15:38:52 -0000 From: Jeremiah Elliott Reply-To: jelliott@artcobell.com Organization: Artco-Bell Corp. To: pgsql-performance@postgresql.org Subject: slow query - where not in Date: Fri, 28 Mar 2003 09:38:50 -0600 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200303280938.50382.jelliott@artcobell.com> X-Spam-Status: No, hits=-5.8 required=5.0 tests=BAYES_10,USER_AGENT version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/181 X-Sequence-Number: 1479 here is the query that is killing me: select shoporder from sodetailtabletrans where shoporder not in(select shoporder from soheadertable) This is just an example query. Any time I use 'where not in(' it takes several hours to return a resultset. The postgres version is 7.2.3 although I have tried it on my test server which has 7.3 on it and it runs just as slow. The server is a fast server 2GHz with a gig of ram. I have tried several differant index setups but nothing seems to help. soheadertable - 5104 rows CREATE TABLE "soheadertable" ( "shoporder" numeric(10,0) NOT NULL, "initrundate" date, "actualrundate" date, "processedminutes" numeric(10,0), "starttime" timestamptz, "endtime" timestamptz, "line" int4, "personcount" numeric(10,0), "product" varchar(15), "qtytomake" numeric(10,3), "linestatus" numeric(2,0) DEFAULT 1, "finishlinestatus" numeric(2,0) DEFAULT 1, "qtyinqueue" numeric(10,3), "lastcartonprinted" numeric(10,0), "qtydone" int8, "warehouse" text, "rescheduledate" date, "calculateddatetorun" date ); CREATE UNIQUE INDEX "shoporder_soheadertable_ukey" ON "soheadertable" ("shoporder"); sodetailtabletrans - 31494 rows CREATE TABLE "sodetailtabletrans" ( "shoporder" numeric(10,0) NOT NULL, "soseq" numeric(5,0) NOT NULL, "product" char(15) NOT NULL, "qtyqueued" numeric(17,2), "qtyneeded" numeric(17,2), "qtyallocated" numeric(17,2), "qtyused" numeric(17,2), "linestatus" numeric(2,0) DEFAULT 1, "unitsperenditem" numeric(10,1), CONSTRAINT "sodetailtrans_pk" PRIMARY KEY ("shoporder", "soseq") -Jeremiah Elliott jelliott@artcobell.com ); From pgsql-performance-owner@postgresql.org Fri Mar 28 10:59:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 17DD0475ED4 for ; Fri, 28 Mar 2003 10:59:55 -0500 (EST) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id 697AD475E77 for ; Fri, 28 Mar 2003 10:59:54 -0500 (EST) Received: (qmail 10916 invoked by uid 500); 28 Mar 2003 15:59:33 -0000 Date: Fri, 28 Mar 2003 09:59:33 -0600 From: Bruno Wolff III To: Jeremiah Elliott Cc: pgsql-performance@postgresql.org Subject: Re: slow query - where not in Message-ID: <20030328155933.GA10761@wolff.to> Mail-Followup-To: Jeremiah Elliott , pgsql-performance@postgresql.org References: <200303280938.50382.jelliott@artcobell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200303280938.50382.jelliott@artcobell.com> User-Agent: Mutt/1.3.25i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/182 X-Sequence-Number: 1480 On Fri, Mar 28, 2003 at 09:38:50 -0600, Jeremiah Elliott wrote: > here is the query that is killing me: > > select shoporder from sodetailtabletrans where shoporder not in(select > shoporder from soheadertable) This will probably work better in 7.4. For now there are several ways to rewrite this query. If there are no null values for shoporder in soheadertable or sodetailtabletrans you can use not exists instead of not in: select shoporder from sodetailtabletrans where shoporder not exists(select shoporder from soheadertable) You can use set difference to calculate the result: select shoporder from sodetailtabletrans except all select shoporder from soheadertable If there are no null values for shoporder in one of sodetailtabletrans or soheadertable you can user an outer join with a restriction that limits the rows of interest to those that don't match: select sodetailtabletrans.shoporder from sodetailtabletrans left join soheadertable using (shoporder) where soheadertable.shoporder is null From pgsql-performance-owner@postgresql.org Fri Mar 28 11:20:31 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 73B10476356 for ; Fri, 28 Mar 2003 11:20:30 -0500 (EST) Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id C122747634B for ; Fri, 28 Mar 2003 11:20:29 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id 3E9611381D8; Fri, 28 Mar 2003 11:20:32 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18ywal-0005W4-00; Fri, 28 Mar 2003 11:20:31 -0500 To: jelliott@artcobell.com Cc: pgsql-performance@postgresql.org Subject: Re: slow query - where not in References: <200303280938.50382.jelliott@artcobell.com> In-Reply-To: <200303280938.50382.jelliott@artcobell.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 28 Mar 2003 11:20:29 -0500 Message-ID: <87u1dn31ki.fsf@stark.dyndns.tv> Lines: 36 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/183 X-Sequence-Number: 1481 Jeremiah Elliott writes: > here is the query that is killing me: > > select shoporder from sodetailtabletrans where shoporder not in(select > shoporder from soheadertable) > > This is just an example query. Any time I use 'where not in(' it takes several > hours to return a resultset. The postgres version is 7.2.3 although I have > tried it on my test server which has 7.3 on it and it runs just as slow. The > server is a fast server 2GHz with a gig of ram. I have tried several > differant index setups but nothing seems to help. This should be improved with 7.4, however there are some other things you can try now. try SELECT shoporder FROM sodetailtabletrans WHERE NOT EXISTS ( SELECT 1 FROM soheadertable WHERE shoporder = sodetailtabletrans.shoporder ) or else try something like SELECT a.shoporder FROM sodetailtabletrans as a LEFT OUTER JOIN soheadertable as b ON (a.shoporder = b.shoporder) WHERE b.shoporder IS NULL -- greg From pgsql-performance-owner@postgresql.org Fri Mar 28 11:50:10 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B078E475E77 for ; Fri, 28 Mar 2003 11:50:09 -0500 (EST) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 8527447580B for ; Fri, 28 Mar 2003 11:50:08 -0500 (EST) Received: (qmail 6682 invoked by uid 65534); 28 Mar 2003 16:50:12 -0000 Received: from chello062178186201.1.15.tuwien.teleweb.at (EHLO beeblebrox) (62.178.186.201) by mail.gmx.net (mp014-rz3) with SMTP; 28 Mar 2003 17:50:12 +0100 Message-ID: <028e01c2f54a$9af3d010$3201a8c0@beeblebrox> From: "Michael Paesold" To: "Bruno Wolff III" , "Jeremiah Elliott" Cc: References: <200303280938.50382.jelliott@artcobell.com> <20030328155933.GA10761@wolff.to> Subject: Re: slow query - where not in Date: Fri, 28 Mar 2003 17:53:46 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Status: No, hits=-25.8 required=5.0 tests=BAYES_20,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/184 X-Sequence-Number: 1482 Bruno Wolff III wrote: > Jeremiah Elliott wrote: > > here is the query that is killing me: > > > > select shoporder from sodetailtabletrans where shoporder not in(select > > shoporder from soheadertable) > > If there are no null values for shoporder in soheadertable or > sodetailtabletrans you can use not exists instead of not in: > select shoporder from sodetailtabletrans where shoporder not exists(select > shoporder from soheadertable) I think this should rather be: SELECT shoporder FROM sodetailtabletrans WHERE NOT EXISTS ( SELECT 1 FROM soheadertable WHERE soheadertable.shoporder = sodetailtabletrans.shoporder ) Regards, Michael Paesold From pgsql-performance-owner@postgresql.org Fri Mar 28 12:04:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9FDB7475ED4 for ; Fri, 28 Mar 2003 12:04:46 -0500 (EST) Received: from mescalin.tbi.univie.ac.at (mescalin.tbi.univie.ac.at [131.130.44.61]) by postgresql.org (Postfix) with ESMTP id 73EC1475E91 for ; Fri, 28 Mar 2003 12:04:42 -0500 (EST) Received: from localhost (ulim@localhost) by mescalin.tbi.univie.ac.at (8.11.6/8.11.2) with ESMTP id h2SH4l505287 for ; Fri, 28 Mar 2003 18:04:47 +0100 Date: Fri, 28 Mar 2003 18:04:47 +0100 (CET) From: Ulli Mueckstein To: pgsql-performance@postgresql.org Subject: calling analyze from a stored procedure in C Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-12.1 required=5.0 tests=BAYES_00,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/185 X-Sequence-Number: 1483 Hi everybody! I have to insert a lot of data (more than 1.000.000 rows) in various tables. I use stored procedures in C to insert the data. It is necessary to run ANALYZE after inserting a few thousand rows into a table. Can someone tell me how to call ANALYZE (or analyze_rel(Oid relid, VacuumStmt *vacstmt)) from a C stored procedure ? Any help would be appreciated. Thanks Ulli Mueckstein -- From pgsql-performance-owner@postgresql.org Fri Mar 28 12:54:19 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 02A99475E77 for ; Fri, 28 Mar 2003 12:54:17 -0500 (EST) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id 28FA347580B for ; Fri, 28 Mar 2003 12:54:16 -0500 (EST) Received: (qmail 12758 invoked by uid 500); 28 Mar 2003 17:53:56 -0000 Date: Fri, 28 Mar 2003 11:53:56 -0600 From: Bruno Wolff III To: Michael Paesold Cc: Jeremiah Elliott , pgsql-performance@postgresql.org Subject: Re: slow query - where not in Message-ID: <20030328175356.GA12549@wolff.to> Mail-Followup-To: Michael Paesold , Jeremiah Elliott , pgsql-performance@postgresql.org References: <200303280938.50382.jelliott@artcobell.com> <20030328155933.GA10761@wolff.to> <028e01c2f54a$9af3d010$3201a8c0@beeblebrox> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <028e01c2f54a$9af3d010$3201a8c0@beeblebrox> User-Agent: Mutt/1.3.25i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/186 X-Sequence-Number: 1484 On Fri, Mar 28, 2003 at 17:53:46 +0100, Michael Paesold wrote: > Bruno Wolff III wrote: > > I think this should rather be: > > SELECT shoporder FROM sodetailtabletrans > WHERE NOT EXISTS ( > SELECT 1 FROM soheadertable > WHERE soheadertable.shoporder = sodetailtabletrans.shoporder > ) Thanks for catching my mistake. From pgsql-performance-owner@postgresql.org Fri Mar 28 16:03:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8141A475C3D for ; Fri, 28 Mar 2003 16:03:33 -0500 (EST) Received: from geek.artcobell.com (unknown [63.114.209.181]) by postgresql.org (Postfix) with SMTP id 1748C475458 for ; Fri, 28 Mar 2003 16:03:30 -0500 (EST) Received: (qmail 18609 invoked from network); 28 Mar 2003 20:58:58 -0000 Received: from unknown (HELO localhost) (127.0.0.1) by localhost.uu.net with SMTP; 28 Mar 2003 20:58:58 -0000 From: Jeremiah Elliott Reply-To: jelliott@artcobell.com Organization: Artco-Bell Corp. To: pgsql-performance@postgresql.org Subject: Re: slow query - where not in Date: Fri, 28 Mar 2003 14:58:48 -0600 User-Agent: KMail/1.5 References: <200303280938.50382.jelliott@artcobell.com> <028e01c2f54a$9af3d010$3201a8c0@beeblebrox> <20030328175356.GA12549@wolff.to> In-Reply-To: <20030328175356.GA12549@wolff.to> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200303281458.48326.jelliott@artcobell.com> X-Spam-Status: No, hits=-12.8 required=5.0 tests=BAYES_20,IN_REP_TO,REFERENCES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/187 X-Sequence-Number: 1485 thanks guys - Greg, Bruno and Michael. That made a world of diferance. thx -Jeremiah From pgsql-performance-owner@postgresql.org Sat Mar 29 04:49:29 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9C874474E4F for ; Sat, 29 Mar 2003 04:49:24 -0500 (EST) Received: from smtp.inode.at (smtp-01.inode.at [62.99.194.3]) by postgresql.org (Postfix) with ESMTP id 4D5D3474E42 for ; Sat, 29 Mar 2003 04:49:23 -0500 (EST) Received: from line-c-227.adsl-dynamic.inode.at ([62.99.151.227]:35123 helo=andi-lap) by smtp.inode.at with smtp (Exim 4.10) id 18zCwi-0005BU-00 for pgsql-performance@postgresql.org; Sat, 29 Mar 2003 10:48:17 +0100 Received: by andi-lap (sSMTP sendmail emulation); Sat, 29 Mar 2003 10:49:19 +0100 Subject: Index not used, performance problem From: Andreas Kostyrka To: pgsql-performance@postgresql.org Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-d6Iv6pE/ZRMcQ9VEKCxJ" Organization: Message-Id: <1048931358.7539.11.camel@andi-lap> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 29 Mar 2003 10:49:19 +0100 X-Spam-Status: No, hits=-19.2 required=5.0 tests=BAYES_01,PGP_SIGNATURE_2,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/188 X-Sequence-Number: 1486 --=-d6Iv6pE/ZRMcQ9VEKCxJ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi! I've got the following problem: PostgreSQL 7.2.1-2 (Debian) on Duron/700MHz, 512MB, IDE hdd (laptop). I've got a table that has 6400 rows, an index on the deleted, nachname, vorname and hvvsnummer attributes, and my O-R wrapper generate queries like this: SELECT patient.id, patient.vorname, patient.nachname, patient.titel, patient.geburtsdatum, patient.hvvsnummer, patient.geschlecht, patient.adresse_id, patient.beruf, patient.kommentar, patient.cave, patient.zusatzversicherung, patient.deleted FROM patient WHERE ((((patient.deleted =3D 'f') AND (patient.nachname LIKE 'K%')) AND (patient.vorname LIKE '%')) AND (patient.hvvsnummer LIKE '%')) This results in a SeqScan von patient. Even more curious is that simpler queries like=20 select * from patient where deleted=3D'f'; OR: select * from patient where nachname LIKE 'K%'; all result in SeqScan on patient. I've "analyzed" and "reindex" the table already multiple times, and still PostgreSQL insists upon not using any index. TIA for any pointers, Andreas mpp2=3D# \d patient Table "patient" Column | Type | Modifiers --------------------+--------------+------------- id | integer | not null vorname | text | not null nachname | text | not null titel | text | geburtsdatum | date | hvvsnummer | text | geschlecht | character(1) | adresse_id | integer | beruf | text | kommentar | text | cave | text | zusatzversicherung | text | deleted | boolean | default 'f' Indexes: patient_deleted, patient_hvvsnummer, patient_nachname, patient_vorname Primary key: patient_pkey Check constraints: "patient_geschlecht" (((geschlecht =3D 'm'::bpchar) OR (geschlecht =3D 'w'::bpchar)) OR (geschlecht =3D '?'::bpchar)) Triggers: RI_ConstraintTrigger_352787, RI_ConstraintTrigger_352789, RI_ConstraintTrigger_352801, RI_ConstraintTrigger_352803, RI_ConstraintTrigger_352815 mpp2=3D# select count(*) from patient; count ------- 6406 (1 row) mpp2=3D# explain SELECT * FROM patient WHERE (patient.nachname LIKE 'K%'); NOTICE: QUERY PLAN: Seq Scan on patient (cost=3D0.00..173.07 rows=3D272 width=3D70) EXPLAIN mpp2=3D# explain SELECT * FROM patient WHERE NOT deleted; NOTICE: QUERY PLAN: Seq Scan on patient (cost=3D0.00..157.06 rows=3D6406 width=3D70) EXPLAIN mpp2=3D# explain SELECT * FROM patient WHERE deleted=3D'f'; NOTICE: QUERY PLAN: Seq Scan on patient (cost=3D0.00..173.07 rows=3D6406 width=3D70) EXPLAIN --=-d6Iv6pE/ZRMcQ9VEKCxJ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA+hWweHJdudm4KnO0RAjaJAKCGChqjgKaA2sEHozzyGhFgjkYrOACgnKcR pIaNAHrqykZ1xEfnGd2OBo0= =l/Ao -----END PGP SIGNATURE----- --=-d6Iv6pE/ZRMcQ9VEKCxJ-- From pgsql-performance-owner@postgresql.org Sat Mar 29 08:48:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 38014475A45 for ; Sat, 29 Mar 2003 08:48:06 -0500 (EST) Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id BD6A4474E42 for ; Sat, 29 Mar 2003 08:48:03 -0500 (EST) Received: from localhost (chriskl@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) with ESMTP id h2TDlpk04736; Sat, 29 Mar 2003 21:47:54 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Date: Sat, 29 Mar 2003 21:47:51 +0800 (WST) From: Christopher Kings-Lynne To: Andreas Kostyrka Cc: pgsql-performance@postgresql.org Subject: Re: Index not used, performance problem In-Reply-To: <1048931358.7539.11.camel@andi-lap> Message-ID: <20030329214139.N4697-100000@houston.familyhealth.com.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/189 X-Sequence-Number: 1487 Hi Andreas, A few points: PostgreSQL is rarely going to use an index for a boolean column. The reason is that since almost by definition true will occupy 50% of the rows and false will occupy 50% (say). In this case, a sequential scan is always faster. You would say that the 'selectivity' isn't good enough. As for the LIKE searches, the only ones that PostgreSQL can index are of the form 'FOO%', which is what you are doing. However, I believe that PostgreSQL cannot do this if your database encoding is anything other than 'C'. So, if you are using an Austrian encoding, it might not be able to use the index. Some things to try: If you are always seeking over all four columns, then drop the 4 individual indexes and create one like this: create index my_key on patient(nachname, vorname, hvvsnummer); That would be more efficient, in the C locale. Also, what is the point of searching for LIKE '%'? Why not just leave that out? Chris On 29 Mar 2003, Andreas Kostyrka wrote: > Hi! > > I've got the following problem: > PostgreSQL 7.2.1-2 (Debian) on Duron/700MHz, 512MB, IDE hdd (laptop). > > I've got a table that has 6400 rows, an index on the deleted, nachname, > vorname and hvvsnummer attributes, and my O-R wrapper generate queries > like this: > > SELECT patient.id, patient.vorname, patient.nachname, patient.titel, > patient.geburtsdatum, patient.hvvsnummer, patient.geschlecht, > patient.adresse_id, patient.beruf, patient.kommentar, patient.cave, > patient.zusatzversicherung, patient.deleted FROM patient WHERE > ((((patient.deleted = 'f') AND (patient.nachname LIKE 'K%')) AND > (patient.vorname LIKE '%')) AND (patient.hvvsnummer LIKE '%')) > > This results in a SeqScan von patient. Even more curious is that simpler > queries like > > select * from patient where deleted='f'; OR: > select * from patient where nachname LIKE 'K%'; > > all result in SeqScan on patient. > > I've "analyzed" and "reindex" the table already multiple times, and > still PostgreSQL insists upon not using any index. > > TIA for any pointers, > > Andreas > > mpp2=# \d patient > Table "patient" > Column | Type | Modifiers > --------------------+--------------+------------- > id | integer | not null > vorname | text | not null > nachname | text | not null > titel | text | > geburtsdatum | date | > hvvsnummer | text | > geschlecht | character(1) | > adresse_id | integer | > beruf | text | > kommentar | text | > cave | text | > zusatzversicherung | text | > deleted | boolean | default 'f' > Indexes: patient_deleted, > patient_hvvsnummer, > patient_nachname, > patient_vorname > Primary key: patient_pkey > Check constraints: "patient_geschlecht" (((geschlecht = 'm'::bpchar) OR > (geschlecht = 'w'::bpchar)) OR (geschlecht = '?'::bpchar)) > Triggers: RI_ConstraintTrigger_352787, > RI_ConstraintTrigger_352789, > RI_ConstraintTrigger_352801, > RI_ConstraintTrigger_352803, > RI_ConstraintTrigger_352815 > > mpp2=# select count(*) from patient; > count > ------- > 6406 > (1 row) > > mpp2=# explain SELECT * FROM patient WHERE (patient.nachname LIKE 'K%'); > NOTICE: QUERY PLAN: > > Seq Scan on patient (cost=0.00..173.07 rows=272 width=70) > > EXPLAIN > mpp2=# explain SELECT * FROM patient WHERE NOT deleted; > NOTICE: QUERY PLAN: > > Seq Scan on patient (cost=0.00..157.06 rows=6406 width=70) > > EXPLAIN > mpp2=# explain SELECT * FROM patient WHERE deleted='f'; > NOTICE: QUERY PLAN: > > Seq Scan on patient (cost=0.00..173.07 rows=6406 width=70) > > EXPLAIN > > > From pgsql-performance-owner@postgresql.org Sat Mar 29 10:34:50 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0BBCA475A45 for ; Sat, 29 Mar 2003 10:34:49 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 220B8474E42 for ; Sat, 29 Mar 2003 10:34:48 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18zIM8-0004Ky-00 for ; Sat, 29 Mar 2003 10:34:52 -0500 Date: Sat, 29 Mar 2003 10:34:52 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Index not used, performance problem Message-ID: <20030329103452.B16250@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <1048931358.7539.11.camel@andi-lap> <20030329214139.N4697-100000@houston.familyhealth.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20030329214139.N4697-100000@houston.familyhealth.com.au>; from chriskl@familyhealth.com.au on Sat, Mar 29, 2003 at 09:47:51PM +0800 X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/190 X-Sequence-Number: 1488 On Sat, Mar 29, 2003 at 09:47:51PM +0800, Christopher Kings-Lynne wrote: > the form 'FOO%', which is what you are doing. However, I believe that > PostgreSQL cannot do this if your database encoding is anything other than > 'C'. So, if you are using an Austrian encoding, it might not be able to That is, you need to have had the LOCALE set to 'C' when you did initdb. It's not enough to change it afterwards. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Sat Mar 29 11:48:36 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CBE704758F1 for ; Sat, 29 Mar 2003 11:48:34 -0500 (EST) Received: from mail3.centurytel.net (mail3.centurytel.net [209.142.136.99]) by postgresql.org (Postfix) with ESMTP id 0E235474E42 for ; Sat, 29 Mar 2003 11:48:30 -0500 (EST) Received: from localhost.localdomain (pppoe0716.grp.centurytel.net [64.91.27.209]) by mail3.centurytel.net (8.12.8/8.12.8) with ESMTP id h2TGmYTP017135 for ; Sat, 29 Mar 2003 10:48:34 -0600 (CST) Content-Type: text/plain; charset="iso-8859-1" From: "John K. Herreshoff" To: pgsql-performance@postgresql.org Subject: Re: Index not used, performance problem Date: Sat, 29 Mar 2003 11:49:00 -0500 User-Agent: KMail/1.4.3 References: <1048931358.7539.11.camel@andi-lap> <20030329214139.N4697-100000@houston.familyhealth.com.au> <20030329103452.B16250@mail.libertyrms.com> In-Reply-To: <20030329103452.B16250@mail.libertyrms.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200303291149.00790.jkherr@centurytel.net> X-Spam-Status: No, hits=-38.1 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/191 X-Sequence-Number: 1489 In Linux (Redhat) where, exactly, does one set the LOCALE to C? TIA :-) John. On Saturday 29 March 2003 10:34 am, Andrew Sullivan wrote: > On Sat, Mar 29, 2003 at 09:47:51PM +0800, Christopher Kings-Lynne wrote: > > the form 'FOO%', which is what you are doing. However, I believe that > > PostgreSQL cannot do this if your database encoding is anything other > > than 'C'. So, if you are using an Austrian encoding, it might not be > > able to > > That is, you need to have had the LOCALE set to 'C' when you did > initdb. It's not enough to change it afterwards. > > A From pgsql-performance-owner@postgresql.org Sat Mar 29 11:57:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4F8F8475AE5 for ; Sat, 29 Mar 2003 11:57:55 -0500 (EST) Received: from smtp.inode.at (smtp-01.inode.at [62.99.194.3]) by postgresql.org (Postfix) with ESMTP id A56FD475A80 for ; Sat, 29 Mar 2003 11:57:54 -0500 (EST) Received: from line-c-227.adsl-dynamic.inode.at ([62.99.151.227]:35422 helo=andi-lap) by smtp.inode.at with smtp (Exim 4.10) id 18zJdR-0000wT-00; Sat, 29 Mar 2003 17:56:49 +0100 Received: by andi-lap (sSMTP sendmail emulation); Sat, 29 Mar 2003 17:57:58 +0100 Subject: Re: Index not used, performance problem From: Andreas Kostyrka To: Christopher Kings-Lynne Cc: pgsql-performance@postgresql.org In-Reply-To: <20030329214139.N4697-100000@houston.familyhealth.com.au> References: <20030329214139.N4697-100000@houston.familyhealth.com.au> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-YhVtnAnJHYTlkgVB/PLB" Organization: Message-Id: <1048957078.7539.17.camel@andi-lap> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 29 Mar 2003 17:57:58 +0100 X-Spam-Status: No, hits=-45.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/192 X-Sequence-Number: 1490 --=-YhVtnAnJHYTlkgVB/PLB Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sat, 2003-03-29 at 14:47, Christopher Kings-Lynne wrote: > As for the LIKE searches, the only ones that PostgreSQL can index are of > the form 'FOO%', which is what you are doing. However, I believe that > PostgreSQL cannot do this if your database encoding is anything other than > 'C'. So, if you are using an Austrian encoding, it might not be able to > use the index. Well, I use LATIN1. How do I store 8-bit chars else? And if so, PostgreSQL seems quite strongly broken, because a relational database relies by design heavily on indexes. > Also, what is the point of searching for LIKE '%'? Why not just leave that > out? Well, it's about generating the SQL query. Actually it's just a border case for searching for a given prefix. Andreas --=-YhVtnAnJHYTlkgVB/PLB Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA+hdCVHJdudm4KnO0RAnB7AJ4hE5NYgPJmYjiWhnMexvRmfumf9ACgwuah 2XmtElYM+nBzciXeT5fWEDc= =4NmH -----END PGP SIGNATURE----- --=-YhVtnAnJHYTlkgVB/PLB-- From pgsql-performance-owner@postgresql.org Sat Mar 29 11:59:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6149475E82 for ; Sat, 29 Mar 2003 11:59:08 -0500 (EST) Received: from smtp.inode.at (smtp-04.inode.at [62.99.194.6]) by postgresql.org (Postfix) with ESMTP id 2C2C9475AE5 for ; Sat, 29 Mar 2003 11:59:08 -0500 (EST) Received: from line-c-227.adsl-dynamic.inode.at ([62.99.151.227]:35423 helo=andi-lap) by smtp.inode.at with smtp (Exim 4.10) id 18zJfg-0005IZ-00; Sat, 29 Mar 2003 17:59:09 +0100 Received: by andi-lap (sSMTP sendmail emulation); Sat, 29 Mar 2003 17:59:11 +0100 Subject: Re: Index not used, performance problem From: Andreas Kostyrka To: Christopher Kings-Lynne Cc: pgsql-performance@postgresql.org In-Reply-To: <20030329214139.N4697-100000@houston.familyhealth.com.au> References: <20030329214139.N4697-100000@houston.familyhealth.com.au> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-doEA5B4TdHHZUNvSCiXQ" Organization: Message-Id: <1048957151.7543.19.camel@andi-lap> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 29 Mar 2003 17:59:11 +0100 X-Spam-Status: No, hits=-44.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/194 X-Sequence-Number: 1492 --=-doEA5B4TdHHZUNvSCiXQ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sat, 2003-03-29 at 14:47, Christopher Kings-Lynne wrote: > Hi Andreas, >=20 > A few points: >=20 > PostgreSQL is rarely going to use an index for a boolean column. The > reason is that since almost by definition true will occupy 50% of the rows > and false will occupy 50% (say). In this case, a sequential scan is > always faster. You would say that the 'selectivity' isn't good enough. Well, perhaps it should collect statistics, because a "deleted" column is a prime candidate for a strongly skewed population. Andreas --=-doEA5B4TdHHZUNvSCiXQ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA+hdDfHJdudm4KnO0RAjstAJ0dJmy+cpD4fHR58w8/C7mbuivo2ACeLzWl TCYdzdyza1fmtg3vN+sY4Qw= =EHBI -----END PGP SIGNATURE----- --=-doEA5B4TdHHZUNvSCiXQ-- From pgsql-performance-owner@postgresql.org Sat Mar 29 11:58:27 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 12893475EE2 for ; Sat, 29 Mar 2003 11:58:25 -0500 (EST) Received: from indygecko.com (h24-77-222-182.ok.shawcable.net [24.77.222.182]) by postgresql.org (Postfix) with ESMTP id 0A2A8475ECE for ; Sat, 29 Mar 2003 11:58:24 -0500 (EST) Received: from [192.168.10.10] ([::ffff:192.168.10.10]) by indygecko.com with esmtp; Sat, 29 Mar 2003 08:58:27 -0800 Subject: Re: Index not used, performance problem From: Jord Tanner To: "John K. Herreshoff" Cc: pgsql-performance@postgresql.org In-Reply-To: <200303291149.00790.jkherr@centurytel.net> References: <1048931358.7539.11.camel@andi-lap> <20030329214139.N4697-100000@houston.familyhealth.com.au> <20030329103452.B16250@mail.libertyrms.com> <200303291149.00790.jkherr@centurytel.net> Organization: Message-Id: <1048957169.7512.33.camel@gecko> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.2.3 Date: 29 Mar 2003 08:59:29 -0800 X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/193 X-Sequence-Number: 1491 # su postgres % export LANG=C % /usr/local/pgsql/bin/initdb blah blah That always works for me! On Sat, 2003-03-29 at 08:49, John K. Herreshoff wrote: > In Linux (Redhat) where, exactly, does one set the LOCALE to C? > > TIA :-) > > John. > > On Saturday 29 March 2003 10:34 am, Andrew Sullivan wrote: > > On Sat, Mar 29, 2003 at 09:47:51PM +0800, Christopher Kings-Lynne wrote: > > > the form 'FOO%', which is what you are doing. However, I believe that > > > PostgreSQL cannot do this if your database encoding is anything other > > > than 'C'. So, if you are using an Austrian encoding, it might not be > > > able to > > > > That is, you need to have had the LOCALE set to 'C' when you did > > initdb. It's not enough to change it afterwards. > > > > A > > > ---------------------------(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 -- Jord Tanner From pgsql-performance-owner@postgresql.org Sat Mar 29 12:54:57 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C94C9475A80 for ; Sat, 29 Mar 2003 12:54:56 -0500 (EST) Received: from ms-smtp-02.texas.rr.com (ms-smtp-02.texas.rr.com [24.93.36.230]) by postgresql.org (Postfix) with ESMTP id 8E5B2475A8D for ; Sat, 29 Mar 2003 12:54:55 -0500 (EST) Received: from spaceship.com (cs24243214-140.austin.rr.com [24.243.214.140]) by ms-smtp-02.texas.rr.com (8.12.5/8.12.2) with ESMTP id h2THt0df001360 for ; Sat, 29 Mar 2003 12:55:00 -0500 (EST) Message-ID: <3E85DDF4.7060406@spaceship.com> Date: Sat, 29 Mar 2003 11:55:00 -0600 From: Matt Mello User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Index not used, performance problem References: <20030329214139.N4697-100000@houston.familyhealth.com.au> <1048957151.7543.19.camel@andi-lap> In-Reply-To: <1048957151.7543.19.camel@andi-lap> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/195 X-Sequence-Number: 1493 I have many boolean columns, and my queries almost always use indexes. Just because a column can have only 2 values does not mean that 50% of them will be true and 50% will be false. The ratio of T|F depends on the content. I have some boolean columns with less than 1% true. Obviously, an index will help with these ... and it does, tremendously. If you only have 6400 rows, it is *possible* that the planner will choose not to use an index, as using an index might be slower than just seqscanning. If you do lots of updates on that table, you might need to do a vacuum full occasionally, although I'm not certain how much that benefits a boolean field. Also, if possible, I would consider upgrading to a more recent version. I have seen many of the experts here post news about significant bug fixes between 7.2 and 7.3. (My experience with boolean fields is using 7.3.) In addition, when posting to the list, it is helpful to post an "explain analyze" for a query, as it gives more & better details (for those same experts, of which I am not). Andreas Kostyrka wrote: > On Sat, 2003-03-29 at 14:47, Christopher Kings-Lynne wrote: > >>Hi Andreas, >> >>A few points: >> >>PostgreSQL is rarely going to use an index for a boolean column. The >>reason is that since almost by definition true will occupy 50% of the rows >>and false will occupy 50% (say). In this case, a sequential scan is >>always faster. You would say that the 'selectivity' isn't good enough. > > Well, perhaps it should collect statistics, because a "deleted" column > is a prime candidate for a strongly skewed population. > > Andreas -- Matt Mello 512-350-6900 From pgsql-performance-owner@postgresql.org Sat Mar 29 16:16:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1810C475A8D for ; Sat, 29 Mar 2003 16:16:06 -0500 (EST) Received: from post-20.mail.nl.demon.net (post-20.mail.nl.demon.net [194.159.73.1]) by postgresql.org (Postfix) with ESMTP id B002E474E42 for ; Sat, 29 Mar 2003 16:16:04 -0500 (EST) Received: from [212.238.27.227] (helo=itaudit.demon.nl) by post-20.mail.nl.demon.net with esmtp (Exim 3.36 #1) id 18zNgK-000O4w-00 for pgsql-performance@postgresql.org; Sat, 29 Mar 2003 21:16:05 +0000 Message-ID: <3E860D66.9030209@itaudit.demon.nl> Date: Sat, 29 Mar 2003 22:17:26 +0100 From: Wil Peters User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Bad perfomance of pl/pgsql-function on new server Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-12.1 required=5.0 tests=BAYES_10,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/196 X-Sequence-Number: 1494 Hi, I've written a pl/pgsql-function called 'f_matchstr' to support a search-module on several websites. In short, the function scans the content of a field and counts the occurances of a given search-string. The complete function is listed below. On a database-server that runs SuSE-linux 7.1 and PostgreSQL 7.2 the function perfoms fine. Even when text-fields are accessed with large volumes of text inside the response is OK. This is also very important, because the search-module is used to scan articles that are stored in a databasetable. Recently the database-server is upgraded. It now runs SuSE 8.1 and PostgreSQL 7.2. I copied the databases to the new server using pg_dumpall etc. On the new server - although this server has far better specs! - the function does NOT perfom as well as on the old server. Searches take several minutes, where on the old server a few SECONDS where needed. As far as I can see the settings of PostgreSQL on both servers are the same. Can someone help me with this problem?? Thanx, Wil Peters www.ldits.nl -- Name: "f_matchstr" (text,text,integer,integer) -- Type: FUNCTION -- Owner: postgres CREATE FUNCTION "f_matchstr" (text,text,integer,integer) RETURNS integer AS 'DECLARE fld text; -- Field sstr text; -- Searchstring scptn ALIAS FOR $3; -- Case-sensitivity sxmtch integer; -- Exact-matching match integer; -- Number of matches i integer; lenfld integer; lensstr integer; srchstr text; middle text; lenmiddle integer; BEGIN fld := $1; sstr := $2; sxmtch := $4; lenfld := length(fld); lensstr := length(sstr); i := 1; match := 0; -- Work case insensitive IF scptn = 0 THEN fld := lower(fld); -- Set fieldcontent to lowercase sstr := lower(sstr); -- Set searchstring to lowercase END IF; IF lenfld = lensstr THEN sxmtch := 0; -- Setting of sxmtch does not matter END IF; -- Set searchstring srchstr := '''' || sstr || ''''; IF fld ~ srchstr THEN IF lensstr <= lenfld AND sxmtch = 0 THEN -- Walk trough fieldcontent WHILE i <= lenfld LOOP IF substring(fld,i,lensstr) = sstr THEN match := match + 1; END IF; i := i + 1; -- Escape from loop if 10 matches are reached IF match >= 10 THEN i := lenfld + 1; END IF; END LOOP; ELSIF lensstr < lenfld AND sxmtch = 1 THEN -- Set searchstring for begin of fieldcontent srchstr := ''^'' || sstr || ''[ ,:?!]+''; IF substring(fld,1,lensstr+1) ~ srchstr THEN match := match + 1; END IF; -- Set searchstring for end of fieldcontent srchstr := '' '' || sstr || ''[.?!]?$''; IF substring(fld,lenfld-lensstr-1,lensstr+2) ~ srchstr THEN match := match + 1; END IF; -- Extract middle part of fieldcontent middle := substring(fld,lensstr+1,lenfld-(2*lensstr)); -- Store length of middle part lenmiddle := length(middle); -- Set searchstring for end of fieldcontent -- See below for regular expression thas is needed srchstr := ''[ >("\\'' || '''''' || '']+'' || sstr || ''[ ,.:?!)<"\\'' || '''''' || '']+''; -- Walk trough middle part of fieldcontent WHILE i <= lenmiddle LOOP IF substring(middle,i,lensstr+2) ~ srchstr THEN match := match + 1; END IF; i := i + 1; -- Escape from loop if 10 matches are reached IF match >= 10 THEN i := lenmiddle + 1; END IF; END LOOP; END IF; END IF; RETURN match; END;' LANGUAGE 'plpgsql'; From pgsql-performance-owner@postgresql.org Sat Mar 29 18:14:01 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CB845475AE5 for ; Sat, 29 Mar 2003 18:13:59 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 1368C4758E6 for ; Sat, 29 Mar 2003 18:13:59 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2TNDTub000936; Sat, 29 Mar 2003 18:13:29 -0500 (EST) To: Andreas Kostyrka Cc: Christopher Kings-Lynne , pgsql-performance@postgresql.org Subject: Re: Index not used, performance problem In-reply-to: <1048957078.7539.17.camel@andi-lap> References: <20030329214139.N4697-100000@houston.familyhealth.com.au> <1048957078.7539.17.camel@andi-lap> Comments: In-reply-to Andreas Kostyrka message dated "29 Mar 2003 17:57:58 +0100" Date: Sat, 29 Mar 2003 18:13:28 -0500 Message-ID: <935.1048979608@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/197 X-Sequence-Number: 1495 Andreas Kostyrka writes: > On Sat, 2003-03-29 at 14:47, Christopher Kings-Lynne wrote: >> As for the LIKE searches, the only ones that PostgreSQL can index are of >> the form 'FOO%', which is what you are doing. However, I believe that >> PostgreSQL cannot do this if your database encoding is anything other than >> 'C'. So, if you are using an Austrian encoding, it might not be able to >> use the index. > Well, I use LATIN1. How do I store 8-bit chars else? You are both confusing locale with encoding. The LIKE optimization requires 'C' locale, but it should work with any encoding (or at least any single-byte encoding; not sure about multibyte). > And if so, PostgreSQL seems quite strongly broken, because a > relational database relies by design heavily on indexes. Some of us would reply that the locales are broken ;-). The bizarre sorting rules demanded by so many locales are what make it impossible to optimize a LIKE prefix into an indexscan. See the archives for the reasons why our many tries at this have failed. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Mar 29 18:25:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D23CD475AE5 for ; Sat, 29 Mar 2003 18:25:43 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id E50534758E6 for ; Sat, 29 Mar 2003 18:25:41 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2TNPhub001004; Sat, 29 Mar 2003 18:25:43 -0500 (EST) To: Wil Peters Cc: pgsql-performance@postgresql.org Subject: Re: Bad perfomance of pl/pgsql-function on new server In-reply-to: <3E860D66.9030209@itaudit.demon.nl> References: <3E860D66.9030209@itaudit.demon.nl> Comments: In-reply-to Wil Peters message dated "Sat, 29 Mar 2003 22:17:26 +0100" Date: Sat, 29 Mar 2003 18:25:43 -0500 Message-ID: <1001.1048980343@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/198 X-Sequence-Number: 1496 Wil Peters writes: > On the new server - although this server has far better specs! - the > function does NOT perfom as well as on the old server. Searches take > several minutes, where on the old server a few SECONDS where needed. Is the new installation really equivalent to the old? I'd wonder about differences in multibyte compilation option, database locale and encoding, etc. Any of these could result in a huge hit in text-pushing performance. Another traditional post-upgrade problem is forgetting to VACUUM ANALYZE; but that probably shouldn't affect this function, since it's not issuing any database queries. (Personally I'd have written this sort of function in plperl or pltcl, either of which are far more appropriate for text-string-mashing than plpgsql. But that's not really answering your question.) regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 31 10:46:39 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E440A476478 for ; Mon, 31 Mar 2003 10:40:06 -0500 (EST) Received: from Morgoth.esiway.net (Morgoth.ESIWAY.NET [193.194.16.157]) by postgresql.org (Postfix) with ESMTP id A2D6D4765FA for ; Mon, 31 Mar 2003 07:07:03 -0500 (EST) Received: from Megathlon.ESI (Ghost.esi.it [193.194.16.225]) by Morgoth.esiway.net (8.11.6p2/8.11.6) with ESMTP id h2VC6ph14693 (using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified FAIL) for ; Mon, 31 Mar 2003 14:06:52 +0200 Received: from relay.ESI (IDENT:marco@relay.ESI [10.10.10.3]) (authenticated (0 bits)) by Megathlon.ESI (8.11.6p2/8.11.5) with ESMTP id h2VC6oO30189 (using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified NO) for ; Mon, 31 Mar 2003 14:06:51 +0200 Date: Mon, 31 Mar 2003 14:06:50 +0200 (CEST) From: Marco Colombo To: pgsql-performance@postgresql.org Subject: WAL monitoring and optimizing Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-12.3 required=5.0 tests=BAYES_01,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/199 X-Sequence-Number: 1497 Hi, i'm running 7.2.3 (on RHL7.3). I've read the "WAL Configuration" section of the manual: http://www.postgresql.org/docs/view.php?version=7.2&idoc=0&file=wal-configuration.html I've set wal_debug = 1 in postgresql.conf, but there's no example of how LogInsert and LogFlush are logged. I can find many DEBUG: XLogFlush: request 6/6D8F54BC; write 6/6E13ECB8; flush 6/6E13ECB8 lines in my log, but no XLogInsert. There are lot of DEBUG: INSERT @ 6/70DC8744: prev 6/70DC8564; xprev 6/70DC8564; xid 372353616; bkpb 1: Btree - insert: node 9468978/12901623; lines, but it's not clear if they are calls to LogInsert or something different. They also come in different kinds (Btree - insert, Heap - update, Transaction - commit, XLOG - checkpoint:, maybe others) and I don't know which ones I should be looking for. I've got 7365 'XLogFlush:' lines and 23275 'INSERT @' lines in the last 9 hours. Should I increase the number of WAL buffers? TIA, .TM. -- ____/ ____/ / / / / Marco Colombo ___/ ___ / / Technical Manager / / / ESI s.r.l. _____/ _____/ _/ Colombo@ESI.it From pgsql-performance-owner@postgresql.org Mon Mar 31 12:54:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9AF8C475F09 for ; Mon, 31 Mar 2003 12:54:44 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id EE71A475EDF for ; Mon, 31 Mar 2003 12:54:43 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h2VHsl2L023937; Mon, 31 Mar 2003 12:54:47 -0500 (EST) To: Marco Colombo Cc: pgsql-performance@postgresql.org Subject: Re: WAL monitoring and optimizing In-reply-to: References: Comments: In-reply-to Marco Colombo message dated "Mon, 31 Mar 2003 14:06:50 +0200" Date: Mon, 31 Mar 2003 12:54:46 -0500 Message-ID: <23936.1049133286@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/200 X-Sequence-Number: 1498 Marco Colombo writes: > I've got 7365 'XLogFlush:' lines and 23275 'INSERT @' lines in the > last 9 hours. Should I increase the number of WAL buffers? With a transaction rate as low as that, I wouldn't think you need to. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 31 13:28:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4C74F475F1B for ; Mon, 31 Mar 2003 13:28:29 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 81ADC475F09 for ; Mon, 31 Mar 2003 13:28:28 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h2VINtWU001764; Mon, 31 Mar 2003 11:23:56 -0700 (MST) Date: Mon, 31 Mar 2003 11:21:45 -0700 (MST) From: "scott.marlowe" To: Andreas Kostyrka Cc: Subject: Re: Index not used, performance problem In-Reply-To: <1048957151.7543.19.camel@andi-lap> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/201 X-Sequence-Number: 1499 On 29 Mar 2003, Andreas Kostyrka wrote: > On Sat, 2003-03-29 at 14:47, Christopher Kings-Lynne wrote: > > Hi Andreas, > > > > A few points: > > > > PostgreSQL is rarely going to use an index for a boolean column. The > > reason is that since almost by definition true will occupy 50% of the rows > > and false will occupy 50% (say). In this case, a sequential scan is > > always faster. You would say that the 'selectivity' isn't good enough. > Well, perhaps it should collect statistics, because a "deleted" column > is a prime candidate for a strongly skewed population. It does. When you run analyze. You have vacuumed and analyzed the database right? Assuming you have, it's often better to make a partial index for your booleans. I'll assume that patient.deleted being true is a more rare condition than false, since false is the default. So, create your index this way to make it smaller and faster: create index dxname on sometable (bool_field) where bool_field IS TRUE; Now you have a tiny little index that gets scanned ultra fast and is easy to maintain. You have to, however, access it the same way. the proper way to reference a bool field is with IS [NOT] {TRUE|FALSE} select * from some_table where bool_field IS TRUE would match the index I created aboce. select * from some_table where bool_field = 't' would not. From pgsql-performance-owner@postgresql.org Mon Mar 31 13:54:03 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2AC1E475AF8 for ; Mon, 31 Mar 2003 13:54:02 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 762B947580B for ; Mon, 31 Mar 2003 13:53:58 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h2VIrs2L024342; Mon, 31 Mar 2003 13:53:54 -0500 (EST) To: "scott.marlowe" Cc: Andreas Kostyrka , pgsql-performance@postgresql.org Subject: Re: Index not used, performance problem In-reply-to: References: Comments: In-reply-to "scott.marlowe" message dated "Mon, 31 Mar 2003 11:21:45 -0700" Date: Mon, 31 Mar 2003 13:53:54 -0500 Message-ID: <24341.1049136834@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/202 X-Sequence-Number: 1500 "scott.marlowe" writes: > So, create your index this way to make it smaller and faster: > create index dxname on sometable (bool_field) where bool_field IS TRUE; Also note that the index itself could be on some other column; for example if you do create index fooi on foo (intcol) where boolcol; then a query like select ... from foo where intcol >= 42 and boolcol; could use the index to exploit both WHERE conditions. > You have to, however, access it the same way. the proper > way to reference a bool field is with IS [NOT] {TRUE|FALSE} This strikes me as pedantry. "WHERE bool" (resp. "WHERE NOT bool") has the same semantics and is easier to read, at least to me. (Of course, if you think differently, then by all means write the form that seems clearest to you.) But yeah, the condition appearing in the actual queries had best match what's used in the partial-index CREATE command exactly. The planner is not real smart about deducing "this implies that". regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 31 15:55:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CEACA475D91 for ; Mon, 31 Mar 2003 15:55:44 -0500 (EST) Received: from web21104.mail.yahoo.com (web21104.mail.yahoo.com [216.136.227.106]) by postgresql.org (Postfix) with SMTP id DF5CE475AF8 for ; Mon, 31 Mar 2003 15:55:43 -0500 (EST) Message-ID: <20030331205544.19785.qmail@web21104.mail.yahoo.com> Received: from [208.253.218.33] by web21104.mail.yahoo.com via HTTP; Mon, 31 Mar 2003 12:55:44 PST Date: Mon, 31 Mar 2003 12:55:44 -0800 (PST) From: Shankar K Subject: ext3 filesystem / linux 7.3 To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-5.1 required=5.0 tests=BAYES_10,FROM_ENDS_IN_NUMS version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/203 X-Sequence-Number: 1501 hi there, I was reading bruce's 'postgresql hardware performance tuning' article and he has suggested ext3 filesystem with data mode = writeback for high performance. I would really appreciate if anyone could share your experiences with ext3 from a production stand point or any other suggestions for best read/write performance. Our applications is an hybrid of heavy inserts/updates and DSS queries. version - postgres 7.3.2 hardware - raid 5 (5 x 73 g hardware raid), 4g ram, 2 * 2.8 GHz cpu, redhat 7.3 Note : we don't have the luxury of raid 1+0 (dedicated disks) for xlog and clog files to start with but may be down the line we might look into those options, but for now i've planned on having them on local drives rather than raid 5. thanks for any inputs, Shankar __________________________________________________ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com From pgsql-performance-owner@postgresql.org Mon Mar 31 16:13:19 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5BE41475D91 for ; Mon, 31 Mar 2003 16:13:18 -0500 (EST) Received: from spirit.aldeiadigital.com.br (iplus-fac-213-137.xdsl-fixo.ctbcnetsuper.com.br [200.225.213.137]) by postgresql.org (Postfix) with ESMTP id DA91D475CEE for ; Mon, 31 Mar 2003 16:13:15 -0500 (EST) Received: from aldeiadigital.com.br (localhost.localdomain [127.0.0.1]) by spirit.aldeiadigital.com.br (8.11.6/8.11.6) with SMTP id h2VLDQa01207 for ; Mon, 31 Mar 2003 18:13:27 -0300 Received: from 200.225.202.15 (SquirrelMail authenticated user alepaes) by webmail.ad2.com.br with HTTP; Mon, 31 Mar 2003 18:13:27 -0300 (BRT) Message-ID: <10846.200.225.202.15.1049145207.squirrel@webmail.ad2.com.br> Date: Mon, 31 Mar 2003 18:13:27 -0300 (BRT) Subject: 30-70 seconds query... From: "alexandre :: aldeia digital" To: X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal X-Mailer: SquirrelMail (version 1.2.7) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Virus-Scanned: by amavisd-milter (http://amavis.org/) Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-3.0 required=5.0 tests=BAYES_20,MISSING_MIMEOLE,MISSING_OUTLOOK_NAME version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/204 X-Sequence-Number: 1502 Hi all, I use a case tool and we generate the querys automatically. The query explained is a part of an Report and takes a long time to complete (30 ~ 70 seconds). My machine is a Dual Xeon 2 Ghz, 1 Mb DDR, 3 SCSI HW RAID 5. The tables involved in query have 500.000 rows. Thank=B4s for any help... Alexandre explain analyze SELECT T2.fi08ufemp, T4.es10almtra, T3.fi08MovEst, T1.es10qtdgra, T1.es10Tamanh, T1.es10item, T1.es10numdoc, T1.fi08codigo, T1.es10tipdoc, T1.es10codemp, T4.es10codalm, T4.es10empa, T1.es10datlan, T4.co13CodPro, T4.co13Emp06, T1.es10EmpTam FROM (((ES10T2 T1 LEFT JOIN ES10T T2 ON T2.es10codemp =3D T1.es10codemp AND T2.es10datlan =3D T1.es10datlan AND T2.es10tipdoc =3D T1.es10tipdoc AND T2.fi08codigo =3D T1.fi08codigo AND T2.es10numdoc =3D T1.es10numdoc) LEFT JOIN FI08T T3 ON T3.fi08ufemp =3D T2.fi08ufemp AND T3.fi08codigo =3DT1.fi08codigo) LEFT JO= IN ES10T1 T4 ON T4.es10codemp =3D T1.es10codemp AND T4.es10datlan =3D T1.es10datlan AND T4.es10tipdoc =3D T1.es10tipdoc AND T4.fi08codigo =3D T1.fi08codigo AND T4.es10numdoc =3D T1.es10numdoc AND T4.es10item =3D T1.es10item) WHERE ( T4.co13Emp06 =3D '1' AND T4.co13CodPro =3D '16998' A= ND T1.es10datlan >=3D '2003-02-01'::date ) AND ( T1.es10datlan >=3D '2003-02-01'::date) AND ( T3.fi08MovEst =3D 'S' ) AND ( T4.es10empa =3D '1'= OR ( '1' =3D 0 ) ) AND ( T4.es10codalm =3D '0' OR T4.es10almtra =3D '0' OR (= '0' =3D 0 ) ) AND ( T1.es10datlan <=3D '2003-02-28'::date ) ORDER BY T4.co13Emp06, T4.co13CodPro, T1.es10datlan, T4.es10empa, T4.es10codalm, T4.es10almtra, T1.es10codemp, T1.es10tipdoc, T1.fi08codigo, T1.es10numdoc, T1.es10item; QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------------ Sort (cost=3D379749.51..379833.81 rows=3D33722 width=3D142) (actual time=3D74031.72..74031.72 rows=3D0 loops=3D1) Sort Key: t4.co13emp06, t4.co13codpro, t1.es10datlan, t4.es10empa, t4.es10codalm, t4.es10almtra, t1.es10codemp, t1.es10tipdoc, t1.fi08codigo, t1.es10numdoc, t1.es10item -> Nested Loop (cost=3D1160.89..377213.38 rows=3D33722 width=3D142) (a= ctual time=3D74031.18..74031.18 rows=3D0 loops=3D1) Filter: (("inner".co13emp06 =3D 1::smallint) AND ("inner".co13codpro =3D 16998) AND ("inner".es10empa =3D 1::smallint)) -> Hash Join (cost=3D1160.89..173492.20 rows=3D33722 width=3D99) (actual time=3D35.98..27046.08 rows=3D33660 loops=3D1) Hash Cond: ("outer".fi08codigo =3D "inner".fi08codigo) Join Filter: ("inner".fi08ufemp =3D "outer".fi08ufemp) Filter: ("inner".fi08movest =3D 'S'::bpchar) -> Hash Join (cost=3D1120.19..172524.13 rows=3D33722 width=3D86) (actual time=3D33.64..26566.83 rows=3D33660 loops=3D1) Hash Cond: ("outer".es10datlan =3D "inner".es10datlan) Join Filter: (("inner".es10codemp =3D "outer".es10codemp) AND ("inner".es10tipdoc =3D "outer".es10tipdoc) AND ("inner".fi08codigo =3D "outer".fi08codigo) AND ("inner".es10numdoc =3D "outer".es10numdoc)) -> Index Scan using es10t2_ad1 on es10t2 t1=20 (cost=3D0.00..1148.09 rows=3D33722 width=3D51) (actual time=3D0.08..1885.06 rows=3D33660 loops=3D1) Index Cond: ((es10datlan >=3D '2003-02-01'::date) AND (es10datlan <=3D '2003-02-28'::date)) -> Hash (cost=3D1109.15..1109.15 rows=3D4415 width= =3D35) (actual time=3D33.23..33.23 rows=3D0 loops=3D1) -> Seq Scan on es10t t2 (cost=3D0.00..1109.15 rows=3D4415 width=3D35) (actual time=3D0.03..24.63 rows=3D4395 loops=3D1) -> Hash (cost=3D40.16..40.16 rows=3D216 width=3D13) (actual time=3D1.91..1.91 rows=3D0 loops=3D1) -> Seq Scan on fi08t t3 (cost=3D0.00..40.16 rows=3D2= 16 width=3D13) (actual time=3D0.03..1.46 rows=3D216 loops=3D1) -> Index Scan using es10t1_pkey on es10t1 t4 (cost=3D0.00..6.01 rows=3D1 width=3D43) (actual time=3D1.38..1.39 rows=3D1 loops=3D33660) Index Cond: ((t4.es10codemp =3D "outer".es10codemp) AND (t4.es10datlan =3D "outer".es10datlan) AND (t4.es10tipdoc =3D "outer".es10tipdoc) AND (t4.fi08codigo =3D "outer".fi08codigo) AND (t4.es10numdoc =3D "outer".es10numdoc) AND (t4.es10item =3D "outer".es10item)) Total runtime: 74032.60 msec (20 rows) From pgsql-performance-owner@postgresql.org Mon Mar 31 17:13:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 19AEC475E14 for ; Mon, 31 Mar 2003 17:13:47 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id A39A9475D91 for ; Mon, 31 Mar 2003 17:13:45 -0500 (EST) Received: from klaster.net (pa234.krakow.cvx.ppp.tpnet.pl [213.76.36.234]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 4A5206A281; Tue, 1 Apr 2003 00:13:44 +0200 (CEST) Message-ID: <3E88BE02.9020203@klaster.net> Date: Tue, 01 Apr 2003 00:15:30 +0200 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.3) Gecko/20030312 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: "alexandre:"@serwer.skawsoft.com.pl:aldeia digital Cc: pgsql-performance@postgresql.org Subject: Re: 30-70 seconds query... References: <10846.200.225.202.15.1049145207.squirrel@webmail.ad2.com.br> In-Reply-To: <10846.200.225.202.15.1049145207.squirrel@webmail.ad2.com.br> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-30.3 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,RCVD_IN_RFCI, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/205 X-Sequence-Number: 1503 Uz.ytkownik alexandre :: aldeia digital napisa?: > Hi all, >=20 > I use a case tool and we generate the querys automatically. > The query explained is a part of an Report and takes a long time > to complete (30 ~ 70 seconds). My machine is a Dual Xeon 2 Ghz, 1 Mb DDR, > 3 SCSI HW RAID 5. > The tables involved in query have 500.000 rows. >=20 > Thank=B4s for any help... >=20 > Alexandre >=20 >=20 > explain analyze SELECT T2.fi08ufemp, T4.es10almtra, T3.fi08MovEst, > T1.es10qtdgra, T1.es10Tamanh, T1.es10item, T1.es10numdoc, T1.fi08codigo, > T1.es10tipdoc, T1.es10codemp, T4.es10codalm, T4.es10empa, T1.es10datlan, > T4.co13CodPro, T4.co13Emp06, T1.es10EmpTam FROM (((ES10T2 T1 LEFT JOIN > ES10T T2 ON T2.es10codemp =3D T1.es10codemp AND T2.es10datlan =3D > T1.es10datlan AND T2.es10tipdoc =3D T1.es10tipdoc AND T2.fi08codigo =3D > T1.fi08codigo AND T2.es10numdoc =3D T1.es10numdoc) LEFT JOIN FI08T T3 ON > T3.fi08ufemp =3D T2.fi08ufemp AND T3.fi08codigo =3DT1.fi08codigo) LEFT = JOIN > ES10T1 T4 ON T4.es10codemp =3D T1.es10codemp AND T4.es10datlan =3D > T1.es10datlan AND T4.es10tipdoc =3D T1.es10tipdoc AND T4.fi08codigo =3D > T1.fi08codigo AND T4.es10numdoc =3D T1.es10numdoc AND T4.es10item =3D > T1.es10item) WHERE ( T4.co13Emp06 =3D '1' AND T4.co13CodPro =3D '16998'= AND > T1.es10datlan >=3D '2003-02-01'::date ) AND ( T1.es10datlan >=3D > '2003-02-01'::date) AND ( T3.fi08MovEst =3D 'S' ) AND ( T4.es10empa =3D '= 1' OR > ( '1' =3D 0 ) ) AND ( T4.es10codalm =3D '0' OR T4.es10almtra =3D '0' OR= ( '0' > =3D 0 ) ) AND ( T1.es10datlan <=3D '2003-02-28'::date ) ORDER BY > T4.co13Emp06, T4.co13CodPro, T1.es10datlan, T4.es10empa, T4.es10codalm, > T4.es10almtra, T1.es10codemp, T1.es10tipdoc, T1.fi08codigo, > T1.es10numdoc, T1.es10item; >=20 >=20 > QUERY PLAN > -------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------------------------------------------- > Sort (cost=3D379749.51..379833.81 rows=3D33722 width=3D142) (actual > time=3D74031.72..74031.72 rows=3D0 loops=3D1) > Sort Key: t4.co13emp06, t4.co13codpro, t1.es10datlan, t4.es10empa, > t4.es10codalm, t4.es10almtra, t1.es10codemp, t1.es10tipdoc, > t1.fi08codigo, t1.es10numdoc, t1.es10item > -> Nested Loop (cost=3D1160.89..377213.38 rows=3D33722 width=3D142) = (actual > time=3D74031.18..74031.18 rows=3D0 loops=3D1) > Filter: (("inner".co13emp06 =3D 1::smallint) AND > ("inner".co13codpro =3D 16998) AND ("inner".es10empa =3D > 1::smallint)) > -> Hash Join (cost=3D1160.89..173492.20 rows=3D33722 width=3D9= 9) > (actual time=3D35.98..27046.08 rows=3D33660 loops=3D1) > Hash Cond: ("outer".fi08codigo =3D "inner".fi08codigo) > Join Filter: ("inner".fi08ufemp =3D "outer".fi08ufemp) > Filter: ("inner".fi08movest =3D 'S'::bpchar) > -> Hash Join (cost=3D1120.19..172524.13 rows=3D33722 > width=3D86) (actual time=3D33.64..26566.83 rows=3D33660 loops=3D1) > Hash Cond: ("outer".es10datlan =3D "inner".es10datla= n) > Join Filter: (("inner".es10codemp =3D > "outer".es10codemp) AND ("inner".es10tipdoc =3D > "outer".es10tipdoc) AND ("inner".fi08codigo =3D > "outer".fi08codigo) AND ("inner".es10numdoc =3D > "outer".es10numdoc)) > -> Index Scan using es10t2_ad1 on es10t2 t1=20 > (cost=3D0.00..1148.09 rows=3D33722 width=3D51) (actual > time=3D0.08..1885.06 rows=3D33660 loops=3D1) > Index Cond: ((es10datlan >=3D '2003-02-01'::da= te) > AND (es10datlan <=3D '2003-02-28'::date)) > -> Hash (cost=3D1109.15..1109.15 rows=3D4415 width= =3D35) > (actual time=3D33.23..33.23 rows=3D0 loops=3D1) > -> Seq Scan on es10t t2 (cost=3D0.00..1109.15 > rows=3D4415 width=3D35) (actual time=3D0.03..24.63 > rows=3D4395 loops=3D1) > -> Hash (cost=3D40.16..40.16 rows=3D216 width=3D13) (act= ual > time=3D1.91..1.91 rows=3D0 loops=3D1) > -> Seq Scan on fi08t t3 (cost=3D0.00..40.16 rows= =3D216 > width=3D13) (actual time=3D0.03..1.46 rows=3D216 loops=3D1) > -> Index Scan using es10t1_pkey on es10t1 t4 (cost=3D0.00..6.01 > rows=3D1 width=3D43) (actual time=3D1.38..1.39 rows=3D1 loops=3D33660) > Index Cond: ((t4.es10codemp =3D "outer".es10codemp) AND > (t4.es10datlan =3D "outer".es10datlan) AND (t4.es10tipdoc =3D > "outer".es10tipdoc) AND (t4.fi08codigo =3D > "outer".fi08codigo) AND (t4.es10numdoc =3D > "outer".es10numdoc) AND (t4.es10item =3D "outer".es10item)) > Total runtime: 74032.60 msec > (20 rows) Is the query below the same to yours? explain analyze SELECT T2.fi08ufemp, T4.es10almtra, T3.fi08MovEst, T1.es10qtdgra, T1.es10Tamanh, T1.es10item, T1.es10numdoc, T1.fi08codigo, T1.es10tipdoc, T1.es10codemp, T4.es10codalm, T4.es10empa, T1.es10datlan, T4.co13CodPro, T4.co13Emp06, T1.es10EmpTam FROM ES10T2 T1 LEFT JOIN T2 using=20 (es10codemp,es10datlan,es10tipdoc,fi08codigo,es10numdoc) LEFT JOIN FI08T T3 using (fi08ufemp,fi08codigo) LEFT JOIN ES10T1 T4 using=20 (es10codemp,es10datlan,es10tipdoc,fi08codigo,es10numdoc,es10item) WHERE ( T4.co13Emp06 =3D '1' AND T4.co13CodPro =3D '16998' AND T1.es10datlan >=3D '2003-02-01'::date ) AND ( T1.es10datlan >=3D '2003-02-01'::date) AND ( T3.fi08MovEst =3D 'S' ) AND ( T4.es10empa =3D '= 1' OR ( '1' =3D 0 ) ) AND ( T4.es10codalm =3D '0' OR T4.es10almtra =3D '0' OR= ( '0' =3D 0 ) ) AND ( T1.es10datlan <=3D '2003-02-28'::date ) ORDER BY T4.co13Emp06, T4.co13CodPro, T1.es10datlan, T4.es10empa, T4.es10codalm, T4.es10almtra, T1.es10codemp, T1.es10tipdoc, T1.fi08codigo, T1.es10numdoc, T1.es10item; I have some ideas for your query: - you can probably change outer joins into inner ones because of your=20 where clauses - it looks like the most selective where clause is on t4. Maybe you=20 should rewrite your query to have T4 first after "from"? Check how selective is each your where condition and reorder "from=20 ...tables...." to use your where selectivity. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Mon Mar 31 17:17:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 20FF3475D91 for ; Mon, 31 Mar 2003 17:17:25 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 40C6E475CEE for ; Mon, 31 Mar 2003 17:17:24 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h2VMHK2L025611; Mon, 31 Mar 2003 17:17:20 -0500 (EST) To: "alexandre :: aldeia digital" Cc: pgsql-performance@postgresql.org Subject: Re: 30-70 seconds query... In-reply-to: <10846.200.225.202.15.1049145207.squirrel@webmail.ad2.com.br> References: <10846.200.225.202.15.1049145207.squirrel@webmail.ad2.com.br> Comments: In-reply-to "alexandre :: aldeia digital" message dated "Mon, 31 Mar 2003 18:13:27 -0300" Date: Mon, 31 Mar 2003 17:17:20 -0500 Message-ID: <25610.1049149040@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/206 X-Sequence-Number: 1504 "alexandre :: aldeia digital" writes: > I use a case tool and we generate the querys automatically. > explain analyze SELECT T2.fi08ufemp, T4.es10almtra, T3.fi08MovEst, > T1.es10qtdgra, T1.es10Tamanh, T1.es10item, T1.es10numdoc, T1.fi08codigo, > T1.es10tipdoc, T1.es10codemp, T4.es10codalm, T4.es10empa, T1.es10datlan, > T4.co13CodPro, T4.co13Emp06, T1.es10EmpTam FROM (((ES10T2 T1 LEFT JOIN > ES10T T2 ON T2.es10codemp = T1.es10codemp AND T2.es10datlan = > T1.es10datlan AND T2.es10tipdoc = T1.es10tipdoc AND T2.fi08codigo = > T1.fi08codigo AND T2.es10numdoc = T1.es10numdoc) LEFT JOIN FI08T T3 ON > T3.fi08ufemp = T2.fi08ufemp AND T3.fi08codigo =T1.fi08codigo) LEFT JOIN > ES10T1 T4 ON T4.es10codemp = T1.es10codemp AND T4.es10datlan = > T1.es10datlan AND T4.es10tipdoc = T1.es10tipdoc AND T4.fi08codigo = > T1.fi08codigo AND T4.es10numdoc = T1.es10numdoc AND T4.es10item = > T1.es10item) WHERE ( T4.co13Emp06 = '1' AND T4.co13CodPro = '16998' AND > T1.es10datlan >= '2003-02-01'::date ) AND ( T1.es10datlan >= > '2003-02-01'::date) AND ( T3.fi08MovEst = 'S' ) AND ( T4.es10empa = '1' OR > ( '1' = 0 ) ) AND ( T4.es10codalm = '0' OR T4.es10almtra = '0' OR ( '0' > = 0 ) ) AND ( T1.es10datlan <= '2003-02-28'::date ) ORDER BY > T4.co13Emp06, T4.co13CodPro, T1.es10datlan, T4.es10empa, T4.es10codalm, > T4.es10almtra, T1.es10codemp, T1.es10tipdoc, T1.fi08codigo, > T1.es10numdoc, T1.es10item; Your CASE tool isn't doing you any favors, is it :-(. Mostly you need to rearrange the JOIN order into something more efficient. I'd guess that joining T1 to T4, then to T3, then to T2 would be the way to go here. Also, some study of the WHERE conditions proves that all the LEFT JOINs could be reduced to plain joins, because any null-extended row will get discarded by WHERE anyway. That would be a good thing to do to give the planner more flexibility. PG 7.4 will be better prepared to handle this sort of query, but I don't think it will realize that the T1/T2 left join could be reduced to a plain join given these conditions (that requires observing that null T2 will lead to null T3 because of the join condition... hmmm, I wonder how practical that would be...). Without that deduction, the key step of deciding to join T1/T4 first isn't reachable. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 31 17:58:36 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5FE24475CEE for ; Mon, 31 Mar 2003 17:58:35 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A64FA475C15 for ; Mon, 31 Mar 2003 17:58:34 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h2VMwW2L025847; Mon, 31 Mar 2003 17:58:32 -0500 (EST) To: "alexandre :: aldeia digital" Cc: pgsql-performance@postgresql.org Subject: Re: 30-70 seconds query... In-reply-to: <25610.1049149040@sss.pgh.pa.us> References: <10846.200.225.202.15.1049145207.squirrel@webmail.ad2.com.br> <25610.1049149040@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 31 Mar 2003 17:17:20 -0500" Date: Mon, 31 Mar 2003 17:58:32 -0500 Message-ID: <25846.1049151512@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/207 X-Sequence-Number: 1505 I said: > PG 7.4 will be better prepared to handle this sort of query, but I don't > think it will realize that the T1/T2 left join could be reduced to a > plain join given these conditions I take that back --- actually, the algorithm used in CVS tip *does* deduce that all these left joins can be plain joins. Don't suppose you'd like to experiment with a current snapshot to see how well it does for you? regards, tom lane From pgsql-performance-owner@postgresql.org Mon Mar 31 18:48:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7EC94475AA9 for ; Mon, 31 Mar 2003 18:48:07 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id BCEC547580B for ; Mon, 31 Mar 2003 18:48:06 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h2VNkhWU019100; Mon, 31 Mar 2003 16:46:43 -0700 (MST) Date: Mon, 31 Mar 2003 16:44:32 -0700 (MST) From: "scott.marlowe" To: Tom Lane Cc: "alexandre :: aldeia digital" , Subject: Re: 30-70 seconds query... In-Reply-To: <25846.1049151512@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/208 X-Sequence-Number: 1506 On Mon, 31 Mar 2003, Tom Lane wrote: > I said: > > PG 7.4 will be better prepared to handle this sort of query, but I don't > > think it will realize that the T1/T2 left join could be reduced to a > > plain join given these conditions > > I take that back --- actually, the algorithm used in CVS tip *does* > deduce that all these left joins can be plain joins. > > Don't suppose you'd like to experiment with a current snapshot to see > how well it does for you? Think we can get the authors of the case tool that started this to include it? :-)