From pgsql-performance-owner@postgresql.org Thu Jul 1 01:35:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A6E6AD1B1CF for ; Thu, 1 Jul 2004 00:44:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54345-04 for ; Thu, 1 Jul 2004 03:44:46 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 721D7D1B347 for ; Thu, 1 Jul 2004 00:44:46 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i613ikQC046968 for ; Thu, 1 Jul 2004 03:44:46 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i613FCsC040197 for pgsql-performance@postgresql.org; Thu, 1 Jul 2004 03:15:12 GMT From: Joseph Shraibman X-Newsgroups: comp.databases.postgresql.performance Subject: planner and worst case scenario Date: Wed, 30 Jun 2004 23:14:58 -0400 Organization: Hub.Org Networking Services Lines: 71 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/1 X-Sequence-Number: 7392 Here is my query, that returns one row: SELECT f1, f2,(SELECT dfield FROM d WHERE d.ukey = f1) FROM m WHERE status IN(2) AND jid IN(17674) ORDER BY pkey DESC LIMIT 25 OFFSET 0; Here was the really bad plan chosen. This didn't come back for a long while and had to be cancelled: QUERY PLAN ------------------------------------------------------------------------------------------------------ Limit (cost=0.00..10493.05 rows=25 width=118) -> Index Scan Backward using m_pkey on m (cost=0.00..1883712.97 rows=4488 width=118) Filter: ((status = 2) AND (jid = 17674)) SubPlan -> Index Scan using d_pkey on d (cost=0.00..3.83 rows=1 width=24) Index Cond: (ukey = $0) (6 rows) After an ANALYZE the plan was much better: QUERY PLAN ------------------------------------------------------------------------------------------------------ Limit (cost=22060.13..22060.19 rows=25 width=119) -> Sort (cost=22060.13..22067.61 rows=2993 width=119) Sort Key: serial -> Index Scan using m_jid_uid_key on m (cost=0.00..21887.32 rows=2993 width=119) Index Cond: (jid = 17674) Filter: (status = 2) SubPlan -> Index Scan using d_pkey on d (cost=0.00..3.83 rows=1 width=24) Index Cond: (ukey = $0) (9 rows) The thing is since there was only 1 row in the (very big) table with that jid, the ANALYZE didn't include that row in the stats table, so I'm figuring there was a small random change that made it choose the better query. Doing: ALTER TABLE m ALTER jid SET STATISTICS 1000; produce a much more accurate row guess: QUERY PLAN ------------------------------------------------------------------------------------------------------ Limit (cost=2909.65..2909.71 rows=25 width=115) -> Sort (cost=2909.65..2910.64 rows=395 width=115) Sort Key: serial -> Index Scan using m_jid_uid_key on m (cost=0.00..2892.61 rows=395 width=115) Index Cond: (jbid = 17674) Filter: (status = 2) SubPlan -> Index Scan using d_pkey on d (cost=0.00..3.83 rows=1 width=24) Index Cond: (userkey = $0) (9 rows) It seems the problem is that the pg planner goes for the job with the lowest projected time, but ignores the worst case scenario. I think the odds of this problem happening again are lower since the SET STATISTICS, but I don't know what triggered the really bad plan in the first place. Did pg think that because so many rows would match the limit would be filled up soon, so that a more accurate and lower assumption would cause it to choose the better plan? From pgsql-performance-owner@postgresql.org Thu Jul 1 13:51:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DDDA7D1B380 for ; Thu, 1 Jul 2004 13:12:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19213-06 for ; Thu, 1 Jul 2004 16:12:50 +0000 (GMT) Received: from web13122.mail.yahoo.com (web13122.mail.yahoo.com [216.136.174.126]) by svr1.postgresql.org (Postfix) with SMTP id 0E273D1B46A for ; Thu, 1 Jul 2004 13:12:49 -0300 (ADT) Message-ID: <20040701161247.98527.qmail@web13122.mail.yahoo.com> Received: from [63.78.248.48] by web13122.mail.yahoo.com via HTTP; Thu, 01 Jul 2004 09:12:47 PDT Date: Thu, 1 Jul 2004 09:12:47 -0700 (PDT) From: Litao Wu Subject: network address query To: pgsql-performance@postgresql.org In-Reply-To: <13105.1088623982@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/2 X-Sequence-Number: 7393 Hi, I have query: explain SELECT * FROM ip_tracking T, ip_map C WHERE T.source_ip::inet >>= C.net; QUERY PLAN ------------------------------------------------------------------------------------------- Nested Loop (cost=0.00..3894833367750.16 rows=51709297065144 width=111) Join Filter: ("outer".source_ip >>= ("inner".net)::inet) -> Seq Scan on ip_tracking t (cost=0.00..825050.68 rows=31093368 width=34) -> Seq Scan on ip_map c (cost=0.00..83686.66 rows=3326066 width=77) (4 rows) ip_tracking ( pk_col int, source_ip inet, .. the rest... ) There is one index ip_tracking_ip_idx btree (source_ip) ip_map ( net cidr, ... the rest...) Indexes: map_net_idx hash (net) If I change ">>=" to "=", the query plan is: QUERY PLAN -------------------------------------------------------------------------------------------------------------------------- Nested Loop (cost=0.00..10798882243.63 rows=31093368 width=111) -> Seq Scan on ip_map c (cost=0.00..83686.66 rows=3326066 width=77) -> Index Scan using ip_tracking_ip_idx on ip_tracking t (cost=0.00..3236.72 rows=800 width=34) Index Cond: (t.source_ip = ("outer".net)::inet) (4 rows) This is my first time to deal network address type. Is it possible to make a query use index with operator of ">>=" like the above? Thanks, __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail From pgsql-performance-owner@postgresql.org Thu Jul 1 18:45:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9B185D1B785 for ; Thu, 1 Jul 2004 17:44:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68431-04 for ; Thu, 1 Jul 2004 20:44:31 +0000 (GMT) Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) by svr1.postgresql.org (Postfix) with ESMTP id 0C832D1B78E for ; Thu, 1 Jul 2004 17:44:21 -0300 (ADT) Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) by zigo.dhs.org (Postfix) with ESMTP id 98C6088E9; Thu, 1 Jul 2004 22:44:22 +0200 (CEST) Date: Thu, 1 Jul 2004 22:44:22 +0200 (CEST) From: Dennis Bjorklund To: James Antill Cc: pgsql-performance@postgresql.org Subject: Re: Query gets slow when where clause increases In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/4 X-Sequence-Number: 7395 On Tue, 29 Jun 2004, James Antill wrote: > -> Index Scan using idx_ticket_groups_assigned on ticket_groups g (cost=0.00..241.76 rows=5 width=20) (actual time=0.13..12.67 rows=604 loops=1) > Index Cond: (assigned_to = 1540) Here the planner estimated that it would find 5 rows, but it did find 604. I take that as a sign that you have not ran VACUUM ANALYZE recently? If you done that, then maybe you need to change the statistics target for that column. Before you set it on that column you could try to just alter the default statistics target for one session like this: SET default_statistics_target TO 100; ANALYZE; and then see if you get a better plan when you run the query afterwards. If it helps you can either set the default_statistics_target in postgresql.conf or set it just for some column using ALTER TABLE. -- /Dennis Bj�rklund From pgsql-performance-owner@postgresql.org Fri Jul 2 04:47:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 27AD0D1B27C for ; Fri, 2 Jul 2004 04:47:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61543-03 for ; Fri, 2 Jul 2004 07:47:04 +0000 (GMT) Received: from obelix.wu-wien.ac.at (obelix.wu-wien.ac.at [137.208.3.41]) by svr1.postgresql.org (Postfix) with ESMTP id 4028CD1B1CE for ; Fri, 2 Jul 2004 04:46:57 -0300 (ADT) Received: from ekelhardt (floppy.wu-wien.ac.at [137.208.224.91]) by obelix.wu-wien.ac.at (8.12.8/8.12.6) with ESMTP id i627krSU289624 for ; Fri, 2 Jul 2004 09:46:54 +0200 (envelope-from h9351252@obelix.wu-wien.ac.at) From: "Peter Alberer" To: Subject: Mysterious performance of query because of plsql function in where condition Date: Fri, 2 Jul 2004 09:48:48 +0200 Message-ID: <000001c46009$062e8260$5be0d089@ekelhardt> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-WU-uvscan-status: clean v4.3.20/v4371 hiphop c96b3491ee14de741e972cbba84a0d0d X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200407/5 X-Sequence-Number: 7396 Hi there, i have a problem with a query that uses the result of a plsql function In the where clause: SELECT assignments.assignment_id, assignments.package_id AS package_id, assignments.title AS title, COUNT(*) AS Count FROM assignments INNER JOIN submissions ON (assignments.assignment_id=3Dsubmissions.assignment_id) WHERE package_id=3D949589 AND submission_status(submissions.submission_id)=3D'closed' GROUP BY assignments.assignment_id, assignments.package_id, assignments.title ORDER BY assignments.title; Postgres seems to execute the function "submission_status" for every row of the submissions table (~1500 rows). The query therefore takes quite a lot time, although in fact no row is returned from the assignments table when the condition package_id=3D949589 is used. QUERY PLAN ------------------------------------------------------------------------ --- --------------------------------------------------- Sort (cost=3D41.21..41.21 rows=3D1 width=3D35) (actual time=3D4276.978..4276.978 rows=3D0 loops=3D1) Sort Key: assignments.title -> HashAggregate (cost=3D41.19..41.20 rows=3D1 width=3D35) (actual time=3D4276.970..4276.970 rows=3D0 loops=3D1) -> Hash Join (cost=3D2.40..41.18 rows=3D1 width=3D35) (actual time=3D4276.966..4276.966 rows=3D0 loops=3D1) Hash Cond: ("outer".assignment_id =3D "inner".assignment_id) -> Seq Scan on submissions (cost=3D0.00..38.73 rows=3D9 width=3D4) (actual time=3D10.902..4276.745 rows=3D38 loops=3D1) Filter: (submission_status(submission_id) =3D 'closed'::text) -> Hash (cost=3D2.40..2.40 rows=3D2 width=3D35) (actual time=3D0.058..0.058 rows=3D0 loops=3D1) -> Seq Scan on assignments (cost=3D0.00..2.40 rows=3D2 width=3D35) (actual time=3D0.015..0.052 rows=3D2 loops=3D1) Filter: (package_id =3D 949589) Total runtime: 4277.078 ms (11 rows) I therefore tried to rephrase the query, to make sure that the function is only used for the rows returned by the join but not even the following does help (the subselect t1 does not return a single row): select * from ( SELECT a.assignment_id, a.package_id, a.title, s.submission_id, COUNT(*) AS Count FROM assignments a INNER JOIN submissions s ON (a.assignment_id=3Ds.assignment_id) WHERE a.package_id=3D949589 GROUP BY a.assignment_id, a.package_id, a.title, s.submission_id ) t1 where submission_status(t1.submission_id)=3D'closed' order by title; QUERY PLAN ------------------------------------------------------------------------ --- ----------------------------------------------------------- Sort (cost=3D41.21..41.22 rows=3D1 width=3D188) (actual time=3D4114.251..4114.251 rows=3D0 loops=3D1) Sort Key: title -> Subquery Scan t1 (cost=3D41.20..41.20 rows=3D1 width=3D188) (actual time=3D4114.242..4114.242 rows=3D0 loops=3D1) -> HashAggregate (cost=3D41.20..41.20 rows=3D1 width=3D39) (actu= al time=3D4114.238..4114.238 rows=3D0 loops=3D1) -> Hash Join (cost=3D2.40..41.18 rows=3D1 width=3D39) (act= ual time=3D4114.235..4114.235 rows=3D0 loops=3D1) Hash Cond: ("outer".assignment_id =3D "inner".assignment_id) -> Seq Scan on submissions s (cost=3D0.00..38.73 rows=3D9 width=3D8) (actual time=3D7.179..4113.984 rows=3D38 loops=3D1) Filter: (submission_status(submission_id) =3D 'closed'::text) -> Hash (cost=3D2.40..2.40 rows=3D2 width=3D35) (act= ual time=3D0.100..0.100 rows=3D0 loops=3D1) -> Seq Scan on assignments a (cost=3D0.00..2.40 rows=3D2 width=3D35) (actual time=3D0.045..0.094 rows=3D2 loops=3D1) Filter: (package_id =3D 949589) Total runtime: 4114.356 ms (12 rows) The function is nevertheless executed for every row in the submissions table. A simple "select *, submission_status(submission_id) from submissions" takes about the same time as the 2 queries stated above. The whole database has been vacuum analysed right before the explain analyse output has been captured. What can I do to reduce the time this query takes? And why is the function executed although there is no row in the result set of t1 in my rephrased query? TIA, peter Ps: table definitions: Table "public.assignments" Column | Type | Modifiers ---------------+-----------------------------+------------------------ assignment_id | integer | not null title | character varying(100) | not null max_grade | smallint | not null start_date | timestamp without time zone | not null default now() end_date | timestamp without time zone | not null over_due_date | timestamp without time zone | score_release | smallint | not null default 1 package_id | integer | not null cal_item_id | integer | Indexes: "assignments_pk" primary key, btree (assignment_id) Check constraints: "assignments_sr_ck" CHECK (score_release =3D 1 OR score_release =3D 2 OR score_release =3D 3) Foreign-key constraints: "cal_item_id" FOREIGN KEY (cal_item_id) REFERENCES cal_items(cal_item_id) ON DELETE SET NULL "package_id_fk" FOREIGN KEY (package_id) REFERENCES apm_packages(package_id) "assignment_id_fk" FOREIGN KEY (assignment_id) REFERENCES acs_objects(object_id) ON DELETE CASCADE Table "public.submissions" Column | Type | Modifiers ---------------+-----------------------------+----------- submission_id | integer | not null person_id | integer | not null assignment_id | integer | not null last_modified | timestamp without time zone | not null recovery_date | timestamp without time zone | grading | smallint | grading_date | timestamp without time zone | Indexes: "submissions_pk" primary key, btree (submission_id) "submissions_person_ass_un" unique, btree (person_id, assignment_id) Foreign-key constraints: "assignment_id_fk" FOREIGN KEY (assignment_id) REFERENCES assignments(assignment_id) "person_id_fk" FOREIGN KEY (person_id) REFERENCES persons(person_id) -- peter.alberer@wu-wien.ac.at Tel: +43/1/31336/4341 Abteilung f=FCr Wirtschaftsinformatik, Wirtschaftsuniversitaet Wien, Austria From pgsql-bugs-owner@postgresql.org Fri Jul 2 04:50:18 2004 X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 75B1FD1B373 for ; Fri, 2 Jul 2004 04:50:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60972-10 for ; Fri, 2 Jul 2004 07:50:09 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 08125D1B27C for ; Fri, 2 Jul 2004 04:50:08 -0300 (ADT) Received: by www.postgresql.com (Postfix, from userid 80) id B448FCF4D52; Fri, 2 Jul 2004 04:50:07 -0300 (ADT) To: pgsql-bugs@postgresql.org Subject: BUG #1186: Broken Index? From: "PostgreSQL Bugs List" Reply-To: "Gosen, Hitoshi" Message-Id: <20040702075007.B448FCF4D52@www.postgresql.com> Date: Fri, 2 Jul 2004 04:50:07 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/19 X-Sequence-Number: 8601 The following bug has been logged online: Bug reference: 1186 Logged by: Gosen, Hitoshi Email address: mic-gosen@ns.inter-mic.co.jp PostgreSQL version: 7.4 Operating system: linux 2.4.18 Description: Broken Index? Details: Hello All, We are using PostgreSQL 7.4.2 for our website that handles over 200,000 transactions a day. About a month ago, the responses from the SELECT queries on the database became terribly slow. We tried to anaylze the cause of the problem, searching throught the system logs and all, but nothing appeared to be out of the ordinary. What we did to resolve this was to dump the database, delete the database, recreate the database, and finally restore it. After that, things were back to normal. From the above experience, we were able to hypothesize that the fault of the slow responses was not from a broken data or hardware failures, but from a broken index, since we were able to recover 100% of the data on the same machine. Today, the same problem occured, and the same actions are going to be taken to temporary resolve it. Final note: we will also experiment with the 'vacuum full' command to see if it counters this problem. From pgsql-performance-owner@postgresql.org Fri Jul 2 08:52:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B3733D1B1FD for ; Fri, 2 Jul 2004 08:51:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81738-09 for ; Fri, 2 Jul 2004 11:51:28 +0000 (GMT) Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.198.39]) by svr1.postgresql.org (Postfix) with ESMTP id 98A25D1B1EC for ; Fri, 2 Jul 2004 08:51:24 -0300 (ADT) Received: from jefftrout.com ([24.128.241.68]) by comcast.net (rwcrmhc13) with SMTP id <200407021151260150079orge>; Fri, 2 Jul 2004 11:51:27 +0000 Received: (qmail 68752 invoked from network); 2 Jul 2004 11:51:28 -0000 Received: from unknown (HELO ?192.168.0.103?) (10.10.10.176) by 10.10.10.10 with SMTP; 2 Jul 2004 11:51:28 -0000 In-Reply-To: <000001c46009$062e8260$5be0d089@ekelhardt> References: <000001c46009$062e8260$5be0d089@ekelhardt> Mime-Version: 1.0 (Apple Message framework v613) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <4A8C38D1-CC1E-11D8-BD01-000D9366F0C4@torgo.978.org> Content-Transfer-Encoding: 7bit Cc: From: Jeff Subject: Re: Mysterious performance of query because of plsql function in where condition Date: Fri, 2 Jul 2004 07:52:27 -0400 To: "Peter Alberer" X-Mailer: Apple Mail (2.613) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/6 X-Sequence-Number: 7397 On Jul 2, 2004, at 3:48 AM, Peter Alberer wrote: > > Postgres seems to execute the function "submission_status" for every > row > of > the submissions table (~1500 rows). The query therefore takes quite a > lot > time, although in fact no row is returned from the assignments table > when > the condition package_id=949589 is used. > Well, you need to think of it this way - PG has no idea what the function does so it treats it as a "black box" - thus it has to run it for each row to see what evaluates too - especially since it is in a where clause. If you really want a function there you can use a SQL function instead of plpgsql - PG has smart enough to push that function up into your query and let the optimizer look at the whole thing. You can also take a look at the various flags you can use while creating functions such as immutable, strict, etc. they can help -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Fri Jul 2 10:00:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A6B2D1B26C for ; Fri, 2 Jul 2004 10:00:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18639-05 for ; Fri, 2 Jul 2004 13:00:33 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 0D84DD1B1D5 for ; Fri, 2 Jul 2004 10:00:27 -0300 (ADT) Received: (qmail 25503 invoked by uid 500); 2 Jul 2004 13:07:10 -0000 Date: Fri, 2 Jul 2004 08:07:10 -0500 From: Bruno Wolff III To: Peter Alberer Cc: pgsql-performance@postgresql.org Subject: Re: Mysterious performance of query because of plsql function in where condition Message-ID: <20040702130710.GA25007@wolff.to> Mail-Followup-To: Peter Alberer , pgsql-performance@postgresql.org References: <000001c46009$062e8260$5be0d089@ekelhardt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000001c46009$062e8260$5be0d089@ekelhardt> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=MAILTO_TO_SPAM_ADDR X-Spam-Level: * X-Archive-Number: 200407/7 X-Sequence-Number: 7398 On Fri, Jul 02, 2004 at 09:48:48 +0200, Peter Alberer wrote: > > Postgres seems to execute the function "submission_status" for every row > of > the submissions table (~1500 rows). The query therefore takes quite a > lot > time, although in fact no row is returned from the assignments table > when > the condition package_id=949589 is used. If submission_status is invertable you might want to create the inverse function, mark it immutable and call it with 'closed'. That would allow the optimizer to compare submissions.submission_id to a constant. Another option would be be to create an index on submission_status(submissions.submission_id). From pgsql-bugs-owner@postgresql.org Fri Jul 2 10:06:22 2004 X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6E1C2D1B1DA for ; Fri, 2 Jul 2004 10:06:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20939-06 for ; Fri, 2 Jul 2004 13:06:18 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 05EE8D1B18E for ; Fri, 2 Jul 2004 10:06:14 -0300 (ADT) Received: (qmail 25624 invoked by uid 500); 2 Jul 2004 13:12:58 -0000 Date: Fri, 2 Jul 2004 08:12:58 -0500 From: Bruno Wolff III To: "Gosen, Hitoshi" Cc: pgsql-bugs@postgresql.org, pgsql-performance@postgresql.org Subject: Re: BUG #1186: Broken Index? Message-ID: <20040702131258.GB25007@wolff.to> Mail-Followup-To: pgsql-performance@postgresql.org References: <20040702075007.B448FCF4D52@www.postgresql.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040702075007.B448FCF4D52@www.postgresql.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/27 X-Sequence-Number: 8609 On Fri, Jul 02, 2004 at 04:50:07 -0300, PostgreSQL Bugs List wrote: > > The following bug has been logged online: This doesn't appear to be a bug at this point. It sounds like you have a self induced performance problem, so I am moving the discussion to pgsql-performance. > > Bug reference: 1186 > Logged by: Gosen, Hitoshi > > Email address: mic-gosen@ns.inter-mic.co.jp > > PostgreSQL version: 7.4 > > Operating system: linux 2.4.18 > > Description: Broken Index? > > Details: > > Hello All, > We are using PostgreSQL 7.4.2 for our website that handles over 200,000 > transactions a day. > About a month ago, the responses from the SELECT queries on the database > became terribly slow. > We tried to anaylze the cause of the problem, searching throught the system > logs and all, but nothing appeared to be out of the ordinary. > > What we did to resolve this was to dump the database, delete the database, > recreate the database, and finally restore it. After that, things were back > to normal. > > From the above experience, we were able to hypothesize that the fault of the > slow responses was not from a broken data or hardware failures, but from a > broken index, since we were able to recover 100% of the data on the same > machine. > > Today, the same problem occured, and the same actions are going to be taken > to temporary resolve it. > > Final note: we will also experiment with the 'vacuum full' command to see > if it counters this problem. It sounds like you aren't properly vacuuming your database. It is possible that you need a higher FSM setting or to vacuum more frequently. From pgsql-performance-owner@postgresql.org Wed Jul 7 16:20:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2C39AD1B345 for ; Fri, 2 Jul 2004 11:37:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74768-08 for ; Fri, 2 Jul 2004 14:37:32 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 3F62BD1B2D9 for ; Fri, 2 Jul 2004 11:37:28 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i62EbRZ5069174 for ; Fri, 2 Jul 2004 14:37:27 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i62ENj0x066582 for pgsql-performance@postgresql.org; Fri, 2 Jul 2004 14:23:45 GMT From: CoL X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Mysterious performance of query because of plsql function in Date: Fri, 02 Jul 2004 16:23:44 +0200 Organization: Hub.Org Networking Services Lines: 35 Message-ID: References: <000001c46009$062e8260$5be0d089@ekelhardt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en In-Reply-To: <000001c46009$062e8260$5be0d089@ekelhardt> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/25 X-Sequence-Number: 7416 hi, Peter Alberer wrote: > Hi there, > > i have a problem with a query that uses the result of a plsql function > In > the where clause: > > SELECT > assignments.assignment_id, > assignments.package_id AS package_id, > assignments.title AS title, > COUNT(*) AS Count > FROM > assignments INNER JOIN submissions ON > (assignments.assignment_id=submissions.assignment_id) > WHERE > package_id=949589 AND > submission_status(submissions.submission_id)='closed' > GROUP BY > assignments.assignment_id, assignments.package_id, assignments.title > ORDER BY > assignments.title; > > Postgres seems to execute the function "submission_status" for every row > of > the submissions table (~1500 rows). what is submission_status actualy? \df submission_status Is the function submission_status called stable? C. From pgsql-admin-owner@postgresql.org Thu Jul 8 13:05:50 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 943B0D1B33F for ; Fri, 2 Jul 2004 15:54:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11865-06 for ; Fri, 2 Jul 2004 18:54:52 +0000 (GMT) Received: from smtp2.aruba.it (smtp2.aruba.it [62.149.128.201]) by svr1.postgresql.org (Postfix) with SMTP id 14440D1B172 for ; Fri, 2 Jul 2004 15:54:48 -0300 (ADT) Received: (qmail 6320 invoked from network); 2 Jul 2004 18:50:16 -0000 Received: from unknown (HELO ?192.168.0.69?) (80.183.237.107) by smtp2.aruba.it with SMTP; 2 Jul 2004 18:50:16 -0000 Message-ID: <40E5AE72.1080206@expot.it> Date: Fri, 02 Jul 2004 20:50:26 +0200 From: Edoardo Ceccarelli Organization: EXPOT User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Cc: pgsql-admin@postgresql.org Subject: finding a max value References: <20040702075007.B448FCF4D52@www.postgresql.com> <20040702131258.GB25007@wolff.to> In-Reply-To: <20040702131258.GB25007@wolff.to> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: smtp2.aruba.it 1.6.2 0/1000/N X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/100 X-Sequence-Number: 14168 This is the query: select max(KA) from annuncio field KA is indexed and is int4, explaining gives: explain select max(KA) from annuncio; QUERY PLAN ----------------------------------------------------------------------- Aggregate (cost=21173.70..21173.70 rows=1 width=4) -> Seq Scan on annuncio (cost=0.00..20326.76 rows=338776 width=4) (2 rows) wasn't supposed to do an index scan? it takes about 1sec to get the result. From pgsql-bugs-owner@postgresql.org Sat Jul 3 19:57:46 2004 X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1EADBD1B51D for ; Sat, 3 Jul 2004 19:57:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17441-01 for ; Sat, 3 Jul 2004 22:57:37 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id F39F0D1B53E for ; Sat, 3 Jul 2004 19:57:34 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i63MvYi9019543 for ; Sat, 3 Jul 2004 22:57:35 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i63MmgvR017314 for pgsql-bugs@postgresql.org; Sat, 3 Jul 2004 22:48:42 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.bugs Subject: Re: BUG #1186: Broken Index? Date: Sat, 03 Jul 2004 16:51:50 +0200 Organization: PYRENET Midi-pyrenees Provider Lines: 37 Message-ID: References: <20040702075007.B448FCF4D52@www.postgresql.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en In-Reply-To: <20040702075007.B448FCF4D52@www.postgresql.com> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-bugs@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=DATE_IN_PAST_06_12 X-Spam-Level: X-Archive-Number: 200407/44 X-Sequence-Number: 8626 PostgreSQL Bugs List wrote: > Hello All, > We are using PostgreSQL 7.4.2 for our website that handles over 200,000 > transactions a day. > About a month ago, the responses from the SELECT queries on the database > became terribly slow. > We tried to anaylze the cause of the problem, searching throught the system > logs and all, but nothing appeared to be out of the ordinary. > > What we did to resolve this was to dump the database, delete the database, > recreate the database, and finally restore it. After that, things were back > to normal. > > From the above experience, we were able to hypothesize that the fault of the > slow responses was not from a broken data or hardware failures, but from a > broken index, since we were able to recover 100% of the data on the same > machine. > > Today, the same problem occured, and the same actions are going to be taken > to temporary resolve it. > > Final note: we will also experiment with the 'vacuum full' command to see > if it counters this problem. This is not for sure a bug, but a known behaviour if you don't vacuum at all your db. I bet you don't use the vacuum daemon; use it or schedule a simple vacuum on the eavily updated table each 10 minutes. I strongly suggest you to use the autovacuum daemon. Do not esitate to ask how use it. Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Wed Jul 7 16:19:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA059D1B1B7 for ; Mon, 5 Jul 2004 06:18:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88974-01 for ; Mon, 5 Jul 2004 09:18:39 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id C1FDAD1B1D9 for ; Mon, 5 Jul 2004 06:18:35 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1BhPcS-0007k1-00 for ; Mon, 05 Jul 2004 11:18:36 +0200 Date: Mon, 5 Jul 2004 11:18:36 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Odd sorting behaviour Message-ID: <20040705091836.GA29652@uio.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/24 X-Sequence-Number: 7415 [Please CC me on all replies, I'm not subscribed to this list] Hi, I'm trying to find out why one of my queries is so slow -- I'm primarily using PostgreSQL 7.2 (Debian stable), but I don't really get much better performance with 7.4 (Debian unstable). My prototype table looks like this: CREATE TABLE opinions ( prodid INTEGER NOT NULL, uid INTEGER NOT NULL, opinion INTEGER NOT NULL, PRIMARY KEY ( prodid, uid ) ); In addition, there are separate indexes on prodid and uid. I've run VACUUM ANALYZE before all queries, and they are repeatable. (If anybody needs the data, that could be arranged -- it's not secret or anything :-) ) My query looks like this: EXPLAIN ANALYZE SELECT o3.prodid, SUM(o3.opinion*o12.correlation) AS total_correlation FROM opinions o3 RIGHT JOIN ( SELECT o2.uid, SUM(o1.opinion*o2.opinion)/SQRT(count(*)+0.0) AS correlation FROM opinions o1 LEFT JOIN opinions o2 ON o1.prodid=o2.prodid WHERE o1.uid=1355 GROUP BY o2.uid ) o12 ON o3.uid=o12.uid LEFT JOIN ( SELECT o4.prodid, COUNT(*) as num_my_comments FROM opinions o4 WHERE o4.uid=1355 GROUP BY o4.prodid ) nmc ON o3.prodid=nmc.prodid WHERE nmc.num_my_comments IS NULL AND o3.opinion<>0 AND o12.correlation<>0 GROUP BY o3.prodid ORDER BY total_correlation desc; And produces the query plan at http://www.samfundet.no/~sesse/queryplan.txt (The lines were a bit too long to include in an e-mail :-) ) Note that the "o3.opinion<>0 AND o12.correleation<>0" lines are an optimization; I can run the query fine without them and it will produce the same results, but it goes slower both in 7.2 and 7.4. There are a few oddities here: - The "subquery scan o12" phase outputs 1186 rows, yet 83792 are sorted. Where do the other ~82000 rows come from? And why would it take ~100ms to sort the rows at all? (In earlier tests, this was _one full second_ but somehow that seems to have improved, yet without really improving the overall query time. shared_buffers is 4096 and sort_mem is 16384, so it should really fit into RAM.) - Why does it use uid_index for an index scan on the table, when it obviously has no filter on it (since it returns all the rows)? Furthermore, why would this take half a second? (The machine is a 950MHz machine with SCSI disks.) - Also, the outer sort (the sorting of the 58792 rows from the merge join) is slow. :-) 7.4 isn't really much better: http://www.samfundet.no/~sesse/queryplan74.txt Note that this is run on a machine with almost twice the speed (in terms of CPU speed, at least). The same oddities are mostly present (such as o12 returning 1186 rows, but 58788 rows are sorted), so I really don't understand what's going on here. Any ideas on how to improve this? /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Mon Jul 5 07:11:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9AFCCD1B1DA for ; Mon, 5 Jul 2004 07:11:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11168-08 for ; Mon, 5 Jul 2004 10:11:21 +0000 (GMT) Received: from ludojad.itpp.pl (ludojad.itpp.pl [193.41.112.10]) by svr1.postgresql.org (Postfix) with ESMTP id 20BEFD1B196 for ; Mon, 5 Jul 2004 07:11:18 -0300 (ADT) Received: by ludojad.itpp.pl (Postfix, from userid 1111) id 7E4A6B71DF; Mon, 5 Jul 2004 12:15:15 +0200 (CEST) Date: Mon, 5 Jul 2004 12:15:15 +0200 From: eleven@ludojad.itpp.pl To: pgsql-performance@postgresql.org Subject: Seq scan vs. Index scan with different query conditions Message-ID: <20040705101515.GA12879@ludojad.itpp.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200407/9 X-Sequence-Number: 7400 Hello, Can anybody suggest any hint on this: temp=> EXPLAIN SELECT DISTINCT "number" FROM "tablex" WHERE "Date" BETWEEN '2004-06-28'::date AND '2004-07-04'::date AND "Time" BETWEEN '00:00:00'::time AND '18:01:00'::time; Unique (cost=305669.92..306119.43 rows=89 width=8) -> Sort (cost=305669.92..305894.67 rows=89903 width=8) Sort Key: "number" -> Index Scan using "DateTimeIndex" on "tablex" (cost=0.00..298272.66 rows=89903 width=8) Index Cond: (("Date" >= '2004-06-28'::date) AND ("Date" <= '2004-07-04'::date) AND ("Time" >= '00:00:00'::time without time zone) AND ("Time" <= '18:01:00'::time without time zone)) temp=> EXPLAIN SELECT DISTINCT "number" FROM "tablex" WHERE "Date" BETWEEN '2004-06-28'::date AND '2004-07-04'::date AND "Time" BETWEEN '00:00:00'::time AND '19:01:00'::time; Unique (cost=315252.77..315742.27 rows=97 width=8) -> Sort (cost=315252.77..315497.52 rows=97900 width=8) Sort Key: "number" -> Seq Scan on "tablex" (cost=0.00..307137.34 rows=97900 width=8) Filter: (("Date" >= '2004-06-28'::date) AND ("Date" <= '2004-07-04'::date) AND ("Time" >= '00:00:00'::time without time zone) AND ("Time" <= '19:01:00'::time without time zone)) Basically, the difference is in upper "Time" value (as you can see, it's 18:01:00 in the first query and 19:01:00 in the other one). The question is - why does it use index in first case and it tries to do full sequential scan when the upper "Time" value is different? DateTimeIndex was created on both columns (Date/Time): CREATE INDEX "DateTimeIndex" ON "tablex" USING btree ("Date", "Time"); -- wr From pgsql-performance-owner@postgresql.org Mon Jul 5 08:41:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7F879D1B1EC for ; Mon, 5 Jul 2004 08:41:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52753-04 for ; Mon, 5 Jul 2004 11:41:22 +0000 (GMT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id 660F7D1B1D9 for ; Mon, 5 Jul 2004 08:41:18 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) id 1BhRqY-000OAX-0Z; Mon, 05 Jul 2004 12:41:19 +0100 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 7C49717943; Mon, 5 Jul 2004 12:41:15 +0100 (BST) Message-ID: <40E93E5C.1000907@archonet.com> Date: Mon, 05 Jul 2004 12:41:16 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: eleven@ludojad.itpp.pl Cc: pgsql-performance@postgresql.org Subject: Re: Seq scan vs. Index scan with different query conditions References: <20040705101515.GA12879@ludojad.itpp.pl> In-Reply-To: <20040705101515.GA12879@ludojad.itpp.pl> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/10 X-Sequence-Number: 7401 eleven@ludojad.itpp.pl wrote: > -> Index Scan using "DateTimeIndex" on "tablex" (cost=0.00..298272.66 rows=89903 width=8) > -> Seq Scan on "tablex" (cost=0.00..307137.34 rows=97900 width=8) > Basically, the difference is in upper "Time" value (as you can see, it's > 18:01:00 in the first query and 19:01:00 in the other one). > The question is - why does it use index in first case and > it tries to do full sequential scan when the upper "Time" value > is different? Look at the rows, and more importantly the cost. PG thinks the cost in the second case (seq scan) is only slightly more than in the first case (index), so presumably the index scan worked out more expensive. You can test this by issuing "SET ENABLE_SEQSCAN=OFF;" and re-running the second explain. Now, the question is whether PG is right in these cost estimates. You'll need to run "EXPLAIN ANALYSE" rather than just EXPLAIN to see what it actually costs. PS - all the usual questions: make sure you've vacuumed, have you read the tuning document on varlena.com? -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Mon Jul 5 08:44:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 18F08D1B1D5 for ; Mon, 5 Jul 2004 08:44:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52664-07 for ; Mon, 5 Jul 2004 11:44:21 +0000 (GMT) Received: from lamb.mcmillan.net.nz (218-101-12-175.paradise.net.nz [218.101.12.175]) by svr1.postgresql.org (Postfix) with ESMTP id E84B4D1B1E0 for ; Mon, 5 Jul 2004 08:44:16 -0300 (ADT) Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) by lamb.mcmillan.net.nz (Postfix) with ESMTP id 9505FAD9859E; Mon, 5 Jul 2004 23:44:14 +1200 (NZST) Subject: Re: Seq scan vs. Index scan with different query From: Andrew McMillan To: eleven@ludojad.itpp.pl Cc: pgsql-performance@postgresql.org In-Reply-To: <20040705101515.GA12879@ludojad.itpp.pl> References: <20040705101515.GA12879@ludojad.itpp.pl> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-D7Gn1fqrapxF38GPn3pl" Date: Mon, 05 Jul 2004 23:44:13 +1200 Message-Id: <1089027854.6664.197.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 X-Mailer: Evolution 1.5.9.2 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/11 X-Sequence-Number: 7402 --=-D7Gn1fqrapxF38GPn3pl Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, 2004-07-05 at 12:15 +0200, eleven@ludojad.itpp.pl wrote: > Hello, >=20 > Can anybody suggest any hint on this: >=20 > temp=3D> EXPLAIN SELECT DISTINCT "number" FROM "tablex" WHERE "Date" BETW= EEN '2004-06-28'::date AND '2004-07-04'::date AND "Time" BETWEEN '00:00:00'= ::time AND '18:01:00'::time; >=20 > Unique (cost=3D305669.92..306119.43 rows=3D89 width=3D8) > -> Sort (cost=3D305669.92..305894.67 rows=3D89903 width=3D8) > Sort Key: "number" > -> Index Scan using "DateTimeIndex" on "tablex" (cost=3D0.00..298272= .66 rows=3D89903 width=3D8) > Index Cond: (("Date" >=3D '2004-06-28'::date) AND ("Date" <=3D '2004-= 07-04'::date) AND ("Time" >=3D '00:00:00'::time without time zone) AND ("Ti= me" <=3D '18:01:00'::time without time zone)) >=20 >=20 > temp=3D> EXPLAIN SELECT DISTINCT "number" FROM "tablex" WHERE "Date" BETW= EEN '2004-06-28'::date AND '2004-07-04'::date AND "Time" BETWEEN '00:00:00'= ::time AND '19:01:00'::time; >=20 > Unique (cost=3D315252.77..315742.27 rows=3D97 width=3D8) > -> Sort (cost=3D315252.77..315497.52 rows=3D97900 width=3D8) > Sort Key: "number" > -> Seq Scan on "tablex" (cost=3D0.00..307137.34 rows=3D97900 width= =3D8) > Filter: (("Date" >=3D '2004-06-28'::date) AND ("Date" <=3D '2004-07-04= '::date) AND ("Time" >=3D '00:00:00'::time without time zone) AND ("Time" <= =3D '19:01:00'::time without time zone)) >=20 > Basically, the difference is in upper "Time" value (as you can see, it's > 18:01:00 in the first query and 19:01:00 in the other one).=20 > The question is - why does it use index in first case and=20 > it tries to do full sequential scan when the upper "Time" value > is different? >=20 > DateTimeIndex was created on both columns (Date/Time): > CREATE INDEX "DateTimeIndex" ON "tablex" USING btree ("Date", "Time"); PostgreSQL is always going to switch at some point, where the number of rows that have to be read from the table exceed some percentage of the total rows in the table. We can possibly be more helpful if you send EXPLAIN ANALYZE, rather than just EXPLAIN. A few things to be careful of: - Is this supposed to be a slice of midnight to 6pm, for each day between 28 June and 4 July? If you want a continuous period from Midnight 28 June -> 6pm 4 July you're better to have a single timestamp field. - It is unlikely that the , "Time" on your index is adding much to your selectivity, and it may be that you would be better off without it. - the DISTINCT can screw up your results, and it usually means that the SQL is not really the best it could be. A _real_ need for DISTINCT is quite rare in my experience, and from what I have seen it adds overhead and tends to encourage bad query plans when used unnecessarily. Hope this is some help. Regards, Andrew McMillan ------------------------------------------------------------------------- Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 Make things as simple as possible, but no simpler -- Einstein ------------------------------------------------------------------------- --=-D7Gn1fqrapxF38GPn3pl Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBA6T8NjJA0f48GgBIRAuMEAJ9yMe8jagZvUB4gLyeolqpPtueeGQCgtzSG b2oxoi/xilX6DiQNvZAwfyE= =atnn -----END PGP SIGNATURE----- --=-D7Gn1fqrapxF38GPn3pl-- From pgsql-performance-owner@postgresql.org Mon Jul 5 10:42:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6C637D1B258 for ; Mon, 5 Jul 2004 10:42:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09586-07 for ; Mon, 5 Jul 2004 13:42:19 +0000 (GMT) Received: from ludojad.itpp.pl (ludojad.itpp.pl [193.41.112.10]) by svr1.postgresql.org (Postfix) with ESMTP id 50BFBD1B1DA for ; Mon, 5 Jul 2004 10:42:14 -0300 (ADT) Received: by ludojad.itpp.pl (Postfix, from userid 1111) id 925F2B7691; Mon, 5 Jul 2004 15:46:15 +0200 (CEST) Date: Mon, 5 Jul 2004 15:46:15 +0200 From: eleven@ludojad.itpp.pl To: pgsql-performance@postgresql.org Subject: Re: Seq scan vs. Index scan with different query conditions Message-ID: <20040705134615.GA18520@ludojad.itpp.pl> References: <20040705101515.GA12879@ludojad.itpp.pl> <1089027854.6664.197.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline In-Reply-To: <1089027854.6664.197.camel@lamb.mcmillan.net.nz> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200407/12 X-Sequence-Number: 7403 On Mon, Jul 05, 2004 at 11:44:13PM +1200, Andrew McMillan wrote: > > DateTimeIndex was created on both columns (Date/Time): > > CREATE INDEX "DateTimeIndex" ON "tablex" USING btree ("Date", "Time"); > PostgreSQL is always going to switch at some point, where the number of > rows that have to be read from the table exceed some percentage of the > total rows in the table. > We can possibly be more helpful if you send EXPLAIN ANALYZE, rather than > just EXPLAIN. Unfortunately that seq scan vs. index scan heuristic was wrong - full scan kills the machine in no time due to large amount of INSERTs happening in the background (I/O bottleneck). > - Is this supposed to be a slice of midnight to 6pm, for each day > between 28 June and 4 July? If you want a continuous period from > Midnight 28 June -> 6pm 4 July you're better to have a single timestamp > field. > - It is unlikely that the , "Time" on your index is adding much to your > selectivity, and it may be that you would be better off without it. Yes, we've figured out that index on Date + Time is rather useless. Thanks for the tip, we've created index upon Date column instead and it should be enough. > - the DISTINCT can screw up your results, and it usually means that the > SQL is not really the best it could be. A _real_ need for DISTINCT is > quite rare in my experience, and from what I have seen it adds overhead > and tends to encourage bad query plans when used unnecessarily. What do you mean? The reason for which there's DISTINCT in that query is because I want to know how many unique rows is in the table. Do you suggest selecting all rows and doing "DISTINCT"/counting on the application level? -- 11. From pgsql-performance-owner@postgresql.org Mon Jul 5 16:24:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2A00ED1B181 for ; Mon, 5 Jul 2004 16:24:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81820-03 for ; Mon, 5 Jul 2004 19:24:17 +0000 (GMT) Received: from lamb.mcmillan.net.nz (leibniz.catalyst.net.nz [202.49.159.7]) by svr1.postgresql.org (Postfix) with ESMTP id 2394BD1B1DA for ; Mon, 5 Jul 2004 16:24:14 -0300 (ADT) Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) by lamb.mcmillan.net.nz (Postfix) with ESMTP id 02E17AD9859E; Tue, 6 Jul 2004 07:22:06 +1200 (NZST) Subject: Re: Seq scan vs. Index scan with different query From: Andrew McMillan To: eleven@ludojad.itpp.pl Cc: pgsql-performance@postgresql.org In-Reply-To: <20040705134615.GA18520@ludojad.itpp.pl> References: <20040705101515.GA12879@ludojad.itpp.pl> <1089027854.6664.197.camel@lamb.mcmillan.net.nz> <20040705134615.GA18520@ludojad.itpp.pl> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-llkkrdGlDNQgerLZzqQz" Date: Tue, 06 Jul 2004 07:22:05 +1200 Message-Id: <1089055325.6664.220.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 X-Mailer: Evolution 1.5.9.2 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/13 X-Sequence-Number: 7404 --=-llkkrdGlDNQgerLZzqQz Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, 2004-07-05 at 15:46 +0200, eleven@ludojad.itpp.pl wrote: > On Mon, Jul 05, 2004 at 11:44:13PM +1200, Andrew McMillan wrote: >=20 > > > DateTimeIndex was created on both columns (Date/Time): > > > CREATE INDEX "DateTimeIndex" ON "tablex" USING btree ("Date", "Time"); > > PostgreSQL is always going to switch at some point, where the number of > > rows that have to be read from the table exceed some percentage of the > > total rows in the table. > > We can possibly be more helpful if you send EXPLAIN ANALYZE, rather than > > just EXPLAIN. >=20 > Unfortunately that seq scan vs. index scan > heuristic was wrong - full scan kills the machine=20 > in no time due to large amount of INSERTs happening=20 > in the background (I/O bottleneck). In that case you could perhaps consider tweaking various parameters in your postgresql.conf - with an ideal setup the switch should happen when the costs are roughly equal. Have you gone through the information here: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html Also, if table rows are regularly DELETEd or UPDATEd then you will need to ensure it is regularly vacuumed. Does a "VACUUM VERBOSE tablex" show a large number of dead tuples? Are you running pg_autovacuum? Do you get similar results immediately after a "VACUUM FULL ANALYZE tablex"? Possibly there is an uneven distribution of rows in the table. You could consider increasing the statistics target: ALTER TABLE tablex ALTER COLUMN "Date" SET STATISTICS; ANALYZE tablex; > > - Is this supposed to be a slice of midnight to 6pm, for each day > > between 28 June and 4 July? If you want a continuous period from > > Midnight 28 June -> 6pm 4 July you're better to have a single timestamp > > field. > > - It is unlikely that the , "Time" on your index is adding much to your > > selectivity, and it may be that you would be better off without it. >=20 > Yes, we've figured out that index on Date + Time is rather useless. > Thanks for the tip, we've created index upon Date column instead and > it should be enough. It may be that you are better with a single timestamp column with an index on it in any case, if you want the data sorted in timestamp order. Then you can ORDER BY as well, which will encourage the index use further (although this advantage tends to get lost with the DISTINCT). You can still access the time part for a separate comparison just with a cast. > > - the DISTINCT can screw up your results, and it usually means that the > > SQL is not really the best it could be. A _real_ need for DISTINCT is > > quite rare in my experience, and from what I have seen it adds overhead > > and tends to encourage bad query plans when used unnecessarily. >=20 > What do you mean? The reason for which there's DISTINCT in that query is > because I want to know how many unique rows is in the table. > Do you suggest selecting all rows and doing "DISTINCT"/counting=20 > on the application level? That's fine, I've just seen it used far too many times as a substitute for having an extra join, or an application that should only be inserting unique rows in the first place. Things like that. It's just one of those things that always sets off alarm bells when I'm reviewing someone else's work, and on most of these occasions it has not been justified when reexamined. Cheers, 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)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 It is truth which you cannot contradict; you can without any difficulty contradict Socrates. - Plato ------------------------------------------------------------------------- --=-llkkrdGlDNQgerLZzqQz Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBA6apdjJA0f48GgBIRAho8AJsGFlsNHzn+fMny5+wdKdAjTJooVwCgnM1U T031/zvvQfbf3cpXOPv7hh0= =0rZp -----END PGP SIGNATURE----- --=-llkkrdGlDNQgerLZzqQz-- From pgsql-performance-owner@postgresql.org Wed Jul 7 16:04:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8B439D1B195 for ; Mon, 5 Jul 2004 20:14:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72520-08 for ; Mon, 5 Jul 2004 23:14:35 +0000 (GMT) Received: from web50708.mail.yahoo.com (web50708.mail.yahoo.com [206.190.38.106]) by svr1.postgresql.org (Postfix) with SMTP id 66130D1B1AB for ; Mon, 5 Jul 2004 20:14:31 -0300 (ADT) Message-ID: <20040705231434.81471.qmail@web50708.mail.yahoo.com> Received: from [69.138.204.74] by web50708.mail.yahoo.com via HTTP; Mon, 05 Jul 2004 16:14:34 PDT Date: Mon, 5 Jul 2004 16:14:34 -0700 (PDT) From: Eugene Subject: Forcing HashAggregation prior to index scan? To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/22 X-Sequence-Number: 7413 I have a very simple problem. I run two select statments, they are identical except for a single where condition. The first select statment runs in 9 ms, while the second statment runs for 4000 ms SQL1 - fast 9ms explain analyse select seq_ac from refseq_sequence S where seq_ac in (select seq_ac2 from refseq_refseq_hits where seq_ac1 = 'NP_001217') SQL2 - very slow 4000ms explain analyse select seq_ac from refseq_sequence S where seq_ac in (select seq_ac2 from refseq_refseq_hits where seq_ac1 = 'NP_001217') AND S.species = 'Homo sapiens' I think the second sql statment is slower than the first one because planner is not using HashAggregate. Can I force HashAggregation before index scan? Here is the full output from EXPLAIN ANALYZE explain analyse select seq_ac from refseq_sequence S where seq_ac in (select seq_ac2 from refseq_refseq_hits where seq_ac1 = 'NP_001217'); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (cost=169907.83..169919.88 rows=3 width=24) (actual time=1.450..8.707 rows=53 loops=1) -> HashAggregate (cost=169907.83..169907.83 rows=2 width=19) (actual time=1.192..1.876 rows=53 loops=1) -> Index Scan using refseq_refseq_hits_pkey on refseq_refseq_hits (cost=0.00..169801.33 rows=42600 width=19) (actual time=0.140..0.894 rows=54 loops=1) Index Cond: ((seq_ac1)::text = 'NP_001217'::text) -> Index Scan using refseq_sequence_pkey on refseq_sequence s (cost=0.00..6.01 rows=1 width=24) (actual time=0.105..0.111 rows=1 loops=53) Index Cond: ((s.seq_ac)::text = ("outer".seq_ac2)::text) Total runtime: 9.110 ms explain analyse select seq_ac from refseq_sequence S where seq_ac in (select seq_ac2 from refseq_refseq_hits where seq_ac1 = 'NP_001217') and S.species = 'Homo sapiens'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop IN Join (cost=0.00..4111.66 rows=1 width=24) (actual time=504.176..3857.340 rows=30 loops=1) -> Index Scan using refseq_sequence_key2 on refseq_sequence s (cost=0.00..1516.06 rows=389 width=24) (actual time=0.352..491.107 rows=27391 loops=1) Index Cond: ((species)::text = 'Homo sapiens'::text) -> Index Scan using refseq_refseq_hits_pkey on refseq_refseq_hits (cost=0.00..858.14 rows=213 width=19) (actual time=0.114..0.114 rows=0 loops=27391) Index Cond: (((refseq_refseq_hits.seq_ac1)::text = 'NP_001217'::text) AND (("outer".seq_ac)::text = (refseq_refseq_hits.seq_ac2)::text)) Total runtime: 3857.636 ms From pgsql-performance-owner@postgresql.org Tue Jul 6 12:00:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EDEF4D1B1D2 for ; Tue, 6 Jul 2004 12:00:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88060-02 for ; Tue, 6 Jul 2004 15:00:12 +0000 (GMT) Received: from anubis.cinterfor.org.uy (r200-40-147-2.adinet.com.uy [200.40.147.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5273ED1B181 for ; Tue, 6 Jul 2004 12:00:02 -0300 (ADT) Received: from cinterfor.org.uy (it01.cinterfor.org.uy [200.40.147.47]) by anubis.cinterfor.org.uy (8.11.6/8.11.2) with ESMTP id i66Ehpo06479; Tue, 6 Jul 2004 11:43:51 -0300 Message-ID: <40EABDEF.3090607@cinterfor.org.uy> Date: Tue, 06 Jul 2004 11:57:51 -0300 From: Rodrigo Filgueira Organization: CINTERFOR/OIT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: es, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: to fsync or not to fsync Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Cfor-MailScanner: Found to be clean/Hallado libre de virus X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/14 X-Sequence-Number: 7405 Hello there, I'm trying to make sure my postgres 7.4 is running as fast as it can in my box. My hardware configuration is: HP ML-350G3 Dup processor XEON 2.8 Three U320, 10000 rpm disks, RAID-5 HP 641 Raid Controller. 1GB RAM My Software config is: RedHat 7.3 - 2.4.20-28.7smp Kernel, reporting four processors because of hyper threading. Postgres 7.4 Data directory is on a ext3 journaled filesystem (data=journal) Log directory is on another partition. It is to be a dedicated to databases server, this means there are no other heavy processes running. My tests with pgbench with fsync turned off: [root@dbs pgbench]# ./pgbench -U dba -P 4ghinec osdb -c 10 -s 11 -t 1000 starting vacuum...end. transaction type: TPC-B (sort of) scaling factor: 1 number of clients: 10 number of transactions per client: 1000 number of transactions actually processed: 10000/10000 tps = 408.520028 (including connections establishing) tps = 409.697088 (excluding connections establishing) with fsync turned on: [root@dbs pgbench]# ./pgbench -U dba -P 4ghinec osdb starting vacuum...end. transaction type: TPC-B (sort of) scaling factor: 1 number of clients: 1 number of transactions per client: 10 number of transactions actually processed: 10/10 tps = 43.366451 (including connections establishing) tps = 44.867394 (excluding connections establishing) I did a lot of these tests and results are consistent. Now then, without fsync on I get a 1000% improvment!!!! Questions now: 1) since I'm using ext3 with data=journal, do I need to use fsync=true? 2) Is there not a problem with RedHat? should fsyncs asked by postgres to redhat be such a burden? 3) Any other tests you would suggest me to do? thank you all Rodrigo Filgueira Prates IT@CINTERFOR/OIT http://www.cinterfor.org.uy From pgsql-performance-owner@postgresql.org Tue Jul 6 12:45:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9C516D1B19F for ; Tue, 6 Jul 2004 12:45:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12092-08 for ; Tue, 6 Jul 2004 15:45:17 +0000 (GMT) Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.240]) by svr1.postgresql.org (Postfix) with SMTP id 1EDFED1B181 for ; Tue, 6 Jul 2004 12:45:13 -0300 (ADT) Received: by mproxy.gmail.com with SMTP id w29so3144430cwb for ; Tue, 06 Jul 2004 08:45:11 -0700 (PDT) Received: by 10.11.118.71 with SMTP id q71mr434012cwc; Tue, 06 Jul 2004 08:45:10 -0700 (PDT) Message-ID: <753644204070608452ac91892@mail.gmail.com> Date: Tue, 6 Jul 2004 11:45:10 -0400 From: Frank Hsueh To: Rodrigo Filgueira Subject: Re: to fsync or not to fsync Cc: pgsql-performance@postgresql.org In-Reply-To: <40EABDEF.3090607@cinterfor.org.uy> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <40EABDEF.3090607@cinterfor.org.uy> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=NORMAL_HTTP_TO_IP X-Spam-Level: X-Archive-Number: 200407/15 X-Sequence-Number: 7406 Rodrigo, > Hello there, I'm trying to make sure my postgres 7.4 is running as fast > as it can in my box. > ... > My Software config is: > > RedHat 7.3 - 2.4.20-28.7smp Kernel, reporting four processors because of > hyper threading. > Postgres 7.4 > Data directory is on a ext3 journaled filesystem (data=journal) Isn't ext3 a really slow journaled filesystem [1, 2] to begin with? [1] http://slashdot.org/article.pl?sid=04/05/11/134214 [2] http://209.81.41.149/~jpiszcz/index.html It might be a good experiment to figure out how different file systems affect perf. -- Frank Hsueh, EngSci Elec 0T3 + 1 email: frank.hsueh@gmail.com From pgsql-performance-owner@postgresql.org Tue Jul 6 13:50:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2C166D1B1B8 for ; Tue, 6 Jul 2004 13:50:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47466-10 for ; Tue, 6 Jul 2004 16:50:47 +0000 (GMT) Received: from anubis.cinterfor.org.uy (r200-40-147-2.adinet.com.uy [200.40.147.2]) by svr1.postgresql.org (Postfix) with ESMTP id 12586D1B1AB for ; Tue, 6 Jul 2004 13:50:38 -0300 (ADT) Received: from cinterfor.org.uy (it01.cinterfor.org.uy [200.40.147.47]) by anubis.cinterfor.org.uy (8.11.6/8.11.2) with ESMTP id i66GTEo11350; Tue, 6 Jul 2004 13:29:15 -0300 Message-ID: <40EAD6A2.9030400@cinterfor.org.uy> Date: Tue, 06 Jul 2004 13:43:14 -0300 From: Rodrigo Filgueira Organization: CINTERFOR/OIT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: es, en MIME-Version: 1.0 To: Frank Hsueh Cc: pgsql-performance@postgresql.org Subject: Re: to fsync or not to fsync (ext3?) References: <40EABDEF.3090607@cinterfor.org.uy> <753644204070608452ac91892@mail.gmail.com> In-Reply-To: <753644204070608452ac91892@mail.gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Cfor-MailScanner: Found to be clean/Hallado libre de virus X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=NORMAL_HTTP_TO_IP X-Spam-Level: X-Archive-Number: 200407/16 X-Sequence-Number: 7407 Frank, thanks for your answer, This article http://www.linuxjournal.com/print.php?sid=5841 evaluates performance from a relational database point of view and it concludes that ext3 is faster. The articles you provided evaluate filesystems by using basic shell commands, copy, tar, touch. I really don't know why ext3 would be faster for databases but here are some tests that suggest this is true, I run pgbench with data=writeback for ext3, this is as ext2 as an ext3 fs can get, and results are more or less the same as with data=journal Best run with data=journal ------------------------------------ [root@dbs pgbench]# ./pgbench -U dba -P 4ghinec osdb -c 10 -s 11 -t 1000 starting vacuum...end. transaction type: TPC-B (sort of) scaling factor: 1 number of clients: 10 number of transactions per client: 1000 number of transactions actually processed: 10000/10000 tps = 349.844978 (including connections establishing) tps = 350.715286 (excluding connections establishing) Best run with data=writeback ---------------------------------------- [root@dbs pgbench]# ./pgbench -U dba -P 4ghinec osdb -c 10 -s 11 -t 1000 starting vacuum...end. transaction type: TPC-B (sort of) scaling factor: 1 number of clients: 10 number of transactions per client: 1000 number of transactions actually processed: 10000/10000 tps = 319.239210 (including connections establishing) tps = 319.961564 (excluding connections establishing) anybody else can throw some light on this? Frank Hsueh wrote: >Rodrigo, > > >>Hello there, I'm trying to make sure my postgres 7.4 is running as fast >>as it can in my box. >> >> >>My Software config is: >> >>RedHat 7.3 - 2.4.20-28.7smp Kernel, reporting four processors because of >>hyper threading. >>Postgres 7.4 >>Data directory is on a ext3 journaled filesystem (data=journal) >> >> >Isn't ext3 a really slow journaled filesystem [1, 2] to begin with? > >[1] http://slashdot.org/article.pl?sid=04/05/11/134214 >[2] http://209.81.41.149/~jpiszcz/index.html > >It might be a good experiment to figure out how different file systems >affect perf. > > Rodrigo Filgueira Prates IT@CINTERFOR/OIT http://www.cinterfor.org.uy From pgsql-performance-owner@postgresql.org Tue Jul 6 14:54:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 22AB5D1B20D for ; Tue, 6 Jul 2004 14:54:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80926-10 for ; Tue, 6 Jul 2004 17:54:10 +0000 (GMT) Received: from hotmail.com (bay17-dav9.bay17.hotmail.com [64.4.43.189]) by svr1.postgresql.org (Postfix) with ESMTP id 13A29D1B1D5 for ; Tue, 6 Jul 2004 14:54:08 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 6 Jul 2004 10:52:31 -0700 Received: from 142.104.250.115 by bay17-dav9.bay17.hotmail.com with DAV; Tue, 06 Jul 2004 17:52:31 +0000 X-Originating-IP: [142.104.250.115] X-Originating-Email: [borajetta@hotmail.com] X-Sender: borajetta@hotmail.com From: "borajetta" To: Subject: Keyword searching question Date: Tue, 6 Jul 2004 10:52:59 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0013_01C46347.66E63FD0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: X-OriginalArrivalTime: 06 Jul 2004 17:52:31.0540 (UTC) FILETIME=[02B2FF40:01C46382] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=HTML_20_30, HTML_MESSAGE, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/17 X-Sequence-Number: 7408 This is a multi-part message in MIME format. ------=_NextPart_000_0013_01C46347.66E63FD0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have been trying to get keyword searching quicker and have now decided to= make smaller tables. I was working with tables of about 50 000 000 rows but now will use about 1= .5million rows, I am using a TSearch2 to find keywords in the titles column= of the rows. I have indexes using a gist index on the TSearch2 using 'def= ault'. I wanted to know if it would be quicker to change my words in the title int= o crc32 bit integers and then look for them using an index which would be o= n the crc numbers. I could then cluster on the crc numbers and this should= result in a fast search but I just want to know if you know of better ways= of doing keyword searching, I need it to be about 1-4 seconds and return u= sually around 1-5 thousand rows. I know places like google and ebay do seaches and only return 200 or 100 ma= x rows, this can be done on our current system very fast as you just limit = the number returned but for our purposes I need to return all the rows, Thanks smokedvw ------=_NextPart_000_0013_01C46347.66E63FD0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I have been trying to get keyword searchin= g quicker=20 and have now decided to make smaller tables.
 
I was working with tables of about 50 000 = 000 rows=20 but now will use about 1.5million rows, I am using a TSearch2 to find keywo= rds=20 in the titles column of the rows.  I have indexes using a gist index o= n the=20 TSearch2 using 'default'.
I wanted to know if it would be quicker to= change=20 my words in the title into crc32 bit integers and then look for them using = an=20 index which would be on the crc numbers.  I could then cluster on the = crc=20 numbers and this should result in a fast search but I just want to know if = you=20 know of better ways of doing keyword searching, I need it to be about 1-4= =20 seconds and return usually around 1-5 thousand rows.
 
I know places like google and ebay do seac= hes and=20 only return 200 or 100 max rows, this can be done on our current system ver= y=20 fast as you just limit the number returned but for our purposes I need to r= eturn=20 all the rows,
 
Thanks
smokedvw
------=_NextPart_000_0013_01C46347.66E63FD0-- From pgsql-performance-owner@postgresql.org Tue Jul 6 14:57:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A3EA4D1B1A9 for ; Tue, 6 Jul 2004 14:57:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86115-01 for ; Tue, 6 Jul 2004 17:57:28 +0000 (GMT) Received: from hotmail.com (bay17-dav8.bay17.hotmail.com [64.4.43.188]) by svr1.postgresql.org (Postfix) with ESMTP id 0ABAAD1B1B0 for ; Tue, 6 Jul 2004 14:57:26 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 6 Jul 2004 10:56:01 -0700 Received: from 142.104.250.115 by bay17-dav8.bay17.hotmail.com with DAV; Tue, 06 Jul 2004 17:56:01 +0000 X-Originating-IP: [142.104.250.115] X-Originating-Email: [borajetta@hotmail.com] X-Sender: borajetta@hotmail.com From: "borajetta" To: Subject: Re: Keyword searching question Date: Tue, 6 Jul 2004 10:56:29 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0028_01C46347.E43B5CE0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: X-OriginalArrivalTime: 06 Jul 2004 17:56:01.0326 (UTC) FILETIME=[7FBDCCE0:01C46382] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=HTML_30_40, HTML_MESSAGE, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/18 X-Sequence-Number: 7409 This is a multi-part message in MIME format. ------=_NextPart_000_0028_01C46347.E43B5CE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Forgot to mention that were running post gres 7.4.2 using a dual optiron sy= stem and 4gig ram. The results are used by the PHP web server. Thanks again ----- Original Message -----=20 From: borajetta=20 To: pgsql-performance@postgresql.org=20 Sent: Tuesday, July 06, 2004 10:52 AM Subject: Keyword searching question I have been trying to get keyword searching quicker and have now decided = to make smaller tables. I was working with tables of about 50 000 000 rows but now will use about= 1.5million rows, I am using a TSearch2 to find keywords in the titles colu= mn of the rows. I have indexes using a gist index on the TSearch2 using 'd= efault'. I wanted to know if it would be quicker to change my words in the title i= nto crc32 bit integers and then look for them using an index which would be= on the crc numbers. I could then cluster on the crc numbers and this shou= ld result in a fast search but I just want to know if you know of better wa= ys of doing keyword searching, I need it to be about 1-4 seconds and return= usually around 1-5 thousand rows. I know places like google and ebay do seaches and only return 200 or 100 = max rows, this can be done on our current system very fast as you just limi= t the number returned but for our purposes I need to return all the rows, Thanks smokedvw ------=_NextPart_000_0028_01C46347.E43B5CE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Forgot to mention that were running post g= res 7.4.2=20 using a dual optiron system and 4gig ram. The results are used by the PHP w= eb=20 server.
Thanks again
----- Original Message -----
Fro= m:=20 borajetta
To: pgsql-performance@postgr= esql.org=20
Sent: Tuesday, July 06, 2004 10:52= =20 AM
Subject: Keyword searching questio= n

I have been trying to get keyword search= ing=20 quicker and have now decided to make smaller tables.
 
I was working with tables of about 50 00= 0 000=20 rows but now will use about 1.5million rows, I am using a TSearch2 to fin= d=20 keywords in the titles column of the rows.  I have indexes using a g= ist=20 index on the TSearch2 using 'default'.
I wanted to know if it would be quicker = to change=20 my words in the title into crc32 bit integers and then look for them usin= g an=20 index which would be on the crc numbers.  I could then cluster on th= e crc=20 numbers and this should result in a fast search but I just want to know i= f you=20 know of better ways of doing keyword searching, I need it to be about 1-4= =20 seconds and return usually around 1-5 thousand rows.
 
I know places like google and ebay do se= aches and=20 only return 200 or 100 max rows, this can be done on our current system v= ery=20 fast as you just limit the number returned but for our purposes I need to= =20 return all the rows,
 
Thanks
smokedvw
------=_NextPart_000_0028_01C46347.E43B5CE0-- From pgsql-performance-owner@postgresql.org Wed Jul 7 12:13:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2B240D1B1AE for ; Wed, 7 Jul 2004 12:13:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47834-08 for ; Wed, 7 Jul 2004 15:13:45 +0000 (GMT) Received: from mailhost.ics.forth.gr (mailhost.ics.forth.gr [139.91.157.50]) by svr1.postgresql.org (Postfix) with ESMTP id E3CCFD1B196 for ; Wed, 7 Jul 2004 12:13:44 -0300 (ADT) Received: from mailhost.ics.forth.gr (nemesis.ics.forth.gr [139.91.157.50]) by mailhost.ics.forth.gr (8.12.10/ICS-FORTH/V10-Server-1.0) with SMTP id i67FDgEx014864 for ; Wed, 7 Jul 2004 18:13:43 +0300 (EEST) Received: (from ASSP-nospam [127.0.0.1]) by mailhost.ics.forth.gr (SAVSMTP 3.1.0.29) with SMTP id M2004070718134214905 for ; Wed, 07 Jul 2004 18:13:42 +0300 Received: from 139.91.157.52 ([139.91.157.52] helo=calliope.ics.forth.gr) by ASSP-nospam ; 7 Jul 04 15:13:42 -0000 Received: from localhost (theohari@localhost) by calliope.ics.forth.gr (8.9.3/ICS-FORTH/V8.2.2C-INTNULL) with ESMTP id SAA22125 for ; Wed, 7 Jul 2004 18:13:42 +0300 (EET DST) X-Authentication-Warning: calliope.ics.forth.gr: theohari owned process doing -bs Date: Wed, 7 Jul 2004 18:13:42 +0300 (EET DST) From: Ioannis Theoharis To: pgsql-performance@postgresql.org Subject: Implementatiion of Inheritance in Postgres Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/19 X-Sequence-Number: 7410 I would like to ask you where i can find information about the implementation of the inheritance relationship in Postgres. There are several ways to store and to retrieve instances contained in an hierarchie. Which clustering and buffer replacement policy implements Postgres? There is a system table called pg_inherits, but how is it used during hierarchies traversing? From pgsql-performance-owner@postgresql.org Wed Jul 7 13:17:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C4668D1B1B6 for ; Wed, 7 Jul 2004 13:17:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90709-05 for ; Wed, 7 Jul 2004 16:17:38 +0000 (GMT) Received: from web51408.mail.yahoo.com (web51408.mail.yahoo.com [206.190.38.187]) by svr1.postgresql.org (Postfix) with SMTP id B4F73D1B1AE for ; Wed, 7 Jul 2004 13:17:36 -0300 (ADT) Message-ID: <20040707161640.48270.qmail@web51408.mail.yahoo.com> Received: from [192.88.67.254] by web51408.mail.yahoo.com via HTTP; Wed, 07 Jul 2004 09:16:40 PDT Date: Wed, 7 Jul 2004 09:16:40 -0700 (PDT) From: Bill Chandler Subject: Terrible performance after deleting/recreating indexes To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200407/20 X-Sequence-Number: 7411 Hi, Using PostgreSQL 7.4.2 on Solaris. I'm trying to improve performance on some queries to my databases so I wanted to try out various index structures. Since I'm going to be running my performance tests repeatedly, I created some SQL scripts to delete and recreate various index configurations. One of the scripts contains the commands for recreating the 'original' index configuration (i.e. the one I've already got some numbers for). Only thing is now when I delete and recreate the original indexes then run the query, I'm finding the performance has gone completely down the tubes compared to what I originally had. A query that used to take 5 minutes to complete now takes hours to complete. For what it's worth my query looks something like: select * from tbl_1, tbl_2 where tbl_1.id = tbl_2.id and tbl_2.name like 'x%y%' and tbl_1.x > 1234567890123 order by tbl_1.x; tbl_1 is very big (> 2 million rows) tbl_2 is relatively small (7000 or so rows) tbl_1.x is a numeric(13) tbl_1.id & tbl_2.id are integers tbl_2.name is a varchar(64) I've run 'VACUUM ANALYZE' on both tables involved in the query. I also used 'EXPLAIN' and observed that the query plan is completely changed from what it was originally. Any idea why this would be? I would have thougth that a freshly created index would have better performance not worse. I have not done any inserts or updates since recreating the indexes. thanks in advance, Bill C __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From pgsql-performance-owner@postgresql.org Wed Jul 7 14:24:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5C981D1B18C for ; Wed, 7 Jul 2004 14:24:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26343-03 for ; Wed, 7 Jul 2004 17:24:16 +0000 (GMT) Received: from f10207-20.adc1.level3.com (qfe1.f10207-20.Atlanta2.Level3.net [67.72.93.25]) by svr1.postgresql.org (Postfix) with ESMTP id B9E44D1B1B7 for ; Wed, 7 Jul 2004 14:24:14 -0300 (ADT) Received: from scanner3.l3.com (qfe0.f4ff49-08.idc1.oss.level3.com [10.1.156.103]) by f10207-20.adc1.level3.com (8.12.10/8.12.10) with ESMTP id i67HOCsO013134 for ; Wed, 7 Jul 2004 17:24:12 GMT Received: from scanner3.l3.com (localhost [127.0.0.1]) by localhost.l3.com (Postfix) with ESMTP id AE89678B404 for ; Wed, 7 Jul 2004 17:24:11 +0000 (GMT) Received: from idc1exc0001.corp.global.level3.com (idc1exc0001.corp.global.level3.com [10.1.7.194]) by scanner3.l3.com (Postfix) with SMTP id 8429778B401 for ; Wed, 7 Jul 2004 17:24:11 +0000 (GMT) Received: from idc1exc0002.corp.global.level3.com ([10.1.8.18]) by idc1exc0001.corp.global.level3.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 7 Jul 2004 11:24:11 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: inserting into brand new database faster than old database Date: Wed, 7 Jul 2004 11:24:11 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: inserting into brand new database faster than old database Thread-Index: AcRd5wGKoioF3cKeTdallpjVj3vtPgGXlbsQ From: "Missner, T. R." To: X-OriginalArrivalTime: 07 Jul 2004 17:24:11.0410 (UTC) FILETIME=[37C17F20:01C46447] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/21 X-Sequence-Number: 7412 Hello, I have been a happy postgresql developer for a few years now. Recently I have discovered a very strange phenomenon in regards to inserting rows. My app inserts millions of records a day, averaging about 30 rows a second. I use autovac to make sure my stats and indexes are up to date. Rarely are rows ever deleted. Each day a brand new set of tables is created and eventually the old tables are dropped. The app calls functions which based on some simple logic perform the correct inserts. The problem I am seeing is that after a particular database gets kinda old, say a couple of months, performance begins to degrade. Even after creating brand new tables my insert speed is slow in comparison ( by a magnitude of 5 or more ) with a brand new schema which has the exact same tables. I am running on an IBM 360 dual processor Linux server with a 100 gig raid array spanning 5 scsi disks. The machine has 1 gig of ram of which 500 meg is dedicated to Postgresql. Just to be clear, the question I have is why would a brand new db schema allow inserts faster than an older schema with brand new tables? Since the tables are empty to start, vacuuming should not be an issue at all. Each schema is identical in every way except the db name and creation date. Any ideas are appreciated. Thanks, T.R. Missner From pgsql-performance-owner@postgresql.org Wed Jul 7 16:25:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4FDC1D1B360 for ; Wed, 7 Jul 2004 16:19:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85025-03 for ; Wed, 7 Jul 2004 19:19:23 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id 7AD36D1B342 for ; Wed, 7 Jul 2004 16:19:20 -0300 (ADT) Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=[192.168.0.66]) by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) id 1BiHwu-00001o-Ki; Wed, 07 Jul 2004 15:19:21 -0400 Message-ID: <40EC4C36.1050608@zeut.net> Date: Wed, 07 Jul 2004 15:17:10 -0400 From: "Matthew T. O'Connor" User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Missner, T. R." Cc: pgsql-performance@postgresql.org Subject: Re: inserting into brand new database faster than old database References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 67.80.199.173 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/26 X-Sequence-Number: 7417 I don't think I have enough detail about your app. Couple of questions, are there any tables that recieve a lot of inserts / updates / deletes that are not deleted and recreated often? If so, one possibility is that you don't have a large enough FSM settings and your table is actually growing despite using autovac. Does that sounds possbile to you? Missner, T. R. wrote: > Hello, > > I have been a happy postgresql developer for a few years now. Recently > I have discovered a very strange phenomenon in regards to inserting > rows. > > My app inserts millions of records a day, averaging about 30 rows a > second. I use autovac to make sure my stats and indexes are up to date. > Rarely are rows ever deleted. Each day a brand new set of tables is > created and eventually the old tables are dropped. The app calls > functions which based on some simple logic perform the correct inserts. > > > The problem I am seeing is that after a particular database gets kinda > old, say a couple of months, performance begins to degrade. Even after > creating brand new tables my insert speed is slow in comparison ( by a > magnitude of 5 or more ) with a brand new schema which has the exact > same tables. I am running on an IBM 360 dual processor Linux server > with a 100 gig raid array spanning 5 scsi disks. The machine has 1 gig > of ram of which 500 meg is dedicated to Postgresql. > > Just to be clear, the question I have is why would a brand new db schema > allow inserts faster than an older schema with brand new tables? Since > the tables are empty to start, vacuuming should not be an issue at all. > Each schema is identical in every way except the db name and creation > date. > > Any ideas are appreciated. > > Thanks, > > T.R. Missner > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > From pgsql-performance-owner@postgresql.org Wed Jul 7 16:28:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8F2A4D1B19C for ; Wed, 7 Jul 2004 16:28:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86905-08 for ; Wed, 7 Jul 2004 19:28:20 +0000 (GMT) Received: from f10207-20.adc1.level3.com (qfe1.f10207-20.Atlanta2.Level3.net [67.72.93.25]) by svr1.postgresql.org (Postfix) with ESMTP id 1D51FD1B195 for ; Wed, 7 Jul 2004 16:28:18 -0300 (ADT) Received: from scanner3.l3.com (qfe0.f4ff49-08.idc1.oss.level3.com [10.1.156.103]) by f10207-20.adc1.level3.com (8.12.10/8.12.10) with ESMTP id i67JSGsO001545; Wed, 7 Jul 2004 19:28:16 GMT Received: from scanner3.l3.com (localhost [127.0.0.1]) by localhost.l3.com (Postfix) with ESMTP id E352C78B403; Wed, 7 Jul 2004 19:28:15 +0000 (GMT) Received: from idc1exc0001.corp.global.level3.com (idc1exc0001.corp.global.level3.com [10.1.7.194]) by scanner3.l3.com (Postfix) with SMTP id B754B78B401; Wed, 7 Jul 2004 19:28:15 +0000 (GMT) Received: from idc1exc0002.corp.global.level3.com ([10.1.8.18]) by idc1exc0001.corp.global.level3.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 7 Jul 2004 13:28:15 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: inserting into brand new database faster than old database Date: Wed, 7 Jul 2004 13:28:15 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] inserting into brand new database faster than old database Thread-Index: AcRkV1EpMo6D+8/tRgGpVIOMzI6UOQAAMcaA From: "Missner, T. R." To: "Matthew T. O'Connor" Cc: X-OriginalArrivalTime: 07 Jul 2004 19:28:15.0540 (UTC) FILETIME=[8CCD9740:01C46458] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/27 X-Sequence-Number: 7418 I do have one table that acts as a lookup table and grows in size as the app runs, however in the tests I have been doing I have dropped and recreated all tables including the lookup table. I keep wondering how disk is allocated to a particular DB. Also is there any way I could tell whether the writes to disk are the bottleneck? T.R. Missner Level(3) Communications SSID tools Senior Software Engineer -----Original Message----- From: Matthew T. O'Connor [mailto:matthew@zeut.net]=20 Sent: Wednesday, July 07, 2004 1:17 PM To: Missner, T. R. Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] inserting into brand new database faster than old database I don't think I have enough detail about your app. Couple of questions, are there any tables that recieve a lot of inserts / updates / deletes=20 that are not deleted and recreated often? If so, one possibility is=20 that you don't have a large enough FSM settings and your table is=20 actually growing despite using autovac. Does that sounds possbile to you? Missner, T. R. wrote: > Hello, >=20 > I have been a happy postgresql developer for a few years now. Recently > I have discovered a very strange phenomenon in regards to inserting > rows. >=20 > My app inserts millions of records a day, averaging about 30 rows a > second. I use autovac to make sure my stats and indexes are up to date. > Rarely are rows ever deleted. Each day a brand new set of tables is > created and eventually the old tables are dropped. The app calls > functions which based on some simple logic perform the correct inserts. >=20 >=20 > The problem I am seeing is that after a particular database gets kinda > old, say a couple of months, performance begins to degrade. Even after > creating brand new tables my insert speed is slow in comparison ( by a > magnitude of 5 or more ) with a brand new schema which has the exact > same tables. I am running on an IBM 360 dual processor Linux server > with a 100 gig raid array spanning 5 scsi disks. The machine has 1 gig > of ram of which 500 meg is dedicated to Postgresql. >=20 > Just to be clear, the question I have is why would a brand new db schema > allow inserts faster than an older schema with brand new tables? Since > the tables are empty to start, vacuuming should not be an issue at all. > Each schema is identical in every way except the db name and creation > date. >=20 > Any ideas are appreciated. >=20 > Thanks, >=20 > T.R. Missner >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match >=20 From pgsql-performance-owner@postgresql.org Thu Jul 8 13:13:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 03C6BD1B1B7 for ; Wed, 7 Jul 2004 16:30:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90596-05 for ; Wed, 7 Jul 2004 19:30:05 +0000 (GMT) Received: from mail.and.org (code.and.org [63.113.167.33]) by svr1.postgresql.org (Postfix) with ESMTP id 132AAD1B19F for ; Wed, 7 Jul 2004 16:30:01 -0300 (ADT) Received: from james by mail.and.org with local (Exim 4.30) id 1BiI7C-0000WL-Pu; Wed, 07 Jul 2004 15:29:58 -0400 To: Edoardo Ceccarelli Cc: pgsql-performance@postgresql.org Subject: Re: finding a max value From: James Antill References: <20040702075007.B448FCF4D52@www.postgresql.com> <20040702131258.GB25007@wolff.to> <40E5AE72.1080206@expot.it> Content-Type: text/plain; charset=US-ASCII Date: Wed, 07 Jul 2004 15:29:58 -0400 In-Reply-To: <40E5AE72.1080206@expot.it> (Edoardo Ceccarelli's message of "Fri, 02 Jul 2004 20:50:26 +0200") Message-ID: User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, linux) MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/35 X-Sequence-Number: 7426 Edoardo Ceccarelli writes: > This is the query: > select max(KA) from annuncio > > field KA is indexed and is int4, > > explaining gives: > explain select max(KA) from annuncio; > QUERY PLAN > ----------------------------------------------------------------------- > Aggregate (cost=21173.70..21173.70 rows=1 width=4) > -> Seq Scan on annuncio (cost=0.00..20326.76 rows=338776 width=4) > (2 rows) > > > wasn't supposed to do an index scan? it takes about 1sec to get the result. This is a known misfeature of max() in postgresql, see... http://archives.postgresql.org/pgsql-performance/2003-12/msg00283.php -- # James Antill -- james@and.org :0: * ^From: .*james@and\.org /dev/null From pgsql-admin-owner@postgresql.org Wed Jul 7 17:34:22 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E073AD1B1F8 for ; Wed, 7 Jul 2004 17:34:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24219-03 for ; Wed, 7 Jul 2004 20:34:12 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) by svr1.postgresql.org (Postfix) with SMTP id 43D81D1B1C8 for ; Wed, 7 Jul 2004 17:34:09 -0300 (ADT) Received: by mproxy.gmail.com with SMTP id 62so190427rni for ; Wed, 07 Jul 2004 13:33:59 -0700 (PDT) Received: by 10.38.181.19 with SMTP id d19mr148256rnf; Wed, 07 Jul 2004 13:27:19 -0700 (PDT) Message-ID: <37d451f704070713271da13629@mail.gmail.com> Date: Wed, 7 Jul 2004 15:27:19 -0500 From: Rosser Schwarz To: Edoardo Ceccarelli Subject: Re: [PERFORM] finding a max value Cc: pgsql-performance@postgresql.org, pgsql-admin@postgresql.org In-Reply-To: <40E5AE72.1080206@expot.it> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20040702075007.B448FCF4D52@www.postgresql.com> <20040702131258.GB25007@wolff.to> <40E5AE72.1080206@expot.it> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/89 X-Sequence-Number: 14157 On Fri, 02 Jul 2004 20:50:26 +0200, Edoardo Ceccarelli wrote: > This is the query: > select max(KA) from annuncio > wasn't supposed to do an index scan? it takes about 1sec to get the result. > TIP 5: Have you checked our extensive FAQ? I believe this is a FAQ. See: http://www.postgresql.org/docs/faqs/FAQ.html#4.8 Try "select KA from annuncio order by KA desc limit 1;" /rls -- :wq From pgsql-performance-owner@postgresql.org Wed Jul 7 18:27:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6C5C5D1B18F for ; Wed, 7 Jul 2004 18:27:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46376-07 for ; Wed, 7 Jul 2004 21:27:30 +0000 (GMT) Received: from ecintweb.eldocomp.com (ecintweb.eldocomp.com [205.159.99.8]) by svr1.postgresql.org (Postfix) with ESMTP id 05412D1B1C8 for ; Wed, 7 Jul 2004 18:27:26 -0300 (ADT) Received: by ecintweb.eldocomp.com with XWall v3.29f ; Wed, 7 Jul 2004 14:27:28 -0700 From: Joel McGraw To: "pgsql-performance@postgresql.org" Subject: query plan wierdness? Date: Wed, 7 Jul 2004 14:27:27 -0700 X-Assembled-By: XWall v3.29f Message-ID: <7B3E33EF2A10A84185E3667F6B9A1B781A0679@ECIEXCHANGE.eldocomp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=EXCUSE_16, LINES_OF_YELLING, TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200407/29 X-Sequence-Number: 7420 Can someone explain what I'm missing here? This query does what I expect--it uses the "foo" index on the openeddatetime, callstatus, calltype, callkey fields: elon2=3D# explain analyse select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by openeddatetime desc, callstatus desc, calltype desc, callkey desc limit 26; =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ----------------------------- Limit (cost=3D0.00..103.76 rows=3D26 width=3D297) (actual time=3D0.07..0.= 58 rows=3D26 loops=3D1) -> Index Scan Backward using foo on call (cost=3D0.00..1882805.77 rows=3D471781 width=3D297) (actual time=3D0.06..0.54 rows=3D27 loops=3D1) Index Cond: ((openeddatetime >=3D '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime <=3D '2004-06-24 23:59:59.999-07'::timestamp with time zone)) Filter: (aspid =3D '123C'::bpchar) Total runtime: 0.66 msec (5 rows) However, this query performs a sequence scan on the table, ignoring the call_idx13 index (the only difference is the addition of the aspid field in the order by clause): elon2=3D# explain analyse select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by aspid, openeddatetime desc, callstatus desc, calltype desc, callkey desc limit 26; =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------------------------------------------ Limit (cost=3D349379.41..349379.48 rows=3D26 width=3D297) (actual time=3D32943.52..32943.61 rows=3D26 loops=3D1) -> Sort (cost=3D349379.41..350558.87 rows=3D471781 width=3D297) (actual time=3D32943.52..32943.56 rows=3D27 loops=3D1) Sort Key: aspid, openeddatetime, callstatus, calltype, callkey -> Seq Scan on call (cost=3D0.00..31019.36 rows=3D471781 width=3D297) (actual time=3D1.81..7318.13 rows=3D461973 loops=3D1) Filter: ((aspid =3D '123C'::bpchar) AND (openeddatetime >=3D '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime <=3D '2004-06-24 23:59:59.999-07'::timestamp with time zone)) Total runtime: 39353.86 msec (6 rows) Here's the structure of the table in question: Table "public.call" Column | Type | Modifiers=20 ------------------+--------------------------+----------- aspid | character(4) |=20 lastmodifiedtime | timestamp with time zone |=20 moduser | character(13) |=20 callkey | character(13) |=20 calltype | text |=20 callqueueid | text |=20 openeddatetime | timestamp with time zone |=20 assigneddatetime | timestamp with time zone |=20 closeddatetime | timestamp with time zone |=20 reopeneddatetime | timestamp with time zone |=20 openedby | text |=20 callstatus | character(1) |=20 callpriority | text |=20 callreasontext | text |=20 keyword1 | text |=20 keyword2 | text |=20 callername | text |=20 custfirstname | text |=20 custlastname | text |=20 custssntin | character(9) | custssnseq | text |=20 custdbccode | character(9) |=20 custlongname | text |=20 custtypecode | character(2) |=20 custphone | text |=20 custid | character(9) |=20 assigneduserid | character varying(30) |=20 historyitemcount | integer |=20 callertype | text |=20 callerphoneext | text |=20 followupdate | text |=20 hpjobnumber | character(11) |=20 Indexes: call_idx1 unique btree (aspid, callkey), call_aspid btree (aspid), call_aspid_opendedatetime btree (aspid, openeddatetime), call_idx10 btree (aspid, keyword1, openeddatetime, callstatus, calltype , custtypecode, custid, callkey), call_idx11 btree (aspid, keyword2, openeddatetime, callstatus, calltype , custtypecode, custid, callkey), call_idx12 btree (aspid, custtypecode, custid, openeddatetime, callstat us, calltype, callkey), call_idx13 btree (aspid, openeddatetime, callstatus, calltype, callkey), call_idx14 btree (aspid, callqueueid, callstatus, callkey), call_idx2 btree (aspid, callqueueid, openeddatetime, custtypecode, call status, callkey), call_idx3 btree (aspid, assigneduserid, openeddatetime, custtypecode, c allstatus, callkey), call_idx4 btree (aspid, custid, custtypecode, callkey, callstatus), call_idx7 btree (aspid, calltype, custtypecode, custid, callstatus, cal lkey), call_idx9 btree (aspid, assigneduserid, callstatus, followupdate), foo btree (openeddatetime, callstatus, calltype, callkey) TIA, -Joel -- CONFIDENTIALITY NOTICE -- This message is intended for the sole use of the individual and entity to w= hom it is addressed, and may contain information that is privileged, confid= ential and exempt from disclosure under applicable law. If you are not the = intended addressee, nor authorized to receive for the intended addressee, y= ou are hereby notified that you may not use, copy, disclose or distribute t= o anyone the message or any information contained in the message. If you ha= ve received this message in error, please immediately advise the sender by = reply email, and delete the message. Thank you. From pgsql-performance-owner@postgresql.org Thu Jul 8 13:16:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A227D1B195 for ; Wed, 7 Jul 2004 18:44:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55971-10 for ; Wed, 7 Jul 2004 21:44:27 +0000 (GMT) Received: from mail.sinectis.com.ar (odin.sinectis.com.ar [216.244.192.158]) by svr1.postgresql.org (Postfix) with ESMTP id 1D309D1B18F for ; Wed, 7 Jul 2004 18:44:22 -0300 (ADT) Received: from spinalweb (mail.dtnet.com.ar [200.0.213.22]) (authenticated for gbarosio@sinectis.com.ar) by mail.sinectis.com.ar with ESMTP id i67Li7s23600; Wed, 7 Jul 2004 18:44:08 -0300 X-Originally_To: Date: Wed, 7 Jul 2004 18:45:42 -0300 From: Guido Barosio To: Joel McGraw Cc: pgsql-performance@postgresql.org Subject: Re: query plan wierdness? Message-Id: <20040707184542.515a73f5.gbarosio@sinectis.com.ar> In-Reply-To: <7B3E33EF2A10A84185E3667F6B9A1B781A0679@ECIEXCHANGE.eldocomp.com> References: <7B3E33EF2A10A84185E3667F6B9A1B781A0679@ECIEXCHANGE.eldocomp.com> Organization: SpinalWeb X-Mailer: Sylpheed version 0.8.2 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/36 X-Sequence-Number: 7427 The limit is tricking you. I guess a sequential scan is cheaper than an index scan with the limit 26 found there. I am wrong? Greets -- ------------------------------------------- Guido Barosio Buenos Aires, Argentina ------------------------------------------- From pgsql-performance-owner@postgresql.org Wed Jul 7 19:12:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 24544D1B23E for ; Wed, 7 Jul 2004 19:12:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69151-10 for ; Wed, 7 Jul 2004 22:12:35 +0000 (GMT) Received: from ecintweb.eldocomp.com (smtp.eldocomp.com [205.159.99.8]) by svr1.postgresql.org (Postfix) with ESMTP id CDD8ED1B1BE for ; Wed, 7 Jul 2004 19:12:28 -0300 (ADT) Received: by ecintweb.eldocomp.com with XWall v3.29f ; Wed, 7 Jul 2004 15:12:30 -0700 From: Joel McGraw To: Guido Barosio Cc: "pgsql-performance@postgresql.org" Subject: Re: query plan wierdness? Date: Wed, 7 Jul 2004 15:12:29 -0700 X-Assembled-By: XWall v3.29f Message-ID: <7B3E33EF2A10A84185E3667F6B9A1B7825EE21@ECIEXCHANGE.eldocomp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=EXCUSE_16, LINES_OF_YELLING X-Spam-Level: X-Archive-Number: 200407/30 X-Sequence-Number: 7421 Well, you're kind of right. I removed the limit, and now _both_ versions of the query perform a sequence scan! Oh, I forgot to include in my original post: this is PostgreSQL 7.3.4 (on x86 Linux and sparc Solaris 6) -Joel -----Original Message----- From: Guido Barosio [mailto:gbarosio@sinectis.com.ar]=20 Sent: Wednesday, July 07, 2004 2:46 PM To: Joel McGraw Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] query plan wierdness? The limit is tricking you. I guess a sequential scan is cheaper than an index scan with the limit 26 found there. I am wrong? Greets --=20 ------------------------------------------- Guido Barosio Buenos Aires, Argentina ------------------------------------------- -- CONFIDENTIALITY NOTICE -- This message is intended for the sole use of the individual and entity to w= hom it is addressed, and may contain information that is privileged, confid= ential and exempt from disclosure under applicable law. If you are not the = intended addressee, nor authorized to receive for the intended addressee, y= ou are hereby notified that you may not use, copy, disclose or distribute t= o anyone the message or any information contained in the message. If you ha= ve received this message in error, please immediately advise the sender by = reply email, and delete the message. Thank you. From pgsql-performance-owner@postgresql.org Wed Jul 7 19:50:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F2BCD1B20D for ; Wed, 7 Jul 2004 19:50:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85909-10 for ; Wed, 7 Jul 2004 22:50:36 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id ED521D1B23F for ; Wed, 7 Jul 2004 19:50:31 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 96EF4358D8; Wed, 7 Jul 2004 15:50:31 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 95669358D2; Wed, 7 Jul 2004 15:50:31 -0700 (PDT) Date: Wed, 7 Jul 2004 15:50:31 -0700 (PDT) From: Stephan Szabo To: Joel McGraw Cc: "pgsql-performance@postgresql.org" Subject: Re: query plan wierdness? In-Reply-To: <7B3E33EF2A10A84185E3667F6B9A1B781A0679@ECIEXCHANGE.eldocomp.com> Message-ID: <20040707154849.J63760@megazone.bigpanda.com> References: <7B3E33EF2A10A84185E3667F6B9A1B781A0679@ECIEXCHANGE.eldocomp.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/31 X-Sequence-Number: 7422 On Wed, 7 Jul 2004, Joel McGraw wrote: > However, this query performs a sequence scan on the table, ignoring the > call_idx13 index (the only difference is the addition of the aspid field > in the order by clause): > > elon2=# explain analyse select * from call where aspid='123C' and > OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 > 23:59:59.999' order by aspid, openeddatetime desc, callstatus desc, > calltype desc, callkey desc limit 26; > > QUERY PLAN > > ------------------------------------------------------------------------ > ------------------------------------------------------------------------ > ------------------------------------------------------------ > Limit (cost=349379.41..349379.48 rows=26 width=297) (actual > time=32943.52..32943.61 rows=26 loops=1) > -> Sort (cost=349379.41..350558.87 rows=471781 width=297) (actual > time=32943.52..32943.56 rows=27 loops=1) > Sort Key: aspid, openeddatetime, callstatus, calltype, callkey > -> Seq Scan on call (cost=0.00..31019.36 rows=471781 > width=297) (actual time=1.81..7318.13 rows=461973 loops=1) > Filter: ((aspid = '123C'::bpchar) AND (openeddatetime >= > '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime > <= '2004-06-24 23:59:59.999-07'::timestamp with time zone)) > Total runtime: 39353.86 msec > (6 rows) Hmm, what does it say after a set enable_seqscan=off? Also, what does it say if you use aspid desc rather than just aspid in the order by? From pgsql-performance-owner@postgresql.org Thu Jul 8 06:02:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 47AC1D1B1B7 for ; Thu, 8 Jul 2004 06:02:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14100-07 for ; Thu, 8 Jul 2004 09:02:48 +0000 (GMT) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 35725D1B1B3 for ; Thu, 8 Jul 2004 06:02:45 -0300 (ADT) Received: from gateway.pspl.co.in ([203.199.147.2]:3133 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.34 #0) id 1BiUnn-000LQD-8b by authid with plain; Thu, 08 Jul 2004 14:32:47 +0530 Message-ID: <40ED0DB3.3080209@frodo.hserus.net> Date: Thu, 08 Jul 2004 14:32:43 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Missner, T. R." Cc: pgsql-performance@postgresql.org Subject: Re: inserting into brand new database faster than old database References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/32 X-Sequence-Number: 7423 Missner, T. R. wrote: > Hello, > > I have been a happy postgresql developer for a few years now. Recently > I have discovered a very strange phenomenon in regards to inserting > rows. > > My app inserts millions of records a day, averaging about 30 rows a > second. I use autovac to make sure my stats and indexes are up to date. > Rarely are rows ever deleted. Each day a brand new set of tables is > created and eventually the old tables are dropped. The app calls > functions which based on some simple logic perform the correct inserts. Have you profiled where the time goes in a brand new schema and a degraded database? Is it IO? Is it CPU? Is the function making decision becoming bottleneck? > The problem I am seeing is that after a particular database gets kinda > old, say a couple of months, performance begins to degrade. Even after > creating brand new tables my insert speed is slow in comparison ( by a > magnitude of 5 or more ) with a brand new schema which has the exact > same tables. I am running on an IBM 360 dual processor Linux server > with a 100 gig raid array spanning 5 scsi disks. The machine has 1 gig > of ram of which 500 meg is dedicated to Postgresql. > > Just to be clear, the question I have is why would a brand new db schema > allow inserts faster than an older schema with brand new tables? Since > the tables are empty to start, vacuuming should not be an issue at all. > Each schema is identical in every way except the db name and creation > date. You can do few things. - Get explain analyze. See the difference between actual and projected timings. The difference is the hint about where planner is going wrong. - Is IO your bottleneck? Are vacuum taking longer and longer? If yes then you could try the vacuum delay patch. If your IO is saturated for any reason, everything is going to crawl - Are your indexes bloat free? If you are using pre7.x,vacuum does not clean up indexes. You need to reindex. - Have you vacuumed the complete database? If the catalogs collect dead space it could cause degradation too but that is just a guess. Basically monitor slow inserts and try to find out where time is spent. HTH Shridhar From pgsql-performance-owner@postgresql.org Thu Jul 8 06:07:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 53C11D1B19F for ; Thu, 8 Jul 2004 06:07:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17270-10 for ; Thu, 8 Jul 2004 09:07:41 +0000 (GMT) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 71E28D1B18F for ; Thu, 8 Jul 2004 06:07:39 -0300 (ADT) Received: from gateway.pspl.co.in ([203.199.147.2]:3144 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.34 #0) id 1BiUsW-000LRj-Ny by authid with plain; Thu, 08 Jul 2004 14:37:41 +0530 Message-ID: <40ED0ED9.9000106@frodo.hserus.net> Date: Thu, 08 Jul 2004 14:37:37 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bill Chandler Cc: pgsql-performance@postgresql.org Subject: Re: Terrible performance after deleting/recreating indexes References: <20040707161640.48270.qmail@web51408.mail.yahoo.com> In-Reply-To: <20040707161640.48270.qmail@web51408.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/33 X-Sequence-Number: 7424 Bill Chandler wrote: > Hi, > > Using PostgreSQL 7.4.2 on Solaris. I'm trying to > improve performance on some queries to my databases so > I wanted to try out various index structures. > > Since I'm going to be running my performance tests > repeatedly, I created some SQL scripts to delete and > recreate various index configurations. One of the > scripts contains the commands for recreating the > 'original' index configuration (i.e. the one I've > already got some numbers for). Only thing is now > when I delete and recreate the original indexes then > run the query, I'm finding the performance has gone > completely down the tubes compared to what I > originally had. A query that used to take 5 minutes > to complete now takes hours to complete. > > For what it's worth my query looks something like: > > select * from tbl_1, tbl_2 where tbl_1.id = tbl_2.id > and tbl_2.name like 'x%y%' and tbl_1.x > 1234567890123 > order by tbl_1.x; > > tbl_1 is very big (> 2 million rows) > tbl_2 is relatively small (7000 or so rows) > tbl_1.x is a numeric(13) > tbl_1.id & tbl_2.id are integers > tbl_2.name is a varchar(64) > > I've run 'VACUUM ANALYZE' on both tables involved in > the query. I also used 'EXPLAIN' and observed that > the query plan is completely changed from what it > was originally. Get an explain analyze. That gives actual v/s planned time spent. See what is causing the difference. A discrepency between planned and actual row is usually a indication of out-of-date stats. Which are the indexes on these tables? You should list fields with indexes first in where clause. Also list most selective field first so that it eliminates as many rows as possible in first scan. I hope you have read the tuning articles on varlena.com and applied some basic tuning. And post the table schema, hardware config, postgresql config(important ones of course) and explain analyze for queries. That would be something to start with. Shridhar From pgsql-performance-owner@postgresql.org Thu Jul 8 07:19:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 42F58D1B18C for ; Thu, 8 Jul 2004 07:19:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55697-05 for ; Thu, 8 Jul 2004 10:19:18 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 208C3D1B18F for ; Thu, 8 Jul 2004 07:19:14 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1BiVzl-00048T-00 for ; Thu, 08 Jul 2004 12:19:13 +0200 Date: Thu, 8 Jul 2004 12:19:13 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Odd sorting behaviour Message-ID: <20040708101913.GA15871@uio.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/34 X-Sequence-Number: 7425 [Apologies if this reaches the list twice -- I sent a copy before subscribing, but it seems to be stuck waiting for listmaster forever, so I subscribed and sent it again.] Hi, I'm trying to find out why one of my queries is so slow -- I'm primarily using PostgreSQL 7.2 (Debian stable), but I don't really get much better performance with 7.4 (Debian unstable). My prototype table looks like this: CREATE TABLE opinions ( prodid INTEGER NOT NULL, uid INTEGER NOT NULL, opinion INTEGER NOT NULL, PRIMARY KEY ( prodid, uid ) ); In addition, there are separate indexes on prodid and uid. I've run VACUUM ANALYZE before all queries, and they are repeatable. (If anybody needs the data, that could be arranged -- it's not secret or anything :-) ) My query looks like this: EXPLAIN ANALYZE SELECT o3.prodid, SUM(o3.opinion*o12.correlation) AS total_correlation FROM opinions o3 RIGHT JOIN ( SELECT o2.uid, SUM(o1.opinion*o2.opinion)/SQRT(count(*)+0.0) AS correlation FROM opinions o1 LEFT JOIN opinions o2 ON o1.prodid=o2.prodid WHERE o1.uid=1355 GROUP BY o2.uid ) o12 ON o3.uid=o12.uid LEFT JOIN ( SELECT o4.prodid, COUNT(*) as num_my_comments FROM opinions o4 WHERE o4.uid=1355 GROUP BY o4.prodid ) nmc ON o3.prodid=nmc.prodid WHERE nmc.num_my_comments IS NULL AND o3.opinion<>0 AND o12.correlation<>0 GROUP BY o3.prodid ORDER BY total_correlation desc; And produces the query plan at http://www.samfundet.no/~sesse/queryplan.txt (The lines were a bit too long to include in an e-mail :-) ) Note that the "o3.opinion<>0 AND o12.correleation<>0" lines are an optimization; I can run the query fine without them and it will produce the same results, but it goes slower both in 7.2 and 7.4. There are a few oddities here: - The "subquery scan o12" phase outputs 1186 rows, yet 83792 are sorted. Where do the other ~82000 rows come from? And why would it take ~100ms to sort the rows at all? (In earlier tests, this was _one full second_ but somehow that seems to have improved, yet without really improving the overall query time. shared_buffers is 4096 and sort_mem is 16384, so it should really fit into RAM.) - Why does it use uid_index for an index scan on the table, when it obviously has no filter on it (since it returns all the rows)? Furthermore, why would this take half a second? (The machine is a 950MHz machine with SCSI disks.) - Also, the outer sort (the sorting of the 58792 rows from the merge join) is slow. :-) 7.4 isn't really much better: http://www.samfundet.no/~sesse/queryplan74.txt Note that this is run on a machine with almost twice the speed (in terms of CPU speed, at least). The same oddities are mostly present (such as o12 returning 1186 rows, but 58788 rows are sorted), so I really don't understand what's going on here. Any ideas on how to improve this? /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Thu Jul 8 13:51:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 67EA6D1B1AA for ; Thu, 8 Jul 2004 13:50:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62126-06 for ; Thu, 8 Jul 2004 16:50:24 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 31664D1B258 for ; Thu, 8 Jul 2004 13:50:22 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id 43AD276B48; Thu, 8 Jul 2004 12:50:25 -0400 (EDT) Subject: Re: query plan wierdness? From: Rod Taylor To: Joel McGraw Cc: "pgsql-performance@postgresql.org" In-Reply-To: <7B3E33EF2A10A84185E3667F6B9A1B781A0679@ECIEXCHANGE.eldocomp.com> References: <7B3E33EF2A10A84185E3667F6B9A1B781A0679@ECIEXCHANGE.eldocomp.com> Content-Type: text/plain Message-Id: <1089305420.5999.208.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 08 Jul 2004 12:50:21 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/37 X-Sequence-Number: 7428 > However, this query performs a sequence scan on the table, ignoring the > call_idx13 index (the only difference is the addition of the aspid field > in the order by clause): You do not have an index which matches the ORDER BY, so PostgreSQL cannot simply scan the index for the data you want. Thus is needs to find all matching rows, order them, etc. > 23:59:59.999' order by aspid, openeddatetime desc, callstatus desc, > calltype desc, callkey desc limit 26; aspid ASC, openeddatetime DESC, callstatus DESC, calltype DESC > call_idx13 btree (aspid, openeddatetime, callstatus, calltype, > callkey), This index is: aspid ASC, openeddatetime ASC, callstatus ASC, calltype ASC, callkey ASC A reverse scan, would of course be DESC, DESC, DESC, DESC, DESC -- neither of which matches your requested order by, thus cannot help the reduce the lines looked at to 26. This leaves your WHERE clause to restrict the dataset and it doesn't do a very good job of it. There are more than 450000 rows matching the where clause, which means the sequential scan was probably the right choice (unless you have over 10 million entries in the table). Since your WHERE clause contains a single aspid, an improvement to the PostgreSQL optimizer may be to ignore that field in the ORDER BY as order is no longer important since there is only one possible value. If it did ignore aspid, it would use a plan similar to the first one you provided. You can accomplish the same thing by leaving out aspid ASC OR by setting it to aspid DESC in the ORDER BY. Leaving it out entirely will be slightly faster, but DESC will cause PostgreSQL to use index "call_idx13". From pgsql-performance-owner@postgresql.org Thu Jul 8 15:03:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 68DE6D1B267 for ; Thu, 8 Jul 2004 15:03:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05136-05 for ; Thu, 8 Jul 2004 18:03:45 +0000 (GMT) Received: from web13121.mail.yahoo.com (web13121.mail.yahoo.com [216.136.174.83]) by svr1.postgresql.org (Postfix) with SMTP id 0E2D7D1B260 for ; Thu, 8 Jul 2004 15:03:43 -0300 (ADT) Message-ID: <20040708180343.88032.qmail@web13121.mail.yahoo.com> Received: from [63.78.248.48] by web13121.mail.yahoo.com via HTTP; Thu, 08 Jul 2004 11:03:43 PDT Date: Thu, 8 Jul 2004 11:03:43 -0700 (PDT) From: Litao Wu Subject: vacuum_mem To: "pgsql-performance@postgresql.org" Cc: "pgsql-performance@postgresql.org" In-Reply-To: <1089305420.5999.208.camel@jester> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HOT_NASTY, TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200407/38 X-Sequence-Number: 7429 Hi, I tested vacuum_mem setting under a 4CPU and 4G RAM machine. I am the only person on that machine. The table: tablename | size_kb | reltuples ---------------------------+------------------------- big_t | 2048392 | 7.51515e+06 Case 1: 1. vacuum full big_t; 2. begin; update big_t set email = lpad('a', 255, 'b'); rollback; 3. set vacuum_mem=655360; -- 640M 4. vacuum big_t; It takes 1415,375 ms Also from top, the max SIZE is 615M while SHARE is always 566M PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 5914 postgres 16 0 615M 615M 566M D 7.5 15.8 21:21 postgres: postgres mydb xxx.xxx.xxx.xxx:34361 VACUUM Case 2: 1. vacuum full big_t; 2. begin; update big_t set email = lpad('a', 255, 'b'); rollback; 3. set vacuum_mem=65536; -- 64M 4. vacuum big_t; It takes 1297,798 ms Also from top, the max SIZE is 615M while SHARE is always 566M PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 3613 postgres 15 0 615M 615M 566M D 17.1 15.8 9:04 postgres: postgres mydb xxx.xxx.xxx.xxx:34365 VACUUM It seems vacuum_mem does not have performance effect at all. In reality, we vaccum nightly and I want to find out which vacuum_mem value is the best to short vacuum time. Any thoughts? Thanks, __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail From pgsql-performance-owner@postgresql.org Thu Jul 8 21:31:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 78978D1B275 for ; Thu, 8 Jul 2004 15:06:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06578-05 for ; Thu, 8 Jul 2004 18:06:11 +0000 (GMT) Received: from smtp-out6.blueyonder.co.uk (smtp-out6.blueyonder.co.uk [195.188.213.9]) by svr1.postgresql.org (Postfix) with ESMTP id 95978D1B181 for ; Thu, 8 Jul 2004 15:06:08 -0300 (ADT) Received: from lappy ([82.43.186.55]) by smtp-out6.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.5600); Thu, 8 Jul 2004 19:06:24 +0100 Message-ID: <00ac01c46516$3ec859e0$0300a8c0@lappy> From: "Andy Ballingall" To: References: <20040708101913.GA15871@uio.no> Subject: Working on huge RAM based datasets Date: Thu, 8 Jul 2004 19:05:06 +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.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-OriginalArrivalTime: 08 Jul 2004 18:06:24.0766 (UTC) FILETIME=[482AB1E0:01C46516] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/42 X-Sequence-Number: 7433 Hi, I'm really stuck and I wonder if any of you could help. I have an application which will be sitting on a quite large database (roughly 8-16GB). The nature of the application is such that, on a second by second basis, the working set of the database is likely to be a substantial portion (e.g. between 50 and 70%) of the data - Just imagine an almost stochastic sampling of the data in each table, and you'll get an idea. Potentially quite smelly. To start with, I thought. No problems. Just configure a DB server with an obscene amount of RAM (e.g. 64GB), and configure PG with a shared buffer cache that is big enough to hold every page of data in the database, plus 10% or whatever to allow for a bit of room, ensuring that there is enough RAM in the box so that all the backend processes can do their thing, and all the other services can do their thing, and the swap system on the host remains idle. Apparently not :( I've read a number of places now saying that the PG cache has an optimal size which isn't "as big as you can make it without affecting other stuff on the machine". The suggestion is to let linux take the strain for the lion's share of the caching (using its buffer cache), and just make the PG cache big enough to hold the data it needs for individual queries. ___ Ignoring for a moment the problem of answering the question 'so how big shall I make the PG cache?', and ignoring the possibility that as the database content changes over the months this answer will need updating from time to time for optimal performance, does anyone have any actual experience with trying to maintain a large, mainly RAM resident database? What is it about the buffer cache that makes it so unhappy being able to hold everything? I don't want to be seen as a cache hit fascist, but isn't it just better if the data is just *there*, available in the postmaster's address space ready for each backend process to access it, rather than expecting the Linux cache mechanism, optimised as it may be, to have to do the caching? Is it that the PG cache entries are accessed through a 'not particularly optimal for large numbers of tuples' type of strategy? (Optimal though it might be for more modest numbers). And on a more general note, with the advent of 64 bit addressing and rising RAM sizes, won't there, with time, be more and more DB applications that would want to capitalise on the potential speed improvements that come with not having to work hard to get the right bits in the right bit of memory all the time? And finally, am I worrying too much, and actually this problem is common to all databases? Thanks for reading, Andy From pgsql-performance-owner@postgresql.org Thu Jul 8 15:26:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 29842D1B21B for ; Thu, 8 Jul 2004 15:25:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15880-05 for ; Thu, 8 Jul 2004 18:25:54 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id DF8E9D1B20E for ; Thu, 8 Jul 2004 15:25:52 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id 1DFEE76B65; Thu, 8 Jul 2004 14:25:33 -0400 (EDT) Subject: Re: vacuum_mem From: Rod Taylor To: Litao Wu Cc: "pgsql-performance@postgresql.org" In-Reply-To: <20040708180343.88032.qmail@web13121.mail.yahoo.com> References: <20040708180343.88032.qmail@web13121.mail.yahoo.com> Content-Type: text/plain Message-Id: <1089311129.5999.219.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 08 Jul 2004 14:25:30 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/39 X-Sequence-Number: 7430 > It seems vacuum_mem does not have performance > effect at all. Wrong conclusion. It implies that your test case takes less than 64M of memory to track your removed tuples. I think it takes 8 bytes to track a tuple for vacuuming an index, which means it should be able to track 800000 deletions. Since you're demonstration had 750000 for removal, it's under the limit. Try your test again with 32MB; it should make a single sequential pass on the table, and 2 passes on each index for that table. Either that, or do a few more aborted updates. From pgsql-performance-owner@postgresql.org Thu Jul 8 17:49:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E31CD1B21B for ; Thu, 8 Jul 2004 17:49:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86018-02 for ; Thu, 8 Jul 2004 20:49:25 +0000 (GMT) Received: from web51407.mail.yahoo.com (web51407.mail.yahoo.com [206.190.38.186]) by svr1.postgresql.org (Postfix) with SMTP id 0BB25D1B1AB for ; Thu, 8 Jul 2004 17:49:20 -0300 (ADT) Message-ID: <20040708204921.4921.qmail@web51407.mail.yahoo.com> Received: from [192.88.67.254] by web51407.mail.yahoo.com via HTTP; Thu, 08 Jul 2004 13:49:21 PDT Date: Thu, 8 Jul 2004 13:49:21 -0700 (PDT) From: Bill Chandler Subject: Re: Terrible performance after deleting/recreating indexes To: pgsql-performance@postgresql.org In-Reply-To: <40ED0ED9.9000106@frodo.hserus.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200407/40 X-Sequence-Number: 7431 Thanks for the advice. On further review it appears I am only getting this performance degradation when I run the command via a JDBC app. If I do the exact same query from psql, the performance is fine. I've tried both the JDBC2 and JDBC3 jars. Same results. It definitely seems to correspond to deleting and recreating the indexes, though. The same query thru JDBC worked fine before recreating the indexes. Does that make any sense at all? thanks Bill --- Shridhar Daithankar wrote: > Bill Chandler wrote: > > > Hi, > > > > Using PostgreSQL 7.4.2 on Solaris. I'm trying to > > improve performance on some queries to my > databases so > > I wanted to try out various index structures. > > > > Since I'm going to be running my performance tests > > repeatedly, I created some SQL scripts to delete > and > > recreate various index configurations. One of the > > scripts contains the commands for recreating the > > 'original' index configuration (i.e. the one I've > > already got some numbers for). Only thing is now > > when I delete and recreate the original indexes > then > > run the query, I'm finding the performance has > gone > > completely down the tubes compared to what I > > originally had. A query that used to take 5 > minutes > > to complete now takes hours to complete. > > > > For what it's worth my query looks something like: > > > > select * from tbl_1, tbl_2 where tbl_1.id = > tbl_2.id > > and tbl_2.name like 'x%y%' and tbl_1.x > > 1234567890123 > > order by tbl_1.x; > > > > tbl_1 is very big (> 2 million rows) > > tbl_2 is relatively small (7000 or so rows) > > tbl_1.x is a numeric(13) > > tbl_1.id & tbl_2.id are integers > > tbl_2.name is a varchar(64) > > > > I've run 'VACUUM ANALYZE' on both tables involved > in > > the query. I also used 'EXPLAIN' and observed > that > > the query plan is completely changed from what it > > was originally. > > Get an explain analyze. That gives actual v/s > planned time spent. See what is > causing the difference. A discrepency between > planned and actual row is usually > a indication of out-of-date stats. > > > Which are the indexes on these tables? You should > list fields with indexes first > in where clause. Also list most selective field > first so that it eliminates as > many rows as possible in first scan. > > > I hope you have read the tuning articles on > varlena.com and applied some basic > tuning. > > And post the table schema, hardware config, > postgresql config(important ones of > course) and explain analyze for queries. That would > be something to start with. > > Shridhar > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: you can get off all lists at once with the > unregister command > (send "unregister YourEmailAddressHere" to > majordomo@postgresql.org) > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail From pgsql-performance-owner@postgresql.org Thu Jul 8 21:13:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7BD15D1B20D for ; Thu, 8 Jul 2004 21:13:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72711-08 for ; Fri, 9 Jul 2004 00:13:15 +0000 (GMT) Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) by svr1.postgresql.org (Postfix) with ESMTP id 26AF5D1B1A5 for ; Thu, 8 Jul 2004 21:13:11 -0300 (ADT) Received: from smtp-2.paradise.net.nz (smtp-2b.paradise.net.nz [202.0.32.211]) by linda-2.paradise.net.nz (Paradise.net.nz) with ESMTP id <0I0K00MN05Y0W1@linda-2.paradise.net.nz> for pgsql-performance@postgresql.org; Fri, 09 Jul 2004 12:13:13 +1200 (NZST) Received: from coretech.co.nz (218-101-13-113.paradise.net.nz [218.101.13.113]) by smtp-2.paradise.net.nz (Postfix) with ESMTP id 24C9D9E81C; Fri, 09 Jul 2004 12:12:13 +1200 (NZST) Date: Fri, 09 Jul 2004 12:14:32 +1200 From: Mark Kirkwood Subject: Re: Terrible performance after deleting/recreating indexes In-reply-to: <20040708204921.4921.qmail@web51407.mail.yahoo.com> To: Bill Chandler Cc: pgsql-performance@postgresql.org Message-id: <40EDE368.90603@coretech.co.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040429 References: <20040708204921.4921.qmail@web51407.mail.yahoo.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/41 X-Sequence-Number: 7432 That is interesting - both psql and JDBC merely submit statements for the backend to process, so generally you would expect no difference in execution plan or performance. It might be worth setting "log_statement=true" in postgresql.conf and checking that you are executing *exactly* the same statement in both JDBC and psql. regards Mark P.s : lets see the output from EXPLAIN ANALYZE :-) Bill Chandler wrote: >Thanks for the advice. > >On further review it appears I am only getting this >performance degradation when I run the command via >a JDBC app. If I do the exact same query from >psql, the performance is fine. I've tried both the >JDBC2 and JDBC3 jars. Same results. > > > > > > > From pgsql-performance-owner@postgresql.org Thu Jul 8 22:35:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0F85BD1B1D5 for ; Thu, 8 Jul 2004 22:35:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06127-02 for ; Fri, 9 Jul 2004 01:35:28 +0000 (GMT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 01293D1B195 for ; Thu, 8 Jul 2004 22:35:22 -0300 (ADT) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i691UAbP074481; Fri, 9 Jul 2004 09:30:10 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <40EDF7DE.8080900@familyhealth.com.au> Date: Fri, 09 Jul 2004 09:41:50 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andy Ballingall Cc: pgsql-performance@postgresql.org Subject: Re: Working on huge RAM based datasets References: <20040708101913.GA15871@uio.no> <00ac01c46516$3ec859e0$0300a8c0@lappy> In-Reply-To: <00ac01c46516$3ec859e0$0300a8c0@lappy> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/43 X-Sequence-Number: 7434 > What is it about the buffer cache that makes it so unhappy being able to > hold everything? I don't want to be seen as a cache hit fascist, but isn't > it just better if the data is just *there*, available in the postmaster's > address space ready for each backend process to access it, rather than > expecting the Linux cache mechanism, optimised as it may be, to have to do > the caching? Because the PostgreSQL buffer management algorithms are pitiful compared to Linux's. In 7.5, it's improved with the new ARC algorithm, but still - the Linux disk buffer cache will be very fast. Chris From pgsql-performance-owner@postgresql.org Fri Jul 9 18:17:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9DD01D1B233 for ; Fri, 9 Jul 2004 06:28:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84980-02 for ; Fri, 9 Jul 2004 09:28:25 +0000 (GMT) Received: from smtp-out4.blueyonder.co.uk (smtp-out4.blueyonder.co.uk [195.188.213.7]) by svr1.postgresql.org (Postfix) with ESMTP id C579CD1B1F8 for ; Fri, 9 Jul 2004 06:28:21 -0300 (ADT) Received: from lappy ([82.43.186.55]) by smtp-out4.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.5600); Fri, 9 Jul 2004 10:28:39 +0100 Message-ID: <011301c46597$15d145c0$0300a8c0@lappy> From: "Andy Ballingall" To: "Christopher Kings-Lynne" Cc: References: <20040708101913.GA15871@uio.no> <00ac01c46516$3ec859e0$0300a8c0@lappy> <40EDF7DE.8080900@familyhealth.com.au> Subject: Re: Working on huge RAM based datasets Date: Fri, 9 Jul 2004 10:28:24 +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.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-OriginalArrivalTime: 09 Jul 2004 09:28:39.0884 (UTC) FILETIME=[1E77A0C0:01C46597] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/52 X-Sequence-Number: 7443 Thanks, Chris. > > What is it about the buffer cache that makes it so unhappy being able to > > hold everything? I don't want to be seen as a cache hit fascist, but isn't > > it just better if the data is just *there*, available in the postmaster's > > address space ready for each backend process to access it, rather than > > expecting the Linux cache mechanism, optimised as it may be, to have to do > > the caching? > > Because the PostgreSQL buffer management algorithms are pitiful compared > to Linux's. In 7.5, it's improved with the new ARC algorithm, but still > - the Linux disk buffer cache will be very fast. > I've had that reply elsewhere too. Initially, I was afraid that there was a memory copy involved if the OS buffer cache supplied a block of data to PG, but I've learned a lot more about the linux buffer cache, so it now makes more sense to me why it's not a terrible thing to let the OS manage the lions' share of the caching on a high RAM system. On another thread, (not in this mailing list), someone mentioned that there are a class of databases which, rather than caching bits of database file (be it in the OS buffer cache or the postmaster workspace), construct a a well indexed memory representation of the entire data in the postmaster workspace (or its equivalent), and this, remaining persistent, allows the DB to service backend queries far quicker than if the postmaster was working with the assumption that most of the data was on disk (even if, in practice, large amounts or perhaps even all of it resides in OS cache). Though I'm no stranger to data management in general, I'm still in a steep learning curve for databases in general and PG in particular, but I just wondered how big a subject this is in the development group for PG at the moment? After all, we're now seeing the first wave of 'reasonably priced' 64 bit servers supported by a proper 64 bit OS (e.g. linux). HP are selling a 4 Opteron server which can take 256GB of RAM, and that starts at $10000 (ok - they don't give you that much RAM for that price - not yet, anyway!) This is the future, isn't it? Each year, a higher percentage of DB applications will be able to fit entirely in RAM, and that percentage is going to be quite significant in just a few years. The disk system gets relegated to a data preload on startup and servicing the writes as the server does its stuff. Regards, Andy From pgsql-performance-owner@postgresql.org Fri Jul 9 11:16:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E139D1B29D for ; Fri, 9 Jul 2004 11:16:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06041-09 for ; Fri, 9 Jul 2004 14:16:38 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id D330BD1B233 for ; Fri, 9 Jul 2004 11:16:33 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Working on huge RAM based datasets X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Fri, 9 Jul 2004 10:16:36 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEC2@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Working on huge RAM based datasets Thread-Index: AcRlTOo8eDyLm32AQz+7DrtGGK62eAAcfCRQ From: "Merlin Moncure" To: "Andy Ballingall" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/44 X-Sequence-Number: 7435 > What is it about the buffer cache that makes it so unhappy being able to > hold everything? I don't want to be seen as a cache hit fascist, but isn't > it just better if the data is just *there*, available in the postmaster's > address space ready for each backend process to access it, rather than > expecting the Linux cache mechanism, optimised as it may be, to have to do > the caching? The disk cache on most operating systems is optimized. Plus, keeping shared buffers low gives you more room to bump up the sort memory, which will make your big queries run faster. Merlin From pgsql-performance-owner@postgresql.org Fri Jul 9 12:18:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 08F08D1B2D9 for ; Fri, 9 Jul 2004 12:18:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41069-03 for ; Fri, 9 Jul 2004 15:18:51 +0000 (GMT) Received: from web51410.mail.yahoo.com (web51410.mail.yahoo.com [206.190.38.189]) by svr1.postgresql.org (Postfix) with SMTP id 53B21D1B2A4 for ; Fri, 9 Jul 2004 12:18:49 -0300 (ADT) Message-ID: <20040709151848.89738.qmail@web51410.mail.yahoo.com> Received: from [192.88.67.254] by web51410.mail.yahoo.com via HTTP; Fri, 09 Jul 2004 08:18:48 PDT Date: Fri, 9 Jul 2004 08:18:48 -0700 (PDT) From: Bill Chandler Subject: Re: Terrible performance after deleting/recreating indexes To: pgsql-performance@postgresql.org In-Reply-To: <40EDE368.90603@coretech.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS, LINES_OF_YELLING X-Spam-Level: X-Archive-Number: 200407/45 X-Sequence-Number: 7436 Thanks for this tip. Turns out there is a difference. I am using cursors (i.e. calling setFetchSize(5000) on my Statement) in JDBC. So the SQL statement is preceded by: DECLARE JDBC_CURS_1 CURSOR FOR ... which is then followed by the SQL statemnt. This is followed by the separate statement: FETCH FORWARD 5000 FROM JDBC_CURS_1; Also, don't know if this is significant but there are a few lines before both of these: set datestyle to 'ISO'; select version(), case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end; set client_encoding = 'UNICODE begin; Only thing is, though, none of this is new. I was using cursors before as well. Here is the output from "EXPLAIN ANALYZE". Hope it comes out readable: QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=50466.04..50470.45 rows=1765 width=114) (actual time=87237.003..88235.011 rows=108311 loops=1) Sort Key: iso_nep_data_update_events.lds -> Merge Join (cost=49240.03..50370.85 rows=1765 width=114) (actual time=56658.356..65221.995 rows=108311 loops=1) Merge Cond: ("outer".obj_id = "inner".obj_id) -> Sort (cost=198.01..198.16 rows=61 width=65) (actual time=175.947..181.172 rows=3768 loops=1) Sort Key: iso_nep_control.obj_id -> Seq Scan on iso_nep_control (cost=0.00..196.20 rows=61 width=65) (actual time=0.056..108.151 rows=3768 loops=1) Filter: ((real_name)::text ~~ 'NEPOOL%REAL%'::text) -> Sort (cost=49042.02..49598.46 rows=222573 width=69) (actual time=56482.073..58642.901 rows=216528 loops=1) Sort Key: iso_nep_data_update_events.obj_id -> Index Scan using iso_nep_due_idx1 on iso_nep_data_update_events (cost=0.00..7183.18 rows=222573 width=69) (actual time=0.179..11739.104 rows=216671 loops=1) Index Cond: (lds > 1088554754000::numeric) Total runtime: 88643.330 ms (13 rows) Here is the actual query: select iso_nep_DATA_UPDATE_EVENTS.lds, iso_nep_DATA_UPDATE_EVENTS.tsds, iso_nep_DATA_UPDATE_EVENTS.value, iso_nep_DATA_UPDATE_EVENTS.correction, iso_nep_DATA_UPDATE_EVENTS.delta_lds_tsds, iso_nep_CONTROL.real_name, iso_nep_CONTROL.freq, iso_nep_CONTROL.type from iso_nep_DATA_UPDATE_EVENTS, iso_nep_CONTROL where iso_nep_CONTROL.real_name like 'NEPOOL%REAL%' escape '/' and iso_nep_DATA_UPDATE_EVENTS.obj_id = iso_nep_CONTROL.obj_id and iso_nep_DATA_UPDATE_EVENTS.lds > 1088554754000 order by lds; Two tables: iso_nep_data_update_events and iso_nep_control. Basically getting all columns from both tables. Joining the tables on obj_id = obj_id. Have unique indexes on iso_nep_control.obj_id (clustered) and iso_nep_control.real_name. Have non-unique indexes on iso_nep_data_update_events.lds and iso_nep_data_update_events.obj_id. thanks, Bill --- Mark Kirkwood wrote: > That is interesting - both psql and JDBC merely > submit statements for > the backend to process, so generally you would > expect no difference in > execution plan or performance. > > It might be worth setting "log_statement=true" in > postgresql.conf and > checking that you are executing *exactly* the same > statement in both > JDBC and psql. > > regards > > Mark > > P.s : lets see the output from EXPLAIN ANALYZE :-) > > Bill Chandler wrote: > > >Thanks for the advice. > > > >On further review it appears I am only getting this > > >performance degradation when I run the command via > >a JDBC app. If I do the exact same query from > >psql, the performance is fine. I've tried both the > >JDBC2 and JDBC3 jars. Same results. > > > > > > > > > > > > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail From pgsql-performance-owner@postgresql.org Fri Jul 9 18:17:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C659AD1B1B7 for ; Fri, 9 Jul 2004 13:08:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59906-08 for ; Fri, 9 Jul 2004 16:08:07 +0000 (GMT) Received: from smtp-out2.blueyonder.co.uk (smtp-out2.blueyonder.co.uk [195.188.213.5]) by svr1.postgresql.org (Postfix) with ESMTP id 2DA97D1B1B0 for ; Fri, 9 Jul 2004 13:08:04 -0300 (ADT) Received: from lappy ([82.43.186.55]) by smtp-out2.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Fri, 9 Jul 2004 17:08:21 +0100 Message-ID: <01bf01c465ce$eb4df680$0300a8c0@lappy> From: "Andy Ballingall" To: "Merlin Moncure" Cc: References: <6EE64EF3AB31D5448D0007DD34EEB34101AEC2@Herge.rcsinc.local> Subject: Re: Working on huge RAM based datasets Date: Fri, 9 Jul 2004 17:08:05 +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.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-OriginalArrivalTime: 09 Jul 2004 16:08:21.0093 (UTC) FILETIME=[F461B950:01C465CE] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/51 X-Sequence-Number: 7442 >The disk cache on most operating systems is optimized. Plus, keeping shared buffers low gives you more room to bump up the sort memory, which will make your big queries run faster. Thanks merlin, Whether the OS caches the data or PG does, you still want it cached. If your sorting backends gobble up the pages that otherwise would be filled with the database buffers, then your postmaster will crawl, as it'll *really* have to wait for stuff from disk. In my scenario, you'd spec the machine so that there would be plenty of memory for *everything*. On your OS optimisation point, OS caches are, of course, optimised. But people have told me that PG's caching strategy is simply less well optimised, and *that* is the reason for keeping the shared buffer cache down in my scenario. That's a shame in a way, but I understand why it is the way it is - other things have been addressed which speed up operations in different ways. My 'all in RAM' scenario is very rare at the moment, so why waste valuable development resources on developing optimised RAM based data structures to hold the data for quicker query execution when hardly anyone will see the benefit? However - it won't be so rare for too much longer... If I gave you a half a terabyte of RAM and a 4 processor 64 bit machine, I'm sure you could imagine how much quicker databases could run if they were optimised for this sort of platform. Anyway, I'm looking forward to experimenting with stuff the way it works at the moment. Many thanks, Andy From pgsql-performance-owner@postgresql.org Fri Jul 9 15:15:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CB00CD1B1B7 for ; Fri, 9 Jul 2004 15:15:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22244-04 for ; Fri, 9 Jul 2004 18:15:53 +0000 (GMT) Received: from ecintweb.eldocomp.com (smtp.eldocomp.com [205.159.99.8]) by svr1.postgresql.org (Postfix) with ESMTP id 8E631D1B1B0 for ; Fri, 9 Jul 2004 15:15:50 -0300 (ADT) Received: by ecintweb.eldocomp.com with XWall v3.29f ; Fri, 9 Jul 2004 11:15:50 -0700 From: Joel McGraw To: Rod Taylor Cc: "pgsql-performance@postgresql.org" Subject: Re: query plan wierdness? Date: Fri, 9 Jul 2004 11:15:49 -0700 X-Assembled-By: XWall v3.29f Message-ID: <7B3E33EF2A10A84185E3667F6B9A1B781A0683@ECIEXCHANGE.eldocomp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=EXCUSE_16, LINES_OF_YELLING X-Spam-Level: X-Archive-Number: 200407/46 X-Sequence-Number: 7437 >=20 > > However, this query performs a sequence scan on the table, ignoring the > > call_idx13 index (the only difference is the addition of the aspid field > > in the order by clause): >=20 > You do not have an index which matches the ORDER BY, so PostgreSQL > cannot simply scan the index for the data you want. Thus is needs to > find all matching rows, order them, etc. >=20 > > 23:59:59.999' order by aspid, openeddatetime desc, callstatus desc, > > calltype desc, callkey desc limit 26; >=20 > aspid ASC, openeddatetime DESC, callstatus DESC, calltype DESC >=20 > > call_idx13 btree (aspid, openeddatetime, callstatus, calltype, > > callkey), >=20 > This index is: aspid ASC, openeddatetime ASC, callstatus ASC, calltype > ASC, callkey ASC >=20 OK, that makes sense; however, this doesn't: elon2=3D# explain analyse select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by aspid asc, openeddatetime asc, callstatus asc, calltype asc, callkey asc; =20 QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------------------------------------ Sort (cost=3D342903.52..344071.99 rows=3D467384 width=3D295) (actual time=3D33159.38..33897.22 rows=3D461973 loops=3D1) Sort Key: aspid, openeddatetime, callstatus, calltype, callkey -> Seq Scan on call (cost=3D0.00..31019.36 rows=3D467384 width=3D295) (actual time=3D1.80..7373.75 rows=3D461973 loops=3D1) Filter: ((aspid =3D '123C'::bpchar) AND (openeddatetime >=3D '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime <=3D '2004-06-24 23:59:59.999-07'::timestamp with time zone)) Total runtime: 38043.03 msec (5 rows) I've modified the "order by" to reflect the call_idx13 index, yet the query still causes a sequence scan of the table. > A reverse scan, would of course be DESC, DESC, DESC, DESC, DESC -- > neither of which matches your requested order by, thus cannot help the > reduce the lines looked at to 26. To clarify, the query that the programmer wants is: select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by aspid, openeddatetime desc, callstatus desc, calltype desc, callkey desc; We had started playing with placing limits on the query to address another, unrelated problem. However, out of curiosity I did some testing with varying limits to see at which point the planner decided to do a sequence scan instead of using the index. elon2=3D# explain analyse select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by aspid, openeddatetime , callstatus , calltype , callkey limit 92785; =20 QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 ------------------------------------------------------------------------ ------------------------------------------------------------------------ ---------------------------------------------------------- Limit (cost=3D0.00..343130.36 rows=3D92785 width=3D295) (actual time=3D0.17..1835.55 rows=3D92785 loops=3D1) -> Index Scan using call_idx13 on call (cost=3D0.00..1728444.76 rows=3D467384 width=3D295) (actual time=3D0.17..1699.56 rows=3D92786 loops= =3D1) Index Cond: ((aspid =3D '123C'::bpchar) AND (openeddatetime >=3D '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime <=3D '2004-06-24 23:59:59.999-07'::timestamp with time zone)) Total runtime: 1901.43 msec (4 rows) elon2=3D# explain analyse select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by aspid, openeddatetime , callstatus , calltype , callkey limit 92786; =20 QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 ------------------------------------------------------------------------ ------------------------------------------------------------------------ ---------------------------------------------------------- Limit (cost=3D0.00..343134.06 rows=3D92786 width=3D295) (actual time=3D0.17..1834.09 rows=3D92786 loops=3D1) -> Index Scan using call_idx13 on call (cost=3D0.00..1728444.76 rows=3D467384 width=3D295) (actual time=3D0.17..1698.16 rows=3D92787 loops= =3D1) Index Cond: ((aspid =3D '123C'::bpchar) AND (openeddatetime >=3D '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime <=3D '2004-06-24 23:59:59.999-07'::timestamp with time zone)) Total runtime: 1899.97 msec (4 rows) elon2=3D# select count(*) from call; count -------- 507392 (1 row) =20 >=20 > This leaves your WHERE clause to restrict the dataset and it doesn't do > a very good job of it. There are more than 450000 rows matching the > where clause, which means the sequential scan was probably the right > choice (unless you have over 10 million entries in the table). >=20 >=20 > Since your WHERE clause contains a single aspid, an improvement to the > PostgreSQL optimizer may be to ignore that field in the ORDER BY as > order is no longer important since there is only one possible value. If > it did ignore aspid, it would use a plan similar to the first one you > provided. >=20 > You can accomplish the same thing by leaving out aspid ASC OR by setting > it to aspid DESC in the ORDER BY. Leaving it out entirely will be > slightly faster, but DESC will cause PostgreSQL to use index > "call_idx13". >=20 >=20 Again, that makes sense to me, but if I remove aspid from the query it still ignores the index.... elon2=3D# explain analyse select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by openeddatetime desc, callstatus desc, calltype desc, callkey desc; =20 QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------------------------------------ Sort (cost=3D342903.52..344071.99 rows=3D467384 width=3D295) (actual time=3D17598.31..18304.26 rows=3D461973 loops=3D1) Sort Key: openeddatetime, callstatus, calltype, callkey -> Seq Scan on call (cost=3D0.00..31019.36 rows=3D467384 width=3D295) (actual time=3D1.78..7337.85 rows=3D461973 loops=3D1) Filter: ((aspid =3D '123C'::bpchar) AND (openeddatetime >=3D '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime <=3D '2004-06-24 23:59:59.999-07'::timestamp with time zone)) Total runtime: 21665.43 msec (5 rows) Setting enable_seqscan=3Doff still doesn't cause the desired index to be selected: elon2=3D# explain analyse select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by aspid desc, openeddatetime desc, callstatus desc, calltype desc, callkey desc; =20 QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------- Sort (cost=3D355314.41..356482.87 rows=3D467384 width=3D295) (actual time=3D33382.92..34088.10 rows=3D461973 loops=3D1) Sort Key: aspid, openeddatetime, callstatus, calltype, callkey -> Index Scan using call_aspid on call (cost=3D0.00..43430.25 rows=3D467384 width=3D295) (actual time=3D0.24..7915.21 rows=3D461973 loops= =3D1) Index Cond: (aspid =3D '123C'::bpchar) Filter: ((openeddatetime >=3D '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime <=3D '2004-06-24 23:59:59.999-07'::timestamp with time zone)) Total runtime: 39196.39 msec Thanks for your help (and sorry for the long post), -Joel -- CONFIDENTIALITY NOTICE -- This message is intended for the sole use of the individual and entity to w= hom it is addressed, and may contain information that is privileged, confid= ential and exempt from disclosure under applicable law. If you are not the = intended addressee, nor authorized to receive for the intended addressee, y= ou are hereby notified that you may not use, copy, disclose or distribute t= o anyone the message or any information contained in the message. If you ha= ve received this message in error, please immediately advise the sender by = reply email, and delete the message. Thank you. From pgsql-performance-owner@postgresql.org Fri Jul 9 16:18:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7A385D1B173 for ; Fri, 9 Jul 2004 16:18:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50886-07 for ; Fri, 9 Jul 2004 19:18:54 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 76ED0D1B184 for ; Fri, 9 Jul 2004 16:18:51 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id 75C7E76A30; Fri, 9 Jul 2004 15:18:55 -0400 (EDT) Subject: Re: query plan wierdness? From: Rod Taylor To: Joel McGraw Cc: "pgsql-performance@postgresql.org" In-Reply-To: <7B3E33EF2A10A84185E3667F6B9A1B781A0683@ECIEXCHANGE.eldocomp.com> References: <7B3E33EF2A10A84185E3667F6B9A1B781A0683@ECIEXCHANGE.eldocomp.com> Content-Type: text/plain Message-Id: <1089400730.15774.159.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 09 Jul 2004 15:18:51 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=REMOVE_REMOVAL_NEAR X-Spam-Level: * X-Archive-Number: 200407/47 X-Sequence-Number: 7438 > OK, that makes sense; however, this doesn't: > > elon2=# explain analyse select * from call where aspid='123C' and > OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 > 23:59:59.999' order by aspid asc, openeddatetime asc, callstatus asc, > calltype asc, callkey asc; > I've modified the "order by" to reflect the call_idx13 index, yet the > query still causes a sequence scan of the table. This query shown above does not have a limit where the original one had LIMIT 26. PostgreSQL has determined that pulling out all the table rows, and sorting them in CPU is cheaper than pulling out all index rows, then randomly pulling out all table rows. Normally, that would be well on the mark. You can sort a large number of tuples for a single random disk seek, but this is not true for you. Considering you're pulling out 450k rows in 8 seconds, I'd also guess the data is mostly in memory. Is that normal? Or is this a result of having run several test queries against the same data multiple times? If it's normal, bump your effective_cache parameter higher to move the sort vs. scan threshold. > Again, that makes sense to me, but if I remove aspid from the query it > still ignores the index.... You've changed 2 variables. You removed the aspid AND removed the LIMIT. Add back the limit of 26 like you originally showed, and it'll do what I described. > Setting enable_seqscan=off still doesn't cause the desired index to be > selected: > > elon2=# explain analyse select * from call where aspid='123C' and > OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 > 23:59:59.999' order by aspid desc, openeddatetime desc, callstatus desc, > calltype desc, callkey desc; > > QUERY PLAN > > ------------------------------------------------------------------------ > ------------------------------------------------------------------------ > ------------------------- > Sort (cost=355314.41..356482.87 rows=467384 width=295) (actual > time=33382.92..34088.10 rows=461973 loops=1) > Sort Key: aspid, openeddatetime, callstatus, calltype, callkey > -> Index Scan using call_aspid on call (cost=0.00..43430.25 > rows=467384 width=295) (actual time=0.24..7915.21 rows=461973 loops=1) > Index Cond: (aspid = '123C'::bpchar) > Filter: ((openeddatetime >= '2000-01-01 00:00:00-07'::timestamp > with time zone) AND (openeddatetime <= '2004-06-24 > 23:59:59.999-07'::timestamp with time zone)) > Total runtime: 39196.39 msec I'm a little surprised at this. I should have done a reverse index scan and skipped the sort step. In fact, with a very simple select, I get this: rbt=# \d t Table "public.t" Column | Type | Modifiers --------+--------------------------------+----------- col1 | bpchar | col2 | timestamp(0) without time zone | col3 | integer | col4 | integer | col5 | integer | Indexes: "t_idx" btree (col1, col2, col3, col4, col5) rbt=# set enable_seqscan = false; SET rbt=# explain analyze select * from t order by col1 desc, col2 desc, col3 desc, col4 desc, col5 desc; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- Index Scan Backward using t_idx on t (cost=0.00..6.20 rows=18 width=52) (actual time=0.046..0.219 rows=18 loops=1) Total runtime: 1.813 ms (2 rows) Any chance you could put together a test case demonstrating the above behaviour? Everything from CREATE TABLE, through dataload to the EXPLAIN ANALYZE. From pgsql-jdbc-owner@postgresql.org Fri Jul 9 17:24:29 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8F29BD1B20E for ; Fri, 9 Jul 2004 17:24:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81370-03 for ; Fri, 9 Jul 2004 20:24:22 +0000 (GMT) Received: from web51401.mail.yahoo.com (web51401.mail.yahoo.com [206.190.38.180]) by svr1.postgresql.org (Postfix) with SMTP id 1FA69D1B1AB for ; Fri, 9 Jul 2004 17:24:15 -0300 (ADT) Message-ID: <20040709202416.54013.qmail@web51401.mail.yahoo.com> Received: from [192.88.67.254] by web51401.mail.yahoo.com via HTTP; Fri, 09 Jul 2004 13:24:16 PDT Date: Fri, 9 Jul 2004 13:24:16 -0700 (PDT) From: Bill Chandler Subject: Cursors performance (was: Re: [PERFORM] Terrible performance after deleting/recreating indexes) To: pgsql-performance@postgresql.org Cc: pgsql-jdbc@postgresql.org In-Reply-To: <40ED0ED9.9000106@frodo.hserus.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS, LINES_OF_YELLING X-Spam-Level: X-Archive-Number: 200407/66 X-Sequence-Number: 10450 Thanks to all who have responded. I now think my problem is not related to deleting/recreating indexes. Somehow it is related to JDBC cursors. It appears that what is happening is that since I'm using a fetch size of 5000, the command: FETCH FORWARD 5000 FROM JDBC_CURS_1 is being repeatedly sent to the server as I process the result set from my query. Each time this command is sent it it takes about 5 minutes to return which is about the amount of time the whole query took to complete before the performance degredation. So in other words it looks as if the full select is being rerun on each fetch. Now the mystery is why is this happening all of the sudden? I have been running w/ fetch size set to 5000 for the last couple of weeks and it did not appear to be doing this (i.e. re-running the entire select statement again). Is this what I should expect when using cursors? I would have thought that the server should "remember" where it left off in the query since the last fetch and continue from there. Could I have inadvertently changed a parameter somewhere that would cause this behavior? thanks, Bill __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From pgsql-jdbc-owner@postgresql.org Fri Jul 9 17:38:57 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 920C0D1B1CB for ; Fri, 9 Jul 2004 17:38:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87533-05 for ; Fri, 9 Jul 2004 20:38:47 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 072E5D1B1B0 for ; Fri, 9 Jul 2004 17:38:44 -0300 (ADT) Received: (qmail 18954 invoked from network); 9 Jul 2004 20:38:43 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 9 Jul 2004 20:38:43 -0000 Subject: Re: Cursors performance (was: Re: [PERFORM] Terrible From: Dave Cramer Reply-To: pg@fastcrypt.com To: Bill Chandler Cc: pgsql-performance@postgresql.org, "pgsql-jdbc@postgresql.org" In-Reply-To: <20040709202416.54013.qmail@web51401.mail.yahoo.com> References: <20040709202416.54013.qmail@web51401.mail.yahoo.com> Content-Type: text/plain Organization: Cramer Consulting Message-Id: <1089405541.3645.289.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 09 Jul 2004 16:39:01 -0400 Content-Transfer-Encoding: 7bit X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/67 X-Sequence-Number: 10451 Bill, What happens if you do this in psql, also you can turn on duration logging in the backend and log the queries. dave On Fri, 2004-07-09 at 16:24, Bill Chandler wrote: > Thanks to all who have responded. I now think my > problem is not related to deleting/recreating indexes. > Somehow it is related to JDBC cursors. It appears > that what is happening is that since I'm using > a fetch size of 5000, the command: > > FETCH FORWARD 5000 FROM JDBC_CURS_1 > > is being repeatedly sent to the server as I process > the result set from my query. Each time this command > is sent it it takes about 5 minutes to return which is > about the amount of time the whole query took to > complete before the performance degredation. So in > other words it looks as if the full select is being > rerun on each fetch. > > Now the mystery is why is this happening all of the > sudden? I have been running w/ fetch size set to 5000 > for the last couple of weeks and it did not appear to > be doing this (i.e. re-running the entire select > statement again). Is this what I should expect when > using cursors? I would have thought that the server > should "remember" where it left off in the query since > the last fetch and continue from there. > > Could I have inadvertently changed a parameter > somewhere that would cause this behavior? > > thanks, > > Bill > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > ---------------------------(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 > > > > !DSPAM:40eefff6170301475214189! > > -- Dave Cramer 519 939 0336 ICQ # 14675561 From pgsql-jdbc-owner@postgresql.org Fri Jul 9 17:44:51 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 866B2D1B1AB for ; Fri, 9 Jul 2004 17:44:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89434-08 for ; Fri, 9 Jul 2004 20:44:42 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 8B6E4D1B18F for ; Fri, 9 Jul 2004 17:44:39 -0300 (ADT) Received: (qmail 32093 invoked by uid 1112); 9 Jul 2004 20:44:32 -0000 Date: Fri, 9 Jul 2004 15:44:32 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Bill Chandler Cc: pgsql-performance@postgresql.org, pgsql-jdbc@postgresql.org Subject: Re: Cursors performance (was: Re: [PERFORM] Terrible performance In-Reply-To: <20040709202416.54013.qmail@web51401.mail.yahoo.com> Message-ID: References: <20040709202416.54013.qmail@web51401.mail.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/68 X-Sequence-Number: 10452 On Fri, 9 Jul 2004, Bill Chandler wrote: > Thanks to all who have responded. I now think my > problem is not related to deleting/recreating indexes. > Somehow it is related to JDBC cursors. It appears > that what is happening is that since I'm using > a fetch size of 5000, the command: > > FETCH FORWARD 5000 FROM JDBC_CURS_1 > If the top level node of your execution plan is a sort step, it should take essentially no time to retrieve additional rows after the first fetch. The sort step is materializes the results so that future fetches simply need to spit this data back to the client. I would agree with Dave's suggestion to use log_duration and compare the values for the first and subsequent fetches. Kris Jurka From pgsql-jdbc-owner@postgresql.org Fri Jul 9 18:04:04 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B3E7FD1B19B for ; Fri, 9 Jul 2004 18:03:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96934-09 for ; Fri, 9 Jul 2004 21:03:50 +0000 (GMT) Received: from web51406.mail.yahoo.com (web51406.mail.yahoo.com [206.190.38.185]) by svr1.postgresql.org (Postfix) with SMTP id 8FD6CD1B184 for ; Fri, 9 Jul 2004 18:03:46 -0300 (ADT) Message-ID: <20040709210348.1813.qmail@web51406.mail.yahoo.com> Received: from [192.88.67.254] by web51406.mail.yahoo.com via HTTP; Fri, 09 Jul 2004 14:03:48 PDT Date: Fri, 9 Jul 2004 14:03:48 -0700 (PDT) From: Bill Chandler Subject: Re: Cursors performance (was: Re: [PERFORM] Terrible performance after deleting/recreating indexes) To: pg@fastcrypt.com Cc: pgsql-jdbc@postgresql.org In-Reply-To: <1089405541.3645.289.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200407/69 X-Sequence-Number: 10453 Using psql it peforms exactly as I'd expect. The rows get printed out to stdout, I hold down the space bar to keep everything scrolling and as every 5000 rows go by I see a new fetch statement logged in the server log. The results from this statement seem to come back instaneously and the output starts scrolling again immediately. Whole query takes a few minutes to complete. I seems like it has something to do w/ my JDBC app but I can't think for the life of me what I might have changed. Anyway, there's only the setFetchSize(5000) and the setAutoCommit(false) that are relevant to cursors, right? And those have been in there for weeks. Bill --- Dave Cramer wrote: > Bill, > > What happens if you do this in psql, also you can > turn on duration > logging in the backend and log the queries. > > dave > On Fri, 2004-07-09 at 16:24, Bill Chandler wrote: > > Thanks to all who have responded. I now think my > > problem is not related to deleting/recreating > indexes. > > Somehow it is related to JDBC cursors. It appears > > that what is happening is that since I'm using > > a fetch size of 5000, the command: > > > > FETCH FORWARD 5000 FROM JDBC_CURS_1 > > > > is being repeatedly sent to the server as I > process > > the result set from my query. Each time this > command > > is sent it it takes about 5 minutes to return > which is > > about the amount of time the whole query took to > > complete before the performance degredation. So in > > other words it looks as if the full select is > being > > rerun on each fetch. > > > > Now the mystery is why is this happening all of > the > > sudden? I have been running w/ fetch size set to > 5000 > > for the last couple of weeks and it did not appear > to > > be doing this (i.e. re-running the entire select > > statement again). Is this what I should expect > when > > using cursors? I would have thought that the > server > > should "remember" where it left off in the query > since > > the last fetch and continue from there. > > > > Could I have inadvertently changed a parameter > > somewhere that would cause this behavior? > > > > thanks, > > > > Bill > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection around > > http://mail.yahoo.com > > > > ---------------------------(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 > > > > > > > > !DSPAM:40eefff6170301475214189! > > > > > -- > Dave Cramer > 519 939 0336 > ICQ # 14675561 > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From pgsql-jdbc-owner@postgresql.org Fri Jul 9 18:11:45 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 94029D1B1C8 for ; Fri, 9 Jul 2004 18:10:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01336-05 for ; Fri, 9 Jul 2004 21:10:41 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id DC737D1B1B0 for ; Fri, 9 Jul 2004 18:10:37 -0300 (ADT) Received: (qmail 26613 invoked from network); 9 Jul 2004 21:10:37 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 9 Jul 2004 21:10:37 -0000 Subject: Re: Cursors performance (was: Re: [PERFORM] Terrible From: Dave Cramer Reply-To: pg@fastcrypt.com To: Bill Chandler Cc: "pgsql-jdbc@postgresql.org" In-Reply-To: <20040709210348.1813.qmail@web51406.mail.yahoo.com> References: <20040709210348.1813.qmail@web51406.mail.yahoo.com> Content-Type: text/plain Organization: Cramer Consulting Message-Id: <1089407457.1518.295.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 09 Jul 2004 17:10:57 -0400 Content-Transfer-Encoding: 7bit X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/71 X-Sequence-Number: 10455 Ok, given that there are 5000 rows, the jdbc driver will actually fetch all 5000 when you do the fetch, so is it the speed of the connection, or the actual fetch that is taking the time, again, check the server logs for duration. Dave On Fri, 2004-07-09 at 17:03, Bill Chandler wrote: > Using psql it peforms exactly as I'd expect. The > rows get printed out to stdout, I hold down the space > bar to keep everything scrolling and as every 5000 > rows go by I see a new fetch statement logged in the > server log. The results from this statement seem to > come back instaneously and the output starts scrolling > again immediately. Whole query takes a few minutes > to complete. > > I seems like it has something to do w/ my JDBC app > but I can't think for the life of me what I might have > changed. Anyway, there's only the setFetchSize(5000) > and the setAutoCommit(false) that are relevant to > cursors, right? And those have been in there for > weeks. > > Bill > > --- Dave Cramer wrote: > > Bill, > > > > What happens if you do this in psql, also you can > > turn on duration > > logging in the backend and log the queries. > > > > dave > > On Fri, 2004-07-09 at 16:24, Bill Chandler wrote: > > > Thanks to all who have responded. I now think my > > > problem is not related to deleting/recreating > > indexes. > > > Somehow it is related to JDBC cursors. It appears > > > that what is happening is that since I'm using > > > a fetch size of 5000, the command: > > > > > > FETCH FORWARD 5000 FROM JDBC_CURS_1 > > > > > > is being repeatedly sent to the server as I > > process > > > the result set from my query. Each time this > > command > > > is sent it it takes about 5 minutes to return > > which is > > > about the amount of time the whole query took to > > > complete before the performance degredation. So in > > > other words it looks as if the full select is > > being > > > rerun on each fetch. > > > > > > Now the mystery is why is this happening all of > > the > > > sudden? I have been running w/ fetch size set to > > 5000 > > > for the last couple of weeks and it did not appear > > to > > > be doing this (i.e. re-running the entire select > > > statement again). Is this what I should expect > > when > > > using cursors? I would have thought that the > > server > > > should "remember" where it left off in the query > > since > > > the last fetch and continue from there. > > > > > > Could I have inadvertently changed a parameter > > > somewhere that would cause this behavior? > > > > > > thanks, > > > > > > Bill > > > > > > __________________________________________________ > > > Do You Yahoo!? > > > Tired of spam? Yahoo! Mail has the best spam > > protection around > > > http://mail.yahoo.com > > > > > > ---------------------------(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 > > > > > > > > > > > > > > > > > > > > -- > > Dave Cramer > > 519 939 0336 > > ICQ # 14675561 > > > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > > > !DSPAM:40ef083f256273772718645! > > -- Dave Cramer 519 939 0336 ICQ # 14675561 From pgsql-jdbc-owner@postgresql.org Fri Jul 9 18:33:31 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88128D1B1D1 for ; Fri, 9 Jul 2004 18:18:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05801-02 for ; Fri, 9 Jul 2004 21:18:03 +0000 (GMT) Received: from web51406.mail.yahoo.com (web51406.mail.yahoo.com [206.190.38.185]) by svr1.postgresql.org (Postfix) with SMTP id 317FBD1B1B9 for ; Fri, 9 Jul 2004 18:17:59 -0300 (ADT) Message-ID: <20040709211801.12966.qmail@web51406.mail.yahoo.com> Received: from [192.88.67.254] by web51406.mail.yahoo.com via HTTP; Fri, 09 Jul 2004 14:18:01 PDT Date: Fri, 9 Jul 2004 14:18:01 -0700 (PDT) From: Bill Chandler Subject: Re: Cursors performance (was: Re: [PERFORM] Terrible performance after deleting/recreating indexes) To: pg@fastcrypt.com Cc: pgsql-jdbc@postgresql.org In-Reply-To: <1089407457.1518.295.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200407/73 X-Sequence-Number: 10457 Here are the result from "log_duration = true" DECLARE/1st FETCH: 325014.881 ms 2nd FETCH: 324055.281 ms --- Dave Cramer wrote: > Ok, given that there are 5000 rows, the jdbc driver > will actually fetch > all 5000 when you do the fetch, so is it the speed > of the connection, or > the actual fetch that is taking the time, again, > check the server logs > for duration. > > Dave > On Fri, 2004-07-09 at 17:03, Bill Chandler wrote: > > Using psql it peforms exactly as I'd expect. The > > rows get printed out to stdout, I hold down the > space > > bar to keep everything scrolling and as every 5000 > > rows go by I see a new fetch statement logged in > the > > server log. The results from this statement seem > to > > come back instaneously and the output starts > scrolling > > again immediately. Whole query takes a few > minutes > > to complete. > > > > I seems like it has something to do w/ my JDBC app > > but I can't think for the life of me what I might > have > > changed. Anyway, there's only the > setFetchSize(5000) > > and the setAutoCommit(false) that are relevant to > > cursors, right? And those have been in there for > > weeks. > > > > Bill > > > > --- Dave Cramer wrote: > > > Bill, > > > > > > What happens if you do this in psql, also you > can > > > turn on duration > > > logging in the backend and log the queries. > > > > > > dave > > > On Fri, 2004-07-09 at 16:24, Bill Chandler > wrote: > > > > Thanks to all who have responded. I now think > my > > > > problem is not related to deleting/recreating > > > indexes. > > > > Somehow it is related to JDBC cursors. It > appears > > > > that what is happening is that since I'm using > > > > > a fetch size of 5000, the command: > > > > > > > > FETCH FORWARD 5000 FROM JDBC_CURS_1 > > > > > > > > is being repeatedly sent to the server as I > > > process > > > > the result set from my query. Each time this > > > command > > > > is sent it it takes about 5 minutes to return > > > which is > > > > about the amount of time the whole query took > to > > > > complete before the performance degredation. > So in > > > > other words it looks as if the full select is > > > being > > > > rerun on each fetch. > > > > > > > > Now the mystery is why is this happening all > of > > > the > > > > sudden? I have been running w/ fetch size set > to > > > 5000 > > > > for the last couple of weeks and it did not > appear > > > to > > > > be doing this (i.e. re-running the entire > select > > > > statement again). Is this what I should > expect > > > when > > > > using cursors? I would have thought that the > > > server > > > > should "remember" where it left off in the > query > > > since > > > > the last fetch and continue from there. > > > > > > > > Could I have inadvertently changed a parameter > > > > somewhere that would cause this behavior? > > > > > > > > thanks, > > > > > > > > Bill > > > > > > > > > __________________________________________________ > > > > Do You Yahoo!? > > > > Tired of spam? Yahoo! Mail has the best spam > > > protection around > > > > http://mail.yahoo.com > > > > > > > > ---------------------------(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 > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Dave Cramer > > > 519 939 0336 > > > ICQ # 14675561 > > > > > > > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection around > > http://mail.yahoo.com > > > > > > > > !DSPAM:40ef083f256273772718645! > > > > > -- > Dave Cramer > 519 939 0336 > ICQ # 14675561 > > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail From pgsql-jdbc-owner@postgresql.org Fri Jul 9 18:56:40 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D54C3D1B33F; Fri, 9 Jul 2004 18:55:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22995-04; Fri, 9 Jul 2004 21:55:42 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 9FE5CD1B379; Fri, 9 Jul 2004 18:55:37 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1Bj3LF-00079k-00; Sat, 10 Jul 2004 09:55:37 +1200 Message-ID: <40EF1457.1060002@opencloud.com> Date: Sat, 10 Jul 2004 09:55:35 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bill Chandler Cc: pgsql-performance@postgresql.org, pgsql-jdbc@postgresql.org Subject: Re: Cursors performance References: <20040709202416.54013.qmail@web51401.mail.yahoo.com> In-Reply-To: <20040709202416.54013.qmail@web51401.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/75 X-Sequence-Number: 10459 Bill Chandler wrote: > Now the mystery is why is this happening all of the > sudden? I have been running w/ fetch size set to 5000 > for the last couple of weeks and it did not appear to > be doing this (i.e. re-running the entire select > statement again). Is this what I should expect when > using cursors? I would have thought that the server > should "remember" where it left off in the query since > the last fetch and continue from there. I'd check heap size, GC activity (-verbose:gc), CPU use, swapping activity on the *client* side. It may be that your dataset size or physical memory or something similar has changed sufficiently that GC resulting from the data in each 5k row batch is killing you. Can you try a trivial app that runs the same query (with same fetchsize, autocommit, etc) via JDBC and does nothing but steps forward through the resultset, and see how fast it runs? Perhaps the problem is in your processing logic. -O From pgsql-performance-owner@postgresql.org Tue Jul 13 16:29:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C4E4CD1B360 for ; Fri, 9 Jul 2004 19:29:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38066-07 for ; Fri, 9 Jul 2004 22:28:57 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id B096BD1B342 for ; Fri, 9 Jul 2004 19:28:52 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i69MSpi7078548 for ; Fri, 9 Jul 2004 22:28:51 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i69MN00N077592 for pgsql-performance@postgresql.org; Fri, 9 Jul 2004 22:23:00 GMT From: "Mischa Sandberg" X-Newsgroups: comp.databases.postgresql.performance References: <20040708101913.GA15871@uio.no> <00ac01c46516$3ec859e0$0300a8c0@lappy> <40EDF7DE.8080900@familyhealth.com.au> <011301c46597$15d145c0$0300a8c0@lappy> Subject: Re: Inverted-list databases (was: Working on huge RAM based datasets) Lines: 32 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: Date: Fri, 09 Jul 2004 22:23:03 GMT To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=PRIORITY_NO_NAME X-Spam-Level: X-Archive-Number: 200407/76 X-Sequence-Number: 7467 ""Andy Ballingall"" wrote in message news:011301c46597$15d145c0$0300a8c0@lappy... > On another thread, (not in this mailing list), someone mentioned that there > are a class of databases which, rather than caching bits of database file > (be it in the OS buffer cache or the postmaster workspace), construct a a > well indexed memory representation of the entire data in the postmaster > workspace (or its equivalent), and this, remaining persistent, allows the DB > to service backend queries far quicker than if the postmaster was working > with the assumption that most of the data was on disk (even if, in practice, > large amounts or perhaps even all of it resides in OS cache). As a historical note, System R (grandaddy of all relational dbs) worked this way. And it worked under ridiculous memory constraints by modern standards. Space-conscious MOLAP databases do this, FWIW. Sybase 11 bitmap indexes pretty much amount to this, too. I've built a SQL engine that used bitmap indexes within B-Tree indexes, making it practical to index every field of every table (the purpose of the engine). You can also build special-purpose in-memory representations to test for existence (of a key), when you expect a lot of failures. Google "superimposed coding" e.g. http://www.dbcsoftware.com/dbcnews/NOV94.TXT From pgsql-performance-owner@postgresql.org Fri Jul 9 23:52:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C6294D1B195 for ; Fri, 9 Jul 2004 23:52:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17194-03 for ; Sat, 10 Jul 2004 02:52:07 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2BF6DD1B1B3 for ; Fri, 9 Jul 2004 23:52:02 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6A2q4rp002001; Fri, 9 Jul 2004 22:52:04 -0400 (EDT) To: "Missner, T. R." Cc: pgsql-performance@postgresql.org Subject: Re: inserting into brand new database faster than old database In-reply-to: References: Comments: In-reply-to "Missner, T. R." message dated "Wed, 07 Jul 2004 11:24:11 -0600" Date: Fri, 09 Jul 2004 22:52:04 -0400 Message-ID: <2000.1089427924@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/54 X-Sequence-Number: 7445 "Missner, T. R." writes: > ... Each day a brand new set of tables is > created and eventually the old tables are dropped. You did not say which PG version you are using (tut tut) but my first thought is that it's a pre-7.4 release and your problems trace to bloat in the system-catalog indexes. The indexes on pg_class and pg_attribute would be quite likely to suffer serious bloat if you continually create and drop tables, because the range of useful table OIDs will be continually shifting. We didn't fix this until 7.4. If you are seeing this in 7.4.* then more investigation is needed... regards, tom lane From pgsql-jdbc-owner@postgresql.org Sat Jul 10 00:05:06 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3B943D1B2BD; Sat, 10 Jul 2004 00:03:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25994-04; Sat, 10 Jul 2004 03:04:03 +0000 (GMT) Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [202.0.58.20]) by svr1.postgresql.org (Postfix) with ESMTP id 433FBD1B269; Sat, 10 Jul 2004 00:03:56 -0300 (ADT) Received: from smtp-2.paradise.net.nz (smtp-2b.paradise.net.nz [202.0.32.211]) by linda-1.paradise.net.nz (Paradise.net.nz) with ESMTP id <0I0M002NO8IOUE@linda-1.paradise.net.nz>; Sat, 10 Jul 2004 15:04:00 +1200 (NZST) Received: from coretech.co.nz (203-96-145-168.adsl.paradise.net.nz [203.96.145.168]) by smtp-2.paradise.net.nz (Postfix) with ESMTP id 2B2219E25B; Sat, 10 Jul 2004 15:04:00 +1200 (NZST) Date: Sat, 10 Jul 2004 15:06:20 +1200 From: Mark Kirkwood Subject: Re: Cursors performance In-reply-to: <20040709202416.54013.qmail@web51401.mail.yahoo.com> To: Bill Chandler Cc: pgsql-performance@postgresql.org, pgsql-jdbc@postgresql.org Message-id: <40EF5D2C.5080506@coretech.co.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040429 References: <20040709202416.54013.qmail@web51401.mail.yahoo.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/82 X-Sequence-Number: 10466 Might be worth doing a little test: i) modify your code to fetch 1 row at a time ii) set log_duration=true in your postgresql.conf (as the other posters have suggested) Then compare with running the query in psql. regards Mark Bill Chandler wrote: >Thanks to all who have responded. I now think my >problem is not related to deleting/recreating indexes. >Somehow it is related to JDBC cursors. It appears >that what is happening is that since I'm using >a fetch size of 5000, the command: > >FETCH FORWARD 5000 FROM JDBC_CURS_1 > >is being repeatedly sent to the server as I process >the result set from my query. Each time this command >is sent it it takes about 5 minutes to return which is >about the amount of time the whole query took to >complete before the performance degredation. So in >other words it looks as if the full select is being >rerun on each fetch. > >Now the mystery is why is this happening all of the >sudden? I have been running w/ fetch size set to 5000 >for the last couple of weeks and it did not appear to >be doing this (i.e. re-running the entire select >statement again). Is this what I should expect when >using cursors? I would have thought that the server >should "remember" where it left off in the query since >the last fetch and continue from there. > >Could I have inadvertently changed a parameter >somewhere that would cause this behavior? > >thanks, > >Bill > >__________________________________________________ >Do You Yahoo!? >Tired of spam? Yahoo! Mail has the best spam protection around >http://mail.yahoo.com > >---------------------------(end of broadcast)--------------------------- >TIP 8: explain analyze is your friend > > From pgsql-performance-owner@postgresql.org Sat Jul 10 00:10:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6BA9BD1B1A0 for ; Sat, 10 Jul 2004 00:10:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27573-03 for ; Sat, 10 Jul 2004 03:10:07 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id ED1DBD1B23F for ; Sat, 10 Jul 2004 00:09:59 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6A3A4K7002133; Fri, 9 Jul 2004 23:10:04 -0400 (EDT) To: Eugene Cc: pgsql-performance@postgresql.org Subject: Re: Forcing HashAggregation prior to index scan? In-reply-to: <20040705231434.81471.qmail@web50708.mail.yahoo.com> References: <20040705231434.81471.qmail@web50708.mail.yahoo.com> Comments: In-reply-to Eugene message dated "Mon, 05 Jul 2004 16:14:34 -0700" Date: Fri, 09 Jul 2004 23:10:04 -0400 Message-ID: <2132.1089429004@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/56 X-Sequence-Number: 7447 Eugene writes: > Can I force HashAggregation before index scan? No. But look into why the planner's rows estimate is so bad here: > -> Index Scan using refseq_sequence_key2 on refseq_sequence s (cost=0.00..1516.06 rows=389 > width=24) (actual time=0.352..491.107 rows=27391 loops=1) > Index Cond: ((species)::text = 'Homo sapiens'::text) Have you ANALYZEd this table recently? If so, maybe you need a larger statistics target for the species column. The estimated row count shouldn't be off by a factor of seventy... regards, tom lane From pgsql-performance-owner@postgresql.org Sat Jul 10 07:00:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3BCC9D1B181 for ; Sat, 10 Jul 2004 07:00:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49626-06 for ; Sat, 10 Jul 2004 10:00:28 +0000 (GMT) Received: from stan.aopsys.com (unknown [147.210.68.135]) by svr1.postgresql.org (Postfix) with ESMTP id 1AC80D1B1B9 for ; Sat, 10 Jul 2004 07:00:18 -0300 (ADT) Received: from [127.0.0.1] (helo=lolo.bearteam.org) by stan.aopsys.com with esmtp (Exim 4.30) id 1BjEeP-0001l1-Sn for pgsql-performance@postgresql.org; Sat, 10 Jul 2004 12:00:09 +0200 To: pgsql-performance@postgresql.org Subject: Re: achat borne wifi References: <20040707185547.36377a9a.matthieu.compin@parinux.org> From: Laurent Martelli Organization: Parinux Date: Sat, 10 Jul 2004 12:00:09 +0200 In-Reply-To: <20040707185547.36377a9a.matthieu.compin@parinux.org> (Matthieu Compin's message of "Wed, 7 Jul 2004 18:55:47 +0200") Message-ID: <87y8lsdvx2.fsf@lolo.bearteam.org> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/57 X-Sequence-Number: 7448 >>>>> "Matthieu" == Matthieu Compin writes: Matthieu> bonjour � tous! J'avais �mis l'id�e d'acheteer une borne Matthieu> wifi pour nos futurs manifestation public. Je viens donc Matthieu> de discuter pour avoir qq infos et des prix. Je pense que c'est un bon investissement. +1 donc -- Laurent Martelli vice-pr�sident de Parinux http://www.bearteam.org/~laurent/ http://www.parinux.org/ laurent@bearteam.org From pgsql-performance-owner@postgresql.org Tue Jul 13 16:29:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 69C07D1B181 for ; Sat, 10 Jul 2004 09:25:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91192-02 for ; Sat, 10 Jul 2004 12:25:38 +0000 (GMT) Received: from smtp-out4.blueyonder.co.uk (smtp-out4.blueyonder.co.uk [195.188.213.7]) by svr1.postgresql.org (Postfix) with ESMTP id 8CBC8D1B19C for ; Sat, 10 Jul 2004 09:25:27 -0300 (ADT) Received: from lappy ([82.43.186.55]) by smtp-out4.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.5600); Sat, 10 Jul 2004 13:25:52 +0100 Message-ID: <021101c46679$01ef4330$0300a8c0@lappy> From: "Andy Ballingall" To: "J. Andrew Rogers" Cc: References: <20040708101913.GA15871@uio.no> <00ac01c46516$3ec859e0$0300a8c0@lappy> <40EDF7DE.8080900@familyhealth.com.au> <011301c46597$15d145c0$0300a8c0@lappy> <1089409248.4524.13.camel@vulture.corp.neopolitan.com> Subject: Re: Working on huge RAM based datasets Date: Sat, 10 Jul 2004 13:25:37 +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.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-OriginalArrivalTime: 10 Jul 2004 12:25:52.0858 (UTC) FILETIME=[0AA073A0:01C46679] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/75 X-Sequence-Number: 7466 Oops - sorry - I confused my numbers. The opteron machine in mind *only* has up to 64GB of RAM (e.g. HP DL585) - here's the datapage: http://h18004.www1.hp.com/products/servers/proliantdl585/index.html Still - with *just* 64GB of RAM, that would comfortably provide for the type of scenario I envisage. Is that still enough for your app? The 256GB number came from something I read saying that the current crop of 64 bit chips will allow up to 256GB of RAM in principle, so it is just a matter of time before the memory limit shoots up on these simple products. If you are prepared to pay a bit more, already there are some big memory options on linux: E.g. you can have up to 192GB in an SGI Altix 350: http://www.sgi.com/servers/altix/downloads/altix350_at_a_glance.pdf Or up to 4 terabytes in it's bigger brother the Altix 3000 - but that's getting a bit esoteric. http://www.sgi.com/servers/altix/ (This won lots of awards recently) The nice thing about the two things above is that they run linux in a single address space NUMA setup, and in theory you can just bolt on more CPUs and more RAM as your needs grow. Thanks, Andy ----- Original Message ----- From: "J. Andrew Rogers" To: "Andy Ballingall" Sent: Friday, July 09, 2004 10:40 PM Subject: Re: [PERFORM] Working on huge RAM based datasets > On Fri, 2004-07-09 at 02:28, Andy Ballingall wrote: > > After all, we're now seeing the first wave of 'reasonably priced' 64 bit > > servers supported by a proper 64 bit OS (e.g. linux). HP are selling a 4 > > Opteron server which can take 256GB of RAM, and that starts at $10000 (ok - > > they don't give you that much RAM for that price - not yet, anyway!) > > > Which server is this?! They are selling an Opteron system that can hold > 256 GB of RAM? > > I looked on their site, and couldn't find anything like that. I run > some MASSIVE memory codes that don't need a lot of CPU, and if such a > box existed, I'd be very interested. > > cheers, > > j. andrew rogers > > > ----- Original Message ----- From: "J. Andrew Rogers" To: "Andy Ballingall" Sent: Friday, July 09, 2004 10:40 PM Subject: Re: [PERFORM] Working on huge RAM based datasets > On Fri, 2004-07-09 at 02:28, Andy Ballingall wrote: > > After all, we're now seeing the first wave of 'reasonably priced' 64 bit > > servers supported by a proper 64 bit OS (e.g. linux). HP are selling a 4 > > Opteron server which can take 256GB of RAM, and that starts at $10000 (ok - > > they don't give you that much RAM for that price - not yet, anyway!) > > > Which server is this?! They are selling an Opteron system that can hold > 256 GB of RAM? > > I looked on their site, and couldn't find anything like that. I run > some MASSIVE memory codes that don't need a lot of CPU, and if such a > box existed, I'd be very interested. > > cheers, > > j. andrew rogers > > > From pgsql-performance-owner@postgresql.org Sat Jul 10 10:59:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5027ED1B269 for ; Sat, 10 Jul 2004 10:59:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17952-03 for ; Sat, 10 Jul 2004 13:59:03 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 6E931D1B267 for ; Sat, 10 Jul 2004 10:58:53 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6ADwwi7064572 for ; Sat, 10 Jul 2004 13:58:58 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6ADoWlk063629 for pgsql-performance@postgresql.org; Sat, 10 Jul 2004 13:50:32 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Working on huge RAM based datasets Date: Sat, 10 Jul 2004 09:06:34 -0400 Organization: cbbrowne Computing Inc Lines: 44 Message-ID: References: <20040708101913.GA15871@uio.no> <00ac01c46516$3ec859e0$0300a8c0@lappy> <40EDF7DE.8080900@familyhealth.com.au> <011301c46597$15d145c0$0300a8c0@lappy> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:J0dE4S02h10Xyja2/mYapvMvZpU= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/58 X-Sequence-Number: 7449 Quoth andy_ballingall@bigfoot.com ("Andy Ballingall"): > This is the future, isn't it? Each year, a higher percentage of DB > applications will be able to fit entirely in RAM, and that percentage is > going to be quite significant in just a few years. The disk system gets > relegated to a data preload on startup and servicing the writes as the > server does its stuff. Regrettably, this may be something that fits better with MySQL, as it already has an architecture oriented to having different "storage engines" in behind. There may be merit to the notion of implementing in-memory databases; some assumptions change: - You might use bitmap indices, although that probably "kills" MVCC; - You might use T-trees rather than B-trees for indices, although research seems to indicate that B-trees win out if there is a great deal of concurrent access; - It can become worthwhile to use compression schemes to fit more records into memory that wouldn't be worthwhile if using demand paging. If you really want to try this, then look at Konstantin Knizhnik's FastDB system: http://www.ispras.ru/~knizhnik/fastdb.html It assumes that your application will be a monolithic C++ process; if that isn't the case, then performance will probably suffer due to throwing in context switches. The changes in assumptions are pretty vital ones, that imply you're heading in a fairly different direction than that which PostgreSQL seems to be taking. That's not to say that there isn't merit to building a database system using T-trees and bitmap indices attuned to applications where main-memory storage is key; it's just that the proposal probably should go somewhere else. -- output = ("cbbrowne" "@" "cbbrowne.com") http://www3.sympatico.ca/cbbrowne/languages.html How does the guy who drives the snowplow get to work in the mornings? From pgsql-performance-owner@postgresql.org Sun Jul 11 11:14:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 390A0D1B1AB for ; Sun, 11 Jul 2004 11:14:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29912-04 for ; Sun, 11 Jul 2004 14:14:14 +0000 (GMT) Received: from smtp104.mail.sc5.yahoo.com (smtp104.mail.sc5.yahoo.com [66.163.169.223]) by svr1.postgresql.org (Postfix) with SMTP id 7CC45D1B174 for ; Sun, 11 Jul 2004 11:14:05 -0300 (ADT) Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 with login) by smtp104.mail.sc5.yahoo.com with SMTP; 11 Jul 2004 14:14:14 -0000 Received: from Yahoo.com (ganymed.black-lion.info [192.168.192.100]) (authenticated bits=0) by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id i6BEE23v004406; Sun, 11 Jul 2004 10:14:08 -0400 (EDT) (envelope-from JanWieck@Yahoo.com) Message-ID: <40F14ADE.4080402@Yahoo.com> Date: Sun, 11 Jul 2004 10:12:46 -0400 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Merlin Moncure Cc: Andy Ballingall , pgsql-performance@postgresql.org Subject: Re: Working on huge RAM based datasets References: <6EE64EF3AB31D5448D0007DD34EEB34101AEC2@Herge.rcsinc.local> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AEC2@Herge.rcsinc.local> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/59 X-Sequence-Number: 7450 On 7/9/2004 10:16 AM, Merlin Moncure wrote: >> What is it about the buffer cache that makes it so unhappy being able > to >> hold everything? I don't want to be seen as a cache hit fascist, but > isn't >> it just better if the data is just *there*, available in the > postmaster's >> address space ready for each backend process to access it, rather than >> expecting the Linux cache mechanism, optimised as it may be, to have > to do >> the caching? > > The disk cache on most operating systems is optimized. Plus, keeping > shared buffers low gives you more room to bump up the sort memory, which > will make your big queries run faster. Plus, the situation will change dramatically with 7.5 where the disk cache will have less information than the PG shared buffers, which will become sequential scan resistant and will know that a block was pulled in on behalf of vacuum and not because the regular database access pattern required it. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # From pgsql-performance-owner@postgresql.org Sun Jul 11 14:59:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 40F8DD1B1A5 for ; Sun, 11 Jul 2004 14:59:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05286-02 for ; Sun, 11 Jul 2004 17:59:19 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 35D1CD1B1CE for ; Sun, 11 Jul 2004 14:59:18 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6BHxHi7080425 for ; Sun, 11 Jul 2004 17:59:17 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6BHswf6079680 for pgsql-performance@postgresql.org; Sun, 11 Jul 2004 17:54:58 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Working on huge RAM based datasets Date: Sun, 11 Jul 2004 13:04:44 -0400 Organization: cbbrowne Computing Inc Lines: 35 Message-ID: References: <6EE64EF3AB31D5448D0007DD34EEB34101AEC2@Herge.rcsinc.local> <40F14ADE.4080402@Yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:iJbLjk/dfq2t2ce8PF7GBsuPEGE= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/60 X-Sequence-Number: 7451 Martha Stewart called it a Good Thing when JanWieck@Yahoo.com (Jan Wieck) wrote: > On 7/9/2004 10:16 AM, Merlin Moncure wrote: >>> What is it about the buffer cache that makes it so unhappy being >>> able to hold everything? I don't want to be seen as a cache hit >>> fascist, but isn't it just better if the data is just *there*, >>> available in the postmaster's address space ready for each backend >>> process to access it, rather than expecting the Linux cache >>> mechanism, optimised as it may be, to have to do the caching? >> The disk cache on most operating systems is optimized. Plus, >> keeping shared buffers low gives you more room to bump up the sort >> memory, which will make your big queries run faster. > Plus, the situation will change dramatically with 7.5 where the disk > cache will have less information than the PG shared buffers, which > will become sequential scan resistant and will know that a block was > pulled in on behalf of vacuum and not because the regular database > access pattern required it. It'll be very curious how this changes things. I _think_ it means that shared buffer usage becomes more efficient both for small and large buffers, since vacuums and seq scans shouldn't "eviscerate" the shared buffers the way they can in earlier versions. What would be most interesting to see is whether this makes it wise to increase shared buffer size. It may be more effective to bump down the cache a little, and bump up sort memory; hard to tell. -- let name="cbbrowne" and tld="ntlug.org" in String.concat "@" [name;tld];; http://cbbrowne.com/info/spreadsheets.html "But life wasn't yes-no, on-off. Life was shades of gray, and rainbows not in the order of the spectrum." -- L. E. Modesitt, Jr., _Adiamante_ From pgsql-performance-owner@postgresql.org Mon Jul 12 11:05:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 59485D1B266 for ; Mon, 12 Jul 2004 11:05:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54856-05 for ; Mon, 12 Jul 2004 14:05:06 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 6BCBDD1B23C for ; Mon, 12 Jul 2004 11:04:55 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Working on huge RAM based datasets X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Mon, 12 Jul 2004 10:05:06 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEC9@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Working on huge RAM based datasets Thread-Index: AcRnUVk7ad7XhHIXQ6CKb/wbGJFdcgAxxlkg From: "Merlin Moncure" To: "Jan Wieck" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/61 X-Sequence-Number: 7452 Jan wrote: > > The disk cache on most operating systems is optimized. Plus, keeping > > shared buffers low gives you more room to bump up the sort memory, which > > will make your big queries run faster. >=20 > Plus, the situation will change dramatically with 7.5 where the disk > cache will have less information than the PG shared buffers, which will > become sequential scan resistant and will know that a block was pulled > in on behalf of vacuum and not because the regular database access > pattern required it. Hm. In my experience the different between data cached between shared buffers and the O/S is not very much...both are fast. However, I almost always see dramatic performance speedups for bumping up work mem. Are you suggesting that it will be advantageous to bump up shared buffers? Merlin From pgsql-performance-owner@postgresql.org Mon Jul 12 11:22:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ED95CD1B1DA for ; Mon, 12 Jul 2004 11:22:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62621-06 for ; Mon, 12 Jul 2004 14:23:04 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 7B596D1B1AB for ; Mon, 12 Jul 2004 11:22:54 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Working on huge RAM based datasets X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Mon, 12 Jul 2004 10:23:06 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AECA@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Working on huge RAM based datasets Thread-Index: AcRl+slaBHCfCyBERkitfj7lRUn5HgCHpOMQ From: "Merlin Moncure" To: "Andy Ballingall" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/62 X-Sequence-Number: 7453 Andy wrote: > Whether the OS caches the data or PG does, you still want it cached. If > your > sorting backends gobble up the pages that otherwise would be filled with > the > database buffers, then your postmaster will crawl, as it'll *really* have > to > wait for stuff from disk. In my scenario, you'd spec the machine so that > there would be plenty of memory for *everything*. That's the whole point: memory is a limited resource. If pg is crawling, then the problem is simple: you need more memory. The question is: is it postgresql's responsibility to manage that resource? Pg is a data management tool, not a memory management tool. The same 'let's manage everything' argument also frequently gets brought up wrt file i/o, because people assume the o/s sucks at file management. In reality, they are quite good, and through use of the generic interface the administrator is free to choose a file system that best suits the needs of the application. At some point, hard disks will be replaced by solid state memory technologies...do you really want to recode your memory manager when this happens because all your old assumptions are no longer correct? Merlin From pgsql-performance-owner@postgresql.org Mon Jul 12 11:38:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DF96AD1B269 for ; Mon, 12 Jul 2004 11:38:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72806-03 for ; Mon, 12 Jul 2004 14:38:09 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7FAEBD1B1AB for ; Mon, 12 Jul 2004 11:37:58 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id 0FBCA76AF9; Mon, 12 Jul 2004 10:38:11 -0400 (EDT) Subject: Re: Working on huge RAM based datasets From: Rod Taylor To: Christopher Browne Cc: Postgresql Performance In-Reply-To: References: <6EE64EF3AB31D5448D0007DD34EEB34101AEC2@Herge.rcsinc.local> <40F14ADE.4080402@Yahoo.com> Content-Type: text/plain Message-Id: <1089643087.42256.7.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 12 Jul 2004 10:38:08 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/63 X-Sequence-Number: 7454 > What would be most interesting to see is whether this makes it wise to > increase shared buffer size. It may be more effective to bump down > the cache a little, and bump up sort memory; hard to tell. How do we go about scheduling tests with the OSDL folks? If they could do 10 runs with buffers between 1k and 500k it would help us get a broad view of the situation. From pgsql-performance-owner@postgresql.org Mon Jul 12 13:39:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 99AA6D1B1CB for ; Mon, 12 Jul 2004 13:38:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32489-04 for ; Mon, 12 Jul 2004 16:38:43 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 83BBCD1B18F for ; Mon, 12 Jul 2004 13:38:41 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5731708; Mon, 12 Jul 2004 09:39:53 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Rod Taylor , Christopher Browne Subject: Re: Working on huge RAM based datasets Date: Mon, 12 Jul 2004 09:38:01 -0700 User-Agent: KMail/1.4.3 Cc: Postgresql Performance References: <6EE64EF3AB31D5448D0007DD34EEB34101AEC2@Herge.rcsinc.local> <1089643087.42256.7.camel@jester> In-Reply-To: <1089643087.42256.7.camel@jester> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200407120938.01764.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/64 X-Sequence-Number: 7455 Rond, Chris, > > What would be most interesting to see is whether this makes it wise to > > increase shared buffer size. It may be more effective to bump down > > the cache a little, and bump up sort memory; hard to tell. > > How do we go about scheduling tests with the OSDL folks? If they could > do 10 runs with buffers between 1k and 500k it would help us get a broad > view of the situation. Yes. We'll need to. However, I'd like to wait until we're officially in Beta. I'll be seeing the OSDL folks in person (PostgreSQL+OSDL BOF at Linux World Expo!!) in a couple of weeks. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Jul 13 16:29:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E423ED1B174 for ; Mon, 12 Jul 2004 13:59:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39826-09 for ; Mon, 12 Jul 2004 16:59:13 +0000 (GMT) Received: from excite.com (nat19.excitenetwork.com [63.236.75.67]) by svr1.postgresql.org (Postfix) with ESMTP id 34290D1B18F for ; Mon, 12 Jul 2004 13:59:11 -0300 (ADT) Received: from excite.com (xprdmailfe9.nwk.excite.com [10.50.30.38]) by xmxpita.excite.com (Postfix) with ESMTP id 54FE318240 for ; Mon, 12 Jul 2004 12:59:08 -0400 (EDT) Received: by xprdmailfe9.nwk.excite.com (Postfix, from userid 110) id 940A7395A; Mon, 12 Jul 2004 12:59:05 -0400 (EDT) To: pgsql-performance@postgresql.org Subject: Swapping in 7.4.3 Received: from [209.208.69.77] by xprdmailfe9.nwk.excite.com via HTTP; Mon, 12 Jul 2004 12:59:05 EST X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: ID = 71ccd8138f9d1bf5b17fb0a5f85a08cf Reply-To: jim.ewert@excite.com From: "Jim Ewert" MIME-Version: 1.0 X-Sender: jim.ewert@excite.com X-Mailer: PHP Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <20040712165905.940A7395A@xprdmailfe9.nwk.excite.com> Date: Mon, 12 Jul 2004 12:59:05 -0400 (EDT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.1 tagged_above=0.0 required=5.0 tests=RCVD_FAKE_HELO_DOTCOM, RCVD_IN_NJABL, RCVD_IN_NJABL_SPAM X-Spam-Level: ** X-Archive-Number: 200407/77 X-Sequence-Number: 7468 When I went to 7.4.3 (Slackware 9.1) w/ JDBC, the improvements are that it doesn't initially take much memory (have 512M) and didn't swap. I ran a full vaccum and a cluster before installation, however speed degaded to 1 *second* / update of one row in 150 rows of data, within a day! pg_autovacuum now gives excellent performance however it is taking 66M of swap; only 270k cached. _______________________________________________ Join Excite! - http://www.excite.com The most personalized portal on the Web! From pgsql-performance-owner@postgresql.org Mon Jul 12 15:02:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 13A3CD1B1D9 for ; Mon, 12 Jul 2004 15:01:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72577-01 for ; Mon, 12 Jul 2004 18:01:35 +0000 (GMT) Received: from smtp105.mail.sc5.yahoo.com (smtp105.mail.sc5.yahoo.com [66.163.169.225]) by svr1.postgresql.org (Postfix) with SMTP id B23D3D1B1CD for ; Mon, 12 Jul 2004 15:01:32 -0300 (ADT) Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 with login) by smtp105.mail.sc5.yahoo.com with SMTP; 12 Jul 2004 18:01:32 -0000 Received: from Yahoo.com (vgateway.libertyrms.info [207.219.45.62] (may be forged)) (authenticated bits=0) by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id i6CI1N3v025173; Mon, 12 Jul 2004 14:01:24 -0400 (EDT) (envelope-from JanWieck@Yahoo.com) Message-ID: <40F2D1E6.10504@Yahoo.com> Date: Mon, 12 Jul 2004 14:01:10 -0400 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: Rod Taylor , Christopher Browne , Postgresql Performance Subject: Re: Working on huge RAM based datasets References: <6EE64EF3AB31D5448D0007DD34EEB34101AEC2@Herge.rcsinc.local> <1089643087.42256.7.camel@jester> <200407120938.01764.josh@agliodbs.com> In-Reply-To: <200407120938.01764.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.6 tagged_above=0.0 required=5.0 tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS X-Spam-Level: ** X-Archive-Number: 200407/65 X-Sequence-Number: 7456 On 7/12/2004 12:38 PM, Josh Berkus wrote: > Rond, Chris, > >> > What would be most interesting to see is whether this makes it wise to >> > increase shared buffer size. It may be more effective to bump down >> > the cache a little, and bump up sort memory; hard to tell. >> >> How do we go about scheduling tests with the OSDL folks? If they could >> do 10 runs with buffers between 1k and 500k it would help us get a broad >> view of the situation. > > Yes. We'll need to. However, I'd like to wait until we're officially in > Beta. I'll be seeing the OSDL folks in person (PostgreSQL+OSDL BOF at Linux > World Expo!!) in a couple of weeks. > Don't forget to add that ARC needs some time actually to let the algorithm adjust the queue sizes and populate the cache according to the access pattern. You can't start a virgin postmaster and then slam on the accellerator of your test application by launching 500 concurrent clients out of the blue and expect that it starts off airborne. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # From pgsql-jdbc-owner@postgresql.org Mon Jul 12 15:07:48 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D8AF0D1B1CE for ; Mon, 12 Jul 2004 15:07:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73343-06 for ; Mon, 12 Jul 2004 18:07:32 +0000 (GMT) Received: from web51407.mail.yahoo.com (web51407.mail.yahoo.com [206.190.38.186]) by svr1.postgresql.org (Postfix) with SMTP id B8BE0D1B1C7 for ; Mon, 12 Jul 2004 15:07:29 -0300 (ADT) Message-ID: <20040712180730.37055.qmail@web51407.mail.yahoo.com> Received: from [192.88.67.254] by web51407.mail.yahoo.com via HTTP; Mon, 12 Jul 2004 11:07:29 PDT Date: Mon, 12 Jul 2004 11:07:29 -0700 (PDT) From: Bill Chandler Subject: Re: [PERFORM] Cursors performance To: Mark Kirkwood Cc: pgsql-jdbc@postgresql.org, pgsql-perform@postgresql.org In-Reply-To: <40EF5D2C.5080506@coretech.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200407/113 X-Sequence-Number: 10497 Thanks, Will try this test (I'm assuming you mean to say to set fetch size of 1 and rerun on both JDBC and psql). BTW, here is another clue: I only get the JDBC performance degradation when I include the "real_name like 'NEPOOL%REAL%'" clause. I've tried re-ordering too: i.e. putting this clause first in the statement, last in the statement, etc. Doesn't seem to make any difference. real_name is a varchar(64). There is a unique index on it. thanks, Bill --- Mark Kirkwood wrote: > Might be worth doing a little test: > > i) modify your code to fetch 1 row at a time > ii) set log_duration=true in your postgresql.conf > (as the other posters > have suggested) > > Then compare with running the query in psql. > > regards > > Mark > > > > Bill Chandler wrote: > > >Thanks to all who have responded. I now think my > >problem is not related to deleting/recreating > indexes. > >Somehow it is related to JDBC cursors. It appears > >that what is happening is that since I'm using > >a fetch size of 5000, the command: > > > >FETCH FORWARD 5000 FROM JDBC_CURS_1 > > > >is being repeatedly sent to the server as I process > >the result set from my query. Each time this > command > >is sent it it takes about 5 minutes to return which > is > >about the amount of time the whole query took to > >complete before the performance degredation. So in > >other words it looks as if the full select is being > >rerun on each fetch. > > > >Now the mystery is why is this happening all of the > >sudden? I have been running w/ fetch size set to > 5000 > >for the last couple of weeks and it did not appear > to > >be doing this (i.e. re-running the entire select > >statement again). Is this what I should expect > when > >using cursors? I would have thought that the > server > >should "remember" where it left off in the query > since > >the last fetch and continue from there. > > > >Could I have inadvertently changed a parameter > >somewhere that would cause this behavior? > > > >thanks, > > > >Bill > > > >__________________________________________________ > >Do You Yahoo!? > >Tired of spam? Yahoo! Mail has the best spam > protection around > >http://mail.yahoo.com > > > >---------------------------(end of > broadcast)--------------------------- > >TIP 8: explain analyze is your friend > > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > > http://www.postgresql.org/docs/faqs/FAQ.html > __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail From pgsql-performance-owner@postgresql.org Mon Jul 12 15:34:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7E2B6D1B1AE for ; Mon, 12 Jul 2004 15:33:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83686-03 for ; Mon, 12 Jul 2004 18:33:46 +0000 (GMT) Received: from stan.aopsys.com (aopsysadsl.net1.nerim.net [62.212.101.94]) by svr1.postgresql.org (Postfix) with ESMTP id 501FCD1B1AB for ; Mon, 12 Jul 2004 15:33:42 -0300 (ADT) Received: from [127.0.0.1] (helo=localhost) by stan.aopsys.com with esmtp (Exim 4.32) id 1Bk5cG-0007zp-5X for pgsql-performance@postgresql.org; Mon, 12 Jul 2004 20:33:28 +0200 To: pgsql-performance@postgresql.org Subject: Re: Fw: invitation au "Village du Logiciel Libre" de la References: <1089623613.7535.5.camel@bioinfo.monsteletch.org> <20040712103747.89735.qmail@web51403.mail.yahoo.com> <20040712144648.3bbcd800@xila> From: Laurent Martelli Organization: Parinux Date: Mon, 12 Jul 2004 20:33:27 +0200 In-Reply-To: <20040712144648.3bbcd800@xila> (alix@guillard.nom.fr's message of "Mon, 12 Jul 2004 14:46:48 +0200") Message-ID: <87r7rhf53c.fsf@stan.aopsys.com> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/20.7 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/66 X-Sequence-Number: 7457 >>>>> "alix" == alix writes: alix> Le Mon, 12 Jul 2004 12:37:47 +0200 (CEST) Jean-Luc Ancey alix> & stef �crivit: >> > Pour moi la m�me chose que l'ann�e derni�re : on > s'abstient. alix> Pour moi la m�me chose que l'ann�e derni�re : on y va. Idem pour moi. -- Laurent Martelli vice-pr�sident de Parinux http://www.bearteam.org/~laurent/ http://www.parinux.org/ laurent@bearteam.org From pgsql-jdbc-owner@postgresql.org Mon Jul 12 18:05:28 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5FB02D1B18C; Mon, 12 Jul 2004 18:05:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49840-04; Mon, 12 Jul 2004 21:05:13 +0000 (GMT) Received: from NSNOVPS00411.nacio.xythos.com (212-59.84.64.master-link.com [64.84.59.212]) by svr1.postgresql.org (Postfix) with ESMTP id 23039D1B1A0; Mon, 12 Jul 2004 18:05:10 -0300 (ADT) Received: from [192.168.1.69] ([64.154.218.194]) by NSNOVPS00411.nacio.xythos.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 12 Jul 2004 14:05:11 -0700 Message-ID: <40F2FD08.7020106@xythos.com> Date: Mon, 12 Jul 2004 14:05:12 -0700 From: Barry Lind User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bill Chandler Cc: Mark Kirkwood , pgsql-jdbc@postgresql.org, pgsql-perform@postgresql.org Subject: Re: [PERFORM] Cursors performance References: <20040712180730.37055.qmail@web51407.mail.yahoo.com> In-Reply-To: <20040712180730.37055.qmail@web51407.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 12 Jul 2004 21:05:11.0407 (UTC) FILETIME=[EB6537F0:01C46853] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/115 X-Sequence-Number: 10499 Bill, I suspect that this is an artifact of using server side prepared statements. When testing this via psql you will be forming sql like: select ... from ... where ... and real_name like 'NEPOOL%REAL%' ... but the JDBC driver with server side prepared statements is doing: select ... from ... where ... and real_name like ? ... So when the statement is prepared, since it doesn't know what values you are going to use in the bind variable, it will generally take a more concervative execution plan than if it knows what the bind variable is. So I suspect the performance difference is just in the different execution plans for the two different forms of the sql statement. thanks, --Barry Bill Chandler wrote: > Thanks, > > Will try this test (I'm assuming you mean to say to > set fetch size of 1 and rerun on both JDBC and > psql). > > BTW, here is another clue: I only get the JDBC > performance degradation when I include the "real_name > like 'NEPOOL%REAL%'" clause. I've tried re-ordering > too: i.e. putting this clause first in the statement, > last in the statement, etc. Doesn't seem to make any > difference. > > real_name is a varchar(64). There is a unique index > on it. > > thanks, > > Bill > > --- Mark Kirkwood wrote: > >>Might be worth doing a little test: >> >>i) modify your code to fetch 1 row at a time >>ii) set log_duration=true in your postgresql.conf >>(as the other posters >>have suggested) >> >>Then compare with running the query in psql. >> >>regards >> >>Mark >> >> >> >>Bill Chandler wrote: >> >> >>>Thanks to all who have responded. I now think my >>>problem is not related to deleting/recreating >> >>indexes. >> >>>Somehow it is related to JDBC cursors. It appears >>>that what is happening is that since I'm using >>>a fetch size of 5000, the command: >>> >>>FETCH FORWARD 5000 FROM JDBC_CURS_1 >>> >>>is being repeatedly sent to the server as I process >>>the result set from my query. Each time this >> >>command >> >>>is sent it it takes about 5 minutes to return which >> >>is >> >>>about the amount of time the whole query took to >>>complete before the performance degredation. So in >>>other words it looks as if the full select is being >>>rerun on each fetch. >>> >>>Now the mystery is why is this happening all of the >>>sudden? I have been running w/ fetch size set to >> >>5000 >> >>>for the last couple of weeks and it did not appear >> >>to >> >>>be doing this (i.e. re-running the entire select >>>statement again). Is this what I should expect >> >>when >> >>>using cursors? I would have thought that the >> >>server >> >>>should "remember" where it left off in the query >> >>since >> >>>the last fetch and continue from there. >>> >>>Could I have inadvertently changed a parameter >>>somewhere that would cause this behavior? >>> >>>thanks, >>> >>>Bill >>> >>>__________________________________________________ >>>Do You Yahoo!? >>>Tired of spam? Yahoo! Mail has the best spam >> >>protection around >> >>>http://mail.yahoo.com >>> >>>---------------------------(end of >> >>broadcast)--------------------------- >> >>>TIP 8: explain analyze is your friend >>> >>> >> >>---------------------------(end of >>broadcast)--------------------------- >>TIP 5: Have you checked our extensive FAQ? >> >> >>http://www.postgresql.org/docs/faqs/FAQ.html >> > > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail - 50x more storage than other providers! > http://promotions.yahoo.com/new_mail > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-jdbc-owner@postgresql.org Mon Jul 12 18:21:21 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 038C8D1B267 for ; Mon, 12 Jul 2004 18:20:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53035-09 for ; Mon, 12 Jul 2004 21:20:16 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 9FF3ED1B20E for ; Mon, 12 Jul 2004 18:20:07 -0300 (ADT) Received: (qmail 21768 invoked by uid 1112); 12 Jul 2004 21:11:53 -0000 Date: Mon, 12 Jul 2004 16:11:53 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Barry Lind Cc: Bill Chandler , Mark Kirkwood , pgsql-jdbc@postgresql.org, pgsql-perform@postgresql.org Subject: Re: [PERFORM] Cursors performance In-Reply-To: <40F2FD08.7020106@xythos.com> Message-ID: References: <20040712180730.37055.qmail@web51407.mail.yahoo.com> <40F2FD08.7020106@xythos.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/116 X-Sequence-Number: 10500 On Mon, 12 Jul 2004, Barry Lind wrote: > Bill, > > I suspect that this is an artifact of using server side prepared > statements. When testing this via psql you will be forming sql like: I don't think so. The 7.4 driver can use either cursors or server prepared statements, not both. He's definitely using cursors, so I server prepared statements don't come into the mix here. Kris Jurka From pgsql-performance-owner@postgresql.org Mon Jul 12 20:54:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 168B5D1B2A6 for ; Mon, 12 Jul 2004 20:54:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11042-09 for ; Mon, 12 Jul 2004 23:54:09 +0000 (GMT) Received: from ecintweb.eldocomp.com (smtp.eldocomp.com [205.159.99.8]) by svr1.postgresql.org (Postfix) with ESMTP id 6F20CD1B2A4 for ; Mon, 12 Jul 2004 20:54:05 -0300 (ADT) Received: by ecintweb.eldocomp.com with XWall v3.29f ; Mon, 12 Jul 2004 16:54:08 -0700 From: Joel McGraw To: Rod Taylor Cc: "pgsql-performance@postgresql.org" Subject: Re: query plan wierdness? Date: Mon, 12 Jul 2004 16:54:07 -0700 X-Assembled-By: XWall v3.29f Message-ID: <7B3E33EF2A10A84185E3667F6B9A1B781A068A@ECIEXCHANGE.eldocomp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=EXCUSE_16, LINES_OF_YELLING X-Spam-Level: X-Archive-Number: 200407/67 X-Sequence-Number: 7458 >=20 > Considering you're pulling out 450k rows in 8 seconds, I'd also guess > the data is mostly in memory. Is that normal? Or is this a result of > having run several test queries against the same data multiple times? >=20 Ah yes, that would have been the result of running the query several times... Oddly enough, I put the same database on a different machine, and the query now behaves as I hoped all along. Notice that I'm using the "real" query, with the aspid in asc and the other fields in desc order, yet the query does use the call_idx13 index: csitech=3D# explain analyse select * from call where aspid=3D'123C' and OpenedDateTime between '2000-01-01 00:00:00.0' and '2004-06-24 23:59:59.999' order by aspid, openeddatetime desc, callstatus desc, calltype desc, callkey desc; =20 QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20 ------------------------------------------------------------------------ ------------------------------------------------------------------------ ---------------------------------------------------------- Sort (cost=3D60.01..60.05 rows=3D14 width=3D696) (actual time=3D42393.56..43381.85 rows=3D510705 loops=3D1) Sort Key: aspid, openeddatetime, callstatus, calltype, callkey -> Index Scan using call_idx13 on call (cost=3D0.00..59.74 rows=3D14 width=3D696) (actual time=3D0.33..19679.01 rows=3D510705 loops=3D1) Index Cond: ((aspid =3D '123C'::bpchar) AND (openeddatetime >=3D '2000-01-01 00:00:00-07'::timestamp with time zone) AND (openeddatetime <=3D '2004-06-24 23:59:59.999-07'::timestamp with time zone)) Total runtime: 43602.05 msec FWIW, this is different hardware (Solaris 9/Sparc), but the same version of Postgres (7.3.4). The data is a superset of the data in the other database (they are both snapshots taken from production). I dropped and recreated the index on the other (Linux) machine, ran vacuum analyse, then tried the query again. It still performs a sequence scan on the call table. :( >=20 > Any chance you could put together a test case demonstrating the above > behaviour? Everything from CREATE TABLE, through dataload to the EXPLAIN > ANALYZE. Forgive me for being thick: what exactly would be involved? Due to HIPAA regulations, I cannot "expose" any of the data. I hesitated to bring this up because I wanted to focus on the technical issues rather than have this degenerate into a religious war. The chief developer in charge of the project brought this query to my attention. He has a fair amount of political sway in the company, and is now lobbying to switch to MySQL because he maintains that PostgreSQL is broken and/or too slow for our needs. He has apparently benchmarked the same query using MySQL and gotten much more favorable results (I have been unable to corroborate this yet). -Joel -- CONFIDENTIALITY NOTICE -- This message is intended for the sole use of the individual and entity to w= hom it is addressed, and may contain information that is privileged, confid= ential and exempt from disclosure under applicable law. If you are not the = intended addressee, nor authorized to receive for the intended addressee, y= ou are hereby notified that you may not use, copy, disclose or distribute t= o anyone the message or any information contained in the message. If you ha= ve received this message in error, please immediately advise the sender by = reply email, and delete the message. Thank you. From pgsql-performance-owner@postgresql.org Mon Jul 12 23:11:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0964ED1B1A0 for ; Mon, 12 Jul 2004 23:10:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54846-10 for ; Tue, 13 Jul 2004 02:10:43 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9A7BBD1B174 for ; Mon, 12 Jul 2004 23:10:38 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id D2F7776AEF; Mon, 12 Jul 2004 22:06:41 -0400 (EDT) Subject: Re: query plan wierdness? From: Rod Taylor To: Joel McGraw Cc: "pgsql-performance@postgresql.org" In-Reply-To: <7B3E33EF2A10A84185E3667F6B9A1B781A068A@ECIEXCHANGE.eldocomp.com> References: <7B3E33EF2A10A84185E3667F6B9A1B781A068A@ECIEXCHANGE.eldocomp.com> Content-Type: text/plain Message-Id: <1089682228.44991.20.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 12 Jul 2004 22:06:42 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/68 X-Sequence-Number: 7459 > Oddly enough, I put the same database on a different machine, and the > query now behaves as I hoped all along. Notice that I'm using the > "real" query, with the aspid in asc and the other fields in desc order, > yet the query does use the call_idx13 index: Notice that while it only takes 19 seconds to pull the data out of the table, it is spending 30 seconds sorting it -- so the index scan isn't buying you very much. Try it again with ORDER BY ascid DESC and you should get the query down to 20 seconds in total on that Sparc; so I wouldn't call it exactly what you wanted. he decision about whether to use an index or not, is borderline. And as you've shown they take approximately the same amount of time. Use of an index will not necessarily be faster than a sequential scan -- but the penalty for accidentally selecting one when it shouldn't have is much higher. > > Any chance you could put together a test case demonstrating the above > > behaviour? Everything from CREATE TABLE, through dataload to the > EXPLAIN > > ANALYZE. > > > Forgive me for being thick: what exactly would be involved? Due to > HIPAA regulations, I cannot "expose" any of the data. Of course. But that doesn't mean you couldn't create table different name and muck around with the values. But you're getting what you want, so it isn't a problem anymore. > > I hesitated to bring this up because I wanted to focus on the technical > issues rather than have this degenerate into a religious war. The chief > developer in charge of the project brought this query to my attention. > He has a fair amount of political sway in the company, and is now > lobbying to switch to MySQL because he maintains that PostgreSQL is > broken and/or too slow for our needs. He has apparently benchmarked the > same query using MySQL and gotten much more favorable results (I have > been unable to corroborate this yet). > I wouldn't be surprised if MySQL did run this single query faster with nothing else going on during that time. MySQL was designed primarily with a single user in mind, but it is unlikely this will be your production situation so the benchmark is next to useless. Connect 50 clients to the databases running this (and a mixture of other selects) while another 20 clients are firing off updates, inserts, deletes on these and other structures -- or whatever matches your full production load. This is what PostgreSQL (and a number of other DBs) are designed for, typical production loads. From pgsql-performance-owner@postgresql.org Tue Jul 13 02:54:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6A29ED1B198 for ; Tue, 13 Jul 2004 02:51:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33112-03 for ; Tue, 13 Jul 2004 05:51:37 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.201]) by svr1.postgresql.org (Postfix) with SMTP id D389BD1B181 for ; Tue, 13 Jul 2004 02:51:29 -0300 (ADT) Received: by mproxy.gmail.com with SMTP id 73so337085rne for ; Mon, 12 Jul 2004 22:51:27 -0700 (PDT) Received: by 10.38.90.5 with SMTP id n5mr500241rnb; Mon, 12 Jul 2004 22:51:27 -0700 (PDT) Message-ID: Date: Mon, 12 Jul 2004 22:51:27 -0700 From: Chris Cheston To: pgsql-performance@postgresql.org Subject: How to create an index for type timestamp column using rtree? Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/69 X-Sequence-Number: 7460 Hi all, I'm storing some timestamps as integers (UTF) in a table and I want to query by <= and >= for times between a certain period. The table has gotten quite large and is now very slow in querying. I think it's time to create an index for the timestamp column. I tried using an rtree (for <= and >= optimization): create INDEX logs_timestamp ON logs using rtree (timestamp); but I get ERROR: data type integer has no default operator class for access method "rtree" You must specify an operator class for the index or define a default operator class for the data type Do I have to create an rtree type for my timestamp integer column? Existing rtree columns are below. Pls help. Thanks, Chris server=> select am.amname as acc_method, opc.opcname as ops_name from pg_am am, pg_opclass opc where opc.opcamid = am.oid order by acc_method, ops_name; acc_method | ops_name ------------+----------------- btree | abstime_ops btree | bit_ops btree | bool_ops btree | bpchar_ops btree | bytea_ops btree | char_ops btree | cidr_ops btree | date_ops btree | float4_ops btree | float8_ops btree | inet_ops btree | int2_ops btree | int4_ops btree | int8_ops btree | interval_ops btree | macaddr_ops btree | name_ops btree | numeric_ops btree | oid_ops btree | oidvector_ops btree | text_ops btree | time_ops btree | timestamp_ops btree | timestamptz_ops btree | timetz_ops btree | varbit_ops btree | varchar_ops hash | bpchar_ops hash | char_ops hash | cidr_ops hash | date_ops hash | float4_ops hash | float8_ops hash | inet_ops hash | int2_ops hash | int4_ops hash | int8_ops hash | interval_ops hash | macaddr_ops hash | name_ops hash | oid_ops hash | oidvector_ops hash | text_ops hash | time_ops hash | timestamp_ops hash | timestamptz_ops hash | timetz_ops hash | varchar_ops rtree | bigbox_ops rtree | box_ops rtree | poly_ops (51 rows) From pgsql-performance-owner@postgresql.org Tue Jul 13 03:25:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2E0CAD1B1A0 for ; Tue, 13 Jul 2004 03:25:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44313-05 for ; Tue, 13 Jul 2004 06:25:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5B16CD1B19B for ; Tue, 13 Jul 2004 03:24:53 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6D6Evwg011801; Tue, 13 Jul 2004 02:14:58 -0400 (EDT) To: Chris Cheston Cc: pgsql-performance@postgresql.org Subject: Re: How to create an index for type timestamp column using rtree? In-reply-to: References: Comments: In-reply-to Chris Cheston message dated "Mon, 12 Jul 2004 22:51:27 -0700" Date: Tue, 13 Jul 2004 02:14:57 -0400 Message-ID: <11800.1089699297@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/70 X-Sequence-Number: 7461 Chris Cheston writes: > I'm storing some timestamps as integers (UTF) in a table and I want to > query by <= and >= for times between a certain period. btree can handle range queries nicely; why do you think you need an rtree? rtree is for 2-dimensional datums which a timestamp is not ... regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jul 13 03:31:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD673D1B1AB for ; Tue, 13 Jul 2004 03:31:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44312-08 for ; Tue, 13 Jul 2004 06:31:40 +0000 (GMT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id B2499D1B18E for ; Tue, 13 Jul 2004 03:31:31 -0300 (ADT) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i6D6QVbP017563; Tue, 13 Jul 2004 14:26:31 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <40F3824C.8090607@familyhealth.com.au> Date: Tue, 13 Jul 2004 14:33:48 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Chris Cheston Cc: pgsql-performance@postgresql.org Subject: Re: How to create an index for type timestamp column using References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/71 X-Sequence-Number: 7462 > I'm storing some timestamps as integers (UTF) in a table and I want to > query by <= and >= for times between a certain period. The table has > gotten quite large and is now very slow in querying. > > I think it's time to create an index for the timestamp column. Uh, yeah. > I tried using an rtree (for <= and >= optimization): Bad idea. > Do I have to create an rtree type for my timestamp integer column? Why do you want an rtree index? They're for multidimensional polygonal data and stuff. Just create a normal index... Chris From pgsql-performance-owner@postgresql.org Tue Jul 13 04:56:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C516DD1B1B0 for ; Tue, 13 Jul 2004 04:56:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79534-03 for ; Tue, 13 Jul 2004 07:56:06 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) by svr1.postgresql.org (Postfix) with SMTP id DD82DD1B18E for ; Tue, 13 Jul 2004 04:55:55 -0300 (ADT) Received: by mproxy.gmail.com with SMTP id 72so17986rnf for ; Tue, 13 Jul 2004 00:56:03 -0700 (PDT) Received: by 10.38.163.20 with SMTP id l20mr350761rne; Tue, 13 Jul 2004 00:56:02 -0700 (PDT) Message-ID: Date: Tue, 13 Jul 2004 00:56:02 -0700 From: Chris Cheston To: pgsql-performance@postgresql.org Subject: Re: How to create an index for type timestamp column using rtree? In-Reply-To: <40F3824C.8090607@familyhealth.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <40F3824C.8090607@familyhealth.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/72 X-Sequence-Number: 7463 Thanks, Chris and Tom. I had read *incorrectly* that rtrees are better for <= and >= comparisons. Chris On Tue, 13 Jul 2004 14:33:48 +0800, Christopher Kings-Lynne wrote: > > I'm storing some timestamps as integers (UTF) in a table and I want to > > query by <= and >= for times between a certain period. The table has > > gotten quite large and is now very slow in querying. > > > > I think it's time to create an index for the timestamp column. > > Uh, yeah. > > > I tried using an rtree (for <= and >= optimization): > > Bad idea. > > > Do I have to create an rtree type for my timestamp integer column? > > Why do you want an rtree index? They're for multidimensional polygonal > data and stuff. Just create a normal index... > > Chris > > From pgsql-jdbc-owner@postgresql.org Tue Jul 13 13:13:59 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7D3CFD1B34F for ; Tue, 13 Jul 2004 13:13:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22874-03 for ; Tue, 13 Jul 2004 16:13:48 +0000 (GMT) Received: from web51404.mail.yahoo.com (web51404.mail.yahoo.com [206.190.38.183]) by svr1.postgresql.org (Postfix) with SMTP id D5D3ED1B170 for ; Tue, 13 Jul 2004 13:13:46 -0300 (ADT) Message-ID: <20040713161346.62000.qmail@web51404.mail.yahoo.com> Received: from [192.88.67.254] by web51404.mail.yahoo.com via HTTP; Tue, 13 Jul 2004 09:13:46 PDT Date: Tue, 13 Jul 2004 09:13:46 -0700 (PDT) From: Bill Chandler Subject: Re: [PERFORM] Cursors performance To: Kris Jurka Cc: pgsql-jdbc@postgresql.org, pgsql-perform@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200407/129 X-Sequence-Number: 10513 All, Looks like I may have beaten this one to death. May have to chalk it up to a limitation for now due to deadlines and revisit it later. One final clue before I go: if I change my wildcard to 'NEPOOL%' from 'NEPOOL%REAL%' my query completes much faster. Of course this makes sense since it's much easier to search a string for a prefix than it is to do a complex regular expression match. I just didn't expect it to be orders of magnitude difference. The table containing the string being searched is only 7500 rows but I am joining it with a table with 2.5 million rows. So maybe there's something I can do to do the wildcard search on the smaller table first then do the join. Ok, thanks again to all who responded. Really appreciate the tips on logging statements and duration, etc. regards, Bill --- Kris Jurka wrote: > > > On Mon, 12 Jul 2004, Barry Lind wrote: > > > Bill, > > > > I suspect that this is an artifact of using server > side prepared > > statements. When testing this via psql you will > be forming sql like: > > I don't think so. The 7.4 driver can use either > cursors or server > prepared statements, not both. He's definitely > using cursors, so I server > prepared statements don't come into the mix here. > > Kris Jurka > > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to > majordomo@postgresql.org > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail From pgsql-performance-owner@postgresql.org Tue Jul 13 13:51:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 31795D1B342 for ; Tue, 13 Jul 2004 13:51:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39091-10 for ; Tue, 13 Jul 2004 16:50:55 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id C7D30D1B23E for ; Tue, 13 Jul 2004 13:50:53 -0300 (ADT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id 727B0EC0BA for ; Tue, 13 Jul 2004 17:54:10 +0200 (CEST) Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 5B64EEC0AA for ; Tue, 13 Jul 2004 17:54:10 +0200 (CEST) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: pgsql-performance@postgresql.org Subject: Insert are going slower ... Date: Tue, 13 Jul 2004 18:50:52 +0200 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Message-Id: <200407131850.52095.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/73 X-Sequence-Number: 7464 Hi, I have a database with 10 tables having about 50 000 000 records ... Every day I have to delete about 20 000 records, inserting about the same in one of this table. Then I make some agregations inside the other tables to get some week results, and globals result by users. That mean about 180 000 to 300 000 insert by table each days. The time for the calculation of the request is about 2 / 4 minutes ... I do the request inside a temporary table ... then I do an insert into my_table select * from temp_table. And that's the point, the INSERT take about (depending of the tables) 41 minutes up to 2 hours ... only for 180 to 300 000 INSERTs ... The table have index really usefull ... so please do not tell me to delete some of them ... and I can't drop them before inserting data ... it's really too long to regenerate them ... I'm configured with no flush, I have 8 Gb of RAM, and RAID 5 with SCSI 7200 harddrive ... I'm using Linux Debian, with a PostgreSQL version compiled by myself in 7.4.3. What can I do to get better results ?? (configuration option, and/or hardware update ?) What can I give you to get more important informations to help me ? Regards, -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-jdbc-owner@postgresql.org Tue Jul 13 14:09:02 2004 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F35F2D1B1CB for ; Tue, 13 Jul 2004 14:08:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50191-02 for ; Tue, 13 Jul 2004 17:08:58 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9D87CD1B1A5 for ; Tue, 13 Jul 2004 14:08:57 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6DH8vVQ016995; Tue, 13 Jul 2004 13:08:57 -0400 (EDT) To: Bill Chandler Cc: Kris Jurka , pgsql-jdbc@postgresql.org, pgsql-perform@postgresql.org Subject: Re: [PERFORM] Cursors performance In-reply-to: <20040713161346.62000.qmail@web51404.mail.yahoo.com> References: <20040713161346.62000.qmail@web51404.mail.yahoo.com> Comments: In-reply-to Bill Chandler message dated "Tue, 13 Jul 2004 09:13:46 -0700" Date: Tue, 13 Jul 2004 13:08:57 -0400 Message-ID: <16994.1089738537@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=MAILTO_TO_SPAM_ADDR X-Spam-Level: * X-Archive-Number: 200407/133 X-Sequence-Number: 10517 Bill Chandler writes: > One final clue before I go: if I change my wildcard to > 'NEPOOL%' from 'NEPOOL%REAL%' my query completes much > faster. Could we see the exact queries and EXPLAIN ANALYZE output for both cases? I'm wondering if the plan changes. I think that the planner will believe that the latter pattern is significantly more selective (how much more selective depends on exactly which PG version you're using); if this results in a bad row-count estimate then a bad plan could get picked. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Jul 13 14:10:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC2B4D1B170 for ; Tue, 13 Jul 2004 14:10:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48689-05 for ; Tue, 13 Jul 2004 17:10:25 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 54973D1B1B0 for ; Tue, 13 Jul 2004 14:10:24 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5742686; Tue, 13 Jul 2004 10:11:34 -0700 Content-Type: text/plain; charset="iso-8859-15" From: Josh Berkus Organization: Aglio Database Solutions To: =?iso-8859-15?q?Herv=E9=20Piedvache?= , pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... Date: Tue, 13 Jul 2004 10:10:30 -0700 User-Agent: KMail/1.4.3 References: <200407131850.52095.herve@elma.fr> In-Reply-To: <200407131850.52095.herve@elma.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200407131010.30790.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/74 X-Sequence-Number: 7465 Herve, > What can I do to get better results ?? (configuration option, and/or > hardware update ?) > What can I give you to get more important informations to help me ? 1) What PostgreSQL version are you using? 2) What's your VACUUM, ANALYZE, VACUUM FULL, REINDEX schedule? 3) Can you list the non-default settings in your PostgreSQL.conf? Particularly, shared_buffers, sort_mem, checkpoint_segments, estimated_cache, and max_fsm_pages? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Jul 13 17:28:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1FD35D1B1D0 for ; Tue, 13 Jul 2004 17:28:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50714-05 for ; Tue, 13 Jul 2004 20:28:32 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id 4DBC7D1B18E for ; Tue, 13 Jul 2004 17:28:27 -0300 (ADT) Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=[192.168.0.66]) by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) id 1BkTt2-000MGB-Lv; Tue, 13 Jul 2004 16:28:24 -0400 Message-ID: <40F44561.2060909@zeut.net> Date: Tue, 13 Jul 2004 16:26:09 -0400 From: "Matthew T. O'Connor" User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jim.ewert@excite.com Cc: pgsql-performance@postgresql.org Subject: Re: Swapping in 7.4.3 References: <20040712165905.940A7395A@xprdmailfe9.nwk.excite.com> In-Reply-To: <20040712165905.940A7395A@xprdmailfe9.nwk.excite.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 67.80.199.173 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/78 X-Sequence-Number: 7469 Jim Ewert wrote: > When I went to 7.4.3 (Slackware 9.1) w/ JDBC, the improvements are that it doesn't initially take much memory (have 512M) and didn't swap. I ran a full vaccum and a cluster before installation, however speed degaded to 1 *second* / update of one row in 150 rows of data, within a day! pg_autovacuum now gives excellent performance however it is taking 66M of swap; only 270k cached. > Are you saying that your system stays fast now that you are using pg_autovacuum, but pg_autovacuum is using 66M of memory? Please clarify, I'm not sure what question you want an answered. Matthew From pgsql-performance-owner@postgresql.org Tue Jul 13 20:42:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1B679D1B1A0 for ; Tue, 13 Jul 2004 20:42:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29577-03 for ; Tue, 13 Jul 2004 23:42:16 +0000 (GMT) Received: from mx.noos.fr (pm-mx6.mgn.net [195.46.220.208]) by svr1.postgresql.org (Postfix) with ESMTP id 1B820D1B198 for ; Tue, 13 Jul 2004 20:42:11 -0300 (ADT) Received: from noos.fr (pm-mnet6.mgn.net [195.46.220.215]) by mx.noos.fr (Postfix) with SMTP id 1009927576; Wed, 14 Jul 2004 01:42:13 +0200 (MEST) X-Mailbox-Line: From footcow@noos.fr Wed Jul 14 01:42:12 2004 Received: from e115.dhcp212-198-145.noos.fr (e115.dhcp212-198-145.noos.fr [212.198.145.115]) by pm-mnet6.mgn.net with ESMTP; Wed, 14 Jul 2004 01:42:12 (MEST) From: =?iso-8859-15?q?Herv=E9_Piedvache?= To: pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... Date: Wed, 14 Jul 2004 01:42:11 +0200 User-Agent: KMail/1.6.2 Cc: Josh Berkus , =?iso-8859-15?q?Herv=E9_Piedvache?= References: <200407131850.52095.herve@elma.fr> <200407131010.30790.josh@agliodbs.com> In-Reply-To: <200407131010.30790.josh@agliodbs.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Message-Id: <200407140142.11720.footcow@noos.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=LINES_OF_YELLING, RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/79 X-Sequence-Number: 7470 Josh, Le mardi 13 Juillet 2004 19:10, Josh Berkus a =E9crit : > > > What can I do to get better results ?? (configuration option, and/or > > hardware update ?) > > What can I give you to get more important informations to help me ? > > 1) What PostgreSQL version are you using? v7.4.3 > 2) What's your VACUUM, ANALYZE, VACUUM FULL, REINDEX schedule? VACUUM FULL VERBOSE ANALYZE; Every day after the calculation I was talking about ... > 3) Can you list the non-default settings in your PostgreSQL.conf? > Particularly, shared_buffers, sort_mem, checkpoint_segments, > estimated_cache, and max_fsm_pages? shared_buffers =3D 48828 sort_mem =3D 512000 vacuum_mem =3D 409600 max_fsm_pages =3D 50000000 max_fsm_relations =3D 2000 max_files_per_process =3D 2000 wal_buffers =3D 1000 checkpoint_segments =3D 3 effective_cache_size =3D 5000000 random_page_cost =3D 3=09 default_statistics_target =3D 20 join_collapse_limit =3D 10 Regards, --=20 Herv=E9 Piedvache From pgsql-performance-owner@postgresql.org Wed Jul 14 07:04:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 10AFBD1B266 for ; Wed, 14 Jul 2004 07:04:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49871-02 for ; Wed, 14 Jul 2004 10:04:04 +0000 (GMT) Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) by svr1.postgresql.org (Postfix) with ESMTP id 0B20ED1B26C for ; Wed, 14 Jul 2004 07:03:55 -0300 (ADT) Received: from wp2000 ([157.157.176.72] [157.157.176.72]) by quasar.skima.is; Wed, 14 Jul 2004 10:04:02 Z Message-Id: <003901c4698a$2cfb5a50$0100000a@wp2000> From: "gnari" To: References: <200407131850.52095.herve@elma.fr> <200407131010.30790.josh@agliodbs.com> <200407140142.11720.footcow@noos.fr> Subject: Re: Insert are going slower ... Date: Wed, 14 Jul 2004 10:06:05 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/80 X-Sequence-Number: 7471 From: "Herv� Piedvache" Sent: Tuesday, July 13, 2004 11:42 PM > effective_cache_size = 5000000 looks like madness to me. my (modest) understanding of this, is that you are telling postgres to assume a 40Gb disk cache (correct me if I am wrong). btw, how much effect does this setting have on the planner? is there a recommended procedure to estimate the best value for effective_cache_size on a dedicated DB server ? gnari From pgsql-performance-owner@postgresql.org Wed Jul 14 07:13:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4DC4ED1B23C for ; Wed, 14 Jul 2004 07:13:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52017-06 for ; Wed, 14 Jul 2004 10:13:30 +0000 (GMT) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 1B73DD1B1BC for ; Wed, 14 Jul 2004 07:13:23 -0300 (ADT) Received: from gateway.pspl.co.in ([203.199.147.2]:3521 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.34 #0) id 1BkglU-0005Vn-KY by authid with plain; Wed, 14 Jul 2004 15:43:29 +0530 Message-ID: <40F50742.1000007@frodo.hserus.net> Date: Wed, 14 Jul 2004 15:43:22 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gnari Cc: pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... References: <200407131850.52095.herve@elma.fr> <200407131010.30790.josh@agliodbs.com> <200407140142.11720.footcow@noos.fr> <003901c4698a$2cfb5a50$0100000a@wp2000> In-Reply-To: <003901c4698a$2cfb5a50$0100000a@wp2000> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/81 X-Sequence-Number: 7472 gnari wrote: > is there a recommended procedure to estimate > the best value for effective_cache_size on a > dedicated DB server ? Rule of thumb(On linux): on a typically loaded machine, observe cache memory of the machine and allocate good chunk of it as effective cache. To define good chunck of it, you need to consider how many other things are running on that machine. If it is file server + web server + database server, you have to allocate the resources depending upon requirement. But remember It does not guarantee that it will be a good value. It is just a starting point..:-) You have to tune it further if required. HTH Shridhar From pgsql-performance-owner@postgresql.org Wed Jul 14 11:08:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA250D1B19C for ; Wed, 14 Jul 2004 11:08:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45905-10 for ; Wed, 14 Jul 2004 14:08:28 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id E3F9AD1B19B for ; Wed, 14 Jul 2004 11:08:18 -0300 (ADT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id CCD4EEC11F; Wed, 14 Jul 2004 15:11:43 +0200 (CEST) Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 9EE87EC00F; Wed, 14 Jul 2004 15:11:43 +0200 (CEST) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... Date: Wed, 14 Jul 2004 16:08:27 +0200 User-Agent: KMail/1.6.2 Cc: Shridhar Daithankar , gnari References: <200407131850.52095.herve@elma.fr> <003901c4698a$2cfb5a50$0100000a@wp2000> <40F50742.1000007@frodo.hserus.net> In-Reply-To: <40F50742.1000007@frodo.hserus.net> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Message-Id: <200407141608.27116.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/82 X-Sequence-Number: 7473 Le mercredi 14 Juillet 2004 12:13, Shridhar Daithankar a �crit : > gnari wrote: > > is there a recommended procedure to estimate > > the best value for effective_cache_size on a > > dedicated DB server ? > > Rule of thumb(On linux): on a typically loaded machine, observe cache > memory of the machine and allocate good chunk of it as effective cache. > > To define good chunck of it, you need to consider how many other things are > running on that machine. If it is file server + web server + database > server, you have to allocate the resources depending upon requirement. > > But remember It does not guarantee that it will be a good value. It is just > a starting point..:-) You have to tune it further if required. In my case it's a PostgreSQL dedicated server ... effective_cache_size = 5000000 For me I give to the planner the information that the kernel is able to cache 5000000 disk page in RAM >free total used free shared buffers cached Mem: 7959120 7712164 246956 0 17372 7165704 -/+ buffers/cache: 529088 7430032 Swap: 2097136 9880 2087256 What should I put ? Regards, -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Wed Jul 14 11:32:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 85108D1B19B for ; Wed, 14 Jul 2004 11:32:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59875-05 for ; Wed, 14 Jul 2004 14:32:50 +0000 (GMT) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 67CF6D1B17B for ; Wed, 14 Jul 2004 11:32:41 -0300 (ADT) Received: from gateway.pspl.co.in ([203.199.147.2]:1774 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.34 #0) id 1BkkoU-0007yL-QE by authid with plain; Wed, 14 Jul 2004 20:02:51 +0530 Message-ID: <40F5440F.7080202@frodo.hserus.net> Date: Wed, 14 Jul 2004 20:02:47 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-15?Q?Herv=E9_Piedvache?= Cc: pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... References: <200407131850.52095.herve@elma.fr> <003901c4698a$2cfb5a50$0100000a@wp2000> <40F50742.1000007@frodo.hserus.net> <200407141608.27116.herve@elma.fr> In-Reply-To: <200407141608.27116.herve@elma.fr> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/83 X-Sequence-Number: 7474 Herv� Piedvache wrote: > In my case it's a PostgreSQL dedicated server ... > > effective_cache_size = 5000000 > > For me I give to the planner the information that the kernel is able to cache > 5000000 disk page in RAM That is what? 38GB of RAM? > > >>free > > total used free shared buffers cached > Mem: 7959120 7712164 246956 0 17372 7165704 > -/+ buffers/cache: 529088 7430032 > Swap: 2097136 9880 2087256 > > What should I put ? 7165704 / 8 = 895713 So counting variations, I would say 875000. That is a 8GB box, right? So 875000 is about 7000MB. Which should be rather practical. Of course you can give it everything you can but that's upto you. Can you get explain analze for inserts? I think some foreign key check etc. are taking long and hence it accumulates. But that is just a wild guess. Off the top of my head, you have allocated roughly 48K shard buffers which seems bit on higher side. Can you check with something like 10K-15K? HTH Shridhar From pgsql-performance-owner@postgresql.org Wed Jul 14 13:41:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6F79BD1B1D9 for ; Wed, 14 Jul 2004 13:41:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16979-04 for ; Wed, 14 Jul 2004 16:41:01 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 821CED1B1AA for ; Wed, 14 Jul 2004 13:40:59 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5752850; Wed, 14 Jul 2004 09:29:43 -0700 Content-Type: text/plain; charset="iso-8859-15" From: Josh Berkus Organization: Aglio Database Solutions To: =?iso-8859-15?q?Herv=E9=20Piedvache?= , pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... Date: Wed, 14 Jul 2004 09:28:29 -0700 User-Agent: KMail/1.4.3 Cc: =?iso-8859-15?q?Herv=E9=20Piedvache?= References: <200407131850.52095.herve@elma.fr> <200407131010.30790.josh@agliodbs.com> <200407140142.11720.footcow@noos.fr> In-Reply-To: <200407140142.11720.footcow@noos.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200407140928.29498.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/84 X-Sequence-Number: 7475 Herve' I forgot to ask about your hardware. How much RAM, and what's your disk setup? CPU? > sort_mem = 512000 Huh? Sort_mem is in K. The above says that you've allocated 512MB sort mem. Is this process the *only* thing going on on the machine? > vacuum_mem = 409600 Again, 409.6MB vacuum mem? That's an odd number, and quite high. > max_fsm_pages = 50000000 50million? That's quite high. Certianly enough to have an effect on your memory usage. How did you calculate this number? > checkpoint_segments = 3 You should probably increase this if you have the disk space. For massive insert operations, I've found it useful to have as much as 128 segments (although this means about 1.5GB disk space) > effective_cache_size = 5000000 If you actually have that much RAM, I'd love to play on your box. Please? > Off the top of my head, you have allocated roughly 48K shard buffers which > seems bit on higher side. Can you check with something like 10K-15K? Shridhar, that depends on how much RAM he has. On 4GB dedicated machines, I've set Shared_Buffers as high as 750MB. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Jul 14 18:19:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D9CCCD1B181 for ; Wed, 14 Jul 2004 18:19:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34849-03 for ; Wed, 14 Jul 2004 21:19:20 +0000 (GMT) Received: from mx.noos.fr (pm-mx4.mgn.net [195.46.220.210]) by svr1.postgresql.org (Postfix) with ESMTP id B6894D1B199 for ; Wed, 14 Jul 2004 18:19:16 -0300 (ADT) Received: from noos.fr (pm-mnet3.mgn.net [195.46.220.218]) by mx.noos.fr (Postfix) with SMTP id 3A8C726C5A; Wed, 14 Jul 2004 23:19:17 +0200 (MEST) X-Mailbox-Line: From footcow@noos.fr Wed Jul 14 23:19:17 2004 Received: from e115.dhcp212-198-145.noos.fr (e115.dhcp212-198-145.noos.fr [212.198.145.115]) by pm-mnet3.mgn.net with ESMTP; Wed, 14 Jul 2004 23:19:17 (MEST) From: =?iso-8859-15?q?Herv=E9_Piedvache?= To: pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... Date: Wed, 14 Jul 2004 23:19:16 +0200 User-Agent: KMail/1.6.2 Cc: Josh Berkus , =?iso-8859-15?q?Herv=E9_Piedvache?= , Shridhar Daithankar References: <200407131850.52095.herve@elma.fr> <200407140142.11720.footcow@noos.fr> <200407140928.29498.josh@agliodbs.com> In-Reply-To: <200407140928.29498.josh@agliodbs.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Message-Id: <200407142319.16607.footcow@noos.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/85 X-Sequence-Number: 7476 Josh, Le mercredi 14 Juillet 2004 18:28, Josh Berkus a =E9crit : > > I forgot to ask about your hardware. How much RAM, and what's your disk > setup? CPU? 8 Gb of RAM Bi - Intel Xeon 2.00GHz Hard drive in SCSI RAID 5 /dev/sdb6 101G 87G 8.7G 91% /usr/local/pgsql/data /dev/sda7 1.8G 129M 1.6G 8% /usr/local/pgsql/data/pg_xlog Server dedicated to PostgreSQL with only one database. > > sort_mem =3D 512000 > > Huh? Sort_mem is in K. The above says that you've allocated 512MB sort > mem. Is this process the *only* thing going on on the machine? PostgreSQL dedicated server yes ... so it's too much ? How you decide the good value ? > > vacuum_mem =3D 409600 > > Again, 409.6MB vacuum mem? That's an odd number, and quite high. Yep but I have 8 Gb of memory ... ;o) So why not ? Just explain me why it's not a good choice ... I have done this because of= =20 this text from you found somewhere : "As this setting only uses RAM when VACUUM is running, you may wish to=20 increase it on high-RAM machines to make VACUUM run faster (but never more= =20 than 20% of available RAM!)" So that's less than 20% of my memory ... > > max_fsm_pages =3D 50000000 > > 50million? That's quite high. Certianly enough to have an effect on > your memory usage. How did you calculate this number? Not done by me ... and the guy is out ... but in same time with 8 Gb of=20 RAM ... that's not a crazy number ? > > checkpoint_segments =3D 3 > > You should probably increase this if you have the disk space. For massive > insert operations, I've found it useful to have as much as 128 segments > (although this means about 1.5GB disk space) > > > effective_cache_size =3D 5000000 > > If you actually have that much RAM, I'd love to play on your box. Please? Hum ... yes as Shridhar told me the number is a crazy one and now down to= =20 875000 ... > > Off the top of my head, you have allocated roughly 48K shard buffers > > which seems bit on higher side. Can you check with something like > > 10K-15K? > > Shridhar, that depends on how much RAM he has. On 4GB dedicated machine= s, > I've set Shared_Buffers as high as 750MB. Could you explain me the interest to reduce this size ?? I really miss understand this point ... regards, --=20 Bill Footcow From pgsql-performance-owner@postgresql.org Wed Jul 14 18:41:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 04A87D1B199 for ; Wed, 14 Jul 2004 18:41:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42295-03 for ; Wed, 14 Jul 2004 21:41:20 +0000 (GMT) Received: from fdd00lnhub.federated.fds (external.fds.com [208.15.90.2]) by svr1.postgresql.org (Postfix) with ESMTP id AA418D1B1A5 for ; Wed, 14 Jul 2004 18:41:16 -0300 (ADT) Subject: vacuum full 100 mins plus? To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 6.0 September 26, 2002 Message-ID: From: Patrick Hatcher Date: Wed, 14 Jul 2004 14:29:48 -0700 X-MIMETrack: Serialize by Router on FDD00LNHUB/FSG/SVR/FDD(Release 6.0|September 26, 2002) at 07/14/2004 05:18:04 PM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/87 X-Sequence-Number: 7478 Should I be concerned that my vacuum process has taken upwards of 100 + minutes to complete? I dropped all indexes before starting and also increased the vacuum_mem before starting. Looking at the output below, it appears that a vacuum full hasn't been done on this table for quite sometime. Would I be better off exporting the data vacuuming the table and reimporting the data? I cannot drop the table do to views attached to the table mdc_oz=# set vacuum_mem = 10240; SET mdc_oz=# vacuum full verbose cdm.cdm_ddw_Tran_item; INFO: vacuuming "cdm.cdm_ddw_tran_item" INFO: "cdm_ddw_tran_item": found 15322404 removable, 10950460 nonremovable row versions in 934724 pages DETAIL: 0 dead row versions cannot be removed yet. Nonremovable row versions range from 233 to 308 bytes long. There were 1081 unused item pointers. Total free space (including removable row versions) is 4474020460 bytes. 544679 pages are or will become empty, including 0 at the end of the table. 692980 pages containing 4433398408 free bytes are potential move destinations. CPU 29.55s/4.13u sec elapsed 107.82 sec. TIA Patrick Hatcher From pgsql-performance-owner@postgresql.org Wed Jul 14 18:32:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7AB07D1B19C for ; Wed, 14 Jul 2004 18:32:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36287-09 for ; Wed, 14 Jul 2004 21:32:06 +0000 (GMT) Received: from mx.noos.fr (pm-mx4.mgn.net [195.46.220.210]) by svr1.postgresql.org (Postfix) with ESMTP id 8651ED1B1A5 for ; Wed, 14 Jul 2004 18:32:03 -0300 (ADT) Received: from noos.fr (pm-mnet3.mgn.net [195.46.220.218]) by mx.noos.fr (Postfix) with SMTP id 5FB1826860; Wed, 14 Jul 2004 23:32:05 +0200 (MEST) X-Mailbox-Line: From footcow@noos.fr Wed Jul 14 23:32:05 2004 Received: from e115.dhcp212-198-145.noos.fr (e115.dhcp212-198-145.noos.fr [212.198.145.115]) by pm-mnet3.mgn.net with ESMTP; Wed, 14 Jul 2004 23:32:05 (MEST) From: =?iso-8859-15?q?Herv=E9_Piedvache?= To: pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... Date: Wed, 14 Jul 2004 23:32:05 +0200 User-Agent: KMail/1.6.2 Cc: Josh Berkus , =?iso-8859-15?q?Herv=E9_Piedvache?= References: <200407131850.52095.herve@elma.fr> <200407140142.11720.footcow@noos.fr> <200407140928.29498.josh@agliodbs.com> In-Reply-To: <200407140928.29498.josh@agliodbs.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Message-Id: <200407142332.05161.footcow@noos.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/86 X-Sequence-Number: 7477 Josh, Le mercredi 14 Juillet 2004 18:28, Josh Berkus a =E9crit : > > > checkpoint_segments =3D 3 > > You should probably increase this if you have the disk space. For massive > insert operations, I've found it useful to have as much as 128 segments > (although this means about 1.5GB disk space) Other point I have also read this :=20 "NOTE: Since 7.2, turning fsync off does NOT stop WAL. It does stop=20 checkpointing." So ... still true for 7.4.3 ??? So I'm with fsync =3D off so the value of= =20 checkpoint_segments have no interest ?? Thanks for your help... --=20 Bill Footcow From pgsql-performance-owner@postgresql.org Wed Jul 14 19:48:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0DDF4D1B198; Wed, 14 Jul 2004 19:48:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66417-06; Wed, 14 Jul 2004 22:48:18 +0000 (GMT) Received: from fdd00lnhub.federated.fds (external.fds.com [208.15.90.2]) by svr1.postgresql.org (Postfix) with ESMTP id F3062D1B181; Wed, 14 Jul 2004 19:48:14 -0300 (ADT) In-Reply-To: Subject: Re: vacuum full 100 mins plus? To: "Patrick Hatcher Cc: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org X-Mailer: Lotus Notes Release 6.0 September 26, 2002 Message-ID: From: Patrick Hatcher Date: Wed, 14 Jul 2004 15:36:46 -0700 X-MIMETrack: Serialize by Router on FDD00LNHUB/FSG/SVR/FDD(Release 6.0|September 26, 2002) at 07/14/2004 06:25:02 PM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.4 tagged_above=0.0 required=5.0 tests=TO_HAS_SPACES X-Spam-Level: ** X-Archive-Number: 200407/88 X-Sequence-Number: 7479 Answered my own question. I gave up the vacuum full after 150 mins. I was able to export to a file, vacuum full the empty table, and reimport in less than 10 mins. I suspect the empty item pointers and the sheer number of removable rows was causing an issue. Patrick Hatcher To Sent by: pgsql-performance@postgresql.org pgsql-performance cc -owner@postgresql .org Subject [PERFORM] vacuum full 100 mins plus? 07/14/2004 02:29 PM Should I be concerned that my vacuum process has taken upwards of 100 + minutes to complete? I dropped all indexes before starting and also increased the vacuum_mem before starting. Looking at the output below, it appears that a vacuum full hasn't been done on this table for quite sometime. Would I be better off exporting the data vacuuming the table and reimporting the data? I cannot drop the table do to views attached to the table mdc_oz=# set vacuum_mem = 10240; SET mdc_oz=# vacuum full verbose cdm.cdm_ddw_Tran_item; INFO: vacuuming "cdm.cdm_ddw_tran_item" INFO: "cdm_ddw_tran_item": found 15322404 removable, 10950460 nonremovable row versions in 934724 pages DETAIL: 0 dead row versions cannot be removed yet. Nonremovable row versions range from 233 to 308 bytes long. There were 1081 unused item pointers. Total free space (including removable row versions) is 4474020460 bytes. 544679 pages are or will become empty, including 0 at the end of the table. 692980 pages containing 4433398408 free bytes are potential move destinations. CPU 29.55s/4.13u sec elapsed 107.82 sec. TIA Patrick Hatcher ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Wed Jul 14 20:11:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 75FDCD1B19B for ; Wed, 14 Jul 2004 20:11:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73858-03 for ; Wed, 14 Jul 2004 23:11:22 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 5E63AD1B199 for ; Wed, 14 Jul 2004 20:11:18 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1BksuG-0006ew-00 for ; Thu, 15 Jul 2004 01:11:20 +0200 Date: Thu, 15 Jul 2004 01:11:20 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Message-ID: <20040714231120.GA25485@uio.no> References: <20040708101913.GA15871@uio.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040708101913.GA15871@uio.no> X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/89 X-Sequence-Number: 7480 On Thu, Jul 08, 2004 at 12:19:13PM +0200, Steinar H. Gunderson wrote: > I'm trying to find out why one of my queries is so slow -- I'm primarily > using PostgreSQL 7.2 (Debian stable), but I don't really get much better > performance with 7.4 (Debian unstable). My prototype table looks like this: I hate to nag, but it's been a week with no reply; did anybody look at this? Is there any more information I can supply to make it easier? /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Wed Jul 14 21:13:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D04E0D1B1CE for ; Wed, 14 Jul 2004 21:13:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93836-04 for ; Thu, 15 Jul 2004 00:12:57 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 644E5D1B1B0 for ; Wed, 14 Jul 2004 21:12:53 -0300 (ADT) Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5756797; Wed, 14 Jul 2004 17:14:08 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Patrick Hatcher Subject: Re: vacuum full 100 mins plus? Date: Wed, 14 Jul 2004 17:13:13 -0700 User-Agent: KMail/1.5.4 Cc: pgsql-performance@postgresql.org References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200407141713.13472.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/90 X-Sequence-Number: 7481 Patrick, > Answered my own question. I gave up the vacuum full after 150 mins. I was > able to export to a file, vacuum full the empty table, and reimport in less > than 10 mins. I suspect the empty item pointers and the sheer number of > removable rows was causing an issue. Yeah. If you've a table that's not been vacuumed in a month, it's often faster to clean it out and import it. I've seen vacuums take up to 3 hours in really bad cases. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Jul 14 22:40:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D3570D1B1B7 for ; Wed, 14 Jul 2004 22:40:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22384-01 for ; Thu, 15 Jul 2004 01:40:46 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 517CED1B16E for ; Wed, 14 Jul 2004 22:40:41 -0300 (ADT) Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5757497; Wed, 14 Jul 2004 18:41:56 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Steinar H. Gunderson" , pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Date: Wed, 14 Jul 2004 18:41:01 -0700 User-Agent: KMail/1.5.4 References: <20040708101913.GA15871@uio.no> In-Reply-To: <20040708101913.GA15871@uio.no> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200407141841.01863.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/91 X-Sequence-Number: 7482 Steinar, > - The "subquery scan o12" phase outputs 1186 rows, yet 83792 are sorted. Where > do the other ~82000 rows come from? And why would it take ~100ms to sort the > rows at all? (In earlier tests, this was _one full second_ but somehow that > seems to have improved, yet without really improving the overall query time. I'm puzzled by the "83792" rows as well. I've a feeling that Explain Analyze is failing to output a step. > - Why does it use uid_index for an index scan on the table, when it obviously > has no filter on it (since it returns all the rows)? In order to support the merge join. It should be a bit faster to do the sort using the index than the actual table. Also, because you pass the <> 0 condition. > Furthermore, why would > this take half a second? (The machine is a 950MHz machine with SCSI disks.) I don't see half a second here. > - Also, the outer sort (the sorting of the 58792 rows from the merge join) > is slow. :-) I don't see a sort after the merge join. Which version are we talking about? I'm looking at the 7.4 version because that outputs more detail. Most of your time is spent in that merge join. Why don't you try doubling sort_mem temporarily to see how it does? Or even raising shared_buffers? -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Jul 15 00:02:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 852B7D1B26C for ; Thu, 15 Jul 2004 00:00:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45296-06 for ; Thu, 15 Jul 2004 03:00:05 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 5210ED1B220 for ; Wed, 14 Jul 2004 23:59:59 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6F303i9001742 for ; Thu, 15 Jul 2004 03:00:04 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6F2pQIb094759 for pgsql-performance@postgresql.org; Thu, 15 Jul 2004 02:51:26 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: vacuum full 100 mins plus? Date: Wed, 14 Jul 2004 22:21:29 -0400 Organization: cbbrowne Computing Inc Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:RuGRZAkgZ9T/9iI/0wzbsxehYhM= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/92 X-Sequence-Number: 7483 A long time ago, in a galaxy far, far away, PHatcher@macys.com (Patrick Hatcher) wrote: > Answered my own question. I gave up the vacuum full after 150 mins. I was > able to export to a file, vacuum full the empty table, and reimport in less > than 10 mins. I suspect the empty item pointers and the sheer number of > removable rows was causing an issue. In that case, you'd be a little further better off if the steps were: - drop indices; - copy table to file (perhaps via pg_dump -t my_table); - truncate the table, or drop-and-recreate, both of which make it unnecessary to do _any_ vacuum of the result; - recreate indices, probably with SORT_MEM set high, to minimize paging to disk - analyze the table (no need to vacuum if you haven't created any dead tuples) - cut SORT_MEM back down to "normal" sizes -- output = reverse("gro.gultn" "@" "enworbbc") http://www3.sympatico.ca/cbbrowne/spreadsheets.html Signs of a Klingon Programmer #6: "Debugging? Klingons do not debug. Our software does not coddle the weak." From pgsql-performance-owner@postgresql.org Thu Jul 15 01:37:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 29E0FD1B174 for ; Thu, 15 Jul 2004 01:36:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77523-08 for ; Thu, 15 Jul 2004 04:36:47 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id F336ED1B18C for ; Thu, 15 Jul 2004 01:36:40 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6F4ahYq016533; Thu, 15 Jul 2004 00:36:43 -0400 (EDT) To: Christopher Browne Cc: pgsql-performance@postgresql.org Subject: Re: vacuum full 100 mins plus? In-reply-to: References: Comments: In-reply-to Christopher Browne message dated "Wed, 14 Jul 2004 22:21:29 -0400" Date: Thu, 15 Jul 2004 00:36:43 -0400 Message-ID: <16532.1089866203@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/93 X-Sequence-Number: 7484 Christopher Browne writes: > A long time ago, in a galaxy far, far away, PHatcher@macys.com (Patrick Hatcher) wrote: >> Answered my own question. I gave up the vacuum full after 150 mins. I was >> able to export to a file, vacuum full the empty table, and reimport in less >> than 10 mins. I suspect the empty item pointers and the sheer number of >> removable rows was causing an issue. > In that case, you'd be a little further better off if the steps were: > - drop indices; > - copy table to file (perhaps via pg_dump -t my_table); > - truncate the table, or drop-and-recreate, both of which make > it unnecessary to do _any_ vacuum of the result; > - recreate indices, probably with SORT_MEM set high, to minimize > paging to disk > - analyze the table (no need to vacuum if you haven't created any > dead tuples) > - cut SORT_MEM back down to "normal" sizes Rather than doing all this manually, you can just CLUSTER on any handy index. In 7.5, another possibility is to issue one of the forms of ALTER TABLE that force a table rewrite. The range of usefulness of VACUUM FULL is really looking narrower and narrower to me. I can foresee a day when we'll abandon it completely. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jul 15 01:53:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AA96FD1B174 for ; Thu, 15 Jul 2004 01:52:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82100-09 for ; Thu, 15 Jul 2004 04:52:49 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id B49ECD1B16E for ; Thu, 15 Jul 2004 01:52:42 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6F4qcJp016638; Thu, 15 Jul 2004 00:52:40 -0400 (EDT) To: josh@agliodbs.com Cc: "Steinar H. Gunderson" , pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour In-reply-to: <200407141841.01863.josh@agliodbs.com> References: <20040708101913.GA15871@uio.no> <200407141841.01863.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 14 Jul 2004 18:41:01 -0700" Date: Thu, 15 Jul 2004 00:52:38 -0400 Message-ID: <16637.1089867158@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/94 X-Sequence-Number: 7485 Josh Berkus writes: >> - The "subquery scan o12" phase outputs 1186 rows, yet 83792 are sorted. > Where >> do the other ~82000 rows come from? > I'm puzzled by the "83792" rows as well. I've a feeling that Explain > Analyze is failing to output a step. No, it's not missing anything. The number being reported here is the number of rows pulled from the plan node --- but this plan node is on the inside of a merge join, and one of the properties of merge join is that it will do partial rescans of its inner input in the presence of equal keys in the outer input. If you have, say, 10 occurrences of "42" in the outer input, then any "42" rows in the inner input have to be rescanned 10 times. EXPLAIN ANALYZE will count each of them as 10 rows returned by the input node. The large multiple here (80-to-one overscan) says that you've got a lot of duplicate values in the outer input. This is generally a good situation to *not* use a mergejoin in ;-). We do have some logic in the planner that attempts to estimate the extra cost involved in such rescanning, but I'm not sure how accurate the cost model is. > Most of your time is spent in that merge join. Why don't you try doubling > sort_mem temporarily to see how it does? Or even raising shared_buffers? Raising shared_buffers seems unlikely to help. I do agree with raising sort_mem --- not so much to make the merge faster as to encourage the thing to try a hash join instead. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jul 15 03:22:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7DEB3D1B18E for ; Thu, 15 Jul 2004 03:22:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11049-04 for ; Thu, 15 Jul 2004 06:22:05 +0000 (GMT) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 25AAED1B199 for ; Thu, 15 Jul 2004 03:21:57 -0300 (ADT) Received: from gateway.pspl.co.in ([203.199.147.2]:2532 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.34 #0) id 1Bkzd3-000Dgc-95 by authid with plain; Thu, 15 Jul 2004 11:52:01 +0530 Message-ID: <40F62284.3090004@frodo.hserus.net> Date: Thu, 15 Jul 2004 11:51:56 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-15?Q?Herv=E9_Piedvache?= Cc: pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... References: <200407131850.52095.herve@elma.fr> <200407140142.11720.footcow@noos.fr> <200407140928.29498.josh@agliodbs.com> <200407142332.05161.footcow@noos.fr> In-Reply-To: <200407142332.05161.footcow@noos.fr> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/95 X-Sequence-Number: 7486 Herv� Piedvache wrote: > Josh, > > Le mercredi 14 Juillet 2004 18:28, Josh Berkus a �crit : > >>>checkpoint_segments = 3 >> >>You should probably increase this if you have the disk space. For massive >>insert operations, I've found it useful to have as much as 128 segments >>(although this means about 1.5GB disk space) > > > Other point I have also read this : > "NOTE: Since 7.2, turning fsync off does NOT stop WAL. It does stop > checkpointing." > > So ... still true for 7.4.3 ??? So I'm with fsync = off so the value of > checkpoint_segments have no interest ?? > > Thanks for your help... I suggest you check this first. Check the performance tuning guide.. http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php That is a starters. As Josh suggested, increase checkpoint segments if you have disk space. Correspondingly WAL disk space requirements go up as well. HTH Shridhar From pgsql-performance-owner@postgresql.org Fri Jul 16 15:37:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A6E1D1B26D for ; Thu, 15 Jul 2004 07:30:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98037-10 for ; Thu, 15 Jul 2004 10:30:06 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 6C7CAD1B241 for ; Thu, 15 Jul 2004 07:29:58 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6FAU3i7022756 for ; Thu, 15 Jul 2004 10:30:03 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6FAOUDc021554 for pgsql-performance@postgresql.org; Thu, 15 Jul 2004 10:24:30 GMT From: Stefan X-Newsgroups: comp.databases.postgresql.performance Subject: extrem bad performance Date: Thu, 15 Jul 2004 12:24:10 +0200 Organization: Hub.Org Networking Services Lines: 28 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=FORGED_YAHOO_RCVD X-Spam-Level: X-Archive-Number: 200407/109 X-Sequence-Number: 7500 Hi, I operate a database server with postgres 7.3.2, 2 Xeon CPU's and 1 GB Ram. The database-files reside on a local SCSI-HD, the system runs on SuSE Enterprise Server 8.0. The size of the dumped database is about 300 MB, the database is vacuumed (-a -z) every night an reindexed every week. The database server is used by a lamp applicationsserver over a 100 MBit Network. My Problem is, that the DB-Server is unbelievable slow! I monitor the database with top. When a (small) query is executed, I see the postmaster task for 2-3 seconds with 80-100 % CPU load. On other systems with the same database but less CPU and RAM power, I see the task for one moment with 2-8 % CPU load. The other systems behave normal the speed is ok. Also a restart of the postmaster brings no improvement. The database grows very slowly. The main load comes from SELECT's and not from INSERT's or UPDATE's, but the performance gets slower day by day... I have no idea where to search for the speed break! Stefan From pgsql-performance-owner@postgresql.org Thu Jul 15 09:08:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F193D1B281 for ; Thu, 15 Jul 2004 09:08:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34524-06 for ; Thu, 15 Jul 2004 12:08:56 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 431BFD1B269 for ; Thu, 15 Jul 2004 09:08:46 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1Bl52k-000890-00 for ; Thu, 15 Jul 2004 14:08:54 +0200 Date: Thu, 15 Jul 2004 14:08:54 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Message-ID: <20040715120854.GA31259@uio.no> References: <20040708101913.GA15871@uio.no> <200407141841.01863.josh@agliodbs.com> <16637.1089867158@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16637.1089867158@sss.pgh.pa.us> X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/96 X-Sequence-Number: 7487 On Thu, Jul 15, 2004 at 12:52:38AM -0400, Tom Lane wrote: > No, it's not missing anything. The number being reported here is the > number of rows pulled from the plan node --- but this plan node is on > the inside of a merge join, and one of the properties of merge join is > that it will do partial rescans of its inner input in the presence of > equal keys in the outer input. If you have, say, 10 occurrences of > "42" in the outer input, then any "42" rows in the inner input have to > be rescanned 10 times. EXPLAIN ANALYZE will count each of them as 10 > rows returned by the input node. OK, that makes sense, although it seems to me as is loops= should have been something larger than 1 if the data was scanned multiple times. > The large multiple here (80-to-one overscan) says that you've got a lot > of duplicate values in the outer input. This is generally a good > situation to *not* use a mergejoin in ;-). We do have some logic in the > planner that attempts to estimate the extra cost involved in such > rescanning, but I'm not sure how accurate the cost model is. Hum, I'm not sure if I'm in the termiology here -- "outer input" in "A left join B" is A, right? But yes, I do have a lot of duplicates, that seems to match my data well. > Raising shared_buffers seems unlikely to help. I do agree with raising > sort_mem --- not so much to make the merge faster as to encourage the > thing to try a hash join instead. sort_mem is already 16384, which I thought would be plenty -- I tried increasing it to 65536 which made exactly zero difference. :-) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Thu Jul 15 10:49:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4F45ED1B229 for ; Thu, 15 Jul 2004 10:49:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73996-10 for ; Thu, 15 Jul 2004 13:49:37 +0000 (GMT) Received: from excite.com (nnn.excitenetwork.com [208.45.133.202]) by svr1.postgresql.org (Postfix) with ESMTP id CDB9AD1B1CE for ; Thu, 15 Jul 2004 10:49:27 -0300 (ADT) Received: from excite.com (xprdmailfe9.nwk.excite.com [10.50.30.38]) by xmxpita.excite.com (Postfix) with ESMTP id 44BDB1806D; Thu, 15 Jul 2004 09:49:34 -0400 (EDT) Received: by xprdmailfe9.nwk.excite.com (Postfix, from userid 110) id 782C43955; Thu, 15 Jul 2004 09:49:33 -0400 (EDT) To: matthew@zeut.net Subject: Re: Swapping in 7.4.3 Received: from [209.208.69.77] by xprdmailfe9.nwk.excite.com via HTTP; Thu, 15 Jul 2004 09:49:33 EST X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: ID = 71ccd8138f9d1bf5b17fb0a5f85a08cf Reply-To: jim.ewert@excite.com From: "Jim Ewert" MIME-Version: 1.0 X-Sender: jim.ewert@excite.com X-Mailer: PHP Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org Message-Id: <20040715134933.782C43955@xprdmailfe9.nwk.excite.com> Date: Thu, 15 Jul 2004 09:49:33 -0400 (EDT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.4 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, RCVD_FAKE_HELO_DOTCOM X-Spam-Level: * X-Archive-Number: 200407/97 X-Sequence-Number: 7488 With pg_autovaccum it's now at 95M swap; averaging 5MB / day increase with same load. Cache slightly increases or decreases according to top. --- On Tue 07/13, Matthew T. O'Connor < matthew@zeut.net > wrote: From: Matthew T. O'Connor [mailto: matthew@zeut.net] To: jim.ewert@excite.com Cc: pgsql-performance@postgresql.org Date: Tue, 13 Jul 2004 16:26:09 -0400 Subject: Re: [PERFORM] Swapping in 7.4.3 Jim Ewert wrote:
> When I went to 7.4.3 (Slackware 9.1) w/ JDBC, the improvements are that it doesn't initially take much memory (have 512M) and didn't swap. I ran a full vaccum and a cluster before installation, however speed degaded to 1 *second* / update of one row in 150 rows of data, within a day! pg_autovacuum now gives excellent performance however it is taking 66M of swap; only 270k cached.
>

Are you saying that your system stays fast now that you are using
pg_autovacuum, but pg_autovacuum is using 66M of memory? Please
clarify, I'm not sure what question you want an answered.

Matthew

_______________________________________________ Join Excite! - http://www.excite.com The most personalized portal on the Web! From pgsql-performance-owner@postgresql.org Thu Jul 15 12:30:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CDED9D1B269 for ; Thu, 15 Jul 2004 12:30:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19951-03 for ; Thu, 15 Jul 2004 15:30:10 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id AC1E4D1B178 for ; Thu, 15 Jul 2004 12:30:10 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6FFU9i7079566 for ; Thu, 15 Jul 2004 15:30:09 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6FFJjoP077279 for pgsql-performance@postgresql.org; Thu, 15 Jul 2004 15:19:45 GMT From: Mike Rylander X-Newsgroups: comp.databases.postgresql.performance Subject: Re: vacuum full 100 mins plus? Date: Thu, 15 Jul 2004 11:14:37 -0400 Organization: Hub.Org Networking Services Lines: 40 Message-ID: References: <16532.1089866203@sss.pgh.pa.us> Reply-To: miker@purplefrog.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: usenet@news.hub.org User-Agent: KNode/0.7.6 To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/98 X-Sequence-Number: 7489 Tom Lane wrote: > Christopher Browne writes: >> A long time ago, in a galaxy far, farpliers PHatcher@macys.com (Patrick >> Hatcher) wrote: >>> Answered my own question. I gave up the vacuum full after 150 mins. I >>> was able to export to a file, vacuum full the empty table, and reimport >>> in less >>> than 10 mins. I suspect the empty item pointers and the sheer number of >>> removable rows was causing an issue. > >> In that case, you'd be a little further better off if the steps were: >> - drop indices; >> - copy table to file (perhaps via pg_dump -t my_table); >> - truncate the table, or drop-and-recreate, both of which make >> it unnecessary to do _any_ vacuum of the result; >> - recreate indices, probably with SORT_MEM set high, to minimize >> paging to disk >> - analyze the table (no need to vacuum if you haven't created any >> dead tuples) >> - cut SORT_MEM back down to "normal" sizes > > Rather than doing all this manually, you can just CLUSTER on any handy > index. In 7.5, another possibility is to issue one of the forms of > ALTER TABLE that force a table rewrite. > > The range of usefulness of VACUUM FULL is really looking narrower and > narrower to me. I can foresee a day when we'll abandon it completely. I would love to see this 10lb sledge hammer go away when we have enough tiny screwdrivers and needlenose pliers to make it obsolete! > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html From pgsql-performance-owner@postgresql.org Thu Jul 15 13:19:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9C2C3D1B178 for ; Thu, 15 Jul 2004 13:19:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39531-08 for ; Thu, 15 Jul 2004 16:19:29 +0000 (GMT) Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net [63.231.195.115]) by svr1.postgresql.org (Postfix) with SMTP id 9D01BD1B170 for ; Thu, 15 Jul 2004 13:19:27 -0300 (ADT) Received: (qmail 63781 invoked by uid 0); 15 Jul 2004 16:19:27 -0000 Received: from mpls-pop-08.inet.qwest.net (63.231.195.8) by mpls-qmqp-04.inet.qwest.net with QMQP; 15 Jul 2004 16:19:27 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-08.inet.qwest.net with SMTP; 15 Jul 2004 16:19:26 -0000 Date: Thu, 15 Jul 2004 10:20:34 -0600 Message-Id: <1089908434.21324.8.camel@localhost.localdomain> From: "Scott Marlowe" To: jim.ewert@excite.com Cc: matthew@zeut.net, pgsql-performance@postgresql.org Subject: Re: Swapping in 7.4.3 In-Reply-To: <20040715134933.782C43955@xprdmailfe9.nwk.excite.com> References: <20040715134933.782C43955@xprdmailfe9.nwk.excite.com> Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/99 X-Sequence-Number: 7490 This is normal. My personal workstation has been up for 16 days, and it shows 65 megs used for swap. The linux kernel looks for things that haven't been accessed in quite a while and tosses them into swap to free up the memory for other uses. This isn't PostgreSQL's fault, or anything elses. It's how a typical Unix kernel works. I.e. you're seeing a problem that simply isn't there. On Thu, 2004-07-15 at 07:49, Jim Ewert wrote: > With pg_autovaccum it's now at 95M swap; averaging 5MB / day increase with same load. Cache slightly increases or decreases according to top. > > --- On Tue 07/13, Matthew T. O'Connor < matthew@zeut.net > wrote: > From: Matthew T. O'Connor [mailto: matthew@zeut.net] > To: jim.ewert@excite.com > Cc: pgsql-performance@postgresql.org > Date: Tue, 13 Jul 2004 16:26:09 -0400 > Subject: Re: [PERFORM] Swapping in 7.4.3 > > Jim Ewert wrote:
> When I went to 7.4.3 (Slackware 9.1) w/ JDBC, the improvements are that it doesn't initially take much memory (have 512M) and didn't swap. I ran a full vaccum and a cluster before installation, however speed degaded to 1 *second* / update of one row in 150 rows of data, within a day! pg_autovacuum now gives excellent performance however it is taking 66M of swap; only 270k cached.
>

Are you saying that your system stays fast now that you are using
pg_autovacuum, but pg_autovacuum is using 66M of memory? Please
clarify, I'm not sure what question you want an answered.

Matthew

> > _______________________________________________ > Join Excite! - http://www.excite.com > The most personalized portal on the Web! > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > From pgsql-performance-owner@postgresql.org Thu Jul 15 15:07:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8AF58D1B233 for ; Thu, 15 Jul 2004 15:07:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92389-07 for ; Thu, 15 Jul 2004 18:07:13 +0000 (GMT) Received: from homer.berkhirt.com (homer.berkhirt.com [207.88.49.100]) by svr1.postgresql.org (Postfix) with ESMTP id 2FA62D1B178 for ; Thu, 15 Jul 2004 15:07:06 -0300 (ADT) Received: from [10.10.11.3] (homer [127.0.0.1]) (authenticated bits=0) by homer.berkhirt.com (8.12.10/8.12.10) with ESMTP id i6FI74bQ012642 for ; Thu, 15 Jul 2004 13:07:05 -0500 Mime-Version: 1.0 (Apple Message framework v618) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; format=flowed To: " " From: Brian Hirt Subject: hardware raid suggestions Date: Thu, 15 Jul 2004 12:07:12 -0600 X-Mailer: Apple Mail (2.618) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/100 X-Sequence-Number: 7491 I've been using the adaptec ZCR raid cards in our servers for a while now, mostly small systems with 3 or 6 disks, and we've been very happy with them. However, we're building a new DB machine with 14 U320 15K SCA drives, and we've run into a performance bottlenkeck with the ZCR card where it just won't scale well. Without going into too many details, we've tested RAID5, RAID10 and RAID50 on pretty much every array size from 4-14 disks (raid 50 tests used more drives), using JFS, reiserfs and EXT3. With every different configuration, performance didn't improve after array size became greater than 6 disks.. We used various benchmarks, including pgbench with scale factors of 10, 100, 1000, 5000 and clients of 10, 15, 30 and 45. We've done many other tests and monitoring tools, and we've come to the conclusion that the ZCR is the problem. We're looking into getting an Adaptec 2200S or the Megaraid 320 2x which have better processors, and hopefully better performance. We feel that the use of the AIC7930 as the CPU on the ZCR just doesn't cut it and a faster raid controller would work better. Does anyone out there have any experience with these cards with postgresql and linux? If so, would you be willing to share your experiences and possibly give a recommendation? --brian From pgsql-performance-owner@postgresql.org Thu Jul 15 15:09:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C7889D1B18F for ; Thu, 15 Jul 2004 15:09:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92129-06 for ; Thu, 15 Jul 2004 18:09:02 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id C8ADAD1B170 for ; Thu, 15 Jul 2004 15:08:59 -0300 (ADT) Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5765884; Thu, 15 Jul 2004 11:10:11 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Shridhar Daithankar , =?iso-8859-15?q?Herv=E9=20Piedvache?= Subject: Re: Insert are going slower ... Date: Thu, 15 Jul 2004 11:09:16 -0700 User-Agent: KMail/1.5.4 Cc: pgsql-performance@postgresql.org References: <200407131850.52095.herve@elma.fr> <200407142332.05161.footcow@noos.fr> <40F62284.3090004@frodo.hserus.net> In-Reply-To: <40F62284.3090004@frodo.hserus.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200407151109.16466.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/101 X-Sequence-Number: 7492 Shridhar, > I suggest you check this first. Check the performance tuning guide.. > > http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php > > That is a starters. As Josh suggested, increase checkpoint segments if you have > disk space. Correspondingly WAL disk space requirements go up as well. Well, not if he has fsync=off. But having fsync off is a very bad idea. You do realize, Herve', that if you lose power on that machine you'll most likely have to restore from backup? -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Jul 15 15:11:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0CFD8D1B170 for ; Thu, 15 Jul 2004 15:11:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93523-04 for ; Thu, 15 Jul 2004 18:11:18 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 6533CD1B16E for ; Thu, 15 Jul 2004 15:11:17 -0300 (ADT) Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5765902; Thu, 15 Jul 2004 11:12:28 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Steinar H. Gunderson" , pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Date: Thu, 15 Jul 2004 11:11:33 -0700 User-Agent: KMail/1.5.4 References: <20040708101913.GA15871@uio.no> <16637.1089867158@sss.pgh.pa.us> <20040715120854.GA31259@uio.no> In-Reply-To: <20040715120854.GA31259@uio.no> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200407151111.34002.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/102 X-Sequence-Number: 7493 Steinar, > sort_mem is already 16384, which I thought would be plenty -- I tried > increasing it to 65536 which made exactly zero difference. :-) Well, then the next step is increasing the statistical sampling on the 3 join columns in that table. Try setting statistics to 500 for each of the 3 cols, analyze, and see if that makes a difference. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jul 16 15:37:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC116D1B220 for ; Thu, 15 Jul 2004 16:36:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36105-01 for ; Thu, 15 Jul 2004 19:36:01 +0000 (GMT) Received: from exchange.rampageusa.net (exchange.dslextreme.com [66.51.198.16]) by svr1.postgresql.org (Postfix) with ESMTP id 48D1ED1B178 for ; Thu, 15 Jul 2004 16:35:59 -0300 (ADT) Content-class: urn:content-classes:message Subject: Wierd issues MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C46AA2.DFA22B87" Date: Thu, 15 Jul 2004 12:35:23 -0700 Message-ID: <79AEF92046759442A4AA04C2AB08C0B814F955@exchange.corp.dslextreme.com> X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Wierd issues Thread-Index: AcRqot8fqDGZ5kzCSnStwp3zWrV8VA== From: "Andrew Matthews" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=HTML_50_60, HTML_FONTCOLOR_UNKNOWN, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200407/108 X-Sequence-Number: 7499 This is a multi-part message in MIME format. ------_=_NextPart_001_01C46AA2.DFA22B87 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I lost the email that had the fix for this and now I need it again... can someone or tom let me know what the fix was, I can't find it in any of my emails or archived on the internet =20 This is what I got... =20 Two servers, one debian, one fedora =20 Debain dual 3ghz, 1 gig ram, ide, PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4 =20 =20 Fedora: Dual 3ghz, 1 gig ram, scsi, PostgreSQL 7.3.4-RH on i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1) =20 =20 Both have same databases, Both have had vacume full ran on them. Both doing the same query =20 Select * from vpopmail; The vpopmail is a view, this is the view =20 =20 View "vpopmail" Column | Type | Modifiers=20 -----------+------------------------+----------- pw_name | character varying(32) |=20 pw_domain | character varying(64) |=20 pw_passwd | character varying |=20 pw_uid | integer |=20 pw_gid | integer |=20 pw_gecos | character varying |=20 pw_dir | character varying(160) |=20 pw_shell | character varying(20) |=20 View definition: SELECT ea.email_name AS pw_name, ea.domain AS pw_domain, get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") AS pw_passwd, 0 AS pw_uid, 0 AS pw_gid, ''::"varchar" AS pw_gecos, ei.directory AS pw_dir, ei.quota AS pw_shell FROM email_addresses ea, email_info ei, users u, user_resources ur WHERE (((((ea.user_resource_id =3D ei.user_resource_id) AND (get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") IS NOT NULL)) AND (ur.id =3D ei.user_resource_id)) AND (u.id =3D ur.user_id)) AND (NOT (EXISTS (SELECT forwarding.email_id FROM forwarding WHERE (forwarding.email_id =3D ea.id))))); =20 =20 =20 Both are set to the same buffers and everything... this is the execution time: =20 Debian: Total runtime: 35594.81 msec =20 Fedora: Total runtime: 2279869.08 msec =20 Huge difference as you can see... here are the pastes of the stuff =20 Debain: =20 user_acl=3D# explain analyze SELECT count(*) from vpopmail; NOTICE: QUERY PLAN: =20 Aggregate (cost=3D438231.94..438231.94 rows=3D1 width=3D20) (actual time=3D35594.67..35594.67 rows=3D1 loops=3D1) -> Hash Join (cost=3D434592.51..438142.51 rows=3D35774 width=3D20) (act= ual time=3D34319.24..35537.11 rows=3D70613 loops=3D1) -> Seq Scan on email_info ei (cost=3D0.00..1721.40 rows=3D71640 width=3D4) (actual time=3D0.04..95.13 rows=3D71689 loops=3D1) -> Hash (cost=3D434328.07..434328.07 rows=3D35776 width=3D16) (actual time=3D34319.00..34319.00 rows=3D0 loops=3D1) -> Hash Join (cost=3D430582.53..434328.07 rows=3D35776 width=3D16) (actual time=3D2372.45..34207.21 rows=3D70613 loops=3D1) -> Seq Scan on users u (cost=3D0.00..1938.51 rows=3D71283 width=3D4) (actual time=3D0.81..30119.58 rows=3D70809 loops=3D= 1) -> Hash (cost=3D430333.64..430333.64 rows=3D35956 width=3D12) (actual time=3D2371.51..2371.51 rows=3D0 loops=3D1) -> Hash Join (cost=3D2425.62..430333.64 rows=3D35956 width=3D12) (actual time=3D176.73..2271.14 rows=3D71470 loops= =3D1) -> Seq Scan on email_addresses ea (cost=3D0.00..426393.25 rows=3D35956 width=3D4) (actual time=3D0.06..627.49 rows=3D71473 loops=3D1) SubPlan -> Index Scan using forwarding_idx on forwarding (cost=3D0.00..5.88 rows=3D1 width=3D4) (actual time=3D0.00..0.00 rows=3D0 loops=3D71960) -> Hash (cost=3D1148.37..1148.37 rows=3D71637 width=3D8) (actual time=3D176.38..176.38 rows=3D0 loops=3D1) -> Seq Scan on user_resources ur (cost=3D0.00..1148.37 rows=3D71637 width=3D8) (actual time=3D0.03..82.21 rows=3D71686 loops=3D1) Total runtime: 35594.81 msec =20 EXPLAIN =20 =20 =20 And for fedora it's =20 =20 Aggregate (cost=3D416775.52..416775.52 rows=3D1 width=3D20) (actual time=3D2279868.57..2279868.58 rows=3D1 loops=3D1) -> Hash Join (cost=3D413853.79..416686.09 rows=3D35772 width=3D20) (actual time=3D2279271.26..2279803.91 rows=3D70841 loops=3D1) Hash Cond: ("outer".user_resource_id =3D "inner".id) -> Seq Scan on email_info ei (cost=3D0.00..1666.07 rows=3D71907 width=3D4) (actual time=3D8.12..171.10 rows=3D71907 loops=3D1) -> Hash (cost=3D413764.36..413764.36 rows=3D35772 width=3D16) (actual time=3D2279263.03..2279263.03 rows=3D0 loops=3D1) -> Hash Join (cost=3D410712.87..413764.36 rows=3D35772 width=3D16) (actual time=3D993.90..2279008.72 rows=3D70841 loops=3D1) Hash Cond: ("outer".id =3D "inner".user_id) -> Seq Scan on users u (cost=3D0.00..1888.85 rows=3D71548 width=3D4) (actual time=3D18.38..2277152.51 rows=3D71028 loops= =3D1) Filter: (get_pwd(username, '127.0.0.1'::character varying, '101'::character varying, 'MD5'::character varying) IS NOT NULL) -> Hash (cost=3D410622.99..410622.99 rows=3D35952 width=3D12) (actual time=3D975.40..975.40 rows=3D0 loops=3D1) -> Hash Join (cost=3D408346.51..410622.99 rows=3D35952 width=3D12) (actual time=3D507.52..905.91 rows=3D71697 loops= =3D1) Hash Cond: ("outer".id =3D "inner".user_resource_id) -> Seq Scan on user_resources ur (cost=3D0.00..1108.04 rows=3D71904 width=3D8) (actual time=3D0.05..95.65 rows=3D71904 loops=3D1) -> Hash (cost=3D408256.29..408256.29 rows=3D36091 width=3D4) (actual time=3D507.33..507.33 rows=3D0 loops=3D1) -> Seq Scan on email_addresses ea (cost=3D0.00..408256.29 rows=3D36091 width=3D4) (actual time=3D0.15..43= 2.83 rows=3D71700 loops=3D1) Filter: (NOT (subplan)) SubPlan -> Index Scan using forwarding_idx on forwarding (cost=3D0.00..5.63 rows=3D1 width=3D4) (actual time=3D0.00..0.00 rows=3D0 loops=3D72182) Index Cond: (email_id =3D $0) Total runtime: 2279869.08 msec (20 rows) ------_=_NextPart_001_01C46AA2.DFA22B87 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I lost the email that had the fix for = this and now I need it again… can someone or tom let me know what the fix = was, I can’t find it in any of my emails or archived on the internet<= /o:p>

 

This is what I got…

 

Two servers, one debian, one fedora

 

Debain dual 3ghz, 1 gig ram, ide, PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4

 

 

Fedora: Dual 3ghz, 1 gig ram, scsi, PostgreSQL 7.3.4-RH = on i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

 

 

Both have same databases, Both have had vacume full ran = on them. Both doing the same query

 

Select * from vpopmail; The vpopmail is a view, this is = the view

 

 

         &n= bsp;      View "vpopmail"

  Column   |          Type          | Modifiers

-----------+------------------------+-----------

 pw_name   | character varying(32)  = |

 pw_domain | character varying(64)  |

 pw_passwd | character varying      |

 pw_uid    | integer           &n= bsp;    |

 pw_gid    | integer           &n= bsp;    |

 pw_gecos  | character varying      |

 pw_dir    | character varying(160) = |

 pw_shell  | character varying(20)  |

View definition: SELECT ea.email_name AS pw_name, ea.dom= ain AS pw_domain, get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") AS pw_passwd, 0 AS pw_uid, 0 AS pw_gid, ''::"varchar" AS pw_gecos, ei.directory AS pw_dir, ei.quota AS pw_shell FROM email_addresses ea, email_info ei, users = u, user_resources ur WHERE (((((ea.user_resource_id =3D ei.user_resource_id) A= ND (get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") IS NOT NULL)) AND (ur.id =3D ei.user_resource_id)) AND (u.id =3D ur.user_id)) AND (NOT (EXISTS (SELECT forwarding.email_id FROM forwarding WHERE (forwarding.email_id =3D ea.id)))));

 

 

 

Both are set to the same buffers and everything… t= his is the execution time:

 

Debian: Total runtime: 35594.81 msec

 

Fedora: Total runtime: 2279869.08 msec=

 

Huge difference as you can see… here are the paste= s of the stuff

 

Debain:

 

user_acl=3D# explain analyze SELECT count(*) from vpopma= il;

NOTICE:  QUERY PLAN:

 

Aggregate  (cost=3D438231.94..438231.94 rows=3D1 wi= dth=3D20) (actual time=3D35594.67..35594.67 rows=3D1 loops=3D1)

  ->  Hash Join  (cost=3D434592.51..438142.51 rows=3D35774 width=3D20) (actual time=3D34319.= 24..35537.11 rows=3D70613 loops=3D1)

        ->  S= eq Scan on email_info ei  (cost=3D0.00..1721.40 rows=3D71640 width=3D4) (= actual time=3D0.04..95.13 rows=3D71689 loops=3D1)

        ->  Hash  (cost=3D434328.07..434328.07 rows=3D35776 width=3D16) (actual time=3D34319.00..34319.00 rows=3D0 loops=3D1)

         &n= bsp;    ->  Hash Join  (cost=3D430582.53..434328.07 rows=3D35776 width= =3D16) (actual time=3D2372.45..34207.21 rows=3D70613 loops=3D1)<= /font>

         &n= bsp;          ->  Seq Scan on users u  (cost=3D0.00..1938.51 rows=3D71283 wi= dth=3D4) (actual time=3D0.81..30119.58 rows=3D70809 loops=3D1)

         &n= bsp;          ->  Hash  (cost=3D430333.64..430333.64 rows=3D35956 width=3D12= ) (actual time=3D2371.51..2371.51 rows=3D0 loops=3D1)

         &n= bsp;            = ;    ->  Hash Join  (cost=3D2425.62..430333.64 rows=3D35956 width= =3D12) (actual time=3D176.73..2271.14 rows=3D71470 loops=3D1)

         &n= bsp;            = ;          ->  Seq Scan on email_addresses ea  (cost=3D0.00..426393.25 rows=3D35956 width=3D4) (actual time=3D0.06..627.49 rows=3D71473 loops=3D1)=

         &n= bsp;            = ;            &n= bsp;   SubPlan

         &n= bsp;            = ;            &n= bsp;     ->  Index Scan using forwarding_idx on forwarding  (cost=3D0.00..5.88 rows=3D1 width=3D4) (actual time=3D0.00..0.00 rows=3D0 l= oops=3D71960)

                 &nb= sp;            =   ->  Hash  (cost=3D1148.37..1148.37 rows=3D71637 width=3D8) (actual time=3D176.38..176.38 rows=3D0 loops=3D1)

         &n= bsp;            = ;            &n= bsp;   ->  Seq Scan on user_resources ur  (cost=3D0.00..1148.37 rows=3D71637 width=3D8) (actual time=3D0.03..82.21 ro= ws=3D71686 loops=3D1)

Total runtime: 35594.81 msec

 

EXPLAIN

 

 

 

And for fedora it’s

 

 

Aggregate  (cost=3D416775.52..416775.52 row=
s=3D1 width=3D20) (actual time=3D2279868.57..2279868.58 rows=3D1 loops=3D1)=
   ->  Hash Join  (cost=
=3D413853.79..416686.09 rows=3D35772 width=3D20) (actual time=3D2279271.26.=
.2279803.91 rows=3D70841 loops=3D1)
        =
 Hash Cond: ("outer".user_resource_id =3D "inner".id)
        =
 ->  Seq Scan on email_info ei  (cost=3D0.00..1666.07 rows=3D7=
1907 width=3D4) (actual time=3D8.12..171.10 rows=3D71907 loops=3D1)
        =
 ->  Hash  (cost=3D413764.36..413764.36 rows=3D35772 width=3D1=
6) (actual time=3D2279263.03..2279263.03 rows=3D0 loops=3D1)
        =
       ->  Hash Join  (cost=3D41=
0712.87..413764.36 rows=3D35772 width=3D16) (actual time=3D993.90..2279008.=
72 rows=3D70841 loops=3D1)
        =
             Ha=
sh Cond: ("outer".id =3D "inner".user_id)
        =
             -&=
gt;  Seq Scan on users u  (cost=3D0.00..1888.85 rows=3D71548 widt=
h=3D4) (actual time=3D18.38..2277152.51 rows=3D71028 loops=3D1)<=
/span>
        =
            &nb=
sp;      Filter: (get_pwd(username, '127.0.0.1'::c=
haracter varying, '101'::character varying, 'MD5'::character varying) IS NO=
T NULL)
        =
             -&=
gt;  Hash  (cost=3D410622.99..410622.99 rows=3D35952 width=3D12) =
(actual time=3D975.40..975.40 rows=3D0 loops=3D1)<=
/pre>
        =
             &n=
bsp;     ->  Hash Join  (cost=3D40834=
6.51..410622.99 rows=3D35952 width=3D12) (actual time=3D507.52..905.91 rows=
=3D71697 loops=3D1)
        =
            &nb=
sp;            Hash =
Cond: ("outer".id =3D "inner".user_resource_id)
        =
            &nb=
sp;            ->=
  Seq Scan on user_resources ur  (cost=3D0=
.00..1108.04 rows=3D71904 width=3D8) (actual time=3D0.05..95.65 rows=3D7190=
4 loops=3D1)
        =
            &nb=
sp;            ->=
  Hash  (cost=3D408256.29..408256.29 rows=3D36091 width=3D4) (act=
ual time=3D507.33..507.33 rows=3D0 loops=3D1)
        =
             &n=
bsp;            =
;     ->  Seq Scan on email_addresses ea&n=
bsp; (cost=3D0.00..408256.29 rows=3D36091 width=3D4) (actual time=3D0.15..4=
32.83 rows=3D71700 loops=3D1)
        =
            &nb=
sp;            =
            Filter: =
(NOT (subplan))
        =
            &nb=
sp;            =
            SubPlan<=
o:p>
        =
            &nb=
sp;            =
            &nb=
sp; ->  Index Scan using forwarding_idx on forwarding  (cost=
=3D0.00..5.63 rows=3D1 width=3D4) (actual time=3D0.00..0.00 rows=3D0 loops=
=3D72182)
        =
            &nb=
sp;            =
            &nb=
sp;       Index Cond: (email_id =3D $0)<=
/o:p>
 Total runtime: 2279869.08 msec

(20 rows)

------_=_NextPart_001_01C46AA2.DFA22B87-- From pgsql-performance-owner@postgresql.org Thu Jul 15 19:16:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6F154D1B195 for ; Thu, 15 Jul 2004 19:16:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05632-03 for ; Thu, 15 Jul 2004 22:16:16 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id BA046D1B16A for ; Thu, 15 Jul 2004 19:16:10 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1BlEWS-0000rh-00 for ; Fri, 16 Jul 2004 00:16:12 +0200 Date: Fri, 16 Jul 2004 00:16:12 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Message-ID: <20040715221612.GA2904@uio.no> References: <20040708101913.GA15871@uio.no> <16637.1089867158@sss.pgh.pa.us> <20040715120854.GA31259@uio.no> <200407151111.34002.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200407151111.34002.josh@agliodbs.com> X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/103 X-Sequence-Number: 7494 On Thu, Jul 15, 2004 at 11:11:33AM -0700, Josh Berkus wrote: >> sort_mem is already 16384, which I thought would be plenty -- I tried >> increasing it to 65536 which made exactly zero difference. :-) > Well, then the next step is increasing the statistical sampling on the 3 join > columns in that table. Try setting statistics to 500 for each of the 3 > cols, analyze, and see if that makes a difference. Made no difference on either version (7.2 or 7.4). BTW, you guys can stop Cc-ing me now; I'm subscribed. :-) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Thu Jul 15 23:55:56 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A0640D1B184 for ; Thu, 15 Jul 2004 23:55:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97690-01 for ; Fri, 16 Jul 2004 02:55:45 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 8C90FD1B1C7 for ; Thu, 15 Jul 2004 23:55:39 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5770287 for pgsql-performance@postgresql.org; Thu, 15 Jul 2004 19:56:54 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Subject: Re: hardware raid suggestions Date: Thu, 15 Jul 2004 19:55:29 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200407151955.29586.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/104 X-Sequence-Number: 7495 Brian, > We're looking into getting an Adaptec 2200S or the Megaraid 320 2x > which have better processors, and hopefully better performance. We > feel that the use of the AIC7930 as the CPU on the ZCR just doesn't > cut it and a faster raid controller would work better. Does anyone out > there have any experience with these cards with postgresql and linux? > If so, would you be willing to share your experiences and possibly give > a recommendation? Yes, my experience with adaptecs has been universally bad. I just really don't think that "the SCSI-2 card company" is up to making high-end raid cards. MegaRaid is generally positively reviewed in a lot of places. Be careful to order the battery back-up at the same time as the Raid card; the batteries have the annoying habit of going off the market for months at a time. You should also consider looking into driver issues. In general, the RAID card drivers distributed for Linux simply aren't as good as those the same companies write for Windows or Unix. That may be your issue with the ZCR, as well as CPU. Oh, and don't bother with the upgrade if you're not getting battery backup. You need it. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Jul 16 00:25:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD1A4D1B229 for ; Fri, 16 Jul 2004 00:25:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10883-01 for ; Fri, 16 Jul 2004 03:25:09 +0000 (GMT) Received: from mx1.mailsecurity.net.au (mx1.mailsecurity.net.au [66.135.32.89]) by svr1.postgresql.org (Postfix) with ESMTP id 8C805D1B23C for ; Fri, 16 Jul 2004 00:25:07 -0300 (ADT) Received: from [211.28.202.202] (211.28.202.202.optusnet.com.au [211.28.202.202] (may be forged)) (authenticated) by mx1.mailsecurity.net.au (8.11.6/2.52a) with ESMTP id i6G3OxT26282; Fri, 16 Jul 2004 13:25:00 +1000 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v618) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: " " From: Mark Aufflick Subject: Re: hardware raid suggestions Date: Fri, 16 Jul 2004 13:25:17 +1000 To: Brian Hirt X-Mailer: Apple Mail (2.618) X-MS-Info: Message scanned by Mail Security - www.mailsecurity.net.au X-MS: Message OK X-MS-From: mark@pumptheory.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/105 X-Sequence-Number: 7496 Not sure what your hw platform is, but I always used to get fantastic performance from Compaq Smart Array battery backed cards. Note that I haven't bought any recently so HP may have "hp invent"-ed them... But whatever the brand - if you get a swag of battery backed cache you won't know yourself. It's fun to install an OS on them as well - watch the drive format and verify take 10 seconds ;) Another option to look at is outboard raid boxes that present a single drive "interface" to the server - I know people who swear by them. -- Mark Aufflick e mark@pumptheory.com w www.pumptheory.com (work) w mark.aufflick.com (personal) p +61 438 700 647 On 16/07/2004, at 4:07 AM, Brian Hirt wrote: > I've been using the adaptec ZCR raid cards in our servers for a while > now, mostly small systems with 3 or 6 disks, and we've been very happy > with them. However, we're building a new DB machine with 14 U320 15K > SCA drives, and we've run into a performance bottlenkeck with the ZCR > card where it just won't scale well. Without going into too many > details, we've tested RAID5, RAID10 and RAID50 on pretty much every > array size from 4-14 disks (raid 50 tests used more drives), using > JFS, reiserfs and EXT3. With every different configuration, > performance didn't improve after array size became greater than 6 > disks.. We used various benchmarks, including pgbench with scale > factors of 10, 100, 1000, 5000 and clients of 10, 15, 30 and 45. > We've done many other tests and monitoring tools, and we've come to > the conclusion that the ZCR is the problem. > > We're looking into getting an Adaptec 2200S or the Megaraid 320 2x > which have better processors, and hopefully better performance. We > feel that the use of the AIC7930 as the CPU on the ZCR just doesn't > cut it and a faster raid controller would work better. Does anyone out > there have any experience with these cards with postgresql and linux? > If so, would you be willing to share your experiences and possibly > give a recommendation? > > --brian > > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend > > ======================================================================= > = > Pain free spam & virus protection by: www.mailsecurity.net.au > Forward undetected SPAM to: spam@mailsecurity.net.au > ======================================================================= > = > ======================================================================== Pain free spam & virus protection by: www.mailsecurity.net.au Forward undetected SPAM to: spam@mailsecurity.net.au ======================================================================== From pgsql-performance-owner@postgresql.org Fri Jul 16 04:36:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3A006D1B196 for ; Fri, 16 Jul 2004 04:35:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88479-05 for ; Fri, 16 Jul 2004 07:35:40 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 0739CD1B18F for ; Fri, 16 Jul 2004 04:35:36 -0300 (ADT) Received: from solent (82-68-95-1.dsl.in-addr.zen.co.uk [82.68.95.1]) by bayswater1.ymogen.net (Postfix) with ESMTP id 14D4FA4DF4; Fri, 16 Jul 2004 08:35:35 +0100 (BST) Reply-To: From: "Matt Clark" To: "'Scott Marlowe'" , Cc: , Subject: Re: Swapping in 7.4.3 Date: Fri, 16 Jul 2004 08:35:32 +0100 Organization: Ymogen Ltd Message-ID: <00b101c46b07$79a758d0$8300a8c0@solent> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <1089908434.21324.8.camel@localhost.localdomain> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/106 X-Sequence-Number: 7497 > This is normal. My personal workstation has been up for 16=20 > days, and it shows 65 megs used for swap. The linux kernel=20 > looks for things that haven't been accessed in quite a while=20 > and tosses them into swap to free up the memory for other uses. >=20 > This isn't PostgreSQL's fault, or anything elses. It's how a=20 > typical Unix kernel works. I.e. you're seeing a problem that=20 > simply isn't there. Actually it (and other OSes) does slightly better than that. It _copies_ the least recently used pages into swap, but leaves them in memory. Then when there really is a need to swap stuff out there is no need to actually write to swap because it's already been done, and conversely if those pages are wanted then they don't have to be read from disk because they were never removed from memory. From pgsql-performance-owner@postgresql.org Fri Jul 16 08:17:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B1EFBD1B248 for ; Fri, 16 Jul 2004 08:17:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76782-07 for ; Fri, 16 Jul 2004 11:17:03 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 28359D1B243 for ; Fri, 16 Jul 2004 08:17:00 -0300 (ADT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id C0A15EC1D0; Fri, 16 Jul 2004 12:20:14 +0200 (CEST) Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 8915AEC0EA; Fri, 16 Jul 2004 12:20:14 +0200 (CEST) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: pgsql-performance@postgresql.org, josh@agliodbs.com Subject: Re: Insert are going slower ... Date: Fri, 16 Jul 2004 13:17:02 +0200 User-Agent: KMail/1.6.2 Cc: Shridhar Daithankar , =?iso-8859-15?q?Herv=E9_Piedvache?= References: <200407131850.52095.herve@elma.fr> <40F62284.3090004@frodo.hserus.net> <200407151109.16466.josh@agliodbs.com> In-Reply-To: <200407151109.16466.josh@agliodbs.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Message-Id: <200407161317.02515.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/107 X-Sequence-Number: 7498 Josh, Le jeudi 15 Juillet 2004 20:09, Josh Berkus a �crit : > > I suggest you check this first. Check the performance tuning guide.. > > > > http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php > > > > That is a starters. As Josh suggested, increase checkpoint segments if > > you > > have > > > disk space. Correspondingly WAL disk space requirements go up as well. > > Well, not if he has fsync=off. But having fsync off is a very bad idea. > You do realize, Herve', that if you lose power on that machine you'll most > likely have to restore from backup? Hum ... it's only for speed aspect ... I was using postgresql with this option since 7.01 ... and for me fsync=on was so slow ... Is it really no time consuming for the system to bring it ON now with v7.4.3 ?? Tell me ... -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Fri Jul 16 18:36:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E8018D1B181 for ; Fri, 16 Jul 2004 18:36:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59781-02 for ; Fri, 16 Jul 2004 21:36:32 +0000 (GMT) Received: from web13125.mail.yahoo.com (web13125.mail.yahoo.com [216.136.174.143]) by svr1.postgresql.org (Postfix) with SMTP id 676AFD1B178 for ; Fri, 16 Jul 2004 18:36:28 -0300 (ADT) Message-ID: <20040716213630.27909.qmail@web13125.mail.yahoo.com> Received: from [63.78.248.48] by web13125.mail.yahoo.com via HTTP; Fri, 16 Jul 2004 14:36:30 PDT Date: Fri, 16 Jul 2004 14:36:30 -0700 (PDT) From: Litao Wu Subject: same plan, different time To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/110 X-Sequence-Number: 7501 Hi, I have a query, which runs fast for one id (query 1) and slow for other id (query 2) though both plans and cost are same except these two qeries return different number of rows. explain analyze SELECT * FROM user U LEFT JOIN user_timestamps T USING (user_id), user_alias A WHERE U.user_id = A.user_id AND A.domain_id=7551070; \g QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Join (cost=234.22..61015.98 rows=12 width=238) (actual time=7.73..7.73 rows=0 loops=1) Merge Cond: ("outer".user_id = "inner".user_id) -> Merge Join (cost=0.00..58585.67 rows=909864 width=180) (actual time=0.07..0.07 rows=1 loops=1) Merge Cond: ("outer".user_id = "inner".user_id) -> Index Scan using user_pkey on user u (cost=0.00..29714.99 rows=909864 width=156) (actual time=0.04..0.04 rows=1 loops=1) -> Index Scan using user_timestamps_uid_idx on user_timestamps t (cost=0.00..16006.05 rows=706896 width=24) (actual time=0.02..0.02 rows=1 loops=1) -> Sort (cost=234.22..234.25 rows=12 width=58) (actual time=7.65..7.65 rows=0 loops=1) Sort Key: a.user_id -> Seq Scan on user_alias a (cost=0.00..234.00 rows=12 width=58) (actual time=7.61..7.61 rows=0 loops=1) Filter: (domain_id = 7551070) Total runtime: 7.96 msec (11 rows) explain analyze SELECT * FROM user U LEFT JOIN user_timestamps T USING (user_id), user_alias A WHERE U.user_id = A.user_id AND A.domain_id=2005921193; \g QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Join (cost=247.92..61035.28 rows=332 width=238) (actual time=94511.70..95127.94 rows=493 loops=1) Merge Cond: ("outer".user_id = "inner".user_id) -> Merge Join (cost=0.00..58585.67 rows=909864 width=180) (actual time=6.43..93591.06 rows=897655 loops=1) Merge Cond: ("outer".user_id = "inner".user_id) -> Index Scan using user_pkey on user u (cost=0.00..29714.99 rows=909864 width=156) (actual time=6.29..55634.85 rows=897655 loops=1) -> Index Scan using user_timestamps_uid_idx on user_timestamps t (cost=0.00..16006.05 rows=706896 width=24) (actual time=0.10..20331.13 rows=700466 loops=1) -> Sort (cost=247.92..248.75 rows=332 width=58) (actual time=10.76..11.17 rows=493 loops=1) Sort Key: a.user_id -> Seq Scan on user_alias a (cost=0.00..234.00 rows=332 width=58) (actual time=7.43..9.86 rows=493 loops=1) Filter: (domain_id = 2005921193) Total runtime: 95128.74 msec (11 rows) I also know if I change the order of 2nd query, it will run much faster: explain analyze SELECT * FROM (user_alias A JOIN user U USING (user_id) ) LEFT JOIN user_timestamps T USING (user_id) WHERE A.domain_id=2005921193; \g QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (cost=0.00..2302.31 rows=332 width=238) (actual time=15.32..256.54 rows=493 loops=1) -> Nested Loop (cost=0.00..1263.43 rows=332 width=214) (actual time=15.17..130.58 rows=493 loops=1) -> Seq Scan on user_alias a (cost=0.00..234.00 rows=332 width=58) (actual time=15.04..21.01 rows=493 loops=1) Filter: (domain_id = 2005921193) -> Index Scan using user_pkey on user u (cost=0.00..3.08 rows=1 width=156) (actual time=0.17..0.17 rows=1 loops=493) Index Cond: ("outer".user_id = u.user_id) -> Index Scan using user_timestamps_uid_idx on user_timestamps t (cost=0.00..3.11 rows=1 width=24) (actual time=0.16..0.23 rows=1 loops=493) Index Cond: ("outer".user_id = t.user_id) Total runtime: 257.79 msec (9 rows) user with 911932 rows user_id - PK user_timestamps with 708851 rows user_id - FK with index user_alias with 9689 rows user_id - FK with index domain_id - no index on this column My questions are: 1. Why 1st "Merge Join" in 2nd query gets actual rows=897655 while 1st "Merge Join" in 1st query is actual rows=1? If I know the answer, I will understand: Why 1st "Merge Join" in 2nd query took so longer time than 1st "Merge Join" in 1st query? 2. Why PG optimzer is not smart enough to use 3rd (nested Loop) plan? Thanks, __________________________________ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/ From pgsql-performance-owner@postgresql.org Fri Jul 16 23:31:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 74F8AD1B269 for ; Fri, 16 Jul 2004 23:31:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51303-01 for ; Sat, 17 Jul 2004 02:31:36 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id D9058D1B1B9 for ; Fri, 16 Jul 2004 23:31:31 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id 857AF76A33; Fri, 16 Jul 2004 22:31:42 -0400 (EDT) Subject: Re: extrem bad performance From: Rod Taylor To: Stefan Cc: Postgresql Performance In-Reply-To: References: Content-Type: text/plain Message-Id: <1090031495.81714.11.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 16 Jul 2004 22:31:36 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/111 X-Sequence-Number: 7502 > The database grows very slowly. The main load comes from SELECT's and > not from INSERT's or UPDATE's, but the performance gets slower day by day... > > I have no idea where to search for the speed break! Lets start with an example. Please send us an EXPLAIN ANALYZE of a couple of the poorly performing queries. From pgsql-performance-owner@postgresql.org Sat Jul 17 00:20:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 823FCD1B27A for ; Sat, 17 Jul 2004 00:20:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66551-05 for ; Sat, 17 Jul 2004 03:20:41 +0000 (GMT) Received: from redhotpenguin.com (www.redhotpenguin.com [64.127.99.50]) by svr1.postgresql.org (Postfix) with ESMTP id 53BAFD1B195 for ; Sat, 17 Jul 2004 00:20:35 -0300 (ADT) Received: (qmail 20523 invoked from network); 17 Jul 2004 03:20:40 -0000 Received: from localhost (HELO mail.redhotpenguin.com) (127.0.0.1) by localhost with SMTP; 17 Jul 2004 03:20:40 -0000 Received: from 67.116.52.35 (SquirrelMail authenticated user fred@redhotpenguin.com) by mail.redhotpenguin.com with HTTP; Fri, 16 Jul 2004 20:20:40 -0700 (PDT) Message-ID: <33676.67.116.52.35.1090034440.squirrel@mail.redhotpenguin.com> In-Reply-To: References: Date: Fri, 16 Jul 2004 20:20:40 -0700 (PDT) Subject: Re: hardware raid suggestions From: "Fred Moyer" To: "Brian Hirt" Cc: pgsql-performance@postgresql.org Reply-To: fred@redhotpenguin.com User-Agent: SquirrelMail/1.4.2-1.qvcs.1 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=PRIORITY_NO_NAME, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/112 X-Sequence-Number: 7503 > We're looking into getting an Adaptec 2200S or the Megaraid 320 2x > which have better processors, and hopefully better performance. We > feel that the use of the AIC7930 as the CPU on the ZCR just doesn't > cut it and a faster raid controller would work better. Does anyone out > there have any experience with these cards with postgresql and linux? > If so, would you be willing to share your experiences and possibly give > a recommendation? I have worked with at least four major name brands of scsi and ide raid controllers and so far the one I have found to be generally the most featured and fastest is the ICP Vortex controllers (http://www.icp-vortex.com/). It is also more expensive than the others but has been worth the cost IMHO. It has a command line utility to measure disk performance and I believe the source code for it is available. I have measured over 200 MB/s reads off these controllers on 3u disk array units. I'm sure I could have gotten more with additional tuning. Fred From pgsql-performance-owner@postgresql.org Sat Jul 17 00:31:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BB722D1B1BE for ; Sat, 17 Jul 2004 00:30:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69318-05 for ; Sat, 17 Jul 2004 03:30:34 +0000 (GMT) Received: from redhotpenguin.com (www.redhotpenguin.com [64.127.99.50]) by svr1.postgresql.org (Postfix) with ESMTP id 62E6BD1B199 for ; Sat, 17 Jul 2004 00:30:29 -0300 (ADT) Received: (qmail 20584 invoked from network); 17 Jul 2004 03:30:34 -0000 Received: from localhost (HELO mail.redhotpenguin.com) (127.0.0.1) by localhost with SMTP; 17 Jul 2004 03:30:34 -0000 Received: from 67.116.52.35 (SquirrelMail authenticated user fred@redhotpenguin.com) by mail.redhotpenguin.com with HTTP; Fri, 16 Jul 2004 20:30:34 -0700 (PDT) Message-ID: <33721.67.116.52.35.1090035034.squirrel@mail.redhotpenguin.com> Date: Fri, 16 Jul 2004 20:30:34 -0700 (PDT) Subject: Scaling with lazy index updates From: "Fred Moyer" To: pgsql-performance@postgresql.org Reply-To: fred@redhotpenguin.com User-Agent: SquirrelMail/1.4.2-1.qvcs.1 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=PRIORITY_NO_NAME, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/113 X-Sequence-Number: 7504 Pg Performers, This might be a out of the ordinary question, or perhaps I have been out of the loop for a while but does PostgreSQL (or any other database) have support for lazy index updates. What I mean by lazy index updates is index updating which occur at a regular interval rather than per transaction. I have found that inserts and updates tend to slow down when the database gets really big. I think it is likely an effect of updating indexes when the insert or update occurs. Looking forward to feedback and possibly direction on my lazy index update question. TIA, Fred From pgsql-performance-owner@postgresql.org Sat Jul 17 01:53:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1BA0CD1B19A for ; Sat, 17 Jul 2004 01:43:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92908-10 for ; Sat, 17 Jul 2004 04:43:07 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 03C15D1B170 for ; Sat, 17 Jul 2004 01:43:01 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6H4h4uj001581; Sat, 17 Jul 2004 00:43:05 -0400 (EDT) To: Litao Wu Cc: pgsql-performance@postgresql.org Subject: Re: same plan, different time In-reply-to: <20040716213630.27909.qmail@web13125.mail.yahoo.com> References: <20040716213630.27909.qmail@web13125.mail.yahoo.com> Comments: In-reply-to Litao Wu message dated "Fri, 16 Jul 2004 14:36:30 -0700" Date: Sat, 17 Jul 2004 00:43:04 -0400 Message-ID: <1580.1090039384@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/114 X-Sequence-Number: 7505 Litao Wu writes: > SELECT * > FROM user U LEFT JOIN user_timestamps T USING > (user_id), user_alias A > WHERE U.user_id = A.user_id AND A.domain_id=7551070; Ick. Try changing the join order, perhaps SELECT * FROM (user U JOIN user_alias A ON (U.user_id = A.user_id)) LEFT JOIN user_timestamps T USING (user_id) WHERE A.domain_id=7551070; As you have it, the entire LEFT JOIN has to be formed first, and the useful restriction clause only gets applied later. The fact that the case with 7551070 finishes quickly is just blind luck --- the slow case is much more representative. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Jul 17 21:02:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4F7ABD1B1BE for ; Sat, 17 Jul 2004 21:02:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24483-04 for ; Sun, 18 Jul 2004 00:02:07 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 157CCD1B18A for ; Sat, 17 Jul 2004 21:02:03 -0300 (ADT) Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5791976; Sat, 17 Jul 2004 17:03:17 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: fred@redhotpenguin.com, pgsql-performance@postgresql.org Subject: Re: Scaling with lazy index updates Date: Sat, 17 Jul 2004 17:02:20 -0700 User-Agent: KMail/1.5.4 References: <33721.67.116.52.35.1090035034.squirrel@mail.redhotpenguin.com> In-Reply-To: <33721.67.116.52.35.1090035034.squirrel@mail.redhotpenguin.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200407171702.20997.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/115 X-Sequence-Number: 7506 Howdy Fred, > This might be a out of the ordinary question, or perhaps I have been out > of the loop for a while but does PostgreSQL (or any other database) have > support for lazy index updates. What I mean by lazy index updates is > index updating which occur at a regular interval rather than per > transaction. In a word: No. The issue with "asynchronous index updates" (which is what you asked about) is that they don't work with the way PostgreSQL uses indexes. If the index hasn't been updated, then when a query uses an index scan the row simply wouldn't show up. If that's acceptable behavior for you, then perhaps you could consider asynchronous *table* updates, done at the application layer, which would be much easier to implement. We do as much as we can by offloading b-tree "cleanup" for indexes until VACUUM/REINDEX, which is called manually. Hmmm. Can you think of an example of an RDBMS which does *not* update indexes immediately (and transactionally)? I can't. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Jul 18 06:42:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 38A01D1B20D for ; Sun, 18 Jul 2004 06:42:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75123-08 for ; Sun, 18 Jul 2004 09:42:53 +0000 (GMT) Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) by svr1.postgresql.org (Postfix) with ESMTP id B2FDAD1B1F8 for ; Sun, 18 Jul 2004 06:42:43 -0300 (ADT) Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i6I9goo15202; Sun, 18 Jul 2004 11:42:50 +0200 Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i6I9goX18085; Sun, 18 Jul 2004 11:42:50 +0200 Message-ID: <40FA460C.5030108@bigfoot.com> Date: Sun, 18 Jul 2004 11:42:36 +0200 From: Gaetano Mendola User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: eleven@ludojad.itpp.pl, "pgsql-performance@postgresql.org" Subject: Re: High load average with PostgreSQL 7.4.2 on debian/ibm eserver. References: <20040629155537.GA5465@ludojad.itpp.pl> In-Reply-To: <20040629155537.GA5465@ludojad.itpp.pl> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/116 X-Sequence-Number: 7507 eleven@ludojad.itpp.pl wrote: > Whole config is available here: > http://ludojad.itpp.pl/~eleven/pg-high-load.conf effective_cache_size = 4000 # typically 8KB each #random_page_cost = 4 # units are one sequential page fetch cost #cpu_tuple_cost = 0.01 # (same) #cpu_index_tuple_cost = 0.001 # (same) #cpu_operator_cost = 0.0025 # (same) These values are too higher for your hardware, try to execute the explain analyze for the queries that are running on your box and repeat it lowering these values, I bet postgres is running seq scan instead of an index scan. These are the value that I use for a configuration closer to your: effective_cache_size = 20000 random_page_cost = 2.0 cpu_tuple_cost = 0.005 cpu_index_tuple_cost = 0.0005 cpu_operator_cost = 0.0025 last question, do you use the autovacuum daemon ? If no => you have to use it If yes => did you apply the patch that will not fail with big tables like yours ? if you can post the autovacuum daemon log ( last lines ). Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Sun Jul 18 14:24:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 40AA8D1B16A for ; Sun, 18 Jul 2004 14:24:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08441-03 for ; Sun, 18 Jul 2004 17:24:02 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 78B15D1B275 for ; Sun, 18 Jul 2004 14:23:59 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5799011; Sun, 18 Jul 2004 10:25:08 -0700 Content-Type: text/plain; charset="iso-8859-15" From: Josh Berkus Organization: Aglio Database Solutions To: =?iso-8859-15?q?Herv=E9=20Piedvache?= , pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... Date: Sun, 18 Jul 2004 10:23:21 -0700 User-Agent: KMail/1.4.3 Cc: Shridhar Daithankar , =?iso-8859-15?q?Herv=E9=20Piedvache?= References: <200407131850.52095.herve@elma.fr> <200407151109.16466.josh@agliodbs.com> <200407161317.02515.herve@elma.fr> In-Reply-To: <200407161317.02515.herve@elma.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200407181023.22004.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/117 X-Sequence-Number: 7508 Herve' > Hum ... it's only for speed aspect ... I was using postgresql with this > option since 7.01 ... and for me fsync=on was so slow ... > Is it really no time consuming for the system to bring it ON now with > v7.4.3 ?? Well, I wouldn't do it until you've figured out the current performance problem. The issue with having fsync=off is that, if someone yanks the power cord on your server, there is a significant chance that you will have to restore the database from backup becuase it will be corrupted. But clearly you've been living with that risk for some time. It *is* true that there is significantly less performance difference between 7.4 with fsync off and on than there was between 7.1 with fsync off and on. But there is still a difference. In 7.0 and 7.1 (I think), when you turned fsync off it turned WAL off completely, resulting in a substantial difference in disk activity. Now, it just stops checkpointing WAL but WAL is still recording -- meaning that disk activity decreases some but not a lot. The difference is more noticable the more vulnerable to contention your disk system is. The other reason not to think of fsync=off as a permanent performance tweak is that we're likely to remove the option sometime in the next 2 versions, since an increasing number of features depend on WAL behavior, and the option is largely a legacy of the 7.0 days, when WAL was sometimes buggy and needed to be turned off to get the database to start. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Jul 25 20:09:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F29C4D1B26C for ; Mon, 19 Jul 2004 06:12:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39334-03 for ; Mon, 19 Jul 2004 09:12:16 +0000 (GMT) Received: from smtp-out6.blueyonder.co.uk (smtp-out6.blueyonder.co.uk [195.188.213.9]) by svr1.postgresql.org (Postfix) with ESMTP id 62C3ED1B23E for ; Mon, 19 Jul 2004 06:12:12 -0300 (ADT) Received: from lappy ([82.43.186.234]) by smtp-out6.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.5600); Mon, 19 Jul 2004 10:12:31 +0100 Message-ID: <007101c46d70$7a50d8e0$0300a8c0@lappy> From: "Andy Ballingall" To: "Merlin Moncure" Cc: References: <6EE64EF3AB31D5448D0007DD34EEB34101AECA@Herge.rcsinc.local> Subject: Re: Working on huge RAM based datasets Date: Mon, 19 Jul 2004 10:12:12 +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.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-OriginalArrivalTime: 19 Jul 2004 09:12:31.0302 (UTC) FILETIME=[85473E60:01C46D70] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/163 X-Sequence-Number: 7554 Sorry for the late reply - I've been away. Merlin, I'd like to come back with a few more points! >That's the whole point: memory is a limited resource. If pg is >crawling, then the problem is simple: you need more memory. My posting only relates to the scenario where RAM is not a limiting factor, a scenario which shall become increasingly common over the next few years, as 64 bit processors and OSs allow the exploitation of ever larger, ever cheaper RAM. > The question is: is it postgresql's responsibility to manage that resource? I think you are confusing the issue of RAM and address space. Any application can acquire a piece of address space for its own use. It is the responsibility of the application to do what it needs with that address space. I'm interested in how PG could do something better in its address space when it knows that it can fit all the data it operates on within that address space. Though the OS is responsible for determining whether that address space is RAM resident or not, in my scenario, this is irrelevant, because there *will* be enough RAM for everything, and the OS will, in that scenario, allow all the address space to become RAM resident. I am not advocating undermining the OS in any way. It would be stupid to make PGSQL take over the running of the hardware. >Pg is a data management tool, not a memory management tool. I'm not criticising PG. PG is actually a 'DISK/MEMORY' data management tool. It manages data which lives on disks, but it can only operate on that data in memory, and goes to some lengths to try to fit bits of disk data in a defined piece of memory, and push them back out again. At the moment, this model assumes that RAM is a scarce resource. The model still 'sort of' works when RAM is actually not scarce, because the OS effectively uses that extra RAM to make IO *appear* to be quicker, and indeed, I've found that a hint has been added to PG to tell it how much the OS is likely to be caching. But the question is this: "If you wrote a DB from scratch with the assumption that *all* the data could fit in the address space allocated by the postmaster, and you were confident that the OS had enough RAM so that you never suffered vmem page misses, couldn't you make things go much faster?" A more pertinent question is: "Could PG be extended to have a flag, which when enabled, told it to operate with the assumption that it could fit all the disk data in RAM, and implement the data organisation optimisations that rely on the persistence of data in address space?" >The same >'let's manage everything' argument also frequently gets brought up wrt >file i/o, because people assume the o/s sucks at file management. Well, I'm not saying this. I have substantial experience with high performance file IO through a filesystem. But if you are interested in high speed IO, naive 'let the OS do everything' approach isn't often good enough. You, the application, have to be aware that the order and timing of IO requests, along with the size of IO block you cause to trigger, have a dramatic impact on the speed with which the data reaches your app, OS or no OS. Most high speed storage still relies on spinning things containing data that can only be accessed in a certain way, and data movement is page boundary sensitive. The OS may hide these details from you, but you, the app writer, have to have an understanding of the underlying reality if you want to optimise performance. I want to stress that at no point am I advocating *not* using the OS. PG should do ALL IO and memory allocation through the OS, otherwise you end up with a platform specific product that is of little use. That given, there is still the opportunity for PG to be able to operate far more efficiently in my high memory scenario. Wouldn't your backend processes like to have the entire database sitting ready in address space (ram resident, of course!), indexes all fully built? No tuple more than a few machine instructions away? Imagine the postmaster isn't having to frantically decide which bits of data to kick out of the workspace in order to keep the backends happy. Imagine the postmaster isn't having to build structures to keep track of the newly read in blocks of data from 'disk' (or OS cache). Is this not a compelling scenario? >At some point, hard disks will be replaced by solid state memory >technologies... This is irrelevant to my scenario, though solid state disks would allow write speeds to improve, which would add to the gains which I am fishing for here. >do you really want to recode your memory manager when >this happens because all your old assumptions are no longer correct? My scenario assumes nothing about how the data is stored, but you are right to flag the problems that arise when original assumptions about hardware become incorrect. For example, PG assumes that RAM is a rare resource, and it assumes the postmaster cannot fit the entire database in a single address space. *These* assumptions are now not correct, following the 64bit address space breakthrough. The availability of 64 bit addressing and huge banks of RAM is of enormous significance to databases, and itIt is the whole reason for my post. Over the next 5-10 years, an increasing proportion of databases will fit comfortably in RAM resident address space on commodity equipment. So, the question for the people involved in PG is: *how* can PG be improved to make use of this, and reap the very substantial speed gains in this scenario, without breaking the existing usage scenarios of PG in the traditional 'DB > RAM' scenario? The answer isn't "undermine the OS". The answer is "make the postmaster able to build and operate with persistent, query optimised representations of the disk data". Yes, I guess that might be a lot of work.. But the DB that delivers this performance will be very well placed in the next 5 years, don't you think? Thanks for your comments, Regards, Andy From pgsql-performance-owner@postgresql.org Tue Jul 20 04:50:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3F564D1B2D9 for ; Tue, 20 Jul 2004 04:50:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38418-07 for ; Tue, 20 Jul 2004 07:50:15 +0000 (GMT) Received: from notes.beauchamp.loxane.fr (unknown [217.167.112.209]) by svr1.postgresql.org (Postfix) with ESMTP id BF5D4D1B25F for ; Tue, 20 Jul 2004 04:50:09 -0300 (ADT) To: pgsql-performance@postgresql.org Subject: NAS, SAN or any alternate solution ? MIME-Version: 1.0 X-Mailer: Lotus Notes Release 5.0.10 March 22, 2002 Message-ID: From: bsimon@loxane.com Date: Tue, 20 Jul 2004 09:52:56 +0200 X-MIMETrack: Serialize by Router on notes/Loxane(Release 5.0.10 |March 22, 2002) at 20/07/2004 09:53:01, Serialize complete at 20/07/2004 09:53:01 Content-Type: multipart/alternative; boundary="=_alternative 002B6953C1256ED7_=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200407/118 X-Sequence-Number: 7509 Message en plusieurs parties au format MIME --=_alternative 002B6953C1256ED7_= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I've been searching the list for a while but couldn't find any up-to-date= =20 information relating to my problem. We have a production server with postgresql on cygwin that currently deels= =20 with about 200 Gigs of data (1 big IDE drive). We plan to move to linux=20 for some reasons I don't have to explain. Our aim is also to be able to increase our storage capacity up to=20 approximately 1 or 2 terabytes and to speed up our production process. As= =20 we are a small "microsoft addicted" company , we have some difficulties to= =20 choose the best configuration that would best meet our needs. Our production process is based on transaction (mostly huge inserts) and=20 disk access is the main bottlle-neck. Our main concern is hardware related : Would NAS or SAN be good solutions ? (I've read that NAS uses NFS which=20 could slow down the transfer rate ??) Has anyone ever tried one of these with postgresql ?=20 I would appreciate any comments. Thanks in advance. Benjamin. =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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Benjamin Simon - Ing=E9nieur D=E9veloppement Cartographie http://www.loxane.com tel : 01 30 40 24 00 Fax : 01 30 40 24 04 LOXANE=20 271, Chauss=E9e Jules C=E9sar 95250 Beauchamp France --=_alternative 002B6953C1256ED7_= Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi all,

I've been searching the list for a w= hile but couldn't find any up-to-date information relating to my problem.
We have a production server with pos= tgresql on cygwin that currently deels with about 200 Gigs of data (1 big I= DE drive). We plan to move to linux for some reasons I don't have to explai= n.
Our aim is also to be able to increa= se our storage capacity up to approximately 1 or 2 terabytes and to speed u= p our production process. As we are a small "microsoft addicted" = company , we have some difficulties to choose the best configuration that w= ould best meet our needs.
Our production process is based on t= ransaction (mostly huge inserts) and disk access is the main bottlle-neck.<= /font>

Our main concern is hardware related= :

Would NAS or SAN be good solutions ?= (I've read that NAS uses NFS which could slow down the transfer rate ??)
Has anyone ever tried one of these w= ith postgresql ?

I would appreciate any comments.
Thanks in advance.

Benjamin.

=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Benjamin Simon - Ing=E9nieur D=E9veloppement Cartographie
http://www.loxane.com
tel : 01 30 40 24 00
Fax : 01 30 40 24 04

LOXANE
271, Chauss=E9e Jules C=E9sar 95250 Beauchamp
France
--=_alternative 002B6953C1256ED7_=-- From pgsql-performance-owner@postgresql.org Tue Jul 20 05:20:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 62D7AD1B181 for ; Tue, 20 Jul 2004 05:20:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51364-09 for ; Tue, 20 Jul 2004 08:20:08 +0000 (GMT) Received: from mpls-qmqp-02.inet.qwest.net (mpls-qmqp-02.inet.qwest.net [63.231.195.113]) by svr1.postgresql.org (Postfix) with SMTP id D06C6D1B16E for ; Tue, 20 Jul 2004 05:20:04 -0300 (ADT) Received: (qmail 75742 invoked by uid 0); 20 Jul 2004 07:08:48 -0000 Received: from mpls-pop-06.inet.qwest.net (63.231.195.6) by mpls-qmqp-02.inet.qwest.net with QMQP; 20 Jul 2004 07:08:48 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-06.inet.qwest.net with SMTP; 20 Jul 2004 08:20:05 -0000 Date: Tue, 20 Jul 2004 02:20:56 -0600 Message-Id: <1090311656.709.14.camel@localhost.localdomain> From: "Scott Marlowe" To: bsimon@loxane.com Cc: pgsql-performance@postgresql.org Subject: Re: NAS, SAN or any alternate solution ? In-Reply-To: References: Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/119 X-Sequence-Number: 7510 On Tue, 2004-07-20 at 01:52, bsimon@loxane.com wrote: > Hi all, > > I've been searching the list for a while but couldn't find any > up-to-date information relating to my problem. > We have a production server with postgresql on cygwin that currently > deels with about 200 Gigs of data (1 big IDE drive). We plan to move > to linux for some reasons I don't have to explain. > Our aim is also to be able to increase our storage capacity up to > approximately 1 or 2 terabytes and to speed up our production process. > As we are a small "microsoft addicted" company , we have some > difficulties to choose the best configuration that would best meet our > needs. > Our production process is based on transaction (mostly huge inserts) > and disk access is the main bottlle-neck. > > Our main concern is hardware related : > > Would NAS or SAN be good solutions ? (I've read that NAS uses NFS > which could slow down the transfer rate ??) > Has anyone ever tried one of these with postgresql ? Your best bet would likely be a large external RAID system with lots o cache. Next would be a fast internal RAID card like the LSI Megaraid cards, with lots of drives and batter backed cache. Next would be a SAN, but be careful, there may be issues with some cards and their drivers under linux, research them well before deciding. NFS is right out if you want good performance AND reliability. The cheapest solution that is likely to meet your needs would be the internal RAID card with battery backed cache. From pgsql-performance-owner@postgresql.org Tue Jul 20 06:29:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A517DD1B2E0 for ; Tue, 20 Jul 2004 06:29:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81860-09 for ; Tue, 20 Jul 2004 09:29:32 +0000 (GMT) Received: from notes.beauchamp.loxane.fr (unknown [217.167.112.209]) by svr1.postgresql.org (Postfix) with ESMTP id 82272D1B257 for ; Tue, 20 Jul 2004 06:29:27 -0300 (ADT) To: pgsql-performance@postgresql.org Subject: =?iso-8859-1?Q?R=E9f=2E_=3A_Re=3A__NAS=2C_SAN_or_any_alternate?= solution ? MIME-Version: 1.0 X-Mailer: Lotus Notes Release 5.0.10 March 22, 2002 Message-ID: From: bsimon@loxane.com Date: Tue, 20 Jul 2004 11:32:15 +0200 X-MIMETrack: Serialize by Router on notes/Loxane(Release 5.0.10 |March 22, 2002) at 20/07/2004 11:32:19, Serialize complete at 20/07/2004 11:32:19 Content-Type: multipart/alternative; boundary="=_alternative 0034812AC1256ED7_=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200407/120 X-Sequence-Number: 7511 Message en plusieurs parties au format MIME --=_alternative 0034812AC1256ED7_= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks a lot Scott. It seems that we were totally wrong when considering a network storage=20 solution. I've read your techdoc=20 http://techdocs.postgresql.org/guides/DiskTuningGuide and found many=20 interesting remarks.=20 I think that we will know focus on external Raid systems which seem to be= =20 relativily affordable compared to NAS or SAN (we would have had the budget= =20 for one of these).=20 As we don't plan to have more than 5 connections (I.E process), we think=20 SATA drives would fit our requirements. Could this be an issue for an=20 after crash recovery ? We also hesitate concerning the raid level to use. We are currently=20 comparing raid 1+0 and raid 5 but we have no actual idea on which one to=20 use. Our priorities are :=20 1) performance 2) recovery 3) price 4) back-up=20 It could be nice to have any comments from people who have already set up= =20 a similar platform, giving some precise details of the hardware=20 configuration : - brand of the raid device,=20 - technology used (SCSI/IDE, RAID level ...),=20 - size of the database, number of disks/size of disks ... Such a knowledge base may be useful to convince people to migrate to=20 opensource cheap reliable solutions.=20 Thanks again. Benjamin. "Scott Marlowe" Envoy=E9 par : pgsql-performance-owner@postgresql.org 20/07/2004 10:20 =20 Pour : bsimon@loxane.com cc : pgsql-performance@postgresql.org Objet : Re: [PERFORM] NAS, SAN or any alternate solution ? On Tue, 2004-07-20 at 01:52, bsimon@loxane.com wrote: > Hi all, >=20 > I've been searching the list for a while but couldn't find any > up-to-date information relating to my problem. > We have a production server with postgresql on cygwin that currently > deels with about 200 Gigs of data (1 big IDE drive). We plan to move > to linux for some reasons I don't have to explain. > Our aim is also to be able to increase our storage capacity up to > approximately 1 or 2 terabytes and to speed up our production process. > As we are a small "microsoft addicted" company , we have some > difficulties to choose the best configuration that would best meet our > needs. > Our production process is based on transaction (mostly huge inserts) > and disk access is the main bottlle-neck. >=20 > Our main concern is hardware related : >=20 > Would NAS or SAN be good solutions ? (I've read that NAS uses NFS > which could slow down the transfer rate ??) > Has anyone ever tried one of these with postgresql ?=20 Your best bet would likely be a large external RAID system with lots o cache. Next would be a fast internal RAID card like the LSI Megaraid cards, with lots of drives and batter backed cache. Next would be a SAN, but be careful, there may be issues with some cards and their drivers under linux, research them well before deciding. NFS is right out if you want good performance AND reliability. The cheapest solution that is likely to meet your needs would be the internal RAID card with battery backed cache.=20 ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html --=_alternative 0034812AC1256ED7_= Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thanks a lot Scott.

It seems that we were totally wrong = when considering a network storage solution. I've read your techdoc http://= techdocs.postgresql.org/guides/DiskTuningGuide and found many interesting r= emarks.
I think that we will know focus on e= xternal Raid systems which seem to be relativily affordable compared to NAS= or SAN (we would have had the budget for one of these).
As we don't plan to have more than 5= connections (I.E process), we think SATA drives would fit our requirements= . Could this be an issue for an after crash recovery ?
We also hesitate concerning the raid= level to use. We are currently comparing raid 1+0 and raid 5 but we have n= o actual idea on which one to use.

Our priorities are :
1) performance
2) recovery
3) price
4) back-up

It could be nice to have any comment= s from people who have already set up a similar platform, giving some preci= se details of the hardware configuration :
        - brand = of the raid device,
        - techno= logy used (SCSI/IDE, RAID level ...),
        - size o= f the database, number of disks/size of disks ...

Such a knowledge base may be useful = to convince people to migrate to opensource cheap reliable solutions.
Thanks again.

Benjamin.




"Scott Marlowe" <sma= rlowe@qwest.net>
Envoy=E9 par : pgsql-performance-own= er@postgresql.org

20/07/2004 10:20

       
        Pour : &= nbsp;      bsimon@loxane.com
        cc : &nb= sp;      pgsql-performance@postgresql.org
        Objet : =        Re: [PERFORM] NAS, SAN or any alternate solution= ?



On Tue, 2004-07-20 at 01:52, bsimon= @loxane.com wrote:
> Hi all,
>
> I've been searching the list for a while but couldn't find any
> up-to-date information relating to my problem.
> We have a production server with postgresql on cygwin that currently > deels with about 200 Gigs of data (1 big IDE drive). We plan to move > to linux for some reasons I don't have to explain.
> Our aim is also to be able to increase our storage capacity up to
> approximately 1 or 2 terabytes and to speed up our production process.=
> As we are a small "microsoft addicted" company , we have som= e
> difficulties to choose the best configuration that would best meet our=
> needs.
> Our production process is based on transaction (mostly huge inserts) > and disk access is the main bottlle-neck.
>
> Our main concern is hardware related :
>
> Would NAS or SAN be good solutions ? (I've read that NAS uses NFS
> which could slow down the transfer rate ??)
> Has anyone ever tried one of these with postgresql ?

Your best bet would likely be a large external RAID system with lots o
cache.  Next would be a fast internal RAID card like the LSI Megaraid<= br> cards, with lots of drives and batter backed cache.  Next would be a SAN, but be careful, there may be issues with some cards and their
drivers under linux, research them well before deciding.  NFS is right=
out if you want good performance AND reliability.

The cheapest solution that is likely to meet your needs would be the
internal RAID card with battery backed cache.  


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

              http://www.postgresql.org= /docs/faqs/FAQ.html


--=_alternative 0034812AC1256ED7_=-- From pgsql-performance-owner@postgresql.org Tue Jul 20 07:02:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 05FEED1B257 for ; Tue, 20 Jul 2004 07:02:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01608-03 for ; Tue, 20 Jul 2004 10:02:07 +0000 (GMT) Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [202.0.58.20]) by svr1.postgresql.org (Postfix) with ESMTP id EE3E6D1B1B3 for ; Tue, 20 Jul 2004 07:02:04 -0300 (ADT) Received: from smtp-2.paradise.net.nz (smtp-2b.paradise.net.nz [202.0.32.211]) by linda-1.paradise.net.nz (Paradise.net.nz) with ESMTP id <0I1500GO2AJI9M@linda-1.paradise.net.nz> for pgsql-performance@postgresql.org; Tue, 20 Jul 2004 22:02:07 +1200 (NZST) Received: from coretech.co.nz (218-101-12-189.paradise.net.nz [218.101.12.189]) by smtp-2.paradise.net.nz (Postfix) with ESMTP id 76C109E4CD; Tue, 20 Jul 2004 22:02:06 +1200 (NZST) Date: Tue, 20 Jul 2004 22:04:28 +1200 From: Mark Kirkwood Subject: Re: =?ISO-8859-1?Q?R=E9f=2E_=3A_Re=3A_=5BPERFORM=5D_NAS=2C?= In-reply-to: To: bsimon@loxane.com Cc: pgsql-performance@postgresql.org Message-id: <40FCEE2C.5080502@coretech.co.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=us-ascii Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040429 References: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/121 X-Sequence-Number: 7512 bsimon@loxane.com wrote: > > As we don't plan to have more than 5 connections (I.E process), we > think SATA drives would fit our requirements. Could this be an issue > for an after crash recovery ? > If you can disable the write ATA write cache, then you have safety. Unfortunately many cards under Linux show up as SCSI devices, and you can't access this setting. Does anyone know if the newer SATA cards let you control this? You might want to keep and eye on the upcoming native windows port in 7.5 - It will come with a fearsome array of caveats... but you have been running cygwin in production! - and I am inclined to think the native port will be more solid than this configuration. regards Mark From pgsql-performance-owner@postgresql.org Tue Jul 20 07:15:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D8894D1B269 for ; Tue, 20 Jul 2004 07:15:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10002-05 for ; Tue, 20 Jul 2004 10:15:28 +0000 (GMT) Received: from notes.beauchamp.loxane.fr (unknown [217.167.112.209]) by svr1.postgresql.org (Postfix) with ESMTP id 4B7B1D1B181 for ; Tue, 20 Jul 2004 07:15:23 -0300 (ADT) To: pgsql-performance@postgresql.org Subject: =?iso-8859-1?Q?R=E9f=2E_=3A_Re=3A_R=E9f=2E_=3A_Re=3A__NAS=2C_SAN?= or any alternate solution ? MIME-Version: 1.0 X-Mailer: Lotus Notes Release 5.0.10 March 22, 2002 Message-ID: From: bsimon@loxane.com Date: Tue, 20 Jul 2004 12:18:10 +0200 X-MIMETrack: Serialize by Router on notes/Loxane(Release 5.0.10 |March 22, 2002) at 20/07/2004 12:18:15, Serialize complete at 20/07/2004 12:18:15 Content-Type: multipart/alternative; boundary="=_alternative 0038B517C1256ED7_=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=HTML_20_30, HTML_MESSAGE, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200407/122 X-Sequence-Number: 7513 Message en plusieurs parties au format MIME --=_alternative 0038B517C1256ED7_= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I must say that cygwin did well (there exists good software on windows,=20 i've found one)... as a prototype ... when I look at the postgresql poll=20 (http://www.postgresql.org/survey.php?View=3D1&SurveyID=3D11), it seems lik= e=20 I'm not alone !! Actually, the major problem was the limit of the available allocable=20 memory restricted by cygwin. We don't plan to wait for the 7.5 win native version of postgresql. It was= =20 hard enough to decide moving to linux, I don't want to rollback=20 everything :) Thanks for the advice, I will definetely have a look at the new version=20 anyway as soon as it is released. Regards, Benjamin. Mark Kirkwood 20/07/2004 12:04 =20 Pour : bsimon@loxane.com cc : pgsql-performance@postgresql.org Objet : Re: R=E9f. : Re: [PERFORM] NAS, SAN or any alternate soluti= on ? bsimon@loxane.com wrote: > > As we don't plan to have more than 5 connections (I.E process), we=20 > think SATA drives would fit our requirements. Could this be an issue=20 > for an after crash recovery ? > If you can disable the write ATA write cache, then you have safety.=20 Unfortunately many cards under Linux show up as SCSI devices, and you=20 can't access this setting. Does anyone know if the newer SATA cards let=20 you control this? You might want to keep and eye on the upcoming native windows port in=20 7.5 - It will come with a fearsome array of caveats... but you have been=20 running cygwin in production! - and I am inclined to think the native=20 port will be more solid than this configuration. regards Mark --=_alternative 0038B517C1256ED7_= Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I must say that cygwin did well (the= re exists good software on windows, i've found one)... as a prototype ... w= hen I look at the postgresql poll (http://www.postgresql.org/survey.php?Vie= w=3D1&SurveyID=3D11), it seems like I'm not alone !!
Actually, the major problem was the = limit of the available allocable memory restricted by cygwin.

We don't plan to wait for the 7.5 wi= n native version of postgresql. It was hard enough to decide moving to linu= x, I don't want to  rollback everything :)
Thanks for the advice, I will define= tely have a look at the new version anyway as soon as it is released.

Regards,
Benjamin.



Mark Kirkwood <markir@coretech= .co.nz>

20/07/2004 12:04

       
        Pour : &= nbsp;      bsimon@loxane.com
        cc : &nb= sp;      pgsql-performance@postgresql.org
        Objet : =        Re: R=E9f. : Re: [PERFORM] NAS, SAN or any alter= nate solution ?





bsimon@loxane.com wrote:

>
> As we don't plan to have more than 5 connections (I.E process), we
> think SATA drives would fit our requirements. Could this be an issue <= br> > for an after crash recovery ?
>
If you can disable the write ATA write cache, then you have safety.
Unfortunately many cards under Linux show up as SCSI devices, and you
can't access this setting. Does anyone know if the newer SATA cards let
you control this?

You might want to keep and eye on the upcoming native windows port in
7.5 - It will come with a fearsome array of caveats... but you have been running cygwin in production! - and I am inclined to think the native
port will be more solid than this configuration.

regards

Mark








--=_alternative 0038B517C1256ED7_=-- From pgsql-performance-owner@postgresql.org Tue Jul 20 07:45:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 96559D1B257 for ; Tue, 20 Jul 2004 07:45:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22577-01 for ; Tue, 20 Jul 2004 10:45:11 +0000 (GMT) Received: from smtp-out2.blueyonder.co.uk (smtp-out2.blueyonder.co.uk [195.188.213.5]) by svr1.postgresql.org (Postfix) with ESMTP id 1F30FD1B229 for ; Tue, 20 Jul 2004 07:45:06 -0300 (ADT) Received: from lappy ([82.43.186.234]) by smtp-out2.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Tue, 20 Jul 2004 11:45:26 +0100 Message-ID: <010a01c46e46$9fc7e420$0300a8c0@lappy> From: "abhousehunt" To: References: <6EE64EF3AB31D5448D0007DD34EEB34101AECA@Herge.rcsinc.local> Subject: Re: Working on huge RAM based datasets Date: Tue, 20 Jul 2004 11:45:07 +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.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-OriginalArrivalTime: 20 Jul 2004 10:45:26.0031 (UTC) FILETIME=[AA7D21F0:01C46E46] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/123 X-Sequence-Number: 7514 Sorry for the late reply - I've been away, and I've had problems posting too :( Merlin, I'd like to come back with a few more points! >That's the whole point: memory is a limited resource. If pg is >crawling, then the problem is simple: you need more memory. My posting only relates to the scenario where RAM is not a limiting factor, a scenario which shall become increasingly common over the next few years, as 64 bit processors and OSs allow the exploitation of ever larger, ever cheaper RAM. Incidentally, If PG is crawling, memory might be the problem...but not necessarily - could be disk bound on writes. > The question is: is it postgresql's responsibility to manage that resource? I think you are confusing the issue of RAM and address space. Any application can acquire a piece of address space for its own use. It is the responsibility of the application to do what it needs with that address space. I'm interested in how PG could do something better in its address space when it knows that it can fit all the data it operates on within that address space. Though the OS is responsible for determining whether that address space is RAM resident or not, in my scenario, this is irrelevant, because there *will* be enough RAM for everything, and the OS will, in that scenario, allow all the address space to become RAM resident. I am not advocating undermining the OS in any way. It would be stupid to make PGSQL take over the running of the hardware. I've learned the hard way that bypassing the OS is just a big pain up the backside! >Pg is a data management tool, not a memory management tool. I'm not criticising PG. PG is actually a 'DISK/MEMORY' data management tool. It manages data which lives on disks, but it can only operate on that data in memory, and goes to some lengths to try to fit bits of disk data in a defined piece of memory, and push them back out again. At the moment, this model assumes that RAM is a scarce resource. The model still 'sort of' works when RAM is actually not scarce, because the OS effectively uses that extra RAM to make IO *appear* to be quicker, and indeed, I've found that a hint has been added to PG to tell it how much the OS is likely to be caching. But the question is this: "If you wrote a DB from scratch with the assumption that *all* the data could fit in the address space allocated by the postmaster, and you were confident that the OS had enough RAM so that you never suffered vmem page misses, couldn't you make things go much faster?" A more pertinent question is: "Could PG be extended to have a flag, which when enabled, told it to operate with the assumption that it could fit all the disk data in RAM, and implement the data organisation optimisations that rely on the persistence of data in address space?" >The same >'let's manage everything' argument also frequently gets brought up wrt >file i/o, because people assume the o/s sucks at file management. Well, I'm not saying this. I have substantial experience with high performance file IO through a filesystem. But if you are interested in high speed IO, naive 'let the OS do everything' approach isn't often good enough. You, the application, have to be aware that the order and timing of IO requests, along with the size of IO block you cause to trigger, have a dramatic impact on the speed with which the data reaches your app, OS or no OS. Most high speed storage still relies on spinning things containing data that can only be accessed in a certain way, and data movement is page boundary sensitive. The OS may hide these details from you, but you, the app writer, have to have an understanding of the underlying reality if you want to optimise performance. I want to stress that at no point am I advocating *not* using the OS. PG should do ALL IO and memory allocation through the OS, otherwise you end up with a platform specific product that is of little use. That given, there is still the opportunity for PG to be able to operate far more efficiently in my high memory scenario. Wouldn't your backend processes like to have the entire database sitting ready in address space (ram resident, of course!), indexes all fully built? No tuple more than a few machine instructions away? Imagine the postmaster isn't having to frantically decide which bits of data to kick out of the workspace in order to keep the backends happy. Imagine the postmaster isn't having to build structures to keep track of the newly read in blocks of data from 'disk' (or OS cache). Imagine that everything was just there... Is this not a compelling scenario? >At some point, hard disks will be replaced by solid state memory >technologies... This is irrelevant to my scenario. The optimisations I crave are to do with getting the entire database in a query-optimised form near to the CPUS - i.e. in fast RAM. (I'd expect solid state disk ram to be much slower than the RAM that sits nearer the CPU). The speed of the persistent storage system (whether spinning platters or some sort of persistent solid state memory) isn't really of direct relevance to my argument. Solid state disks would allow write speeds to improve, which would add to the gains which I am fishing for. So when they come, I'll be happy. Still. Solid state disks aren't really an option right now. Big RAM is. >do you really want to recode your memory manager when >this happens because all your old assumptions are no longer correct? My scenario assumes nothing about how the data is stored, but you are right to flag the problems that arise when original assumptions about hardware become incorrect. For example, PG assumes that RAM is a rare resource, and it assumes the postmaster cannot fit the entire database in a single address space. *These* assumptions are now not correct, following the 64bit address space breakthrough. The availability of 64 bit addressing and huge banks of RAM is of enormous significance to databases, and it is the whole reason for my post. Over the next 5-10 years, an increasing proportion of databases will fit comfortably in RAM resident address space on commodity equipment. My particular nationwide application will fit into RAM now. Hence my interest! So, the question for the people involved in PG is: *how* can PG be improved to make use of this, and reap the very substantial speed gains in this scenario, without breaking the existing usage scenarios of PG in the traditional 'DB > RAM' scenario? The answer isn't "undermine the OS". The answer might be"make the postmaster able to build and operate with persistent, query optimised representations of the disk data". Yes, I guess that might be a lot of work.. But the DB that delivers this performance will be very well placed in the next 5 years, don't you think? Anyway - I look forward to further feedback, and thanks for your comments so far. Regards, Andy From pgsql-performance-owner@postgresql.org Tue Jul 20 08:51:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 923C5D1B298 for ; Tue, 20 Jul 2004 08:51:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50819-01 for ; Tue, 20 Jul 2004 11:51:20 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id A2339D1B269 for ; Tue, 20 Jul 2004 08:51:13 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1Bmt9Q-00058y-00 for ; Tue, 20 Jul 2004 13:51:16 +0200 Date: Tue, 20 Jul 2004 13:51:16 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Message-ID: <20040720115116.GB19633@uio.no> References: <20040708101913.GA15871@uio.no> <200407141841.01863.josh@agliodbs.com> <16637.1089867158@sss.pgh.pa.us> <20040715120854.GA31259@uio.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040715120854.GA31259@uio.no> X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/124 X-Sequence-Number: 7515 On Thu, Jul 15, 2004 at 02:08:54PM +0200, Steinar H. Gunderson wrote: > sort_mem is already 16384, which I thought would be plenty -- I tried > increasing it to 65536 which made exactly zero difference. :-) I've tried some further tweaking, but I'm still unable to force it into doing a hash join -- any ideas how I can find out why it chooses a merge join? /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Tue Jul 20 09:26:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6B643D1B387 for ; Tue, 20 Jul 2004 09:26:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67001-01 for ; Tue, 20 Jul 2004 12:26:02 +0000 (GMT) Received: from mail.najdi.si (elfstone.noviforum.si [193.189.169.107]) by svr1.postgresql.org (Postfix) with ESMTP id 28BF5D1B386 for ; Tue, 20 Jul 2004 09:25:57 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by elfstone.noviforum.si (ESMTP) with ESMTP id D97571B91C; Tue, 20 Jul 2004 14:24:08 +0200 (CEST) Received: from elbereth.noviforum.si (elbereth.noviforum.si [192.168.2.26]) by elfstone.noviforum.si (ESMTP) with ESMTP id 9F92B1B916; Tue, 20 Jul 2004 14:24:08 +0200 (CEST) Received: from elbereth.noviforum.si (localhost [127.0.0.1]) by elbereth.noviforum.si (8.12.10/8.12.10) with ESMTP id i6KCNZWg017470; Tue, 20 Jul 2004 14:23:35 +0200 Received: (from gregab@localhost) by elbereth.noviforum.si (8.12.10/8.12.10/Submit) id i6KCNZrC017469; Tue, 20 Jul 2004 14:23:35 +0200 Date: Tue, 20 Jul 2004 14:23:35 +0200 From: Grega Bremec To: bsimon@loxane.com Cc: pgsql-performance@postgresql.org Subject: Re: NAS, SAN or any alternate solution ? Message-ID: <20040720122335.GD16410@elbereth.noviforum.si> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/3yNEOqWowh/8j+e" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2i Organization: Noviforum, Ltd., Software & Media X-Virus-Scanned: by Najdi.si X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/125 X-Sequence-Number: 7516 --/3yNEOqWowh/8j+e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable ...and on Tue, Jul 20, 2004 at 09:52:56AM +0200, bsimon@loxane.com used the= keyboard: > Hi all, >=20 > I've been searching the list for a while but couldn't find any up-to-date= =20 > information relating to my problem. > We have a production server with postgresql on cygwin that currently deel= s=20 > with about 200 Gigs of data (1 big IDE drive). We plan to move to linux= =20 > for some reasons I don't have to explain. > Our aim is also to be able to increase our storage capacity up to=20 > approximately 1 or 2 terabytes and to speed up our production process. As= =20 > we are a small "microsoft addicted" company , we have some difficulties t= o=20 > choose the best configuration that would best meet our needs. > Our production process is based on transaction (mostly huge inserts) and= =20 > disk access is the main bottlle-neck. >=20 > Our main concern is hardware related : >=20 > Would NAS or SAN be good solutions ? (I've read that NAS uses NFS which= =20 > could slow down the transfer rate ??) > Has anyone ever tried one of these with postgresql ?=20 >=20 > I would appreciate any comments. > Thanks in advance. Hello Simon, We're testing 3ware Escalade 9000, which is a hardware-raid SATA controller with VERY good support for Linux (including direct access for S.M.A.R.T. applications, which is a serious problem with other RAID controllers), featuring RAID levels 0, 1, 10, 5, JBOD, up to 12 SATA channels (that's 3ware Escalade 9500S-12, they also come in 4- and 8-channel versions, up to four cards can be fitted into a system), up to 1GB battery-backed ECC RAM (128MB out-of-the-box) and most of all, excellent tuning guides that actually manage to exceed the scope of merely making you come up with good benchmark results for that controller in a specific test environment. Our preliminary tests show that a setup of four 250GB SATA Maxtors that aren't really qualified as fast drives, in RAID5 can deliver block writes of 50MB/s, rewrites at about 35MB/s and reads of approximately 180MB/s, which is rougly 2.5-times the performance of previous Escalades. You can find more info on Escalade 9000 series, benchmarks and other stuff here: http://www.3ware.com/products/serial_ata9000.asp http://www.3ware.com/products/benchmarks_sata.asp http://www.3ware.dk/fileadmin/3ware/documents/Benchmarks/Linux_kernel_2= .6_Benchmarking.pdf Oh, and not to forget - the price for a 3ware 9500S-12, the version we're testing ranges between EUR1000 and EUR1500, depending on the contract you have with the reseller and the intended use of the device. SATA disks are dirt-cheap nowadays, as has been mentioned before. I do agree on the reliability of cache-usage setting those drives report though, it may or may not be true. But one never knows that for sure with SCSI drives either. At least you can assert that proper controller cache sizing with drives that usually feature 8MB (!!!) cache, will mostly ensure that even the largest amount of data that could fit into a hard disk cache of the entire array (96MB) will still be available in the controller cache after a power failure, for it to be re-checked and ensured it is properly written. Hope this helps, --=20 Grega Bremec Senior Administrator Noviforum Ltd., Software & Media http://www.noviforum.si/ --/3yNEOqWowh/8j+e Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFA/Q7HDo/EMYD4+osRAvHwAJ4jVHn/BXzgebgCo+xHAh3/r3Z+AACeJKCR DnvCEwTap6rIRrCxH0bEf5g= =22vO -----END PGP SIGNATURE----- --/3yNEOqWowh/8j+e-- From pgsql-performance-owner@postgresql.org Tue Jul 20 10:04:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DADD8D1B25F for ; Tue, 20 Jul 2004 10:04:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82790-06 for ; Tue, 20 Jul 2004 13:04:01 +0000 (GMT) Received: from mail.najdi.si (elfstone.noviforum.si [193.189.169.107]) by svr1.postgresql.org (Postfix) with ESMTP id E089BD1B1BE for ; Tue, 20 Jul 2004 10:03:57 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by elfstone.noviforum.si (ESMTP) with ESMTP id DEFE31B916; Tue, 20 Jul 2004 15:02:08 +0200 (CEST) Received: from elbereth.noviforum.si (elbereth.noviforum.si [192.168.2.26]) by elfstone.noviforum.si (ESMTP) with ESMTP id A74461B913; Tue, 20 Jul 2004 15:02:08 +0200 (CEST) Received: from elbereth.noviforum.si (localhost [127.0.0.1]) by elbereth.noviforum.si (8.12.10/8.12.10) with ESMTP id i6KD1ZWg017565; Tue, 20 Jul 2004 15:01:35 +0200 Received: (from gregab@localhost) by elbereth.noviforum.si (8.12.10/8.12.10/Submit) id i6KD1Z47017564; Tue, 20 Jul 2004 15:01:35 +0200 Date: Tue, 20 Jul 2004 15:01:35 +0200 From: Grega Bremec To: bsimon@loxane.com Cc: pgsql-performance@postgresql.org Subject: Re: NAS, SAN or any alternate solution ? Message-ID: <20040720130135.GE16410@elbereth.noviforum.si> References: <20040720122335.GD16410@elbereth.noviforum.si> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="uCPdOCrL+PnN2Vxy" Content-Disposition: inline In-Reply-To: <20040720122335.GD16410@elbereth.noviforum.si> User-Agent: Mutt/1.4.2i Organization: Noviforum, Ltd., Software & Media X-Virus-Scanned: by Najdi.si X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/126 X-Sequence-Number: 7517 --uCPdOCrL+PnN2Vxy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable >=20 > Oh, and not to forget - the price for a 3ware 9500S-12, the version > we're testing ranges between EUR1000 and EUR1500, depending on the > contract you have with the reseller and the intended use of the > device. SATA disks are dirt-cheap nowadays, as has been mentioned > before. >=20 Correction, EUR500 and EUR1000, VAT not included. :) Sorry for the mix-up. --=20 Grega Bremec Senior Administrator Noviforum Ltd., Software & Media http://www.noviforum.si/ --uCPdOCrL+PnN2Vxy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFA/RevDo/EMYD4+osRAqyYAJ4seej4xqPCMDtviSukIrGE+uHmVwCfYLDm MDeQgxFcZJ/UzoI5qU4vSPc= =aIPl -----END PGP SIGNATURE----- --uCPdOCrL+PnN2Vxy-- From pgsql-performance-owner@postgresql.org Tue Jul 20 12:27:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5C47ED1B1FD for ; Tue, 20 Jul 2004 12:27:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56815-08 for ; Tue, 20 Jul 2004 15:27:46 +0000 (GMT) Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net [63.231.195.114]) by svr1.postgresql.org (Postfix) with SMTP id B011AD1B1E0 for ; Tue, 20 Jul 2004 12:27:44 -0300 (ADT) Received: (qmail 96583 invoked by uid 0); 20 Jul 2004 14:57:08 -0000 Received: from mpls-pop-03.inet.qwest.net (63.231.195.3) by mpls-qmqp-03.inet.qwest.net with QMQP; 20 Jul 2004 14:57:08 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-03.inet.qwest.net with SMTP; 20 Jul 2004 15:27:43 -0000 Date: Tue, 20 Jul 2004 09:28:54 -0600 Message-Id: <1090337334.709.21.camel@localhost.localdomain> From: "Scott Marlowe" To: bsimon@loxane.com Cc: pgsql-performance@postgresql.org Subject: Re: =?ISO-8859-1?Q?R=E9f=2E?= : Re: NAS, SAN or any In-Reply-To: References: Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/127 X-Sequence-Number: 7518 On Tue, 2004-07-20 at 03:32, bsimon@loxane.com wrote: > Thanks a lot Scott. > > It seems that we were totally wrong when considering a network storage > solution. I've read your techdoc > http://techdocs.postgresql.org/guides/DiskTuningGuide and found many > interesting remarks. > I think that we will know focus on external Raid systems which seem to > be relativily affordable compared to NAS or SAN (we would have had the > budget for one of these). > As we don't plan to have more than 5 connections (I.E process), we > think SATA drives would fit our requirements. Could this be an issue > for an after crash recovery ? If you're looking at (S)ATA RAID, definitely look at escalade, as another poster mentioned. Last year I and a few other folks on the lists were testing RAID controllers for survival of the power plug pull test, and the Escalade passed (someone else did the testing, I tested the LSI MegaRAID 320-2 controller with battery backed cache). > We also hesitate concerning the raid level to use. We are currently > comparing raid 1+0 and raid 5 but we have no actual idea on which one > to use. > > Our priorities are : > 1) performance > 2) recovery > 3) price > 4) back-up Basically, for a smaller number of drivers, RAID 1+0 is almost always a win over RAID 5. As the number of drives in the array grows, RAID 5 usually starts to pull back in the lead. RAID 5 definitely gives you the most storage for your dollar of any of the redundant array types. The more important point of a RAID controller is that it have battery backed cache to make sure that the database server isn't waiting for WAL writes all the time. A single port LSI Megaraid 320-1 controller is only about $500 or less, the last time I checked (with battery backed cache, order it WITH the battery and cache, otherwise you may have a hard time finding the right parts later on.) It supports hot spares for automatic rebuild. From pgsql-performance-owner@postgresql.org Tue Jul 20 13:45:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 71669D1B1FD for ; Tue, 20 Jul 2004 13:44:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00334-07 for ; Tue, 20 Jul 2004 16:44:45 +0000 (GMT) Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by svr1.postgresql.org (Postfix) with ESMTP id D2FD2D1B18A for ; Tue, 20 Jul 2004 13:44:43 -0300 (ADT) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 1985963; Tue, 20 Jul 2004 09:36:42 -0700 Message-ID: <40FD4BFA.5010807@joeconway.com> Date: Tue, 20 Jul 2004 09:44:42 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510 X-Accept-Language: en-us, en MIME-Version: 1.0 To: bsimon@loxane.com Cc: pgsql-performance@postgresql.org Subject: Re: NAS, SAN or any alternate solution ? References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/128 X-Sequence-Number: 7519 bsimon@loxane.com wrote: > Would NAS or SAN be good solutions ? (I've read that NAS uses NFS which > could slow down the transfer rate ??) > Has anyone ever tried one of these with postgresql ? Not (yet) with Postgres, but my company has run ~100GB Oracle database on NAS (NetApp) for the past couple of years. We've found it to outperform local attached storage, and it has been extremely reliable and flexible. Our DBAs wouldn't give it up without a fight. Joe From pgsql-performance-owner@postgresql.org Tue Jul 20 14:03:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 674C1D1B38A for ; Tue, 20 Jul 2004 14:03:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13261-02 for ; Tue, 20 Jul 2004 17:03:43 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 77F9FD1B387 for ; Tue, 20 Jul 2004 14:03:41 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5827667; Tue, 20 Jul 2004 10:04:53 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Steinar H. Gunderson" , pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Date: Tue, 20 Jul 2004 10:02:49 -0700 User-Agent: KMail/1.4.3 References: <20040708101913.GA15871@uio.no> <20040715120854.GA31259@uio.no> <20040720115116.GB19633@uio.no> In-Reply-To: <20040720115116.GB19633@uio.no> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200407201002.49828.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/129 X-Sequence-Number: 7520 Steinar, > I've tried some further tweaking, but I'm still unable to force it into > doing a hash join -- any ideas how I can find out why it chooses a merge > join? I'm sorry, I can't really give your issue the attention it deserves. At this point, I'd have to get a copy of your database, and play around with alternate query structures; and I don't have time. Sorry! -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Jul 20 14:07:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B3F1ED1B285 for ; Tue, 20 Jul 2004 14:07:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15852-03 for ; Tue, 20 Jul 2004 17:07:01 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 9701CD1B2D9 for ; Tue, 20 Jul 2004 14:07:00 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 5827699; Tue, 20 Jul 2004 10:08:11 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Steinar H. Gunderson" , pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Date: Tue, 20 Jul 2004 10:06:08 -0700 User-Agent: KMail/1.4.3 References: <20040708101913.GA15871@uio.no> <20040715120854.GA31259@uio.no> <20040720115116.GB19633@uio.no> In-Reply-To: <20040720115116.GB19633@uio.no> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200407201006.08649.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/130 X-Sequence-Number: 7521 Steinar, > I've tried some further tweaking, but I'm still unable to force it into > doing a hash join -- any ideas how I can find out why it chooses a merge > join? Actually, quick question -- have you tried setting enable_mergjoin=false to see the plan the system comes up with? Is it in fact faster? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Jul 20 14:21:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A4C98D1B1E0 for ; Tue, 20 Jul 2004 14:21:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19121-10 for ; Tue, 20 Jul 2004 17:21:05 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 147EAD1B18A for ; Tue, 20 Jul 2004 14:21:00 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1BmyIW-0005oh-00 for ; Tue, 20 Jul 2004 19:21:00 +0200 Date: Tue, 20 Jul 2004 19:21:00 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Message-ID: <20040720172100.GA22262@uio.no> References: <20040708101913.GA15871@uio.no> <20040715120854.GA31259@uio.no> <20040720115116.GB19633@uio.no> <200407201006.08649.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200407201006.08649.josh@agliodbs.com> X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/131 X-Sequence-Number: 7522 On Tue, Jul 20, 2004 at 10:06:08AM -0700, Josh Berkus wrote: > Actually, quick question -- have you tried setting enable_mergjoin=false to > see the plan the system comes up with? Is it in fact faster? It is significantly faster -- 1200ms vs. 1900ms (on 7.4, at least). Some of the merge joins are changed to nested loop joins, though, which probably reduces the overall performance, so I guess there's more to gain if I can get it to convert only that merge join to a hash join. The sum and multiplication parts still take 400ms or so, though (is this normal? :-) ), so I guess there's a lower limit :-) I could of course post the updated query plan if anybody is interested; let me know. (The data is still available if anybody needs it as well, of course.) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Tue Jul 20 14:30:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8176ED1B182 for ; Tue, 20 Jul 2004 14:30:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24681-05 for ; Tue, 20 Jul 2004 17:30:02 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 643DBD1B343 for ; Tue, 20 Jul 2004 14:29:59 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id C36E076C34; Tue, 20 Jul 2004 13:25:26 -0400 (EDT) Subject: Re: NAS, SAN or any alternate solution ? From: Rod Taylor To: bsimon@loxane.com Cc: Postgresql Performance In-Reply-To: References: Content-Type: text/plain Message-Id: <1090344321.7056.105.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 20 Jul 2004 13:25:22 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/132 X-Sequence-Number: 7523 > Would NAS or SAN be good solutions ? (I've read that NAS uses NFS > which could slow down the transfer rate ??) > Has anyone ever tried one of these with postgresql ? I've used both a NetApp and Hitachi based SANs with PostgreSQL. Both work as well as expected, but do require some tweeking as they normally are not optimized for the datablock size that PostgreSQL likes to deal with (8k by default) -- this can make as much as a 50% difference in performance levels. For a NAS setup, be VERY careful that the NFS implementation you're using has the semantics that the database requires (do plenty of failure testing -- pull plugs and things at random). iSCSI looks more promising, but I've not tested how gracefully it fails. Have your supplier run a bunch of benchmarks for random IO with 8k blocks. One side note, SANs seem to be very good at scaling across multiple jobs from multiple sources, but beware your Fibre Channel drivers -- mine seems to spend quite a bit of time managing interrupts and I've not found a way to put it into a polling mode (I'm not a Linux person and that trick usually happens for me on the BSDs). From pgsql-performance-owner@postgresql.org Tue Jul 20 16:19:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D9246D1B1D1 for ; Tue, 20 Jul 2004 16:19:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79510-07 for ; Tue, 20 Jul 2004 19:19:15 +0000 (GMT) Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net [67.119.5.202]) by svr1.postgresql.org (Postfix) with ESMTP id E80A4D1B1FD for ; Tue, 20 Jul 2004 16:19:11 -0300 (ADT) Received: (from andrew@localhost) by pillette.com (8.11.6/8.11.6) id i6KJJBw08728; Tue, 20 Jul 2004 12:19:11 -0700 Date: Tue, 20 Jul 2004 12:19:11 -0700 From: andrew@pillette.com Message-Id: <200407201919.i6KJJBw08728@pillette.com> Subject: Unbearably slow cascading deletes To: pgsql-performance@postgresql.org Cc: X-Originating-IP: 192.168.1.208 X-Mailer: Webmin 0.940 MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Archive-Number: 200407/133 X-Sequence-Number: 7524 I have (among other things) a parent table with 200 records and a child table with 20MM or more. I set up referential integrity on the FK with ON DELETE CASCADE. It appears that when a DELETE is done on the parent table, the child table deletion is done with a sequential scan. I say this because it took over four minutes to delete a parent record THAT HAD NO CHILDREN. The DB is recently analyzed and SELECTs in the child table are done by the appropriate index on the FK. Let me guess, the cascade trigger's query plan is decided at schema load time, when the optimizer has no clue. Is there a way to fix this without writing my own triggers, using PL/PGSQL EXECUTE to delay the planner? And by the way, if FK conditions like IN (1,3,4) could be handled in a single invocation of the trigger, so much the better. From pgsql-performance-owner@postgresql.org Tue Jul 20 16:45:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 00359D1B3A4 for ; Tue, 20 Jul 2004 16:45:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94029-03 for ; Tue, 20 Jul 2004 19:45:15 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 8A440D1B38B for ; Tue, 20 Jul 2004 16:45:12 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 02A143514B; Tue, 20 Jul 2004 12:45:11 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 012F535127; Tue, 20 Jul 2004 12:45:11 -0700 (PDT) Date: Tue, 20 Jul 2004 12:45:10 -0700 (PDT) From: Stephan Szabo To: andrew@pillette.com Cc: pgsql-performance@postgresql.org Subject: Re: Unbearably slow cascading deletes In-Reply-To: <200407201919.i6KJJBw08728@pillette.com> Message-ID: <20040720123547.J31189@megazone.bigpanda.com> References: <200407201919.i6KJJBw08728@pillette.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/134 X-Sequence-Number: 7525 On Tue, 20 Jul 2004 andrew@pillette.com wrote: > I have (among other things) a parent table with 200 records and a child > table with 20MM or more. I set up referential integrity on the FK with > ON DELETE CASCADE. > > It appears that when a DELETE is done on the parent table, the child > table deletion is done with a sequential scan. I say this because it > took over four minutes to delete a parent record THAT HAD NO CHILDREN. > The DB is recently analyzed and SELECTs in the child table are done by > the appropriate index on the FK. > > Let me guess, the cascade trigger's query plan is decided at schema load > time, when the optimizer has no clue. Is there a way to fix this without > writing my own triggers, using PL/PGSQL EXECUTE to delay the planner? The query plan should be decided at the first cascaded delete for the key in the session. However, IIRC, it's using $arguments for the key values, so it's possible that that is giving it a different plan than it would get if the value were known. What do you get if you prepare the query with an argument for the key and use explain execute? From pgsql-performance-owner@postgresql.org Tue Jul 20 16:55:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 180EFD1B211 for ; Tue, 20 Jul 2004 16:55:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96658-05 for ; Tue, 20 Jul 2004 19:55:16 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 846BCD1B1FD for ; Tue, 20 Jul 2004 16:55:14 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 1E65C35522; Tue, 20 Jul 2004 12:55:14 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 1C0F03551F; Tue, 20 Jul 2004 12:55:14 -0700 (PDT) Date: Tue, 20 Jul 2004 12:55:14 -0700 (PDT) From: Stephan Szabo To: andrew@pillette.com Cc: pgsql-performance@postgresql.org Subject: Re: Unbearably slow cascading deletes In-Reply-To: <20040720123547.J31189@megazone.bigpanda.com> Message-ID: <20040720125453.W31688@megazone.bigpanda.com> References: <200407201919.i6KJJBw08728@pillette.com> <20040720123547.J31189@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/135 X-Sequence-Number: 7526 On Tue, 20 Jul 2004, Stephan Szabo wrote: > > On Tue, 20 Jul 2004 andrew@pillette.com wrote: > > > I have (among other things) a parent table with 200 records and a child > > table with 20MM or more. I set up referential integrity on the FK with > > ON DELETE CASCADE. > > > > It appears that when a DELETE is done on the parent table, the child > > table deletion is done with a sequential scan. I say this because it > > took over four minutes to delete a parent record THAT HAD NO CHILDREN. > > The DB is recently analyzed and SELECTs in the child table are done by > > the appropriate index on the FK. > > > > Let me guess, the cascade trigger's query plan is decided at schema load > > time, when the optimizer has no clue. Is there a way to fix this without > > writing my own triggers, using PL/PGSQL EXECUTE to delay the planner? > > The query plan should be decided at the first cascaded delete for the key > in the session. However, IIRC, it's using $arguments for the key values, > so it's possible that that is giving it a different plan than it would get > if the value were known. What do you get if you prepare the query with an > argument for the key and use explain execute? To be clear, I mean prepare/explain execute an example select/delete from the fk. From pgsql-performance-owner@postgresql.org Tue Jul 20 16:59:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3B23BD1B387 for ; Tue, 20 Jul 2004 16:59:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99177-07 for ; Tue, 20 Jul 2004 19:59:45 +0000 (GMT) Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net [67.119.5.202]) by svr1.postgresql.org (Postfix) with ESMTP id 8CC31D1B344 for ; Tue, 20 Jul 2004 16:59:40 -0300 (ADT) Received: (from andrew@localhost) by pillette.com (8.11.6/8.11.6) id i6KJxe908906; Tue, 20 Jul 2004 12:59:40 -0700 Date: Tue, 20 Jul 2004 12:59:40 -0700 From: andrew@pillette.com Message-Id: <200407201959.i6KJxe908906@pillette.com> Subject: Re: Unbearably slow cascading deletes To: Stephan Szabo Cc: pgsql-performance@postgresql.org X-Originating-IP: 192.168.1.11 X-Mailer: Webmin 0.940 MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, UPPERCASE_25_50 X-Spam-Level: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Archive-Number: 200407/136 X-Sequence-Number: 7527 PREPARE c(int4) AS DELETE FROM childtable WHERE fk=$1; EXPLAIN EXECUTE c(-1); gives an index scan. PREPARE c2(int4) AS DELETE FROM parenttable WHERE key=$1; EXPLAIN EXECUTE c2(1); gives a seq scan on the parent table (itself a little curious) and no explanation of what the triggers are doing. From pgsql-performance-owner@postgresql.org Tue Jul 20 17:07:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EFC60D1B285 for ; Tue, 20 Jul 2004 17:06:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02878-08 for ; Tue, 20 Jul 2004 20:06:48 +0000 (GMT) Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net [67.119.5.202]) by svr1.postgresql.org (Postfix) with ESMTP id 1987ED1B257 for ; Tue, 20 Jul 2004 17:06:45 -0300 (ADT) Received: (from andrew@localhost) by pillette.com (8.11.6/8.11.6) id i6KK6kj08980; Tue, 20 Jul 2004 13:06:46 -0700 Date: Tue, 20 Jul 2004 13:06:46 -0700 From: andrew@pillette.com Message-Id: <200407202006.i6KK6kj08980@pillette.com> Subject: Re: Unbearably slow cascading deletes To: andrew@pillette.com Cc: pgsql-performance@postgresql.org X-Originating-IP: 192.168.1.11 X-Mailer: Webmin 0.940 MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Archive-Number: 200407/137 X-Sequence-Number: 7528 I FOUND IT! A second trigger that doesn't belong...... OK, we're set now, and thanks for showing me some ways to check what the planner is up to. Is there a way of seeing what the triggers will do? From pgsql-performance-owner@postgresql.org Sun Jul 25 20:09:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A366DD1B2D9 for ; Tue, 20 Jul 2004 18:46:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46793-08 for ; Tue, 20 Jul 2004 21:46:14 +0000 (GMT) Received: from umail.ru (umail.mtu.ru [195.34.32.101]) by svr1.postgresql.org (Postfix) with ESMTP id 10B46D1B1AE for ; Tue, 20 Jul 2004 18:46:10 -0300 (ADT) Received: from [83.237.28.208] (HELO ppp83-237-28-208.pppoe.mtu-net.ru) by umail.ru (CommuniGate Pro SMTP 4.2b6) with ESMTP id 279168535 for pgsql-performance@postgresql.org; Wed, 21 Jul 2004 01:46:10 +0400 Date: Wed, 21 Jul 2004 01:46:11 +0400 From: Ilia Kantor X-Mailer: The Bat! (v2.04.7) Business Reply-To: Algolist X-Priority: 3 (Normal) Message-ID: <418482301.20040721014611@manual.ru> To: pgsql-performance@postgresql.org Subject: Index type In-Reply-To: <20040626222142.5E3D75AF09D@svr4.postgresql.org> References: <20040626222142.5E3D75AF09D@svr4.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/162 X-Sequence-Number: 7553 Hello, I have a request like SELECT ... WHERE x<=A<=y AND t<=B<=u AND z<=C<=w AND .. 5 columns are in BETWEEN clauses. What is the best index I could use? If I create btree index on all columns (A,B,C..), here is what explain analyze gives me: ----------------------------------------------------------------- Index Scan using all_ind on test2 (cost=0.00..4.51 rows=1 width=24) (actual ti me=0.000..0.000 rows=5 loops=1) Index Cond: ((a >= '2004-07-20 23:50:50'::timestamp without time zone) AND (a <= '2004-07-21 23:50:50'::timestamp without time zone) AND (b >= '2004-07-20 23 :50:50'::timestamp without time zone) AND (b <= '2004-07-21 23:50:50'::timestamp without time zone) AND (c >= '2004-07-20 23:50:50'::timestamp without time zone ) AND (c <= '2004-07-21 23:50:50'::timestamp without time zone)) Is such search really optimal? I remember we used k-d trees for geometric data with independent coords.. Is that the same as btree for multiple columns I wonder. -- Best regards, Ilia mailto:algolist@manual.ru From pgsql-performance-owner@postgresql.org Tue Jul 20 22:36:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 56DB1D1B179 for ; Tue, 20 Jul 2004 22:36:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32848-01 for ; Wed, 21 Jul 2004 01:36:25 +0000 (GMT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 08BAAD1B16E for ; Tue, 20 Jul 2004 22:36:19 -0300 (ADT) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i6L1aFbP094485; Wed, 21 Jul 2004 09:36:15 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <40FDC8F0.30102@familyhealth.com.au> Date: Wed, 21 Jul 2004 09:37:52 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: andrew@pillette.com Cc: pgsql-performance@postgresql.org Subject: Re: Unbearably slow cascading deletes References: <200407201919.i6KJJBw08728@pillette.com> In-Reply-To: <200407201919.i6KJJBw08728@pillette.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/138 X-Sequence-Number: 7529 > I have (among other things) a parent table with 200 records and a child table with 20MM or more. I set up referential integrity on the FK with ON DELETE CASCADE. > > It appears that when a DELETE is done on the parent table, the child table deletion is done with a sequential scan. I say this because it took over four minutes to delete a parent record THAT HAD NO CHILDREN. The DB is recently analyzed and SELECTs in the child table are done by the appropriate index on the FK. Do you have an index on the foreign key field? Chris From pgsql-performance-owner@postgresql.org Tue Jul 20 23:22:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0404FD1B2E0 for ; Tue, 20 Jul 2004 23:21:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49517-03 for ; Wed, 21 Jul 2004 02:21:33 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id BB2D9D1B20D for ; Tue, 20 Jul 2004 23:20:54 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id D0E8B76A7F; Tue, 20 Jul 2004 22:18:28 -0400 (EDT) Subject: Re: Odd sorting behaviour From: Rod Taylor To: "Steinar H. Gunderson" Cc: Postgresql Performance In-Reply-To: <20040720172100.GA22262@uio.no> References: <20040708101913.GA15871@uio.no> <20040715120854.GA31259@uio.no> <20040720115116.GB19633@uio.no> <200407201006.08649.josh@agliodbs.com> <20040720172100.GA22262@uio.no> Content-Type: text/plain Message-Id: <1090376297.12565.9.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 20 Jul 2004 22:18:19 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/139 X-Sequence-Number: 7530 > I could of course post the updated query plan if anybody is interested; let > me know. (The data is still available if anybody needs it as well, of > course.) I've taken a look and managed to cut out quite a bit of used time. You'll need to confirm it's the same results though (I didn't -- it is the same number of results (query below) First off, "DROP INDEX prodid_index;". It doesn't help anything since the primary key is just as usable, but it does take enough space that it causes thrashing in the buffer_cache. Any queries based on prodid will use the index for the PRIMARY KEY instead. Secondly, I had no luck getting the hashjoin but this probably doesn't matter. I've assumed that the number of users will climb faster than the product set offered, and generated additional data via the below command run 4 times: INSERT INTO opinions SELECT prodid, uid + (SELECT max(uid) FROM opinions), opinion FROM opinions; I found that by this point, the hashjoin and mergejoin have essentially the same performance -- in otherwords, as you grow you'll want the mergejoin eventually so I wouldn't worry about it too much. New Query cuts about 1/3rd the time, forcing hashjoin gets another 1/3rd but see the above note: SELECT o3.prodid , SUM(o3.opinion*o12.correlation) AS total_correlation FROM opinions o3 -- Plain join okay since o12.correlation <> 0 -- eliminates any NULLs anyway. -- Was RIGHT JOIN JOIN (SELECT o2.uid , SUM(o1.opinion*o2.opinion)/SQRT(count(*)::numeric) AS correlation FROM opinions AS o1 JOIN opinions AS o2 USING (prodid) WHERE o1.uid = 1355 GROUP BY o2.uid ) AS o12 USING (uid) -- Was old Left join WHERE o3.prodid NOT IN (SELECT prodid FROM opinions AS o4 WHERE uid = 1355) AND o3.opinion <> 0 AND o12.correlation <> 0 GROUP BY o3.prodid ORDER BY total_correlation desc; From pgsql-performance-owner@postgresql.org Wed Jul 21 07:04:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2BE5AD1B2A6 for ; Wed, 21 Jul 2004 07:04:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34019-05 for ; Wed, 21 Jul 2004 10:04:13 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 8C9A3D1B1BE for ; Wed, 21 Jul 2004 07:04:09 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1BnDxK-0006yz-00 for ; Wed, 21 Jul 2004 12:04:10 +0200 Date: Wed, 21 Jul 2004 12:04:10 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Odd sorting behaviour Message-ID: <20040721100410.GC26552@uio.no> References: <20040708101913.GA15871@uio.no> <20040715120854.GA31259@uio.no> <20040720115116.GB19633@uio.no> <200407201006.08649.josh@agliodbs.com> <20040720172100.GA22262@uio.no> <1090376297.12565.9.camel@jester> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1090376297.12565.9.camel@jester> X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/140 X-Sequence-Number: 7531 On Tue, Jul 20, 2004 at 10:18:19PM -0400, Rod Taylor wrote: > I've taken a look and managed to cut out quite a bit of used time. > You'll need to confirm it's the same results though (I didn't -- it is > the same number of results (query below) It looks very much like the same results. > Secondly, I had no luck getting the hashjoin but this probably doesn't > matter. I've assumed that the number of users will climb faster than the > product set offered, and generated additional data via the below command > run 4 times: Actually, the number of users won't climb that much faster; what will probably increase is the number of opinions. > I found that by this point, the hashjoin and mergejoin have essentially > the same performance -- in otherwords, as you grow you'll want the > mergejoin eventually so I wouldn't worry about it too much. Hm, OK. > -- Plain join okay since o12.correlation <> 0 > -- eliminates any NULLs anyway. > -- Was RIGHT JOIN OK, that makes sense (although I don't really see why it should be faster). > -- Was old Left join > WHERE o3.prodid NOT IN (SELECT prodid > FROM opinions AS o4 > WHERE uid = 1355) As my server is 7.2 and not 7.4, that obviously won't help much :-) Thanks anyway, though -- we'll upgrade eventually, and it'll help then. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Wed Jul 21 11:58:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BDC31D1B16A for ; Wed, 21 Jul 2004 11:58:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80328-09 for ; Wed, 21 Jul 2004 14:58:13 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id EA7CCD1B269 for ; Wed, 21 Jul 2004 11:58:08 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id E744776A46; Wed, 21 Jul 2004 10:58:15 -0400 (EDT) Subject: Re: Odd sorting behaviour From: Rod Taylor To: "Steinar H. Gunderson" Cc: Postgresql Performance In-Reply-To: <20040721100410.GC26552@uio.no> References: <20040708101913.GA15871@uio.no> <20040715120854.GA31259@uio.no> <20040720115116.GB19633@uio.no> <200407201006.08649.josh@agliodbs.com> <20040720172100.GA22262@uio.no> <1090376297.12565.9.camel@jester> <20040721100410.GC26552@uio.no> Content-Type: text/plain Message-Id: <1090421892.21450.7.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 21 Jul 2004 10:58:12 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/141 X-Sequence-Number: 7532 On Wed, 2004-07-21 at 06:04, Steinar H. Gunderson wrote: > On Tue, Jul 20, 2004 at 10:18:19PM -0400, Rod Taylor wrote: > > I've taken a look and managed to cut out quite a bit of used time. > > You'll need to confirm it's the same results though (I didn't -- it is > > the same number of results (query below) > > It looks very much like the same results. Oh.. On my (slow) laptop it cut the time back significantly.. > As my server is 7.2 and not 7.4, that obviously won't help much :-) Thanks > anyway, though -- we'll upgrade eventually, and it'll help then. I see. Yeah, avoid NOT IN like a plague on 7.2. From pgsql-performance-owner@postgresql.org Wed Jul 21 13:46:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8AF2FD1B211 for ; Wed, 21 Jul 2004 13:45:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35673-08 for ; Wed, 21 Jul 2004 16:45:35 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id F390DD1B181 for ; Wed, 21 Jul 2004 13:45:34 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6LGjYqb099018 for ; Wed, 21 Jul 2004 16:45:34 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6LGPtHa096057 for pgsql-performance@postgresql.org; Wed, 21 Jul 2004 16:25:55 GMT From: Stefan X-Newsgroups: comp.databases.postgresql.performance Subject: Re: extrem bad performance Date: Wed, 21 Jul 2004 18:25:55 +0200 Organization: Hub.Org Networking Services Lines: 8 Message-ID: References: <1090031495.81714.11.camel@jester> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en In-Reply-To: <1090031495.81714.11.camel@jester> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=FORGED_YAHOO_RCVD X-Spam-Level: X-Archive-Number: 200407/142 X-Sequence-Number: 7533 Rod Taylor wrote: > Lets start with an example. Please send us an EXPLAIN ANALYZE of a > couple of the poorly performing queries. thanks for your answer. the problem was solved by using FULL(!) VACUUM. regards, Stefan From pgsql-performance-owner@postgresql.org Wed Jul 21 17:46:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 84C11D1B182 for ; Wed, 21 Jul 2004 17:46:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44963-08 for ; Wed, 21 Jul 2004 20:46:05 +0000 (GMT) Received: from mail.partslogistics.com (mail.crazedsanity.com [216.239.10.100]) by svr1.postgresql.org (Postfix) with SMTP id D25AED1B2D9 for ; Wed, 21 Jul 2004 17:45:56 -0300 (ADT) Received: (qmail 12251 invoked by uid 512); 21 Jul 2004 20:45:55 -0000 Received: from joe@avsupport.com by butthead.avsupport.com by uid 89 with qmail-scanner-1.21 (clamdscan: 0.68. spamassassin: 2.63. Clear:RC:1(192.168.10.3):. Processed in 0.442795 secs); 21 Jul 2004 20:45:55 -0000 Received: from unknown (HELO ?192.168.10.3?) (192.168.10.3) by mail.dakotaairparts.com with SMTP; 21 Jul 2004 20:45:55 -0000 Subject: Beowulf Cluster & Postgresql? From: joe To: Postgresql Performance Content-Type: text/plain Message-Id: <1090442756.7202.38.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 21 Jul 2004 15:45:56 -0500 Content-Transfer-Encoding: 7bit X-Qmail-Scanner-Message-ID: <109044275566112243@butthead.avsupport.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/143 X-Sequence-Number: 7534 Hi all, I was wondering if part or all of Postgres would be able to take advantage of a beowulf cluster to increase performance? If not then why not, and if so then how would/could it benefit from being on a cluster? Thanks for the enlightenment in advance. -Joe From pgsql-performance-owner@postgresql.org Wed Jul 21 18:07:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E8F5ED1B2BD for ; Wed, 21 Jul 2004 18:07:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59743-01 for ; Wed, 21 Jul 2004 21:07:43 +0000 (GMT) Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net [63.231.195.114]) by svr1.postgresql.org (Postfix) with SMTP id C104ED1B220 for ; Wed, 21 Jul 2004 18:07:35 -0300 (ADT) Received: (qmail 10613 invoked by uid 0); 21 Jul 2004 20:36:54 -0000 Received: from mpls-pop-11.inet.qwest.net (63.231.195.11) by mpls-qmqp-03.inet.qwest.net with QMQP; 21 Jul 2004 20:36:54 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-11.inet.qwest.net with SMTP; 21 Jul 2004 21:07:33 -0000 Date: Wed, 21 Jul 2004 15:08:30 -0600 Message-Id: <1090444110.709.38.camel@localhost.localdomain> From: "Scott Marlowe" To: "joe" Cc: "Postgresql Performance" Subject: Re: Beowulf Cluster & Postgresql? In-Reply-To: <1090442756.7202.38.camel@localhost> References: <1090442756.7202.38.camel@localhost> Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/144 X-Sequence-Number: 7535 On Wed, 2004-07-21 at 14:45, joe wrote: > Hi all, > I was wondering if part or all of Postgres would be able to take > advantage of a beowulf cluster to increase performance? If not then why > not, and if so then how would/could it benefit from being on a cluster? > > Thanks for the enlightenment in advance. That type of clustering helps with large parallel processes that are loosely interrelated or none at all. In PostgreSQL, as in most databases, all actions that change the data in the database tend to be highly interrelated, so it becomes very expensive to pass all that locking information back and forth. The very thing a cluster would be good at, lots of reads, very few writies, is the antithesis of what postgresql is built to be good at, lots of writes as well as lots of reads. Basically, clustering tends to make the database faster at reads and slower at writes. While there are clustering solutions out there, Beowulf clustering is oriented towards highly parallel CPU intensive workloads, while PostgreSQL tends to be I/O intensive, and since all the data needs to be stored in one "master" place, adding nodes doesn't usually help with making writes faster. From pgsql-performance-owner@postgresql.org Wed Jul 21 23:48:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A002FD1B181 for ; Wed, 21 Jul 2004 23:47:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69052-10 for ; Thu, 22 Jul 2004 02:47:39 +0000 (GMT) Received: from mail.coretech.co.nz (coretech.co.nz [202.36.204.41]) by svr1.postgresql.org (Postfix) with ESMTP id 96A7BD1B16E for ; Wed, 21 Jul 2004 23:47:29 -0300 (ADT) Received: (qmail 6843 invoked from network); 22 Jul 2004 02:47:29 -0000 Received: from unknown (HELO coretech.co.nz) (10.0.10.28) by 0 with SMTP; 22 Jul 2004 02:47:29 -0000 Message-ID: <40FF2AC0.5040807@coretech.co.nz> Date: Thu, 22 Jul 2004 14:47:28 +1200 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: joe Cc: Postgresql Performance Subject: Re: Beowulf Cluster & Postgresql? References: <1090442756.7202.38.camel@localhost> In-Reply-To: <1090442756.7202.38.camel@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/145 X-Sequence-Number: 7536 You might want to take a look at Matt Dillon's Backplane database. It is designed to work in a multi-node environment : http://www.backplane.com/ regards Mark joe wrote: >Hi all, > I was wondering if part or all of Postgres would be able to take >advantage of a beowulf cluster to increase performance? If not then why >not, and if so then how would/could it benefit from being on a cluster? > > Thanks for the enlightenment in advance. > >-Joe > > > >---------------------------(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 Fri Jul 23 02:53:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 67C68D1B182 for ; Fri, 23 Jul 2004 02:53:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38444-10 for ; Fri, 23 Jul 2004 05:53:12 +0000 (GMT) Received: from shrek.sa.quiktrak.com.au (mail.sa.quiktrak.com.au [203.36.209.24]) by svr1.postgresql.org (Postfix) with ESMTP id B7336D1B179 for ; Fri, 23 Jul 2004 02:53:02 -0300 (ADT) Received: from BAEA-4.sa.quiktrak.com.au (mail.sa.quiktrak.com.au [192.168.120.52]) by shrek.sa.quiktrak.com.au (Postfix) with SMTP id BC41C35062 for ; Fri, 23 Jul 2004 15:23:04 +0930 (CST) Received: from SLEEPY (QT170.sa.quiktrak.com.au [192.168.120.170]) by BAEA-4.sa.quiktrak.com.au; Fri, 23 Jul 2004 15:12:19 +0930 From: "William Carney" To: Subject: Performance over a LAN Date: Fri, 23 Jul 2004 15:20:54 +0930 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.50.4939.300 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/146 X-Sequence-Number: 7537 Hello, Using a test client application that performs 100000 insert operations on a table, with the client application running on the same machine as the Postgres server, I get the following results for the time taken to run the test: Unix domain socket connection: 26 seconds Inet domain socket ('localhost'): 35 seconds The table has two columns, a timestamp and a character(16), no indexes. But with the server running on one machine and the client running on another, the two machines being connected by a 100 Mb ethernet, with nothing else on the network, this test takes 17 minutes to run. I have tried changing the frequency of COMMIT operations, but with only a small effect. The machines used are P4s running FreeBSD 5.2.1. The Postgres version is 7.4.3. Can anyone tell me why there's such a big difference? Thanks, William From pgsql-performance-owner@postgresql.org Fri Jul 23 03:00:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4C6CFD1B2A6 for ; Fri, 23 Jul 2004 02:59:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43097-04 for ; Fri, 23 Jul 2004 05:59:23 +0000 (GMT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 57765D1B272 for ; Fri, 23 Jul 2004 02:59:14 -0300 (ADT) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i6N5xKUi051446; Fri, 23 Jul 2004 13:59:20 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <4100A9FE.2020905@familyhealth.com.au> Date: Fri, 23 Jul 2004 14:02:38 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: William Carney Cc: pgsql-performance@postgresql.org Subject: Re: Performance over a LAN References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/147 X-Sequence-Number: 7538 > But with the server running on one machine and the client running on > another, the two machines being connected by a 100 Mb ethernet, with nothing > else on the network, this test takes 17 minutes to run. I have tried > changing the frequency of COMMIT operations, but with only a small effect. Are you using separate INSERT statements? Try using COPY instead, it's much faster. chris From pgsql-performance-owner@postgresql.org Fri Jul 23 03:20:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B8CB4D1B1DC for ; Fri, 23 Jul 2004 03:20:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51396-05 for ; Fri, 23 Jul 2004 06:20:35 +0000 (GMT) Received: from mx1.mailsecurity.net.au (mx1.mailsecurity.net.au [66.135.32.89]) by svr1.postgresql.org (Postfix) with ESMTP id 76B0BD1B195 for ; Fri, 23 Jul 2004 03:20:26 -0300 (ADT) Received: from [211.28.202.202] (211.28.202.202.optusnet.com.au [211.28.202.202] (may be forged)) (authenticated) by mx1.mailsecurity.net.au (8.11.6/2.52a) with ESMTP id i6N6KPK13952; Fri, 23 Jul 2004 16:20:25 +1000 In-Reply-To: <4100A9FE.2020905@familyhealth.com.au> References: <4100A9FE.2020905@familyhealth.com.au> Mime-Version: 1.0 (Apple Message framework v618) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <5DFB2EEA-DC70-11D8-9C7A-003065D62456@pumptheory.com> Content-Transfer-Encoding: 7bit Cc: William Carney , pgsql-performance@postgresql.org From: Mark Aufflick Subject: Re: Performance over a LAN Date: Fri, 23 Jul 2004 16:20:17 +1000 To: Christopher Kings-Lynne X-Mailer: Apple Mail (2.618) X-MS-Info: Message scanned by Mail Security - www.mailsecurity.net.au X-MS: Message OK X-MS-From: mark@pumptheory.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/148 X-Sequence-Number: 7539 I don't think that's the advice being looked for here - if this behaviour is repeatable, then there is something askew with the inet protocol. What is the client application written in? Do you know what version of the postgres network protocol your driver code is using? Are the inserts inside a transaction? I'm very interested in this issue since the environment I now work in has a lot of network connected databases and the performance is much less than I am used to with local databases. Mark. -- Mark Aufflick e mark@pumptheory.com w www.pumptheory.com (work) w mark.aufflick.com (personal) p +61 438 700 647 On 23/07/2004, at 4:02 PM, Christopher Kings-Lynne wrote: >> But with the server running on one machine and the client running on >> another, the two machines being connected by a 100 Mb ethernet, with >> nothing >> else on the network, this test takes 17 minutes to run. I have tried >> changing the frequency of COMMIT operations, but with only a small >> effect. > > Are you using separate INSERT statements? Try using COPY instead, > it's much faster. > > chris > > > ---------------------------(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 > > ======================================================================= > = > Pain free spam & virus protection by: www.mailsecurity.net.au > Forward undetected SPAM to: spam@mailsecurity.net.au > ======================================================================= > = > ======================================================================== Pain free spam & virus protection by: www.mailsecurity.net.au Forward undetected SPAM to: spam@mailsecurity.net.au ======================================================================== From pgsql-performance-owner@postgresql.org Fri Jul 23 03:28:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 808E7D1B2D9 for ; Fri, 23 Jul 2004 03:28:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54319-04 for ; Fri, 23 Jul 2004 06:28:10 +0000 (GMT) Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net [63.231.195.112]) by svr1.postgresql.org (Postfix) with SMTP id 46D66D1B211 for ; Fri, 23 Jul 2004 03:27:55 -0300 (ADT) Received: (qmail 68903 invoked by uid 0); 23 Jul 2004 06:27:58 -0000 Received: from unknown (63.231.195.13) by mpls-qmqp-01.inet.qwest.net with QMQP; 23 Jul 2004 06:27:58 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-13.inet.qwest.net with SMTP; 23 Jul 2004 06:27:58 -0000 Date: Fri, 23 Jul 2004 00:29:11 -0600 Message-Id: <1090564151.709.59.camel@localhost.localdomain> From: "Scott Marlowe" To: "William Carney" Cc: pgsql-performance@postgresql.org Subject: Re: Performance over a LAN In-Reply-To: References: Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/149 X-Sequence-Number: 7540 On Thu, 2004-07-22 at 23:50, William Carney wrote: > Hello, > > Using a test client application that performs 100000 insert operations on a > table, with the client application running on the same machine as the > Postgres server, I get the following results for the time taken to run the > test: > > Unix domain socket connection: 26 seconds > Inet domain socket ('localhost'): 35 seconds > > The table has two columns, a timestamp and a character(16), no indexes. > > But with the server running on one machine and the client running on > another, the two machines being connected by a 100 Mb ethernet, with nothing > else on the network, this test takes 17 minutes to run. I have tried > changing the frequency of COMMIT operations, but with only a small effect. > > The machines used are P4s running FreeBSD 5.2.1. The Postgres version is > 7.4.3. Can anyone tell me why there's such a big difference? Are you using the exact same script locally as across the network? Have you checked to see how fast you can copy just a plain text file across the network connection? Have you checked your system to see if you're getting lots of network errors or anything like that? From pgsql-performance-owner@postgresql.org Fri Jul 23 05:00:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7F754D1B1DC for ; Fri, 23 Jul 2004 04:59:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90259-01 for ; Fri, 23 Jul 2004 07:59:55 +0000 (GMT) Received: from shrek.sa.quiktrak.com.au (mail.sa.quiktrak.com.au [203.36.209.24]) by svr1.postgresql.org (Postfix) with ESMTP id 8D6E8D1B16A for ; Fri, 23 Jul 2004 04:59:46 -0300 (ADT) Received: from BAEA-4.sa.quiktrak.com.au (mail.sa.quiktrak.com.au [192.168.120.52]) by shrek.sa.quiktrak.com.au (Postfix) with SMTP id C878C35062 for ; Fri, 23 Jul 2004 17:29:52 +0930 (CST) Received: from SLEEPY (QT170.sa.quiktrak.com.au [192.168.120.170]) by BAEA-4.sa.quiktrak.com.au; Fri, 23 Jul 2004 17:19:17 +0930 From: "William Carney" To: Subject: Re: Performance over a LAN Date: Fri, 23 Jul 2004 17:27:53 +0930 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) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4939.300 In-Reply-To: <5DFB2EEA-DC70-11D8-9C7A-003065D62456@pumptheory.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/150 X-Sequence-Number: 7541 I tested the LAN connection by transferring around some large (150 MByte) files, and got consistent transfer rates of about 10 MBytes/second in both directions without any problems, which is what I would expect. Netstat says that there are no errors, so I think that the ethernet is working OK. Maybe there's some latency somewhere but I have no reason to think that anything's abnormal. The test program is a C program with embedded SQL (ecpg). The only difference between the tests was the address used in the EXEC SQL CONNECT .. statement. The inserts are committed to the database by performing an EXEC SQL COMMIT after every N of them; I tried various values of N up to several hundred, but it didn't make much difference. Using psql I can see records appearing in the database in groups of that size. I'm not sure about all of the protocol versions. I downloaded the complete Postgres source and built it only a few days ago. Ecpg says that it's version is 3.1.1. I'm not getting any errors reported anywhere, it's just that things are surprisingly slow over the LAN for some reason. William > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Mark > Aufflick > Sent: Friday, 23 July 2004 3:50 PM > To: Christopher Kings-Lynne > Cc: William Carney; pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Performance over a LAN > > > I don't think that's the advice being looked for here - if this > behaviour is repeatable, then there is something askew with the inet > protocol. > > What is the client application written in? Do you know what version of > the postgres network protocol your driver code is using? Are the > inserts inside a transaction? > > I'm very interested in this issue since the environment I now work in > has a lot of network connected databases and the performance is much > less than I am used to with local databases. > > Mark. > -- > Mark Aufflick > e mark@pumptheory.com > w www.pumptheory.com (work) > w mark.aufflick.com (personal) > p +61 438 700 647 > On 23/07/2004, at 4:02 PM, Christopher Kings-Lynne wrote: > > >> But with the server running on one machine and the client running on > >> another, the two machines being connected by a 100 Mb ethernet, with > >> nothing > >> else on the network, this test takes 17 minutes to run. I have tried > >> changing the frequency of COMMIT operations, but with only a small > >> effect. > > > > Are you using separate INSERT statements? Try using COPY instead, > > it's much faster. > > > > chris > > > > > > ---------------------------(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 > > > > ======================================================================= > > = > > Pain free spam & virus protection by: www.mailsecurity.net.au > > Forward undetected SPAM to: spam@mailsecurity.net.au > > ======================================================================= > > = > > > > > ======================================================================== > Pain free spam & virus protection by: www.mailsecurity.net.au > Forward undetected SPAM to: spam@mailsecurity.net.au > ======================================================================== > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match From pgsql-hackers-owner@postgresql.org Fri Jul 23 05:27:02 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9A431D1B1DC for ; Fri, 23 Jul 2004 05:27:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99263-05 for ; Fri, 23 Jul 2004 08:27:05 +0000 (GMT) Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) by svr1.postgresql.org (Postfix) with ESMTP id 2F730D1B195 for ; Fri, 23 Jul 2004 05:26:56 -0300 (ADT) Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i6N8Quv17518 for ; Fri, 23 Jul 2004 10:26:56 +0200 Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i6N8R2X21926 for ; Fri, 23 Jul 2004 10:27:02 +0200 Message-ID: <4100CBCC.5050308@bigfoot.com> Date: Fri, 23 Jul 2004 10:26:52 +0200 From: Gaetano Mendola User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "pgsql-hackers@postgresql.org" Subject: Wrong index choosen? X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200407/1134 X-Sequence-Number: 56695 I hall I have a query in this form: empdb=# explain analyze select * from v_past_connections where id_user = 26195 and login_time > '2004-07-21'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Index Scan using idx_user_logs_login_time on user_logs (cost=0.00..14.10 rows=1 width=28) (actual time=66.890..198.998 rows=5 loops=1) Index Cond: (login_time > '2004-07-21 00:00:00+02'::timestamp with time zone) Filter: (id_user = 26195) Total runtime: 199.083 ms (4 rows) as you see the index on the time stamp column is used The table have indexes on both columns: empdb=# explain analyze select * from v_past_connections where login_time > '2004-07-21'; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------- Index Scan using idx_user_logs_login_time on user_logs (cost=0.00..12.90 rows=481 width=28) (actual time=7.338..661.300 rows=22477 loops=1) Index Cond: (login_time > '2004-07-21 00:00:00+02'::timestamp with time zone) Total runtime: 676.472 ms (3 rows) empdb=# explain analyze select * from v_past_connections where id_user = 26195; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------- Index Scan using idx_user_user_logs on user_logs (cost=0.00..252.47 rows=320 width=28) (actual time=4.420..100.122 rows=221 loops=1) Index Cond: (id_user = 26195) Total runtime: 100.348 ms (3 rows) The rows filtered out with both condictions are two order of magnitude differents, also the extimated rows are close to real numbers: empdb=# select count(*) from v_past_connections where id_user = 26195; count ------- 221 (1 row) empdb=# select count(*) from v_past_connections where login_time > '2004-07-21'; count ------- 22441 (1 row) why then the planner choose to do an index scan using the filter that retrieve a bigger ammount of rows ? A bug ? Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Fri Jul 23 08:43:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 52F69D1B23E for ; Fri, 23 Jul 2004 08:43:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80097-10 for ; Fri, 23 Jul 2004 11:43:09 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id AE963D1B20E for ; Fri, 23 Jul 2004 08:42:59 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id D96E776C7F; Fri, 23 Jul 2004 07:43:08 -0400 (EDT) Subject: Re: Performance over a LAN From: Rod Taylor To: William Carney Cc: Postgresql Performance In-Reply-To: References: Content-Type: text/plain Message-Id: <1090582986.34076.5.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 23 Jul 2004 07:43:07 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/151 X-Sequence-Number: 7542 On Fri, 2004-07-23 at 01:50, William Carney wrote: > Hello, > > Using a test client application that performs 100000 insert operations on a > table, with the client application running on the same machine as the > Postgres server, I get the following results for the time taken to run the > test: > > Unix domain socket connection: 26 seconds > Inet domain socket ('localhost'): 35 seconds > The machines used are P4s running FreeBSD 5.2.1. The Postgres version is > 7.4.3. Can anyone tell me why there's such a big difference? Domains sockets have significantly less work to do than inet sockets as well as less delays for the transmission itself. From pgsql-hackers-owner@postgresql.org Fri Jul 23 09:01:59 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0971FD1B16A for ; Fri, 23 Jul 2004 09:01:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86149-09 for ; Fri, 23 Jul 2004 12:02:00 +0000 (GMT) Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) by svr1.postgresql.org (Postfix) with ESMTP id 05901D1B19A for ; Fri, 23 Jul 2004 09:01:48 -0300 (ADT) Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) by zigo.dhs.org (Postfix) with ESMTP id B77BC8467; Fri, 23 Jul 2004 14:01:56 +0200 (CEST) Date: Fri, 23 Jul 2004 14:01:56 +0200 (CEST) From: Dennis Bjorklund To: Gaetano Mendola Cc: "pgsql-hackers@postgresql.org" Subject: Re: Wrong index choosen? In-Reply-To: <4100CBCC.5050308@bigfoot.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/1136 X-Sequence-Number: 56697 On Fri, 23 Jul 2004, Gaetano Mendola wrote: > empdb=# explain analyze select * from v_past_connections where login_time > '2004-07-21'; > QUERY PLAN > ---------------------------------------------------------------------------------------------------------------------------------------------- > Index Scan using idx_user_logs_login_time on user_logs (cost=0.00..12.90 rows=481 width=28) (actual time=7.338..661.300 rows=22477 loops=1) > Index Cond: (login_time > '2004-07-21 00:00:00+02'::timestamp with time zone) > Total runtime: 676.472 ms > (3 rows) In this plan it estimates to get 481 but it got 22477. So the estimation was very wrong. You can increase the statistics tarhet on the login_time and it will probably be better (after the next analyze). > why then the planner choose to do an index scan using the filter that > retrieve a bigger ammount of rows ? A bug ? Because it has to decide on the plan before it knows exactly what the result will be. As seen above, the estimation was wrong and thus the plan was not as good as it could have been. In this case you probably also want to create a combined index on both columns: CREATE INDEX foo ON user_log (id_user, login_time); ps. This letter belonged to pgsql-performance and not pgsql-hackers. -- /Dennis Bj�rklund From pgsql-performance-owner@postgresql.org Fri Jul 23 09:05:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 006D9D1B269 for ; Fri, 23 Jul 2004 09:05:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90523-04 for ; Fri, 23 Jul 2004 12:05:55 +0000 (GMT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 63719D1B262 for ; Fri, 23 Jul 2004 09:05:45 -0300 (ADT) Received: (qmail 18027 invoked from network); 23 Jul 2004 12:19:49 -0000 Received: from dhcp-7-247.ma.lycos.com (HELO ?10.124.7.247?) (10.124.7.247) by dhcp-7-248.ma.lycos.com with SMTP; 23 Jul 2004 12:19:49 -0000 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v613) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: From: Jeff Subject: Re: Performance over a LAN Date: Fri, 23 Jul 2004 08:07:23 -0400 To: "William Carney" X-Mailer: Apple Mail (2.613) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/152 X-Sequence-Number: 7543 On Jul 23, 2004, at 3:57 AM, William Carney wrote: > > I tested the LAN connection by transferring around some large (150 > MByte) > files, and got consistent transfer rates of about 10 MBytes/second in > both > directions without any problems, which is what I would expect. Netstat > says It would be interesting to run something like ntop that can show you current network usage... unless you are doing a large COPY the PG protocol has a lot of back and forth messages... -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-hackers-owner@postgresql.org Fri Jul 23 11:46:48 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 593AAD1B1F8 for ; Fri, 23 Jul 2004 11:46:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66661-06 for ; Fri, 23 Jul 2004 14:46:53 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0861DD1B182 for ; Fri, 23 Jul 2004 11:46:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6NEjR3F020163; Fri, 23 Jul 2004 10:45:29 -0400 (EDT) To: Dennis Bjorklund Cc: Gaetano Mendola , "pgsql-hackers@postgresql.org" Subject: Re: Wrong index choosen? In-reply-to: References: Comments: In-reply-to Dennis Bjorklund message dated "Fri, 23 Jul 2004 14:01:56 +0200" Date: Fri, 23 Jul 2004 10:45:27 -0400 Message-ID: <20162.1090593927@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/1138 X-Sequence-Number: 56699 Dennis Bjorklund writes: > In this plan it estimates to get 481 but it got 22477. So the estimation > was very wrong. You can increase the statistics tarhet on the login_time > and it will probably be better (after the next analyze). Given the nature of the data (login times), I'd imagine that the problem is simply that he hasn't analyzed recently enough. A bump in stats target may not be needed, but he's going to have to re-analyze that column often if he wants this sort of query to be estimated accurately, because the fraction of entries later than a given time T is *always* going to be changing. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jul 23 12:34:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EF96AD1B16A for ; Fri, 23 Jul 2004 12:34:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89176-10 for ; Fri, 23 Jul 2004 15:34:19 +0000 (GMT) Received: from mail1.panix.com (mail1.panix.com [166.84.1.72]) by svr1.postgresql.org (Postfix) with ESMTP id 67DFCD1B25F for ; Fri, 23 Jul 2004 12:34:18 -0300 (ADT) Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mail1.panix.com (Postfix) with ESMTP id 5575F48912 for ; Fri, 23 Jul 2004 11:34:17 -0400 (EDT) Received: (from adler@localhost) by panix2.panix.com (8.11.6p2-a/8.8.8/PanixN1.1) id i6NFYHE20075 for pgsql-performance@postgresql.org; Fri, 23 Jul 2004 11:34:17 -0400 (EDT) Date: Fri, 23 Jul 2004 11:34:16 -0400 From: Michael Adler To: pgsql-performance@postgresql.org Subject: Re: Performance over a LAN Message-ID: <20040723153416.GC8970@pobox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/153 X-Sequence-Number: 7544 On Fri, Jul 23, 2004 at 03:20:54PM +0930, William Carney wrote: > But with the server running on one machine and the client running on > another, the two machines being connected by a 100 Mb ethernet, with nothing > else on the network, this test takes 17 minutes to run. I have tried > changing the frequency of COMMIT operations, but with only a small effect. > > The machines used are P4s running FreeBSD 5.2.1. The Postgres version is > 7.4.3. Can anyone tell me why there's such a big difference? Can you reproduce this problem in a tiny test case? If your application is doing other networky things (e.g. many name resolutions that hang for 10 seconds each), they may be slowing down the PostgreSQL work. Just a WAG. -mike From pgsql-performance-owner@postgresql.org Fri Jul 23 13:26:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 86FB1D1B1FD for ; Fri, 23 Jul 2004 13:26:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11856-10 for ; Fri, 23 Jul 2004 16:26:11 +0000 (GMT) Received: from web25105.mail.ukl.yahoo.com (web25105.mail.ukl.yahoo.com [217.12.10.53]) by svr1.postgresql.org (Postfix) with SMTP id 81E3CD1B1B8 for ; Fri, 23 Jul 2004 13:26:09 -0300 (ADT) Message-ID: <20040723162608.84118.qmail@web25105.mail.ukl.yahoo.com> Received: from [217.158.107.104] by web25105.mail.ukl.yahoo.com via HTTP; Fri, 23 Jul 2004 17:26:08 BST Date: Fri, 23 Jul 2004 17:26:08 +0100 (BST) From: =?iso-8859-1?q?Gary=20Cowell?= Subject: Re: Performance over a LAN To: pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/154 X-Sequence-Number: 7545 --- William Carney wrote: > The test program is a C program with embedded SQL > (ecpg). The only > difference between the tests was the address used in > the EXEC SQL CONNECT > .. statement. The inserts are committed to the > database by performing an > EXEC SQL COMMIT after every N of them; I tried > various values of N up to > several hundred, but it didn't make much difference. > Using psql I can see > records appearing in the database in groups of that > size. I'm not sure about > all of the protocol versions. I downloaded the > complete Postgres source and > built it only a few days ago. Ecpg says that it's > version is 3.1.1. I'm not > getting any errors reported anywhere, it's just that > things are surprisingly > slow over the LAN for some reason. > > William It's probably the number of round trips to the server. If pg can accept host variable arrays, try using a thousand element array or something to do your inserts. e.g. char mycharhv[1000][10] then set up the mycharhvs[1][..], [2][...] etc and fling them at the database with a single insert statement. I just tried this with the following program: #include exec sql include sqlca; exec sql begin declare section; char db[10]; char inserts[5000][10]; exec sql end declare section; int main(void) { unsigned int n; strcpy(db,"mydb"); exec sql connect to :db; printf("sqlcode connect %i\n",sqlca.sqlcode); for(n=0;n<5000;n++) { strcpy(inserts[n],"hello"); } exec sql insert into gaz values (:inserts); printf("sqlcode insert %i\n",sqlca.sqlcode); exec sql commit work; } This didn't work on pg, I only got one row inserted. This is using ecpg 2.9.0, pg 7.2.2 On Oracle with PRO*C this causes 5000 rows to be written with one insert and is a technique I've used to get better network performance with Oracle. Is this fixed in newer versions? If not, it sounds like a good feature. ___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com From pgsql-performance-owner@postgresql.org Fri Jul 23 14:10:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DAED9D1B179 for ; Fri, 23 Jul 2004 14:09:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35537-06 for ; Fri, 23 Jul 2004 17:09:55 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 5E330D1B16A for ; Fri, 23 Jul 2004 14:09:50 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1Bo3YJ-00020Y-00; Fri, 23 Jul 2004 13:09:48 -0400 To: "William Carney" Cc: Subject: Re: Performance over a LAN References: In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 23 Jul 2004 13:09:47 -0400 Message-ID: <878yday7j8.fsf@stark.xeocode.com> Lines: 14 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/155 X-Sequence-Number: 7546 "William Carney" writes: > The machines used are P4s running FreeBSD 5.2.1. The Postgres version is > 7.4.3. Can anyone tell me why there's such a big difference? You're going to have to run tcpdump and see where the delays are. It might be hard to decode the postgres protocol though. Which driver are you using? I wonder if it isn't the same nagle+delayed ack problem that came up recently. -- greg From pgsql-performance-owner@postgresql.org Fri Jul 23 14:42:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4979BD1B179 for ; Fri, 23 Jul 2004 14:42:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49692-02 for ; Fri, 23 Jul 2004 17:42:25 +0000 (GMT) Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) by svr1.postgresql.org (Postfix) with ESMTP id EA9CBD1B1A1 for ; Fri, 23 Jul 2004 14:42:21 -0300 (ADT) Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i6NHg1X21123; Fri, 23 Jul 2004 19:42:03 +0200 Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i6NHg8X26376; Fri, 23 Jul 2004 19:42:08 +0200 Message-ID: <41014DE1.8000007@bigfoot.com> Date: Fri, 23 Jul 2004 19:41:53 +0200 From: Gaetano Mendola User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Dennis Bjorklund , "pgsql-performance@postgresql.org" Subject: Re: [HACKERS] Wrong index choosen? References: <20162.1090593927@sss.pgh.pa.us> In-Reply-To: <20162.1090593927@sss.pgh.pa.us> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/156 X-Sequence-Number: 7547 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tom Lane wrote: | Dennis Bjorklund writes: | |>In this plan it estimates to get 481 but it got 22477. So the estimation |>was very wrong. You can increase the statistics tarhet on the login_time |>and it will probably be better (after the next analyze). | | | Given the nature of the data (login times), I'd imagine that the problem | is simply that he hasn't analyzed recently enough. A bump in stats | target may not be needed, but he's going to have to re-analyze that | column often if he wants this sort of query to be estimated accurately, | because the fraction of entries later than a given time T is *always* | going to be changing. Well know that I think about it, I felt my shoulders covered by pg_autovacuum but looking at the log I see that table never analyzed! Aaargh. I already applied the patch for the autovacuum but evidently I have to make it more aggressive, I'm sorry that I can not made him more aggressive only for this table. Thank you all. Regards Gaetano Mendola -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBAU3g7UpzwH2SGd4RAhbEAKDLbKXLGRqphBbfyBh6cu7QoqFQhACfdDtu cGS0K1UuTuwTDp4P2JjQ30A= =aepf -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Fri Jul 23 15:12:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6F246D1B220 for ; Fri, 23 Jul 2004 15:12:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60508-05 for ; Fri, 23 Jul 2004 18:12:20 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id 1661DD1B179 for ; Fri, 23 Jul 2004 15:12:17 -0300 (ADT) Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=[192.168.0.66]) by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) id 1Bo4Wl-0006uJ-UU; Fri, 23 Jul 2004 14:12:15 -0400 Message-ID: <410154F9.3080500@zeut.net> Date: Fri, 23 Jul 2004 14:12:09 -0400 From: "Matthew T. O'Connor" User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Gaetano Mendola Cc: Tom Lane , Dennis Bjorklund , "pgsql-performance@postgresql.org" Subject: Re: [HACKERS] Wrong index choosen? References: <20162.1090593927@sss.pgh.pa.us> <41014DE1.8000007@bigfoot.com> In-Reply-To: <41014DE1.8000007@bigfoot.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 67.80.199.173 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/157 X-Sequence-Number: 7548 Gaetano Mendola wrote: > Tom Lane wrote: > | Given the nature of the data (login times), I'd imagine that the problem > | is simply that he hasn't analyzed recently enough. A bump in stats > | target may not be needed, but he's going to have to re-analyze that > | column often if he wants this sort of query to be estimated accurately, > | because the fraction of entries later than a given time T is *always* > | going to be changing. > > Well know that I think about it, I felt my shoulders covered by > pg_autovacuum but looking at the log I see that table never analyzed! > Aaargh. > > I already applied the patch for the autovacuum but evidently I have to > make it more aggressive, I'm sorry that I can not made him more aggressive > only for this table. Yeah, the version of autovacuum in 7.4 contrib doesn't allow table specific settings. The patch I have sumbitted for 7.5 does, so hopefully this will be better in the future. You can however set the VACUUM and ANALYZE thresholds independently. So perhpaps it will help you if you set your ANALYZE setting to be very aggressive and your VACUUM settings to something more standard. Matthew From pgsql-performance-owner@postgresql.org Sun Jul 25 20:09:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D3D28D1B179 for ; Fri, 23 Jul 2004 17:56:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26140-03 for ; Fri, 23 Jul 2004 20:56:19 +0000 (GMT) Received: from smtp06.web.de (smtp06.web.de [217.72.192.224]) by svr1.postgresql.org (Postfix) with ESMTP id 69094D1B33D for ; Fri, 23 Jul 2004 17:56:16 -0300 (ADT) Received: from [62.246.34.39] (helo=hal) by smtp06.web.de with esmtp (WEB.DE 4.101 #44) id 1Bo75V-00080V-00 for pgsql-performance@postgresql.org; Fri, 23 Jul 2004 22:56:17 +0200 From: martin.bokler@web.de To: pgsql-performance@postgresql.org Date: Fri, 23 Jul 2004 23:28:15 +0200 MIME-Version: 1.0 Subject: variable length - user defined types/storage place Message-ID: <41019F0F.10384.345001@localhost> 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-Sender: martin.bokler@web.de X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/164 X-Sequence-Number: 7555 Hi all, in a large table (millions of rows) I am using a variable-length user defined type to store relatively short field entries, i.e. the length of certain fields could be restricted to 2^16 or even 2^8 characters. Now I wonder whether it would be possible to save storage place, by using a smaller length field, i.e. 2 Byte or even better 1 Byte per entry instead of 4 Byte. Is there a possibility to customize the size of the length field or does Postgresql already internally optimize this? Thanks in advance, Martin. From pgsql-performance-owner@postgresql.org Fri Jul 23 18:51:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D03EDD1B1A1 for ; Fri, 23 Jul 2004 18:51:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50543-07 for ; Fri, 23 Jul 2004 21:51:16 +0000 (GMT) Received: from web50004.mail.yahoo.com (web50004.mail.yahoo.com [206.190.38.19]) by svr1.postgresql.org (Postfix) with SMTP id 748A5D1B16A for ; Fri, 23 Jul 2004 18:51:09 -0300 (ADT) Message-ID: <20040723215111.46840.qmail@web50004.mail.yahoo.com> Received: from [200.93.192.137] by web50004.mail.yahoo.com via HTTP; Fri, 23 Jul 2004 16:51:11 CDT Date: Fri, 23 Jul 2004 16:51:11 -0500 (CDT) From: =?iso-8859-1?q?Jaime=20Casanova?= Subject: Re: [HACKERS] Wrong index choosen? To: pgsql-performance@postgresql.org In-Reply-To: <410154F9.3080500@zeut.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/158 X-Sequence-Number: 7549 Hi all, just as a question. There will be some day a feature that let you force the planner to use an specific index, like oracle does? Of course the planner is smart enough most times but sometimes such an option would be usefull, don't you think so? Thanx in advance, Jaime Casanova _________________________________________________________ Do You Yahoo!? Informaci�n de Estados Unidos y Am�rica Latina, en Yahoo! Noticias. Vis�tanos en http://noticias.espanol.yahoo.com From pgsql-performance-owner@postgresql.org Fri Jul 23 19:01:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8E607D1B1BE for ; Fri, 23 Jul 2004 19:01:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57243-02 for ; Fri, 23 Jul 2004 22:01:42 +0000 (GMT) Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net [63.231.195.112]) by svr1.postgresql.org (Postfix) with SMTP id ACCC9D1B272 for ; Fri, 23 Jul 2004 19:01:38 -0300 (ADT) Received: (qmail 5277 invoked by uid 0); 23 Jul 2004 22:01:40 -0000 Received: from unknown (63.231.195.13) by mpls-qmqp-01.inet.qwest.net with QMQP; 23 Jul 2004 22:01:40 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-13.inet.qwest.net with SMTP; 23 Jul 2004 22:01:40 -0000 Date: Fri, 23 Jul 2004 16:02:53 -0600 Message-Id: <1090620173.709.66.camel@localhost.localdomain> From: "Scott Marlowe" To: "Jaime Casanova" Cc: pgsql-performance@postgresql.org Subject: Re: [HACKERS] Wrong index choosen? In-Reply-To: <20040723215111.46840.qmail@web50004.mail.yahoo.com> References: <20040723215111.46840.qmail@web50004.mail.yahoo.com> Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/159 X-Sequence-Number: 7550 On Fri, 2004-07-23 at 15:51, Jaime Casanova wrote: > Hi all, > > just as a question. > > There will be some day a feature that let you force > the planner to use an specific index, like oracle > does? > > Of course the planner is smart enough most times but > sometimes such an option would be usefull, don't you > think so? A planner that always made the right choice would be the most useful thing. After that, the ability to "push" the planner towards an index would be pretty nice. Adding features that make PostgreSQL more error prone (i.e. forcing particular index usage, etc.) and harder to drive but allow an expert to get what they want is kind of a dangerous road to tread. From pgsql-performance-owner@postgresql.org Fri Jul 23 21:08:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C9B54D1B215 for ; Fri, 23 Jul 2004 21:08:07 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97398-02 for ; Sat, 24 Jul 2004 00:07:49 +0000 (GMT) Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) by svr1.postgresql.org (Postfix) with ESMTP id 394F4D1B1F8 for ; Fri, 23 Jul 2004 21:07:43 -0300 (ADT) Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i6O07Zt22596; Sat, 24 Jul 2004 02:07:36 +0200 Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i6O07gX27874; Sat, 24 Jul 2004 02:07:42 +0200 Message-ID: <4101A83F.2070801@bigfoot.com> Date: Sat, 24 Jul 2004 02:07:27 +0200 From: Gaetano Mendola User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Matthew T. O'Connor" Cc: Tom Lane , Dennis Bjorklund , "pgsql-performance@postgresql.org" Subject: Re: [HACKERS] Wrong index choosen? References: <20162.1090593927@sss.pgh.pa.us> <41014DE1.8000007@bigfoot.com> <410154F9.3080500@zeut.net> In-Reply-To: <410154F9.3080500@zeut.net> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/160 X-Sequence-Number: 7551 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matthew T. O'Connor wrote: | Gaetano Mendola wrote: | |> Tom Lane wrote: |> | Given the nature of the data (login times), I'd imagine that the |> problem |> | is simply that he hasn't analyzed recently enough. A bump in stats |> | target may not be needed, but he's going to have to re-analyze that |> | column often if he wants this sort of query to be estimated accurately, |> | because the fraction of entries later than a given time T is *always* |> | going to be changing. |> |> Well know that I think about it, I felt my shoulders covered by |> pg_autovacuum but looking at the log I see that table never analyzed! |> Aaargh. |> |> I already applied the patch for the autovacuum but evidently I have to |> make it more aggressive, I'm sorry that I can not made him more |> aggressive |> only for this table. | | | Yeah, the version of autovacuum in 7.4 contrib doesn't allow table | specific settings. The patch I have sumbitted for 7.5 does, so | hopefully this will be better in the future. | | You can however set the VACUUM and ANALYZE thresholds independently. So | perhpaps it will help you if you set your ANALYZE setting to be very | aggressive and your VACUUM settings to something more standard. Well I think pg_autovacuum as is in 7.4 can not help me for this particular table. The table have 4.8 milions rows and I have for that table almost 10252 new entries for day. I'm using pg_autovacuum with -a 200 -A 0.8 this means a threashold for that table equal to: 3849008 and if I understod well the way pg_autovacuum works this means have an analyze each 375 days, and I need an analyze for each day, at least. So I think is better for me put an analyze for that table in the cron. Am I wrong ? Regards Gaetano Mendola -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBAag87UpzwH2SGd4RAqb1AJ416ioVEY5T/dqnAQsaaqqoWcU3ZACghzsO 4xMowWp/MM8+i7DhoRO4018= =/gNn -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Fri Jul 23 22:49:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 919E3D1B220 for ; Fri, 23 Jul 2004 22:49:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23910-05 for ; Sat, 24 Jul 2004 01:49:48 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id 7B142D1B1B4 for ; Fri, 23 Jul 2004 22:49:43 -0300 (ADT) Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=[192.168.0.66]) by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) id 1BoBfV-000Hx7-Pz; Fri, 23 Jul 2004 21:49:45 -0400 Message-ID: <4101C032.9060409@zeut.net> Date: Fri, 23 Jul 2004 21:49:38 -0400 From: "Matthew T. O'Connor" User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Gaetano Mendola Cc: Tom Lane , Dennis Bjorklund , "pgsql-performance@postgresql.org" Subject: Re: [HACKERS] Wrong index choosen? References: <20162.1090593927@sss.pgh.pa.us> <41014DE1.8000007@bigfoot.com> <410154F9.3080500@zeut.net> <4101A83F.2070801@bigfoot.com> In-Reply-To: <4101A83F.2070801@bigfoot.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 67.80.199.173 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/161 X-Sequence-Number: 7552 Gaetano Mendola wrote: > Well I think pg_autovacuum as is in 7.4 can not help me for this particular > table. > > The table have 4.8 milions rows and I have for that table almost 10252 new > entries for day. > > I'm using pg_autovacuum with -a 200 -A 0.8 this means a threashold for > that table equal to: 3849008 and if I understod well the way pg_autovacuum > works this means have an analyze each 375 days, and I need an analyze for > each day, at least. > > So I think is better for me put an analyze for that table in the cron. > > Am I wrong ? No, I think you are right. You could do something like -a 1000 -A .00185, but that will probably for an analyze too often for most of your other tables. From pgsql-performance-owner@postgresql.org Mon Jul 26 01:57:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 62C25D1B755 for ; Mon, 26 Jul 2004 01:57:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64011-06 for ; Mon, 26 Jul 2004 04:57:37 +0000 (GMT) Received: from fungible2.mail.rice.edu (fungible2-dmfe1.mail.rice.edu [128.42.59.172]) by svr1.postgresql.org (Postfix) with ESMTP id 261E3D1B1D0 for ; Mon, 26 Jul 2004 01:57:29 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by fungible2.mail.rice.edu (Postfix) with SMTP id 75929199C3 for ; Sun, 25 Jul 2004 23:57:35 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by fungible2.mail.rice.edu (Postfix) with ESMTP id 46DAD1995F for ; Sun, 25 Jul 2004 23:57:35 -0500 (CDT) Received: from fungible2.mail.rice.edu ([127.0.0.1]) by localhost (fungible2.mail.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28429-06 for ; Sun, 25 Jul 2004 23:57:33 -0500 (CDT) Received: from wallace.cnx.rice.edu (wallace.cnx.rice.edu [128.42.246.68]) by fungible2.mail.rice.edu (Postfix) with ESMTP id 6D38F1994E for ; Sun, 25 Jul 2004 23:57:33 -0500 (CDT) Received: from reedstrm by wallace.cnx.rice.edu with local (Exim 3.36 #1 (Debian)) id 1BoxXy-00045d-00 for ; Sun, 25 Jul 2004 23:57:10 -0500 Date: Sun, 25 Jul 2004 23:57:10 -0500 From: "Ross J. Reedstrom" To: pgsql-performance@postgresql.org Subject: arrays and indexes Message-ID: <20040726045710.GA14892@cnx.rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavis-20030616-p6 at rice.edu X-DCC--Metrics: fungible2.mail.rice.edu 1067; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/165 X-Sequence-Number: 7556 Hi all - I've got a schema I'm working on modifying, nad I need some help getting the best performance out. The orginal schema has a many to many linkage between a couple tables, using a two column linkage table. This is used to represent groups of people and their relationship to an object (authors, copyrightholders, maintainers) This worked fine, and, with the right indixes, is quite zippy. Approximate schems: table content ( contentid serial, name text, <...> authorgroupid int, cpholdergroupid int, maintgroupid int) table groups ( personid text, groupid int) Note that neither grouid nor personid are unique. Now the users want not just groups, but ordered lists. Well, that's just fine: we could do it with another column in the groups linkage table, and some additional logic in the middleware for detecting identical groups, but it occured to me that PG's array types are just the ticket for ordered lists like this. So, by dropping arrays of personids (authors, copyrightholders, maintainers, ...) into the content table, I can do everything I need. Only one problem. Retreiving all the content for a particular person/role is fairly common. Queries of the form: SELECT * from content c join groups g on c.authorgroupid = g.personid where personid = 'ross'; work fine and use the index on groups.personid. In the new schema, the same thing is: SELECT * from content where 42 = ANY (authors); Works fine, but for the life of me I can't find nor figure out how to build an index that will be used to speed this along. Any ideas? I'm using 7.4.3, BTW. Ross -- Ross Reedstrom, Ph.D. reedstrm@rice.edu Research Scientist phone: 713-348-6166 The Connexions Project http://cnx.rice.edu fax: 713-348-3665 Rice University MS-375, Houston, TX 77005 GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE From pgsql-performance-owner@postgresql.org Mon Jul 26 03:27:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E4C8ED1B53E for ; Mon, 26 Jul 2004 03:27:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90754-08 for ; Mon, 26 Jul 2004 06:27:22 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 4CF06D1B54D for ; Mon, 26 Jul 2004 03:27:15 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BoyxE-0008NL-00; Mon, 26 Jul 2004 02:27:20 -0400 To: "Ross J. Reedstrom" Cc: pgsql-performance@postgresql.org Subject: Re: arrays and indexes References: <20040726045710.GA14892@cnx.rice.edu> In-Reply-To: <20040726045710.GA14892@cnx.rice.edu> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 26 Jul 2004 02:27:20 -0400 Message-ID: <87acxnwaev.fsf@stark.xeocode.com> Lines: 32 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/166 X-Sequence-Number: 7557 "Ross J. Reedstrom" writes: > In the new schema, the same thing is: > > SELECT * from content where 42 = ANY (authors); > > Works fine, but for the life of me I can't find nor figure out how to > build an index that will be used to speed this along. Any ideas? Well that's basically the problem with denormalized data like this. Have you resolved what you're going to do if two sessions try to add a user to the same group at the same time? Or how you'll go about removing a user from all his groups in one shot? Basically, if you denormalize in this fashion it becomes hard to use the groups as anything but single monolithic objects. Whereas normalized data can be queried and updated from other points of view like in the case you name above. Postgres does have a way to do what you ask, though. It involves GiST indexes and the operators from the contrib/intarray directory from the Postgres source. However I warn you in advance that this is fairly esoteric stuff and will take some time to get used to. And at least in my case I found the indexes didn't actually help much for my data sets, probably because they just weren't big enough to benefit. -- greg From pgsql-performance-owner@postgresql.org Mon Jul 26 11:16:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A7185D1B4A2 for ; Mon, 26 Jul 2004 11:16:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07675-08 for ; Mon, 26 Jul 2004 14:16:41 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id E6B0AD1B4FC for ; Mon, 26 Jul 2004 11:16:29 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6QEGYqb072707 for ; Mon, 26 Jul 2004 14:16:34 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6QE1RjQ069860 for pgsql-performance@postgresql.org; Mon, 26 Jul 2004 14:01:27 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: hardware raid suggestions Date: Mon, 26 Jul 2004 16:01:15 +0200 Organization: PYRENET Midi-pyrenees Provider Lines: 40 Message-ID: <41050EAB.6060901@bigfoot.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: Brian Hirt User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en In-Reply-To: X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/168 X-Sequence-Number: 7559 Brian Hirt wrote: > I've been using the adaptec ZCR raid cards in our servers for a while > now, mostly small systems with 3 or 6 disks, and we've been very happy > with them. However, we're building a new DB machine with 14 U320 15K > SCA drives, and we've run into a performance bottlenkeck with the ZCR > card where it just won't scale well. Without going into too many > details, we've tested RAID5, RAID10 and RAID50 on pretty much every > array size from 4-14 disks (raid 50 tests used more drives), using JFS, > reiserfs and EXT3. With every different configuration, performance > didn't improve after array size became greater than 6 disks.. We used > various benchmarks, including pgbench with scale factors of 10, 100, > 1000, 5000 and clients of 10, 15, 30 and 45. We've done many other > tests and monitoring tools, and we've come to the conclusion that the > ZCR is the problem. > > We're looking into getting an Adaptec 2200S or the Megaraid 320 2x which > have better processors, and hopefully better performance. We feel that > the use of the AIC7930 as the CPU on the ZCR just doesn't cut it and a > faster raid controller would work better. Does anyone out there have any > experience with these cards with postgresql and linux? If so, would you > be willing to share your experiences and possibly give a recommendation? > Did you consider the option of use an external storage array ? We are using the dell emc CX600 http://www.dell.com/downloads/emea/products/pvaul/en/Dell_EMC_cx600_specs.pdf and I'm forgotting to have a disk behind... Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Mon Jul 26 11:16:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8075ED1B495 for ; Mon, 26 Jul 2004 11:16:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12539-02 for ; Mon, 26 Jul 2004 14:16:41 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id DB15FD1B4FA for ; Mon, 26 Jul 2004 11:16:29 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6QEGYqd072707 for ; Mon, 26 Jul 2004 14:16:34 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6QECjsq071990 for pgsql-performance@postgresql.org; Mon, 26 Jul 2004 14:12:45 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Insert are going slower ... Date: Mon, 26 Jul 2004 16:12:31 +0200 Organization: PYRENET Midi-pyrenees Provider Lines: 20 Message-ID: <4105114F.5040200@bigfoot.com> References: <200407131850.52095.herve@elma.fr> <200407131010.30790.josh@agliodbs.com> <200407140142.11720.footcow@noos.fr> <200407140928.29498.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: Josh Berkus User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en In-Reply-To: <200407140928.29498.josh@agliodbs.com> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/167 X-Sequence-Number: 7558 Josh Berkus wrote: > Herve' > > I forgot to ask about your hardware. How much RAM, and what's your disk > setup? CPU? > > >>sort_mem = 512000 > > > Huh? Sort_mem is in K. The above says that you've allocated 512MB sort > mem. Is this process the *only* thing going on on the machine? And also is not system wide but let me say "for backend"... Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Mon Jul 26 11:47:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 36C92D1B380 for ; Mon, 26 Jul 2004 11:46:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29017-02 for ; Mon, 26 Jul 2004 14:46:47 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 6FF5AD1B17A for ; Mon, 26 Jul 2004 11:46:35 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6QEkZqb077688 for ; Mon, 26 Jul 2004 14:46:37 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6QEKS18073368 for pgsql-performance@postgresql.org; Mon, 26 Jul 2004 14:20:28 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Insert are going slower ... Date: Mon, 26 Jul 2004 16:20:15 +0200 Organization: PYRENET Midi-pyrenees Provider Lines: 70 Message-ID: <4105131F.9050005@bigfoot.com> References: <200407131850.52095.herve@elma.fr> <200407131010.30790.josh@agliodbs.com> <200407140142.11720.footcow@noos.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@pyrenet.fr To: =?ISO-8859-15?Q?Herv=E9_Piedvache?= User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en In-Reply-To: <200407140142.11720.footcow@noos.fr> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/169 X-Sequence-Number: 7560 Herv� Piedvache wrote: > Josh, > > Le mardi 13 Juillet 2004 19:10, Josh Berkus a �crit : > >>>What can I do to get better results ?? (configuration option, and/or >>>hardware update ?) >>>What can I give you to get more important informations to help me ? >> >>1) What PostgreSQL version are you using? > > > v7.4.3 > > >>2) What's your VACUUM, ANALYZE, VACUUM FULL, REINDEX schedule? > > > VACUUM FULL VERBOSE ANALYZE; > > Every day after the calculation I was talking about ... > > >>3) Can you list the non-default settings in your PostgreSQL.conf? >>Particularly, shared_buffers, sort_mem, checkpoint_segments, >>estimated_cache, and max_fsm_pages? > > sort_mem = 512000 This is too much, you are instructing Postgres to use 512MB for each backend ( some time each backend can use this quantity more then one ) > vacuum_mem = 409600 > max_fsm_pages = 50000000 > max_fsm_relations = 2000 50 milions ? HUG. what tell you postgres in the log after performing a vacuum full ? > max_files_per_process = 2000 > wal_buffers = 1000 > checkpoint_segments = 3 For massive insert you have to increase this number, pump it up to 16 > effective_cache_size = 5000000 5GB for 8 GB system is too much > random_page_cost = 3 on your HW you can decrease it to 2 and also decrease the other cpu costs Regards Gaetano Mendola BTW, I live in Paris too, if you need a hand... From pgsql-performance-owner@postgresql.org Mon Jul 26 11:52:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 93E80D1B751 for ; Mon, 26 Jul 2004 11:52:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30968-04 for ; Mon, 26 Jul 2004 14:52:29 +0000 (GMT) Received: from exchange2.netarx.com (unknown [66.147.137.11]) by svr1.postgresql.org (Postfix) with ESMTP id 8CBE4D1B74B for ; Mon, 26 Jul 2004 11:49:49 -0300 (ADT) Received: from [10.0.0.227] ([10.0.0.227]) by exchange2.netarx.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 26 Jul 2004 10:49:26 -0400 Message-ID: <410519F6.5020806@netarx.com> Date: Mon, 26 Jul 2004 10:49:26 -0400 From: "Harmon S. Nine" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.1) Gecko/20040722 Debian/1.4-2 StumbleUpon/1.79 X-Accept-Language: en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Timestamp-based indexing Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 26 Jul 2004 14:49:26.0280 (UTC) FILETIME=[BF3C5880:01C4731F] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/170 X-Sequence-Number: 7561 Hello -- To increase query (i.e. select) performance, we're trying to get postgres to use an index based on a timestamp column in a given table. Event-based data is put into this table several times a minute, with the timestamp indicating when a particular row was placed in the table. The table is purged daily, retaining only the rows that are less than 7 days old. That is, any row within the table is less than 1 week old (+ 1 day, since the purge is daily). A typical number of rows in the table is around 400,000. A "VACUUM FULL ANALYZE" is performed every 3 hours. The problem: We often query the table to extract those rows that are, say, 10 minutes old or less. Given there are 10080 minutes per week, the planner could, properly configured, estimate the number of rows returned by such a query to be: 10 min/ 10080 min * 400,000 = 0.001 * 400,000 = 400. Making an index scan, with the timestamp field the index, far faster then a sequential scan. However, we can't get the planner to do an timestamp-based index scan. Anyone know what to do? Here's the table specs: monitor=# \d "eventtable" Table "public.eventtable" Column | Type | Modifiers -----------+-----------------------------+-------------------------------------------------------------- timestamp | timestamp without time zone | not null default ('now'::text)::timestamp(6) with time zone key | bigint | not null default nextval('public."eventtable_key_seq"'::text) propagate | boolean | facility | character(10) | priority | character(10) | host | character varying(128) | not null message | text | not null Indexes: "eventtable_pkey" primary key, btree ("timestamp", "key") "eventtable_host" btree (host) "eventtable_timestamp" btree ("timestamp") Here's a query (with "explain analyze"): monitor=# explain analyze select * from "eventtable" where timestamp > CURRENT_TIMESTAMP - INTERVAL '10 minutes'; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Seq Scan on "eventtable" (cost=0.00..19009.97 rows=136444 width=155) (actual time=11071.073..11432.522 rows=821 loops=1) Filter: (("timestamp")::timestamp with time zone > (('now'::text)::timestamp(6) with time zone - '@ 10 mins'::interval)) Total runtime: 11433.384 ms (3 rows) Here's something strange. We try to disable sequential scans, but to no avail. The estimated cost skyrockets, though: monitor=# set enable_seqscan = false; SET monitor=# explain analyze select * from "eventtable" where timestamp > CURRENT_TIMESTAMP - INTERVAL '10 minutes'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on "eventtable" (cost=100000000.00..100019009.97 rows=136444 width=155) (actual time=9909.847..9932.438 rows=1763 loops=1) Filter: (("timestamp")::timestamp with time zone > (('now'::text)::timestamp(6) with time zone - '@ 10 mins'::interval)) Total runtime: 9934.353 ms (3 rows) monitor=# set enable_seqscan = true; SET monitor=# Any help is greatly appreciated :) -- Harmon From pgsql-performance-owner@postgresql.org Mon Jul 26 11:56:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 32DA7D1B373 for ; Mon, 26 Jul 2004 11:56:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31701-06 for ; Mon, 26 Jul 2004 14:56:55 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 9980CD1B380 for ; Mon, 26 Jul 2004 11:56:44 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: arrays and indexes Date: Mon, 26 Jul 2004 10:56:54 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEF1@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] arrays and indexes Thread-Index: AcRyzciGKstWlWZFQeyB2xa3EgFllwAUKR7A From: "Merlin Moncure" To: "Ross J. Reedstrom" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/171 X-Sequence-Number: 7562 Ross wrote: > Hi all - > I've got a schema I'm working on modifying, nad I need some help getting > the best performance out. The orginal schema has a many to many linkage > between a couple tables, using a two column linkage table. This is used > to represent groups of people and their relationship to an object > (authors, copyrightholders, maintainers) This worked fine, and, with the > right indixes, is quite zippy. Approximate schems: >=20 > table content ( > contentid serial, > name text, > <...> > authorgroupid int, > cpholdergroupid int, > maintgroupid int) >=20 > table groups ( > personid text, > groupid int) >=20 > Note that neither grouid nor personid are unique. >=20 > Now the users want not just groups, but ordered lists. Well, that's just > fine: we could do it with another column in the groups linkage table, > and some additional logic in the middleware for detecting identical > groups, but it occured to me that PG's array types are just the ticket > for ordered lists like this. >=20 > So, by dropping arrays of personids (authors, copyrightholders, > maintainers, ...) into the content table, I can do everything I need. >=20 > Only one problem. Retreiving all the content for a particular > person/role is fairly common. Queries of the form: >=20 > SELECT * from content c join groups g on c.authorgroupid =3D g.personid > where personid =3D 'ross'; >=20 > work fine and use the index on groups.personid. >=20 > In the new schema, the same thing is: >=20 > SELECT * from content where 42 =3D ANY (authors); >=20 > Works fine, but for the life of me I can't find nor figure out how to > build an index that will be used to speed this along. Any ideas? >=20 > I'm using 7.4.3, BTW. Arrays are usually a bad choice to put in your tables with a couple of exceptions. Keep in mind that you can generate the array in the query stage using custom aggregates if you prefer to deal with them on the client side. The basic problem is they introduce flexibility issues and are usually better handled by moving the data to a dependant table. Here are cases you might want to consider using arrays in your tables: 1. Your array bounds are small and known at design time (think: pay by quarter example in the docs). 2. Your array will not contain more than one or two dependant elements. 3. You are dealing with an extreme performance situation and you have tried doing things the proper way first. There are other exceptions...arrays can be a powerful tool albeit a dangerous one...just know what you are getting into. A firm understanding of relational principles are a tremendous help. If your array bounds are known, it possible to get around the index problem in limited cases by using a custom function (but only when the array bounds are known: create function any_quarter_over_10k (numeric[]) returns boolean as ' select=20 case=20 when $1[1] =3D > 10000 then true when $1[2] =3D > 10000 then true when $1[3] =3D > 10000 then true when $1[4] =3D > 10000 then true else false end;=09=09 ' language 'sql' IMMUTABLE; create index t_q_10k_idx on t(any_quarter_over_10k(salary_qtr)); select * from t where any_quarter_over_10k(t.salary_qtr) =3D true; Good luck! Merlin From pgsql-performance-owner@postgresql.org Mon Jul 26 12:05:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D18F2D1B17A for ; Mon, 26 Jul 2004 12:04:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37009-03 for ; Mon, 26 Jul 2004 15:04:43 +0000 (GMT) Received: from mail.speedfc.com (66-136-75-131.ded.swbell.net [66.136.75.131]) by svr1.postgresql.org (Postfix) with ESMTP id 42B4CD1B4CA for ; Mon, 26 Jul 2004 12:04:42 -0300 (ADT) Received: from [172.25.96.149] (unknown [172.25.96.149]) by mail.speedfc.com (Postfix) with ESMTP id 5397616EC4; Mon, 26 Jul 2004 10:03:22 -0500 (CDT) Message-ID: <41051C1E.90805@speedfc.com> Date: Mon, 26 Jul 2004 09:58:38 -0500 From: Kevin Barnard Organization: SpeedFC User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Harmon S. Nine" , pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing References: <410519F6.5020806@netarx.com> In-Reply-To: <410519F6.5020806@netarx.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/172 X-Sequence-Number: 7563 Harmon S. Nine wrote: > monitor=# explain analyze select * from "eventtable" where timestamp > > CURRENT_TIMESTAMP - INTERVAL '10 minutes'; > QUERY PLAN Try SELECT * FROM eventtable where timestamp BETWEEN (CURRENT_TIMESTAMP - INTERVAL '10 minutes') AND CURRENT_TIMESTAMP; This should will use a range off valid times. What your query is doing is looking for 10 minutes ago to an infinate future. Statically speaking that should encompass most of the table because you have an infinate range. No index will be used. If you assign a range the planner can fiqure out what you are looking for. -- Kevin Barnard Speed Fulfillment and Call Center kbarnard@speedfc.com 214-258-0120 From pgsql-performance-owner@postgresql.org Mon Jul 26 12:10:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5268ED1B493 for ; Mon, 26 Jul 2004 12:10:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40754-01 for ; Mon, 26 Jul 2004 15:10:00 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id CEA2BD1B17A for ; Mon, 26 Jul 2004 12:09:48 -0300 (ADT) Received: from ool-4353b51a.dyn.optonline.net ([67.83.181.26] helo=[192.168.2.155]) by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) id 1Bp76m-000LBb-6g; Mon, 26 Jul 2004 11:09:44 -0400 Message-ID: <41051EC1.3070704@zeut.net> Date: Mon, 26 Jul 2004 11:09:53 -0400 From: "Matthew T. O'Connor" User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Harmon S. Nine" Cc: pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing References: <410519F6.5020806@netarx.com> In-Reply-To: <410519F6.5020806@netarx.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 67.83.181.26 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/173 X-Sequence-Number: 7564 VACUUM FULL ANALYZE every 3 hours seems a little severe. You will probably be be served just as well by VACUUM ANALYZE. But you probably don't need the VACUUM part most of the time. You might try doing an ANALYZE on the specific tables you are having issues with. Since ANALYZE should be much quicker and not have the performance impact of a VACUUM, you could do it every hour, or even every 15 minutes. Good luck... Harmon S. Nine wrote: > Hello -- > > To increase query (i.e. select) performance, we're trying to get > postgres to use an index based on a timestamp column in a given table. > > Event-based data is put into this table several times a minute, with > the timestamp indicating when a particular row was placed in the table. > > The table is purged daily, retaining only the rows that are less than > 7 days old. That is, any row within the table is less than 1 week old > (+ 1 day, since the purge is daily). > > A typical number of rows in the table is around 400,000. > > A "VACUUM FULL ANALYZE" is performed every 3 hours. > > > The problem: > We often query the table to extract those rows that are, say, 10 > minutes old or less. > > Given there are 10080 minutes per week, the planner could, properly > configured, estimate the number of rows returned by such a query to be: > > 10 min/ 10080 min * 400,000 = 0.001 * 400,000 = 400. > > Making an index scan, with the timestamp field the index, far faster > then a sequential scan. > > > However, we can't get the planner to do an timestamp-based index scan. > > Anyone know what to do? > > > Here's the table specs: > > monitor=# \d "eventtable" > Table "public.eventtable" > Column | Type | > Modifiers > -----------+-----------------------------+-------------------------------------------------------------- > > timestamp | timestamp without time zone | not null default > ('now'::text)::timestamp(6) with time zone > key | bigint | not null default > nextval('public."eventtable_key_seq"'::text) > propagate | boolean | > facility | character(10) | > priority | character(10) | > host | character varying(128) | not null > message | text | not null > Indexes: > "eventtable_pkey" primary key, btree ("timestamp", "key") > "eventtable_host" btree (host) > "eventtable_timestamp" btree ("timestamp") > > > Here's a query (with "explain analyze"): > > monitor=# explain analyze select * from "eventtable" where timestamp > > CURRENT_TIMESTAMP - INTERVAL '10 minutes'; > QUERY PLAN > ---------------------------------------------------------------------------------------------------------------------------- > > Seq Scan on "eventtable" (cost=0.00..19009.97 rows=136444 width=155) > (actual time=11071.073..11432.522 rows=821 loops=1) > Filter: (("timestamp")::timestamp with time zone > > (('now'::text)::timestamp(6) with time zone - '@ 10 mins'::interval)) > Total runtime: 11433.384 ms > (3 rows) > > > Here's something strange. We try to disable sequential scans, but to > no avail. The estimated cost skyrockets, though: > > monitor=# set enable_seqscan = false; > SET > monitor=# explain analyze select * from "eventtable" where timestamp > > CURRENT_TIMESTAMP - INTERVAL '10 minutes'; > QUERY PLAN > ------------------------------------------------------------------------------------------------------------------------------------- > > Seq Scan on "eventtable" (cost=100000000.00..100019009.97 rows=136444 > width=155) (actual time=9909.847..9932.438 rows=1763 loops=1) > Filter: (("timestamp")::timestamp with time zone > > (('now'::text)::timestamp(6) with time zone - '@ 10 mins'::interval)) > Total runtime: 9934.353 ms > (3 rows) > > monitor=# set enable_seqscan = true; > SET > monitor=# > > > > Any help is greatly appreciated :) > > -- Harmon > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > From pgsql-performance-owner@postgresql.org Mon Jul 26 12:43:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D2C3FD1B758 for ; Mon, 26 Jul 2004 12:42:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57810-05 for ; Mon, 26 Jul 2004 15:42:53 +0000 (GMT) Received: from exchange2.netarx.com (unknown [66.147.137.11]) by svr1.postgresql.org (Postfix) with ESMTP id BD0DAD1B73C for ; Mon, 26 Jul 2004 12:42:31 -0300 (ADT) Received: from [10.0.0.227] ([10.0.0.227]) by exchange2.netarx.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 26 Jul 2004 11:42:26 -0400 Message-ID: <41052662.3090600@netarx.com> Date: Mon, 26 Jul 2004 11:42:26 -0400 From: "Harmon S. Nine" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.1) Gecko/20040722 Debian/1.4-2 StumbleUpon/1.79 X-Accept-Language: en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing References: <410519F6.5020806@netarx.com> <41051C1E.90805@speedfc.com> In-Reply-To: <41051C1E.90805@speedfc.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 26 Jul 2004 15:42:26.0796 (UTC) FILETIME=[26F892C0:01C47327] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/174 X-Sequence-Number: 7565 Thank you for your response :) This improves the row estimation, but it is still using a sequential scan. It really seems like the query would go faster if an index scan was used, given the number of rows fetched (both estimated and actual) is significantly less than the number of rows in the table. Is there some way to get the planner to use the timestamp as an index on these queries? monitor=# explain analyze select * from "eventtable" where timestamp between (CURRENT_TIMESTAMP - INTERVAL '10 min') AND CURRENT_TIMESTAMP; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on "eventtable" (cost=0.00..23103.29 rows=2047 width=155) (actual time=10227.253..10276.944 rows=1662 loops=1) Filter: ((("timestamp")::timestamp with time zone >= (('now'::text)::timestamp(6) with time zone - '@ 10 mins'::interval)) AND (("timestamp")::timestamp with time zone <= ('now'::text)::timestamp(6) with time zone)) Total runtime: 10278.628 ms (3 rows) monitor=# SELECT COUNT(*) FROM "eventtable"; count -------- 425602 (1 row) monitor=# -- Harmon Kevin Barnard wrote: > > > Harmon S. Nine wrote: > >> monitor=# explain analyze select * from "eventtable" where timestamp >> > CURRENT_TIMESTAMP - INTERVAL '10 minutes'; >> QUERY PLAN > > > Try > > SELECT * FROM eventtable where timestamp BETWEEN (CURRENT_TIMESTAMP - > INTERVAL '10 minutes') AND CURRENT_TIMESTAMP; > > This should will use a range off valid times. What your query is > doing is looking for 10 minutes ago to an infinate future. Statically > speaking that should encompass most of the table because you have an > infinate range. No index will be used. If you assign a range the > planner can fiqure out what you are looking for. > From pgsql-performance-owner@postgresql.org Mon Jul 26 12:46:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0E4E7D1B457 for ; Mon, 26 Jul 2004 12:46:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60065-01 for ; Mon, 26 Jul 2004 15:46:43 +0000 (GMT) Received: from exchange2.netarx.com (unknown [66.147.137.11]) by svr1.postgresql.org (Postfix) with ESMTP id 59E21D1B442 for ; Mon, 26 Jul 2004 12:46:43 -0300 (ADT) Received: from [10.0.0.227] ([10.0.0.227]) by exchange2.netarx.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 26 Jul 2004 11:46:42 -0400 Message-ID: <41052762.50801@netarx.com> Date: Mon, 26 Jul 2004 11:46:42 -0400 From: "Harmon S. Nine" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.1) Gecko/20040722 Debian/1.4-2 StumbleUpon/1.79 X-Accept-Language: en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing References: <410519F6.5020806@netarx.com> <41051EC1.3070704@zeut.net> In-Reply-To: <41051EC1.3070704@zeut.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 26 Jul 2004 15:46:42.0499 (UTC) FILETIME=[BF61C130:01C47327] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/175 X-Sequence-Number: 7566 We were getting a little desperate, so we engaged in overkill to rule out lack-of-analyze as a cause for the slow queries. Thanks for your advice :) -- Harmon Matthew T. O'Connor wrote: > VACUUM FULL ANALYZE every 3 hours seems a little severe. You will > probably be be served just as well by VACUUM ANALYZE. But you > probably don't need the VACUUM part most of the time. You might try > doing an ANALYZE on the specific tables you are having issues with. > Since ANALYZE should be much quicker and not have the performance > impact of a VACUUM, you could do it every hour, or even every 15 minutes. > > Good luck... > > Harmon S. Nine wrote: > >> Hello -- >> >> To increase query (i.e. select) performance, we're trying to get >> postgres to use an index based on a timestamp column in a given table. >> >> Event-based data is put into this table several times a minute, with >> the timestamp indicating when a particular row was placed in the table. >> >> The table is purged daily, retaining only the rows that are less than >> 7 days old. That is, any row within the table is less than 1 week >> old (+ 1 day, since the purge is daily). >> >> A typical number of rows in the table is around 400,000. >> >> A "VACUUM FULL ANALYZE" is performed every 3 hours. >> >> >> The problem: >> We often query the table to extract those rows that are, say, 10 >> minutes old or less. >> >> Given there are 10080 minutes per week, the planner could, properly >> configured, estimate the number of rows returned by such a query to be: >> >> 10 min/ 10080 min * 400,000 = 0.001 * 400,000 = 400. >> >> Making an index scan, with the timestamp field the index, far faster >> then a sequential scan. >> >> >> However, we can't get the planner to do an timestamp-based index scan. >> >> Anyone know what to do? >> >> >> Here's the table specs: >> >> monitor=# \d "eventtable" >> Table "public.eventtable" >> Column | Type | >> Modifiers >> -----------+-----------------------------+-------------------------------------------------------------- >> >> timestamp | timestamp without time zone | not null default >> ('now'::text)::timestamp(6) with time zone >> key | bigint | not null default >> nextval('public."eventtable_key_seq"'::text) >> propagate | boolean | >> facility | character(10) | >> priority | character(10) | >> host | character varying(128) | not null >> message | text | not null >> Indexes: >> "eventtable_pkey" primary key, btree ("timestamp", "key") >> "eventtable_host" btree (host) >> "eventtable_timestamp" btree ("timestamp") >> >> >> Here's a query (with "explain analyze"): >> >> monitor=# explain analyze select * from "eventtable" where timestamp >> > CURRENT_TIMESTAMP - INTERVAL '10 minutes'; >> QUERY PLAN >> ---------------------------------------------------------------------------------------------------------------------------- >> >> Seq Scan on "eventtable" (cost=0.00..19009.97 rows=136444 width=155) >> (actual time=11071.073..11432.522 rows=821 loops=1) >> Filter: (("timestamp")::timestamp with time zone > >> (('now'::text)::timestamp(6) with time zone - '@ 10 mins'::interval)) >> Total runtime: 11433.384 ms >> (3 rows) >> >> >> Here's something strange. We try to disable sequential scans, but to >> no avail. The estimated cost skyrockets, though: >> >> monitor=# set enable_seqscan = false; >> SET >> monitor=# explain analyze select * from "eventtable" where timestamp >> > CURRENT_TIMESTAMP - INTERVAL '10 minutes'; >> QUERY PLAN >> ------------------------------------------------------------------------------------------------------------------------------------- >> >> Seq Scan on "eventtable" (cost=100000000.00..100019009.97 >> rows=136444 width=155) (actual time=9909.847..9932.438 rows=1763 >> loops=1) >> Filter: (("timestamp")::timestamp with time zone > >> (('now'::text)::timestamp(6) with time zone - '@ 10 mins'::interval)) >> Total runtime: 9934.353 ms >> (3 rows) >> >> monitor=# set enable_seqscan = true; >> SET >> monitor=# >> >> >> >> Any help is greatly appreciated :) >> >> -- Harmon >> >> >> >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 3: if posting/reading through Usenet, please send an appropriate >> subscribe-nomail command to majordomo@postgresql.org so that your >> message can get through to the mailing list cleanly >> > From pgsql-performance-owner@postgresql.org Mon Jul 26 12:59:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 50D97D1B37C for ; Mon, 26 Jul 2004 12:59:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66238-04 for ; Mon, 26 Jul 2004 15:59:39 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9ED40D1B736 for ; Mon, 26 Jul 2004 12:59:20 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6QFxBeF028248; Mon, 26 Jul 2004 11:59:11 -0400 (EDT) To: "Matthew T. O'Connor" Cc: "Harmon S. Nine" , pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing In-reply-to: <41051EC1.3070704@zeut.net> References: <410519F6.5020806@netarx.com> <41051EC1.3070704@zeut.net> Comments: In-reply-to "Matthew T. O'Connor" message dated "Mon, 26 Jul 2004 11:09:53 -0400" Date: Mon, 26 Jul 2004 11:59:11 -0400 Message-ID: <28247.1090857551@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/176 X-Sequence-Number: 7567 "Matthew T. O'Connor" writes: > VACUUM FULL ANALYZE every 3 hours seems a little severe. If rows are only deleted once a day, that's a complete waste of time, indeed. I'd suggest running a plain VACUUM just after the deletion pass is done. ANALYZEs are a different matter and possibly need to be done every few hours, seeing that your maximum timestamp value is constantly changing. >> monitor=# set enable_seqscan = false; >> SET >> monitor=# explain analyze select * from "eventtable" where timestamp > >> CURRENT_TIMESTAMP - INTERVAL '10 minutes'; >> QUERY PLAN >> ------------------------------------------------------------------------------------------------------------------------------------- >> >> Seq Scan on "eventtable" (cost=100000000.00..100019009.97 rows=136444 >> width=155) (actual time=9909.847..9932.438 rows=1763 loops=1) >> Filter: (("timestamp")::timestamp with time zone > >> (('now'::text)::timestamp(6) with time zone - '@ 10 mins'::interval)) >> Total runtime: 9934.353 ms You've got some datatype confusion, too. CURRENT_TIMESTAMP yields timestamp with time zone, and since you made the timestamp column timestamp without time zone, you've got a cross-type comparison which is not indexable (at least not in 7.4). My opinion is that you chose the wrong type for the column. Values that represent specific real-world instants should always be timestamp with time zone, so that they mean the same thing if you look at them in a different time zone. Another issue here is that because CURRENT_TIMESTAMP - INTERVAL '10 minutes' isn't a constant, the planner isn't able to make use of the statistics gathered by ANALYZE anyway. That's why the rowcount estimate has nothing to do with reality. Unless you force the decision with "set enable_seqscan", the planner will never pick an indexscan with this rowcount estimate. The standard advice for getting around this is to hide the nonconstant calculation inside a function that's deliberately mislabeled immutable. For example, create function ago(interval) returns timestamp with time zone as 'select now() - $1' language sql strict immutable; select * from "eventtable" where timestamp > ago('10 minutes'); The planner folds the "ago('10 minutes')" to a constant, checks the statistics, and should do the right thing. Note however that this technique may break if you put a call to ago() inside a function or prepared statement --- it's only safe in interactive queries, where you don't care that the value is reduced to a constant during planning instead of during execution. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Jul 26 13:02:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C9976D1B764 for ; Mon, 26 Jul 2004 13:02:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66404-06 for ; Mon, 26 Jul 2004 16:02:12 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id A4DE7D1B775 for ; Mon, 26 Jul 2004 13:02:07 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id BF1C9350CC; Mon, 26 Jul 2004 09:02:03 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id BDBAF350C9; Mon, 26 Jul 2004 09:02:03 -0700 (PDT) Date: Mon, 26 Jul 2004 09:02:03 -0700 (PDT) From: Stephan Szabo To: "Harmon S. Nine" Cc: pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing In-Reply-To: <410519F6.5020806@netarx.com> Message-ID: <20040726085324.E68237@megazone.bigpanda.com> References: <410519F6.5020806@netarx.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/177 X-Sequence-Number: 7568 On Mon, 26 Jul 2004, Harmon S. Nine wrote: > However, we can't get the planner to do an timestamp-based index scan. > > Anyone know what to do? I'd wonder if the type conversion is causing you problems. CURRENT_TIMESTAMP - INTERVAL '10 minutes' is a timestamp with time zone while the column is timestamp without time zone. Casting CURRENT_TIMESTAMP to timestamp without time zone seemed to make it able to choose an index scan on 7.4. From pgsql-performance-owner@postgresql.org Mon Jul 26 13:24:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 98FB7D1B1D0 for ; Mon, 26 Jul 2004 13:24:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78421-05 for ; Mon, 26 Jul 2004 16:24:40 +0000 (GMT) Received: from mpls-qmqp-02.inet.qwest.net (mpls-qmqp-02.inet.qwest.net [63.231.195.113]) by svr1.postgresql.org (Postfix) with SMTP id 8BBBDD1B16A for ; Mon, 26 Jul 2004 13:24:38 -0300 (ADT) Received: (qmail 42231 invoked by uid 0); 26 Jul 2004 15:12:41 -0000 Received: from mpls-pop-10.inet.qwest.net (63.231.195.10) by mpls-qmqp-02.inet.qwest.net with QMQP; 26 Jul 2004 15:12:41 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-10.inet.qwest.net with SMTP; 26 Jul 2004 16:24:37 -0000 Date: Mon, 26 Jul 2004 10:25:38 -0600 Message-Id: <1090859137.22512.12.camel@localhost.localdomain> From: "Scott Marlowe" To: "Gaetano Mendola" Cc: "=?ISO-8859-1?Q?Herv=E9?= Piedvache" , pgsql-performance@postgresql.org Subject: Re: Insert are going slower ... In-Reply-To: <4105131F.9050005@bigfoot.com> References: <200407131850.52095.herve@elma.fr> <200407131010.30790.josh@agliodbs.com> <200407140142.11720.footcow@noos.fr> <4105131F.9050005@bigfoot.com> Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/178 X-Sequence-Number: 7569 On Mon, 2004-07-26 at 08:20, Gaetano Mendola wrote: > Hervé Piedvache wrote: SNIP > > sort_mem = 512000 > > This is too much, you are instructing Postgres to use 512MB > for each backend ( some time each backend can use this quantity > more then one ) agreed. If any one process needs this much sort mem, you can set it in that sessions with set sort_mem anyway, so to let every sort consume up to 512 meg is asking for trouble. > > effective_cache_size = 5000000 > > 5GB for 8 GB system is too much No, it's not. Assuming that postgresql with all it's shared buffers is using <2 gig, it's quite likely that the kernel is caching at least 5 gigs of disk data. Effective cache size doesn't set any cache size, it tells the planner about how much the kernel is caching. > > random_page_cost = 3 > > on your HW you can decrease it to 2 > and also decrease the other cpu costs On fast machines it often winds up needing to be set somewhere around 1.2 to 2.0 From pgsql-performance-owner@postgresql.org Mon Jul 26 15:37:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C46CDD1B73C for ; Mon, 26 Jul 2004 15:37:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41088-07 for ; Mon, 26 Jul 2004 18:37:51 +0000 (GMT) Received: from exchange2.netarx.com (unknown [66.147.137.11]) by svr1.postgresql.org (Postfix) with ESMTP id 0DC1CD1B580 for ; Mon, 26 Jul 2004 15:37:47 -0300 (ADT) Received: from [10.0.0.227] ([10.0.0.227]) by exchange2.netarx.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 26 Jul 2004 14:37:48 -0400 Message-ID: <41054F7C.3020108@netarx.com> Date: Mon, 26 Jul 2004 14:37:48 -0400 From: "Harmon S. Nine" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.1) Gecko/20040722 Debian/1.4-2 StumbleUpon/1.79 X-Accept-Language: en MIME-Version: 1.0 To: Stephan Szabo , pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing References: <410519F6.5020806@netarx.com> <20040726085324.E68237@megazone.bigpanda.com> In-Reply-To: <20040726085324.E68237@megazone.bigpanda.com> Content-Type: multipart/alternative; boundary="------------020900070905040507070108" X-OriginalArrivalTime: 26 Jul 2004 18:37:48.0640 (UTC) FILETIME=[A67A8E00:01C4733F] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: * X-Archive-Number: 200407/179 X-Sequence-Number: 7570 This is a multi-part message in MIME format. --------------020900070905040507070108 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit THAT WAS IT!! Thank you very much. Is there a way to change the type of "CURRENT_TIMESTAMP" to "timestamp without time zone" so that casting isn't needed? BTW, isn't this a bug? -- Harmon Stephan Szabo wrote: >On Mon, 26 Jul 2004, Harmon S. Nine wrote: > > > >>However, we can't get the planner to do an timestamp-based index scan. >> >>Anyone know what to do? >> >> > >I'd wonder if the type conversion is causing you problems. >CURRENT_TIMESTAMP - INTERVAL '10 minutes' is a timestamp with time zone >while the column is timestamp without time zone. Casting >CURRENT_TIMESTAMP to timestamp without time zone seemed to make it able to >choose an index scan on 7.4. > > > --------------020900070905040507070108 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit THAT WAS IT!!

Thank you very much.
Is there a way to change the type of "CURRENT_TIMESTAMP" to "timestamp without time zone" so that casting isn't needed?


BTW, isn't this a bug?

-- Harmon


Stephan Szabo wrote:
On Mon, 26 Jul 2004, Harmon S. Nine wrote:

  
However, we can't get the planner to do an timestamp-based index scan.

Anyone know what to do?
    

I'd wonder if the type conversion is causing you problems.
CURRENT_TIMESTAMP - INTERVAL '10 minutes' is a timestamp with time zone
while the column is timestamp without time zone.  Casting
CURRENT_TIMESTAMP to timestamp without time zone seemed to make it able to
choose an index scan on 7.4.

  

--------------020900070905040507070108-- From pgsql-performance-owner@postgresql.org Mon Jul 26 15:57:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 963A2D1B169 for ; Mon, 26 Jul 2004 15:57:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52307-08 for ; Mon, 26 Jul 2004 18:57:08 +0000 (GMT) Received: from fungible7.mail.rice.edu (fungible7-dmfe1.mail.rice.edu [128.42.59.177]) by svr1.postgresql.org (Postfix) with ESMTP id 7B76CD1B72E for ; Mon, 26 Jul 2004 15:57:03 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by fungible7.mail.rice.edu (Postfix) with SMTP id E411A1DC10; Mon, 26 Jul 2004 13:57:01 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by fungible7.mail.rice.edu (Postfix) with ESMTP id B3D471DBCA; Mon, 26 Jul 2004 13:57:01 -0500 (CDT) Received: from fungible7.mail.rice.edu ([127.0.0.1]) by localhost (fungible7.mail.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 17560-06; Mon, 26 Jul 2004 13:56:57 -0500 (CDT) Received: from wallace.cnx.rice.edu (wallace.cnx.rice.edu [128.42.246.68]) by fungible7.mail.rice.edu (Postfix) with ESMTP id 1F6E01DBCE; Mon, 26 Jul 2004 13:47:28 -0500 (CDT) Received: from reedstrm by wallace.cnx.rice.edu with local (Exim 3.36 #1 (Debian)) id 1BpAV5-0007IO-00; Mon, 26 Jul 2004 13:47:03 -0500 Date: Mon, 26 Jul 2004 13:47:03 -0500 From: "Ross J. Reedstrom" To: Greg Stark , Merlin Moncure Cc: pgsql-performance@postgresql.org Subject: Re: arrays and indexes Message-ID: <20040726184703.GA27820@cnx.rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , Greg Stark , Merlin Moncure , pgsql-performance@postgresql.org References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF1@Herge.rcsinc.local> <20040726045710.GA14892@cnx.rice.edu> <87acxnwaev.fsf@stark.xeocode.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AEF1@Herge.rcsinc.local> <87acxnwaev.fsf@stark.xeocode.com> User-Agent: Mutt/1.5.6+20040523i X-Virus-Scanned: by amavis-20030616-p6 at rice.edu X-DCC--Metrics: fungible7.mail.rice.edu 1067; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/180 X-Sequence-Number: 7571 On Mon, Jul 26, 2004 at 02:27:20AM -0400, Greg Stark wrote: > > "Ross J. Reedstrom" writes: > > > In the new schema, the same thing is: > > > > SELECT * from content where 42 = ANY (authors); > > > > Works fine, but for the life of me I can't find nor figure out how to > > build an index that will be used to speed this along. Any ideas? > > Well that's basically the problem with denormalized data like this. > > Have you resolved what you're going to do if two sessions try to add a user to > the same group at the same time? Or how you'll go about removing a user from > all his groups in one shot? We've got plenty of interlocks in the middleware to handle the first (mainly because this is an authoring system where everyone has to agree to participate, and acknowledge the open license on the materials) Second, they _can't_ be removed: we're effectively a write only archive. Even if we weren't it would be a rare event and could go slowly (loop over groups in the middleware, probably) > > Basically, if you denormalize in this fashion it becomes hard to use the > groups as anything but single monolithic objects. Whereas normalized data can > be queried and updated from other points of view like in the case you name > above. These groups _really are_ ideal for Joe Conway's work on arrays: we need ordered vectors, so we'd be sorting all the time, otherwise. They're static, and they're read only. The one thing they're not is fixed, known size (Sorry Merlin). They work fine for the query as shown: the only issue is performance. > Postgres does have a way to do what you ask, though. It involves GiST > indexes and the operators from the contrib/intarray directory from the > Postgres source. Well, yes, that's how it used to be done. I figured the new array support should be able to handle it without the addon, however. > However I warn you in advance that this is fairly esoteric stuff and > will take some time to get used to. And at least in my case I found > the indexes didn't actually help much for my data sets, probably > because they just weren't big enough to benefit. I know that they should help in this case: we've got lots of content. Any particular author or maintainter will be in a small fraction of those. i.e.: it's ideal for an index. And the current joined case uses an index, when it's available. I'll take a look at the GiST/contrib work, anyway. Thanks - Ross -- Ross Reedstrom, Ph.D. reedstrm@rice.edu Research Scientist phone: 713-348-6166 The Connexions Project http://cnx.rice.edu fax: 713-348-3665 Rice University MS-375, Houston, TX 77005 GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE From pgsql-performance-owner@postgresql.org Mon Jul 26 17:35:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 77BCAD1B537 for ; Mon, 26 Jul 2004 17:35:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04596-02 for ; Mon, 26 Jul 2004 20:35:02 +0000 (GMT) Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 52F6CD1B57D for ; Mon, 26 Jul 2004 17:34:58 -0300 (ADT) Received: (qmail 28445 invoked from network); 26 Jul 2004 22:34:59 +0200 Received: from unknown (HELO musicbox) (192.168.0.2) by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; 26 Jul 2004 22:34:59 +0200 To: pgsql-performance@postgresql.org Subject: Re: arrays and indexes References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF1@Herge.rcsinc.local> <20040726045710.GA14892@cnx.rice.edu> <87acxnwaev.fsf@stark.xeocode.com> <20040726184703.GA27820@cnx.rice.edu> Message-ID: From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Mon, 26 Jul 2004 22:35:01 +0200 In-Reply-To: <20040726184703.GA27820@cnx.rice.edu> User-Agent: Opera M2/7.50 (Linux, build 673) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/181 X-Sequence-Number: 7572 >> > SELECT * from content where 42 = ANY (authors); >> Postgres does have a way to do what you ask, though. It involves GiST >> indexes and the operators from the contrib/intarray directory from the >> Postgres source. I have tried to use these indexes, and the performance was very good. It can be faster (in fact much faster) than a join with an additional table, because you don't have a join. The SQL array syntax is a pain, though. From pgsql-performance-owner@postgresql.org Mon Jul 26 17:40:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B17FDD1B220 for ; Mon, 26 Jul 2004 17:40:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08615-01 for ; Mon, 26 Jul 2004 20:40:42 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id E8E42D1B215 for ; Mon, 26 Jul 2004 17:40:36 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BpCGu-0002Pn-00; Mon, 26 Jul 2004 16:40:32 -0400 To: "Ross J. Reedstrom" Cc: Greg Stark , Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: arrays and indexes References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF1@Herge.rcsinc.local> <20040726045710.GA14892@cnx.rice.edu> <87acxnwaev.fsf@stark.xeocode.com> <20040726184703.GA27820@cnx.rice.edu> In-Reply-To: <20040726184703.GA27820@cnx.rice.edu> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 26 Jul 2004 16:40:32 -0400 Message-ID: <87y8l6v6wv.fsf@stark.xeocode.com> Lines: 42 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/182 X-Sequence-Number: 7573 "Ross J. Reedstrom" writes: > These groups _really are_ ideal for Joe Conway's work on arrays: we need > ordered vectors, so we'd be sorting all the time, otherwise. They're > static, and they're read only. The one thing they're not is fixed, known > size (Sorry Merlin). They work fine for the query as shown: the only > issue is performance. Well just as long as you understand the trade-offs. Denormalizing can be useful but you need to know what flexibility you're losing too. > > Postgres does have a way to do what you ask, though. It involves GiST > > indexes and the operators from the contrib/intarray directory from the > > Postgres source. > > Well, yes, that's how it used to be done. I figured the new array > support should be able to handle it without the addon, however. I think you can btree index arrays now, which is new, but it's not useful for the kind of lookup you're doing. It would only be useful for joining on array types or looking for groups with given content, or things like that. > > However I warn you in advance that this is fairly esoteric stuff and > > will take some time to get used to. And at least in my case I found > > the indexes didn't actually help much for my data sets, probably > > because they just weren't big enough to benefit. > > I know that they should help in this case: we've got lots of content. > Any particular author or maintainter will be in a small fraction of > those. i.e.: it's ideal for an index. And the current joined case uses > an index, when it's available. I'll take a look at the GiST/contrib work, > anyway. I would be curious to know how it goes. My own project uses denormalized sets stored as arrays as well, though in my case they're precalculated from the fully normalized data. I tried to use GiST indexes but ran into problems combining the btree-GiST code with array GiST code in a multicolumn index. I still don't really know why it failed, but after two days building the index I gave up. -- greg From pgsql-performance-owner@postgresql.org Mon Jul 26 18:21:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BF100D1B215 for ; Mon, 26 Jul 2004 18:21:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23465-09 for ; Mon, 26 Jul 2004 21:21:13 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4046CD1B209 for ; Mon, 26 Jul 2004 18:21:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6QLLCj1009848; Mon, 26 Jul 2004 17:21:13 -0400 (EDT) To: Greg Stark Cc: "Ross J. Reedstrom" , Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: arrays and indexes In-reply-to: <87y8l6v6wv.fsf@stark.xeocode.com> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF1@Herge.rcsinc.local> <20040726045710.GA14892@cnx.rice.edu> <87acxnwaev.fsf@stark.xeocode.com> <20040726184703.GA27820@cnx.rice.edu> <87y8l6v6wv.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "26 Jul 2004 16:40:32 -0400" Date: Mon, 26 Jul 2004 17:21:12 -0400 Message-ID: <9847.1090876872@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/183 X-Sequence-Number: 7574 Greg Stark writes: > I would be curious to know how it goes. My own project uses > denormalized sets stored as arrays as well, though in my case they're > precalculated from the fully normalized data. I tried to use GiST > indexes but ran into problems combining the btree-GiST code with array > GiST code in a multicolumn index. I still don't really know why it > failed, but after two days building the index I gave up. Sounds like a bug to me. Could you put together a test case? regards, tom lane From pgsql-performance-owner@postgresql.org Mon Jul 26 18:27:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A3E23D1B4A2 for ; Mon, 26 Jul 2004 18:26:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30615-03 for ; Mon, 26 Jul 2004 21:26:38 +0000 (GMT) Received: from web13125.mail.yahoo.com (web13125.mail.yahoo.com [216.136.174.143]) by svr1.postgresql.org (Postfix) with SMTP id 80EC1D1B495 for ; Mon, 26 Jul 2004 18:26:34 -0300 (ADT) Message-ID: <20040726212636.5563.qmail@web13125.mail.yahoo.com> Received: from [63.78.248.48] by web13125.mail.yahoo.com via HTTP; Mon, 26 Jul 2004 14:26:36 PDT Date: Mon, 26 Jul 2004 14:26:36 -0700 (PDT) From: Litao Wu Subject: Re: Timestamp-based indexing To: Tom Lane , "Matthew T. O'Connor" Cc: "Harmon S. Nine" , pgsql-performance@postgresql.org In-Reply-To: <28247.1090857551@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/184 X-Sequence-Number: 7575 Hi, How about changing: CURRENT_TIMESTAMP - INTERVAL '10 minutes' to 'now'::timestamptz - INTERVAL '10 minutes' It seems to me that Postgres will treat it as a constant. Thanks, --- Tom Lane wrote: > "Matthew T. O'Connor" writes: > > VACUUM FULL ANALYZE every 3 hours seems a little > severe. > > If rows are only deleted once a day, that's a > complete waste of time, > indeed. > > I'd suggest running a plain VACUUM just after the > deletion pass is done. > ANALYZEs are a different matter and possibly need to > be done every > few hours, seeing that your maximum timestamp value > is constantly > changing. > > >> monitor=# set enable_seqscan = false; > >> SET > >> monitor=# explain analyze select * from > "eventtable" where timestamp > > >> CURRENT_TIMESTAMP - INTERVAL '10 minutes'; > >> QUERY PLAN > >> > ------------------------------------------------------------------------------------------------------------------------------------- > > >> > >> Seq Scan on "eventtable" > (cost=100000000.00..100019009.97 rows=136444 > >> width=155) (actual time=9909.847..9932.438 > rows=1763 loops=1) > >> Filter: (("timestamp")::timestamp with time zone > > > >> (('now'::text)::timestamp(6) with time zone - '@ > 10 mins'::interval)) > >> Total runtime: 9934.353 ms > > You've got some datatype confusion, too. > CURRENT_TIMESTAMP yields > timestamp with time zone, and since you made the > timestamp column > timestamp without time zone, you've got a cross-type > comparison which is > not indexable (at least not in 7.4). My opinion is > that you chose the > wrong type for the column. Values that represent > specific real-world > instants should always be timestamp with time zone, > so that they mean > the same thing if you look at them in a different > time zone. > > Another issue here is that because CURRENT_TIMESTAMP > - INTERVAL '10 > minutes' isn't a constant, the planner isn't able to > make use of the > statistics gathered by ANALYZE anyway. That's why > the rowcount estimate > has nothing to do with reality. Unless you force > the decision with > "set enable_seqscan", the planner will never pick an > indexscan with this > rowcount estimate. The standard advice for getting > around this is to > hide the nonconstant calculation inside a function > that's deliberately > mislabeled immutable. For example, > > create function ago(interval) returns timestamp with > time zone as > 'select now() - $1' language sql strict immutable; > > select * from "eventtable" where timestamp > ago('10 > minutes'); > > The planner folds the "ago('10 minutes')" to a > constant, checks the > statistics, and should do the right thing. Note > however that this > technique may break if you put a call to ago() > inside a function > or prepared statement --- it's only safe in > interactive queries, > where you don't care that the value is reduced to a > constant during > planning instead of during execution. > > regards, tom lane > > ---------------------------(end of > broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose > an index scan if your > joining column's datatypes do not match > __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail From pgsql-performance-owner@postgresql.org Mon Jul 26 18:40:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 26C64D1B342 for ; Mon, 26 Jul 2004 18:40:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35445-07 for ; Mon, 26 Jul 2004 21:40:08 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8143FD1B257 for ; Mon, 26 Jul 2004 18:40:05 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6QLe754010062; Mon, 26 Jul 2004 17:40:07 -0400 (EDT) To: Litao Wu Cc: "Matthew T. O'Connor" , "Harmon S. Nine" , pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing In-reply-to: <20040726212636.5563.qmail@web13125.mail.yahoo.com> References: <20040726212636.5563.qmail@web13125.mail.yahoo.com> Comments: In-reply-to Litao Wu message dated "Mon, 26 Jul 2004 14:26:36 -0700" Date: Mon, 26 Jul 2004 17:40:07 -0400 Message-ID: <10061.1090878007@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/185 X-Sequence-Number: 7576 Litao Wu writes: > How about changing: > CURRENT_TIMESTAMP - INTERVAL '10 minutes' > to > 'now'::timestamptz - INTERVAL '10 minutes' > It seems to me that Postgres will treat it as > a constant. Yeah, that works too, though again it might burn you if used inside a function or prepared statement. What you're doing here is to push the freezing of the "now" value even further upstream, namely to initial parsing of the command. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Jul 26 22:52:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 26C50D1B17A for ; Mon, 26 Jul 2004 22:52:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32394-02 for ; Tue, 27 Jul 2004 01:51:54 +0000 (GMT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 9A5EAD1B169 for ; Mon, 26 Jul 2004 22:51:48 -0300 (ADT) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i6R1pQUi073543; Tue, 27 Jul 2004 09:51:32 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <4105B57D.3040003@familyhealth.com.au> Date: Tue, 27 Jul 2004 09:53:01 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Litao Wu , "Matthew T. O'Connor" , "Harmon S. Nine" , pgsql-performance@postgresql.org Subject: Re: Timestamp-based indexing References: <20040726212636.5563.qmail@web13125.mail.yahoo.com> <10061.1090878007@sss.pgh.pa.us> In-Reply-To: <10061.1090878007@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/186 X-Sequence-Number: 7577 >>It seems to me that Postgres will treat it as >>a constant. > > > Yeah, that works too, though again it might burn you if used inside a > function or prepared statement. What you're doing here is to push the > freezing of the "now" value even further upstream, namely to initial > parsing of the command. What I do in my apps to get postgres to use the timestamp indexes in some situations is to just generate the current timestamp in iso format and then just insert it into the query as a constant, for that run of the query. Chris From pgsql-performance-owner@postgresql.org Tue Jul 27 01:33:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 07AEFD1B26C for ; Tue, 27 Jul 2004 01:32:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88237-04 for ; Tue, 27 Jul 2004 04:32:45 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 6A4F8D1B266 for ; Tue, 27 Jul 2004 01:32:45 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BpJdl-0003Kc-00; Tue, 27 Jul 2004 00:32:37 -0400 To: Tom Lane Cc: Greg Stark , "Ross J. Reedstrom" , Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: arrays and indexes References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF1@Herge.rcsinc.local> <20040726045710.GA14892@cnx.rice.edu> <87acxnwaev.fsf@stark.xeocode.com> <20040726184703.GA27820@cnx.rice.edu> <87y8l6v6wv.fsf@stark.xeocode.com> <9847.1090876872@sss.pgh.pa.us> In-Reply-To: <9847.1090876872@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Jul 2004 00:32:37 -0400 Message-ID: <87ekmyul22.fsf@stark.xeocode.com> Lines: 32 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/187 X-Sequence-Number: 7578 Tom Lane writes: > > I still don't really know why it failed, but after two days building the > > index I gave up. > > Sounds like a bug to me. Could you put together a test case? At the time I contacted one of the GiST authors and we went over things for a while. They diagnosed the problem as being caused by having a poor selectivity GiST btree as the leading column in the index. He seemed to think this was fairly fundamental and wasn't something they were going to be able to address. And I was fairly certain I didn't want to turn the index upside down to have the more selective columns first (as is usually normal) for various reasons. So I gave it up as a lost cause. In any case in my application it was unlikely to really help. I expect that leading btree index to narrow the search to only a few hundred or few thousand records in the normal case. So the access times are already within reason even having to dig through all the records. And since other queries are likely to need other records from that set I'll need them all in cache eventually. There are a lot of array columns to search through, so the added i/o to read all those indexes would probably be a net loss when they push other things out of cache. I could try setting up a test case, but I think all it took was having a btree-gist index that was insufficiently selective. In my case I had about 900 integer values each on the order of 100-1000 records. -- greg From pgsql-performance-owner@postgresql.org Tue Jul 27 04:35:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BCFD7D1B18A for ; Tue, 27 Jul 2004 04:35:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51478-09 for ; Tue, 27 Jul 2004 07:35:43 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 1729DD1B179 for ; Tue, 27 Jul 2004 04:35:37 -0300 (ADT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id C6C63EC311 for ; Tue, 27 Jul 2004 08:38:20 +0200 (CEST) Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id A51EFEC304 for ; Tue, 27 Jul 2004 08:38:20 +0200 (CEST) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: pgsql-performance@postgresql.org Subject: Little understanding for tuning ... Date: Tue, 27 Jul 2004 09:35:33 +0200 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Message-Id: <200407270935.33431.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/188 X-Sequence-Number: 7579 Dear all, This is my two last line of a vacuum full verbose analyse;. INFO: �free space map: 27 relations, 4336 pages stored; 3232 total pages needed DETAIL: �Allocated FSM size: 2000 relations + 50000000 pages = 293088 kB What are the good parameters to set with those informations : max_fsm_pages = 30000 � max_fsm_relations = 100 Any other parameters could be defined with this informations ? Thanks per advance, -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Tue Jul 27 10:07:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5FB51D1B4C9 for ; Tue, 27 Jul 2004 10:07:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93853-07 for ; Tue, 27 Jul 2004 13:07:02 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 62976D1B4A2 for ; Tue, 27 Jul 2004 10:06:58 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: best way to fetch next/prev record based on index X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 27 Jul 2004 09:07:02 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: best way to fetch next/prev record based on index Thread-Index: AcRz2ptgPgM0sdjeRISaPhtTneo8uw== From: "Merlin Moncure" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/189 X-Sequence-Number: 7580 I am in a situation where I have to treat a table as logically ordered based on an index. Right now I'm doing this via queries, and a I need a better way to do it. Cursors do not meet my requirements, because they are always insensitive. Also, my performance requirements are extreme...I need 100% index usage. Currently, I use queries to do this. Unfortunately, the queries can get kind of complex because many if the indexes (keys, really) are over 3 or more columns in a table. So, for a table t with a three part key over columns a,b,c, the query to read the next value from t for given values a1, b1, c1 is select * from t where a >=3D a1 and (a > a1 or b >=3D b1) and (a > a1 or b > b1 or c > c1) In about 95% of cases, the planner correctly selects the index t(a,b,c) and uses it. However, the 5% remaining cases usually come at the worst time, when large tables and 3 or 4 part keys are involved. In those cases sometimes the planner applies the filter to a, but not b or c with a large performance hit. Manipulating statistics on the table does not seem to help. Interestingly, it is possible to rewrite the above query by switching and with or and >=3D with >. However when written that way, the planner almost never gets it right. My problem is deceptively simple: how you read the next record from a table based on a given set of values? In practice, this is difficult to implement. If anybody can suggest a alternative/better way to this, I'm all ears. Merlin From pgsql-performance-owner@postgresql.org Tue Jul 27 10:15:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 54C1ED1B4C9 for ; Tue, 27 Jul 2004 10:15:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95407-08 for ; Tue, 27 Jul 2004 13:15:40 +0000 (GMT) Received: from mail.logi-track.com (www.logi-track.com [213.239.193.212]) by svr1.postgresql.org (Postfix) with ESMTP id BB8C6D1B38E for ; Tue, 27 Jul 2004 10:15:32 -0300 (ADT) Received: from kingfisher.intern.logi-track.com (G6110.g.pppool.de [80.185.97.16]) by mail.logi-track.com (Postfix) with ESMTP id B45D030197; Tue, 27 Jul 2004 13:21:48 +0000 (UTC) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id 831FBAB2D0; Tue, 27 Jul 2004 15:15:32 +0200 (CEST) Date: Tue, 27 Jul 2004 15:15:31 +0200 From: Markus Schaber To: PostgreSQL Performance List Subject: Automagic tuning Message-Id: <20040727151531.4f60b5b0@kingfisher.intern.logi-track.com> Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K; Wed, 28 Jul 2004 00:30:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05492-08 for ; Wed, 28 Jul 2004 03:30:42 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 50E90D1CC1F for ; Wed, 28 Jul 2004 00:22:24 -0300 (ADT) Received: from mail.logi-track.com (burro.logi-track.com [213.239.193.212]) by www.postgresql.com (Postfix) with ESMTP id 5966ACF6401 for ; Tue, 27 Jul 2004 11:13:53 -0300 (ADT) Received: from kingfisher.intern.logi-track.com (G6110.g.pppool.de [80.185.97.16]) by mail.logi-track.com (Postfix) with ESMTP id 70AC930197; Tue, 27 Jul 2004 14:19:41 +0000 (UTC) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id 4A479AB2D0; Tue, 27 Jul 2004 16:13:26 +0200 (CEST) Date: Tue, 27 Jul 2004 16:13:25 +0200 From: Markus Schaber To: "Merlin Moncure" Cc: Subject: Re: best way to fetch next/prev record based on index Message-Id: <20040727161325.213b11eb@kingfisher.intern.logi-track.com> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K wrote: > So, for a table t with a three part key over columns a,b,c, the query > to read the next value from t for given values a1, b1, c1 is >=20 > select * from t where > a >=3D a1 and > (a > a1 or b >=3D b1) and > (a > a1 or b > b1 or c > c1) You mut not rely on such trickery to get any ordering, as the SQL data model contains no ordering, and a query optimizer is free to deliver you the tuples in any order it feels like. Why don't you add a 'ORDER BY a,b,c ASC' to your query? > Interestingly, it is possible to rewrite the above query by switching > and with or and >=3D with >. However when written that way, the planner > almost never gets it right. That's the reason why you cannot rely on any implicit ordering, the planner is free to rewrite a query as it likes as long as it delivers the same tuples, but in any order it wants. > My problem is deceptively simple: how you read the next record from a > table based on a given set of values? In practice, this is difficult > to implement. If anybody can suggest a alternative/better way to > this, I'm all ears. So you really want something like 'SELECT * FROM t WHERE a>=3Da1 AND b>=3Db1 AND c>=3Dc1 ORDER BY a,b,c ASC L= IMIT 1' HTH, Markus --=20 markus schaber | dipl. informatiker logi-track ag | rennweg 14-16 | ch 8001 z=FCrich phone +41-43-888 62 52 | fax +41-43-888 62 53 mailto:schabios@logi-track.com | www.logi-track.com From pgsql-performance-owner@postgresql.org Wed Jul 28 00:35:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 26B57D1B8C5 for ; Wed, 28 Jul 2004 00:35:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10330-03 for ; Wed, 28 Jul 2004 03:35:33 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 13FC0D1D2D2 for ; Wed, 28 Jul 2004 00:23:31 -0300 (ADT) Received: from vscan01.westnet.com.au (vscan01.westnet.com.au [203.10.1.131]) by www.postgresql.com (Postfix) with ESMTP id 8A8C8CF645A for ; Tue, 27 Jul 2004 11:20:07 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with ESMTP id 1C0B051805; Tue, 27 Jul 2004 22:19:46 +0800 (WST) Received: from [192.168.1.9] (dsl-202-72-133-22.wa.westnet.com.au [202.72.133.22]) by vscan01.westnet.com.au (Postfix) with ESMTP id C31FC50C49; Tue, 27 Jul 2004 22:19:45 +0800 (WST) Message-ID: <41066485.7080502@familyhealth.com.au> Date: Tue, 27 Jul 2004 22:19:49 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Markus Schaber Cc: PostgreSQL Performance List Subject: Re: Automagic tuning References: <20040727151531.4f60b5b0@kingfisher.intern.logi-track.com> In-Reply-To: <20040727151531.4f60b5b0@kingfisher.intern.logi-track.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/199 X-Sequence-Number: 7590 > Are there any tools that help with postgres/postgis performance tuning? > > So they measure the acutal tuple costs and cpu power, or suggest optimal > values for the index sample counts? Have you turned on the stat_* settings in postgresql.conf and then examined the pg_stat_* system views? Chris From pgsql-performance-owner@postgresql.org Wed Jul 28 00:36:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 30709D1B741 for ; Wed, 28 Jul 2004 00:34:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09048-06 for ; Wed, 28 Jul 2004 03:33:57 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 85AD2D1D1C7 for ; Wed, 28 Jul 2004 00:23:12 -0300 (ADT) Received: from mail.logi-track.com (burro.logi-track.com [213.239.193.212]) by www.postgresql.com (Postfix) with ESMTP id 770F0CF6491 for ; Tue, 27 Jul 2004 11:21:43 -0300 (ADT) Received: from kingfisher.intern.logi-track.com (G6110.g.pppool.de [80.185.97.16]) by mail.logi-track.com (Postfix) with ESMTP id 288A730197; Tue, 27 Jul 2004 14:27:35 +0000 (UTC) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id 32A37AB2D0; Tue, 27 Jul 2004 16:21:18 +0200 (CEST) Date: Tue, 27 Jul 2004 16:21:17 +0200 From: Markus Schaber To: "Merlin Moncure" Cc: Subject: Correction of best way to fetch next/prev record based on index Message-Id: <20040727162117.6de666b6@kingfisher.intern.logi-track.com> In-Reply-To: <20040727161325.213b11eb@kingfisher.intern.logi-track.com> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> <20040727161325.213b11eb@kingfisher.intern.logi-track.com> Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K You mut not Should be "must", not "mut" :-) > > My problem is deceptively simple: how you read the next record from > > a table based on a given set of values? In practice, this is > > difficult to implement. If anybody can suggest a alternative/better > > way to this, I'm all ears. >=20 > So you really want something like >=20 > 'SELECT * FROM t WHERE a>=3Da1 AND b>=3Db1 AND c>=3Dc1 ORDER BY a,b,c ASC > LIMIT 1' Sorry, as you want the _next_, and I assume that a1, b1 and c1 are the current row's values, you should rather use something like: 'SELECT * FROM t WHERE a>=3Da1 AND b>=3Db1 AND c>=3Dc1 ORDER BY a,b,c ASC LIMIT 1 OFFSET 1' HTH, Markus --=20 markus schaber | dipl. informatiker logi-track ag | rennweg 14-16 | ch 8001 z=FCrich phone +41-43-888 62 52 | fax +41-43-888 62 53 mailto:schabios@logi-track.com | www.logi-track.com From pgsql-performance-owner@postgresql.org Wed Jul 28 00:46:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 65170D1CB6F for ; Wed, 28 Jul 2004 00:41:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14267-09 for ; Wed, 28 Jul 2004 03:41:44 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 7FBF6D1D6F4 for ; Wed, 28 Jul 2004 00:24:33 -0300 (ADT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by www.postgresql.com (Postfix) with ESMTP id BE962CF649C for ; Tue, 27 Jul 2004 11:21:46 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: best way to fetch next/prev record based on index X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 27 Jul 2004 10:21:32 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEF8@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index Thread-Index: AcRz4+Kd7QAm+QdxRrCsrng5zB/PGAAAA0MA From: "Merlin Moncure" To: "Markus Schaber" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/204 X-Sequence-Number: 7595 > > So, for a table t with a three part key over columns a,b,c, the query > > to read the next value from t for given values a1, b1, c1 is > > > > select * from t where > > a >=3D a1 and > > (a > a1 or b >=3D b1) and > > (a > a1 or b > b1 or c > c1) >=20 > You mut not rely on such trickery to get any ordering, as the SQL data > model contains no ordering, and a query optimizer is free to deliver you > the tuples in any order it feels like. >=20 > Why don't you add a 'ORDER BY a,b,c ASC' to your query? Left that part out (oops) :). My queries always have that at the end (or they will give incorrect results!). All are suffixed with order by a,b,c limit n. n is manipulated in some cases for progressive read ahead (kind of like fetch 'n' in cursors)). The basic problem is the planner can't always match the query to the index. So, either the planner has to be helped/fixed or I have to explore another solution. This seems to happen most when the 'a' column has very poor selectivity. In this case, the planner will only examine the 'a' part of the key. Merlin From pgsql-performance-owner@postgresql.org Wed Jul 28 00:34:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E8719D1CA97 for ; Wed, 28 Jul 2004 00:28:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04682-02 for ; Wed, 28 Jul 2004 03:28:41 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id E69B2D1CB85 for ; Wed, 28 Jul 2004 00:22:12 -0300 (ADT) Received: from tht.net (vista.tht.net [216.126.88.2]) by www.postgresql.com (Postfix) with ESMTP id 4F24FCF689C for ; Tue, 27 Jul 2004 11:36:58 -0300 (ADT) Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) by tht.net (Postfix) with ESMTP id D906876B20; Tue, 27 Jul 2004 10:36:36 -0400 (EDT) Subject: Re: best way to fetch next/prev record based on index From: Rod Taylor To: Merlin Moncure Cc: Postgresql Performance In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> Content-Type: text/plain Message-Id: <1090938993.83536.85.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 27 Jul 2004 10:36:34 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/197 X-Sequence-Number: 7588 You only want one record to be returned? Tack a LIMIT 1 onto the end of the query. > My problem is deceptively simple: how you read the next record from a > table based on a given set of values? In practice, this is difficult to > implement. If anybody can suggest a alternative/better way to this, I'm > all ears. From pgsql-performance-owner@postgresql.org Wed Jul 28 00:43:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B404AD1C4C3 for ; Wed, 28 Jul 2004 00:24:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99980-08 for ; Wed, 28 Jul 2004 03:24:13 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 18145D1C92A for ; Wed, 28 Jul 2004 00:21:33 -0300 (ADT) Received: from mail.logi-track.com (burro.logi-track.com [213.239.193.212]) by www.postgresql.com (Postfix) with ESMTP id 135A4CF6957 for ; Tue, 27 Jul 2004 11:51:10 -0300 (ADT) Received: from kingfisher.intern.logi-track.com (G6110.g.pppool.de [80.185.97.16]) by mail.logi-track.com (Postfix) with ESMTP id BF9BE30197; Tue, 27 Jul 2004 14:57:02 +0000 (UTC) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id 34541AB2D0; Tue, 27 Jul 2004 16:50:45 +0200 (CEST) Date: Tue, 27 Jul 2004 16:50:44 +0200 From: Markus Schaber To: "Merlin Moncure" Cc: Subject: Re: best way to fetch next/prev record based on index Message-Id: <20040727165044.0549286e@kingfisher.intern.logi-track.com> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AEF8@Herge.rcsinc.local> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF8@Herge.rcsinc.local> Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K wrote: > The basic problem is the planner can't always match the query to the > index. So, either the planner has to be helped/fixed or I have to > explore another solution. This seems to happen most when the 'a' > column has very poor selectivity. In this case, the planner will only > examine the 'a' part of the key. So it may help to add some more indices so you have an index for all permut= ations, Create an index on (a,b,c), (a,c,b), (b,c,a), (b,a,c), (c,a,b) and (c,b,a). So as long as one of the rows has enough selectivity, the planner should be able to select the correct index. Maybe increasing the number of random samples for the rows is useful. HTH, Markus --=20 markus schaber | dipl. informatiker logi-track ag | rennweg 14-16 | ch 8001 z=FCrich phone +41-43-888 62 52 | fax +41-43-888 62 53 mailto:schabios@logi-track.com | www.logi-track.com From pgsql-performance-owner@postgresql.org Wed Jul 28 00:51:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 58D83D1B8FC for ; Wed, 28 Jul 2004 00:50:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19023-09 for ; Wed, 28 Jul 2004 03:50:07 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 545EDD1DB8D for ; Wed, 28 Jul 2004 00:26:12 -0300 (ADT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by www.postgresql.com (Postfix) with ESMTP id EBE83CF6A15 for ; Tue, 27 Jul 2004 12:03:41 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: best way to fetch next/prev record based on index X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 27 Jul 2004 11:03:14 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEF9@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index Thread-Index: AcRz6RjbsQIw3tE5RGa8D8Rgeb24kAAAIHSA From: "Merlin Moncure" To: "Markus Schaber" Cc: , "Rod Taylor" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/208 X-Sequence-Number: 7599 Markus wrote: > > The basic problem is the planner can't always match the query to the > > index. So, either the planner has to be helped/fixed or I have to > > explore another solution. This seems to happen most when the 'a' > > column has very poor selectivity. In this case, the planner will only > > examine the 'a' part of the key. >=20 > So it may help to add some more indices so you have an index for all > permutations, >=20 > Create an index on (a,b,c), (a,c,b), (b,c,a), (b,a,c), (c,a,b) and > (c,b,a). It is mathematically impossible for any index except for (a,b,c) to work. Although, in theory, (a,b) could be used...but that wouldn't help. In any event, creating 1000s and 1000s of extra indices is not an option. Here is some log snippets illustrating my problem: Here is a log snippet illustrating things when everything is working ok (notice the sub-millisecond times): prepare data3_read_next_menu_item_recent_file_0 (character varying, numeric, numeric, numeric) as select xmin, xmax, * from data3.menu_item_recent_file where mir_user_id >=3D $1 and=20 (mir_user_id > $1 or mir_menu_item_id >=3D $2) and=20 (mir_user_id > $1 or mir_menu_item_id > $2 or mir_sequence_no > $3) order by mir_user_id, mir_menu_item_id, mir_sequence_no limit $4 0.000849704 sec data3_read_next_menu_item_recent_file_0 0.000435999 sec params: $1=3DMERLIN $2=3D00057 $3=3D00000001 $4=3D1=20 data3_read_next_menu_item_recent_file_0 0.0117151 sec params: $1=3DMERLIN $2=3D00058 $3=3D00000002 $4=3D2=20 data3_read_next_menu_item_recent_file_0 0.0385374 sec params: $1=3DMERLIN $2=3D00203 $3=3D00000005 $4=3D3=20 data3_read_next_menu_item_recent_file_0 0.0211677 sec params: $1=3DMERLIN $2=3D00449 $3=3D00000010 $4=3D4=20 data3_read_next_menu_item_recent_file_0 0.000818999 sec params: $1=3DMERLIN $2=3D00813 $3=3D00000008 $4=3D5 Here is a log snippet when there is a problem: data3_start_nl_line_file_0 37.2677 sec params: $1=3D $2=3D008768 $3=3D003 $= 4=3D1 prepare data3_read_next_line_file_0 (character, numeric, numeric, numeric) as select xmin, xmax, * from data3.line_file where li_quote_flag >=3D $1 and=20 (li_quote_flag > $1 or li_order_no >=3D $2) and=20 (li_quote_flag > $1 or li_order_no > $2 or li_seq_no > $3) order by li_quote_flag, li_order_no, li_seq_no limit $4 0.000839501 sec data3_read_next_line_file_0 0.313869 sec params: $1=3D $2=3D008768 $3=3D005 $4=3D1=20 data3_read_next_line_file_0 0.343179 sec params: $1=3D $2=3D008768 $3=3D006 $4=3D2=20 data3_read_next_line_file_0 0.308703 sec params: $1=3D $2=3D008768 $3=3D008 $4=3D3=20 data3_read_next_line_file_0 0.306802 sec params: $1=3D $2=3D008768 $3=3D011 $4=3D4=20 data3_read_next_line_file_0 0.311033 sec params: $1=3D $2=3D008768 $3=3D015 $4=3D5 in the above statements, .3 sec to return a single row is very poor. Explain only matches li_quote_flag to the index which offers very poor selectivity. li_quote_flag is a char(1) and there is an index on line_file on the three where columns in the proper order. Merlin From pgsql-performance-owner@postgresql.org Wed Jul 28 00:22:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 452CAD1CC25 for ; Wed, 28 Jul 2004 00:22:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98499-06 for ; Wed, 28 Jul 2004 03:22:21 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 99833D1BACD for ; Wed, 28 Jul 2004 00:21:24 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by www.postgresql.com (Postfix) with ESMTP id 0E96DCF68C1 for ; Tue, 27 Jul 2004 12:15:16 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6RFE1wM028701; Tue, 27 Jul 2004 11:14:01 -0400 (EDT) To: "Merlin Moncure" Cc: pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> Comments: In-reply-to "Merlin Moncure" message dated "Tue, 27 Jul 2004 09:07:02 -0400" Date: Tue, 27 Jul 2004 11:14:01 -0400 Message-ID: <28700.1090941241@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/191 X-Sequence-Number: 7582 "Merlin Moncure" writes: > So, for a table t with a three part key over columns a,b,c, the query to > read the next value from t for given values a1, b1, c1 is > select * from t where > a >= a1 and > (a > a1 or b >= b1) and > (a > a1 or b > b1 or c > c1) > In about 95% of cases, the planner correctly selects the index t(a,b,c) > and uses it. I'm surprised it's that good. Why not do select * from t where a >= a1 and b >= b1 and c >= c1 order by a,b,c limit 1 offset 1; which has a much more obvious translation to an indexscan. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jul 28 00:52:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D1403D1CC46 for ; Wed, 28 Jul 2004 00:52:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22518-05 for ; Wed, 28 Jul 2004 03:52:29 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 9CE10D1DC5E for ; Wed, 28 Jul 2004 00:26:37 -0300 (ADT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by www.postgresql.com (Postfix) with ESMTP id F1D96CF6BB0 for ; Tue, 27 Jul 2004 12:30:22 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: best way to fetch next/prev record based on index X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 27 Jul 2004 11:29:53 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEFA@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index Thread-Index: AcRz7IL3jGrhTyIOT1uD4LF3TlNkGwAABwtw From: "Merlin Moncure" To: "Tom Lane" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/209 X-Sequence-Number: 7600 > > select * from t where > > a >=3D a1 and > > (a > a1 or b >=3D b1) and > > (a > a1 or b > b1 or c > c1) >=20 > > In about 95% of cases, the planner correctly selects the index t(a,b,c) > > and uses it. >=20 > I'm surprised it's that good. Why not do It is. In fact, it's so good, I mistakenly assumed it would get it right all the time. That led me directly to my current situation. =20 > select * from t where a >=3D a1 and b >=3D b1 and c >=3D c1 > order by a,b,c > limit 1 offset 1; Note: I left off the limit/order part of the query in my original example. My previous experience with offset was that it's not practical for this type of use. Query time degrades when offset gets large...it's basically n^2/2 for a scan of a table. If offset was pumped up to O(1) for any sized offset, the problem would be trivial.=20=20 Plus, your where clause does not guarantee results. Imagine: a b c 2 3 4 4 2 1 c !> c1 The only other way to rewrite the query is thus (pg has much more trouble with this form): select * from t where a > a1 or (a >=3D a1 and b > b1) or (a >=3D a1 and b >=3D b1 and c > c1) Merlin From pgsql-performance-owner@postgresql.org Wed Jul 28 00:35:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A9FC5D1B741 for ; Wed, 28 Jul 2004 00:34:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08758-07 for ; Wed, 28 Jul 2004 03:34:09 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id ABA66D1BB4C for ; Wed, 28 Jul 2004 00:23:15 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by www.postgresql.com (Postfix) with ESMTP id 7A09ECF6BEC for ; Tue, 27 Jul 2004 12:34:35 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6RFXJo2029488; Tue, 27 Jul 2004 11:33:20 -0400 (EDT) To: "Merlin Moncure" Cc: pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AEFA@Herge.rcsinc.local> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFA@Herge.rcsinc.local> Comments: In-reply-to "Merlin Moncure" message dated "Tue, 27 Jul 2004 11:29:53 -0400" Date: Tue, 27 Jul 2004 11:33:19 -0400 Message-ID: <29487.1090942399@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/200 X-Sequence-Number: 7591 "Merlin Moncure" writes: > Plus, your where clause does not guarantee results. No, but in combination with the ORDER BY it does. Please note also that the offset would *always* be one, so your gripe about it not scaling seems misguided to me. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jul 28 00:47:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6B0F7D1CA15 for ; Wed, 28 Jul 2004 00:47:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17678-09 for ; Wed, 28 Jul 2004 03:47:08 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 95AB9D1DA75 for ; Wed, 28 Jul 2004 00:25:41 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by www.postgresql.com (Postfix) with ESMTP id D5CE0CF4AEF for ; Tue, 27 Jul 2004 12:41:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6RFe73E029559; Tue, 27 Jul 2004 11:40:07 -0400 (EDT) To: "Merlin Moncure" Cc: pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index In-reply-to: <29487.1090942399@sss.pgh.pa.us> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFA@Herge.rcsinc.local> <29487.1090942399@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 27 Jul 2004 11:33:19 -0400" Date: Tue, 27 Jul 2004 11:40:07 -0400 Message-ID: <29558.1090942807@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/205 X-Sequence-Number: 7596 Tom Lane writes: > "Merlin Moncure" writes: >> Plus, your where clause does not guarantee results. > No, but in combination with the ORDER BY it does. Oh, wait, you're right --- I'm mis-visualizing the situation. Hmm, it sure seems like there ought to be an easy way to do this... regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jul 28 00:30:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4DD8FD1CA50 for ; Wed, 28 Jul 2004 00:28:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04936-03 for ; Wed, 28 Jul 2004 03:28:54 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 93650D1CBDC for ; Wed, 28 Jul 2004 00:22:13 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by www.postgresql.com (Postfix) with ESMTP id 46721CF6D7A for ; Tue, 27 Jul 2004 13:01:54 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6RG0cEG029728; Tue, 27 Jul 2004 12:00:39 -0400 (EDT) To: "Merlin Moncure" Cc: pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index In-reply-to: <29558.1090942807@sss.pgh.pa.us> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFA@Herge.rcsinc.local> <29487.1090942399@sss.pgh.pa.us> <29558.1090942807@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 27 Jul 2004 11:40:07 -0400" Date: Tue, 27 Jul 2004 12:00:38 -0400 Message-ID: <29727.1090944038@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/195 X-Sequence-Number: 7586 I said: > Oh, wait, you're right --- I'm mis-visualizing the situation. > Hmm, it sure seems like there ought to be an easy way to do this... The problem is that a multi-column index doesn't actually have the semantics you want. If you are willing to consider adding another index (or replacing the existing 3-column guy), how about create index ti on t((array[a,b,c])); select * from t where array[a,b,c] >= array[a1,b1,c1] order by array[a,b,c] limit 1 offset 1; This seems to do the right thing in 7.4 and later. It does require that all three columns have the same datatype though; you weren't specific about the data model ... regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jul 28 00:48:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D4A4AD1BBA3 for ; Wed, 28 Jul 2004 00:38:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12516-04 for ; Wed, 28 Jul 2004 03:38:05 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 9B912D1BCF1 for ; Wed, 28 Jul 2004 00:23:59 -0300 (ADT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by www.postgresql.com (Postfix) with ESMTP id 9FC03CF6D87 for ; Tue, 27 Jul 2004 13:02:38 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: best way to fetch next/prev record based on index X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 27 Jul 2004 12:02:17 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEFB@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index Thread-Index: AcRz8CwdPcY9SdnpQaKSnAze+UOYAQAAUJbw From: "Merlin Moncure" To: "Tom Lane" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/206 X-Sequence-Number: 7597 > Hmm, it sure seems like there ought to be an easy way to do this... Here is the only alternative that I see: create function column_stacker(text[] columns, text[] types) returns text [...] language 'C' immutable; the above function stacks the columns together in a single string for easy range indexing. create index on t_idx(array[t.a::text, t.b::text, t.c::text], array['int', 'int', 'char(2)']); This is a lot more complicated then it sounds but it can be done. The use of arrays is forced because of limitations in the way pg handles parameters (no big deal). The real disadvantage here is that it these indexes don't help with normal queries so every key gets two indexes :(. I'm just looking for a nudge in the right direction here...if the answer is GIST, I'll start researching that, etc. The ideal solution for me would be a smarter planner or a simple C function to get the next record out of the index (exposed through a UDF). Everything has to stay generic...the ultimate goal is an ISAM driver for pg. Merlin From pgsql-performance-owner@postgresql.org Wed Jul 28 00:30:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 66A49D1CA66 for ; Wed, 28 Jul 2004 00:29:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04626-06 for ; Wed, 28 Jul 2004 03:29:09 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id C577BD1B7A9 for ; Wed, 28 Jul 2004 00:22:15 -0300 (ADT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by www.postgresql.com (Postfix) with ESMTP id 479ECCF726F for ; Tue, 27 Jul 2004 14:15:46 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BpVVA-0004uG-00; Tue, 27 Jul 2004 13:12:32 -0400 To: "Merlin Moncure" Cc: Subject: Re: best way to fetch next/prev record based on index References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Jul 2004 13:12:31 -0400 Message-ID: <876589v0g0.fsf@stark.xeocode.com> Lines: 33 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/194 X-Sequence-Number: 7585 > Interestingly, it is possible to rewrite the above query by switching > and with or and >= with >. However when written that way, the planner > almost never gets it right. Well, note it's still not really getting it right even in your case. It's doing an index scan on a>=a1 but if you have lots of values in your table where a=a1 and b (a1,b1,c1) to work however it doesn't. It appears to mean a>a1 AND b>b1 AND c>c1 which isn't at all what you want. I imagine the standard dictates this meaning. > My problem is deceptively simple: how you read the next record from a > table based on a given set of values? In practice, this is difficult to > implement. If anybody can suggest a alternative/better way to this, I'm > all ears. I've done this a million times for simple integer keys, but I've never had to do it for multi-column keys. It seems it would be nice if some syntax similar to (a,b,c) > (a1,b1,c1) worked for this. -- greg From pgsql-performance-owner@postgresql.org Wed Jul 28 00:35:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AA499D1BACC for ; Wed, 28 Jul 2004 00:34:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09780-03 for ; Wed, 28 Jul 2004 03:34:32 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 2BCF5D1CDF7 for ; Wed, 28 Jul 2004 00:23:23 -0300 (ADT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by www.postgresql.com (Postfix) with ESMTP id 72CFBCF7343 for ; Tue, 27 Jul 2004 14:29:24 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: best way to fetch next/prev record based on index X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 27 Jul 2004 13:28:08 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEFD@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index Thread-Index: AcRz/Vw6NPQ03EuUTSqjwa1BBHuefQAARHpg From: "Merlin Moncure" To: Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/198 X-Sequence-Number: 7589 Greg wrote: > One thing that can help is to add ORDER BY a,b,c LIMIT 1 to your query. > That > will virtually guarantee that it uses an index scan, which will at least > avoid > making it scan all the records *after* finding the match. However it still > doesn't seem to make Postgres use an Index Cond to allow it to do an > instant > lookup. Yes, order by/limit was accidentally left of my original example. My problem is with the word 'virtually'. > do it for multi-column keys. It seems it would be nice if some syntax > similar > to (a,b,c) > (a1,b1,c1) worked for this. 'nice' would be an understatement... if the above syntax is not defined in the standard, I would humbly suggest, well, beg for it to work as you thought it did. That would be GREAT! ISMT it may be that that is in fact standard...(I don't have it, so I don't know). Merlin From pgsql-performance-owner@postgresql.org Wed Jul 28 00:36:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3E76ED1CAF8 for ; Wed, 28 Jul 2004 00:33:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07766-10 for ; Wed, 28 Jul 2004 03:33:12 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 49F79D1BABE for ; Wed, 28 Jul 2004 00:22:49 -0300 (ADT) Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net [67.119.5.202]) by www.postgresql.com (Postfix) with ESMTP id 6AF40CF7409 for ; Tue, 27 Jul 2004 14:38:26 -0300 (ADT) Received: (from andrew@localhost) by pillette.com (8.11.6/8.11.6) id i6RHbOP04615; Tue, 27 Jul 2004 10:37:24 -0700 Date: Tue, 27 Jul 2004 10:37:24 -0700 From: andrew@pillette.com Message-Id: <200407271737.i6RHbOP04615@pillette.com> Subject: Re: best way to fetch next/prev record based on index To: "Merlin Moncure" Cc: X-Originating-IP: 192.168.1.203 X-Mailer: Webmin 0.940 MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Archive-Number: 200407/202 X-Sequence-Number: 7593 "Merlin Moncure" wrote .. [snip] > select * from t where > a >= a1 and > (a > a1 or b >= b1) and > (a > a1 or b > b1 or c > c1) I don't see why this is guaranteed to work without an ORDER BY clause, even if TABLE t is clustered on the correct index. Am I missing something? I have two suggestions: (1) I think I would have written SELECT * FROM t WHERE (a >= a1 AND b>=b1 AND c>=c1) ORDER BY a,b,c LIMIT 1 OFFSET 1; using the way LIMIT cuts down on sort time (I've never tried it with both LIMIT and OFFSET, though; you could always use LIMIT 2 and skip a record client-side if that works better). (2) I've seen code where depending on the types and values of the fields, it was possible to construct a string from a, b, c by some sort of concatenation where the index now agreed with the lexicographic (dictionary) ordering on the string. Postgres could do that with a functional index, if your values can be used with this trick. From pgsql-performance-owner@postgresql.org Wed Jul 28 00:30:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1D08BD1BB1E for ; Wed, 28 Jul 2004 00:29:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04936-05 for ; Wed, 28 Jul 2004 03:29:18 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 10B85D1B7AB for ; Wed, 28 Jul 2004 00:22:17 -0300 (ADT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by www.postgresql.com (Postfix) with ESMTP id 486EDCF6835 for ; Tue, 27 Jul 2004 15:18:54 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: best way to fetch next/prev record based on index X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 27 Jul 2004 14:17:15 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEFE@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: best way to fetch next/prev record based on index Thread-Index: AcR0AGIV/yfapmVIRLq4Sa5qTrmk7wABOKqw From: "Merlin Moncure" To: Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/193 X-Sequence-Number: 7584 > SELECT * FROM t WHERE > (a >=3D a1 AND b>=3Db1 AND c>=3Dc1) ORDER BY a,b,c LIMIT 1 OFFSET 1; >=20 > using the way LIMIT cuts down on sort time (I've never tried it with both > LIMIT and OFFSET, though; you could always use LIMIT 2 and skip a record > client-side if that works better). Don't want to further clutter the list (answered this question several times already), but your query does not work. What I meant to write was: select * from t where a >=3D a1 and (a > a1 or b >=3D b1) and (a > a1 or b > b1 or c > c1) order by a, b, c limit 1 The problem with your query is it excludes all values of c >=3D c1 regardless of values of a and b. Merlin From pgsql-performance-owner@postgresql.org Wed Jul 28 00:50:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 21391D1CB0D for ; Wed, 28 Jul 2004 00:36:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10844-08 for ; Wed, 28 Jul 2004 03:36:27 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id D41B8D1D4E4 for ; Wed, 28 Jul 2004 00:23:39 -0300 (ADT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by www.postgresql.com (Postfix) with ESMTP id 8C423CF7B97 for ; Tue, 27 Jul 2004 15:41:59 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BpWqf-00056n-00; Tue, 27 Jul 2004 14:38:49 -0400 To: "Merlin Moncure" Cc: , Subject: Re: best way to fetch next/prev record based on index References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFD@Herge.rcsinc.local> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AEFD@Herge.rcsinc.local> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Jul 2004 14:38:48 -0400 Message-ID: <87wu0pthvr.fsf@stark.xeocode.com> Lines: 52 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/207 X-Sequence-Number: 7598 "Merlin Moncure" writes: > > do it for multi-column keys. It seems it would be nice if some syntax > > similar to (a,b,c) > (a1,b1,c1) worked for this. > > 'nice' would be an understatement... > > if the above syntax is not defined in the standard, I would humbly suggest, > well, beg for it to work as you thought it did. That would be GREAT! ISMT it > may be that that is in fact standard...(I don't have it, so I don't know). Hum. It would seem my intuition matches the SQL92 spec and Postgres gets this wrong. From page 208 (Section 8.2.7) of http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt 7) Let Rx and Ry be the two s of the and let RXi and RYi be the i-th s of Rx and Ry, respectively. "Rx Ry" is true, false, or unknown as follows: a) "x = Ry" is true if and only if RXi = RYi for all i. b) "x <> Ry" is true if and only if RXi <> RYi for some i. c) "x < Ry" is true if and only if RXi = RYi for all i < n and RXn < RYn for some n. d) "x > Ry" is true if and only if RXi = RYi for all i < n and RXn > RYn for some n. ... (This is A July 10, 1992 Proposed revision, I don't know how far it differs from the final. I imagine they mean "Rx" in all the places they use "x" alone) That fairly clearly specifies (a,b,c) < (a1,b1,c1) to work the way you want it to. Less-than-or-equal is then defined based on the above definition. Even if Postgres did this right I'm not sure that would solve your index woes. I imagine the first thing Postgres would do is rewrite it into regular scalar expressions. Ideally the optimizer should be capable of then deducing from the scalar expressions that an index scan would be useful. -- greg From pgsql-performance-owner@postgresql.org Wed Jul 28 00:26:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 42E3FD1DB81 for ; Wed, 28 Jul 2004 00:26:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01382-09 for ; Wed, 28 Jul 2004 03:26:03 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id E74AAD1CA61 for ; Wed, 28 Jul 2004 00:21:51 -0300 (ADT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by www.postgresql.com (Postfix) with ESMTP id 23FF0CF6E21 for ; Tue, 27 Jul 2004 16:21:09 -0300 (ADT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: best way to fetch next/prev record based on index X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 27 Jul 2004 15:20:49 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index Thread-Index: AcR0CWgy87OVE6nvS4ah4deWzH3kzwAAJYaQ From: "Merlin Moncure" To: Cc: , "Tom Lane" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/192 X-Sequence-Number: 7583 Greg Stark wrote: > > > do it for multi-column keys. It seems it would be nice if some syntax > > > similar to (a,b,c) > (a1,b1,c1) worked for this. > Hum. It would seem my intuition matches the SQL92 spec and Postgres gets > this > wrong. [...]=20 > Even if Postgres did this right I'm not sure that would solve your index > woes. > I imagine the first thing Postgres would do is rewrite it into regular > scalar > expressions. Ideally the optimizer should be capable of then deducing from > the > scalar expressions that an index scan would be useful. Wow. For once, the standard is my friend. Well, what has to be done? :) Does pg do it the way it does for a reason? From the outside it seems like the planner would have an easier job if it can make a field by field comparison.=20=20 Would a patch introducing the correct behavior (per the standard) be accepted? It seems pretty complicated (not to mention the planner issues). Merlin From pgsql-performance-owner@postgresql.org Thu Jul 29 12:32:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 94615D1BAF7 for ; Tue, 27 Jul 2004 23:14:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65776-09 for ; Wed, 28 Jul 2004 02:14:52 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id EB171D1B76B for ; Tue, 27 Jul 2004 23:14:19 -0300 (ADT) Received: from bache.ece.cmu.edu (BACHE.ECE.CMU.EDU [128.2.129.23]) by www.postgresql.com (Postfix) with ESMTP id 75749CF6F0F for ; Tue, 27 Jul 2004 16:38:35 -0300 (ADT) Received: from elysium.pdl.cmu.edu (ELYSIUM.PDL.CMU.EDU [128.2.134.97]) by bache.ece.cmu.edu (Postfix) with SMTP id 9DD1782 for ; Tue, 27 Jul 2004 15:38:05 -0400 (EDT) Date: Tue, 27 Jul 2004 15:38:05 -0400 (EDT) From: Stan Bielski X-Sender: bielski@elysium.pdl.cmu.edu To: pgsql-performance@postgresql.org Subject: Optimizer refuses to hash join Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/221 X-Sequence-Number: 7612 Hello, I having a great deal of difficulty getting postgres to do a hash join. Even if I disable nestloop and mergejoin in postgres.conf, the optimizer still refuses to select hash join. This behavior is killing my performance. Postgres version is 7.3.2 and relevant tables are vacuum analyzed. Here's an overview of what I'm doing: I have one table of network logs ordered by time values. The other table is a set of hosts (approximately 60) that are infected by a worm. I want to do this query on the dataset: standb=# explain SELECT count (allflow_tv_sobig.tv_s) FROM allflow_tv_sobig, blaster_set WHERE allflow_tv_sobig.src = blaster_set.label AND allflow_tv_sobig.tv_s >= 1060101118::bigint and allflow_tv_sobig.tv_s < 1060187518::bigint; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=185785.06..185785.06 rows=1 width=32) -> Merge Join (cost=174939.71..184986.38 rows=319472 width=32) Merge Cond: ("outer".label = "inner".src) -> Index Scan using blaster_set_x on blaster_set (cost=0.00..3.67 rows=66 width=12) -> Sort (cost=174939.71..178073.92 rows=1253684 width=20) Sort Key: allflow_tv_sobig.src -> Index Scan using allflow_tv_sobig_x on allflow_tv_sobig (cost=0.00..47955.63 rows=1253684 width=20) Index Cond: ((tv_s >= 1060101118::bigint) AND (tv_s < 1060187518::bigint)) (8 rows) Basically I just want to use the smaller table as a filtering mechanism so that I only get resulted for hosts in that table. Rather than do the sensible thing, which is scan the list of infected hosts, then scan the traffic table and ignore entries that aren't in the first list, the optimizer insists on SORTING the table of network traffic according to source address. Considering that this table is very large, these queries are taking forever. Doing it in a nested loop, while it doesn't require sorting, still takes a very long time as well. Is there anyway that I can force the optimizer to do this the right way, aside from adding each IP manually to a disgustingly bloated 'where' clause? Thanks, -S From pgsql-performance-owner@postgresql.org Wed Jul 28 01:01:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EFEEAD1B258 for ; Wed, 28 Jul 2004 01:01:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28308-05 for ; Wed, 28 Jul 2004 04:00:44 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id D7688D1CBAA for ; Wed, 28 Jul 2004 00:45:35 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 47EB5355E6; Tue, 27 Jul 2004 20:45:34 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 4652A355E4; Tue, 27 Jul 2004 20:45:34 -0700 (PDT) Date: Tue, 27 Jul 2004 20:45:34 -0700 (PDT) From: Stephan Szabo To: Merlin Moncure Cc: gsstark@mit.edu, pgsql-performance@postgresql.org, Tom Lane Subject: Re: best way to fetch next/prev record based on index In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> Message-ID: <20040727204057.S28969@megazone.bigpanda.com> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM X-Spam-Level: * X-Archive-Number: 200407/210 X-Sequence-Number: 7601 On Tue, 27 Jul 2004, Merlin Moncure wrote: > Greg Stark wrote: > > > > do it for multi-column keys. It seems it would be nice if some > syntax > > > > similar to (a,b,c) > (a1,b1,c1) worked for this. > > Hum. It would seem my intuition matches the SQL92 spec and Postgres > gets > > this > > wrong. > [...] > > Even if Postgres did this right I'm not sure that would solve your > index > > woes. > > I imagine the first thing Postgres would do is rewrite it into regular > > scalar > > expressions. Ideally the optimizer should be capable of then deducing > from > > the > > scalar expressions that an index scan would be useful. > > Wow. For once, the standard is my friend. Well, what has to be done? > :) Does pg do it the way it does for a reason? From the outside it > seems like the planner would have an easier job if it can make a field > by field comparison. > > Would a patch introducing the correct behavior (per the standard) be > accepted? It seems pretty complicated (not to mention the planner > issues). Given the comment on make_row_op, /* * XXX it's really wrong to generate a simple AND combination for < <= * > >=. We probably need to invent a new runtime node type to handle * those correctly. For the moment, though, keep on doing this ... */ I'd expect it'd be accepted. From pgsql-performance-owner@postgresql.org Wed Jul 28 02:53:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 64ADED1B74A for ; Wed, 28 Jul 2004 02:53:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74394-02 for ; Wed, 28 Jul 2004 05:53:30 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id C6FA5D1B39A for ; Wed, 28 Jul 2004 02:53:27 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BphNN-0008Lq-00; Wed, 28 Jul 2004 01:53:17 -0400 To: Stephan Szabo Cc: Merlin Moncure , gsstark@mit.edu, pgsql-performance@postgresql.org, Tom Lane Subject: Re: best way to fetch next/prev record based on index References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> <20040727204057.S28969@megazone.bigpanda.com> In-Reply-To: <20040727204057.S28969@megazone.bigpanda.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 28 Jul 2004 01:53:17 -0400 Message-ID: <87oem0u182.fsf@stark.xeocode.com> Lines: 54 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/211 X-Sequence-Number: 7602 Stephan Szabo writes: > Given the comment on make_row_op, > /* > * XXX it's really wrong to generate a simple AND combination for < <= > * > >=. We probably need to invent a new runtime node type to handle > * those correctly. For the moment, though, keep on doing this ... > */ > I'd expect it'd be accepted. Hm, this code is new. As of version 1.169 2004/04/18 it only accepted "=" and "<>" operators: /* Combining operators other than =/<> is dubious... */ if (row_length != 1 && strcmp(opname, "=") != 0 && strcmp(opname, "<>") != 0) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("row comparison cannot use operator %s", opname))); I think perhaps it's a bad idea to be introducing support for standard syntax until we can support the correct semantics. It will only mislead people and create backwards-compatibility headaches when we fix it to work properly. Removing <,<=,>,>= would be trivial. Patch (untested): --- parse_expr.c.~1.174.~ 2004-07-28 01:01:12.000000000 -0400 +++ parse_expr.c 2004-07-28 01:52:29.000000000 -0400 @@ -1695,11 +1695,7 @@ */ oprname = strVal(llast(opname)); - if ((strcmp(oprname, "=") == 0) || - (strcmp(oprname, "<") == 0) || - (strcmp(oprname, "<=") == 0) || - (strcmp(oprname, ">") == 0) || - (strcmp(oprname, ">=") == 0)) + if (strcmp(oprname, "=") == 0) { boolop = AND_EXPR; } Fixing it to write out complex boolean expressions wouldn't be too hard, but I'm not clear it would be worth it, since I suspect the end result would be as the comment indicates, to introduce a new runtime node. -- greg From pgsql-performance-owner@postgresql.org Wed Jul 28 04:15:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B71F7D1B341 for ; Wed, 28 Jul 2004 04:15:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04102-06 for ; Wed, 28 Jul 2004 07:14:57 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 439C2D1B540 for ; Wed, 28 Jul 2004 04:14:54 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BpieI-0002su-00; Wed, 28 Jul 2004 03:14:50 -0400 To: Greg Stark Cc: Stephan Szabo , Merlin Moncure , gsstark@mit.edu, pgsql-performance@postgresql.org, Tom Lane Subject: Re: best way to fetch next/prev record based on index References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> <20040727204057.S28969@megazone.bigpanda.com> <87oem0u182.fsf@stark.xeocode.com> In-Reply-To: <87oem0u182.fsf@stark.xeocode.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 28 Jul 2004 03:14:49 -0400 Message-ID: <87isc8txg6.fsf@stark.xeocode.com> Lines: 218 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/212 X-Sequence-Number: 7603 Greg Stark writes: > Fixing it to write out complex boolean expressions wouldn't be too hard, but > I'm not clear it would be worth it, since I suspect the end result would be as > the comment indicates, to introduce a new runtime node. Just to prove that it isn't really all that hard, I took a stab at doing this. This is basically only my second attempt to write even trivial bits of server backend code so I certainly don't suggest anyone try using this code. In fact it doesn't quite compile, because I have a bit of confusion between the char *oprname and List *opname variables. Now I could clear that up, but I'm missing one piece of the puzzle. To make it work I do need a way to construct a List *opname from ">" or "=" and I don't know how to do that. I think that's all I'm missing, but perhaps in the morning I'll look at this code and wonder "what was I thinking?!" This approach won't get the optimizer to actually use an index for these comparisons, but it will fix the semantics to match the spec. Later we can either improve the optimizer to detect expressions like this (which I think would be cooler since some users may write them by hand and not use the row-expression approach, but I don't see how to do it), or introduce a new run-time node and have the optimizer handle it. But at least we won't have to worry about backwards-compatibility issues with the semantics changing. Oh, I tried to stick to the style, but sometimes I couldn't help myself. I suppose I would have to fix up the style the rest of the way if I got it working and you wanted a patch to apply. /* * Transform a "row op row" construct */ static Node * make_row_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree) { Node *result = NULL; RowExpr *lrow, *rrow; List *largs, *rargs; char *oprname; /* Inputs are untransformed RowExprs */ lrow = (RowExpr *) transformExpr(pstate, ltree); rrow = (RowExpr *) transformExpr(pstate, rtree); Assert(IsA(lrow, RowExpr)); Assert(IsA(rrow, RowExpr)); largs = lrow->args; rargs = rrow->args; if (list_length(largs) != list_length(rargs)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("unequal number of entries in row expression"))); oprname = strVal(llast(opname)); if (strcmp(oprname, "=") == 0) { result = make_row_op_simple(pstate, "=", largs, rargs); } else if (strcmp(oprname, "<>") == 0) { result = make_row_op_simple(pstate, "<>", largs, rargs); } else if ((strcmp(oprname, "<") == 0) || (strcmp(oprname, ">") == 0)) { result = make_row_op_complex(pstate, oprname, largs, rargs); } /* alternatively these last two could just create negated < and > * expressions. Which is better depends on whether the extra clause * confuses the optimizer more or less than having to push the NOTs down */ else if (strcmp(oprname, ">=") == 0) { Node *branch = make_row_op_simple(pstate, "=", largs, rargs); result = make_row_op_complex(pstate, ">", largs, rargs); result = (Node *) makeBoolExpr(OR_EXPR, list_make2(result, branch)); } else if (strcmp(oprname, "<=") == 0) { Node *branch = make_row_op_simple(pstate, "=", largs, rargs); result = make_row_op_complex(pstate, "<", largs, rargs); result = (Node *) makeBoolExpr(OR_EXPR, list_make2(result, branch)); } else { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("operator %s is not supported for row expressions", oprname))); } return result; } /* * Handle something like * (A,B,C) = (X,Y,Z) * By constructing * (A=X) AND (B=Y) AND (C=Z) * */ static Node * make_row_op_simple(ParseState *pstate, char *oprname, List *largs, List *rargs) { ListCell *l, *r; BoolExprType boolop; Node *result; boolop = strcmp(oprname, "<>")==0 ? OR_EXPR : AND_EXPR; forboth(l, largs, r, rargs) { Node *larg = (Node *) lfirst(l); Node *rarg = (Node *) lfirst(r); Node *cmp; cmp = (Node *) make_op(pstate, opname, larg, rarg); cmp = coerce_to_boolean(pstate, cmp, "row comparison"); if (result == NULL) result = cmp; else result = (Node *) makeBoolExpr(boolop, list_make2(result, cmp)); } if (result == NULL) { /* zero-length rows? Generate constant TRUE or FALSE */ if (boolop == AND_EXPR) result = makeBoolConst(true, false); else result = makeBoolConst(false, false); } return result; } /* * Handles something like: * (A,B,C) > (X,Y,Z) * * By constructing something like: * ( ( A > X) OR (A=X AND B>Y) OR (A=X AND B=Y AND C>Z) ) * */ static Node * make_row_op_complex(ParseState *pstate, char *oprname, List *largs, List *rargs) { ListCell *l, *outer_l, *r, *outer_r; Node *result; forboth(outer_l, largs, outer_r, rargs) { Node *outer_larg = (Node *) lfirst(outer_l); Node *outer_rarg = (Node *) lfirst(outer_r); Node *branch = NULL; Node *cmp; /* all leading elements have to be equal */ forboth(l, largs, r, rargs) { Node *larg = (Node *) lfirst(l); Node *rarg = (Node *) lfirst(r); Node *cmp; if (larg == outer_larg) { break; } cmp = (Node *) make_op(pstate, "=", larg, rarg); cmp = coerce_to_boolean(pstate, cmp, "row comparison"); if (branch == NULL) branch = cmp; else branch = (Node *) makeBoolExpr(AND_EXPR, list_make2(branch, cmp)); } /* trailing element has to be strictly greater or less than */ cmp = (Node *) make_op(pstate, oprname, outer_larg, outer_rarg); cmp = coerce_to_boolean(pstate, cmp, "row comparison"); branch = branch==NULL ? cmp : (Node *) makeBoolExpr(AND_EXPR, list_make2(branch, cmp)); result = result==NULL ? branch : (Node *) makeBoolExpr(OR_EXPR, list_make2(result, branch)); } if (result == NULL) { /* zero-length rows? Generate constant FALSE */ result = makeBoolConst(true, false); } return result; } -- greg From pgsql-performance-owner@postgresql.org Wed Jul 28 09:48:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9BC40D1B56B for ; Wed, 28 Jul 2004 09:48:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37299-01 for ; Wed, 28 Jul 2004 12:47:39 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 264ABD1B744 for ; Wed, 28 Jul 2004 09:47:34 -0300 (ADT) Subject: Re: best way to fetch next/prev record based on index MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Wed, 28 Jul 2004 08:47:32 -0400 Content-class: urn:content-classes:message Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF03@Herge.rcsinc.local> X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index thread-index: AcR0cpdx8jBJYmBaSVWuZZ7Jq6p4IAAJuKGA From: "Merlin Moncure" To: Cc: "Stephan Szabo" , "Merlin Moncure" , , , "Tom Lane" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/213 X-Sequence-Number: 7604 > Greg Stark writes: > This approach won't get the optimizer to actually use an index for these > comparisons, but it will fix the semantics to match the spec. Later we can > either improve the optimizer to detect expressions like this (which I > think > would be cooler since some users may write them by hand and not use the > row-expression approach, but I don't see how to do it), or introduce a new > run-time node and have the optimizer handle it. But at least we won't have > to > worry about backwards-compatibility issues with the semantics changing. >=20 > Oh, I tried to stick to the style, but sometimes I couldn't help myself. I > suppose I would have to fix up the style the rest of the way if I got it > working and you wanted a patch to apply. Regarding the <=3D and >=3D operators: can you apply them in the complex pass? If you can, this might be more efficient. > /* > * Handles something like: > * (A,B,C) > (X,Y,Z) > * > * By constructing something like: > * ( ( A > X) OR (A=3DX AND B>Y) OR (A=3DX AND B=3DY AND C>Z) ) > * ^ > */ | the last comparison of the last major clause (or the only comparison for a single field row construct) is a special case. In > cases use >, in >=3D cases use >=3D, etc.; this is logical equivalent to doing or of simple =3D intersected with complex >.=20=20 Is this step of the transformation visible to the optimizer/planner? For purely selfish reasons, it would be really nice if a field by field row construction could get a fast path to the index if the fields match the index fields. Merlin From pgsql-performance-owner@postgresql.org Wed Jul 28 11:07:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E668CD1B37E for ; Wed, 28 Jul 2004 11:07:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69609-09 for ; Wed, 28 Jul 2004 14:07:09 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9D3B6D1B1E0 for ; Wed, 28 Jul 2004 11:07:04 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6SE72aT021450; Wed, 28 Jul 2004 10:07:02 -0400 (EDT) To: Greg Stark Cc: Stephan Szabo , Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index In-reply-to: <87oem0u182.fsf@stark.xeocode.com> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> <20040727204057.S28969@megazone.bigpanda.com> <87oem0u182.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "28 Jul 2004 01:53:17 -0400" Date: Wed, 28 Jul 2004 10:07:01 -0400 Message-ID: <21449.1091023621@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/214 X-Sequence-Number: 7605 Greg Stark writes: > Removing <,<=,>,>= would be trivial. ... and not backwards-compatible. If we did that then cases involving unlabeled row expressions would no longer work as they did in prior releases. For example select (1,2,3) < (4,5,6); is accepted by all releases back to 7.0, and probably much further (but 7.0 is the oldest I have handy to test). The only reason the code in parse_expr.c appears new is that the functionality used to be in gram.y. I'd like to see this fixed to comply with the spec, but given the lack of complaints about the existing behavior over so many years, ripping it out meanwhile doesn't seem appropriate. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Jul 28 12:38:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A506DD1B252 for ; Wed, 28 Jul 2004 12:38:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11906-05 for ; Wed, 28 Jul 2004 15:38:07 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id CA695D1B37C for ; Wed, 28 Jul 2004 12:38:02 -0300 (ADT) Subject: Re: best way to fetch next/prev record based on index MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Wed, 28 Jul 2004 11:38:00 -0400 Content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF05@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index thread-index: AcR0rC1IMv1G/AnGQh2sQMnyrB+ZfAAASprw From: "Merlin Moncure" To: "Tom Lane" Cc: "Greg Stark" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/215 X-Sequence-Number: 7606 > Greg Stark writes: > > Removing <,<=3D,>,>=3D would be trivial. >=20 > ... and not backwards-compatible. If we did that then cases involving > unlabeled row expressions would no longer work as they did in prior > releases. For example >=20 > select (1,2,3) < (4,5,6); >=20 > is accepted by all releases back to 7.0, and probably much further (but > 7.0 is the oldest I have handy to test). The only reason the code in > parse_expr.c appears new is that the functionality used to be in gram.y. >=20 > I'd like to see this fixed to comply with the spec, but given the lack > of complaints about the existing behavior over so many years, ripping > it out meanwhile doesn't seem appropriate. Just to clarify: I think Greg is arguing to bring pg to SQL 92 spec and not remove anything. ISTM the SQL standard was designed with exactly my problem in mind: how to get the next key in a table.=20 IMHO, relying=20 on select (1,2,3) < (4,5,6);=20 to give a result which is neither standard nor documented seems to be bad style. The current methodology could cause pg to give incorrect results in TPC benchmarks...not good. Also, it's trivial to rewrite that comparison with the old behavior using 'and'. OTOH, it is not trivial to rewrite the comparison to do it the correct way...it's kind of an SQL 'trick question'. Most likely, a very small minority of pg users are even away of the above syntax anyways. To be fair, I'm a big fan of deprecating features for at least one release for compatibility reasons. It's no big deal to me, because I'm already writing the queries out the long way anyways. My interests are in the optimizer. If there is a way to enhance it so that it multi-column comparisons in a logical way, that would be great. Is this theoretically possible (probable)? Merlin From pgsql-performance-owner@postgresql.org Wed Jul 28 13:01:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B3C80D1B229 for ; Wed, 28 Jul 2004 13:01:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20443-08 for ; Wed, 28 Jul 2004 16:01:22 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id D82CBD1B484 for ; Wed, 28 Jul 2004 13:00:37 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1Bpqqw-0004r5-00; Wed, 28 Jul 2004 12:00:26 -0400 To: Tom Lane Cc: Greg Stark , Stephan Szabo , Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> <20040727204057.S28969@megazone.bigpanda.com> <87oem0u182.fsf@stark.xeocode.com> <21449.1091023621@sss.pgh.pa.us> In-Reply-To: <21449.1091023621@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 28 Jul 2004 12:00:25 -0400 Message-ID: <87y8l4rujq.fsf@stark.xeocode.com> Lines: 26 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/216 X-Sequence-Number: 7607 Tom Lane writes: > The only reason the code in parse_expr.c appears new is that the > functionality used to be in gram.y. Ah, that was what I was missing. Though it's odd since it seems there was code in parse_expr.c to handle the "=" case specially. > I'd like to see this fixed to comply with the spec, but given the lack > of complaints about the existing behavior over so many years, ripping > it out meanwhile doesn't seem appropriate. I tried my hand at this last night and think I did an ok first pass. But I'm missing one piece of the puzzle to get it to compile. What do I need to know to be able to construct a List* suitable for passing as the second arg to make_op() knowing only that I want to create a List* to represent "=" or "<" or so on? I also had another question I didn't ask in the other email. In the midst of a forboth() loop, how would I tell if I'm at the last element of the lists? Would lnext(l)==NULL do it? -- greg From pgsql-performance-owner@postgresql.org Wed Jul 28 13:54:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C528BD1B376 for ; Wed, 28 Jul 2004 13:54:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47655-03 for ; Wed, 28 Jul 2004 16:53:41 +0000 (GMT) Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 54C3DD1B495 for ; Wed, 28 Jul 2004 13:53:02 -0300 (ADT) Received: (qmail 8798 invoked from network); 28 Jul 2004 18:53:02 +0200 Received: from unknown (HELO musicbox) (192.168.0.2) by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; 28 Jul 2004 18:53:02 +0200 Date: Wed, 28 Jul 2004 18:53:12 +0200 To: pgsql-performance@postgresql.org Subject: Join performance References: <6EE64EF3AB31D5448D0007DD34EEB34101AF05@Herge.rcsinc.local> From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AF05@Herge.rcsinc.local> User-Agent: Opera M2/7.50 (Linux, build 673) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/217 X-Sequence-Number: 7608 Hello, I'm building a kind of messaging/forum application with postgresql. There are users which will send each others messages, send messages to forums, etc. I would like to put the messages in folders, so each user has several folders (inbox, sent...), and forums are also folders. A message will appear in the sender's "sent" folder and the receiver's inbox, or receiving forum folder. There are two ways I can do this : - either by placing two folder fields (outbox_folder_id and receiving_folder_id) in the messages table, which can both point to a folder or be null. When a user sends a message to another user/folder, these fields are set appropriately. - or by having a messages table, and a link table linking messages to folders. I have built a test database with about 20000 messages in 2000 folders (10 messages per folder). Finding all the messages in a folder takes more than 600 times longer with the link table than with the single table approach (66 ms vs. 0.12 ms). Is this normal ? I have checked explain analyze and it uses indexes in all cases. The query plans look right to me. From pgsql-performance-owner@postgresql.org Wed Jul 28 13:56:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 11082D1B374 for ; Wed, 28 Jul 2004 13:56:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47071-07 for ; Wed, 28 Jul 2004 16:56:25 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D921ED1B1E0 for ; Wed, 28 Jul 2004 13:56:24 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6SGuLrS023585; Wed, 28 Jul 2004 12:56:21 -0400 (EDT) To: Greg Stark Cc: Stephan Szabo , Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index In-reply-to: <87y8l4rujq.fsf@stark.xeocode.com> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> <20040727204057.S28969@megazone.bigpanda.com> <87oem0u182.fsf@stark.xeocode.com> <21449.1091023621@sss.pgh.pa.us> <87y8l4rujq.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "28 Jul 2004 12:00:25 -0400" Date: Wed, 28 Jul 2004 12:56:21 -0400 Message-ID: <23584.1091033781@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/218 X-Sequence-Number: 7609 Greg Stark writes: > Tom Lane writes: >> The only reason the code in parse_expr.c appears new is that the >> functionality used to be in gram.y. > Ah, that was what I was missing. Though it's odd since it seems there was code > in parse_expr.c to handle the "=" case specially. IIRC, the case involving a subselect, eg ... WHERE (1,2) = ANY (SELECT a, b FROM foo) ... has always been handled in parse_expr.c, but cases involving simple rows were previously expanded in gram.y. One of the reasons I moved the logic over to parse_expr.c was the thought that it would be easier to do it right in parse_expr.c --- gram.y would not be allowed to look up related operators, which seems necessary to handle the construct per spec. > I tried my hand at this last night and think I did an ok first pass. The main issue in my mind is whether to invent a separate node type for row comparisons. This is probably a good idea for a number of reasons, the most obvious being that there's no way to avoid multiple evaluations of the subexpressions if you try to expand it into simple comparisons. Also it seems likely that the planner would find it easier to recognize the relationship to a multicolumn index than if the thing is expanded. (But teaching the planner and the index mechanisms themselves about this is going to be a major project in any case.) One thing I did not like about your first pass is that it makes unsupportable assumptions about there being a semantic relationship between operators named, say, '<' and '<='. Postgres used to have such bogosity in a number of places but we've managed to get rid of most of it. (Offhand I think the only remaining hard-wired assumption about operators of particular names having particular semantics is that the foreign key mechanisms assume '=' must be the right operator to compare keys with. Eventually we need to get rid of that too.) IMHO the right way to do this is to look up a suitable btree operator class and use the appropriate member operators of that class. (In a separate-node-type implementation, we'd probably ignore the operators as such altogether, and just call the btree comparison function of the opclass.) It's not entirely clear to me how to select the opclass when the initially given inputs are of different types, though. In the present code we leave it to oper() to do the right thing, including possibly coercing the inputs to matching types. Possibly we should still apply oper(), but then insist that the selected operator appear as a btree opclass member, comparable to the way we handle sort operators now. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jul 29 12:48:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0D11CD1B174 for ; Wed, 28 Jul 2004 19:20:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92007-06 for ; Wed, 28 Jul 2004 22:20:06 +0000 (GMT) Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) by svr1.postgresql.org (Postfix) with ESMTP id B29A8D1B170 for ; Wed, 28 Jul 2004 19:20:00 -0300 (ADT) Received: by ganymede.hub.org (Postfix, from userid 1000) id 68A8D33DCE; Wed, 28 Jul 2004 19:20:02 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 5FCBB33CA0 for ; Wed, 28 Jul 2004 19:20:02 -0300 (ADT) X-Return-Path: X-Received: from localhost ([unix socket]) by ganymede.hub.org (Cyrus v2.2.6) with LMTPA; Wed, 28 Jul 2004 17:28:05 -0300 X-Sieve: CMU Sieve 2.2 X-Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 5878E36D57 for ; Wed, 28 Jul 2004 17:25:34 -0300 (ADT) X-Received: from mail.postgresql.org [200.46.204.71] by localhost with IMAP (fetchmail-6.2.5) for scrappy@localhost (single-drop); Wed, 28 Jul 2004 17:25:34 -0300 (ADT) X-Received: from svr1.postgresql.org ([unix socket]) by svr1.postgresql.org (Cyrus v2.2.6) with LMTPA; Wed, 28 Jul 2004 17:21:39 -0300 X-Sieve: CMU Sieve 2.2 X-Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 63FA0D1B76B for ; Wed, 28 Jul 2004 17:21:39 -0300 (ADT) X-Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39213-09 for ; Wed, 28 Jul 2004 20:21:40 +0000 (GMT) X-Received: from postgresql.org (svr1.postgresql.org [200.46.204.71]) by svr1.postgresql.org (Postfix) with ESMTP id ECB78D1B735 for ; Wed, 28 Jul 2004 17:19:49 -0300 (ADT) X-Original-To: pgsql-performance-postgresql.org-owner@localhost.postgresql.org X-Delivered-To: pgsql-performance-postgresql.org-owner@localhost.postgresql.org X-Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E1105D1B743 for ; Wed, 28 Jul 2004 17:19:46 -0300 (ADT) X-Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39213-06 for ; Wed, 28 Jul 2004 20:19:26 +0000 (GMT) X-Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id DB2F1D1B745 for ; Wed, 28 Jul 2004 17:17:36 -0300 (ADT) X-Received: from asdc003.abovesecurite.lan (unknown [206.162.148.235]) by www.postgresql.com (Postfix) with ESMTP id B0404CF5765 for ; Wed, 28 Jul 2004 14:08:26 -0300 (ADT) X-Received: from develavoie ([206.162.148.230]) by asdc003.abovesecurite.lan over TLS secured channel with Microsoft SMTPSVC(6.0.3790.0); Wed, 28 Jul 2004 13:13:08 -0400 From: "Stephane Tessier" To: Subject: my boss want to migrate to ORACLE Date: Wed, 28 Jul 2004 13:08:06 -0400 Message-ID: <000001c474c5$73e2cfc0$4e00020a@develavoie> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01C474A3.ECD3A0C0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Importance: Normal X-OriginalArrivalTime: 28 Jul 2004 17:13:08.0781 (UTC) FILETIME=[277915D0:01C474C6] X-Virus-Scanned: by amavisd-new at hub.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-DCC: : X-Spam-Pyzor: ReSent-Date: Wed, 28 Jul 2004 19:19:56 -0300 (ADT) Resent-From: "Marc G. Fournier" Resent-To: pgsql-performance@postgresql.org ReSent-Subject: my boss want to migrate to ORACLE ReSent-Message-ID: <20040728191956.Q792@ganymede.hub.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=HTML_30_40, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200407/222 X-Sequence-Number: 7613 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C474A3.ECD3A0C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi everyone, somebody can help me??????? my boss want to migrate to ORACLE................ we have a BIG problem of performance,it's slow.... we use postgres 7.3 for php security application with approximately 4 millions of insertion by day and 4 millions of delete and update and archive db with 40 millions of archived stuff... we have 10 databases for our clients and a centralized database for the general stuff. database specs: double XEON 2.4 on DELL PowerEdge2650 2 gigs of RAM 5 SCSI Drive RAID 5 15rpm tasks: 4 millions of transactions by day 160 open connection 24 hours by day 7 days by week pg_autovacuum running 24/7 reindex on midnight postgresql.conf: tcpip_socket = true #ssl = false max_connections = 256 #superuser_reserved_connections = 2 #port = 5432 #hostname_lookup = false #show_source_port = false #unix_socket_directory = '' #unix_socket_group = '' #unix_socket_permissions = 0777 # octal #virtual_host = '' #krb_server_keyfile = '' # # Shared Memory Size # #shared_buffers = 256 # min max_connections*2 or 16, 8KB each #shared_buffers = 196000 # min max_connections*2 or 16, 8KB each shared_buffers = 128000 # min max_connections*2 or 16, 8KB each #max_fsm_relations = 1000 # min 10, fsm is free space map, ~40 bytes max_fsm_pages = 1000000 # min 1000, fsm is free space map, ~6 bytes #max_locks_per_transaction = 64 # min 10 #wal_buffers = 8 # min 4, typically 8KB each # # Non-shared Memory Sizes # #sort_mem = 32168 # min 64, size in KB #vacuum_mem = 8192 # min 1024, size in KB vacuum_mem = 65536 # min 1024, size in KB # # Write-ahead log (WAL) # #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each #checkpoint_timeout = 300 # range 30-3600, in seconds # #commit_delay = 0 # range 0-100000, in microseconds #commit_siblings = 5 # range 1-1000 # #fsync = true #wal_sync_method = fsync # the default varies across platforms: # # fsync, fdatasync, open_sync, or open_datasync #wal_debug = 0 # range 0-16 # # Optimizer Parameters # #enable_seqscan = true #enable_indexscan = true #enable_tidscan = true #enable_sort = true #enable_nestloop = true #enable_mergejoin = true #enable_hashjoin = true #effective_cache_size = 1000 # typically 8KB each effective_cache_size = 196608 # typically 8KB each #random_page_cost = 4 # units are one sequential page fetch cost #cpu_tuple_cost = 0.01 # (same) #cpu_index_tuple_cost = 0.001 # (same) #cpu_operator_cost = 0.0025 # (same) #default_statistics_target = 10 # range 1-1000 # # GEQO Optimizer Parameters # #geqo = true #geqo_selection_bias = 2.0 # range 1.5-2.0 #geqo_threshold = 11 #geqo_pool_size = 0 # default based on tables in statement, # range 128-1024 #geqo_effort = 1 #geqo_generations = 0 #geqo_random_seed = -1 # auto-compute seed # # Message display # server_min_messages =notice # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, log, fatal, # panic client_min_messages =notice # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # log, info, notice, warning, error #silent_mode = false #log_connections =true #log_pid =true #log_statement =true #log_duration =true #log_timestamp =true log_min_error_statement =error # Values in order of increasing severity: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, panic(off) #debug_print_parse = false #debug_print_rewritten = false #debug_print_plan = false #debug_pretty_print = false #explain_pretty_print = true # requires USE_ASSERT_CHECKING #debug_assertions = true # # Syslog # syslog = 0 # range 0-2 syslog_facility = 'LOCAL0' syslog_ident = 'postgres' # # Statistics # show_parser_stats = false show_planner_stats =false show_executor_stats = false show_statement_stats =false # requires BTREE_BUILD_STATS #show_btree_build_stats = false # # Access statistics collection # stats_start_collector = true stats_reset_on_server_start = false stats_command_string = true stats_row_level = true stats_block_level = true # # Lock Tracing # #trace_notify = false # requires LOCK_DEBUG #trace_locks = false #trace_userlocks = false #trace_lwlocks = false #debug_deadlocks = false #trace_lock_oidmin = 16384 #trace_lock_table = 0 # # Misc # #autocommit = true #dynamic_library_path = '$libdir' #search_path = '$user,public' #datestyle = 'iso, us' #timezone = unknown # actually, defaults to TZ environment setting #australian_timezones = false #client_encoding = sql_ascii # actually, defaults to database encoding #authentication_timeout = 60 # 1-600, in seconds #deadlock_timeout = 1000 # in milliseconds #default_transaction_isolation = 'read committed' #max_expr_depth = 10000 # min 10 #max_files_per_process = 1000 # min 25 #password_encryption = true #sql_inheritance = true #transform_null_equals = false #statement_timeout = 0 # 0 is disabled, in milliseconds #db_user_namespace = false **************************************************************************** *************************************************************************** Stephane Tessier, CISSP Development Team Leader 450-430-8166 X:206 ------=_NextPart_000_0001_01C474A3.ECD3A0C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi=20 everyone,
 
somebody = can help=20 me??????? my boss want to migrate to ORACLE................
 
we have a= BIG=20 problem of performance,it's slow....
we use po= stgres 7.3=20 for php security application with approximately 4 millions of insertio= n by=20 day and 4 millions of delete and update
and archi= ve db with=20 40 millions of archived stuff...
 
we have 1= 0 databases=20 for our clients and a centralized database for the general=20 stuff.
 
database= =20 specs:
 
double XE= ON 2.4 on=20 DELL PowerEdge2650
2 gigs of= =20 RAM
5 SCSI Dr= ive RAID 5=20 15rpm
 
tasks:
 
4 million= s of=20 transactions by day
160 open = connection=20 24 hours by day 7 days by week
pg_autova= cuum=20 running 24/7
reindex o= n=20 midnight
 
postgresql.conf:
 
tcpip_soc= ket =3D=20 true
#ssl =3D false
 
max_conne= ctions =3D=20 256
#superuser_reserved_connections =3D 2
 
#port =3D= 5432=20
#hostname_lookup =3D false
#show_source_port =3D false
=
 
#unix_socket_directory =3D ''
#unix_socket_gr= oup =3D=20 ''
#unix_socket_permissions =3D 0777 # octal
 
#virtual_= host =3D=20 ''
 
#krb_serv= er_keyfile=20 =3D ''
 

#
#       Shared Memory=20 Size
#
#shared_buffers =3D=20 256           # min=20 max_connections*2 or 16, 8KB each
#shared_buffers =3D=20 196000           &nb= sp;   =20 # min max_connections*2 or 16, 8KB each
shared_buffers =3D=20 128000         # min max_connection= s*2=20 or 16, 8KB each
#max_fsm_relations =3D 1000     = ; =20 # min 10, fsm is free space map, ~40 bytes
max_fsm_pages =3D=20 1000000         # min 1000, fsm is = free=20 space map, ~6 bytes
#max_locks_per_transaction =3D 64 # min 10
#wal_b= uffers=20 =3D=20 8            &n= bsp;  =20 # min 4, typically 8KB each
 
#
#       Non-shared Memory=20 Sizes
#
#sort_mem =3D 32168       # min= 64,=20 size in KB
#vacuum_mem =3D=20 8192            = ; =20 # min 1024, size in KB
vacuum_mem =3D=20 65536           &nbs= p; =20 # min 1024, size in KB
 
#
#       Write-ahead log=20 (WAL)
#
#checkpoint_segments =3D 3      = ; =20 # in logfile segments, min 1, 16MB each
#checkpoint_timeout =3D=20 300       # range 30-3600, in=20 seconds
#
#commit_delay =3D=20 0            &n= bsp; =20 # range 0-100000, in microseconds
#commit_siblings =3D=20 5            # range= =20 1-1000
#
#fsync =3D true
#wal_sync_method =3D=20 fsync        # the default varies across= =20 platforms:
#          =             &nb= sp;       =20 # fsync, fdatasync, open_sync, or open_datasync
#wal_debug =3D=20 0            &n= bsp;    =20 # range 0-16
 

#
#       Optimizer=20 Parameters
#
#enable_seqscan =3D true
#enable_indexscan =3D=20 true
#enable_tidscan =3D true
#enable_sort =3D true
#enable_nestlo= op =3D=20 true
#enable_mergejoin =3D true
#enable_hashjoin =3D true
 
#effective_cache_size =3D 1000    # typically 8KB=20 each
effective_cache_size =3D 196608   # typically 8KB=20 each
#random_page_cost =3D=20 4           # units are o= ne=20 sequential page fetch cost
#cpu_tuple_cost =3D=20 0.01          #=20 (same)
#cpu_index_tuple_cost =3D 0.001   #=20 (same)
#cpu_operator_cost =3D 0.0025     # (same)
 
#default_statistics_target =3D 10 # range 1-1000
 
#
#       GEQO Optimizer=20 Parameters
#
#geqo =3D true
#geqo_selection_bias =3D=20 2.0      # range 1.5-2.0
#geqo_threshold =3D=20 11
#geqo_pool_size =3D=20 0             #= =20 default based on tables in statement,=20
            = ;            &n= bsp;      =20 # range 128-1024
#geqo_effort =3D 1
#geqo_generations =3D=20 0
#geqo_random_seed =3D=20 -1          # auto-compute=20 seed
 

#
#       Message=20 display
#
server_min_messages =3Dnotice     # Val= ues, in=20 order of decreasing=20 detail:
          &nbs= p;            &= nbsp;       =20 #   debug5, debug4, debug3, debug2,=20 debug1,
          &nbs= p;            &= nbsp;       =20 #   info, notice, warning, error, log,=20 fatal,
           = ;            &n= bsp;       =20 #   panic
client_min_messages =3Dnotice    = ; #=20 Values, in order of decreasing=20 detail:
          &nbs= p;            &= nbsp;       =20 #   debug5, debug4, debug3, debug2,=20 debug1,
          &nbs= p;            &= nbsp;       =20 #   log, info, notice, warning, error
#silent_mode =3D false
 
#log_connections =3Dtrue
#log_pid =3Dtrue
#log_statement=20 =3Dtrue
#log_duration =3Dtrue
#log_timestamp =3Dtrue
 
log_min_error_statement =3Derror
# Values in order of increasing=20 severity:
          &n= bsp;            = ;         =20 #   debug5, debug4, debug3, debug2,=20 debug1,
          &nbs= p;            &= nbsp;        =20 #   info, notice, warning, error, panic(off)
 
#debug_print_parse =3D false
#debug_print_rewritten =3D=20 false
#debug_print_plan =3D false
#debug_pretty_print =3D false
 
#explain_pretty_print =3D true
 
# requires USE_ASSERT_CHECKING
#debug_assertions =3D true
 

#
#       Syslog
#
syslog = =3D=20 0            &n= bsp;        =20 # range 0-2
syslog_facility =3D 'LOCAL0'
syslog_ident =3D 'postgres'<= /DIV>
 

#
#      =20 Statistics
#
show_parser_stats =3D false
show_planner_stats=20 =3Dfalse
show_executor_stats =3D false
show_statement_stats =3Dfalse =
 
# requires BTREE_BUILD_STATS
#show_btree_build_stats =3D false
 

#
#       Access statistics=20 collection
#
stats_start_collector =3D true
stats_reset_on_server_= start =3D=20 false
stats_command_string =3D true
stats_row_level =3D true=20
stats_block_level =3D true
 

#
#       Lock=20 Tracing
#
#trace_notify =3D false
 
# requires LOCK_DEBUG
#trace_locks =3D false
#trace_userlocks = =3D=20 false
#trace_lwlocks =3D false
#debug_deadlocks =3D=20 false
#trace_lock_oidmin =3D 16384
#trace_lock_table =3D 0
 

#
#       Misc
#
#autocommi= t =3D=20 true
#dynamic_library_path =3D '$libdir'
#search_path =3D=20 '$user,public'
#datestyle =3D 'iso, us'
#timezone =3D=20 unknown           &n= bsp;=20 # actually, defaults to TZ environment setting
#australian_timezones =3D= =20 false
#client_encoding =3D sql_ascii    # actually, defau= lts to=20 database encoding
#authentication_timeout =3D 60    # 1-6= 00, in=20 seconds
#deadlock_timeout =3D 1000      &n= bsp; #=20 in milliseconds
#default_transaction_isolation =3D 'read=20 committed'
#max_expr_depth =3D=20 10000         # min=20 10
#max_files_per_process =3D 1000   # min 25
#password_enc= ryption=20 =3D true
#sql_inheritance =3D true
#transform_null_equals =3D=20 false
#statement_timeout =3D=20 0          # 0 is disabled, in= =20 milliseconds
#db_user_namespace =3D false
************************************************= ***************************************************************************= ****************************
 

Stephane Tessier, CISSP
Development Team=20 Leader
450-430-8166 X:206

 
------=_NextPart_000_0001_01C474A3.ECD3A0C0-- From pgsql-performance-owner@postgresql.org Wed Jul 28 19:54:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC211D1B195 for ; Wed, 28 Jul 2004 19:54:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03201-04 for ; Wed, 28 Jul 2004 22:54:42 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id DE413D1B182 for ; Wed, 28 Jul 2004 19:54:39 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BpxJj-0006kh-00; Wed, 28 Jul 2004 18:54:35 -0400 To: Tom Lane Cc: Greg Stark , Stephan Szabo , Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> <20040727204057.S28969@megazone.bigpanda.com> <87oem0u182.fsf@stark.xeocode.com> <21449.1091023621@sss.pgh.pa.us> <87y8l4rujq.fsf@stark.xeocode.com> <23584.1091033781@sss.pgh.pa.us> In-Reply-To: <23584.1091033781@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 28 Jul 2004 18:54:35 -0400 Message-ID: <876587spxw.fsf@stark.xeocode.com> Lines: 16 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/219 X-Sequence-Number: 7610 Tom Lane writes: > One thing I did not like about your first pass is that it makes > unsupportable assumptions about there being a semantic relationship > between operators named, say, '<' and '<='. Hm, I think I even had caught that issue on the mailing list previously. In that case though, it seems even the existing code is insufficient. Instead of testing whether the operator with strcmp against "=" and "<>" it should perhaps be looking for an operator class and the strategy number for the operator and its negator. -- greg From pgsql-performance-owner@postgresql.org Wed Jul 28 20:12:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 66214D1B1B9 for ; Wed, 28 Jul 2004 20:12:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11565-01 for ; Wed, 28 Jul 2004 23:11:42 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 85305D1B174 for ; Wed, 28 Jul 2004 20:11:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6SNB6C7000815; Wed, 28 Jul 2004 19:11:06 -0400 (EDT) To: Greg Stark Cc: Stephan Szabo , Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index In-reply-to: <876587spxw.fsf@stark.xeocode.com> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEFF@Herge.rcsinc.local> <20040727204057.S28969@megazone.bigpanda.com> <87oem0u182.fsf@stark.xeocode.com> <21449.1091023621@sss.pgh.pa.us> <87y8l4rujq.fsf@stark.xeocode.com> <23584.1091033781@sss.pgh.pa.us> <876587spxw.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "28 Jul 2004 18:54:35 -0400" Date: Wed, 28 Jul 2004 19:11:06 -0400 Message-ID: <814.1091056266@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/220 X-Sequence-Number: 7611 Greg Stark writes: > Tom Lane writes: >> One thing I did not like about your first pass is that it makes >> unsupportable assumptions about there being a semantic relationship >> between operators named, say, '<' and '<='. > In that case though, it seems even the existing code is insufficient. Well, yeah, we know the existing code is broken ;-) > Instead of testing whether the operator with strcmp against "=" and > "<>" it should perhaps be looking for an operator class and the > strategy number for the operator and its negator. Probably. You can find some relevant code in indxpath.c in the stuff that tries to determine whether partial indexes are relevant. I think that the ideal behavior is that we not look directly at the operator name at all. For example it's not too unreasonable to want to write (a,b) ~<~ (c,d) if you have an index that uses those non-locale-aware operators. We should find the operator that matches the name and input arguments, and then try to make sense of the operator semantics by matching it to btree opclasses. Note that it's possible to find multiple matches, for example if someone has installed a "reverse sort" opclass. I think we would want to prefer a match in the datatype's default opclass, if there is one, but otherwise we can probably follow the lead of the existing code and assume that any match is equally good. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jul 29 12:55:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 80024D1B462 for ; Thu, 29 Jul 2004 12:54:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26415-06 for ; Thu, 29 Jul 2004 15:54:52 +0000 (GMT) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by svr1.postgresql.org (Postfix) with ESMTP id B149DD1B442 for ; Thu, 29 Jul 2004 12:54:50 -0300 (ADT) Received: from 204.127.197.111 ([204.127.197.111]) by comcast.net (rwcrmhc11) with SMTP id <20040729155450013003he6de>; Thu, 29 Jul 2004 15:54:50 +0000 Received: from [64.237.4.140] by 204.127.197.111; Thu, 29 Jul 2004 15:54:49 +0000 From: pathat@comcast.net To: pgsql-performance@postgresql.org Subject: Extremely slow query... Date: Thu, 29 Jul 2004 15:54:49 +0000 Message-Id: <072920041554.15818.41091DC90005607500003DCA22007374789B0E089B0E9F@comcast.net> X-Mailer: AT&T Message Center Version 1 (Jun 24 2004) X-Authenticated-Sender: cGF0aGF0QGNvbWNhc3QubmV0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200407/223 X-Sequence-Number: 7614 I have the following query that I have to quit after 10 mins. I have vacuum full analyzed each of the tables and still nothing seems to help. There are indexes on all the join fields. I've included the query, explain and the table structures. Please let me know if there is anything else I should provide. SELECT m.r_score,m.f_score,m.m_score,m.rfm_score,ed.email_id, '00'::varchar as event_id, COUNT(e.email_adr) AS count FROM cdm.cdm_indiv_mast m INNER JOIN cdm.cdm_email_data e on e.indiv_fkey = m.indiv_key INNER JOIN cdm.email_sent es on es.email_address = e.email_adr inner join cdm.email_description ed on ed.email_id = es.email_id where (ed.event_date::date between '2003-10-07' and '2003-12-31') and m.m_score >0 GROUP BY 1,2,3,4,5,6 QUERY PLAN HashAggregate (cost=551716.04..551724.14 rows=3241 width=58) -> Hash Join (cost=417315.57..546391.36 rows=304267 width=58) Hash Cond: (("outer".email_address)::text = ("inner".email_adr)::text) -> Nested Loop (cost=0.00..85076.89 rows=1309498 width=42) -> Seq Scan on email_description ed (cost=0.00..20.72 rows=3 width=19) Filter: (((event_date)::date >= '2003-10-07'::date) AND ((event_date)::date <= '2003-12-31'::date)) -> Index Scan using emailsnt_id_idx on email_sent es (cost=0.00..20964.10 rows=591036 width=42) Index Cond: (("outer".email_id)::text = (es.email_id)::text) -> Hash (cost=404914.28..404914.28 rows=1202517 width=39) -> Hash Join (cost=144451.53..404914.28 rows=1202517 width=39) Hash Cond: ("outer".indiv_fkey = "inner".indiv_key) -> Seq Scan on cdm_email_data e (cost=0.00..93002.83 rows=5175383 width=31) -> Hash (cost=134399.24..134399.24 rows=1202517 width=24) -> Index Scan using m_score_idx on cdm_indiv_mast m (cost=0.00..134399.24 rows=1202517 width=24) Index Cond: (m_score > 0) CREATE TABLE cdm.cdm_email_data ( email_adr varchar(75) NOT NULL, opt_out char(1) DEFAULT 'n'::bpchar, indiv_fkey int8 NOT NULL, CONSTRAINT email_datuniq UNIQUE (email_adr, indiv_fkey) ) WITHOUT OIDS; CREATE INDEX emaildat_email_idx ON cdm.cdm_email_data USING btree (email_adr); CREATE TABLE cdm.cdm_indiv_mast ( name_first varchar(20), name_middle varchar(20), name_last varchar(30), name_suffix varchar(5), addr1 varchar(40), addr2 varchar(40), addr3 varchar(40), city varchar(25), state varchar(7), r_score int4, f_score int4, m_score int4, rfm_score int4, rfm_segment int4, CONSTRAINT indiv_mast_pk PRIMARY KEY (indiv_key) ) WITH OIDS; CREATE INDEX f_score_idx ON cdm.cdm_indiv_mast USING btree (f_score); CREATE INDEX m_score_idx ON cdm.cdm_indiv_mast USING btree (m_score); CREATE INDEX r_score_idx ON cdm.cdm_indiv_mast USING btree (r_score); CREATE TABLE cdm.email_description ( email_id varchar(20) NOT NULL, event_date timestamp, affiliate varchar(75), event_name varchar(100), mailing varchar(255), category varchar(100), div_code varchar(30), mkt_category varchar(50), merch_code varchar(50), campaign_code varchar(50), offer_code varchar(30), CONSTRAINT email_desc_pk PRIMARY KEY (email_id) ) WITHOUT OIDS; CREATE INDEX email_desc_id_idx ON cdm.email_description USING btree (email_id); CREATE INDEX eml_desc_date_idx ON cdm.email_description USING btree (event_date); CREATE TABLE cdm.email_sent ( email_address varchar(75), email_id varchar(20), email_sent_ts timestamp, email_type char(1) ) WITHOUT OIDS; CREATE INDEX emailsnt_id_idx ON cdm.email_sent USING btree (email_id); CREATE INDEX email_sent_emailidx ON cdm.email_sent USING btree (email_address); -TIA -Patrick Hatcher From pgsql-performance-owner@postgresql.org Thu Jul 29 13:14:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7622ED1B488 for ; Thu, 29 Jul 2004 13:09:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32828-09 for ; Thu, 29 Jul 2004 16:09:01 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 3B31ED1B462 for ; Thu, 29 Jul 2004 13:08:58 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 755433531F; Thu, 29 Jul 2004 09:08:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 7393A3531D; Thu, 29 Jul 2004 09:08:55 -0700 (PDT) Date: Thu, 29 Jul 2004 09:08:55 -0700 (PDT) From: Stephan Szabo To: Stan Bielski Cc: pgsql-performance@postgresql.org Subject: Re: Optimizer refuses to hash join In-Reply-To: Message-ID: <20040729090450.D97947@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/224 X-Sequence-Number: 7615 On Tue, 27 Jul 2004, Stan Bielski wrote: > I having a great deal of difficulty getting postgres to do a hash join. > Even if I disable nestloop and mergejoin in postgres.conf, the optimizer > still refuses to select hash join. This behavior is killing my > performance. > > Postgres version is 7.3.2 and relevant tables are vacuum analyzed. > > Here's an overview of what I'm doing: > > I have one table of network logs ordered by time values. The other table > is a set of hosts (approximately 60) that are infected by a worm. I want > to do this query on the dataset: > > standb=# explain SELECT count (allflow_tv_sobig.tv_s) FROM > allflow_tv_sobig, blaster_set WHERE allflow_tv_sobig.src = > blaster_set.label AND allflow_tv_sobig.tv_s >= 1060101118::bigint and > allflow_tv_sobig.tv_s < 1060187518::bigint; Can you send explain analyze results for the normal case and the nested loop case? It's generally more useful than plain explain. I'd also wonder if blaster_set.label is unique such that you might be able to write the condition as an exists clause and if that's better. If you were running 7.4, I'd suggest IN, but that'll certainly be painful in 7.3. From pgsql-performance-owner@postgresql.org Thu Jul 29 13:49:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DD78FD1B174 for ; Thu, 29 Jul 2004 13:48:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53037-05 for ; Thu, 29 Jul 2004 16:48:53 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 8E910D1B541 for ; Thu, 29 Jul 2004 13:48:51 -0300 (ADT) Subject: Re: best way to fetch next/prev record based on index MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-class: urn:content-classes:message Date: Thu, 29 Jul 2004 12:48:51 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF0F@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index thread-index: AcR0+DeeInYMXSk7TDmCdGW3ZeBNOQAkhUDw From: "Merlin Moncure" To: Cc: "Greg Stark" , "Tom Lane" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/225 X-Sequence-Number: 7616 Just an update on this: queries in the 'next key' form on fields(a,b,c) only ever use the index for the first field (a). I just never noticed that before...in most cases this is selective enough. In most logical cases in multi part keys the most important stuff comes first. Curiously, queries in the Boolean reversed form (switching and with or, etc.) find the index but do not apply any condition, kind of like an indexed sequential scan... Well, if and when the rowtype comparison can be made to work over multi part keys (and the optimizer is made to do tricks there), postgres can be made to give much better generalized ISAM access. In the meantime, I'll just troubleshoot specific cases via application specific behavior as they come up. In any case, many thanks to Greg and Tom for taking the time to pick this apart. Merlin From pgsql-performance-owner@postgresql.org Thu Jul 29 14:07:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7FE84D1B174 for ; Thu, 29 Jul 2004 14:06:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62589-03 for ; Thu, 29 Jul 2004 17:06:28 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 730ACD1B462 for ; Thu, 29 Jul 2004 14:06:27 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6TH6Qiu015404; Thu, 29 Jul 2004 13:06:27 -0400 (EDT) To: Stan Bielski Cc: pgsql-performance@postgresql.org Subject: Re: Optimizer refuses to hash join In-reply-to: References: Comments: In-reply-to Stan Bielski message dated "Tue, 27 Jul 2004 15:38:05 -0400" Date: Thu, 29 Jul 2004 13:06:26 -0400 Message-ID: <15403.1091120786@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/226 X-Sequence-Number: 7617 Stan Bielski writes: > I having a great deal of difficulty getting postgres to do a hash join. > Even if I disable nestloop and mergejoin in postgres.conf, the optimizer > still refuses to select hash join. Are you sure the join condition is hashjoinable? You didn't say anything about the datatypes involved ... If it is, the other possibility is that you need to increase sort_mem to accommodate the hash table. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jul 29 14:58:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6E3F2D1B2E6 for ; Thu, 29 Jul 2004 14:58:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83490-08 for ; Thu, 29 Jul 2004 17:58:05 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id C2BA6D1B182 for ; Thu, 29 Jul 2004 14:58:02 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BqFAB-0000or-00; Thu, 29 Jul 2004 13:57:55 -0400 To: "Merlin Moncure" Cc: , "Greg Stark" , "Tom Lane" Subject: Re: best way to fetch next/prev record based on index References: <6EE64EF3AB31D5448D0007DD34EEB34101AF0F@Herge.rcsinc.local> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AF0F@Herge.rcsinc.local> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 29 Jul 2004 13:57:55 -0400 Message-ID: <877jsmr90c.fsf@stark.xeocode.com> Lines: 21 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/227 X-Sequence-Number: 7618 "Merlin Moncure" writes: > Well, if and when the rowtype comparison can be made to work over multi > part keys (and the optimizer is made to do tricks there), postgres can > be made to give much better generalized ISAM access. In the meantime, > I'll just troubleshoot specific cases via application specific behavior > as they come up. In any case, many thanks to Greg and Tom for taking > the time to pick this apart. Well I'm not sure whether you caught it, but Tom did come up with a work-around that works with the current infrastructure if all the columns involved are the same datatype. You can create a regular btree index on the expression array[a,b,c] and then do your lookup using array[a,b,c] > array[a1,b1,c1]. This will only work in 7.4, not previous releases, for several reasons. -- greg From pgsql-performance-owner@postgresql.org Thu Jul 29 15:23:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 75331D1B233 for ; Thu, 29 Jul 2004 15:23:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93686-09 for ; Thu, 29 Jul 2004 18:23:18 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 25650D1B182 for ; Thu, 29 Jul 2004 15:23:14 -0300 (ADT) Subject: Re: best way to fetch next/prev record based on index MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-class: urn:content-classes:message Date: Thu, 29 Jul 2004 14:23:15 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF11@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index thread-index: AcR1lZaFx2PUr+v/Sla0b1BKArHS9QAAZQcw From: "Merlin Moncure" To: Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/228 X-Sequence-Number: 7619 Greg Stark wrote: > Well I'm not sure whether you caught it, but Tom did come up with a > work-around that works with the current infrastructure if all the columns > involved are the same datatype. >=20 > You can create a regular btree index on the expression array[a,b,c] and > then > do your lookup using array[a,b,c] > array[a1,b1,c1]. Unfortunately, ISAM files allow keys based on combinations of fields on any type. So this is not an option. (I have spent over 6 months researching this problem). However, this would work: Create index on t(stackparam(array[a::text,b::text,c::text), array['char(2)', 'int', 'date')]; With the 'type strings' queried out in advance. stackparam(text[], text[]) is a C function with uses the types and cats the strings together in such a way that preserves sorting. In any case, this is an ugly and inefficient mess, and I have no desire to do this unless there is no other way. I would much rather see postgres 'get' (a,b,c) > (a1, b1, c1)...if there is even a chance this is possible, I'll direct my efforts there. IMNSHO, this form was invented by the SQL folks for dealing with data in an ISAM manner, postgres should be able do it and do it well. Merlin From pgsql-performance-owner@postgresql.org Thu Jul 29 15:41:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 40336D1B233 for ; Thu, 29 Jul 2004 15:41:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03689-06 for ; Thu, 29 Jul 2004 18:41:43 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 102F5D1B241 for ; Thu, 29 Jul 2004 15:41:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6TIfbT5016243; Thu, 29 Jul 2004 14:41:37 -0400 (EDT) To: "Merlin Moncure" Cc: gsstark@mit.edu, pgsql-performance@postgresql.org Subject: Re: best way to fetch next/prev record based on index In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AF11@Herge.rcsinc.local> References: <6EE64EF3AB31D5448D0007DD34EEB34101AF11@Herge.rcsinc.local> Comments: In-reply-to "Merlin Moncure" message dated "Thu, 29 Jul 2004 14:23:15 -0400" Date: Thu, 29 Jul 2004 14:41:37 -0400 Message-ID: <16242.1091126497@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/229 X-Sequence-Number: 7620 "Merlin Moncure" writes: > I would much rather see postgres 'get' (a,b,c) > (a1, > b1, c1)...if there is even a chance this is possible, I'll direct my > efforts there. For the ISAM context this whole discussion is kinda moot, because you really don't want to have to plan and execute a fairly expensive query for every record fetch. If we had all the improvements discussed, it would be a reasonably cheap operation by the standards of "execute an independent query", but by the standards of "fetch next record in my query" it'll still suck. (Using PREPARE might help, but only somewhat.) It strikes me that what you really want for ISAM is to improve the cursor mechanism so it will do the things you need. I'm not sure what's involved, but let's talk about that angle for a bit. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Jul 29 15:49:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2CEA3D1B229 for ; Thu, 29 Jul 2004 15:49:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11261-01 for ; Thu, 29 Jul 2004 18:49:36 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 486DDD1B241 for ; Thu, 29 Jul 2004 15:49:34 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BqFyA-0000z7-00; Thu, 29 Jul 2004 14:49:34 -0400 To: "Merlin Moncure" Cc: , Subject: Re: best way to fetch next/prev record based on index References: <6EE64EF3AB31D5448D0007DD34EEB34101AF11@Herge.rcsinc.local> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AF11@Herge.rcsinc.local> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 29 Jul 2004 14:49:34 -0400 Message-ID: <87vfg6ps1t.fsf@stark.xeocode.com> Lines: 14 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/230 X-Sequence-Number: 7621 "Merlin Moncure" writes: > However, this would work: > Create index on t(stackparam(array[a::text,b::text,c::text), > array['char(2)', 'int', 'date')]; Well, I fear not all datatypes sort properly when treated as text. Notably integers don't. "10" sorts before "2" for example. You could probably deal with this with careful attention to each datatype you're converting if you're interested in going to that length. -- greg From pgsql-performance-owner@postgresql.org Thu Jul 29 17:12:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3E0BBD1B256 for ; Thu, 29 Jul 2004 17:11:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47004-03 for ; Thu, 29 Jul 2004 20:11:51 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 22F2BD1B248 for ; Thu, 29 Jul 2004 17:11:45 -0300 (ADT) Subject: Re: best way to fetch next/prev record based on index MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-class: urn:content-classes:message Date: Thu, 29 Jul 2004 16:11:49 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF13@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] best way to fetch next/prev record based on index thread-index: AcR1m7OEua3srYbxQzefTGoD/yLTFgAA+iwA From: "Merlin Moncure" To: "Tom Lane" Cc: , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/231 X-Sequence-Number: 7622 > "Merlin Moncure" writes: > > I would much rather see postgres 'get' (a,b,c) > (a1, > > b1, c1)...if there is even a chance this is possible, I'll direct my > > efforts there. >=20 > For the ISAM context this whole discussion is kinda moot, because you > really don't want to have to plan and execute a fairly expensive query > for every record fetch. If we had all the improvements discussed, it > would be a reasonably cheap operation by the standards of "execute > an independent query", but by the standards of "fetch next record > in my query" it'll still suck. (Using PREPARE might help, but only > somewhat.) >=20 > It strikes me that what you really want for ISAM is to improve the > cursor mechanism so it will do the things you need. I'm not sure > what's involved, but let's talk about that angle for a bit. Sorry for the long post, but here's an explanation of why I think things are better off where they are. I've created a middleware that translates ISAM file I/O on the fly to SQL and uses prepared statements over parse/bind to execute them. This is why I was so insistent against scoping prepared statement lifetime to transaction level.=20=20 Cursors seem attractive at first but they are a decidedly mixed bag. First of all, PostgreSQL cursors are insensitive, which absolutely precludes their use. Supposing they weren't though, I'm not so sure I'd use them if it was possible to do the same things via vanilla queries.=20= =20 It turns out that prepared statements get the job done. Moving them to parse/bind got me a 30% drop in server cpu time and statement execution times run between .1 and .5 ms for random reads. Sequential reads go from that fast to slower depending on index performance. So, I don't have performance issues except where the index doesn't deliver.=20=20 2000-10000 reads/sec is competitive with commercial ISAM filesystems on the pc (assuming application is not running on the server), and it is far better than any other commercial ISAM emulation I've played with up to this point. Don't have concrete #s, but the server can deliver 2-3 times that in concurrency situations, in many cases the application performance is actually network bound...this is all on pc hardware. Of course, mainframes can do much, much better than this but that's really outside the scope of what I'm trying to do. So, things run pretty fast as they are, and keeping things running through queries keeps things generic and flexible. Also, queries consume zero resources on the server except for the time it takes to process and deal with them. Cursors, OTOH, have to be opened up for every table for every user. Cursors are read-only always, whereas views can be updated with rules. It's worth noting that other commercial ISAM emulation systems (for example Acu4GL by AcuCorp) cut queries on the fly as well, even when cursor options are available. If cursors became sensitive, they would be worth consideration. I've never really had 1000 large ones open at once, be interesting to see how that worked. In ideal object would be a 'pseudo cursor', an insensitive cursor shared by multiple users with each having their own record pointer. This might be better handled via middleware though (this might also give better options handling different locking scenarios). Merlin From pgsql-performance-owner@postgresql.org Thu Jul 29 18:05:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A798D1B181 for ; Thu, 29 Jul 2004 18:05:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67707-06 for ; Thu, 29 Jul 2004 21:04:57 +0000 (GMT) Received: from monkey.sneakemail.com (clean.sneakemail.com [38.136.15.35]) by svr1.postgresql.org (Postfix) with SMTP id 94163D1B16A for ; Thu, 29 Jul 2004 18:04:51 -0300 (ADT) Received: (qmail 10750 invoked by uid 501); 29 Jul 2004 21:04:52 -0000 Received: (sneakemail censored 908-19450 #1); 29 Jul 2004 21:04:52 -0000 Date: Thu, 29 Jul 2004 17:04:51 -0400 (EDT) From: 8lhhxba02@sneakemail.com To: pgsql-performance@postgresql.org Subject: Index works with foo.val=bar.val but not foo.val<=bar.val Message-ID: <908-19450@sneakemail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS, FROM_HAS_MIXED_NUMS, NO_REAL_NAME X-Spam-Level: * X-Archive-Number: 200407/232 X-Sequence-Number: 7623 can anyone imagine why my query refuses to use indexes for a foo.val<=bar.val query (but works for foo.val=bar.val foo.val<=1). the i_value fields are ints (int4), and selectivity of both of these queries is 2/10000. and I'm running pgsql 7.4.3. Also, the default_statistics_target is 1000 and I increased the effective_cache_size from 1000 to 80000 but it still doesn't work (but seems sort of unrelated. there seems to be something fundamentally wrong, because even if I set enable_seqscan=off and all the other crazy plans it tries, it never gets to index scan). If anyone has any ideas, please let me know, I've been trying to get this working for a long time now. this query produces the correct plan using Index Scan: INSERT INTO answer SELECT foo.cid as pid, bar.cid as sid,count(bar.cid) as cnt, 1 FROM foo, bar WHERE foo.field=bar.field AND ( foo.op='i=i' AND bar.op='i=i' AND bar.i_value=foo.i_value ) GROUP BY foo.cid,bar.cid; ------explain analyze---------- Subquery Scan "*SELECT*" (cost=9.04..9.07 rows=2 width=20) (actual time=1.000..1.000 rows=2 loops=1) -> HashAggregate (cost=9.04..9.04 rows=2 width=8) (actual time=1.000..1.000 rows=2 loops=1) -> Nested Loop (cost=0.00..9.02 rows=2 width=8) (actual time=1.000..1.000 rows=2 loops=1) Join Filter: (("outer".field)::text = ("inner".field)::text) -> Seq Scan on foo (cost=0.00..1.01 rows=1 width=17) (actual time=0.000..0.000 rows=1 loops=1) Filter: ((op)::text = 'i=i'::text) -> Index Scan using bar_index_op_i_value on bar (cost=0.00..7.98 rows=2 width=17) (actual time=1.000..1.000 rows=2 loops=1) Index Cond: (((bar.op)::text = 'i=i'::text) AND (bar.i_value = "outer".i_value)) Total runtime: 1.000 ms ------------------------- this almost identical query doesn't (with = as <=): INSERT INTO answer SELECT foo.cid as pid, bar.cid as sid,count(bar.cid) as cnt, 5 FROM foo, bar WHERE foo.field=bar.field AND ( foo.op='i<=i' AND bar.op='i=i' AND bar.i_value<=foo.i_value ) GROUP BY foo.cid,bar.cid; -------------Explain------- Table contains 9 rows QUERY PLAN ---------- Subquery Scan "*SELECT*" (cost=385.02..435.03 rows=3334 width=20) (actual time=50.000..50.000 rows=2 loops=1) -> HashAggregate (cost=385.02..393.35 rows=3334 width=8) (actual time=50.000..50.000 rows=2 loops=1) -> Nested Loop (cost=0.00..360.01 rows=3334 width=8) (actual time=9.000..50.000 rows=2 loops=1) Join Filter: ((("outer".field)::text = ("inner".field)::text) AND ("inner".i_value <= "outer".i_value)) -> Seq Scan on foo (cost=0.00..1.01 rows=1 width=17) (actual time=0.000..0.000 rows=1 loops =1) Filter: ((op)::text = 'i<=i'::text) -> Seq Scan on bar (cost=0.00..209.00 rows=10000 width=17) (actual time=0.000..29.000 rows= 10000 loops=1) Filter: ((op)::text = 'i=i'::text) Total runtime: 51.000 ms ---------------------------- These queries both are on tables foo with 10,000 values (with i_value values from 1-5000) and one single entry in bar (with i_value=1) If table bar has more than 1 entry, it resorts to a merge join, why can't I get this to use Index Scan also? This is what happens if bar has like 20 values (1-20): INSERT INTO answer SELECT foo.cid as pid, bar.cid as sid,count(bar.cid) as cnt, 5 FROM foo, bar WHERE foo.field=bar.field AND ( foo.op='i<=i' AND bar.op='i=i' AND bar.i_value<=foo.i_value ) GROUP BY foo.cid,bar.cid; -------------Explain------- Table contains 8 rows QUERY PLAN ---------- Subquery Scan "*SELECT*" (cost=2.74..3.04 rows=20 width=20) (actual time=0.000..0.000 rows=20 loops=1) -> HashAggregate (cost=2.74..2.79 rows=20 width=8) (actual time=0.000..0.000 rows=20 loops=1) -> Merge Join (cost=1.29..2.59 rows=20 width=8) (actual time=0.000..0.000 rows=20 loops=1) Merge Cond: ("outer".i_value = "inner".i_value) Join Filter: (("inner".field)::text = ("outer".field)::text) -> Index Scan using bar_index on bar (cost=0.00..500.98 rows=10000 width=17) (actu al time=0.000..0.000 rows=21 loops=1) Filter: ((op)::text = 'i=i'::text) -> Sort (cost=1.29..1.32 rows=10 width=17) (actual time=0.000..0.000 rows=19 loops=1) Sort Key: foo.i_value -> Seq Scan on foo (cost=0.00..1.12 rows=10 width=17) (actual time=0.000..0.000 rows= 10 loops=1) Filter: ((op)::text = 'i=i'::text) Total runtime: 4.000 ms Thanks! --Kris "Love is like Pi: natural, irrational, and very important." -- Lisa Hoffman From pgsql-performance-owner@postgresql.org Thu Jul 29 22:22:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 549F3D1B183 for ; Thu, 29 Jul 2004 22:21:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53419-02 for ; Fri, 30 Jul 2004 01:21:58 +0000 (GMT) Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) by svr1.postgresql.org (Postfix) with SMTP id 9A091D1B23E for ; Thu, 29 Jul 2004 22:21:52 -0300 (ADT) Received: (qmail 21904 invoked by uid 0); 30 Jul 2004 11:21:52 +1000 Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) (russell@pws.com.au@203.45.44.212) by mail.pws.com.au with SMTP; 30 Jul 2004 11:21:52 +1000 From: Russell Smith To: pgsql-performance@postgresql.org Subject: Re: my boss want to migrate to ORACLE Date: Fri, 30 Jul 2004 11:21:47 +1000 User-Agent: KMail/1.6.1 References: <000001c474c5$73e2cfc0$4e00020a@develavoie> In-Reply-To: <000001c474c5$73e2cfc0$4e00020a@develavoie> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200407301121.47721.mr-russ@pws.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/233 X-Sequence-Number: 7624 On Thu, 29 Jul 2004 03:08 am, Stephane Tessier wrote: > Hi everyone, > > somebody can help me??????? my boss want to migrate to > ORACLE................ > > we have a BIG problem of performance,it's slow.... > we use postgres 7.3 for php security application with approximately 4 > millions of insertion by day and 4 millions of delete and update > and archive db with 40 millions of archived stuff... This is heavy update. as I say below, what is the vacuum setup like? > > we have 10 databases for our clients and a centralized database for the > general stuff. > > database specs: > > double XEON 2.4 on DELL PowerEdge2650 > 2 gigs of RAM > 5 SCSI Drive RAID 5 15rpm > > tasks: > > 4 millions of transactions by day > 160 open connection 24 hours by day 7 days by week > pg_autovacuum running 24/7 > reindex on midnight Where is your pg_autovacuum config? how often is it set to vacuum? and analyze for that matter. > postgresql.conf: > > tcpip_socket = true > #ssl = false > > max_connections = 256 > #superuser_reserved_connections = 2 > > #port = 5432 > #hostname_lookup = false > #show_source_port = false > > #unix_socket_directory = '' > #unix_socket_group = '' > #unix_socket_permissions = 0777 # octal > > #virtual_host = '' > > #krb_server_keyfile = '' > > > # > # Shared Memory Size > # > #shared_buffers = 256 # min max_connections*2 or 16, 8KB each > #shared_buffers = 196000 # min max_connections*2 or 16, 8KB > each > shared_buffers = 128000 # min max_connections*2 or 16, 8KB each > #max_fsm_relations = 1000 # min 10, fsm is free space map, ~40 bytes > max_fsm_pages = 1000000 # min 1000, fsm is free space map, ~6 bytes > #max_locks_per_transaction = 64 # min 10 > #wal_buffers = 8 # min 4, typically 8KB each I would assume given heavy update you need more WAL buffers, but then I don't know a lot. > > # > # Non-shared Memory Sizes > # > #sort_mem = 32168 # min 64, size in KB > #vacuum_mem = 8192 # min 1024, size in KB > vacuum_mem = 65536 # min 1024, size in KB > > # > # Write-ahead log (WAL) > # > #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each > #checkpoint_timeout = 300 # range 30-3600, in seconds 3 checkpoint_segments is too low for the number of inserts/delete/updates you are doing. you need a much larger check_point, something like 10+ but the tuning docs will give you a better idea. > # > #commit_delay = 0 # range 0-100000, in microseconds > #commit_siblings = 5 # range 1-1000 > # > #fsync = true > #wal_sync_method = fsync # the default varies across platforms: > # # fsync, fdatasync, open_sync, or > open_datasync > #wal_debug = 0 # range 0-16 > > > # > # Optimizer Parameters > # > #enable_seqscan = true > #enable_indexscan = true > #enable_tidscan = true > #enable_sort = true > #enable_nestloop = true > #enable_mergejoin = true > #enable_hashjoin = true > > #effective_cache_size = 1000 # typically 8KB each > effective_cache_size = 196608 # typically 8KB each > #random_page_cost = 4 # units are one sequential page fetch cost > #cpu_tuple_cost = 0.01 # (same) > #cpu_index_tuple_cost = 0.001 # (same) > #cpu_operator_cost = 0.0025 # (same) > > #default_statistics_target = 10 # range 1-1000 > > # > # GEQO Optimizer Parameters > # > #geqo = true > #geqo_selection_bias = 2.0 # range 1.5-2.0 > #geqo_threshold = 11 > #geqo_pool_size = 0 # default based on tables in statement, > # range 128-1024 > #geqo_effort = 1 > #geqo_generations = 0 > #geqo_random_seed = -1 # auto-compute seed > > > # > # Message display > # > server_min_messages =notice # Values, in order of decreasing detail: > # debug5, debug4, debug3, debug2, debug1, > # info, notice, warning, error, log, > fatal, > # panic > client_min_messages =notice # Values, in order of decreasing detail: > # debug5, debug4, debug3, debug2, debug1, > # log, info, notice, warning, error > #silent_mode = false > > #log_connections =true > #log_pid =true > #log_statement =true > #log_duration =true > #log_timestamp =true > > log_min_error_statement =error > # Values in order of increasing severity: > # debug5, debug4, debug3, debug2, > debug1, # info, notice, warning, error, panic(off) > > #debug_print_parse = false > #debug_print_rewritten = false > #debug_print_plan = false > #debug_pretty_print = false > > #explain_pretty_print = true > > # requires USE_ASSERT_CHECKING > #debug_assertions = true > > > # > # Syslog > # > syslog = 0 # range 0-2 > syslog_facility = 'LOCAL0' > syslog_ident = 'postgres' > > > # > # Statistics > # > show_parser_stats = false > show_planner_stats =false > show_executor_stats = false > show_statement_stats =false > > # requires BTREE_BUILD_STATS > #show_btree_build_stats = false > > > # > # Access statistics collection > # > stats_start_collector = true > stats_reset_on_server_start = false > stats_command_string = true > stats_row_level = true > stats_block_level = true > > > # > # Lock Tracing > # > #trace_notify = false > > # requires LOCK_DEBUG > #trace_locks = false > #trace_userlocks = false > #trace_lwlocks = false > #debug_deadlocks = false > #trace_lock_oidmin = 16384 > #trace_lock_table = 0 > > > # > # Misc > # > #autocommit = true > #dynamic_library_path = '$libdir' > #search_path = '$user,public' > #datestyle = 'iso, us' > #timezone = unknown # actually, defaults to TZ environment > setting > #australian_timezones = false > #client_encoding = sql_ascii # actually, defaults to database encoding > #authentication_timeout = 60 # 1-600, in seconds > #deadlock_timeout = 1000 # in milliseconds > #default_transaction_isolation = 'read committed' > #max_expr_depth = 10000 # min 10 > #max_files_per_process = 1000 # min 25 > #password_encryption = true > #sql_inheritance = true > #transform_null_equals = false > #statement_timeout = 0 # 0 is disabled, in milliseconds > #db_user_namespace = false > > *************************************************************************** >* > *************************************************************************** > > Stephane Tessier, CISSP > Development Team Leader > 450-430-8166 X:206 From pgsql-performance-owner@postgresql.org Thu Jul 29 23:34:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B7B08D1B183 for ; Thu, 29 Jul 2004 23:33:49 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73270-07 for ; Fri, 30 Jul 2004 02:33:48 +0000 (GMT) Received: from mail.coretech.co.nz (coretech.co.nz [202.36.204.41]) by svr1.postgresql.org (Postfix) with ESMTP id EAB77D1B179 for ; Thu, 29 Jul 2004 23:33:42 -0300 (ADT) Received: (qmail 30810 invoked from network); 30 Jul 2004 02:33:42 -0000 Received: from localhost (127.0.0.1) by 0 with SMTP; 30 Jul 2004 02:33:42 -0000 Received: from 203.167.203.141 ([203.167.203.141]) by mail.coretech.co.nz (Horde) with HTTP for ; Fri, 30 Jul 2004 14:33:42 +1200 Message-ID: <1091154822.df11fea7be44f@mail.coretech.co.nz> Date: Fri, 30 Jul 2004 14:33:42 +1200 From: markir@coretech.co.nz To: Stephane Tessier Cc: pgsql-performance@postgresql.org Subject: Re: my boss want to migrate to ORACLE References: <000001c474c5$73e2cfc0$4e00020a@develavoie> In-Reply-To: <000001c474c5$73e2cfc0$4e00020a@develavoie> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) 4.0-cvs X-Originating-IP: Withheld X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200407/234 X-Sequence-Number: 7625 Quoting Stephane Tessier : General parameter suggestions: > shared_buffers = 128000 # min max_connections*2 or 16, 8KB each > effective_cache_size = 196608 # typically 8KB each Try reducing shared_buffers (say 30000). There has been much discussion regards setting this parameter - most folks see minimal gains, or even performance *loss* with settings higher than 30000. > #sort_mem = 32168 # min 64, size in KB Depending on what queries you are experiencing problems with, you might want to set this parameter to something. However with 160 connections you need to be careful, as each one uses this much memory (if it needs to sort). > #wal_buffers = 8 Try this in the 100-1000 range > #checkpoint_segments = 3 Try this quite a lot higher - say 10-50. Pg_autovacuum: I have not used this, so can't really give any help about setup. However you can check how well it is working by selecting relname, reltuples, relpages out of pg_class, and see if you have relations with stupidly low numbers of rows per page (clearly you need to be ANALYZing reasonably frequently for this query to give accurate information). Other Comments: To provide you with more help, we need to know what is slow. Particulary what queries are the most troublesome (post EXPLAIN ANALYZE of them). You can identify these by setting the log_statement and log_duration parameters. Finally: (comment for your boss), it is *not* a given that ORACLE will perform any better..... regards Mark From pgsql-performance-owner@postgresql.org Fri Jul 30 00:00:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D4FACD1B1B4 for ; Thu, 29 Jul 2004 23:59:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82087-03 for ; Fri, 30 Jul 2004 02:59:56 +0000 (GMT) Received: from mail.coretech.co.nz (coretech.co.nz [202.36.204.41]) by svr1.postgresql.org (Postfix) with ESMTP id 9CBB7D1B252 for ; Thu, 29 Jul 2004 23:59:55 -0300 (ADT) Received: (qmail 31694 invoked from network); 30 Jul 2004 02:59:53 -0000 Received: from localhost (127.0.0.1) by 0 with SMTP; 30 Jul 2004 02:59:53 -0000 Received: from 203.167.203.141 ([203.167.203.141]) by mail.coretech.co.nz (Horde) with HTTP for ; Fri, 30 Jul 2004 14:59:53 +1200 Message-ID: <1091156393.39517b44365bc@mail.coretech.co.nz> Date: Fri, 30 Jul 2004 14:59:53 +1200 From: markir@coretech.co.nz To: Stephane Tessier Cc: pgsql-performance@postgresql.org Subject: Re: my boss want to migrate to ORACLE References: <000001c474c5$73e2cfc0$4e00020a@develavoie> In-Reply-To: <000001c474c5$73e2cfc0$4e00020a@develavoie> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) 4.0-cvs X-Originating-IP: Withheld X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200407/235 X-Sequence-Number: 7626 A furthur thought or two: - you are *sure* that it is Postgres that is slow? (could be Php...or your machine could be out of some resource - see next 2 points) - is your machine running out of cpu or memory? - is your machine seeing huge io transfers or long io waits? - are you running Php on this machine as well as Postgres? - what os (and what release) are you running? (guessing Linux but...) As an aside, they always say this but: Postgres 7.4 generally performs better than 7.3...so an upgrade could be worth it - *after* you have solved/identified the other issues. best wishes Mark Quoting Stephane Tessier : > Hi everyone, > > somebody can help me??????? my boss want to migrate to > ORACLE................ > > we have a BIG problem of performance,it's slow.... > we use postgres 7.3 for php security application with approximately 4 > millions of insertion by day and 4 millions of delete and update > and archive db with 40 millions of archived stuff... > > we have 10 databases for our clients and a centralized database for the > general stuff. > > database specs: > > double XEON 2.4 on DELL PowerEdge2650 > 2 gigs of RAM > 5 SCSI Drive RAID 5 15rpm > > tasks: > > 4 millions of transactions by day > 160 open connection 24 hours by day 7 days by week > pg_autovacuum running 24/7 > reindex on midnight From pgsql-performance-owner@postgresql.org Fri Jul 30 09:33:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A8AED1B564 for ; Fri, 30 Jul 2004 09:33:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98164-09 for ; Fri, 30 Jul 2004 12:33:53 +0000 (GMT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id E83F1D1B541 for ; Fri, 30 Jul 2004 09:33:46 -0300 (ADT) Received: (qmail 27044 invoked from network); 30 Jul 2004 12:49:28 -0000 Received: from unknown (HELO ?10.124.7.6?) (10.124.7.6) by dhcp-7-248.ma.lycos.com with SMTP; 30 Jul 2004 12:49:28 -0000 In-Reply-To: <000001c474c5$73e2cfc0$4e00020a@develavoie> References: <000001c474c5$73e2cfc0$4e00020a@develavoie> Mime-Version: 1.0 (Apple Message framework v618) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-Id: Content-Transfer-Encoding: quoted-printable Cc: pgsql-performance@postgresql.org From: Jeff Subject: Re: my boss want to migrate to ORACLE Date: Fri, 30 Jul 2004 08:33:52 -0400 To: "Stephane Tessier" X-Mailer: Apple Mail (2.618) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/236 X-Sequence-Number: 7627 On Jul 28, 2004, at 1:08 PM, Stephane Tessier wrote: > we have a BIG problem of performance,it's slow.... Can you isolate which part is slow? (log_min_duration is useful for=20 finding your slow running queries) > we use postgres 7.3 for php security application with approximately=A04= =20 > millions of insertion by day and=A04 millions of delete and update That is pretty heavy write volume. Are these updates done in batches=20 or "now and then"? If they are done in batches you could speed them up=20 by wrapping them inside a transaction. > #shared_buffers =3D 256=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # min max_connectio= ns*2 or 16, 8KB each > #shared_buffers =3D 196000=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 #= min max_connections*2 or 16,=20 > 8KB each > shared_buffers =3D 128000=A0=A0=A0=A0=A0=A0=A0=A0 # min max_connections*2= or 16, 8KB each > Too much. Generally over 10000 will stop benefitting you. > #wal_buffers =3D 8=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # min 4, = typically 8KB each Might want to bump this up > #checkpoint_segments =3D 3=A0=A0=A0=A0=A0=A0=A0 # in logfile segments, mi= n 1, 16MB each Given your write volume, increase this up a bit.. oh.. 20 or 30 of them=20 will help a lot. But it will use 16*30MB of disk space. Oracle is *NOT* a silver bullet. It will not instantly make your problems go away. I'm working on a project porting some things to Oracle and as a test I=20 also ported it to Postgres. And you know what? Postgres is running=20 about 30% faster than Oracle. The Oracle lovers here are not too happy=20 with that one :) Just so you know.. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Fri Jul 30 10:56:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 41AD7D1B19A for ; Fri, 30 Jul 2004 10:56:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41852-02 for ; Fri, 30 Jul 2004 13:56:21 +0000 (GMT) Received: from asdc003.abovesecurite.lan (unknown [206.162.148.235]) by svr1.postgresql.org (Postfix) with ESMTP id 8FAEDD1B56D for ; Fri, 30 Jul 2004 10:56:16 -0300 (ADT) Received: from develavoie ([206.162.148.230]) by asdc003.abovesecurite.lan over TLS secured channel with Microsoft SMTPSVC(6.0.3790.0); Fri, 30 Jul 2004 10:01:21 -0400 From: "Stephane Tessier" To: Cc: Subject: Re: my boss want to migrate to ORACLE Date: Fri, 30 Jul 2004 09:56:17 -0400 Message-ID: <001f01c4763c$fcef40f0$4e00020a@develavoie> 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.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Importance: Normal In-Reply-To: <1091156393.39517b44365bc@mail.coretech.co.nz> X-OriginalArrivalTime: 30 Jul 2004 14:01:21.0390 (UTC) FILETIME=[B15C10E0:01C4763D] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/237 X-Sequence-Number: 7628 I think with your help guys I'll do it! I'm working on it! I'll work on theses issues: we have space for more ram(we use 2 gigs on possibility of 3 gigs) iowait is very high 98% --> look like postgresql wait for io access raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each write on disk use more transactions (we have a lot of insert/update without transaction). cpu look like not running very hard *php is not running on the same machine *redhat enterprise 3.0 ES *the version of postgresql is 7.3.4(using RHDB from redhat) *pg_autovacuum running at 12 and 24 hour each day -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of markir@coretech.co.nz Sent: 29 juillet, 2004 23:00 To: Stephane Tessier Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] my boss want to migrate to ORACLE A furthur thought or two: - you are *sure* that it is Postgres that is slow? (could be Php...or your machine could be out of some resource - see next 2 points) - is your machine running out of cpu or memory? - is your machine seeing huge io transfers or long io waits? - are you running Php on this machine as well as Postgres? - what os (and what release) are you running? (guessing Linux but...) As an aside, they always say this but: Postgres 7.4 generally performs better than 7.3...so an upgrade could be worth it - *after* you have solved/identified the other issues. best wishes Mark Quoting Stephane Tessier : > Hi everyone, > > somebody can help me??????? my boss want to migrate to > ORACLE................ > > we have a BIG problem of performance,it's slow.... > we use postgres 7.3 for php security application with approximately 4 > millions of insertion by day and 4 millions of delete and update > and archive db with 40 millions of archived stuff... > > we have 10 databases for our clients and a centralized database for the > general stuff. > > database specs: > > double XEON 2.4 on DELL PowerEdge2650 > 2 gigs of RAM > 5 SCSI Drive RAID 5 15rpm > > tasks: > > 4 millions of transactions by day > 160 open connection 24 hours by day 7 days by week > pg_autovacuum running 24/7 > reindex on midnight ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match From pgsql-performance-owner@postgresql.org Fri Jul 30 11:14:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6D313D1B181 for ; Fri, 30 Jul 2004 11:14:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46985-05 for ; Fri, 30 Jul 2004 14:14:27 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 91CBBD1B16A for ; Fri, 30 Jul 2004 11:14:22 -0300 (ADT) Subject: Re: my boss want to migrate to ORACLE MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Fri, 30 Jul 2004 10:13:20 -0400 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF14@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] my boss want to migrate to ORACLE thread-index: AcR1hwXQq5dtPFPVQx+CFstg0W9vTgAtuDUw From: "Merlin Moncure" To: "Stephane Tessier" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/238 X-Sequence-Number: 7629 Stephane wrote: Hi everyone, =A0 somebody can help me??????? my boss want to migrate to ORACLE..............= .. #fsync =3D true=20 [snip] Are you using battery baked RAID?=20=20 Your problem is probably due to the database syncing all the time. With fs= ync one, you get 1 sync per transaction that updates, deletes, etc. 4 mill= ion writes/day =3D 46 writes/sec avg. Of course, writes will be very burst= y, and when you get over 100 you are going to have problems even on 15k sys= tem. All databases have this problem, including Oracle. Keeping WAL and d= ata on separate volumes helps a lot. It's quicker and easier to use hardwa= re solution tho. If you want to run fsync on with that much I/O, consider using a battery ba= cked raid controller that caches writes. This will make a *big* difference= . A quick'n'dirty test is to turn fsync off for a little while to see if t= his fixes your performance problems. Merlin From pgsql-performance-owner@postgresql.org Fri Jul 30 12:13:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D4955D1B736 for ; Fri, 30 Jul 2004 12:13:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76104-05 for ; Fri, 30 Jul 2004 15:13:38 +0000 (GMT) Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net [63.231.195.112]) by svr1.postgresql.org (Postfix) with SMTP id 827C5D1B73B for ; Fri, 30 Jul 2004 12:13:34 -0300 (ADT) Received: (qmail 26224 invoked by uid 0); 30 Jul 2004 15:13:33 -0000 Received: from unknown (63.231.195.5) by mpls-qmqp-01.inet.qwest.net with QMQP; 30 Jul 2004 15:13:33 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-05.inet.qwest.net with SMTP; 30 Jul 2004 15:13:33 -0000 Date: Fri, 30 Jul 2004 09:14:51 -0600 Message-Id: <1091200491.27159.56.camel@localhost.localdomain> From: "Scott Marlowe" To: "Stephane Tessier" Cc: markir@coretech.co.nz, pgsql-performance@postgresql.org Subject: Re: my boss want to migrate to ORACLE In-Reply-To: <001f01c4763c$fcef40f0$4e00020a@develavoie> References: <001f01c4763c$fcef40f0$4e00020a@develavoie> Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/239 X-Sequence-Number: 7630 On Fri, 2004-07-30 at 07:56, Stephane Tessier wrote: > I think with your help guys I'll do it! > > I'm working on it! > > I'll work on theses issues: > > we have space for more ram(we use 2 gigs on possibility of 3 gigs) > iowait is very high 98% --> look like postgresql wait for io access > raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each > write on disk Just get battery backed cache on your RAID controller. RAID0 is way too unreliable for a production environment. One disk dies and all your data is just gone. > use more transactions (we have a lot of insert/update without transaction). > cpu look like not running very hard > > *php is not running on the same machine > *redhat enterprise 3.0 ES > *the version of postgresql is 7.3.4(using RHDB from redhat) > *pg_autovacuum running at 12 and 24 hour each day > > > > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of > markir@coretech.co.nz > Sent: 29 juillet, 2004 23:00 > To: Stephane Tessier > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] my boss want to migrate to ORACLE > > > A furthur thought or two: > > - you are *sure* that it is Postgres that is slow? (could be Php...or your > machine could be out of some resource - see next 2 points) > - is your machine running out of cpu or memory? > - is your machine seeing huge io transfers or long io waits? > - are you running Php on this machine as well as Postgres? > - what os (and what release) are you running? (guessing Linux but...) > > As an aside, they always say this but: Postgres 7.4 generally performs > better > than 7.3...so an upgrade could be worth it - *after* you have > solved/identified > the other issues. > > best wishes > > Mark > > Quoting Stephane Tessier : > > > Hi everyone, > > > > somebody can help me??????? my boss want to migrate to > > ORACLE................ > > > > we have a BIG problem of performance,it's slow.... > > we use postgres 7.3 for php security application with approximately 4 > > millions of insertion by day and 4 millions of delete and update > > and archive db with 40 millions of archived stuff... > > > > we have 10 databases for our clients and a centralized database for the > > general stuff. > > > > database specs: > > > > double XEON 2.4 on DELL PowerEdge2650 > > 2 gigs of RAM > > 5 SCSI Drive RAID 5 15rpm > > > > tasks: > > > > 4 millions of transactions by day > > 160 open connection 24 hours by day 7 days by week > > pg_autovacuum running 24/7 > > reindex on midnight > > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend > From pgsql-performance-owner@postgresql.org Fri Jul 30 13:49:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 036A4D1B1CD for ; Fri, 30 Jul 2004 13:49:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19057-08 for ; Fri, 30 Jul 2004 16:49:32 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0B1F4D1B199 for ; Fri, 30 Jul 2004 13:49:31 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6UGnUKa024078; Fri, 30 Jul 2004 12:49:30 -0400 (EDT) To: Stan Bielski Cc: pgsql-performance@postgresql.org Subject: Re: Optimizer refuses to hash join In-reply-to: References: Comments: In-reply-to Stan Bielski message dated "Thu, 29 Jul 2004 14:49:55 -0400" Date: Fri, 30 Jul 2004 12:49:30 -0400 Message-ID: <24077.1091206170@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/240 X-Sequence-Number: 7631 Stan Bielski writes: > On Thu, 29 Jul 2004, Tom Lane wrote: >> Are you sure the join condition is hashjoinable? You didn't say >> anything about the datatypes involved ... > My apologies. The columns that I want to join are both type 'inet'. > Shouldn't that be hashjoinable? Depends on your PG version. The raw type isn't hashjoinable, because its '=' operator ignores the inet-vs-cidr flag. Before 7.4 the operator was (correctly) marked not hashjoinable. In 7.4 it was (incorrectly) marked hashjoinable, due no doubt to momentary brain fade on my part. For 7.5 it is hashjoinable and the join will actually work, because we added a specialized hash function that also ignores the inet-vs-cidr flag. If you are joining data that is all inet or all cidr (no mixtures), then 7.4 works okay, which is why we didn't notice the bug right away. If that's good enough for now, you could emulate the 7.4 behavior in earlier releases by setting the oprcanhash flag in pg_operator for the inet equality operator. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Jul 30 14:56:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 37ACFD1B1BE for ; Fri, 30 Jul 2004 14:56:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51004-05 for ; Fri, 30 Jul 2004 17:56:35 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id B91C1D1B16B for ; Fri, 30 Jul 2004 14:56:33 -0300 (ADT) Received: from 64.sub-166-155-3.myvzw.com ([166.155.3.64]) by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) id 1BqbcL-000N8q-6g; Fri, 30 Jul 2004 13:56:30 -0400 Message-ID: <410A8BC0.3070106@zeut.net> Date: Fri, 30 Jul 2004 13:56:16 -0400 From: "Matthew T. O'Connor" User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stephane Tessier Cc: markir@coretech.co.nz, pgsql-performance@postgresql.org Subject: Re: my boss want to migrate to ORACLE References: <001f01c4763c$fcef40f0$4e00020a@develavoie> In-Reply-To: <001f01c4763c$fcef40f0$4e00020a@develavoie> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 166.155.3.64 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/241 X-Sequence-Number: 7632 Stephane Tessier wrote: >I think with your help guys I'll do it! > >I'm working on it! > >I'll work on theses issues: > >we have space for more ram(we use 2 gigs on possibility of 3 gigs) >iowait is very high 98% --> look like postgresql wait for io access >raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each >write on disk >use more transactions (we have a lot of insert/update without transaction). >cpu look like not running very hard > >*php is not running on the same machine >*redhat enterprise 3.0 ES >*the version of postgresql is 7.3.4(using RHDB from redhat) >*pg_autovacuum running at 12 and 24 hour each day > > What do you mean by "pg_autovacuum running at 12 and 24 hour each day"? From pgsql-performance-owner@postgresql.org Fri Jul 30 15:12:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2417DD1B1B6 for ; Fri, 30 Jul 2004 15:12:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57129-10 for ; Fri, 30 Jul 2004 18:11:58 +0000 (GMT) Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) by svr1.postgresql.org (Postfix) with ESMTP id 4F1C8D1B375 for ; Fri, 30 Jul 2004 15:11:55 -0300 (ADT) Received: from xeon (xeon.unixathome.org [192.168.0.18]) by bast.unixathome.org (Postfix) with ESMTP id 78A2B3D34; Fri, 30 Jul 2004 14:11:41 -0400 (EDT) Date: Fri, 30 Jul 2004 14:11:41 -0400 (EDT) From: Dan Langille X-X-Sender: dan@xeon.unixathome.org To: "Matthew T. O'Connor" Cc: Stephane Tessier , markir@coretech.co.nz, pgsql-performance@postgresql.org Subject: Re: my boss want to migrate to ORACLE In-Reply-To: <410A8BC0.3070106@zeut.net> Message-ID: <20040730141118.S80979@xeon.unixathome.org> References: <001f01c4763c$fcef40f0$4e00020a@develavoie> <410A8BC0.3070106@zeut.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/242 X-Sequence-Number: 7633 On Fri, 30 Jul 2004, Matthew T. O'Connor wrote: > Stephane Tessier wrote: > > >I think with your help guys I'll do it! > > > >I'm working on it! > > > >I'll work on theses issues: > > > >we have space for more ram(we use 2 gigs on possibility of 3 gigs) > >iowait is very high 98% --> look like postgresql wait for io access > >raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each > >write on disk > >use more transactions (we have a lot of insert/update without transaction). > >cpu look like not running very hard > > > >*php is not running on the same machine > >*redhat enterprise 3.0 ES > >*the version of postgresql is 7.3.4(using RHDB from redhat) > >*pg_autovacuum running at 12 and 24 hour each day > > > > > What do you mean by "pg_autovacuum running at 12 and 24 hour each day"? I suspect he means at 1200 and 2400 each day (i.e noon and midnight). -- Dan Langille - http://www.langille.org/ From pgsql-performance-owner@postgresql.org Fri Jul 30 15:29:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5DDE2D1B16A for ; Fri, 30 Jul 2004 15:29:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64836-03 for ; Fri, 30 Jul 2004 18:29:22 +0000 (GMT) Received: from homer.berkhirt.com (homer.berkhirt.com [207.88.49.100]) by svr1.postgresql.org (Postfix) with ESMTP id 16EDAD1B16B for ; Fri, 30 Jul 2004 15:29:10 -0300 (ADT) Received: from [10.10.11.3] (homer [127.0.0.1]) (authenticated bits=0) by homer.berkhirt.com (8.12.10/8.12.10) with ESMTP id i6UISrbQ007230; Fri, 30 Jul 2004 13:28:55 -0500 In-Reply-To: <20040730141118.S80979@xeon.unixathome.org> References: <001f01c4763c$fcef40f0$4e00020a@develavoie> <410A8BC0.3070106@zeut.net> <20040730141118.S80979@xeon.unixathome.org> Mime-Version: 1.0 (Apple Message framework v618) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <548C98FA-E256-11D8-9FFA-000D93AD2E74@mobygames.com> Content-Transfer-Encoding: 7bit Cc: markir@coretech.co.nz, "Matthew T. O'Connor" , Stephane Tessier , pgsql-performance@postgresql.org From: Brian Hirt Subject: Re: my boss want to migrate to ORACLE Date: Fri, 30 Jul 2004 12:29:02 -0600 To: Dan Langille X-Mailer: Apple Mail (2.618) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/243 X-Sequence-Number: 7634 pg_autovacuum is a daemon, not something that get's run twice a day. I think that's what the question Matthew was getting @. I'm not sure what would happen to performance if pg_autovacuum was launched twice a day from cron, but you could end up in an ugly situation if it starts up. --brian On Jul 30, 2004, at 12:11 PM, Dan Langille wrote: > On Fri, 30 Jul 2004, Matthew T. O'Connor wrote: > >> Stephane Tessier wrote: >> >>> I think with your help guys I'll do it! >>> >>> I'm working on it! >>> >>> I'll work on theses issues: >>> >>> we have space for more ram(we use 2 gigs on possibility of 3 gigs) >>> iowait is very high 98% --> look like postgresql wait for io access >>> raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for >>> each >>> write on disk >>> use more transactions (we have a lot of insert/update without >>> transaction). >>> cpu look like not running very hard >>> >>> *php is not running on the same machine >>> *redhat enterprise 3.0 ES >>> *the version of postgresql is 7.3.4(using RHDB from redhat) >>> *pg_autovacuum running at 12 and 24 hour each day >>> >>> >> What do you mean by "pg_autovacuum running at 12 and 24 hour each >> day"? > > I suspect he means at 1200 and 2400 each day (i.e noon and midnight). > > -- > Dan Langille - http://www.langille.org/ > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Fri Jul 30 23:17:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 97590D1B172 for ; Fri, 30 Jul 2004 23:17:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16795-09 for ; Sat, 31 Jul 2004 02:17:38 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id DE4DFD1B1A1 for ; Fri, 30 Jul 2004 23:17:33 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i6V2HXqd053263 for ; Sat, 31 Jul 2004 02:17:33 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i6V1oN7r050520 for pgsql-performance@postgresql.org; Sat, 31 Jul 2004 01:50:23 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: my boss want to migrate to ORACLE Date: Fri, 30 Jul 2004 21:22:25 -0400 Organization: cbbrowne Computing Inc Lines: 68 Message-ID: References: <1091156393.39517b44365bc@mail.coretech.co.nz> <001f01c4763c$fcef40f0$4e00020a@develavoie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:phQBNJfjLYiYF3arEAm8G36pLNU= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/244 X-Sequence-Number: 7635 After a long battle with technology, stephane.tessier@abovesecurity.com ("Stephane Tessier"), an earthling, wrote: > I think with your help guys I'll do it! > > I'm working on it! > > I'll work on theses issues: > > we have space for more ram(we use 2 gigs on possibility of 3 gigs) That _may_ help; not completely clear. > iowait is very high 98% --> look like postgresql wait for io access In that case, if you haven't got a RAID controller with battery backed cache, then that should buy you a BIG boost in performance. Maybe $1500 USD; that could be money FABULOUSLY well spent. > raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each > write on disk I try to avoid talking about RAID levels, and leave them to others :-). Sticking WAL on a solid state disk would be WAY COOL; you almost certainly are hitting WAL really hard, which eventually cooks disks. What is unfortunate is that there doesn't seem to be a "low end" 1GB SSD; I'd hope that would cost $5K, and that might give a bigger boost than the battery-backed RAID controller with lotsa cache. > use more transactions (we have a lot of insert/update without > transaction). That'll help unless you get the RAID controller, in which case WAL updates become much cheaper. > cpu look like not running very hard Not surprising. > *php is not running on the same machine > *redhat enterprise 3.0 ES > *the version of postgresql is 7.3.4(using RHDB from redhat) All makes sense. It would be attractive to move to 7.4.2 or 7.4.3; they're really quite a lot faster. If there's no option to migrate quickly, then 7.5 has interesting cache management changes that ought to help even more, particularly with your vacuuming issues :-). But it's probably better to get two incremental changes; migrating to 7.4, and being able to tell the boss "That improved performance by x%", and then doing _another_ upgrade that _also_ improves things should provide a pretty compelling argument in favour of keeping up the good work with PostgreSQL. > *pg_autovacuum running at 12 and 24 hour each day That really doesn't make sense. The point of pg_autovacuum is for it to run 24 hours a day. If you kick it off twice, once at 11:59, then stop it, and then once at 23:59, and then stop it, it shouldn't actually do any work. Or have you set it up with a 'sleep period' of ~12 hours? -- let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;; http://www.ntlug.org/~cbbrowne/sgml.html The *Worst* Things to Say to a Police Officer: Hey, is that a 9 mm? That's nothing compared to this .44 magnum. From pgsql-performance-owner@postgresql.org Sat Jul 31 01:17:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 394A4D1B1D2 for ; Sat, 31 Jul 2004 01:13:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55067-08 for ; Sat, 31 Jul 2004 04:13:25 +0000 (GMT) Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net [63.231.195.115]) by svr1.postgresql.org (Postfix) with SMTP id 7EB25D1B1B9 for ; Sat, 31 Jul 2004 01:13:23 -0300 (ADT) Received: (qmail 17597 invoked by uid 0); 31 Jul 2004 04:13:22 -0000 Received: from mpls-pop-12.inet.qwest.net (63.231.195.12) by mpls-qmqp-04.inet.qwest.net with QMQP; 31 Jul 2004 04:13:22 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-12.inet.qwest.net with SMTP; 31 Jul 2004 04:13:22 -0000 Date: Fri, 30 Jul 2004 22:14:41 -0600 Message-Id: <1091247281.27159.726.camel@localhost.localdomain> From: "Scott Marlowe" To: "Christopher Browne" Cc: pgsql-performance@postgresql.org Subject: Re: my boss want to migrate to ORACLE In-Reply-To: References: <1091156393.39517b44365bc@mail.coretech.co.nz> <001f01c4763c$fcef40f0$4e00020a@develavoie> Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/245 X-Sequence-Number: 7636 On Fri, 2004-07-30 at 19:22, Christopher Browne wrote: > After a long battle with technology, stephane.tessier@abovesecurity.com ("Stephane Tessier"), an earthling, wrote: > > I think with your help guys I'll do it! > > > > I'm working on it! > > > > I'll work on theses issues: > > > > we have space for more ram(we use 2 gigs on possibility of 3 gigs) > > That _may_ help; not completely clear. > > > iowait is very high 98% --> look like postgresql wait for io access > > In that case, if you haven't got a RAID controller with battery backed > cache, then that should buy you a BIG boost in performance. Maybe > $1500 USD; that could be money FABULOUSLY well spent. > > > raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each > > write on disk > > I try to avoid talking about RAID levels, and leave them to others > :-). FYI, in a previous post on this topic, the original poster put up a top output that showed the machine using 2 gigs of swap with 150 Meg for kernel cache, and all the memory being used by a few postgresql processes. The machine was simply configured to give WAY too much memory to shared buffers and sort mem and this was likely causing the big slowdown. Adding a battery backed caching RAID controller and properly configuring postgresql.conf should get him into the realm of reasonable performance.