From pgsql-admin-owner@postgresql.org Fri Nov 1 06:15:58 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7D1B5475F28 for ; Fri, 1 Nov 2002 06:15:55 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 4F001475E25 for ; Fri, 1 Nov 2002 06:15:51 -0500 (EST) Received: (qmail 22127 invoked from network); 1 Nov 2002 11:03:34 -0000 Received: from news1.trade-india.com (HELO www.trade-india.com) (130.94.20.27) by infocom-236-129-del.trade-india.com with SMTP; 1 Nov 2002 11:03:34 -0000 Received: (qmail 7858 invoked by uid 99); 1 Nov 2002 11:15:43 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Fri, 1 Nov 2002 16:45:43 +0530 (IST) Message-ID: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> Date: Fri, 1 Nov 2002 16:45:43 +0530 (IST) Subject: Is dump-reload the only cure? From: To: X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/4 X-Sequence-Number: 6192 Hi , For a particular table it was only dump and reload of the table that helped in enabling index usage. I tried VACUUM ANALYZE and even recreating the indexes but it did not work. why does the planner use the index like a miser? below are the details was there anything bettwer i could have done for indexes getting used? regds mallah. Query: explain SELECT count( email_id ) from email_bank_mailing_lists where query_id='499'; NOTICE: QUERY PLAN: Aggregate (cost=4330.48..4330.48 rows=1 width=4) -> Index Scan using email_bank_ml_qid on email_bank_mailing_lists (cost=0.00..4327.28 rows=1282 width=4) EXPLAIN distribution of query_id in table: total: 256419 query_id | count(*) ---------------------- 298 | 6167 328 | 2083 354 | 9875 404 | 6974 432 | 5059 437 | 2497 440 | 2837 448 | 14624 449 | 13053 454 | 409 455 | 3725 456 | 560 458 | 3477 460 | 5561 486 | 41842 488 | 63642 492 | 2244 493 | 6047 494 | 37415 499 | 25010 501 | 3318 before dump reload: tradein_clients=# VACUUM VERBOSE ANALYZE email_bank_mailing_lists; NOTICE: --Relation email_bank_mailing_lists-- NOTICE: Pages 3583: Changed 0, Empty 0; Tup 256419: Vac 0, Keep 0, UnUsed 44822. Total CPU 0.24s/0.04u sec elapsed 0.30 sec. NOTICE: Analyzing email_bank_mailing_lists VACUUM tradein_clients=# explain SELECT count( email_id ) from email_bank_mailing_lists where query_id=499;NOTICE: QUERY PLAN: Aggregate (cost=6863.24..6863.24 rows=1 width=4) -> Seq Scan on email_bank_mailing_lists (cost=0.00..6788.24 rows=30001 width=4) EXPLAIN ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/ From pgsql-admin-owner@postgresql.org Fri Nov 1 13:11:56 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A1915474E53; Fri, 1 Nov 2002 07:52:14 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 10EAE474E44; Fri, 1 Nov 2002 07:52:14 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gA1CqefU005533; Fri, 1 Nov 2002 07:52:40 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: [pgsql-performance] Is dump-reload the only cure? From: Rod Taylor To: mallah@trade-india.com Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> References: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 01 Nov 2002 07:52:40 -0500 Message-Id: <1036155160.3550.8.camel@jester> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/20 X-Sequence-Number: 6208 On Fri, 2002-11-01 at 06:15, mallah@trade-india.com wrote: Looks like a borderline case. See the costs of the index scan and sequential scan are very similar. Since 499 covers nearly 1 in 10 tuples, it's likely found on nearly every page. This should make a sequential scan much cheaper. However, if the data is clumped together (not distributed throughout the table) than an index scan may be preferable. So... CLUSTER may be useful to you. In the future please 'explain analyze' the queries you're looking at to see actual costs as compared to the estimated cost. > 499 | 25010 > 501 | 3318 > > > before dump reload: > tradein_clients=# VACUUM VERBOSE ANALYZE email_bank_mailing_lists; > NOTICE: --Relation email_bank_mailing_lists-- > NOTICE: Pages 3583: Changed 0, Empty 0; Tup 256419: Vac 0, Keep 0, UnUsed 44822. > Total CPU 0.24s/0.04u sec elapsed 0.30 sec. > NOTICE: Analyzing email_bank_mailing_lists > VACUUM > tradein_clients=# explain SELECT count( email_id ) from email_bank_mailing_lists where > query_id=499;NOTICE: QUERY PLAN: > > Aggregate (cost=6863.24..6863.24 rows=1 width=4) > -> Seq Scan on email_bank_mailing_lists (cost=0.00..6788.24 rows=30001 width=4) > > EXPLAIN -- Rod Taylor From pgsql-admin-owner@postgresql.org Fri Nov 1 08:03:47 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CF8D4475AE5 for ; Fri, 1 Nov 2002 08:03:45 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 5DDF4474E44 for ; Fri, 1 Nov 2002 08:03:42 -0500 (EST) Received: (qmail 23930 invoked from network); 1 Nov 2002 12:51:27 -0000 Received: from news1.trade-india.com (HELO www.trade-india.com) (130.94.20.27) by infocom-236-129-del.trade-india.com with SMTP; 1 Nov 2002 12:51:25 -0000 Received: (qmail 11215 invoked by uid 99); 1 Nov 2002 13:03:36 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Fri, 1 Nov 2002 18:33:36 +0530 (IST) Message-ID: <1062.203.145.130.142.1036155816.squirrel@mail.trade-india.com> Date: Fri, 1 Nov 2002 18:33:36 +0530 (IST) Subject: Re: [pgsql-performance] Is dump-reload the only cure? From: To: In-Reply-To: <1036155160.3550.8.camel@jester> References: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> <1036155160.3550.8.camel@jester> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: , , X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/5 X-Sequence-Number: 6193 Hi Rod , Does it means that index scan is used for less frequenlty occuring data? yes my table was not clustered. can u tell me what does 0.00..6788.24 and rows and width means? in explain out put cost=0.00..6788.24 rows=30001 width=4 I have one more table where i face the similar problem , i have not dump - reloaded it yet , will post again if i face the problem. thanks Regds Mallah. > On Fri, 2002-11-01 at 06:15, mallah@trade-india.com wrote: > > > Looks like a borderline case. See the costs of the index scan and sequential scan are very > similar. Since 499 covers nearly 1 in 10 tuples, it's likely found on nearly every page. This > should make a sequential scan much cheaper. > > However, if the data is clumped together (not distributed throughout the table) than an index > scan may be preferable. So... CLUSTER may be useful to you. > > In the future please 'explain analyze' the queries you're looking at to see actual costs as > compared to the estimated cost. > > >> 499 | 25010 >> 501 | 3318 >> >> >> before dump reload: >> tradein_clients=# VACUUM VERBOSE ANALYZE email_bank_mailing_lists; NOTICE: --Relation >> email_bank_mailing_lists-- >> NOTICE: Pages 3583: Changed 0, Empty 0; Tup 256419: Vac 0, Keep 0, UnUsed 44822. >> Total CPU 0.24s/0.04u sec elapsed 0.30 sec. >> NOTICE: Analyzing email_bank_mailing_lists >> VACUUM >> tradein_clients=# explain SELECT count( email_id ) from email_bank_mailing_lists where >> query_id=499;NOTICE: QUERY PLAN: >> >> Aggregate (cost=6863.24..6863.24 rows=1 width=4) >> -> Seq Scan on email_bank_mailing_lists (cost=0.00..6788.24 rows=30001 width=4) >> >> EXPLAIN > > -- > Rod Taylor ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/ From pgsql-admin-owner@postgresql.org Fri Nov 1 08:15:35 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2AC72475CA9 for ; Fri, 1 Nov 2002 08:15:34 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 7BE36475BEC for ; Fri, 1 Nov 2002 08:15:30 -0500 (EST) Received: (qmail 24048 invoked from network); 1 Nov 2002 13:03:12 -0000 Received: from news1.trade-india.com (HELO www.trade-india.com) (130.94.20.27) by infocom-236-129-del.trade-india.com with SMTP; 1 Nov 2002 13:03:12 -0000 Received: (qmail 11446 invoked by uid 99); 1 Nov 2002 13:15:22 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Fri, 1 Nov 2002 18:45:22 +0530 (IST) Message-ID: <1068.203.145.130.142.1036156522.squirrel@mail.trade-india.com> Date: Fri, 1 Nov 2002 18:45:22 +0530 (IST) Subject: Re: [pgsql-performance] Is dump-reload the only cure? From: To: In-Reply-To: <1036155160.3550.8.camel@jester> References: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> <1036155160.3550.8.camel@jester> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: , X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/6 X-Sequence-Number: 6194 Rod , Clustering did work for my other case ;-) tradein_clients=> explain analyze SELECT count(*) from email_source where source_id=173; NOTICE: QUERY PLAN: Aggregate (cost=13042.91..13042.91 rows=1 width=0) (actual time=1415.32..1415.32 rows=1 loops=1) -> Seq Scan on email_source (cost=0.00..12964.48 rows=31375 width=0) (actual time=1.19..1368.58 rows=32851 loops=1)Total runtime: 1415.42 msec EXPLAIN tradein_clients=> \d email_source Table "email_source" Column | Type | Modifiers -----------+---------+----------- email_id | integer | source_id | integer | Indexes: email_source_sid Unique keys: email_source_idx tradein_clients=> CLUSTER email_source_sid on email_source ; CLUSTER tradein_clients=> tradein_clients=> explain analyze SELECT count(*) from email_source where source_id=173; NOTICE: QUERY PLAN: Aggregate (cost=11458.83..11458.83 rows=1 width=0) (actual time=207.73..207.73 rows=1 loops=1) -> Index Scan using email_source_sid on email_source (cost=0.00..11449.76 rows=3627 width=0) (actual time=0.27..161.04 rows=32851 loops=1)Total runtime: 207.90 msec EXPLAIN Does it Mean that clustered indexes are guarrented to be used for index scan? one more thing does clustering means that all future data addition will happen in the ordered manner only i mean consecutively in terms of source_id? Regds MALLAH. > On Fri, 2002-11-01 at 06:15, mallah@trade-india.com wrote: > > > Looks like a borderline case. See the costs of the index scan and sequential scan are very > similar. Since 499 covers nearly 1 in 10 tuples, it's likely found on nearly every page. This > should make a sequential scan much cheaper. > > However, if the data is clumped together (not distributed throughout the table) than an index > scan may be preferable. So... CLUSTER may be useful to you. > > In the future please 'explain analyze' the queries you're looking at to see actual costs as > compared to the estimated cost. > > >> 499 | 25010 >> 501 | 3318 >> >> >> before dump reload: >> tradein_clients=# VACUUM VERBOSE ANALYZE email_bank_mailing_lists; NOTICE: --Relation >> email_bank_mailing_lists-- >> NOTICE: Pages 3583: Changed 0, Empty 0; Tup 256419: Vac 0, Keep 0, UnUsed 44822. >> Total CPU 0.24s/0.04u sec elapsed 0.30 sec. >> NOTICE: Analyzing email_bank_mailing_lists >> VACUUM >> tradein_clients=# explain SELECT count( email_id ) from email_bank_mailing_lists where >> query_id=499;NOTICE: QUERY PLAN: >> >> Aggregate (cost=6863.24..6863.24 rows=1 width=4) >> -> Seq Scan on email_bank_mailing_lists (cost=0.00..6788.24 rows=30001 width=4) >> >> EXPLAIN > > -- > Rod Taylor ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/ From pgsql-admin-owner@postgresql.org Fri Nov 1 13:11:58 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1A552474E53; Fri, 1 Nov 2002 09:07:05 -0500 (EST) Received: from jester.senspire.com (nat.inquent.com [216.6.14.45]) by postgresql.org (Postfix) with ESMTP id 6C1A1474E44; Fri, 1 Nov 2002 09:07:04 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gA1E7fI3005819; Fri, 1 Nov 2002 09:07:41 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: [pgsql-performance] Is dump-reload the only cure? From: Rod Taylor To: mallah@trade-india.com Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <1062.203.145.130.142.1036155816.squirrel@mail.trade-india.com> References: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> <1036155160.3550.8.camel@jester> <1062.203.145.130.142.1036155816.squirrel@mail.trade-india.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 01 Nov 2002 09:07:41 -0500 Message-Id: <1036159661.5794.0.camel@jester> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/21 X-Sequence-Number: 6209 See Paragraph 2 of the description section: http://www.postgresql.org/idocs/index.php?sql-explain.html In the above is a good explanation of 'cost'. Rows is the number of rows estimated to be returned, and width is the expected number of columns it needs to deal with at that point. On Fri, 2002-11-01 at 08:03, mallah@trade-india.com wrote: > > Hi Rod , > > Does it means that index scan is used for less frequenlty occuring data? > yes my table was not clustered. > > can u tell me what does 0.00..6788.24 and rows and width means? > > in explain out put cost=0.00..6788.24 rows=30001 width=4 > > > I have one more table where i face the similar problem , i have not dump - reloaded > it yet , will post again if i face the problem. > > > thanks > > Regds > Mallah. > > > > On Fri, 2002-11-01 at 06:15, mallah@trade-india.com wrote: > > > > > > Looks like a borderline case. See the costs of the index scan and sequential scan are very > > similar. Since 499 covers nearly 1 in 10 tuples, it's likely found on nearly every page. This > > should make a sequential scan much cheaper. > > > > However, if the data is clumped together (not distributed throughout the table) than an index > > scan may be preferable. So... CLUSTER may be useful to you. > > > > In the future please 'explain analyze' the queries you're looking at to see actual costs as > > compared to the estimated cost. > > > > > >> 499 | 25010 > >> 501 | 3318 > >> > >> > >> before dump reload: > >> tradein_clients=# VACUUM VERBOSE ANALYZE email_bank_mailing_lists; NOTICE: --Relation > >> email_bank_mailing_lists-- > >> NOTICE: Pages 3583: Changed 0, Empty 0; Tup 256419: Vac 0, Keep 0, UnUsed 44822. > >> Total CPU 0.24s/0.04u sec elapsed 0.30 sec. > >> NOTICE: Analyzing email_bank_mailing_lists > >> VACUUM > >> tradein_clients=# explain SELECT count( email_id ) from email_bank_mailing_lists where > >> query_id=499;NOTICE: QUERY PLAN: > >> > >> Aggregate (cost=6863.24..6863.24 rows=1 width=4) > >> -> Seq Scan on email_bank_mailing_lists (cost=0.00..6788.24 rows=30001 width=4) > >> > >> EXPLAIN > > > > -- > > Rod Taylor > > > > ----------------------------------------- > Get your free web based email at trade-india.com. > "India's Leading B2B eMarketplace.!" > http://www.trade-india.com/ > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > -- Rod Taylor From pgsql-admin-owner@postgresql.org Fri Nov 1 13:11:59 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DCB55474E53; Fri, 1 Nov 2002 09:10:26 -0500 (EST) Received: from jester.senspire.com (nat.inquent.com [216.6.14.45]) by postgresql.org (Postfix) with ESMTP id 4CD6E474E44; Fri, 1 Nov 2002 09:10:26 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gA1EB3I3005829; Fri, 1 Nov 2002 09:11:03 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: [pgsql-performance] Is dump-reload the only cure? From: Rod Taylor To: mallah@trade-india.com Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <1062.203.145.130.142.1036155816.squirrel@mail.trade-india.com> References: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> <1036155160.3550.8.camel@jester> <1062.203.145.130.142.1036155816.squirrel@mail.trade-india.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 01 Nov 2002 09:11:03 -0500 Message-Id: <1036159864.5794.5.camel@jester> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/22 X-Sequence-Number: 6210 On Fri, 2002-11-01 at 08:03, mallah@trade-india.com wrote: > > Hi Rod , > > Does it means that index scan is used for less frequenlty occuring data? > yes my table was not clustered. > > can u tell me what does 0.00..6788.24 and rows and width means? > > in explain out put cost=0.00..6788.24 rows=30001 width=4 > > > I have one more table where i face the similar problem , i have not dump - reloaded > it yet , will post again if i face the problem. Keep in mind that an index scan is very expensive in regards to a single tuple. It has to run through (fetch) the index pages, then fetch the pages from the table. Since the table fetches are random, the harddrive will probably incur a seek for each tuple found in the index. The seeks add up much quicker than a sequential scan (without nearly as many seeks or drive head movements). -- Rod Taylor From pgsql-performance-owner@postgresql.org Fri Nov 1 09:38:17 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2F1724762AD for ; Fri, 1 Nov 2002 09:38:15 -0500 (EST) Received: from jester.senspire.com (nat.inquent.com [216.6.14.45]) by postgresql.org (Postfix) with ESMTP id BF465475F2B for ; Fri, 1 Nov 2002 09:38:13 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gA1EcpI3005913; Fri, 1 Nov 2002 09:38:51 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: Is dump-reload the only cure? From: Rod Taylor To: mallah@trade-india.com Cc: pgsql-performance@postgresql.org In-Reply-To: <1068.203.145.130.142.1036156522.squirrel@mail.trade-india.com> References: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> <1036155160.3550.8.camel@jester> <1068.203.145.130.142.1036156522.squirrel@mail.trade-india.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 01 Nov 2002 09:38:51 -0500 Message-Id: <1036161531.5794.18.camel@jester> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/7 X-Sequence-Number: 165 > Does it Mean that clustered indexes are guarrented to be used for index scan? > one more thing does clustering means that all future data addition will happen > in the ordered manner only i mean consecutively in terms of source_id? No, but clustering a table allows an index scan to visit less pages, and make less disk seeks. This in turn makes it a better choice for some queries due to the current layout of tuples on the disk. However, there are new borderline cases -- just in different places than before. -- Rod Taylor From pgsql-admin-owner@postgresql.org Fri Nov 1 09:41:32 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F0AE3475DAD for ; Fri, 1 Nov 2002 09:41:29 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 5E2A1474E44 for ; Fri, 1 Nov 2002 09:41:26 -0500 (EST) Received: (qmail 24976 invoked from network); 1 Nov 2002 14:29:11 -0000 Received: from news1.trade-india.com (HELO www.trade-india.com) (130.94.20.27) by infocom-236-129-del.trade-india.com with SMTP; 1 Nov 2002 14:29:11 -0000 Received: (qmail 13345 invoked by uid 99); 1 Nov 2002 14:41:22 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Fri, 1 Nov 2002 20:11:22 +0530 (IST) Message-ID: <1040.203.145.130.142.1036161682.squirrel@mail.trade-india.com> Date: Fri, 1 Nov 2002 20:11:22 +0530 (IST) Subject: Re: [pgsql-performance] Is dump-reload the only cure? From: To: In-Reply-To: <1036159864.5794.5.camel@jester> References: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> <1036155160.3550.8.camel@jester> <1062.203.145.130.142.1036155816.squirrel@mail.trade-india.com> <1036159864.5794.5.camel@jester> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: , X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/8 X-Sequence-Number: 6196 Thanks for the insight Rod. is there any other place i can know more abt these principles? But if the table is clustered then the pages are stored catagiously with respect to that column rite? > On Fri, 2002-11-01 at 08:03, mallah@trade-india.com wrote: >> >> Hi Rod , >> >> Does it means that index scan is used for less frequenlty occuring data? yes my table was not >> clustered. >> >> can u tell me what does 0.00..6788.24 and rows and width means? >> >> in explain out put cost=0.00..6788.24 rows=30001 width=4 >> >> >> I have one more table where i face the similar problem , i have not dump - reloaded it yet , >> will post again if i face the problem. > > Keep in mind that an index scan is very expensive in regards to a single tuple. It has to run > through (fetch) the index pages, then fetch the pages from the table. Since the table fetches > are random, the harddrive will probably incur a seek for each tuple found in the index. The > seeks add up much quicker than a sequential scan (without nearly as many seeks or drive head > movements). > > -- > Rod Taylor ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/ From pgsql-admin-owner@postgresql.org Fri Nov 1 14:54:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C8C30476E3E; Fri, 1 Nov 2002 14:54:08 -0500 (EST) Received: from briar.mmrd.com (unknown [208.255.226.182]) by postgresql.org (Postfix) with ESMTP id 7F7FA476DF2; Fri, 1 Nov 2002 14:54:06 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by briar.mmrd.com (8.11.2/8.11.2) with ESMTP id gA1JnSv18493; Fri, 1 Nov 2002 14:49:28 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id gA1Js6R25715; Fri, 1 Nov 2002 14:54:06 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 49KV8A10; Fri, 1 Nov 2002 14:54:04 -0500 Subject: Re: [pgsql-performance] Is dump-reload the only cure? From: Robert Treat To: mallah@trade-india.com Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> References: <1584.203.145.130.142.1036149343.squirrel@mail.trade-india.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 01 Nov 2002 14:54:05 -0500 Message-Id: <1036180445.20463.22.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/28 X-Sequence-Number: 6216 On Fri, 2002-11-01 at 06:15, mallah@trade-india.com wrote: > tradein_clients=# VACUUM VERBOSE ANALYZE email_bank_mailing_lists; > NOTICE: --Relation email_bank_mailing_lists-- > NOTICE: Pages 3583: Changed 0, Empty 0; Tup 256419: Vac 0, Keep 0, UnUsed 44822. > Total CPU 0.24s/0.04u sec elapsed 0.30 sec. > NOTICE: Analyzing email_bank_mailing_lists > VACUUM I'd suggest running a vacuum full and then running vacuum analyze more often. 44822 unused tuples seems quite excessive to me... Robert Treat From pgsql-performance-owner@postgresql.org Fri Nov 1 15:18:06 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4CA14476195 for ; Fri, 1 Nov 2002 15:18:05 -0500 (EST) Received: from mta4.snet.net (mta4.snet.net [204.60.203.76]) by postgresql.org (Postfix) with ESMTP id 9E3D8475FDD for ; Fri, 1 Nov 2002 15:18:04 -0500 (EST) Received: from pop.snet.net (pop.snet.net [204.60.203.72]) by mta4.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gA1KHeUm005175 for ; Fri, 1 Nov 2002 15:17:40 -0500 (EST) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gA1KHpH8026296 for ; Fri, 1 Nov 2002 15:17:52 -0500 (EST) Subject: Does this matter? From: Wei Weng To: pgsql-performance@postgresql.org Content-Type: text/plain Organization: Message-Id: <1036181881.24810.1.camel@Monet> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.1.90 (Preview Release) Date: 01 Nov 2002 15:18:01 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/10 X-Sequence-Number: 168 Does it make a performance difference if I use a char(20) or a char(36) as the primary key? My thought is no, but I would like to hear more opinions. And a little further off topic(since we have many database experts here), does it matter on MS SQL server 7? Thanks! -- Wei Weng Network Software Engineer KenCast Inc. From pgsql-performance-owner@postgresql.org Fri Nov 1 15:24:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EFFF7476CE7 for ; Fri, 1 Nov 2002 15:24:01 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id F2CDB476D76 for ; Fri, 1 Nov 2002 15:23:59 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1808698; Fri, 01 Nov 2002 12:26:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Wei Weng , pgsql-performance@postgresql.org Subject: Re: Does this matter? Date: Fri, 1 Nov 2002 12:23:48 -0800 X-Mailer: KMail [version 1.4] References: <1036181881.24810.1.camel@Monet> In-Reply-To: <1036181881.24810.1.camel@Monet> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211011223.48962.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/11 X-Sequence-Number: 169 Wei, > Does it make a performance difference if I use a char(20) or a char(36) > as the primary key? My thought is no, but I would like to hear more > opinions. Yes, it does, though probably minor unless you have millions of records. C= HAR=20 is padded out to the specified length. Therefore the index on a char(36)= =20 column will be a little larger, and thus a little slower, than the char(20)= .=20=20 Now, there would be no difference between VARCHAR(20) and VARCHAR(36) unles= s=20 you used some of the extra 16 characters on most rows. Either way, for tables of a few thousand records, I doubt that you'll notic= e=20 the difference. BTW, why not use a SERIAL value as a surrogate primary ke= y? > And a little further off topic(since we have many database experts > here), does it matter on MS SQL server 7? Yes, same reason. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 1 15:52:31 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CD90D476EFF for ; Fri, 1 Nov 2002 15:52:30 -0500 (EST) Received: from mta4.snet.net (mta4.snet.net [204.60.203.76]) by postgresql.org (Postfix) with ESMTP id 16A6D476EAF for ; Fri, 1 Nov 2002 15:52:30 -0500 (EST) Received: from pop.snet.net ([204.60.203.73]) by mta4.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gA1Kq1Um019959; Fri, 1 Nov 2002 15:52:01 -0500 (EST) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gA1KqCH8023385; Fri, 1 Nov 2002 15:52:16 -0500 (EST) Subject: Re: Does this matter? From: Wei Weng To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org In-Reply-To: <200211011223.48962.josh@agliodbs.com> References: <1036181881.24810.1.camel@Monet> <200211011223.48962.josh@agliodbs.com> Content-Type: text/plain Organization: Message-Id: <1036183942.25096.3.camel@Monet> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.1.90 (Preview Release) Date: 01 Nov 2002 15:52:22 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/12 X-Sequence-Number: 170 Josh: Since I need to use a GUID as the primary key, I have to use the char datatype. On Fri, 2002-11-01 at 15:23, Josh Berkus wrote: > Wei, > > > Does it make a performance difference if I use a char(20) or a char(36) > > as the primary key? My thought is no, but I would like to hear more > > opinions. > > Yes, it does, though probably minor unless you have millions of records. CHAR > is padded out to the specified length. Therefore the index on a char(36) > column will be a little larger, and thus a little slower, than the char(20). Does it affect the INSERT/UPDATE/DELETE operations on tables or simply the SELECT operation or both? > > Now, there would be no difference between VARCHAR(20) and VARCHAR(36) unless > you used some of the extra 16 characters on most rows. > > Either way, for tables of a few thousand records, I doubt that you'll notice > the difference. BTW, why not use a SERIAL value as a surrogate primary key? > > > And a little further off topic(since we have many database experts > > here), does it matter on MS SQL server 7? > > Yes, same reason. -- Wei Weng Network Software Engineer KenCast Inc. From pgsql-performance-owner@postgresql.org Fri Nov 1 15:53:41 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 19533475F1A for ; Fri, 1 Nov 2002 15:53:41 -0500 (EST) Received: from cypress.adhesivemedia.com (cypress.adhesivemedia.com [207.202.159.72]) by postgresql.org (Postfix) with ESMTP id 64BEB475EBD for ; Fri, 1 Nov 2002 15:53:40 -0500 (EST) Received: from cypress.adhesivemedia.com (localhost [127.0.0.1]) by cypress.adhesivemedia.com (8.12.3/8.12.3) with ESMTP id gA1KrTFk009850; Fri, 1 Nov 2002 12:53:29 -0800 (PST) (envelope-from philip@adhesivemedia.com) Received: from localhost (philip@localhost) by cypress.adhesivemedia.com (8.12.3/8.12.3/Submit) with ESMTP id gA1KrTCq009847; Fri, 1 Nov 2002 12:53:29 -0800 (PST) X-Authentication-Warning: cypress.adhesivemedia.com: philip owned process doing -bs Date: Fri, 1 Nov 2002 12:53:29 -0800 (PST) From: Philip Hallstrom To: Josh Berkus Cc: Wei Weng , Subject: Re: Does this matter? In-Reply-To: <200211011223.48962.josh@agliodbs.com> Message-ID: <20021101125052.Y6303-100000@cypress.adhesivemedia.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/13 X-Sequence-Number: 171 > Wei, > > > Does it make a performance difference if I use a char(20) or a char(36) > > as the primary key? My thought is no, but I would like to hear more > > opinions. > > Yes, it does, though probably minor unless you have millions of records. CHAR > is padded out to the specified length. Therefore the index on a char(36) > column will be a little larger, and thus a little slower, than the char(20). > Really? According to this url (search for "Tip") there is no performance difference just a space difference. I don't know for sure either way, but if there is a difference the manual needs updating. http://www.postgresql.org/idocs/index.php?datatype-character.html -philip From pgsql-performance-owner@postgresql.org Fri Nov 1 16:10:58 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7052B474E44 for ; Fri, 1 Nov 2002 16:10:57 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id CF4BE474E53 for ; Fri, 1 Nov 2002 16:10:55 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 187j4D-0004oY-00 for ; Fri, 01 Nov 2002 16:10:57 -0500 Date: Fri, 1 Nov 2002 16:10:57 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Does this matter? Message-ID: <20021101161057.V5799@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <200211011223.48962.josh@agliodbs.com> <20021101125052.Y6303-100000@cypress.adhesivemedia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20021101125052.Y6303-100000@cypress.adhesivemedia.com>; from philip@adhesivemedia.com on Fri, Nov 01, 2002 at 12:53:29PM -0800 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/14 X-Sequence-Number: 172 On Fri, Nov 01, 2002 at 12:53:29PM -0800, Philip Hallstrom wrote: > > is padded out to the specified length. Therefore the index on a char(36) > > column will be a little larger, and thus a little slower, than the char(20). > > > > Really? According to this url (search for "Tip") there is no performance > difference just a space difference. I don't know for sure either way, but > if there is a difference the manual needs updating. Hmm. Maybe a clarification, but I don't think this is quite what the tip is talking about. The tip points out that part of the cost is "the increased storage" from the blank-padded type (char) as contrasted with non-padded types (like text). The tip isn't talking about whether a length of 20 is faster than a length of 36. Anyway, I can't really believe the length would be a big deal except on really huge tables. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Nov 1 17:00:23 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BF630476D56 for ; Fri, 1 Nov 2002 17:00:20 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id E786B476C72 for ; Fri, 1 Nov 2002 17:00:18 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1808822; Fri, 01 Nov 2002 14:02:36 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Philip Hallstrom Subject: Re: Does this matter? Date: Fri, 1 Nov 2002 14:00:09 -0800 X-Mailer: KMail [version 1.4] Cc: Wei Weng , References: <20021101125052.Y6303-100000@cypress.adhesivemedia.com> In-Reply-To: <20021101125052.Y6303-100000@cypress.adhesivemedia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211011400.09915.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/15 X-Sequence-Number: 173 Phillip, > Really? According to this url (search for "Tip") there is no performance > difference just a space difference. I don't know for sure either way, but > if there is a difference the manual needs updating. >=20 > http://www.postgresql.org/idocs/index.php?datatype-character.html Actually, that note is intended to tell people that CHAR is not any faster= =20 than VARCHAR for the same-length string ... since CHAR *is* faster than=20 VARCHAR in some systems, like MS SQL Server. --=20 -Josh Berkus From pgsql-performance-owner@postgresql.org Fri Nov 1 17:00:23 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8824C476D76 for ; Fri, 1 Nov 2002 17:00:21 -0500 (EST) Received: from acorn.he.net (acorn.he.net [64.71.137.130]) by postgresql.org (Postfix) with ESMTP id 479E6476D54 for ; Fri, 1 Nov 2002 17:00:20 -0500 (EST) Received: from CurtisVaio ([63.164.0.45] (may be forged)) by acorn.he.net (8.8.6/8.8.2) with SMTP id OAA13101; Fri, 1 Nov 2002 14:00:17 -0800 From: "Curtis Faith" To: "Andrew Sullivan" Cc: Subject: Re: Does this matter? Date: Fri, 1 Nov 2002 18:00:19 -0400 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 In-Reply-To: <20021101161057.V5799@mail.libertyrms.com> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/16 X-Sequence-Number: 174 Andrew Sullivan wrote: > Hmm. Maybe a clarification, but I don't think this is quite what the > tip is talking about. The tip points out that part of the cost is > "the increased storage" from the blank-padded type (char) as > contrasted with non-padded types (like text). The tip isn't talking > about whether a length of 20 is faster than a length of 36. Anyway, > I can't really believe the length would be a big deal except on > really huge tables. It really depends on the access. I spend quite a bit of time optimizing database internals and the size of an index matters much more than is apparent in certain cases. This is especially true for medium sized tables. The real issue is the number of reads required to find a particular entry in the index. Assume a btree that tries to be 70% full. Assume 40 bytes for a header, 8 bytes overhead per index entry and an 8K btree page. The following represents the number of index entries that can be contained in both a two level and a three level btree. Type Bytes Items per page 2 3 ---- ------ ----- ------ ---------- char(36) 40 129 16,641 2,146,689 char(20) 24 203 41,209 8,365,427 Depending on the size of the table, the number of pages in the btree affect performance in two separate ways: 1) Cache hit ratio - This greatly depends on the way the tables are accessed but more densely packed btree indices are used more often and more likely to be present in a cache than less densely packed indices. 2) I/O time - If the number of items reaches a particular size then the btree will add an additional level which could result in a very expensive I/O operation per access. How this affects performance depends very specifically on the way the index is used. The problem is not necessarily the size of the table but the transitions in numbers of levels in the btree. For a table size of 200 to 15,000 tuples, there won't be a major difference. For a table size of 25,000 to 40,000 tuples, and assuming the root page is cached, an index lookup can be twice as fast with a char(20) as it is for a char(36) because in the one case a two-level btree handles the table while a three-level btree is needed for the other. This won't typically affect multi-user throughput as much since other backends will be working while the I/O's are waiting but it might affect the performance as seen from a single client. - Curtis From pgsql-performance-owner@postgresql.org Fri Nov 1 17:01:22 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8CEAB4761D4 for ; Fri, 1 Nov 2002 17:01:21 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id C45F94761D0 for ; Fri, 1 Nov 2002 17:01:20 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1808821; Fri, 01 Nov 2002 14:03:38 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Wei Weng Subject: Re: Does this matter? Date: Fri, 1 Nov 2002 14:01:11 -0800 X-Mailer: KMail [version 1.4] Cc: pgsql-performance@postgresql.org References: <1036181881.24810.1.camel@Monet> <200211011223.48962.josh@agliodbs.com> <1036183942.25096.3.camel@Monet> In-Reply-To: <1036183942.25096.3.camel@Monet> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211011401.11270.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/17 X-Sequence-Number: 175 Wei, > Does it affect the INSERT/UPDATE/DELETE operations on tables or simply > the SELECT operation or both? All of the above. How many rows are we talking about, anyway? The differe= nce=20 may be academic. --=20 -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco From pgsql-performance-owner@postgresql.org Sun Nov 3 23:08:15 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8CD08475C85 for ; Sun, 3 Nov 2002 23:08:14 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 1E4CC475BA0 for ; Sun, 3 Nov 2002 23:08:14 -0500 (EST) Received: from tokyo.samurai.com (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id DBC1F1F2E; Sun, 3 Nov 2002 23:08:17 -0500 (EST) To: Wei Weng Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Does this matter? References: <1036181881.24810.1.camel@Monet> <200211011223.48962.josh@agliodbs.com> <1036183942.25096.3.camel@Monet> From: Neil Conway In-Reply-To: <1036183942.25096.3.camel@Monet> Date: 03 Nov 2002 23:08:17 -0500 Message-ID: <87d6pmyo26.fsf@mailbox.samurai.com> Lines: 14 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/18 X-Sequence-Number: 176 Wei Weng writes: > Since I need to use a GUID as the primary key, I have to use the char > datatype. Try uniqueidentifier: http://archives.postgresql.org/pgsql-announce/2002-07/msg00001.php Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-sql-owner@postgresql.org Sun Nov 3 23:33:04 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D72CC475C85 for ; Sun, 3 Nov 2002 23:33:03 -0500 (EST) Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) by postgresql.org (Postfix) with ESMTP id 587D0475BA0 for ; Sun, 3 Nov 2002 23:33:03 -0500 (EST) Received: from PASCAL.kencast.com (p67-47.acedsl.com [66.114.67.47]) by mail1.acecape.com (8.12.2/8.12.2) with ESMTP id gA44X7t2006645 for ; Sun, 3 Nov 2002 23:33:08 -0500 Message-Id: <5.1.1.6.0.20021103233223.00bcfcd8@mail.futuris.net> X-Sender: wweng@mail.futuris.net X-Mailer: QUALCOMM Windows Eudora Version 5.1.1 Date: Sun, 03 Nov 2002 23:33:18 -0500 To: pgsql-sql From: Wei Weng Subject: Re: [PERFORM] Does this matter? In-Reply-To: <87d6pmyo26.fsf@mailbox.samurai.com> References: <1036183942.25096.3.camel@Monet> <1036181881.24810.1.camel@Monet> <200211011223.48962.josh@agliodbs.com> <1036183942.25096.3.camel@Monet> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/40 X-Sequence-Number: 10182 Thanks, I noticed that sweet addon and will try to integrate it into our system once 7.3 is officially released. :) btw, do we have a release date yet? Thanks Wei At 11:08 PM 11/3/2002 -0500, you wrote: >Wei Weng writes: > > Since I need to use a GUID as the primary key, I have to use the char > > datatype. > >Try uniqueidentifier: > > http://archives.postgresql.org/pgsql-announce/2002-07/msg00001.php > >Cheers, > >Neil > >-- >Neil Conway || PGP Key ID: DB3C29FC > > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > >http://www.postgresql.org/users-lounge/docs/faq.html From pgsql-general-owner@postgresql.org Sat Nov 9 07:33:39 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 47461475956 for ; Sat, 9 Nov 2002 07:33:37 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 0D5AA4758E1 for ; Sat, 9 Nov 2002 07:33:36 -0500 (EST) Received: from mail.topconcepts.net (62.226.215.26) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Sat, 09 Nov 2002 13:33:30 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Sat, 09 Nov 2002 13:33:35 +0100 Message-ID: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Subject: Upgrade to dual processor machine? Date: Sat, 9 Nov 2002 13:32:53 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/423 X-Sequence-Number: 32844 hi all, will an upgrade to a dual processor machine noticeably increase performance of a postgresql server? load average now often is about 4.0 - 8.5 - and I'll have got to do something sooner or later... any help is appreciated... -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- From pgsql-general-owner@postgresql.org Sat Nov 9 07:50:35 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BEE39475425 for ; Sat, 9 Nov 2002 07:50:33 -0500 (EST) Received: from new-smtp1.ihug.com.au (new-smtp1.ihug.com.au [203.109.250.27]) by postgresql.org (Postfix) with ESMTP id 2BA6A474E61 for ; Sat, 9 Nov 2002 07:50:33 -0500 (EST) Received: from p156-tnt1.mel.ihug.com.au (postgresql.org) [203.173.160.156] by new-smtp1.ihug.com.au with esmtp (Exim 3.22 #1 (Debian)) id 18AV4S-0007pL-00; Sat, 09 Nov 2002 23:50:40 +1100 Message-ID: <3DCD049D.1CE7D82C@postgresql.org> Date: Sat, 09 Nov 2002 23:50:37 +1100 From: Justin Clift X-Mailer: Mozilla 4.8 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Henrik Steffen Cc: pgsql-general@postgresql.org Subject: Re: Upgrade to dual processor machine? References: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/424 X-Sequence-Number: 32845 Hi Henrik, It'd be helpful to know the other specifics of the server, and a bit about the workload the server has. i.e. - Processor type and speed - Memory - Disk configuration - OS - Do you do other stuff on it, apart from PostgreSQL? - How many clients simultaneously connecting to it? - What do the clients connect with? JDBC/ODBC/libpq/etc? - Have you configured the memory after installation of PostgreSQL, so it's better optimised than the defaults? :-) Regards and best wishes, Justin Clift Henrik Steffen wrote: > > hi all, > > will an upgrade to a dual processor machine > noticeably increase performance of a postgresql server? > > load average now often is about 4.0 - 8.5 - and I'll > have got to do something sooner or later... > > any help is appreciated... > > -- > > Mit freundlichem Gru� > > Henrik Steffen > Gesch�ftsf�hrer > > top concepts Internetmarketing GmbH > Am Steinkamp 7 - D-21684 Stade - Germany > -------------------------------------------------------- > http://www.topconcepts.com Tel. +49 4141 991230 > mail: steffen@topconcepts.com Fax. +49 4141 991233 > -------------------------------------------------------- > 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) > -------------------------------------------------------- > Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de > System-Partner gesucht: http://www.franchise.city-map.de > -------------------------------------------------------- > Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 > -------------------------------------------------------- > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi From pgsql-general-owner@postgresql.org Sat Nov 9 13:56:25 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 684C74758FE for ; Sat, 9 Nov 2002 13:56:23 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id D935C4758DC for ; Sat, 9 Nov 2002 13:56:22 -0500 (EST) Received: from tokyo.samurai.com (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 624B01D5D; Sat, 9 Nov 2002 13:56:34 -0500 (EST) To: "Henrik Steffen" Cc: Subject: Re: Upgrade to dual processor machine? References: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> From: Neil Conway In-Reply-To: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> Date: 09 Nov 2002 13:56:33 -0500 Message-ID: <87r8dua7xa.fsf@mailbox.samurai.com> Lines: 15 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/430 X-Sequence-Number: 32851 "Henrik Steffen" writes: > will an upgrade to a dual processor machine > noticeably increase performance of a postgresql server? Assuming you have more than 1 concurrent client, it likely will. Whether it will be a huge performance improvement depends on the other characteristics of the workload (e.g. is it I/O bound or CPU bound?). Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-general-owner@postgresql.org Mon Nov 11 02:06:24 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F33DD475B07 for ; Mon, 11 Nov 2002 02:06:22 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id C2B09475A3F for ; Mon, 11 Nov 2002 02:06:21 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.230) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Mon, 11 Nov 2002 08:06:00 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Mon, 11 Nov 2002 08:02:54 +0100 Message-ID: <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Justin Clift" , References: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> <3DCD049D.1CE7D82C@postgresql.org> Subject: Re: Upgrade to dual processor machine? Date: Mon, 11 Nov 2002 08:05:27 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/448 X-Sequence-Number: 32869 Hi Justin, here a little more information: > - Processor type and speed Intel Pentium IV, 1.6 GHz > - Memory 1024 MB ECC-RAM > - Disk configuration 2 x 60 GB IDE (Raid 0) > - OS Redhat Linux > > - Do you do other stuff on it, apart from PostgreSQL? No, it's a dedicated database server > > - How many clients simultaneously connecting to it? one webserver with max. 50 instances, approximately 10.000 users a day, about 150.000 Pageviews daily. All pages are created on the fly using mod_perl connecting to the db-server. > - What do the clients connect with? JDBC/ODBC/libpq/etc? I am using Pg.pm --- this is called libpq, isn't it? > - Have you configured the memory after installation of PostgreSQL, so > it's better optimised than the defaults? no - what should I do? Looking at 'top' right now, I see the following: Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff So, what do you suggest to gain more performance? Thanks in advance, > Hi Henrik, > > It'd be helpful to know the other specifics of the server, and a bit > about the workload the server has. > > i.e. > > - Processor type and speed > - Memory > - Disk configuration > - OS > > - Do you do other stuff on it, apart from PostgreSQL? > > - How many clients simultaneously connecting to it? > - What do the clients connect with? JDBC/ODBC/libpq/etc? > > - Have you configured the memory after installation of PostgreSQL, so > it's better optimised than the defaults? > > :-) > > Regards and best wishes, > > Justin Clift > > > Henrik Steffen wrote: > > > > hi all, > > > > will an upgrade to a dual processor machine > > noticeably increase performance of a postgresql server? > > > > load average now often is about 4.0 - 8.5 - and I'll > > have got to do something sooner or later... > > > > any help is appreciated... > > > > -- > > > > Mit freundlichem Gru� > > > > Henrik Steffen > > Gesch�ftsf�hrer > > > > top concepts Internetmarketing GmbH > > Am Steinkamp 7 - D-21684 Stade - Germany > > -------------------------------------------------------- > > http://www.topconcepts.com Tel. +49 4141 991230 > > mail: steffen@topconcepts.com Fax. +49 4141 991233 > > -------------------------------------------------------- > > 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) > > -------------------------------------------------------- > > Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de > > System-Partner gesucht: http://www.franchise.city-map.de > > -------------------------------------------------------- > > Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 > > -------------------------------------------------------- > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > -- > "My grandfather once told me that there are two kinds of people: those > who work and those who take the credit. He told me to try to be in the > first group; there was less competition there." > - Indira Gandhi From pgsql-general-owner@postgresql.org Mon Nov 11 02:32:53 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C41E8475A3F; Mon, 11 Nov 2002 02:32:52 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 5968C47580B; Mon, 11 Nov 2002 02:32:52 -0500 (EST) Received: from tokyo.samurai.com (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 5706B1D5D; Mon, 11 Nov 2002 02:32:52 -0500 (EST) To: "Henrik Steffen" Cc: "Justin Clift" , Subject: Re: Upgrade to dual processor machine? References: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> <3DCD049D.1CE7D82C@postgresql.org> <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> From: Neil Conway In-Reply-To: <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> Date: 11 Nov 2002 02:32:43 -0500 Message-ID: <87y980tvc4.fsf@mailbox.samurai.com> Lines: 29 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/449 X-Sequence-Number: 32870 "Henrik Steffen" writes: > > - What do the clients connect with? JDBC/ODBC/libpq/etc? > I am using Pg.pm --- this is called libpq, isn't it? Well, it's a thin Perl wrapper over libpq (which is the C client API). You said you're using mod_perl: you may wish to consider using DBI and DBD::Pg instead of Pg.pm, so you can make use of persistent connections using Apache::DBI. > > - Have you configured the memory after installation of PostgreSQL, so > > it's better optimised than the defaults? > no - what should I do? Looking at 'top' right now, I see the following: > Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff No, Justin is referring to the memory-related configuration options in postgresql.conf, like shared_buffers, wal_buffers, sort_mem, and the like. > So, what do you suggest to gain more performance? IMHO, dual processors would likely be a good performance improvement. Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-general-owner@postgresql.org Mon Nov 11 02:44:29 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 98586475A3F for ; Mon, 11 Nov 2002 02:44:28 -0500 (EST) Received: from new-smtp1.ihug.com.au (new-smtp1.ihug.com.au [203.109.250.27]) by postgresql.org (Postfix) with ESMTP id 0931947580B for ; Mon, 11 Nov 2002 02:44:28 -0500 (EST) Received: from p389-tnt2.mel.ihug.com.au (postgresql.org) [203.173.165.135] by new-smtp1.ihug.com.au with esmtp (Exim 3.22 #1 (Debian)) id 18B9FC-0007J7-00; Mon, 11 Nov 2002 18:44:27 +1100 Message-ID: <3DCF5FD8.39F41505@postgresql.org> Date: Mon, 11 Nov 2002 18:44:24 +1100 From: Justin Clift X-Mailer: Mozilla 4.8 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Henrik Steffen Cc: pgsql-general@postgresql.org Subject: Re: Upgrade to dual processor machine? References: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> <3DCD049D.1CE7D82C@postgresql.org> <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/450 X-Sequence-Number: 32871 Hi Henrik, Ok, you're machine is doing a decent amount of work, and will need looking at carefully. Going to get more specific about some stuff, as it'll definitely assist with giving you proper guidance here. - Have you run any system-performance tools apart from top, to figure out how the various parts of your system are operating? For example, by looking into and measuring the different parts of your system, you may find you have several processes simultaneously waiting to execute purely because the disk drives can't keep up with the requests. The solution may turn out to be upgrading your disks instead of your CPU's (example only). Without taking measurements to the point of understanding what's going on, you'll only be guessing. The most concerning aspect at the moment is this: "> - Have you configured the memory after installation of PostgreSQL, so > it's better optimised than the defaults? no - what should I do? Looking at 'top' right now, I see the following: Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff" This is telling me that the system is operating close to using all it's memory with running processes. *Bad* for this kind of thing. The default memory configuration for PostgreSQL is very lean and causes high CPU load and slow throughput. You don't seem to have enough spare memory at the moment to really try adjusting this upwards. :( Important question, how much memory can you get into that server? Could you do 3GB or more? Something that would be *really nice* is if you have a second server with the same configuration hanging around that you can try stuff on. For example, loading it with a copy of all your data, changing the memory configuration, then testing it. Further system specific details needed: - Which version of the Linux kernel, and of RedHat? Different version of the Linux kernel do things differently. For example version 2.4.3 does virtual memory differently than say version 2.4.17. - If you do a ps (ps -ef) during a busy time, how many instances of the PostgreSQL process do you see in memory? This will tell you how many clients have an open connection to the database at any time. - How much data is in your database(s)? Just to get an idea of your volume of data. - If disk performance turns out to be the problem, would you consider moving to higher-end hard drives? This will probably mean an Ultra160 or Ultra320 SCSI card, and drives to match. That's not going to be totally cheap, but if you have a decent budget then it might be ok. As you can see, this could take a bit of time an effort to get right. Regards and best wishes, Justin Clift Henrik Steffen wrote: > > Hi Justin, > > here a little more information: > > > - Processor type and speed > Intel Pentium IV, 1.6 GHz > > > - Memory > 1024 MB ECC-RAM > > > - Disk configuration > 2 x 60 GB IDE (Raid 0) > > > - OS > Redhat Linux > > > > > - Do you do other stuff on it, apart from PostgreSQL? > No, it's a dedicated database server > > > > > - How many clients simultaneously connecting to it? > one webserver with max. 50 instances, approximately 10.000 users a day, > about 150.000 Pageviews daily. All pages are created on the fly using > mod_perl connecting to the db-server. > > > - What do the clients connect with? JDBC/ODBC/libpq/etc? > I am using Pg.pm --- this is called libpq, isn't it? > > > - Have you configured the memory after installation of PostgreSQL, so > > it's better optimised than the defaults? > no - what should I do? Looking at 'top' right now, I see the following: > Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff > > So, what do you suggest to gain more performance? > > Thanks in advance, -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi From pgsql-performance-owner@postgresql.org Mon Nov 11 05:08:10 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5D865475A3F for ; Mon, 11 Nov 2002 05:08:08 -0500 (EST) Received: from head.netsystem.cz (head.netsystem.cz [194.212.169.67]) by postgresql.org (Postfix) with ESMTP id AE956475921 for ; Mon, 11 Nov 2002 05:08:07 -0500 (EST) Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1]) by head.netsystem.cz (Postfix) with SMTP id 2D1A18FA6 for ; Mon, 11 Nov 2002 11:08:09 +0100 (CET) Received: from netsystem.cz (novakji.netsystem.cz [192.168.200.24]) by head.netsystem.cz (Postfix) with ESMTP id 11A3F886B for ; Mon, 11 Nov 2002 11:08:09 +0100 (CET) Message-ID: <3DCF8188.2040001@netsystem.cz> Date: Mon, 11 Nov 2002 11:08:08 +0100 From: Jirka Novak Organization: Net-System Liberec User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020826 X-Accept-Language: cs, en-us MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Slow response from 'SELECT * FROM table' Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/19 X-Sequence-Number: 177 Hi, I have table with 30 columns and 30000..500000 rows. When I make 'SELECT * FROM table' postgresql start doing something and return first row after 10s (for 30k rows) and after 5min (500k rows). It looks like it copy whole response to temp space and after that it shows it. I don't know why. I tested same table structure and datas on Oracle and MSSQL and both returned first row immediatly. Have someone any idea? Jirka Novak From pgsql-performance-owner@postgresql.org Mon Nov 11 05:13:05 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 779A2475A3F for ; Mon, 11 Nov 2002 05:13:04 -0500 (EST) Received: from mx.smartnet.cz (unknown [193.165.185.50]) by postgresql.org (Postfix) with ESMTP id 2D82A475921 for ; Mon, 11 Nov 2002 05:13:03 -0500 (EST) Received: from kuba (helo=localhost) by mx.smartnet.cz with local-esmtp (Exim 3.35 #1 (Debian)) id 18BBYz-0007AT-00; Mon, 11 Nov 2002 11:13:01 +0100 Date: Mon, 11 Nov 2002 11:13:01 +0100 (CET) From: Jakub Ouhrabka X-X-Sender: kuba@server To: Jirka Novak Cc: pgsql-performance@postgresql.org Subject: Re: Slow response from 'SELECT * FROM table' In-Reply-To: <3DCF8188.2040001@netsystem.cz> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/20 X-Sequence-Number: 178 hi, do you really need all 500k records? if not i'd suggest using limit and offset clause (select * from table order by xy limit 100 - xy should be indexed...) or if you really need all records use a cursor. kuba On Mon, 11 Nov 2002, Jirka Novak wrote: > Hi, > > I have table with 30 columns and 30000..500000 rows. When I make > 'SELECT * FROM table' postgresql start doing something and return first > row after 10s (for 30k rows) and after 5min (500k rows). It looks like > it copy whole response to temp space and after that it shows it. > I don't know why. I tested same table structure and datas on Oracle > and MSSQL and both returned first row immediatly. > Have someone any idea? > > Jirka Novak > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > From pgsql-general-owner@postgresql.org Mon Nov 11 06:58:37 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 621B9475AFA for ; Mon, 11 Nov 2002 06:58:36 -0500 (EST) Received: from orion.hrz.tu-freiberg.de (orion.hrz.tu-freiberg.de [139.20.64.5]) by postgresql.org (Postfix) with ESMTP id 8849A475ADE for ; Mon, 11 Nov 2002 06:58:35 -0500 (EST) Received: from hermes.vpn ([139.20.16.10]) by orion.hrz.tu-freiberg.de (8.12.6/8.12.6) with ESMTP id gABBvYK2098068; Mon, 11 Nov 2002 12:57:34 +0100 (CET) (envelope-from bahmann@math.tu-freiberg.de) Received: from helge (helo=localhost) by hermes.vpn with local-esmtp (Exim 3.35 #1 (Debian)) id 18BDAp-0000ms-00; Mon, 11 Nov 2002 12:56:11 +0100 Date: Mon, 11 Nov 2002 12:56:11 +0100 (CET) From: Helge Bahmann To: Henrik Steffen Cc: pgsql-general@postgresql.org Subject: Re: Upgrade to dual processor machine? In-Reply-To: <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/453 X-Sequence-Number: 32874 FWIW, in summer I have done a little bit of testing on one of our dual-cpu machines; among this I have been running OSDB (open source database benchmark), 32 simulated clients, against Postgres (7.2.1)/Linux (2.4.18), once bootet with maxcpus=1 and once with maxcpus=2; if I remember correctly I saw something between 80-90% performance improvement on the IR benchmark with the second cpu activated. Note the run was completely cpu-bound, neither harddisk nor memory was the bottleneck, so you may see less of an improvement if other parts of your system are the limit; but Postgres itself appears to make use of the available cpus quite nicely. Regards -- Helge Bahmann /| \__ The past: Smart users in front of dumb terminals /_|____\ _/\ | __) $ ./configure \\ \|__/__| checking whether build environment is sane... yes \\/___/ | checking for AIX... no (we already did this) | From pgsql-performance-owner@postgresql.org Mon Nov 11 12:18:54 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 75AD747630C for ; Mon, 11 Nov 2002 12:18:53 -0500 (EST) Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) by postgresql.org (Postfix) with ESMTP id E84214762F5 for ; Mon, 11 Nov 2002 12:18:52 -0500 (EST) Received: from PASCAL.kencast.com (p67-47.acedsl.com [66.114.67.47]) by mail1.acecape.com (8.12.2/8.12.2) with ESMTP id gABHIlt2000957; Mon, 11 Nov 2002 12:18:48 -0500 Message-Id: <5.1.1.6.0.20021111121838.00ba47e8@mail.futuris.net> X-Sender: wweng@mail.futuris.net X-Mailer: QUALCOMM Windows Eudora Version 5.1.1 Date: Mon, 11 Nov 2002 12:19:47 -0500 To: Jakub Ouhrabka , Jirka Novak From: Wei Weng Subject: Re: Slow response from 'SELECT * FROM table' Cc: pgsql-performance@postgresql.org In-Reply-To: References: <3DCF8188.2040001@netsystem.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/21 X-Sequence-Number: 179 I am curious, what performance difference does it make to use vanilla SELECT with to use cursor (for retrieving the entire records)? Thanks Wei At 11:13 AM 11/11/2002 +0100, Jakub Ouhrabka wrote: >hi, > >do you really need all 500k records? if not i'd suggest using limit and >offset clause (select * from table order by xy limit 100 - xy should be >indexed...) or if you really need all records use a cursor. > >kuba > >On Mon, 11 Nov 2002, Jirka Novak wrote: > > > Hi, > > > > I have table with 30 columns and 30000..500000 rows. When I make > > 'SELECT * FROM table' postgresql start doing something and return first > > row after 10s (for 30k rows) and after 5min (500k rows). It looks like > > it copy whole response to temp space and after that it shows it. > > I don't know why. I tested same table structure and datas on Oracle > > and MSSQL and both returned first row immediatly. > > Have someone any idea? > > > > Jirka Novak > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 3: if posting/reading through Usenet, please send an appropriate > > subscribe-nomail command to majordomo@postgresql.org so that your > > message can get through to the mailing list cleanly > > > > >---------------------------(end of broadcast)--------------------------- >TIP 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 Nov 11 12:24:47 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 78291475FE3 for ; Mon, 11 Nov 2002 12:24:46 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id CABAB475F28 for ; Mon, 11 Nov 2002 12:24:45 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1821126; Mon, 11 Nov 2002 09:28:04 -0800 From: "Josh Berkus" Subject: Re: Slow response from 'SELECT * FROM table' To: Jirka Novak , pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Mon, 11 Nov 2002 09:28:04 -0800 Message-ID: In-Reply-To: <3DCF8188.2040001@netsystem.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/22 X-Sequence-Number: 180 Jirka, > I have table with 30 columns and 30000..500000 rows. When I make > 'SELECT * FROM table' postgresql start doing something and return > first row after 10s (for 30k rows) and after 5min (500k rows). It > looks like it copy whole response to temp space and after that it > shows it. > I don't know why. I tested same table structure and datas on Oracle > > and MSSQL and both returned first row immediatly. > Have someone any idea? I can think of any number of reasons why. However, I need more detail from you: 1) Why are you selecting 500,000 rows at once? 2) Is "SELECT * FROM table_a" the entirety of your query, or was there more to it than that? 3) Are you talking about PSQL, or some other interface? -Josh Berkus From pgsql-performance-owner@postgresql.org Mon Nov 11 12:44:51 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4361B475F09 for ; Mon, 11 Nov 2002 12:44:50 -0500 (EST) Received: from mta06bw.bigpond.com (mta06bw.bigpond.com [139.134.6.96]) by postgresql.org (Postfix) with ESMTP id EC53D475F00 for ; Mon, 11 Nov 2002 12:44:48 -0500 (EST) Received: from CPE-144-132-182-167.nsw.bigpond.net.au ([144.135.24.81]) by mta06bw.bigpond.com (Netscape Messaging Server 4.15 mta06bw Jul 16 2002 22:47:55) with SMTP id H5FAMS00.HZC for ; Tue, 12 Nov 2002 03:44:52 +1000 Received: from CPE-144-132-182-167.nsw.bigpond.net.au ([144.132.182.167]) by bwmam05.mailsvc.email.bigpond.com(MailRouter V3.0n 44/47528315); 12 Nov 2002 03:44:52 Subject: Query performance discontinuity From: Mike Nielsen To: pgsql-performance@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 12 Nov 2002 04:44:44 +1100 Message-Id: <1037036692.29703.213.camel@CPE-144-132-182-167> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/23 X-Sequence-Number: 181 pgsql-performers, Just out of curiosity, anybody with any ideas on what happens to this query when the limit is 59626? It's as though 59626 = infinity? pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by tstart,time_stamp limit 59624; NOTICE: QUERY PLAN: Limit (cost=0.00..160328.37 rows=59624 width=179) (actual time=14.52..2225.16 rows=59624 loops=1) -> Index Scan using ps2_idx on ps2 (cost=0.00..881812.85 rows=327935 width=179) (actual time=14.51..2154.59 rows=59625 loops=1) Total runtime: 2265.93 msec EXPLAIN pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by tstart,time_stamp limit 59625; NOTICE: QUERY PLAN: Limit (cost=0.00..160331.06 rows=59625 width=179) (actual time=0.45..2212.19 rows=59625 loops=1) -> Index Scan using ps2_idx on ps2 (cost=0.00..881812.85 rows=327935 width=179) (actual time=0.45..2140.87 rows=59626 loops=1) Total runtime: 2254.50 msec EXPLAIN pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by tstart,time_stamp limit 59626; NOTICE: QUERY PLAN: Limit (cost=160332.32..160332.32 rows=59626 width=179) (actual time=37359.41..37535.85 rows=59626 loops=1) -> Sort (cost=160332.32..160332.32 rows=327935 width=179) (actual time=37359.40..37471.07 rows=59627 loops=1) -> Seq Scan on ps2 (cost=0.00..13783.52 rows=327935 width=179) (actual time=0.26..12433.00 rows=327960 loops=1) Total runtime: 38477.39 msec EXPLAIN pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by tstart,time_stamp limit 59627; NOTICE: QUERY PLAN: Limit (cost=160332.32..160332.32 rows=59627 width=179) (actual time=38084.85..38260.88 rows=59627 loops=1) -> Sort (cost=160332.32..160332.32 rows=327935 width=179) (actual time=38084.83..38194.63 rows=59628 loops=1) -> Seq Scan on ps2 (cost=0.00..13783.52 rows=327935 width=179) (actual time=0.15..12174.74 rows=327960 loops=1) Total runtime: 38611.83 msec EXPLAIN pganalysis=> \d ps2 Table "ps2" Column | Type | Modifiers -------------+--------------------------+----------- host | character varying(255) | pid | integer | line | integer | time_stamp | timestamp with time zone | seq | integer | cpu_sys | real | cpu_elapsed | real | cpu_user | real | cpu_syst | real | cpu_usert | real | mssp | integer | sigp | integer | msrt | integer | msst | integer | sigt | integer | msrp | integer | swap | integer | swat | integer | recp | integer | rect | integer | pgfp | integer | pgft | integer | icsp | integer | vcst | integer | icst | integer | vcsp | integer | fsbop | integer | fsbos | integer | fsbip | integer | fsbis | integer | dread | integer | dwrit | integer | sbhr | real | sread | integer | swrit | integer | lbhr | real | lread | integer | lwrit | integer | dbuser | character(8) | tstart | timestamp with time zone | Indexes: ps2_idx pganalysis=> \d ps2_idx Index "ps2_idx" Column | Type ------------+-------------------------- tstart | timestamp with time zone time_stamp | timestamp with time zone btree pganalysis=> psql (PostgreSQL) 7.2 contains support for: readline, history, multibyte Platform: Celeron 1.3GHz, 512MB 40GB IDE hard disk, Linux 2.4.8-26mdk kernel Regards, Mike From pgsql-performance-owner@postgresql.org Mon Nov 11 12:59:53 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 065A9475EB2 for ; Mon, 11 Nov 2002 12:59:52 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 4F9B6475A3F for ; Mon, 11 Nov 2002 12:59:51 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18BIqk-0002uM-00 for ; Mon, 11 Nov 2002 12:59:50 -0500 Date: Mon, 11 Nov 2002 12:59:50 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Slow response from 'SELECT * FROM table' Message-ID: <20021111125950.L4386@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <3DCF8188.2040001@netsystem.cz> <5.1.1.6.0.20021111121838.00ba47e8@mail.futuris.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <5.1.1.6.0.20021111121838.00ba47e8@mail.futuris.net>; from wweng@kencast.com on Mon, Nov 11, 2002 at 12:19:47PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/24 X-Sequence-Number: 182 On Mon, Nov 11, 2002 at 12:19:47PM -0500, Wei Weng wrote: > I am curious, what performance difference does it make to use vanilla > SELECT with to use cursor (for retrieving the entire records)? If you use a cursor, you don't need to buffer the entire record set before returning it. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-general-owner@postgresql.org Mon Nov 11 13:09:01 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DFB6D475A3F; Mon, 11 Nov 2002 13:09:00 -0500 (EST) Received: from hamster.lnn.lee.net (unknown [12.163.57.59]) by postgresql.org (Postfix) with ESMTP id 110B247580B; Mon, 11 Nov 2002 13:09:00 -0500 (EST) Received: from localhost (localhost.localdomain [127.0.0.1]) by hamster.lnn.lee.net (8.11.6/8.11.6) with ESMTP id gABI8td16832; Mon, 11 Nov 2002 12:08:56 -0600 Date: Mon, 11 Nov 2002 12:08:55 -0600 (CST) From: Shaun Thomas X-X-Sender: sthomas@hamster.inn.lee.net To: Henrik Steffen Cc: Justin Clift , Subject: Re: Upgrade to dual processor machine? In-Reply-To: <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/466 X-Sequence-Number: 32887 On Mon, 11 Nov 2002, Henrik Steffen wrote: > > - How many clients simultaneously connecting to it? > one webserver with max. 50 instances, approximately 10.000 users a day, > about 150.000 Pageviews daily. All pages are created on the fly using > mod_perl connecting to the db-server. Aha. What kind of web-side data caching are you doing? That alone can drop your load down to < 1. Even something like a 1-hour cache, or something you can manually expire can work amazing wonders for database usage. So far, the only thing we've found that doesn't really fit this model are full text searches. Here, the biggest difference to our DB server was caused by *not* having all of our 9 webservers doing 50+ connections per second, which we achieved mainly through caching. Adding another CPU will work as well, but as far as a long-term, not just throwing hardware at the problem kind of solution goes, see if you can get caching worked in there somehow. Since you know you're using Pg.pm (switch to DBI::pg, trust me on this one), you should have little problem either caching your result set or even the whole resulting page with select non-cachable parts. Not only will that reduce page-load time, but the strain on your database as well. -- Shaun M. Thomas INN Database Administrator Phone: (309) 743-0812 Fax : (309) 743-0830 Email: sthomas@townnews.com Web : www.townnews.com From pgsql-general-owner@postgresql.org Mon Nov 11 13:40:20 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 812774762D7; Mon, 11 Nov 2002 13:40:19 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id BFBB84762B0; Mon, 11 Nov 2002 13:40:18 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gABIdRqq014498; Mon, 11 Nov 2002 11:39:27 -0700 (MST) Date: Mon, 11 Nov 2002 11:25:45 -0700 (MST) From: "scott.marlowe" To: Shaun Thomas Cc: Henrik Steffen , Justin Clift , Subject: Re: Upgrade to dual processor machine? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/467 X-Sequence-Number: 32888 On Mon, 11 Nov 2002, Shaun Thomas wrote: > On Mon, 11 Nov 2002, Henrik Steffen wrote: > > > > - How many clients simultaneously connecting to it? > > one webserver with max. 50 instances, approximately 10.000 users a day, > > about 150.000 Pageviews daily. All pages are created on the fly using > > mod_perl connecting to the db-server. > > Aha. What kind of web-side data caching are you doing? That alone can > drop your load down to < 1. Even something like a 1-hour cache, or > something you can manually expire can work amazing wonders for database > usage. So far, the only thing we've found that doesn't really fit this > model are full text searches. > > Here, the biggest difference to our DB server was caused by *not* having > all of our 9 webservers doing 50+ connections per second, which we > achieved mainly through caching. Adding another CPU will work as well, > but as far as a long-term, not just throwing hardware at the problem > kind of solution goes, see if you can get caching worked in there > somehow. > > Since you know you're using Pg.pm (switch to DBI::pg, trust me on this > one), you should have little problem either caching your result set or > even the whole resulting page with select non-cachable parts. Not only > will that reduce page-load time, but the strain on your database as > well. Agreed. I highly recommend squid as a caching proxy. Powerful, fast, and Open source. It's included in most flavors of Linux. I'm sure it's available as a port if not included in most BSDs as well. From pgsql-performance-owner@postgresql.org Mon Nov 11 14:13:33 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EC919475A3F for ; Mon, 11 Nov 2002 14:13:31 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 434BC47580B for ; Mon, 11 Nov 2002 14:13:31 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1821309; Mon, 11 Nov 2002 11:16:47 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Mike Nielsen , pgsql-performance@postgresql.org Subject: Re: Query performance discontinuity Date: Mon, 11 Nov 2002 11:14:49 -0800 X-Mailer: KMail [version 1.4] References: <1037036692.29703.213.camel@CPE-144-132-182-167> In-Reply-To: <1037036692.29703.213.camel@CPE-144-132-182-167> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211111114.49300.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/25 X-Sequence-Number: 183 Mike, > Just out of curiosity, anybody with any ideas on what happens to this > query when the limit is 59626? It's as though 59626 =3D infinity? I'd suspect that this size has something to do with your system resources.= =20=20 have you tried this test on other hardware? BTW, my experience is that Celerons are dog-slow at anything involveing lar= ge=20 or complex queries. Something to do with the crippled cache, I think. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 11 14:37:20 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6673D475A3F for ; Mon, 11 Nov 2002 14:37:19 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id BF7D547580B for ; Mon, 11 Nov 2002 14:37:18 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A3909D60E; Mon, 11 Nov 2002 11:37:18 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 99C215C02; Mon, 11 Nov 2002 11:37:18 -0800 (PST) Date: Mon, 11 Nov 2002 11:37:18 -0800 (PST) From: Stephan Szabo To: Mike Nielsen Cc: Subject: Re: Query performance discontinuity In-Reply-To: <1037036692.29703.213.camel@CPE-144-132-182-167> Message-ID: <20021111112148.S54055-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/26 X-Sequence-Number: 184 On 12 Nov 2002, Mike Nielsen wrote: > Just out of curiosity, anybody with any ideas on what happens to this > query when the limit is 59626? It's as though 59626 = infinity? > EXPLAIN > pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 > 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > tstart,time_stamp limit 59625; > NOTICE: QUERY PLAN: > > Limit (cost=0.00..160331.06 rows=59625 width=179) (actual > time=0.45..2212.19 rows=59625 loops=1) > -> Index Scan using ps2_idx on ps2 (cost=0.00..881812.85 rows=327935 > width=179) (actual time=0.45..2140.87 rows=59626 loops=1) > Total runtime: 2254.50 msec > > EXPLAIN > pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 > 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > tstart,time_stamp limit 59626; > NOTICE: QUERY PLAN: > > Limit (cost=160332.32..160332.32 rows=59626 width=179) (actual > time=37359.41..37535.85 rows=59626 loops=1) > -> Sort (cost=160332.32..160332.32 rows=327935 width=179) (actual > time=37359.40..37471.07 rows=59627 loops=1) > -> Seq Scan on ps2 (cost=0.00..13783.52 rows=327935 width=179) > (actual time=0.26..12433.00 rows=327960 loops=1) > Total runtime: 38477.39 msec This is apparently the breakpoint at which the sequence scan/sort/limit max cost seems to become lower than indexscan/limit given the small difference in estimated costs. What do you get with limit 59626 and enable_seqscan=off? My guess is that it's just above the 160332.32 estimated here. I believe that the query is using the index to avoid a sort, but possibly/probably not to do the condition. I'd wonder if analyzing with more buckets might get it a better idea, but I really don't know. Another option is to see what making an index on (time_stamp, tstart) gives you, but if most of the table meets the time_stamp condition, that wouldn't help any. From pgsql-performance-owner@postgresql.org Mon Nov 11 20:39:26 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 497C8475E45 for ; Mon, 11 Nov 2002 20:39:25 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A869E475A3F for ; Mon, 11 Nov 2002 20:39:24 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAC1d2hR019959; Mon, 11 Nov 2002 20:39:02 -0500 (EST) To: Stephan Szabo Cc: Mike Nielsen , pgsql-performance@postgresql.org Subject: Re: Query performance discontinuity In-reply-to: <20021111112148.S54055-100000@megazone23.bigpanda.com> References: <20021111112148.S54055-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Mon, 11 Nov 2002 11:37:18 -0800" Date: Mon, 11 Nov 2002 20:39:01 -0500 Message-ID: <19958.1037065141@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/27 X-Sequence-Number: 185 Stephan Szabo writes: >> pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 >> 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by >> tstart,time_stamp limit 59625; >> NOTICE: QUERY PLAN: >> >> Limit (cost=0.00..160331.06 rows=59625 width=179) (actual >> time=0.45..2212.19 rows=59625 loops=1) >> -> Index Scan using ps2_idx on ps2 (cost=0.00..881812.85 rows=327935 >> width=179) (actual time=0.45..2140.87 rows=59626 loops=1) >> Total runtime: 2254.50 msec > I believe that the query is using the index to avoid a sort, but > possibly/probably not to do the condition. Certainly not to do the condition, because <> is not an indexable operator. Would it be possible to express the tstart condition as tstart > '2000-1-1 00:00:00' ? The other thing that's pretty obvious is that the cost of the indexscan plan is drastically overestimated relative to the seqscan/sort plan. It might be worth experimenting with lowering random_page_cost to see if that helps. I'm also curious to know whether the table is likely to be nearly in order by tstart/time_stamp --- we know that the effects of index-order correlation aren't modeled very well in 7.2. Finally, it might be worth increasing sort_mem, if it's at the default presently. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 11 23:10:32 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E8DB0475F00 for ; Mon, 11 Nov 2002 23:10:29 -0500 (EST) Received: from mta05ps.bigpond.com (mta05ps.bigpond.com [144.135.25.137]) by postgresql.org (Postfix) with ESMTP id 908F0475E45 for ; Mon, 11 Nov 2002 23:10:28 -0500 (EST) Received: from CPE-144-132-182-167.nsw.bigpond.net.au ([144.135.25.81]) by mta05ps.bigpond.com (Netscape Messaging Server 4.15 mta05ps Jul 16 2002 22:47:55) with SMTP id H5G3LJ00.08R; Tue, 12 Nov 2002 14:10:31 +1000 Received: from CPE-144-132-182-167.nsw.bigpond.net.au ([144.132.182.167]) by psmam05.mailsvc.email.bigpond.com(MailRouter V3.0n 107/8888815); 12 Nov 2002 14:10:31 Subject: Re: Query performance discontinuity From: Mike Nielsen To: Postgresql performance Cc: Stephan Szabo , Tom Lane , Josh Berkus In-Reply-To: <1037036692.29703.213.camel@CPE-144-132-182-167> References: <1037036692.29703.213.camel@CPE-144-132-182-167> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 12 Nov 2002 15:10:31 +1100 Message-Id: <1037074231.29703.234.camel@CPE-144-132-182-167> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/28 X-Sequence-Number: 186 Stephan, Tom & Josh: Here's the result I get from changing the <> to a > in the tstart condition (no improvement): pganalysis=> explain analyze select * from ps2 where tstart> '2000-1-1 pganalysis'> 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by pganalysis-> tstart,time_stamp limit 59628; NOTICE: QUERY PLAN: Limit (cost=160313.27..160313.27 rows=59628 width=179) (actual time=42269.87..42709.82 rows=59628 loops=1) -> Sort (cost=160313.27..160313.27 rows=327895 width=179) (actual time=42269.86..42643.74 rows=59629 loops=1) -> Seq Scan on ps2 (cost=0.00..13783.40 rows=327895 width=179) (actual time=0.15..15211.49 rows=327960 loops=1) Total runtime: 43232.53 msec EXPLAIN Setting enable_seqscan=off produced a good result: pganalysis=> explain analyze select * from ps2 where tstart> '2000-1-1 pganalysis'> 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by pganalysis-> tstart,time_stamp limit 59628; NOTICE: QUERY PLAN: Limit (cost=0.00..160322.87 rows=59628 width=179) (actual time=40.39..2222.06 rows=59628 loops=1) -> Index Scan using ps2_idx on ps2 (cost=0.00..881616.45 rows=327895 width=179) (actual time=40.38..2151.38 rows=59629 loops=1) Total runtime: 2262.23 msec EXPLAIN The ps2 table is in time_stamp order, but the tstarts aren't quite as good -- they're mostly there, but they're computed by subtracting a (stochastic) value from time_stamp. I haven't tinkered with sort_mem yet, but will once I've got this little project wrapped up (1 or 2 days to go!). This, by the way, is pg log data that I've parsed up so I can do some performance number-crunching for a client of mine. Is there a better way to get comprehensive, per-query read, write and cache hit data? As you can imagine, with millions of records, my client-side perl script for the parsing is slow. I've tried my hand at writing an aggregate function on the server side using lex and yacc, but decided that, at least for this project, I'd rather let the machine do the head-banging -- I can tokenize the raw syslog data (loaded into another pg table) into an intermediate result in an aggregate function, and my parser works on the token strings, but the perl script finished before I could go any further... In the off chance, however, that I get invited to more of this kind of work, it would be really handy to be able to get the data without all this hassle! Any clues would be gratefully received. Regards, Mike On Tue, 2002-11-12 at 04:44, Mike Nielsen wrote: pgsql-performers, Just out of curiosity, anybody with any ideas on what happens to this query when the limit is 59626? It's as though 59626 = infinity? pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by tstart,time_stamp limit 59624; NOTICE: QUERY PLAN: Limit (cost=0.00..160328.37 rows=59624 width=179) (actual time=14.52..2225.16 rows=59624 loops=1) -> Index Scan using ps2_idx on ps2 (cost=0.00..881812.85 rows=327935 width=179) (actual time=14.51..2154.59 rows=59625 loops=1) Total runtime: 2265.93 msec EXPLAIN pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by tstart,time_stamp limit 59625; NOTICE: QUERY PLAN: Limit (cost=0.00..160331.06 rows=59625 width=179) (actual time=0.45..2212.19 rows=59625 loops=1) -> Index Scan using ps2_idx on ps2 (cost=0.00..881812.85 rows=327935 width=179) (actual time=0.45..2140.87 rows=59626 loops=1) Total runtime: 2254.50 msec EXPLAIN pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by tstart,time_stamp limit 59626; NOTICE: QUERY PLAN: Limit (cost=160332.32..160332.32 rows=59626 width=179) (actual time=37359.41..37535.85 rows=59626 loops=1) -> Sort (cost=160332.32..160332.32 rows=327935 width=179) (actual time=37359.40..37471.07 rows=59627 loops=1) -> Seq Scan on ps2 (cost=0.00..13783.52 rows=327935 width=179) (actual time=0.26..12433.00 rows=327960 loops=1) Total runtime: 38477.39 msec EXPLAIN pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by tstart,time_stamp limit 59627; NOTICE: QUERY PLAN: Limit (cost=160332.32..160332.32 rows=59627 width=179) (actual time=38084.85..38260.88 rows=59627 loops=1) -> Sort (cost=160332.32..160332.32 rows=327935 width=179) (actual time=38084.83..38194.63 rows=59628 loops=1) -> Seq Scan on ps2 (cost=0.00..13783.52 rows=327935 width=179) (actual time=0.15..12174.74 rows=327960 loops=1) Total runtime: 38611.83 msec EXPLAIN pganalysis=> \d ps2 Table "ps2" Column | Type | Modifiers -------------+--------------------------+----------- host | character varying(255) | pid | integer | line | integer | time_stamp | timestamp with time zone | seq | integer | cpu_sys | real | cpu_elapsed | real | cpu_user | real | cpu_syst | real | cpu_usert | real | mssp | integer | sigp | integer | msrt | integer | msst | integer | sigt | integer | msrp | integer | swap | integer | swat | integer | recp | integer | rect | integer | pgfp | integer | pgft | integer | icsp | integer | vcst | integer | icst | integer | vcsp | integer | fsbop | integer | fsbos | integer | fsbip | integer | fsbis | integer | dread | integer | dwrit | integer | sbhr | real | sread | integer | swrit | integer | lbhr | real | lread | integer | lwrit | integer | dbuser | character(8) | tstart | timestamp with time zone | Indexes: ps2_idx pganalysis=> \d ps2_idx Index "ps2_idx" Column | Type ------------+-------------------------- tstart | timestamp with time zone time_stamp | timestamp with time zone btree pganalysis=> psql (PostgreSQL) 7.2 contains support for: readline, history, multibyte Platform: Celeron 1.3GHz, 512MB 40GB IDE hard disk, Linux 2.4.8-26mdk kernel Regards, Mike ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster From pgsql-performance-owner@postgresql.org Mon Nov 11 23:50:50 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1400B475D0F for ; Mon, 11 Nov 2002 23:50:49 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 05D0F475A3F for ; Mon, 11 Nov 2002 23:50:47 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAC4pJYt015177; Mon, 11 Nov 2002 23:51:20 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: Query performance discontinuity From: Rod Taylor To: Mike Nielsen Cc: Postgresql performance In-Reply-To: <1037074231.29703.234.camel@CPE-144-132-182-167> References: <1037036692.29703.213.camel@CPE-144-132-182-167> <1037074231.29703.234.camel@CPE-144-132-182-167> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 11 Nov 2002 23:51:19 -0500 Message-Id: <1037076680.66615.21.camel@jester> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/29 X-Sequence-Number: 187 Given the estimated costs, PostgreSQL is doing the right things. However, in your case, it doesn't appear that the estimations are realistic. Index scans are much cheaper than advertised. Try setting your random_page_cost lower (1.5 to 2 rather than 4). Bumping sortmem to 32 or 64MB (if plenty of ram is available) will help most situations. Might see the 'pg_autotune' project for assistance in picking good values. http://gborg.postgresql.org/project/pgautotune/projdisplay.php On Mon, 2002-11-11 at 23:10, Mike Nielsen wrote: > Stephan, Tom & Josh: > > Here's the result I get from changing the <> to a > in the tstart > condition (no improvement): > > pganalysis=> explain analyze select * from ps2 where tstart> '2000-1-1 > pganalysis'> 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > pganalysis-> tstart,time_stamp limit 59628; > NOTICE: QUERY PLAN: > > Limit (cost=160313.27..160313.27 rows=59628 width=179) (actual > time=42269.87..42709.82 rows=59628 loops=1) > -> Sort (cost=160313.27..160313.27 rows=327895 width=179) (actual > time=42269.86..42643.74 rows=59629 loops=1) > -> Seq Scan on ps2 (cost=0.00..13783.40 rows=327895 width=179) > (actual time=0.15..15211.49 rows=327960 loops=1) > Total runtime: 43232.53 msec > > EXPLAIN > > Setting enable_seqscan=off produced a good result: > > > pganalysis=> explain analyze select * from ps2 where tstart> '2000-1-1 > pganalysis'> 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > pganalysis-> tstart,time_stamp limit 59628; > NOTICE: QUERY PLAN: > > Limit (cost=0.00..160322.87 rows=59628 width=179) (actual > time=40.39..2222.06 rows=59628 loops=1) > -> Index Scan using ps2_idx on ps2 (cost=0.00..881616.45 rows=327895 > width=179) (actual time=40.38..2151.38 rows=59629 loops=1) > Total runtime: 2262.23 msec > > EXPLAIN > > The ps2 table is in time_stamp order, but the tstarts aren't quite as > good -- they're mostly there, but they're computed by subtracting a > (stochastic) value from time_stamp. > > I haven't tinkered with sort_mem yet, but will once I've got this little > project wrapped up (1 or 2 days to go!). > > This, by the way, is pg log data that I've parsed up so I can do some > performance number-crunching for a client of mine. Is there a better > way to get comprehensive, per-query read, write and cache hit data? As > you can imagine, with millions of records, my client-side perl script > for the parsing is slow. I've tried my hand at writing an aggregate > function on the server side using lex and yacc, but decided that, at > least for this project, I'd rather let the machine do the head-banging > -- I can tokenize the raw syslog data (loaded into another pg table) > into an intermediate result in an aggregate function, and my parser > works on the token strings, but the perl script finished before I could > go any further... > > In the off chance, however, that I get invited to more of this kind of > work, it would be really handy to be able to get the data without all > this hassle! Any clues would be gratefully received. > > Regards, > > Mike > > > On Tue, 2002-11-12 at 04:44, Mike Nielsen wrote: > pgsql-performers, > > Just out of curiosity, anybody with any ideas on what happens to this > query when the limit is 59626? It's as though 59626 = infinity? > > pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 > 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > tstart,time_stamp limit 59624; > NOTICE: QUERY PLAN: > > Limit (cost=0.00..160328.37 rows=59624 width=179) (actual > time=14.52..2225.16 rows=59624 loops=1) > -> Index Scan using ps2_idx on ps2 (cost=0.00..881812.85 rows=327935 > width=179) (actual time=14.51..2154.59 rows=59625 loops=1) > Total runtime: 2265.93 msec > > EXPLAIN > pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 > 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > tstart,time_stamp limit 59625; > NOTICE: QUERY PLAN: > > Limit (cost=0.00..160331.06 rows=59625 width=179) (actual > time=0.45..2212.19 rows=59625 loops=1) > -> Index Scan using ps2_idx on ps2 (cost=0.00..881812.85 rows=327935 > width=179) (actual time=0.45..2140.87 rows=59626 loops=1) > Total runtime: 2254.50 msec > > EXPLAIN > pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 > 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > tstart,time_stamp limit 59626; > NOTICE: QUERY PLAN: > > Limit (cost=160332.32..160332.32 rows=59626 width=179) (actual > time=37359.41..37535.85 rows=59626 loops=1) > -> Sort (cost=160332.32..160332.32 rows=327935 width=179) (actual > time=37359.40..37471.07 rows=59627 loops=1) > -> Seq Scan on ps2 (cost=0.00..13783.52 rows=327935 width=179) > (actual time=0.26..12433.00 rows=327960 loops=1) > Total runtime: 38477.39 msec > > EXPLAIN > pganalysis=> explain analyze select * from ps2 where tstart<> '2000-1-1 > 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > tstart,time_stamp limit 59627; > NOTICE: QUERY PLAN: > > Limit (cost=160332.32..160332.32 rows=59627 width=179) (actual > time=38084.85..38260.88 rows=59627 loops=1) > -> Sort (cost=160332.32..160332.32 rows=327935 width=179) (actual > time=38084.83..38194.63 rows=59628 loops=1) > -> Seq Scan on ps2 (cost=0.00..13783.52 rows=327935 width=179) > (actual time=0.15..12174.74 rows=327960 loops=1) > Total runtime: 38611.83 msec > > EXPLAIN > > pganalysis=> \d ps2 > Table "ps2" > Column | Type | Modifiers > -------------+--------------------------+----------- > host | character varying(255) | > pid | integer | > line | integer | > time_stamp | timestamp with time zone | > seq | integer | > cpu_sys | real | > cpu_elapsed | real | > cpu_user | real | > cpu_syst | real | > cpu_usert | real | > mssp | integer | > sigp | integer | > msrt | integer | > msst | integer | > sigt | integer | > msrp | integer | > swap | integer | > swat | integer | > recp | integer | > rect | integer | > pgfp | integer | > pgft | integer | > icsp | integer | > vcst | integer | > icst | integer | > vcsp | integer | > fsbop | integer | > fsbos | integer | > fsbip | integer | > fsbis | integer | > dread | integer | > dwrit | integer | > sbhr | real | > sread | integer | > swrit | integer | > lbhr | real | > lread | integer | > lwrit | integer | > dbuser | character(8) | > tstart | timestamp with time zone | > Indexes: ps2_idx > > pganalysis=> \d ps2_idx > Index "ps2_idx" > Column | Type > ------------+-------------------------- > tstart | timestamp with time zone > time_stamp | timestamp with time zone > btree > > pganalysis=> > > psql (PostgreSQL) 7.2 > contains support for: readline, history, multibyte > > > Platform: Celeron 1.3GHz, 512MB 40GB IDE hard disk, Linux 2.4.8-26mdk > kernel > > Regards, > > Mike > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- Rod Taylor From pgsql-performance-owner@postgresql.org Tue Nov 12 02:30:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 716BC475CA6 for ; Tue, 12 Nov 2002 02:30:07 -0500 (EST) Received: from head.netsystem.cz (head.netsystem.cz [194.212.169.67]) by postgresql.org (Postfix) with ESMTP id 68A2B475AEC for ; Tue, 12 Nov 2002 02:30:05 -0500 (EST) Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1]) by head.netsystem.cz (Postfix) with SMTP id 89EF88FB2 for ; Tue, 12 Nov 2002 08:30:05 +0100 (CET) Received: from netsystem.cz (novakji.netsystem.cz [192.168.200.24]) by head.netsystem.cz (Postfix) with ESMTP id 6281A8FB1 for ; Tue, 12 Nov 2002 08:30:05 +0100 (CET) Message-ID: <3DD0ADFD.5060609@netsystem.cz> Date: Tue, 12 Nov 2002 08:30:05 +0100 From: Jirka Novak Organization: Net-System Liberec User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020826 X-Accept-Language: cs, en-us MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Slow response from 'SELECT * FROM table' References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/30 X-Sequence-Number: 188 Thanks all, cursor resolved this problem. I thinked that queries are rewriten into implicit cursor, so I didn't use it for query. Now I see, I was wrong. Jirka Novak From pgsql-performance-owner@postgresql.org Tue Nov 12 11:54:19 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AD074475AE5 for ; Tue, 12 Nov 2002 11:54:17 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 0445D475AD7 for ; Tue, 12 Nov 2002 11:54:17 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1822582; Tue, 12 Nov 2002 08:57:43 -0800 From: "Josh Berkus" Subject: Re: Query performance discontinuity To: Rod Taylor , Mike Nielsen Cc: Postgresql performance X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Tue, 12 Nov 2002 08:57:43 -0800 Message-ID: In-Reply-To: <1037076680.66615.21.camel@jester> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/31 X-Sequence-Number: 189 Mike, > Given the estimated costs, PostgreSQL is doing the right things. > > However, in your case, it doesn't appear that the estimations are > realistic. Index scans are much cheaper than advertised. Can I assume that you've run VACUUM FULL ANALYZE on the table, or preferably the whole database? > > Try setting your random_page_cost lower (1.5 to 2 rather than 4). > Bumping sortmem to 32 or 64MB (if plenty of ram is available) will > help > most situations. > > Might see the 'pg_autotune' project for assistance in picking good > values. > > http://gborg.postgresql.org/project/pgautotune/projdisplay.php Um. I don't think we have anything to advertise yet, for pg_autotune. It's still very much an alpha, and the limits we set are pretty arbitrary. -Josh Berkus From pgsql-general-owner@postgresql.org Tue Nov 12 12:37:45 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6C038475E75; Tue, 12 Nov 2002 12:37:44 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id C3443475DC0; Tue, 12 Nov 2002 12:37:43 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gACHahEa014269; Tue, 12 Nov 2002 10:36:44 -0700 (MST) Date: Tue, 12 Nov 2002 10:22:54 -0700 (MST) From: "scott.marlowe" To: Henrik Steffen Cc: Justin Clift , Subject: Re: Upgrade to dual processor machine? In-Reply-To: <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/489 X-Sequence-Number: 32910 On Mon, 11 Nov 2002, Henrik Steffen wrote: > > - How many clients simultaneously connecting to it? > one webserver with max. 50 instances, approximately 10.000 users a day, > about 150.000 Pageviews daily. All pages are created on the fly using > mod_perl connecting to the db-server. If you've got 50 simos, you could use more CPUs, whether your I/O bound or not. > > - What do the clients connect with? JDBC/ODBC/libpq/etc? > I am using Pg.pm --- this is called libpq, isn't it? > > > - Have you configured the memory after installation of PostgreSQL, so > > it's better optimised than the defaults? > no - what should I do? Looking at 'top' right now, I see the following: > Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff Hey, what is the "cached" field saying there? Is the machine caching a whole bunch or just a little? If it's caching a whole bunch, look at increasing your shmmax shmall settings and then the shared buffers in postgresql.conf for better performance. From pgsql-general-owner@postgresql.org Tue Nov 12 14:23:15 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1B21475DA3 for ; Tue, 12 Nov 2002 14:23:13 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 91A2E475AEC for ; Tue, 12 Nov 2002 14:23:12 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Tue, 12 Nov 2002 20:23:05 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Tue, 12 Nov 2002 20:18:28 +0100 Message-ID: <003a01c28a80$d7935840$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Shaun Thomas" Cc: "Justin Clift" , References: Subject: Re: Upgrade to dual processor machine? Date: Tue, 12 Nov 2002 20:22:29 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/497 X-Sequence-Number: 32918 hi, thanks for this information... we are allready using squid as a transpartent www-accelerator, this works very well and squid handles about 70 % out of all hits. However, sometimes some search engines use to start indexing more than 25 DIFFERENT documents per second, this is when things start getting more difficult .... we have played around a little with an ip-based bandwidth-regulation tool at squid-level, which works quite well - though you'll have to add new search-engines on demand. But anyway - we still have to look at the facts: we have had a 200 % increase of visitors and pageviews during the last 6 months. Upgrading to DBI:pg is something I have been thinking about allready, but as far as I know, I am allready using persistent connections with mod_perl and Pg.pm, am I not???! -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Shaun Thomas" To: "Henrik Steffen" Cc: "Justin Clift" ; Sent: Monday, November 11, 2002 7:08 PM Subject: Re: [GENERAL] Upgrade to dual processor machine? > On Mon, 11 Nov 2002, Henrik Steffen wrote: > > > > - How many clients simultaneously connecting to it? > > one webserver with max. 50 instances, approximately 10.000 users a day, > > about 150.000 Pageviews daily. All pages are created on the fly using > > mod_perl connecting to the db-server. > > Aha. What kind of web-side data caching are you doing? That alone can > drop your load down to < 1. Even something like a 1-hour cache, or > something you can manually expire can work amazing wonders for database > usage. So far, the only thing we've found that doesn't really fit this > model are full text searches. > > Here, the biggest difference to our DB server was caused by *not* having > all of our 9 webservers doing 50+ connections per second, which we > achieved mainly through caching. Adding another CPU will work as well, > but as far as a long-term, not just throwing hardware at the problem > kind of solution goes, see if you can get caching worked in there > somehow. > > Since you know you're using Pg.pm (switch to DBI::pg, trust me on this > one), you should have little problem either caching your result set or > even the whole resulting page with select non-cachable parts. Not only > will that reduce page-load time, but the strain on your database as > well. > > -- > Shaun M. Thomas INN Database Administrator > Phone: (309) 743-0812 Fax : (309) 743-0830 > Email: sthomas@townnews.com Web : www.townnews.com > From pgsql-general-owner@postgresql.org Tue Nov 12 14:28:29 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 53355476404 for ; Tue, 12 Nov 2002 14:28:27 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id B64534762B7 for ; Tue, 12 Nov 2002 14:28:22 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Tue, 12 Nov 2002 20:28:11 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Tue, 12 Nov 2002 20:23:33 +0100 Message-ID: <004801c28a81$8da1ca40$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "scott.marlowe" Cc: References: Subject: Re: Upgrade to dual processor machine? Date: Tue, 12 Nov 2002 20:27:34 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/499 X-Sequence-Number: 32920 The cache-field is saying 873548K cached at the moment Is this a "whole bunch of cache" in your opinion? Is it too much? So, where do i find and change shmmax shmall settings ?? What should I put there? What is a recommended value for shared buffers in postgresql.conf ? FYI: ps ax | grep -c postgres ==> shows 23 at the moment however, w shows: load average 3.09, 2.01, 1.76 (this is low at the moment) thanks again, -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "scott.marlowe" To: "Henrik Steffen" Cc: "Justin Clift" ; Sent: Tuesday, November 12, 2002 6:22 PM Subject: Re: [GENERAL] Upgrade to dual processor machine? > On Mon, 11 Nov 2002, Henrik Steffen wrote: > > > > - How many clients simultaneously connecting to it? > > one webserver with max. 50 instances, approximately 10.000 users a day, > > about 150.000 Pageviews daily. All pages are created on the fly using > > mod_perl connecting to the db-server. > > If you've got 50 simos, you could use more CPUs, whether your I/O bound or > not. > > > > - What do the clients connect with? JDBC/ODBC/libpq/etc? > > I am using Pg.pm --- this is called libpq, isn't it? > > > > > - Have you configured the memory after installation of PostgreSQL, so > > > it's better optimised than the defaults? > > no - what should I do? Looking at 'top' right now, I see the following: > > Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff > > Hey, what is the "cached" field saying there? Is the machine caching a > whole bunch or just a little? If it's caching a whole bunch, look at > increasing your shmmax shmall settings and then the shared buffers in > postgresql.conf for better performance. > > > From pgsql-general-owner@postgresql.org Tue Nov 12 14:42:48 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0F301476212 for ; Tue, 12 Nov 2002 14:42:48 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id BEFAC47610B for ; Tue, 12 Nov 2002 14:42:46 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Tue, 12 Nov 2002 20:42:45 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Tue, 12 Nov 2002 20:38:08 +0100 Message-ID: <005601c28a83$96982f20$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Justin Clift" Cc: References: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> <3DCD049D.1CE7D82C@postgresql.org> <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> <3DCF5FD8.39F41505@postgresql.org> Subject: Re: Upgrade to dual processor machine? Date: Tue, 12 Nov 2002 20:42:08 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/502 X-Sequence-Number: 32923 Hi Justin, thanks for your answer, I will now try to deliver some more information to you... but I am in particular a programmer, not a hacker ;-)) so please excuse if I lack some knowledge in system things and stuff.... > - Have you run any system-performance tools apart from top, to figure > out how the various parts of your system are operating? nope. don't know any... which would you recommend for measurement of i/o usage etc. ? > The solution may turn out to be upgrading your disks instead > of your CPU's (example only). I will at least consider this... IDE disks are not that reliable either... > Important question, how much memory can you get into that server? Could > you do 3GB or more? no, sorry - 1 GB is allready the upper limit... I consider migrating everything to a new hardware, (dual?) intel xeon with perhaps even raid-v storage system with a new upper limit of 12 GB RAM which will give me some upgrade-possibilies ... ;-)) > Something that would be *really nice* is if you have a second server > with the same configuration hanging around that you can try stuff on. > For example, loading it with a copy of all your data, changing the > memory configuration, then testing it. I actually DO have an identical second server, and the db is allready on it. however, the system has a few problems concerning harddisk failuers and memory problems (don't ever use it for running systems!! we had this server on the list before... I almost gave up on this one, when suddenly all problems and crashes were solved when moving to a different machine as suggested by tom lane ....) ... but for some testing purpose it sould be sufficient ;-)) > - Which version of the Linux kernel, and of RedHat? redhat - linux kernel 2.4.7-10 > - If you do a ps (ps -ef) during a busy time, how many instances of the > PostgreSQL process do you see in memory? This will tell you how many > ients have an open connection to the database at any time. up to 40 clients are running... right now it's 21 processes and w shows a load average of 1.92, 1.58, 1.59 > - How much data is in your database(s)? Just to get an idea of your > volume of data. It's 3.6 GB at the moment in one database in 98 user tables. > - If disk performance turns out to be the problem, would you consider > moving to higher-end hard drives allready considering .... -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Justin Clift" To: "Henrik Steffen" Cc: Sent: Monday, November 11, 2002 8:44 AM Subject: Re: [GENERAL] Upgrade to dual processor machine? > Hi Henrik, > > Ok, you're machine is doing a decent amount of work, and will need > looking at carefully. > > Going to get more specific about some stuff, as it'll definitely assist > with giving you proper guidance here. > > - Have you run any system-performance tools apart from top, to figure > out how the various parts of your system are operating? > > For example, by looking into and measuring the different parts of your > system, you may find you have several processes simultaneously waiting > to execute purely because the disk drives can't keep up with the > requests. The solution may turn out to be upgrading your disks instead > of your CPU's (example only). Without taking measurements to the point > of understanding what's going on, you'll only be guessing. > > The most concerning aspect at the moment is this: > > "> - Have you configured the memory after installation of PostgreSQL, so > > it's better optimised than the defaults? > no - what should I do? Looking at 'top' right now, I see the following: > Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff" > > This is telling me that the system is operating close to using all it's > memory with running processes. *Bad* for this kind of thing. The > default memory configuration for PostgreSQL is very lean and causes high > CPU load and slow throughput. You don't seem to have enough spare > memory at the moment to really try adjusting this upwards. :( > > Important question, how much memory can you get into that server? Could > you do 3GB or more? > > Something that would be *really nice* is if you have a second server > with the same configuration hanging around that you can try stuff on. > For example, loading it with a copy of all your data, changing the > memory configuration, then testing it. > > > Further system specific details needed: > > - Which version of the Linux kernel, and of RedHat? Different version > of the Linux kernel do things differently. For example version 2.4.3 > does virtual memory differently than say version 2.4.17. > > > - If you do a ps (ps -ef) during a busy time, how many instances of the > PostgreSQL process do you see in memory? This will tell you how many > clients have an open connection to the database at any time. > > > - How much data is in your database(s)? Just to get an idea of your > volume of data. > > > - If disk performance turns out to be the problem, would you consider > moving to higher-end hard drives? This will probably mean an Ultra160 > or Ultra320 SCSI card, and drives to match. That's not going to be > totally cheap, but if you have a decent budget then it might be ok. > > > As you can see, this could take a bit of time an effort to get right. > > Regards and best wishes, > > Justin Clift > > > Henrik Steffen wrote: > > > > Hi Justin, > > > > here a little more information: > > > > > - Processor type and speed > > Intel Pentium IV, 1.6 GHz > > > > > - Memory > > 1024 MB ECC-RAM > > > > > - Disk configuration > > 2 x 60 GB IDE (Raid 0) > > > > > - OS > > Redhat Linux > > > > > > > > - Do you do other stuff on it, apart from PostgreSQL? > > No, it's a dedicated database server > > > > > > > > - How many clients simultaneously connecting to it? > > one webserver with max. 50 instances, approximately 10.000 users a day, > > about 150.000 Pageviews daily. All pages are created on the fly using > > mod_perl connecting to the db-server. > > > > > - What do the clients connect with? JDBC/ODBC/libpq/etc? > > I am using Pg.pm --- this is called libpq, isn't it? > > > > > - Have you configured the memory after installation of PostgreSQL, so > > > it's better optimised than the defaults? > > no - what should I do? Looking at 'top' right now, I see the following: > > Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff > > > > So, what do you suggest to gain more performance? > > > > Thanks in advance, > > -- > "My grandfather once told me that there are two kinds of people: those > who work and those who take the credit. He told me to try to be in the > first group; there was less competition there." > - Indira Gandhi > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > From pgsql-general-owner@postgresql.org Tue Nov 12 14:45:50 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0C55647609C for ; Tue, 12 Nov 2002 14:45:50 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id D77A3475EC7 for ; Tue, 12 Nov 2002 14:45:48 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Tue, 12 Nov 2002 20:45:48 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Tue, 12 Nov 2002 20:41:11 +0100 Message-ID: <006201c28a84$03c5b540$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: References: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP><3DCD049D.1CE7D82C@postgresql.org><001701c28950$b6a12bc0$7100a8c0@STEINKAMP> <87y980tvc4.fsf@mailbox.samurai.com> Subject: Re: Upgrade to dual processor machine? Date: Tue, 12 Nov 2002 20:45:12 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/503 X-Sequence-Number: 32924 hello, Am I not allready using persistent connections with Pg.pm ? It looks at least like it.... I only need a new connection from webserver to db-server once a new webserver child is born. well, anyway i am consindering updating to DBD::Pg of course... it's only to change about 100.000 lines of perl code .... > No, Justin is referring to the memory-related configuration options in > postgresql.conf, like shared_buffers, wal_buffers, sort_mem, and the > like. so, how am i supposed to tune these settings ?? thanks again, -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Neil Conway" To: "Henrik Steffen" Cc: "Justin Clift" ; Sent: Monday, November 11, 2002 8:32 AM Subject: Re: [GENERAL] Upgrade to dual processor machine? > "Henrik Steffen" writes: > > > - What do the clients connect with? JDBC/ODBC/libpq/etc? > > I am using Pg.pm --- this is called libpq, isn't it? > > Well, it's a thin Perl wrapper over libpq (which is the C client > API). You said you're using mod_perl: you may wish to consider using > DBI and DBD::Pg instead of Pg.pm, so you can make use of persistent > connections using Apache::DBI. > > > > - Have you configured the memory after installation of PostgreSQL, so > > > it's better optimised than the defaults? > > > no - what should I do? Looking at 'top' right now, I see the following: > > Mem 1020808K av, 1015840K used, 4968K free, 1356K shrd, 32852K buff > > No, Justin is referring to the memory-related configuration options in > postgresql.conf, like shared_buffers, wal_buffers, sort_mem, and the > like. > > > So, what do you suggest to gain more performance? > > IMHO, dual processors would likely be a good performance improvement. > > Cheers, > > Neil > > -- > Neil Conway || PGP Key ID: DB3C29FC > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html From pgsql-general-owner@postgresql.org Tue Nov 12 15:04:21 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0360347610B for ; Tue, 12 Nov 2002 15:04:21 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 61323476108 for ; Tue, 12 Nov 2002 15:04:20 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1822929; Tue, 12 Nov 2002 12:07:43 -0800 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-general@postgresql.org Subject: Re: Upgrade to dual processor machine? Date: Tue, 12 Nov 2002 12:05:44 -0800 X-Mailer: KMail [version 1.4] Cc: steffen@city-map.de MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211121205.44452.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/504 X-Sequence-Number: 32925 Heinrik, "So, where do i find and change shmmax shmall settings ?? What should I put there? What is a recommended value for shared buffers in postgresql.conf ?" There is no "recommended value." You have to calculate this relatively: 1) Figure out how much RAM your server has available for PostgreSQL. For= =20 example, I have one server on which I allocate 256 mb for Apache, 128 mb fo= r=20 linux, and thus have 512mb available for Postgres. 2) Calculate out the memory settings to use 70% of that amount of Ram in=20 regular usage. Please beware that sort_mem is *not* shared, meaning that = it=20 will be multiplied by the number of concurrent requests requiring sorting.= =20=20 Thus, your calculation (in K) should be: 250K + 8.2K * shared_buffers + 14.2K * max_connections + sort_mem * average number of requests per minute =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 memory available to postgresql in K * 0.7 You will also have to set SHMMAX and SHMMALL to accept this memory allocati= on.=20=20 Since shmmax is set in bytes, then I generally feel safe making it: 1024 * 0.5 * memory available to postgresql in K Setting them is done simply: $ echo 134217728 >/proc/sys/kernel/shmall $ echo 134217728 >/proc/sys/kernel/shmmax This is all taken from the postgresql documentation, with some experience: http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/runtime.html --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-general-owner@postgresql.org Tue Nov 12 15:41:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 049DE476283 for ; Tue, 12 Nov 2002 15:41:09 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 4E936475FF9 for ; Tue, 12 Nov 2002 15:41:08 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gACKePqi028874; Tue, 12 Nov 2002 13:40:25 -0700 (MST) Date: Tue, 12 Nov 2002 13:26:34 -0700 (MST) From: "scott.marlowe" To: Josh Berkus Cc: , Subject: Re: Upgrade to dual processor machine? In-Reply-To: <200211121205.44452.josh@agliodbs.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/509 X-Sequence-Number: 32930 On Tue, 12 Nov 2002, Josh Berkus wrote: > Heinrik, > > "So, where do i find and change shmmax shmall settings ?? > What should I put there? > > What is a recommended value for shared buffers in postgresql.conf ?" > > There is no "recommended value." You have to calculate this relatively: > > 1) Figure out how much RAM your server has available for PostgreSQL. For > example, I have one server on which I allocate 256 mb for Apache, 128 mb for > linux, and thus have 512mb available for Postgres. > > 2) Calculate out the memory settings to use 70% of that amount of Ram in > regular usage. Please beware that sort_mem is *not* shared, meaning that it > will be multiplied by the number of concurrent requests requiring sorting. > Thus, your calculation (in K) should be: > > 250K + > 8.2K * shared_buffers + > 14.2K * max_connections + > sort_mem * average number of requests per minute > ===================================== > memory available to postgresql in K * 0.7 > > You will also have to set SHMMAX and SHMMALL to accept this memory allocation. > Since shmmax is set in bytes, then I generally feel safe making it: > 1024 * 0.5 * memory available to postgresql in K > > Setting them is done simply: > $ echo 134217728 >/proc/sys/kernel/shmall > $ echo 134217728 >/proc/sys/kernel/shmmax > > This is all taken from the postgresql documentation, with some experience: > http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/runtime.html Note that on RedHat boxes, you can also use the /etc/sysctl.conf file to do this. It is considered the preferred method, and a little less obtuse for beginners. As root, run 'sysctl -a' to get a list of all possible system kernel settings. 'sysctl -a | grep shm' will show you all the shared memory settings as they are now. Edit the /etc/sysctl.conf file with the new settings and use 'sysctl -p' to process the new settings. This way you don't have to edit the /etc/rc.d/rc.local file to get the settings you want. On the subject of sort_mem, I've found that if your result sets are all large (say 100+megs each) that as long as your sort mem isn't big enough to hold the whole result set, the performance difference is negligable. I.e. going from 4 meg to 16 meg of sort_mem for a 100 Meg result set doesn't seem to help much at all. In fact, in some circumstances, it seems that the smaller number is faster, especially under heavy parallel load, since larger settings may result in undesired swapping out of other processes to allocate memory for sorts. In other words, it's faster to sort 20 results in 4 megs each if you aren't causing swapping out, than it is to sort 20 results in 32 megs each if that does cause things to swap out. From pgsql-performance-owner@postgresql.org Tue Nov 12 19:04:24 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0CF00475E6F for ; Tue, 12 Nov 2002 19:04:24 -0500 (EST) Received: from mta04bw.bigpond.com (mta04bw.bigpond.com [139.134.6.87]) by postgresql.org (Postfix) with ESMTP id BE52F475AEC for ; Tue, 12 Nov 2002 19:04:22 -0500 (EST) Received: from CPE-144-132-182-167.nsw.bigpond.net.au ([144.135.24.78]) by mta04bw.bigpond.com (Netscape Messaging Server 4.15 mta04bw Jul 16 2002 22:47:55) with SMTP id H5HMVB00.0LT; Wed, 13 Nov 2002 10:04:23 +1000 Received: from CPE-144-132-182-167.nsw.bigpond.net.au ([144.132.182.167]) by bwmam04.mailsvc.email.bigpond.com(MailRouter V3.0n 35/56200302); 13 Nov 2002 10:04:49 Subject: Re: Query performance discontinuity From: Mike Nielsen To: Josh Berkus Cc: Rod Taylor , Postgresql performance In-Reply-To: References: Content-Type: text/plain Organization: Message-Id: <1037145841.2280.7.camel@CPE-144-132-182-167.nsw.bigpond.net.au> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 13 Nov 2002 11:04:01 +1100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/32 X-Sequence-Number: 190 Hi, Josh. Yes, I'd run a VACUUM FULL ANALYZE -- I did it again just to make sure, and re-ran the query (similar result): pganalysis=> explain analyze select * from ps2 where tstart> '2000-1-1 pganalysis'> 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by pganalysis-> tstart,time_stamp limit 59628; NOTICE: QUERY PLAN: Limit (cost=160313.27..160313.27 rows=59628 width=179) (actual time=45405.47..46320.12 rows=59628 loops=1) -> Sort (cost=160313.27..160313.27 rows=327895 width=179) (actual time=45405.46..46248.31 rows=59629 loops=1) -> Seq Scan on ps2 (cost=0.00..13783.40 rows=327895 width=179) (actual time=13.52..17111.66 rows=327960 loops=1) Total runtime: 46894.21 msec EXPLAIN Unfortunately, I have not yet had time to experiment with twiddling the query optimizer parameters or memory -- my apologies for this, but, well, a guy's gotta eat... Regards, Mike On Wed, 2002-11-13 at 03:57, Josh Berkus wrote: > Mike, > > > Given the estimated costs, PostgreSQL is doing the right things. > > > > However, in your case, it doesn't appear that the estimations are > > realistic. Index scans are much cheaper than advertised. > > Can I assume that you've run VACUUM FULL ANALYZE on the table, or > preferably the whole database? > > > > > Try setting your random_page_cost lower (1.5 to 2 rather than 4). > > Bumping sortmem to 32 or 64MB (if plenty of ram is available) will > > help > > most situations. > > > > Might see the 'pg_autotune' project for assistance in picking good > > values. > > > > http://gborg.postgresql.org/project/pgautotune/projdisplay.php > > Um. I don't think we have anything to advertise yet, for pg_autotune. > It's still very much an alpha, and the limits we set are pretty > arbitrary. > > -Josh Berkus -- Mike Nielsen From pgsql-general-owner@postgresql.org Tue Nov 12 22:37:38 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EADB94762BA for ; Tue, 12 Nov 2002 22:37:36 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 5CC04476198 for ; Tue, 12 Nov 2002 22:37:36 -0500 (EST) Received: from tokyo.samurai.com (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 6985C1DC2; Tue, 12 Nov 2002 22:37:39 -0500 (EST) To: "Henrik Steffen" Cc: Subject: Re: Upgrade to dual processor machine? References: <016b01c287ec$1fe92580$7100a8c0@STEINKAMP> <3DCD049D.1CE7D82C@postgresql.org> <001701c28950$b6a12bc0$7100a8c0@STEINKAMP> <87y980tvc4.fsf@mailbox.samurai.com> <006201c28a84$03c5b540$7100a8c0@STEINKAMP> From: Neil Conway In-Reply-To: <006201c28a84$03c5b540$7100a8c0@STEINKAMP> Date: 12 Nov 2002 22:37:35 -0500 Message-ID: <871y5qw35s.fsf@mailbox.samurai.com> Lines: 19 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/520 X-Sequence-Number: 32941 "Henrik Steffen" writes: > > No, Justin is referring to the memory-related configuration options in > > postgresql.conf, like shared_buffers, wal_buffers, sort_mem, and the > > like. > > so, how am i supposed to tune these settings ?? postgresql.conf See the documentation: http://developer.postgresql.org/docs/postgres/runtime-config.html Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-general-owner@postgresql.org Wed Nov 13 02:29:58 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0B168475C8B for ; Wed, 13 Nov 2002 02:29:57 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id F1C604759AF for ; Wed, 13 Nov 2002 02:29:55 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 08:29:55 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 08:25:22 +0100 Message-ID: <008f01c28ae6$64a45e40$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Cc: References: <200211121205.44452.josh@agliodbs.com> Subject: Re: Upgrade to dual processor machine? Date: Wed, 13 Nov 2002 08:29:25 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/524 X-Sequence-Number: 32945 Hello Josh! This is was I figured out now: 1) RAM available: 1024 MB, there's nothing else but postgres on this machine, so if I calculate 128 MB for Linux, there are 896 MB left for Postgres. 2) 70 % of 896 MB is 627 MB Now, if I follow your instructions: 250K + 8.2K * 128 (shared_buffers) = 1049,6K + 14.2K * 64 (max_connections) = 908,8K + 1024K * 5000 (average number of requests per minute) = 5120000K =============================================================== 5122208.4K ==> 5002.16 MB this is a little bit more than I have available, isn't it? :((( sure that this has got to be the "average number of requests per minute" and not "per second" ? seems so much, doesn't it? what am I supposed to do now? thanks again, -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Josh Berkus" To: Cc: Sent: Tuesday, November 12, 2002 9:05 PM Subject: Re: Upgrade to dual processor machine? Heinrik, "So, where do i find and change shmmax shmall settings ?? What should I put there? What is a recommended value for shared buffers in postgresql.conf ?" There is no "recommended value." You have to calculate this relatively: 1) Figure out how much RAM your server has available for PostgreSQL. For example, I have one server on which I allocate 256 mb for Apache, 128 mb for linux, and thus have 512mb available for Postgres. 2) Calculate out the memory settings to use 70% of that amount of Ram in regular usage. Please beware that sort_mem is *not* shared, meaning that it will be multiplied by the number of concurrent requests requiring sorting. Thus, your calculation (in K) should be: 250K + 8.2K * shared_buffers + 14.2K * max_connections + sort_mem * average number of requests per minute ===================================== memory available to postgresql in K * 0.7 You will also have to set SHMMAX and SHMMALL to accept this memory allocation. Since shmmax is set in bytes, then I generally feel safe making it: 1024 * 0.5 * memory available to postgresql in K Setting them is done simply: $ echo 134217728 >/proc/sys/kernel/shmall $ echo 134217728 >/proc/sys/kernel/shmmax This is all taken from the postgresql documentation, with some experience: http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/runtime.html -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-general-owner@postgresql.org Wed Nov 13 02:53:05 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D93BF4759AF for ; Wed, 13 Nov 2002 02:53:03 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id B970B47623E for ; Wed, 13 Nov 2002 02:53:00 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gAD7r0E12901 for ; Wed, 13 Nov 2002 13:23:00 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gAD7r0v12896 for ; Wed, 13 Nov 2002 13:23:00 +0530 From: "Shridhar Daithankar" To: Date: Wed, 13 Nov 2002 13:23:36 +0530 MIME-Version: 1.0 Subject: Re: Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD25258.11435.46A9D60@localhost> In-reply-to: <008f01c28ae6$64a45e40$7100a8c0@STEINKAMP> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/525 X-Sequence-Number: 32946 On 13 Nov 2002 at 8:29, Henrik Steffen wrote: > Hello Josh! > > This is was I figured out now: > > 1) RAM available: 1024 MB, there's nothing else but postgres on this > machine, so if I calculate 128 MB for Linux, there are 896 MB left > for Postgres. > > 2) 70 % of 896 MB is 627 MB > > Now, if I follow your instructions: > > 250K + > 8.2K * 128 (shared_buffers) = 1049,6K + > 14.2K * 64 (max_connections) = 908,8K + > 1024K * 5000 (average number of requests per minute) = 5120000K > =============================================================== > 5122208.4K ==> 5002.16 MB > > this is a little bit more than I have available, isn't it? :((( Obviously tuning depends upon application and you have to set the threshold by trial and error. I would suggest following from some recent discussions on such topics. 1)Set shared buffers somewhere between 500-600MB. Tha'ts going to be optimal range for a Gig of RAM. 2) How big you database is? How much of it you need it in memory at any given time? You need to get these figures while setting shared buffers. But still 500- 600MB seems good because it does not include file system cache and buffers. 3) Sort mem is a tricky affair. AFAIU, it is used only when you create index or sort results of a query. If do these things seldomly, you can set this very low or default. For individual session that creates index, you can set the sort memory accordingly. Certainly in your case, number of requests per minute are high but if you are not creating any index/sorting in each query, you can leave the default as it is.. HTH Bye Shridhar -- Another dream that failed. There's nothing sadder. -- Kirk, "This side of Paradise", stardate 3417.3 From pgsql-general-owner@postgresql.org Wed Nov 13 03:14:39 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E595C4764C4 for ; Wed, 13 Nov 2002 03:14:36 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 764174762A4 for ; Wed, 13 Nov 2002 03:14:35 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 09:14:33 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 09:10:00 +0100 Message-ID: <00b901c28aec$a0d19580$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Cc: References: <3DD25258.11435.46A9D60@localhost> Subject: Re: Upgrade to dual processor machine? Date: Wed, 13 Nov 2002 09:14:03 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/527 X-Sequence-Number: 32948 Hello Shridhar, thanks for your answer... 1) in the docs it says: shared_buffers should be 2*max_connections, min 16. now, you suggest to put it to 500-600 MB, which means I will have to increase shared_buffers to 68683 -- is this really correct? I mean, RAM is allready now almost totally consumed. 2) the database has a size of 3.6 GB at the moment... about 100 user tables. 3) ok, I understand: I am not creating any indexes usually. Only once at night all user indexes are dropped and recreated, I could imagine to increase the sort_mem for this script... so sort_mem with 1024K is ok, or should it be lowered to, say, 512K ? -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Shridhar Daithankar" To: Sent: Wednesday, November 13, 2002 8:53 AM Subject: Re: [GENERAL] Upgrade to dual processor machine? > On 13 Nov 2002 at 8:29, Henrik Steffen wrote: > > > Hello Josh! > > > > This is was I figured out now: > > > > 1) RAM available: 1024 MB, there's nothing else but postgres on this > > machine, so if I calculate 128 MB for Linux, there are 896 MB left > > for Postgres. > > > > 2) 70 % of 896 MB is 627 MB > > > > Now, if I follow your instructions: > > > > 250K + > > 8.2K * 128 (shared_buffers) = 1049,6K + > > 14.2K * 64 (max_connections) = 908,8K + > > 1024K * 5000 (average number of requests per minute) = 5120000K > > =============================================================== > > 5122208.4K ==> 5002.16 MB > > > > this is a little bit more than I have available, isn't it? :((( > > Obviously tuning depends upon application and you have to set the threshold by > trial and error. > > I would suggest following from some recent discussions on such topics. > > 1)Set shared buffers somewhere between 500-600MB. Tha'ts going to be optimal > range for a Gig of RAM. > > 2) How big you database is? How much of it you need it in memory at any given > time? You need to get these figures while setting shared buffers. But still 500- > 600MB seems good because it does not include file system cache and buffers. > > 3) Sort mem is a tricky affair. AFAIU, it is used only when you create index or > sort results of a query. If do these things seldomly, you can set this very low > or default. For individual session that creates index, you can set the sort > memory accordingly. Certainly in your case, number of requests per minute are > high but if you are not creating any index/sorting in each query, you can leave > the default as it is.. > > HTH > > Bye > Shridhar > > -- > Another dream that failed. There's nothing sadder. -- Kirk, "This side of > Paradise", stardate 3417.3 > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-general-owner@postgresql.org Wed Nov 13 03:26:37 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0EA904764D1 for ; Wed, 13 Nov 2002 03:26:35 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 164F54762A4 for ; Wed, 13 Nov 2002 03:25:48 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gAD8PlW16405 for ; Wed, 13 Nov 2002 13:55:47 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gAD8Plv16400 for ; Wed, 13 Nov 2002 13:55:47 +0530 From: "Shridhar Daithankar" To: Date: Wed, 13 Nov 2002 13:56:23 +0530 MIME-Version: 1.0 Subject: Re: Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD25A07.25377.488A27F@localhost> In-reply-to: <00b901c28aec$a0d19580$7100a8c0@STEINKAMP> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/528 X-Sequence-Number: 32949 On 13 Nov 2002 at 9:14, Henrik Steffen wrote: > 1) in the docs it says: shared_buffers should be 2*max_connections, min 16. > now, you suggest to put it to 500-600 MB, which means I will have to > increase shared_buffers to 68683 -- is this really correct? I mean, > RAM is allready now almost totally consumed. Yes. 2*max connection is minimum. Anything additional is always welcome as long as it does not starve the system. If you have a gig of memory and shared buffers are 536MB as you have indicated, who is taking rest of the RAM? What are your current settings? Could you please repost. I lost earlier thread(Sorry for that.. Had a HDD meltdown here couple of days back. Lost few mails..) > 2) the database has a size of 3.6 GB at the moment... about 100 user tables. 500-600MB would take you comfortably in this case.. > 3) ok, I understand: I am not creating any indexes usually. Only once at night > all user indexes are dropped and recreated, I could imagine to increase the > sort_mem for this script... so sort_mem with 1024K is ok, or should it be > lowered to, say, 512K ? That actually depends upons size of table you are indexing and time you can allow for indexing. Default is 4 MB. I would something like 32MB should help a lot.. HTH Bye Shridhar -- QOTD: "It seems to me that your antenna doesn't bring in too many stations anymore." From pgsql-general-owner@postgresql.org Wed Nov 13 04:43:13 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3EFCE47616E for ; Wed, 13 Nov 2002 04:43:11 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id EB244476029 for ; Wed, 13 Nov 2002 04:43:09 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.10 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 10:43:09 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 10:38:37 +0100 Message-ID: <013601c28af9$01730480$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Cc: References: <3DD25A07.25377.488A27F@localhost> Subject: Re: Upgrade to dual processor machine? Date: Wed, 13 Nov 2002 10:42:39 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/529 X-Sequence-Number: 32950 dear shridhar, > Yes. 2*max connection is minimum. Anything additional is always welcome as long > as it does not starve the system. ok, I tried to set shared_buffers to 65535 now. but then restarting postgres fails - it says: IpcMemoryCreate: shmget(key=5432001, size=545333248, 03600) failed: Invalid argument and a message telling me to either lower the shared_buffers or raise the SHMMAX. > If you have a gig of memory and shared buffers are 536MB as you have indicated, > who is taking rest of the RAM? well, I guess it's postgres... see the output of top below: 11:06am up 1 day, 16:46, 1 user, load average: 1,32, 1,12, 1,22 53 processes: 52 sleeping, 1 running, 0 zombie, 0 stopped CPU states: 24,5% user, 11,2% system, 0,0% nice, 5,6% idle Mem: 1020808K av, 1006156K used, 14652K free, 8520K shrd, 37204K buff Swap: 1028112K av, 60K used, 1028052K free 849776K cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 10678 root 19 0 2184 2184 1584 S 2,9 0,2 0:00 sendmail 1 root 8 0 520 520 452 S 0,0 0,0 0:03 init 2 root 9 0 0 0 0 SW 0,0 0,0 0:00 keventd 3 root 9 0 0 0 0 SW 0,0 0,0 0:00 kapm-idled 4 root 19 19 0 0 0 SWN 0,0 0,0 0:00 ksoftirqd_CPU0 5 root 9 0 0 0 0 SW 0,0 0,0 0:28 kswapd 6 root 9 0 0 0 0 SW 0,0 0,0 0:00 kreclaimd 7 root 9 0 0 0 0 SW 0,0 0,0 0:09 bdflush 8 root 9 0 0 0 0 SW 0,0 0,0 0:00 kupdated 9 root -1 -20 0 0 0 SW< 0,0 0,0 0:00 mdrecoveryd 13 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 136 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 137 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 138 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 139 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 140 root 9 0 0 0 0 SW 0,0 0,0 2:16 kjournald 378 root 9 0 0 0 0 SW 0,0 0,0 0:00 eth0 454 root 9 0 572 572 476 S 0,0 0,0 0:00 syslogd 459 root 9 0 1044 1044 392 S 0,0 0,1 0:00 klogd 572 root 8 0 1128 1092 968 S 0,0 0,1 0:07 sshd 584 root 9 0 1056 1056 848 S 0,0 0,1 0:02 nlservd 611 root 8 0 1836 1820 1288 S 0,0 0,1 0:00 sendmail 693 root 9 0 640 640 556 S 0,0 0,0 0:00 crond 729 daemon 9 0 472 464 404 S 0,0 0,0 0:00 atd 736 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 737 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 738 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 739 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 740 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 741 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 9800 root 9 0 1888 1864 1552 S 0,0 0,1 0:02 sshd 9801 root 16 0 1368 1368 1016 S 0,0 0,1 0:00 bash 10574 postgres 0 0 1448 1448 1380 S 0,0 0,1 0:00 postmaster 10576 postgres 9 0 1436 1436 1388 S 0,0 0,1 0:00 postmaster 10577 postgres 9 0 1480 1480 1388 S 0,0 0,1 0:00 postmaster 10579 postgres 14 0 11500 11M 10324 S 0,0 1,1 0:08 postmaster 10580 postgres 9 0 11672 11M 10328 S 0,0 1,1 0:03 postmaster 10581 postgres 14 0 11620 11M 10352 S 0,0 1,1 0:08 postmaster 10585 postgres 11 0 11560 11M 10304 S 0,0 1,1 0:08 postmaster 10588 postgres 9 0 11520 11M 10316 S 0,0 1,1 0:14 postmaster 10589 postgres 9 0 11632 11M 10324 S 0,0 1,1 0:06 postmaster 10590 postgres 10 0 11620 11M 10320 S 0,0 1,1 0:06 postmaster 10591 postgres 9 0 11536 11M 10320 S 0,0 1,1 0:08 postmaster 10592 postgres 11 0 11508 11M 10316 S 0,0 1,1 0:04 postmaster 10595 postgres 9 0 11644 11M 10324 S 0,0 1,1 0:03 postmaster 10596 postgres 11 0 11664 11M 10328 S 0,0 1,1 0:08 postmaster 10597 postgres 9 0 11736 11M 10340 S 0,0 1,1 0:24 postmaster 10598 postgres 9 0 11500 11M 10312 S 0,0 1,1 0:10 postmaster 10599 postgres 11 0 11676 11M 10324 S 0,0 1,1 0:13 postmaster 10602 postgres 9 0 11476 11M 10308 S 0,0 1,1 0:09 postmaster 10652 postgres 9 0 7840 7840 7020 S 0,0 0,7 0:00 postmaster 10669 postgres 9 0 9076 9076 8224 S 0,0 0,8 0:00 postmaster 10677 root 13 0 1032 1028 828 R 0,0 0,1 0:00 top I have now changed the SHMMAX settings to 545333248 and changed the shared_buffers to 65535 again. now postgres starts up correctly. the top result changes to: 11:40am up 1 day, 17:20, 1 user, load average: 2,24, 2,51, 2,14 57 processes: 55 sleeping, 2 running, 0 zombie, 0 stopped CPU states: 24,7% user, 11,3% system, 0,0% nice, 6,2% idle Mem: 1020808K av, 1015844K used, 4964K free, 531420K shrd, 24796K buff Swap: 1028112K av, 60K used, 1028052K free 338376K cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 11010 root 17 0 1036 1032 828 R 14,2 0,1 0:00 top 11007 postgres 14 0 14268 13M 12668 R 9,7 1,3 0:00 postmaster 11011 root 9 0 2184 2184 1584 S 3,0 0,2 0:00 sendmail 1 root 8 0 520 520 452 S 0,0 0,0 0:03 init 2 root 9 0 0 0 0 SW 0,0 0,0 0:00 keventd 3 root 9 0 0 0 0 SW 0,0 0,0 0:00 kapm-idled 4 root 19 19 0 0 0 SWN 0,0 0,0 0:00 ksoftirqd_CPU0 5 root 9 0 0 0 0 SW 0,0 0,0 0:29 kswapd 6 root 9 0 0 0 0 SW 0,0 0,0 0:00 kreclaimd 7 root 9 0 0 0 0 SW 0,0 0,0 0:09 bdflush 8 root 9 0 0 0 0 SW 0,0 0,0 0:00 kupdated 9 root -1 -20 0 0 0 SW< 0,0 0,0 0:00 mdrecoveryd 13 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 136 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 137 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 138 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 139 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald 140 root 9 0 0 0 0 SW 0,0 0,0 2:18 kjournald 378 root 9 0 0 0 0 SW 0,0 0,0 0:00 eth0 454 root 9 0 572 572 476 S 0,0 0,0 0:00 syslogd 459 root 9 0 1044 1044 392 S 0,0 0,1 0:00 klogd 572 root 8 0 1128 1092 968 S 0,0 0,1 0:07 sshd 584 root 9 0 1056 1056 848 S 0,0 0,1 0:02 nlservd 611 root 9 0 1836 1820 1288 S 0,0 0,1 0:00 sendmail 693 root 9 0 640 640 556 S 0,0 0,0 0:00 crond 729 daemon 9 0 472 464 404 S 0,0 0,0 0:00 atd 736 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 737 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 738 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 739 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 740 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 741 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty 9800 root 9 0 1888 1864 1552 S 0,0 0,1 0:03 sshd 9801 root 10 0 1368 1368 1016 S 0,0 0,1 0:00 bash 10838 postgres 7 0 6992 6992 6924 S 0,0 0,6 0:00 postmaster 10840 postgres 9 0 6984 6984 6932 S 0,0 0,6 0:00 postmaster 10841 postgres 9 0 7024 7024 6932 S 0,0 0,6 0:00 postmaster 10852 postgres 9 0 489M 489M 487M S 0,0 49,0 0:32 postmaster 10869 postgres 9 0 357M 357M 356M S 0,0 35,8 0:21 postmaster 10908 postgres 9 0 263M 263M 262M S 0,0 26,4 0:20 postmaster 10909 postgres 9 0 283M 283M 281M S 0,0 28,4 0:19 postmaster 10932 postgres 9 0 288M 288M 286M S 0,0 28,9 0:13 postmaster 10946 postgres 9 0 213M 213M 211M S 0,0 21,4 0:06 postmaster 10947 postgres 9 0 239M 239M 238M S 0,0 24,0 0:07 postmaster 10948 postgres 9 0 292M 292M 290M S 0,0 29,2 0:09 postmaster 10957 postgres 9 0 214M 214M 212M S 0,0 21,5 0:10 postmaster 10964 postgres 9 0 58156 56M 56400 S 0,0 5,6 0:05 postmaster 10974 postgres 9 0 50860 49M 49120 S 0,0 4,9 0:04 postmaster 10975 postgres 9 0 209M 209M 207M S 0,0 21,0 0:04 postmaster 10976 postgres 9 0 174M 174M 172M S 0,0 17,5 0:08 postmaster 10977 postgres 9 0 52484 51M 50932 S 0,0 5,1 0:05 postmaster 10990 postgres 9 0 199M 199M 197M S 0,0 19,9 0:06 postmaster 10993 postgres 9 0 141M 141M 139M S 0,0 14,1 0:01 postmaster 10998 postgres 9 0 181M 181M 180M S 0,0 18,2 0:04 postmaster 10999 postgres 9 0 139M 139M 138M S 0,0 14,0 0:01 postmaster 11001 postgres 9 0 45484 44M 43948 S 0,0 4,4 0:01 postmaster 11006 postgres 9 0 15276 14M 13952 S 0,0 1,4 0:00 postmaster now, does this look better in your eyes? > What are your current settings? Could you please repost. I lost earlier > thread(Sorry for that.. Had a HDD meltdown here couple of days back. Lost few > mails..) do you need more information here? From pgsql-general-owner@postgresql.org Wed Nov 13 04:59:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EF825475C8B for ; Wed, 13 Nov 2002 04:59:40 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 52D8D4759AF for ; Wed, 13 Nov 2002 04:59:38 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gAD9xcn30834 for ; Wed, 13 Nov 2002 15:29:38 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gAD9xcv30829 for ; Wed, 13 Nov 2002 15:29:38 +0530 From: "Shridhar Daithankar" To: Date: Wed, 13 Nov 2002 15:30:15 +0530 MIME-Version: 1.0 Subject: Re: Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD27007.325.4DE8FDF@localhost> In-reply-to: <013601c28af9$01730480$7100a8c0@STEINKAMP> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/530 X-Sequence-Number: 32951 On 13 Nov 2002 at 10:42, Henrik Steffen wrote: > > Yes. 2*max connection is minimum. Anything additional is always welcome as long > > as it does not starve the system. > > ok, I tried to set shared_buffers to 65535 now. but then restarting postgres > fails - it says: > > IpcMemoryCreate: shmget(key=5432001, size=545333248, 03600) failed: Invalid argument > > and a message telling me to either lower the shared_buffers or raise the > SHMMAX. Yes. you need to raise SHMMAX. A good feature of recent linux distro. is that they set SHMMAX to half of physical memory. A very good default IMO.. > 11:06am up 1 day, 16:46, 1 user, load average: 1,32, 1,12, 1,22 > 53 processes: 52 sleeping, 1 running, 0 zombie, 0 stopped > CPU states: 24,5% user, 11,2% system, 0,0% nice, 5,6% idle > Mem: 1020808K av, 1006156K used, 14652K free, 8520K shrd, 37204K buff > Swap: 1028112K av, 60K used, 1028052K free 849776K cached > I have now changed the SHMMAX settings to 545333248 and changed the > shared_buffers to 65535 again. now postgres starts up correctly. > > the top result changes to: > > 11:40am up 1 day, 17:20, 1 user, load average: 2,24, 2,51, 2,14 > 57 processes: 55 sleeping, 2 running, 0 zombie, 0 stopped > CPU states: 24,7% user, 11,3% system, 0,0% nice, 6,2% idle > Mem: 1020808K av, 1015844K used, 4964K free, 531420K shrd, 24796K buff > Swap: 1028112K av, 60K used, 1028052K free 338376K cached > now, does this look better in your eyes? Well, don't look at top to find out free memoy. Use free. On my machine.. [shridhar@perth shridhar]$ free total used free shared buffers cached Mem: 255828 250676 5152 0 66564 29604 -/+ buffers/cache: 154508 101320 Swap: 401616 12764 388852 [shridhar@perth shridhar]$ Here the important value is second value in second line, 101320. That's true free memory. Remeber when system needs memory, it can always shrunk cache/buffers. In both of your stats, cache+memory are roughly 400MB. Relax, your system is not starving for memory... > do you need more information here? Not for this problem, but just curious. What does uname -a says? Secondly just curious, with 5000 requests per minute, what is the peak number of connection you are getting? You should look int pooling parameters for better performance.. HTH Bye Shridhar -- Hawkeye's Conclusion: It's not easy to play the clown when you've got to run the whole circus. From pgsql-general-owner@postgresql.org Wed Nov 13 05:55:18 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6308A4764D1 for ; Wed, 13 Nov 2002 05:55:16 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 37DC4476493 for ; Wed, 13 Nov 2002 05:55:15 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 11:55:15 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 11:50:43 +0100 Message-ID: <01c001c28b03$1419e7c0$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Cc: References: <3DD27007.325.4DE8FDF@localhost> Subject: Re: Upgrade to dual processor machine? Date: Wed, 13 Nov 2002 11:54:45 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/532 X-Sequence-Number: 32953 Dear Shridhar, ok, so my system has got 362 MB of free RAM currently... this sounds good. uname -a says: Linux db2.city-map.de 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown I didn't actually measure requests per minute through a longer period... I tested it 2 hours ago using debug and logging all queries, and I saw approx. 2500 requests per minute. but at that time of the day there are only about 25 simultaneous users on our website. so i calculated 50 users and 5.000 rpm for average daytime usage. I guess the maximum peak would be approx. 10.000 queries per minute. -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Shridhar Daithankar" To: Sent: Wednesday, November 13, 2002 11:00 AM Subject: Re: [GENERAL] Upgrade to dual processor machine? > On 13 Nov 2002 at 10:42, Henrik Steffen wrote: > > > Yes. 2*max connection is minimum. Anything additional is always welcome as long > > > as it does not starve the system. > > > > ok, I tried to set shared_buffers to 65535 now. but then restarting postgres > > fails - it says: > > > > IpcMemoryCreate: shmget(key=5432001, size=545333248, 03600) failed: Invalid argument > > > > and a message telling me to either lower the shared_buffers or raise the > > SHMMAX. > > Yes. you need to raise SHMMAX. A good feature of recent linux distro. is that > they set SHMMAX to half of physical memory. A very good default IMO.. > > > 11:06am up 1 day, 16:46, 1 user, load average: 1,32, 1,12, 1,22 > > 53 processes: 52 sleeping, 1 running, 0 zombie, 0 stopped > > CPU states: 24,5% user, 11,2% system, 0,0% nice, 5,6% idle > > Mem: 1020808K av, 1006156K used, 14652K free, 8520K shrd, 37204K buff > > Swap: 1028112K av, 60K used, 1028052K free 849776K cached > > I have now changed the SHMMAX settings to 545333248 and changed the > > shared_buffers to 65535 again. now postgres starts up correctly. > > > > the top result changes to: > > > > 11:40am up 1 day, 17:20, 1 user, load average: 2,24, 2,51, 2,14 > > 57 processes: 55 sleeping, 2 running, 0 zombie, 0 stopped > > CPU states: 24,7% user, 11,3% system, 0,0% nice, 6,2% idle > > Mem: 1020808K av, 1015844K used, 4964K free, 531420K shrd, 24796K buff > > Swap: 1028112K av, 60K used, 1028052K free 338376K cached > > now, does this look better in your eyes? > > Well, don't look at top to find out free memoy. Use free. On my machine.. > > [shridhar@perth shridhar]$ free > total used free shared buffers cached > Mem: 255828 250676 5152 0 66564 29604 > -/+ buffers/cache: 154508 101320 > Swap: 401616 12764 388852 > [shridhar@perth shridhar]$ > > Here the important value is second value in second line, 101320. That's true > free memory. Remeber when system needs memory, it can always shrunk > cache/buffers. In both of your stats, cache+memory are roughly 400MB. > > Relax, your system is not starving for memory... > > > do you need more information here? > > Not for this problem, but just curious. What does uname -a says? > > Secondly just curious, with 5000 requests per minute, what is the peak number > of connection you are getting? You should look int pooling parameters for > better performance.. > > HTH > > > Bye > Shridhar > > -- > Hawkeye's Conclusion: It's not easy to play the clown when you've got to run > the whole circus. > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly From pgsql-general-owner@postgresql.org Wed Nov 13 06:02:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 576694760E3 for ; Wed, 13 Nov 2002 06:02:08 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id A98B6475C8B for ; Wed, 13 Nov 2002 06:02:05 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gADB26A04568 for ; Wed, 13 Nov 2002 16:32:06 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gADB26v04563 for ; Wed, 13 Nov 2002 16:32:06 +0530 From: "Shridhar Daithankar" To: Date: Wed, 13 Nov 2002 16:32:42 +0530 MIME-Version: 1.0 Subject: Re: Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD27EAA.29848.517BFB4@localhost> In-reply-to: <01c001c28b03$1419e7c0$7100a8c0@STEINKAMP> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/535 X-Sequence-Number: 32956 On 13 Nov 2002 at 11:54, Henrik Steffen wrote: > Dear Shridhar, > > ok, so my system has got 362 MB of free RAM currently... this sounds good. Cool.. Keep watching that.. If that goes down to less than 50, you certainly need to look into.. > uname -a says: > Linux db2.city-map.de 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown hmm.. Some sort of RedHat I assume. Upgrade the kernel at least. Any variant of 2.4.19.x should give you at least 10-15% performance increase. Besides that will cure the linux VM fiascos as well.. > I didn't actually measure requests per minute through a longer period... > I tested it 2 hours ago using debug and logging all queries, and I saw > approx. 2500 requests per minute. but at that time of the day there are > only about 25 simultaneous users on our website. so i calculated 50 > users and 5.000 rpm for average daytime usage. I guess the maximum peak > would be approx. 10.000 queries per minute. Hmm.. Certainly connection pooling will give you advantage. Tune it if you can( php BTW?) HTH Bye Shridhar -- divorce, n: A change of wife. From pgsql-general-owner@postgresql.org Wed Nov 13 07:00:53 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4AB0F476866 for ; Wed, 13 Nov 2002 07:00:52 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 7D72C47684C for ; Wed, 13 Nov 2002 07:00:49 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.203) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 13:00:49 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Wed, 13 Nov 2002 12:56:17 +0100 Message-ID: <000d01c28b0c$3c941000$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Cc: References: <3DD27EAA.29848.517BFB4@localhost> Subject: Re: Upgrade to dual processor machine? Date: Wed, 13 Nov 2002 13:00:18 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/542 X-Sequence-Number: 32963 > Cool.. Keep watching that.. If that goes down to less than 50, you certainly > need to look into.. I will. > hmm.. Some sort of RedHat I assume. Upgrade the kernel at least. Any variant of > 2.4.19.x should give you at least 10-15% performance increase. Besides that > will cure the linux VM fiascos as well.. redhat, right. Ok, I will have this tested. > Hmm.. Certainly connection pooling will give you advantage. Tune it if you can( > php BTW?) using persistent connections with perl / apache mod_perl From pgsql-general-owner@postgresql.org Wed Nov 13 08:20:45 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C376C47646A for ; Wed, 13 Nov 2002 08:20:44 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 9AB7C4763EC for ; Wed, 13 Nov 2002 08:20:43 -0500 (EST) Received: from tokyo.samurai.com (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id E9D2F1E9A; Wed, 13 Nov 2002 08:20:45 -0500 (EST) To: shridhar_daithankar@persistent.co.in Cc: Subject: Re: Upgrade to dual processor machine? References: <3DD25258.11435.46A9D60@localhost> From: Neil Conway In-Reply-To: <3DD25258.11435.46A9D60@localhost> Date: 13 Nov 2002 08:20:43 -0500 Message-ID: <87k7jhvc5w.fsf@mailbox.samurai.com> Lines: 18 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/545 X-Sequence-Number: 32966 "Shridhar Daithankar" writes: > 3) Sort mem is a tricky affair. AFAIU, it is used only when you create index or > sort results of a query. If do these things seldomly, you can set this very low > or default. For individual session that creates index, you can set the sort > memory accordingly. What would the benefit of this be? sort_mem is just an upper limit on memory consumption, and that memory is only allocated on demand. So there shouldn't be a difference between setting sort_mem globally to some reasonable value, and manually changing it for backends that need to do any sorting. Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-general-owner@postgresql.org Wed Nov 13 08:24:33 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E5AF04760AF for ; Wed, 13 Nov 2002 08:24:32 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 77BEE475D70 for ; Wed, 13 Nov 2002 08:24:31 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gADDOYk22294 for ; Wed, 13 Nov 2002 18:54:34 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gADDOYv22289 for ; Wed, 13 Nov 2002 18:54:34 +0530 From: "Shridhar Daithankar" To: Date: Wed, 13 Nov 2002 18:55:06 +0530 MIME-Version: 1.0 Subject: Re: Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD2A00A.22227.34D748@localhost> References: <3DD25258.11435.46A9D60@localhost> In-reply-to: <87k7jhvc5w.fsf@mailbox.samurai.com> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/546 X-Sequence-Number: 32967 On 13 Nov 2002 at 8:20, Neil Conway wrote: > "Shridhar Daithankar" writes: > > 3) Sort mem is a tricky affair. AFAIU, it is used only when you create index or > > sort results of a query. If do these things seldomly, you can set this very low > > or default. For individual session that creates index, you can set the sort > > memory accordingly. > > What would the benefit of this be? sort_mem is just an upper limit on > memory consumption, and that memory is only allocated on demand. So > there shouldn't be a difference between setting sort_mem globally to > some reasonable value, and manually changing it for backends that need > to do any sorting. Well, while that is correct, setting sort mem high only when required would prevent memory exhaustion if that happens. Remember he has 5000 requests per minute with concurrent connection. Now say there is a default high setting of sort mem and a connection persist for a long time, it *might* accumulate memory. Personally I would not keep it high by default. Bye Shridhar -- Absentee, n.: A person with an income who has had the forethought to remove himself from the sphere of exaction. -- Ambrose Bierce, "The Devil's Dictionary" From pgsql-general-owner@postgresql.org Wed Nov 13 08:29:50 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B124A476441 for ; Wed, 13 Nov 2002 08:29:48 -0500 (EST) Received: from ns1.gnw.de (ns1.turtle-entertainment.de [193.41.200.20]) by postgresql.org (Postfix) with ESMTP id 928554763EC for ; Wed, 13 Nov 2002 08:29:47 -0500 (EST) Received: from [213.148.158.226] (helo=mail.office.turtle-entertainment.de) by ns1.gnw.de with esmtp (Exim 3.16 #1 (Debian)) id 18Bxab-000552-00 for ; Wed, 13 Nov 2002 14:29:53 +0100 Received: from bm.office.turtle-entertainment.de ([212.6.194.129] helo=shock) by mail.office.turtle-entertainment.de with asmtp (Exim 3.22 #7 (Debian)) id 18BxaW-0006Vq-00 for ; Wed, 13 Nov 2002 14:29:48 +0100 Message-ID: <021e01c28b18$c516b1b0$81c206d4@office.turtleentertainment.de> From: =?iso-8859-1?Q?Bj=F6rn_Metzdorf?= To: References: <3DD25258.11435.46A9D60@localhost> <3DD2A00A.22227.34D748@localhost> Subject: Re: Upgrade to dual processor machine? Date: Wed, 13 Nov 2002 14:30:01 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Scanner: exiscan *18BxaW-0006Vq-00*135QEiU6Fjw* http://duncanthrax.net/exiscan/ X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/547 X-Sequence-Number: 32968 > > What would the benefit of this be? sort_mem is just an upper limit on > > memory consumption, and that memory is only allocated on demand. So > > there shouldn't be a difference between setting sort_mem globally to > > some reasonable value, and manually changing it for backends that need > > to do any sorting. > > Well, while that is correct, setting sort mem high only when required would > prevent memory exhaustion if that happens. > > Remember he has 5000 requests per minute with concurrent connection. Now say > there is a default high setting of sort mem and a connection persist for a long > time, it *might* accumulate memory. Personally I would not keep it high by > default. Could you elaborate on what exactly is a query requiring sorting (and therefore is affected by sort_mem setting)? Is it a SELECT with WHERE-clause using seq scan? Is it rebuilding of an index? What else could it be? Regards, Bjoern From pgsql-general-owner@postgresql.org Wed Nov 13 08:34:17 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BFDD54768AC for ; Wed, 13 Nov 2002 08:34:15 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id D2F0D476872 for ; Wed, 13 Nov 2002 08:33:50 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gADDXrl23039 for ; Wed, 13 Nov 2002 19:03:53 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gADDXrv23034 for ; Wed, 13 Nov 2002 19:03:53 +0530 From: "Shridhar Daithankar" To: Date: Wed, 13 Nov 2002 19:04:27 +0530 MIME-Version: 1.0 Subject: Re: Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD2A23B.9377.3D66EE@localhost> In-reply-to: <021e01c28b18$c516b1b0$81c206d4@office.turtleentertainment.de> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=ISO-8859-1 Content-description: Mail message body Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from Quoted-printable to 8bit by www.pspl.co.in id gADDXrv23034 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/548 X-Sequence-Number: 32969 On 13 Nov 2002 at 14:30, Bj�rn Metzdorf wrote: > Could you elaborate on what exactly is a query requiring sorting (and > therefore is affected by sort_mem setting)? > Is it a SELECT with WHERE-clause using seq scan? Is it rebuilding of an > index? What else could it be? I can think of an sql query with an order by clause on a non-indexed field and say that field is not included in where condition e.g. select name, addreess from users where id>1000 order by name; with index on id. Bye Shridhar -- You canna change the laws of physics, Captain; I've got to have thirty minutes! From pgsql-general-owner@postgresql.org Wed Nov 13 08:52:33 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 982EC476858 for ; Wed, 13 Nov 2002 08:52:32 -0500 (EST) Received: from varsoon.wireboard.com (www.wireboard.com [216.151.155.101]) by postgresql.org (Postfix) with ESMTP id A5BAD475C8B for ; Wed, 13 Nov 2002 08:52:29 -0500 (EST) Received: from doug by varsoon.wireboard.com with local (Exim 3.35 #1) id 18BxwE-00084Q-00; Wed, 13 Nov 2002 08:52:14 -0500 To: "Henrik Steffen" Cc: , Subject: Re: Upgrade to dual processor machine? References: <3DD27EAA.29848.517BFB4@localhost> <000d01c28b0c$3c941000$7100a8c0@STEINKAMP> From: Doug McNaught Date: 13 Nov 2002 08:52:14 -0500 In-Reply-To: "Henrik Steffen"'s message of "Wed, 13 Nov 2002 13:00:18 +0100" Message-ID: Lines: 12 User-Agent: Gnus/5.0806 (Gnus v5.8.6) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/552 X-Sequence-Number: 32973 "Henrik Steffen" writes: > > hmm.. Some sort of RedHat I assume. Upgrade the kernel at least. Any variant of > > 2.4.19.x should give you at least 10-15% performance increase. Besides that > > will cure the linux VM fiascos as well.. > > redhat, right. Ok, I will have this tested. If you don't want to roll your own, I think RH has a newer errata kernel on updates.redhat.com that you can install as an RPM. -Doug From pgsql-general-owner@postgresql.org Wed Nov 13 09:11:40 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 88EC647658F for ; Wed, 13 Nov 2002 09:11:38 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 58038476942 for ; Wed, 13 Nov 2002 09:11:09 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gADEB3hR021153; Wed, 13 Nov 2002 09:11:03 -0500 (EST) To: shridhar_daithankar@persistent.co.in Cc: pgsql-general@postgresql.org Subject: Re: Upgrade to dual processor machine? In-reply-to: <3DD25258.11435.46A9D60@localhost> References: <3DD25258.11435.46A9D60@localhost> Comments: In-reply-to "Shridhar Daithankar" message dated "Wed, 13 Nov 2002 13:23:36 +0530" Date: Wed, 13 Nov 2002 09:11:03 -0500 Message-ID: <21152.1037196663@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/560 X-Sequence-Number: 32981 "Shridhar Daithankar" writes: > 3) Sort mem is a tricky affair. AFAIU, it is used only when you create > index or sort results of a query. If do these things seldomly, you can > set this very low or default. I think this is bad advice. Sort memory is only consumed when needed, so there's no advantage in decreasing the setting just because you think a particular client process isn't going to need to sort. All you will accomplish is to pessimize your performance if a sort does happen to be needed. You do need to set the installation default on the basis of thinking about what will happen if all backends are trying to sort at once. But having done that, you should be able to increase the setting in individual sessions that you know are going to do large sorts. The default setting (1024K) is, like most of the default settings in PG, on the small side IMHO. I don't care for advice that leads to allocating half of physical RAM to PG's shared buffers, either. This ignores the fact that the kernel's disk caches are nearly as effective as PG's internal buffers, and much more flexible (because the kernel can decrease the size of its caches when there's heavy memory pressure from processes). I'd start with a few thousand shared buffers and let the kernel consume the bulk of RAM with its buffering. That approach lets you use a higher sort_mem setting, too. regards, tom lane From pgsql-general-owner@postgresql.org Wed Nov 13 12:02:11 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9E51D475F32; Wed, 13 Nov 2002 12:02:08 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 7B901475F28; Wed, 13 Nov 2002 12:02:07 -0500 (EST) Received: by davinci.ethosmedia.com (CommuniGate Pro PIPE 3.5.9) with PIPE id 1824299; Wed, 13 Nov 2002 09:05:40 -0800 X-Spam-Status: Scanner Called Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1824298; Wed, 13 Nov 2002 09:05:35 -0800 From: "Josh Berkus" Subject: Re: Upgrade to dual processor machine? To: "Henrik Steffen" , Cc: , pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Wed, 13 Nov 2002 09:05:35 -0800 Message-ID: In-Reply-To: <008f01c28ae6$64a45e40$7100a8c0@STEINKAMP> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Spam-Status: No, hits=-4.1 required=6.0 tests=IN_REP_TO, SUBJ_ENDS_IN_Q_MARK, AWL version=2.20 X-Spam-Level: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/574 X-Sequence-Number: 32995 Henrik, First off, I'm moving this discussion to the PGSQL-PERFORMANCE list, where it belongs. To subscribe, send the message "subscribe pgsql-perform your@email.address" to "majordomo@postgresql.org". > This is was I figured out now: > > 1) RAM available: 1024 MB, there's nothing else but postgres on this > machine, so if I calculate 128 MB for Linux, there are 896 MB left > for Postgres. > > 2) 70 % of 896 MB is 627 MB > > Now, if I follow your instructions: > > 250K + > 8.2K * 128 (shared_buffers) = 1049,6K + > 14.2K * 64 (max_connections) = 908,8K + > 1024K * 5000 (average number of requests per minute) = 5120000K > =============================================================== > 5122208.4K ==> 5002.16 MB > > this is a little bit more than I have available, isn't it? :((( > > sure that this has got to be the "average number of requests per > minute" > and not "per second" ? seems so much, doesn't it? > > what am I supposed to do now? Well, now it gets more complicated. You need to determine: A) The median processing time of each of those requests. B) The amount of Sort_mem actually required for each request. I reccommend "per minute" because that's an easy over-estimate ... few requests last a full minute, and as a result average-requests-per-minute gives you a safe guage of maximum concurrent requests (in transactional database environments), which is really what we are trying to determine. Um, you do know that I'm talking about *database* requests -- that is, queries -- and not web page requests, yes? If you're using server-side caching, there can be a *huge* difference. If you have 5000 requests per minute, and only 64 connections, then I can hypothesize that: 1) you are doing some kind of connection pooling; 2) those are exclusively *read-only* requests; 3) those are very simple requests, or at least processed very quickly. If all of the above is true, then you can probably base you calculation on requests-per-second, rather than requests-per-minute. Then, of course, it becomes an interactive process. You change the settings, re-start the database server, and watch the memory used by the postgreSQL processes. Your goal is to have that memory usage hover around 700mb during heavy usage periods (any less, and you are throttling the database through scarcity of RAM) but to never, ever, force usage of Swap memory, which will slow down the server 10-fold. If you see the RAM only at half that, but the processor at 90%+, then you should consider upgrading your processor. But you're more likely to run out of RAM first. I believe that you haven't already because with your low shared-buffer settings, most of the potential sort_mem is going unused. BTW, if you are *really* getting 5000 queries per minute, I would strongly reccomend doubling your RAM. -Josh Berkus > > ----- Original Message ----- > From: "Josh Berkus" > To: > Cc: > Sent: Tuesday, November 12, 2002 9:05 PM > Subject: Re: Upgrade to dual processor machine? > > > Heinrik, > > "So, where do i find and change shmmax shmall settings ?? > What should I put there? > > What is a recommended value for shared buffers in postgresql.conf ?" > > There is no "recommended value." You have to calculate this > relatively: > > 1) Figure out how much RAM your server has available for PostgreSQL. > For > example, I have one server on which I allocate 256 mb for Apache, 128 > mb for > linux, and thus have 512mb available for Postgres. > > 2) Calculate out the memory settings to use 70% of that amount of Ram > in > regular usage. Please beware that sort_mem is *not* shared, meaning > that it > will be multiplied by the number of concurrent requests requiring > sorting. > Thus, your calculation (in K) should be: > > 250K + > 8.2K * shared_buffers + > 14.2K * max_connections + > sort_mem * average number of requests per minute > ===================================== > memory available to postgresql in K * 0.7 > > You will also have to set SHMMAX and SHMMALL to accept this memory > allocation. > Since shmmax is set in bytes, then I generally feel safe making it: > 1024 * 0.5 * memory available to postgresql in K > > Setting them is done simply: > $ echo 134217728 >/proc/sys/kernel/shmall > $ echo 134217728 >/proc/sys/kernel/shmmax > > This is all taken from the postgresql documentation, with some > experience: > http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/runtime.html > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco From pgsql-general-owner@postgresql.org Wed Nov 13 12:33:34 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CF678475F28 for ; Wed, 13 Nov 2002 12:33:32 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 3CAA2475EF7 for ; Wed, 13 Nov 2002 12:33:32 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gADHWFMU025725; Wed, 13 Nov 2002 10:32:15 -0700 (MST) Date: Wed, 13 Nov 2002 10:18:19 -0700 (MST) From: "scott.marlowe" To: Henrik Steffen Cc: , Subject: Re: Upgrade to dual processor machine? In-Reply-To: <00b901c28aec$a0d19580$7100a8c0@STEINKAMP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/578 X-Sequence-Number: 32999 On Wed, 13 Nov 2002, Henrik Steffen wrote: > > Hello Shridhar, > > thanks for your answer... > > 1) in the docs it says: shared_buffers should be 2*max_connections, min 16. > now, you suggest to put it to 500-600 MB, which means I will have to > increase shared_buffers to 68683 -- is this really correct? I mean, > RAM is allready now almost totally consumed. Actually, that's not quite correct. The RAM is already showing as being in use, but it's being used by the kernel as file cache, and will be released the second a process asks for more memory, so it really isn't "in use" in the classic sense. > 2) the database has a size of 3.6 GB at the moment... about 100 user tables. > > 3) ok, I understand: I am not creating any indexes usually. Only once at night > all user indexes are dropped and recreated, I could imagine to increase the > sort_mem for this script... so sort_mem with 1024K is ok, or should it be > lowered to, say, 512K ? Generally a sort mem of 8 meg or less is pretty safe, as the allocation is only made WHILE the sort is running and is released right after. The danger is that if it is set higher, like say 32 or 64 meg, and a dozen or so sql statements just happen to all sort at the same time, you can run out of memory and have a "swap storm" where the machine is swapping out processes one after the other to give each the amount of swap space it needs. Note also that a SQL query with more than one sort in it will use up to sort_mem for each sort independently, so a dozen SQL queries that each require say three sorts all running at once can theoretically use 36*sort_mem amount of memory. Once the machine starts swapping for sort_mem, things get slow VERY fast. It's one of those knees you don't want to hit. From pgsql-general-owner@postgresql.org Wed Nov 13 12:18:23 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E9F5747632D; Wed, 13 Nov 2002 12:18:21 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 0AB6E47628E; Wed, 13 Nov 2002 12:18:20 -0500 (EST) Received: by davinci.ethosmedia.com (CommuniGate Pro PIPE 3.5.9) with PIPE id 1824317; Wed, 13 Nov 2002 09:21:55 -0800 X-Spam-Status: Scanner Called Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1824321; Wed, 13 Nov 2002 09:21:50 -0800 From: "Josh Berkus" Subject: Re: Upgrade to dual processor machine? To: "Josh Berkus" , "Henrik Steffen" , Cc: , pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Wed, 13 Nov 2002 09:21:50 -0800 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Spam-Status: No, hits=-4.1 required=6.0 tests=IN_REP_TO, SUBJ_ENDS_IN_Q_MARK, AWL version=2.20 X-Spam-Level: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/576 X-Sequence-Number: 32997 Henrik Oops! Two corrections, below. Sorry about the typos. > First off, I'm moving this discussion to the PGSQL-PERFORMANCE list, > where it belongs. To subscribe, send the message "subscribe > pgsql-perform your@email.address" to "majordomo@postgresql.org". Sorry ... thats "subscribe pgsql-performance your@email.address". > Then, of course, it becomes an interactive process. You change the > settings, re-start the database server, and watch the memory used by > the postgreSQL processes. Your goal is to have that memory usage > hover around 700mb during heavy usage periods (any less, and you are That's "600mb", not "700mb". I also just read Tom's response regarding reserving more RAM for kernel buffering. This hasn't been my experience, but then I work mostly with transactional databases (many read-write requests) rather than read-only databases. As such, I'd be interested in a test: Calculate out your PostgreSQL RAM to total, say, 256mb and run a speed test on the database. Then calculate it out to the previous 600mb, and do the same. I'd like to know the results. In fact, e-mail me off list if you want further help -- I'm interested in the outcome. -Josh Berkus From pgsql-performance-owner@postgresql.org Wed Nov 13 16:44:07 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0EC46475F66 for ; Wed, 13 Nov 2002 16:44:06 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 4388D475DD7 for ; Wed, 13 Nov 2002 16:44:05 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1824793; Wed, 13 Nov 2002 13:47:35 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Mike Nielsen Subject: Re: Query performance discontinuity Date: Wed, 13 Nov 2002 13:45:34 -0800 X-Mailer: KMail [version 1.4] Cc: Rod Taylor , Postgresql performance References: <1037145841.2280.7.camel@CPE-144-132-182-167.nsw.bigpond.net.au> In-Reply-To: <1037145841.2280.7.camel@CPE-144-132-182-167.nsw.bigpond.net.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211131345.34038.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/35 X-Sequence-Number: 193 Mike, > Yes, I'd run a VACUUM FULL ANALYZE -- I did it again just to make sure, > and re-ran the query (similar result): >=20 > pganalysis=3D> explain analyze select * from ps2 where tstart> '2000-1-1 > pganalysis'> 00:00:00' and time_stamp > '2000-1-1 00:00:00' order by > pganalysis-> tstart,time_stamp limit 59628; > NOTICE: QUERY PLAN: >=20 > Limit (cost=3D160313.27..160313.27 rows=3D59628 width=3D179) (actual > time=3D45405.47..46320.12 rows=3D59628 loops=3D1) > -> Sort (cost=3D160313.27..160313.27 rows=3D327895 width=3D179) (actu= al > time=3D45405.46..46248.31 rows=3D59629 loops=3D1) > -> Seq Scan on ps2 (cost=3D0.00..13783.40 rows=3D327895 width= =3D179) > (actual time=3D13.52..17111.66 rows=3D327960 loops=3D1) > Total runtime: 46894.21 msec >=20 > EXPLAIN >=20 > Unfortunately, I have not yet had time to experiment with twiddling the > query optimizer parameters or memory -- my apologies for this, but, > well, a guy's gotta eat... Well, I''ll just concur with what others have said: for some reason, the=20 parser is slightly underestimateing the cost of a seq scan, and dramaticall= y=20 overestimating the cost of an index scan, for this query.=20=20=20 Other than tweaking to parser calculation values, I'd suggest dropping and= =20 re-building the index just for thouroughness. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 13 23:04:44 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 669D8475D93 for ; Wed, 13 Nov 2002 23:04:43 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id F2202475D87 for ; Wed, 13 Nov 2002 23:04:41 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gAE44kM02403 for ; Thu, 14 Nov 2002 09:34:46 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gAE44kv02398 for ; Thu, 14 Nov 2002 09:34:46 +0530 From: "Shridhar Daithankar" To: pgsql-performance@postgresql.org Date: Thu, 14 Nov 2002 09:35:21 +0530 MIME-Version: 1.0 Subject: Re: Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD36E59.10218.284E8AE@localhost> In-reply-to: References: X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/36 X-Sequence-Number: 194 On 13 Nov 2002 at 9:21, Josh Berkus wrote: > I also just read Tom's response regarding reserving more RAM for kernel > buffering. This hasn't been my experience, but then I work mostly > with transactional databases (many read-write requests) rather than > read-only databases. > > As such, I'd be interested in a test: Calculate out your PostgreSQL > RAM to total, say, 256mb and run a speed test on the database. Then > calculate it out to the previous 600mb, and do the same. I'd like to > know the results. I would like to add here. Let's say you do large amount of reads/writes. Make sure that size of data exceeds RAM allocated to postgresql. Testing 100MB of data with 256MB or 600MB of buffers isn't going to make any difference in performance. If this is the practical scenario, then Tom's suggestion is a better solution. IMO postgresql buffers should be enough to hold data requierd for transactions+some good chunk of read only data. Read only data can be left to OS buffers for most part of it.. HTH Bye Shridhar -- Sometimes a feeling is all we humans have to go on. -- Kirk, "A Taste of Armageddon", stardate 3193.9 From pgsql-general-owner@postgresql.org Thu Nov 14 00:50:58 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 38EE5476161 for ; Thu, 14 Nov 2002 00:50:58 -0500 (EST) Received: from svana.org (svana.org [203.20.62.76]) by postgresql.org (Postfix) with ESMTP id 88E3C476122 for ; Thu, 14 Nov 2002 00:50:57 -0500 (EST) Received: from kleptog by svana.org with local (Exim 3.35 #1 (Debian)) id 18CCob-0004bE-00; Thu, 14 Nov 2002 16:45:21 +1100 Date: Thu, 14 Nov 2002 16:45:21 +1100 From: Martijn van Oosterhout To: "scott.marlowe" Cc: Henrik Steffen , shridhar_daithankar@persistent.co.in, pgsql-general@postgresql.org Subject: Re: Upgrade to dual processor machine? Message-ID: <20021114054520.GA14531@svana.org> Reply-To: Martijn van Oosterhout Mail-Followup-To: "scott.marlowe" , Henrik Steffen , shridhar_daithankar@persistent.co.in, pgsql-general@postgresql.org References: <00b901c28aec$a0d19580$7100a8c0@STEINKAMP> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.28i X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 X-PGP-Key-URL: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/608 X-Sequence-Number: 33029 --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 13, 2002 at 10:18:19AM -0700, scott.marlowe wrote: > Generally a sort mem of 8 meg or less is pretty safe, as the allocation i= s=20 > only made WHILE the sort is running and is released right after. The=20 > danger is that if it is set higher, like say 32 or 64 meg, and a dozen or= =20 > so sql statements just happen to all sort at the same time, you can run= =20 > out of memory and have a "swap storm" where the machine is swapping out= =20 > processes one after the other to give each the amount of swap space it=20 > needs. Note also that a SQL query with more than one sort in it will use= =20 > up to sort_mem for each sort independently, so a dozen SQL queries that= =20 > each require say three sorts all running at once can theoretically use=20 > 36*sort_mem amount of memory. Once the machine starts swapping for=20 > sort_mem, things get slow VERY fast. It's one of those knees you don't= =20 > want to hit. Something I havn't seen mentioned yet is the very useful program "vmstat". It gives you a quick summary of how many blocks are being copied to and from disk, whether and how much you are swapping, how many processes are actually running and sleeping at any one time. You can tell it you give you an average over any period of time (like a minute or an hour). Example: # vmstat 1 procs memory swap io system = cpu r b w swpd free buff cache si so bi bo in cs us sy= id 1 0 0 29728 47584 1128 63048 3 2 17 10 21 38 9 2= 35 1 0 0 29728 47584 1128 63048 0 0 0 0 1539 356 6 0= 94 1 0 0 29728 47552 1128 63080 0 0 32 0 1542 354 5 1= 94 1 0 0 29728 47552 1128 63080 0 0 0 0 1551 355 6 0= 94 1 0 0 29728 47520 1128 63112 0 0 32 0 1542 361 5 2= 93 As you can see, not a terribly loaded machine :) --=20 Martijn van Oosterhout http://svana.org/kleptog/ > We place no reliance On Virgin or Pigeon;=20 > Our method is Science, Our aim is Religion. - Aleister Crowley --KsGdsel6WgEHnImy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE90zhwY5Twig3Ge+YRArSlAKCQCO+cJ+7NBfA1bm6L0FcBtqIXLQCfTj4Z MJFRriR1gdf4G8966rMltY4= =knXG -----END PGP SIGNATURE----- --KsGdsel6WgEHnImy-- From pgsql-general-owner@postgresql.org Thu Nov 14 04:28:51 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F045E475FD3 for ; Thu, 14 Nov 2002 04:28:48 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 10B0D475C3D for ; Thu, 14 Nov 2002 04:28:47 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.218) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 10:28:46 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 10:22:37 +0100 Message-ID: <001501c28bc0$2a339340$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Josh Berkus" Cc: , References: Subject: Re: Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 10:28:17 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/609 X-Sequence-Number: 33030 ok, now i subscribed to performance, too ;-) > Well, now it gets more complicated. You need to determine: > A) The median processing time of each of those requests. > B) The amount of Sort_mem actually required for each request. as I am dealing with postgres for a webserver the median processing time of each request has got to be <1 sec. how can i measure the amount of sort_mem needed? at the highest there are perhaps 20 concurrent database requests at the same time. i have enabled 64 maximum connections, because i have apache configured to use persistent database connections using mod_perl and pg.pm. I set Apache to run MaxClients at 40 (there could additionally be some manual psql connections) > Um, you do know that I'm talking about *database* requests -- that is, > queries -- and not web page requests, yes? If you're using server-side > caching, there can be a *huge* difference. yes, I did understand that. And when I measured 5.000 requests per minute I looked at the pgsql.log (after enabling the debug options and counting all the queries within minute). so, server-side caching does not appear within these 5.000 requests... that's for sure. > If you have 5000 requests per minute, and only 64 connections, then I > can hypothesize that: > 1) you are doing some kind of connection pooling; > 2) those are exclusively *read-only* requests; > 3) those are very simple requests, or at least processed very quickly 1) correct 2) no, not exclusively - but as it's a webserver-application (www.city-map.de) most users just read from the database, while they always do an update to raise some statistics (page-views counters etc.) - furthermore, there is an internal content-management system where about 100 editors do inserts and updates. but there are of course more visitors (>10.000 daily) than editors. 3) yes, many requests are very simple for better performance in a web-application Swapping does never happen so far. -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Josh Berkus" To: "Henrik Steffen" ; Cc: ; Sent: Wednesday, November 13, 2002 6:05 PM Subject: Re: [GENERAL] Upgrade to dual processor machine? > Henrik, > > First off, I'm moving this discussion to the PGSQL-PERFORMANCE list, > where it belongs. To subscribe, send the message "subscribe > pgsql-perform your@email.address" to "majordomo@postgresql.org". > > > This is was I figured out now: > > > > 1) RAM available: 1024 MB, there's nothing else but postgres on this > > machine, so if I calculate 128 MB for Linux, there are 896 MB left > > for Postgres. > > > > 2) 70 % of 896 MB is 627 MB > > > > Now, if I follow your instructions: > > > > 250K + > > 8.2K * 128 (shared_buffers) = 1049,6K + > > 14.2K * 64 (max_connections) = 908,8K + > > 1024K * 5000 (average number of requests per minute) = 5120000K > > =============================================================== > > 5122208.4K ==> 5002.16 MB > > > > this is a little bit more than I have available, isn't it? :((( > > > > sure that this has got to be the "average number of requests per > > minute" > > and not "per second" ? seems so much, doesn't it? > > > > what am I supposed to do now? > > Well, now it gets more complicated. You need to determine: > A) The median processing time of each of those requests. > B) The amount of Sort_mem actually required for each request. > > I reccommend "per minute" because that's an easy over-estimate ... few > requests last a full minute, and as a result > average-requests-per-minute gives you a safe guage of maximum > concurrent requests (in transactional database environments), which is > really what we are trying to determine. > > Um, you do know that I'm talking about *database* requests -- that is, > queries -- and not web page requests, yes? If you're using server-side > caching, there can be a *huge* difference. > > If you have 5000 requests per minute, and only 64 connections, then I > can hypothesize that: > 1) you are doing some kind of connection pooling; > 2) those are exclusively *read-only* requests; > 3) those are very simple requests, or at least processed very quickly. > > If all of the above is true, then you can probably base you calculation > on requests-per-second, rather than requests-per-minute. > > Then, of course, it becomes an interactive process. You change the > settings, re-start the database server, and watch the memory used by > the postgreSQL processes. Your goal is to have that memory usage > hover around 700mb during heavy usage periods (any less, and you are > throttling the database through scarcity of RAM) but to never, ever, > force usage of Swap memory, which will slow down the server 10-fold. > > If you see the RAM only at half that, but the processor at 90%+, then > you should consider upgrading your processor. But you're more likely > to run out of RAM first. I believe that you haven't already because > with your low shared-buffer settings, most of the potential sort_mem is > going unused. > > BTW, if you are *really* getting 5000 queries per minute, I would > strongly reccomend doubling your RAM. > > -Josh Berkus > > > > > > ----- Original Message ----- > > From: "Josh Berkus" > > To: > > Cc: > > Sent: Tuesday, November 12, 2002 9:05 PM > > Subject: Re: Upgrade to dual processor machine? > > > > > > Heinrik, > > > > "So, where do i find and change shmmax shmall settings ?? > > What should I put there? > > > > What is a recommended value for shared buffers in postgresql.conf ?" > > > > There is no "recommended value." You have to calculate this > > relatively: > > > > 1) Figure out how much RAM your server has available for PostgreSQL. > > For > > example, I have one server on which I allocate 256 mb for Apache, 128 > > mb for > > linux, and thus have 512mb available for Postgres. > > > > 2) Calculate out the memory settings to use 70% of that amount of Ram > > in > > regular usage. Please beware that sort_mem is *not* shared, meaning > > that it > > will be multiplied by the number of concurrent requests requiring > > sorting. > > Thus, your calculation (in K) should be: > > > > 250K + > > 8.2K * shared_buffers + > > 14.2K * max_connections + > > sort_mem * average number of requests per minute > > ===================================== > > memory available to postgresql in K * 0.7 > > > > You will also have to set SHMMAX and SHMMALL to accept this memory > > allocation. > > Since shmmax is set in bytes, then I generally feel safe making it: > > 1024 * 0.5 * memory available to postgresql in K > > > > Setting them is done simply: > > $ echo 134217728 >/proc/sys/kernel/shmall > > $ echo 134217728 >/proc/sys/kernel/shmmax > > > > This is all taken from the postgresql documentation, with some > > experience: > > > http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/runtime.html > > > > -- > > -Josh Berkus > > Aglio Database Solutions > > San Francisco > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html From pgsql-general-owner@postgresql.org Thu Nov 14 04:41:48 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 95A4F476481 for ; Thu, 14 Nov 2002 04:41:46 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 5411347600E for ; Thu, 14 Nov 2002 04:41:42 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.218) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 10:41:37 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 10:35:29 +0100 Message-ID: <005001c28bc1$f6133c80$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Martijn van Oosterhout" Cc: , References: <00b901c28aec$a0d19580$7100a8c0@STEINKAMP> <20021114054520.GA14531@svana.org> Subject: Re: Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 10:41:09 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/611 X-Sequence-Number: 33032 hi, this is what my vmstat 1 5 looks like --- cute tool, didn't know it yet - thanks! procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 2 1 1 60 4940 10288 344212 0 0 158 74 14 31 25 9 66 0 3 1 60 4940 10428 343680 0 0 6548 280 500 595 14 10 76 0 5 1 60 4940 10488 343148 0 0 7732 180 658 983 14 12 74 0 4 1 60 4964 10540 344536 0 0 6364 268 513 715 11 5 84 0 4 1 60 4964 10588 344056 0 0 5180 360 578 610 21 6 73 -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Martijn van Oosterhout" To: "scott.marlowe" Cc: "Henrik Steffen" ; ; Sent: Thursday, November 14, 2002 6:45 AM Subject: Re: [GENERAL] Upgrade to dual processor machine? From pgsql-performance-owner@postgresql.org Thu Nov 14 04:44:35 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2C2D0476481 for ; Thu, 14 Nov 2002 04:44:33 -0500 (EST) Received: from siaco.id.pl (siaco.id.pl [213.25.114.8]) by postgresql.org (Postfix) with SMTP id 25EFF475EDC for ; Thu, 14 Nov 2002 04:43:45 -0500 (EST) Received: (qmail 28981 invoked by uid 1000); 14 Nov 2002 09:43:44 -0000 Date: Thu, 14 Nov 2002 10:43:44 +0100 From: Ryszard Lach To: pgsql-performance@postgresql.org Subject: Docs about buffers and sortmem setting Message-ID: <20021114094344.GA28964@siaco.id.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline User-Agent: Mutt/1.4i X-My-GPG-Key: echo | mail -s "send key pub" rla@id.pl X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/39 X-Sequence-Number: 197 Hi! I've seen on this list some calculations concerning buffers and sort_mem settings. Could you tell me if there is a document about such a calculation? I'd like to use nearly all of my RAM for postgres. Richard. -- "First they ignore you. Then they laugh at you. Then they fight you. Then you win." - Mohandas Gandhi. From pgsql-general-owner@postgresql.org Thu Nov 14 05:04:25 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5E038475C3D for ; Thu, 14 Nov 2002 05:04:24 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 42E624759AF for ; Thu, 14 Nov 2002 05:04:23 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.218) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 11:04:23 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 10:58:15 +0100 Message-ID: <00ec01c28bc5$241b9200$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Cc: Subject: Re: Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 11:03:54 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/612 X-Sequence-Number: 33033 Hi all, this is how it looks like, when my system is busy (right now!!!) 50 concurrent visitors at the same time surfing through our web-pages ps ax | grep postgres: 22568 ? S 0:00 postgres: stats buffer process 22569 ? S 0:00 postgres: stats collector process 22577 ? S 0:15 postgres: postgres kunden 62.116.172.180 INSERT 22578 ? S 0:19 postgres: postgres kunden 62.116.172.180 UPDATE 22582 ? S 0:14 postgres: postgres kunden 62.116.172.180 idle 22583 ? S 0:30 postgres: postgres kunden 62.116.172.180 idle 22584 ? S 0:19 postgres: postgres kunden 62.116.172.180 idle 22586 ? S 0:17 postgres: postgres kunden 62.116.172.180 idle 22587 ? S 0:15 postgres: postgres kunden 62.116.172.180 idle 22588 ? S 0:20 postgres: postgres kunden 62.116.172.180 INSERT 22590 ? S 0:15 postgres: postgres kunden 62.116.172.180 INSERT 22592 ? S 0:18 postgres: postgres kunden 62.116.172.180 INSERT 22593 ? S 0:15 postgres: postgres kunden 62.116.172.180 idle 22594 ? S 0:19 postgres: postgres kunden 62.116.172.180 UPDATE 22601 ? D 0:22 postgres: postgres kunden 62.116.172.180 SELECT 22643 ? S 0:14 postgres: postgres kunden 62.116.172.180 idle 22730 ? D 0:10 postgres: postgres kunden 62.116.172.180 SELECT 22734 ? D 0:08 postgres: postgres kunden 62.116.172.180 SELECT 22753 ? S 0:10 postgres: postgres kunden 62.116.172.180 SELECT 22754 ? S 0:05 postgres: postgres kunden 62.116.172.180 idle 22755 ? S 0:02 postgres: postgres kunden 62.116.172.180 idle 22756 ? S 0:02 postgres: postgres kunden 62.116.172.180 idle 22762 ? S 0:05 postgres: postgres kunden 62.116.172.180 UPDATE 22764 ? D 0:04 postgres: postgres kunden 62.116.172.180 SELECT 22765 ? S 0:02 postgres: postgres kunden 62.116.172.180 UPDATE 22766 ? D 0:02 postgres: postgres kunden 62.116.172.180 SELECT 22787 ? S 0:02 postgres: postgres kunden 62.116.172.180 idle 22796 ? S 0:00 postgres: postgres kunden 62.116.172.180 UPDATE 22803 ? S 0:00 postgres: postgres kunden 62.116.172.180 idle 22804 ? S 0:01 postgres: postgres kunden 62.116.172.180 idle 22805 ? S 0:01 postgres: postgres kunden 62.116.172.180 idle 22806 ? S 0:00 postgres: postgres kunden 62.116.172.180 idle 22807 ? S 0:00 postgres: postgres kunden 62.116.172.180 idle 22809 ? D 0:00 postgres: postgres kunden 62.116.172.180 SELECT 22814 ? S 0:01 postgres: postgres kunden 62.116.172.180 idle 22815 ? D 0:03 postgres: postgres kunden 62.116.172.180 SELECT 22818 ? S 0:00 postgres: postgres kunden 62.116.172.180 idle 22821 ? S 0:00 postgres: postgres kunden 62.116.172.180 idle 22824 ? S 0:01 postgres: postgres kunden 62.116.172.180 UPDATE 22825 ? S 0:00 postgres: postgres kunden 62.116.172.180 UPDATE 22829 ? S 0:00 postgres: checkpoint subprocess 22830 ? S 0:00 postgres: postgres kunden 62.116.172.180 INSERT 22832 pts/0 S 0:00 grep postgres -> I count 20 concurrent database queries above ... vmstat 1 5: procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 1 8 1 60 4964 5888 309684 0 0 176 74 16 32 25 9 66 0 6 3 60 4964 5932 308772 0 0 6264 256 347 347 13 9 78 0 5 1 60 4964 5900 309364 0 0 9312 224 380 309 11 6 83 1 4 1 60 5272 5940 309152 0 0 10320 116 397 429 17 6 77 1 4 1 60 4964 5896 309512 0 0 11020 152 451 456 14 10 76 free: total used free shared buffers cached Mem: 1020808 1015860 4948 531424 5972 309548 -/+ buffers/cache: 700340 320468 Swap: 1028112 60 1028052 w: 12:04pm up 2 days, 17:44, 1 user, load average: 10.28, 7.22, 3.88 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 condor.city-map. 11:46am 0.00s 0.09s 0.01s w this is when things begin to go more slowly.... any advice? -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Nov 14 05:27:44 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 269D0475C3D for ; Thu, 14 Nov 2002 05:27:43 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 574BB4759AF for ; Thu, 14 Nov 2002 05:27:41 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gAEARgS14831 for ; Thu, 14 Nov 2002 15:57:42 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gAEARgv14826 for ; Thu, 14 Nov 2002 15:57:42 +0530 From: "Shridhar Daithankar" To: Date: Thu, 14 Nov 2002 15:58:17 +0530 MIME-Version: 1.0 Subject: Re: [GENERAL] Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD3C819.3038.3E3812E@localhost> In-reply-to: <00ec01c28bc5$241b9200$7100a8c0@STEINKAMP> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/40 X-Sequence-Number: 198 On 14 Nov 2002 at 11:03, Henrik Steffen wrote: > vmstat 1 5: > procs memory swap io system cpu > r b w swpd free buff cache si so bi bo in cs us sy id > 1 8 1 60 4964 5888 309684 0 0 176 74 16 32 25 9 66 > 0 6 3 60 4964 5932 308772 0 0 6264 256 347 347 13 9 78 > 0 5 1 60 4964 5900 309364 0 0 9312 224 380 309 11 6 83 > 1 4 1 60 5272 5940 309152 0 0 10320 116 397 429 17 6 77 > 1 4 1 60 4964 5896 309512 0 0 11020 152 451 456 14 10 76 > w: > 12:04pm up 2 days, 17:44, 1 user, load average: 10.28, 7.22, 3.88 > USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT > root pts/0 condor.city-map. 11:46am 0.00s 0.09s 0.01s w > this is when things begin to go more slowly.... Two things immediately noticable.. Load average and block ins.. Either your disk write BW is saturated or CPU is too full, which I believe is the case. HAve you ever got faster write performance than 12K blocks say? Disk BW may be a bottleneck here.. Are they IDE disks? Besides almost transactions are insert/update.. And if you have 11K blocks per second to write.. I suggest you vacuum analyse most used table one in a minute or so. Decide the best frequency by trial and error. A good start is double the time it takes for vacuum. i.e. if vacuum analyse takes 60 sec to finish, leave a gap of 120 sec. between two runs of vacuum. You need to vacuum only those tables which are heavily updated. This will make vacuum faster. HTH Bye Shridhar -- Nouvelle cuisine, n.: French for "not enough food".Continental breakfast, n.: English for "not enough food".Tapas, n.: Spanish for "not enough food".Dim Sum, n.: Chinese for more food than you've ever seen in your entire life. From pgsql-performance-owner@postgresql.org Thu Nov 14 06:56:13 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F0D2247685F for ; Thu, 14 Nov 2002 06:56:12 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 13FC547646B for ; Thu, 14 Nov 2002 06:56:12 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18CIbW-0000uu-00 for ; Thu, 14 Nov 2002 06:56:14 -0500 Date: Thu, 14 Nov 2002 06:56:14 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Docs about buffers and sortmem setting Message-ID: <20021114065614.B2982@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20021114094344.GA28964@siaco.id.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20021114094344.GA28964@siaco.id.pl>; from rla@id.pl on Thu, Nov 14, 2002 at 10:43:44AM +0100 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/41 X-Sequence-Number: 199 On Thu, Nov 14, 2002 at 10:43:44AM +0100, Ryszard Lach wrote: > Hi! > > I've seen on this list some calculations concerning buffers and sort_mem > settings. Could you tell me if there is a document about such a > calculation? I'd like to use nearly all of my RAM for postgres. Probably that's not true. You'll likely cause swapping if you try to. The general rule of thumb is to try about 25% of physical memory for your buffer size. Some people like to increase from there, until swapping starts, and then back off; but there are arguments against doing this, given the efficiency of modern filesystem buffering. In practice, a buffer size in the tens of thousands is probably adequate. We actually have discovered long-term negative performance effects if the buffers are set too large. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Nov 14 07:20:07 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2B854476A0C for ; Thu, 14 Nov 2002 07:20:07 -0500 (EST) Received: from ns1.gnw.de (ns1.turtle-entertainment.de [193.41.200.20]) by postgresql.org (Postfix) with ESMTP id 5AE31476A05 for ; Thu, 14 Nov 2002 07:20:06 -0500 (EST) Received: from [213.148.158.226] (helo=mail.office.turtle-entertainment.de) by ns1.gnw.de with esmtp (Exim 3.16 #1 (Debian)) id 18CIyf-0004s5-00 for ; Thu, 14 Nov 2002 13:20:09 +0100 Received: from pd9e21f26.dip.t-dialin.net ([217.226.31.38] helo=shock) by mail.office.turtle-entertainment.de with asmtp (Exim 3.22 #7 (Debian)) id 18CIyZ-00034n-00 for ; Thu, 14 Nov 2002 13:20:04 +0100 Message-ID: <00d701c28bd8$28ecce80$0564a8c0@toolteam.net> From: "Bjoern Metzdorf" To: References: <20021114094344.GA28964@siaco.id.pl> <20021114065614.B2982@mail.libertyrms.com> Subject: Re: Docs about buffers and sortmem setting Date: Thu, 14 Nov 2002 13:19:57 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Scanner: exiscan *18CIyZ-00034n-00*PBPtfZ4wbfg* http://duncanthrax.net/exiscan/ X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/42 X-Sequence-Number: 200 > The general rule of thumb is to try about 25% of physical memory for > your buffer size. Some people like to increase from there, until > swapping starts, and then back off; but there are arguments against > doing this, given the efficiency of modern filesystem buffering. How about 32-bit Linux machines with more than 1 GB RAM? We have a 2 GB RAM machine running, and I gave 800 MB to postgres shared buffers. AFAIK Linux user space can handle only 1 GB and the rest is for kernel buffer and cache.. Regards, Bjoern From pgsql-performance-owner@postgresql.org Thu Nov 14 08:35:11 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 03485476B15 for ; Thu, 14 Nov 2002 08:35:11 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 80067476B0F for ; Thu, 14 Nov 2002 08:35:10 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18CK9K-0002aK-00 for ; Thu, 14 Nov 2002 08:35:14 -0500 Date: Thu, 14 Nov 2002 08:35:14 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Docs about buffers and sortmem setting Message-ID: <20021114083514.A9625@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20021114094344.GA28964@siaco.id.pl> <20021114065614.B2982@mail.libertyrms.com> <00d701c28bd8$28ecce80$0564a8c0@toolteam.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <00d701c28bd8$28ecce80$0564a8c0@toolteam.net>; from bm@turtle-entertainment.de on Thu, Nov 14, 2002 at 01:19:57PM +0100 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/43 X-Sequence-Number: 201 On Thu, Nov 14, 2002 at 01:19:57PM +0100, Bjoern Metzdorf wrote: > How about 32-bit Linux machines with more than 1 GB RAM? We have a 2 GB RAM > machine running, and I gave 800 MB to postgres shared buffers. AFAIK Linux > user space can handle only 1 GB and the rest is for kernel buffer and > cache.. How big is your data set? If it's smaller than 800 MB, you're wasting the buffers anyway. The thing is that the OS will buffer what you read anyway, so depending on how large your buffers are and how much memory your filesystem is able to use for its buffersm, you may actually be storing twice in memory everything in the shared memory: once in the shared area, and another time in the filesystem buffer. On our 16 G Solaris (Ultra SPARC) boxes, we found that using a gig for shared buffers was actually worse than a slightly lower amount, under Sol 7. The filesystem buffering is too good, so even though the system call to the "filesystem" (which turns out to be just to memory, because of the buffer) has a measurable cost, the implementation of the shared-buffer handling is bad enough that it costs _more_ to manage large buffers. Smaller buffers seem not to face the difficulty. I haven't a clue why. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Nov 14 09:36:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 344A1476B4A for ; Thu, 14 Nov 2002 09:36:56 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id A82CA476B0E for ; Thu, 14 Nov 2002 09:36:46 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gAEEaod06281 for ; Thu, 14 Nov 2002 20:06:50 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gAEEanv06276 for ; Thu, 14 Nov 2002 20:06:49 +0530 From: "Shridhar Daithankar" To: pgsql-performance@postgresql.org Date: Thu, 14 Nov 2002 20:07:24 +0530 MIME-Version: 1.0 Subject: Re: swapping? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD4027C.4503.18465B@localhost> In-reply-to: <1037287817.1348.1.camel@Monet> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/45 X-Sequence-Number: 203 On 14 Nov 2002 at 10:30, Wei Weng wrote: > The term had been mentioned often enough on this mailing list. Can > someone enlighten me with some description or a URL where I can read on? > And why is it important to postgresql database performace? When programs request more memory than available, OS 'swaps' some memory to special area on disk and make the memory available. To programs, it gives appearance that nearly infinite memory is available. Unfortunately disk are hell slower than RAM and hence swapping slows things down as it takes much to swap in to disk and swap out of disk. Since OS does not care which programs get swapped, it is possible that postgresql instance can get swapped. That slows down effective memory access to knees.. That's why for good performance, a serve should never swap.. Bye Shridhar -- Peterson's Admonition: When you think you're going down for the third time -- just remember that you may have counted wrong. From pgsql-performance-owner@postgresql.org Thu Nov 14 09:56:27 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7D59C475EB9 for ; Thu, 14 Nov 2002 09:56:25 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id AF874475D93 for ; Thu, 14 Nov 2002 09:56:23 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id gAEEuNL27864; Thu, 14 Nov 2002 09:56:23 -0500 (EST) From: Bruce Momjian Message-Id: <200211141456.gAEEuNL27864@candle.pha.pa.us> Subject: Re: swapping? In-Reply-To: <1037289210.1348.4.camel@Monet> To: Wei Weng Date: Thu, 14 Nov 2002 09:56:22 -0500 (EST) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/47 X-Sequence-Number: 205 Usually vmstat shows page ins. I also write a paper on this: http://techdocs.postgresql.org/redir.php?link=http://www.ca.postgresql.org/docs/momjian/hw_performance/ The techdocs site has other stuff, see "Optimzation" section: http://techdocs.postgresql.org/ --------------------------------------------------------------------------- Wei Weng wrote: > How do you notice that if a system started swapping or not? > > Thanks > > On Thu, 2002-11-14 at 09:37, Shridhar Daithankar wrote: > > On 14 Nov 2002 at 10:30, Wei Weng wrote: > > > > > The term had been mentioned often enough on this mailing list. Can > > > someone enlighten me with some description or a URL where I can read on? > > > And why is it important to postgresql database performace? > > > > When programs request more memory than available, OS 'swaps' some memory to > > special area on disk and make the memory available. To programs, it gives > > appearance that nearly infinite memory is available. > > > > Unfortunately disk are hell slower than RAM and hence swapping slows things > > down as it takes much to swap in to disk and swap out of disk. Since OS does > > not care which programs get swapped, it is possible that postgresql instance > > can get swapped. That slows down effective memory access to knees.. > > > > That's why for good performance, a serve should never swap.. > > > > Bye > > Shridhar > > > > -- > > Peterson's Admonition: When you think you're going down for the third time -- > > just remember that you may have counted wrong. > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- > Wei Weng > Network Software Engineer > KenCast Inc. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Thu Nov 14 10:17:48 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C8F8D476B81 for ; Thu, 14 Nov 2002 10:17:46 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 4FD18476A9C for ; Thu, 14 Nov 2002 10:17:23 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18CLkF-0004gT-00 for ; Thu, 14 Nov 2002 10:17:27 -0500 Date: Thu, 14 Nov 2002 10:17:27 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: swapping? Message-ID: <20021114101727.C9625@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <200211141456.gAEEuNL27864@candle.pha.pa.us> <1037290020.1348.10.camel@Monet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1037290020.1348.10.camel@Monet>; from wweng@kencast.com on Thu, Nov 14, 2002 at 11:07:00AM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/49 X-Sequence-Number: 207 On Thu, Nov 14, 2002 at 11:07:00AM -0500, Wei Weng wrote: > 1: I see sort_mem setting in my postgresql.conf, what is the "buffer > size" people often talk about? It's the shared buffer configuration option in your config file. > 2: What is the unit of sort_mem in postgresql.conf? In my basic(default) > installation, I have sort_mem=512. Is that 512MBs or 512KBs? It's in kilobytes. It appears that it might profit you to read the administrator's guide. There's lots in the Fine Manuals. The section on runtime configuration is at http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/runtime-config.html A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-general-owner@postgresql.org Thu Nov 14 10:21:30 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3821E475AA1 for ; Thu, 14 Nov 2002 10:21:27 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 52BCC476B0A for ; Thu, 14 Nov 2002 10:21:24 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.218) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 16:21:25 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 16:15:18 +0100 Message-ID: <004601c28bf1$6dc98de0$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "pginfo" Cc: , References: <3DD25A07.25377.488A27F@localhost> <013601c28af9$01730480$7100a8c0@STEINKAMP> <3DD3AFE8.CFACDC4F@t1.unisoftbg.com> Subject: Re: Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 16:20:56 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/620 X-Sequence-Number: 33041 hi Ivan to get the shared buffer memory I followed all the instructions I gathered here on the list within the last two days. the kernel settings SHMMAX etc. were important here in my opinion... you could search the archives for all the other mails within this thread and try yourself. by the way: today we update to kernel 2.4.19 and we measured BIG performance gains! however, since the upgrade 'top' doesn't show any shared memory in the summary any longer... yet for every process it lists a certain amount of shared mem... is this a kernel/top issue or did I miss something here? the kernel is much more performant! -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "pginfo" To: "Henrik Steffen" Sent: Thursday, November 14, 2002 3:15 PM Subject: Re: [GENERAL] Upgrade to dual processor machine? > Hi, > Sorry for this question. > I see you have 8520K shrd . > How are you setup you linux box to use tis shared buffers? (any answer will be great). > > > > I have tryed it many times without success. > > Also it is courios that the sum of cpu loading is not 100% ! > > We are using two pg servers: > one single processor Intel 1 GHz, 1 GB RAM, > and one dual Intel 1GHz, 1.5 GB RAM. > It exist big diference in pg performance and I noticed many times when the system use > all two processors. > > If I can help you with more info you are free to ask. > > regards, > Ivan. > > > Henrik Steffen wrote: > > > dear shridhar, > > > > > Yes. 2*max connection is minimum. Anything additional is always welcome as long > > > as it does not starve the system. > > > > ok, I tried to set shared_buffers to 65535 now. but then restarting postgres > > fails - it says: > > > > IpcMemoryCreate: shmget(key=5432001, size=545333248, 03600) failed: Invalid argument > > > > and a message telling me to either lower the shared_buffers or raise the > > SHMMAX. > > > > > If you have a gig of memory and shared buffers are 536MB as you have indicated, > > > who is taking rest of the RAM? > > > > well, I guess it's postgres... see the output of top below: > > > > 11:06am up 1 day, 16:46, 1 user, load average: 1,32, 1,12, 1,22 > > 53 processes: 52 sleeping, 1 running, 0 zombie, 0 stopped > > CPU states: 24,5% user, 11,2% system, 0,0% nice, 5,6% idle > > Mem: 1020808K av, 1006156K used, 14652K free, 8520K shrd, 37204K buff > > Swap: 1028112K av, 60K used, 1028052K free 849776K cached > > > > PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND > > 10678 root 19 0 2184 2184 1584 S 2,9 0,2 0:00 sendmail > > 1 root 8 0 520 520 452 S 0,0 0,0 0:03 init > > 2 root 9 0 0 0 0 SW 0,0 0,0 0:00 keventd > > 3 root 9 0 0 0 0 SW 0,0 0,0 0:00 kapm-idled > > 4 root 19 19 0 0 0 SWN 0,0 0,0 0:00 ksoftirqd_CPU0 > > 5 root 9 0 0 0 0 SW 0,0 0,0 0:28 kswapd > > 6 root 9 0 0 0 0 SW 0,0 0,0 0:00 kreclaimd > > 7 root 9 0 0 0 0 SW 0,0 0,0 0:09 bdflush > > 8 root 9 0 0 0 0 SW 0,0 0,0 0:00 kupdated > > 9 root -1 -20 0 0 0 SW< 0,0 0,0 0:00 mdrecoveryd > > 13 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 136 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 137 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 138 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 139 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 140 root 9 0 0 0 0 SW 0,0 0,0 2:16 kjournald > > 378 root 9 0 0 0 0 SW 0,0 0,0 0:00 eth0 > > 454 root 9 0 572 572 476 S 0,0 0,0 0:00 syslogd > > 459 root 9 0 1044 1044 392 S 0,0 0,1 0:00 klogd > > 572 root 8 0 1128 1092 968 S 0,0 0,1 0:07 sshd > > 584 root 9 0 1056 1056 848 S 0,0 0,1 0:02 nlservd > > 611 root 8 0 1836 1820 1288 S 0,0 0,1 0:00 sendmail > > 693 root 9 0 640 640 556 S 0,0 0,0 0:00 crond > > 729 daemon 9 0 472 464 404 S 0,0 0,0 0:00 atd > > 736 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 737 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 738 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 739 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 740 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 741 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 9800 root 9 0 1888 1864 1552 S 0,0 0,1 0:02 sshd > > 9801 root 16 0 1368 1368 1016 S 0,0 0,1 0:00 bash > > 10574 postgres 0 0 1448 1448 1380 S 0,0 0,1 0:00 postmaster > > 10576 postgres 9 0 1436 1436 1388 S 0,0 0,1 0:00 postmaster > > 10577 postgres 9 0 1480 1480 1388 S 0,0 0,1 0:00 postmaster > > 10579 postgres 14 0 11500 11M 10324 S 0,0 1,1 0:08 postmaster > > 10580 postgres 9 0 11672 11M 10328 S 0,0 1,1 0:03 postmaster > > 10581 postgres 14 0 11620 11M 10352 S 0,0 1,1 0:08 postmaster > > 10585 postgres 11 0 11560 11M 10304 S 0,0 1,1 0:08 postmaster > > 10588 postgres 9 0 11520 11M 10316 S 0,0 1,1 0:14 postmaster > > 10589 postgres 9 0 11632 11M 10324 S 0,0 1,1 0:06 postmaster > > 10590 postgres 10 0 11620 11M 10320 S 0,0 1,1 0:06 postmaster > > 10591 postgres 9 0 11536 11M 10320 S 0,0 1,1 0:08 postmaster > > 10592 postgres 11 0 11508 11M 10316 S 0,0 1,1 0:04 postmaster > > 10595 postgres 9 0 11644 11M 10324 S 0,0 1,1 0:03 postmaster > > 10596 postgres 11 0 11664 11M 10328 S 0,0 1,1 0:08 postmaster > > 10597 postgres 9 0 11736 11M 10340 S 0,0 1,1 0:24 postmaster > > 10598 postgres 9 0 11500 11M 10312 S 0,0 1,1 0:10 postmaster > > 10599 postgres 11 0 11676 11M 10324 S 0,0 1,1 0:13 postmaster > > 10602 postgres 9 0 11476 11M 10308 S 0,0 1,1 0:09 postmaster > > 10652 postgres 9 0 7840 7840 7020 S 0,0 0,7 0:00 postmaster > > 10669 postgres 9 0 9076 9076 8224 S 0,0 0,8 0:00 postmaster > > 10677 root 13 0 1032 1028 828 R 0,0 0,1 0:00 top > > > > I have now changed the SHMMAX settings to 545333248 and changed the > > shared_buffers to 65535 again. now postgres starts up correctly. > > > > the top result changes to: > > > > 11:40am up 1 day, 17:20, 1 user, load average: 2,24, 2,51, 2,14 > > 57 processes: 55 sleeping, 2 running, 0 zombie, 0 stopped > > CPU states: 24,7% user, 11,3% system, 0,0% nice, 6,2% idle > > Mem: 1020808K av, 1015844K used, 4964K free, 531420K shrd, 24796K buff > > Swap: 1028112K av, 60K used, 1028052K free 338376K cached > > > > PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND > > 11010 root 17 0 1036 1032 828 R 14,2 0,1 0:00 top > > 11007 postgres 14 0 14268 13M 12668 R 9,7 1,3 0:00 postmaster > > 11011 root 9 0 2184 2184 1584 S 3,0 0,2 0:00 sendmail > > 1 root 8 0 520 520 452 S 0,0 0,0 0:03 init > > 2 root 9 0 0 0 0 SW 0,0 0,0 0:00 keventd > > 3 root 9 0 0 0 0 SW 0,0 0,0 0:00 kapm-idled > > 4 root 19 19 0 0 0 SWN 0,0 0,0 0:00 ksoftirqd_CPU0 > > 5 root 9 0 0 0 0 SW 0,0 0,0 0:29 kswapd > > 6 root 9 0 0 0 0 SW 0,0 0,0 0:00 kreclaimd > > 7 root 9 0 0 0 0 SW 0,0 0,0 0:09 bdflush > > 8 root 9 0 0 0 0 SW 0,0 0,0 0:00 kupdated > > 9 root -1 -20 0 0 0 SW< 0,0 0,0 0:00 mdrecoveryd > > 13 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 136 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 137 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 138 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 139 root 9 0 0 0 0 SW 0,0 0,0 0:00 kjournald > > 140 root 9 0 0 0 0 SW 0,0 0,0 2:18 kjournald > > 378 root 9 0 0 0 0 SW 0,0 0,0 0:00 eth0 > > 454 root 9 0 572 572 476 S 0,0 0,0 0:00 syslogd > > 459 root 9 0 1044 1044 392 S 0,0 0,1 0:00 klogd > > 572 root 8 0 1128 1092 968 S 0,0 0,1 0:07 sshd > > 584 root 9 0 1056 1056 848 S 0,0 0,1 0:02 nlservd > > 611 root 9 0 1836 1820 1288 S 0,0 0,1 0:00 sendmail > > 693 root 9 0 640 640 556 S 0,0 0,0 0:00 crond > > 729 daemon 9 0 472 464 404 S 0,0 0,0 0:00 atd > > 736 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 737 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 738 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 739 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 740 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 741 root 9 0 448 448 384 S 0,0 0,0 0:00 mingetty > > 9800 root 9 0 1888 1864 1552 S 0,0 0,1 0:03 sshd > > 9801 root 10 0 1368 1368 1016 S 0,0 0,1 0:00 bash > > 10838 postgres 7 0 6992 6992 6924 S 0,0 0,6 0:00 postmaster > > 10840 postgres 9 0 6984 6984 6932 S 0,0 0,6 0:00 postmaster > > 10841 postgres 9 0 7024 7024 6932 S 0,0 0,6 0:00 postmaster > > 10852 postgres 9 0 489M 489M 487M S 0,0 49,0 0:32 postmaster > > 10869 postgres 9 0 357M 357M 356M S 0,0 35,8 0:21 postmaster > > 10908 postgres 9 0 263M 263M 262M S 0,0 26,4 0:20 postmaster > > 10909 postgres 9 0 283M 283M 281M S 0,0 28,4 0:19 postmaster > > 10932 postgres 9 0 288M 288M 286M S 0,0 28,9 0:13 postmaster > > 10946 postgres 9 0 213M 213M 211M S 0,0 21,4 0:06 postmaster > > 10947 postgres 9 0 239M 239M 238M S 0,0 24,0 0:07 postmaster > > 10948 postgres 9 0 292M 292M 290M S 0,0 29,2 0:09 postmaster > > 10957 postgres 9 0 214M 214M 212M S 0,0 21,5 0:10 postmaster > > 10964 postgres 9 0 58156 56M 56400 S 0,0 5,6 0:05 postmaster > > 10974 postgres 9 0 50860 49M 49120 S 0,0 4,9 0:04 postmaster > > 10975 postgres 9 0 209M 209M 207M S 0,0 21,0 0:04 postmaster > > 10976 postgres 9 0 174M 174M 172M S 0,0 17,5 0:08 postmaster > > 10977 postgres 9 0 52484 51M 50932 S 0,0 5,1 0:05 postmaster > > 10990 postgres 9 0 199M 199M 197M S 0,0 19,9 0:06 postmaster > > 10993 postgres 9 0 141M 141M 139M S 0,0 14,1 0:01 postmaster > > 10998 postgres 9 0 181M 181M 180M S 0,0 18,2 0:04 postmaster > > 10999 postgres 9 0 139M 139M 138M S 0,0 14,0 0:01 postmaster > > 11001 postgres 9 0 45484 44M 43948 S 0,0 4,4 0:01 postmaster > > 11006 postgres 9 0 15276 14M 13952 S 0,0 1,4 0:00 postmaster > > > > now, does this look better in your eyes? > > > > > What are your current settings? Could you please repost. I lost earlier > > > thread(Sorry for that.. Had a HDD meltdown here couple of days back. Lost few > > > mails..) > > > > do you need more information here? > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 6: Have you searched our list archives? > > > > http://archives.postgresql.org > > > From pgsql-performance-owner@postgresql.org Thu Nov 14 09:30:19 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1B81476171 for ; Thu, 14 Nov 2002 09:30:16 -0500 (EST) Received: from mta5.snet.net (mta5.snet.net [204.60.203.77]) by postgresql.org (Postfix) with ESMTP id B0A69475AA1 for ; Thu, 14 Nov 2002 09:30:15 -0500 (EST) Received: from pop.snet.net (pop.snet.net [204.60.203.72]) by mta5.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gAEER5o0011724 for ; Thu, 14 Nov 2002 09:27:05 -0500 (EST) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gAEEU8wj028962 for ; Thu, 14 Nov 2002 09:30:08 -0500 (EST) Subject: swapping? From: Wei Weng To: pgsql-performance@postgresql.org Content-Type: text/plain Organization: Message-Id: <1037287817.1348.1.camel@Monet> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 14 Nov 2002 10:30:17 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/44 X-Sequence-Number: 202 The term had been mentioned often enough on this mailing list. Can someone enlighten me with some description or a URL where I can read on? And why is it important to postgresql database performace? Thanks -- Wei Weng Network Software Engineer KenCast Inc. From pgsql-general-owner@postgresql.org Thu Nov 14 10:31:56 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 39D89475F3D for ; Thu, 14 Nov 2002 10:31:56 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 1C022475F38 for ; Thu, 14 Nov 2002 10:31:55 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.218) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 16:31:58 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 16:25:51 +0100 Message-ID: <007501c28bf2$e70f95e0$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Shridhar Daithankar" Cc: , References: <3DD25A07.25377.488A27F@localhost> <3DD3AFE8.CFACDC4F@t1.unisoftbg.com> <004601c28bf1$6dc98de0$7100a8c0@STEINKAMP> <200211142055.42466.shridhar_daithankar@persistent.co.in> Subject: Re: [PERFORM] Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 16:31:29 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/621 X-Sequence-Number: 33042 hi, this is what it look like right now... looks like 69 MB of shared memory... ------ Shared Memory Segments -------- key shmid owner perms Bytes nattch Status 0x0052e2c1 131072 postgres 600 69074944 19 ------ Semaphore Arrays -------- key semid owner perms nsems Status 0x0052e2c1 655360 postgres 600 17 0x0052e2c2 688129 postgres 600 17 0x0052e2c3 720898 postgres 600 17 ------ Message Queues -------- key msqid owner perms used-bytes messages -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Shridhar Daithankar" To: "Henrik Steffen" Sent: Thursday, November 14, 2002 4:25 PM Subject: Re: [PERFORM] [GENERAL] Upgrade to dual processor machine? > On Thursday 14 November 2002 08:50 pm, you wrote: > > by the way: today we update to kernel 2.4.19 and we measured BIG > > performance gains! however, since the upgrade 'top' doesn't show any > > shared memory in the summary any longer... yet for every process > > it lists a certain amount of shared mem... is this a kernel/top issue > > or did I miss something here? > > No. The shared memory accounting is turned off because it is seemingly much > complex. Process do share memory. Check output of ipcs as root.. > > Shridhar From pgsql-performance-owner@postgresql.org Thu Nov 14 10:34:52 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5F4BE475F25 for ; Thu, 14 Nov 2002 10:34:51 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id D39CA475EB9 for ; Thu, 14 Nov 2002 10:34:49 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gAEFYrd10268 for ; Thu, 14 Nov 2002 21:04:53 +0530 Received: from daithan.itnranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gAEFYrv10263 for ; Thu, 14 Nov 2002 21:04:53 +0530 Content-Type: text/plain; charset="iso-8859-1" From: Shridhar Daithankar To: Subject: Re: [GENERAL] Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 21:05:28 +0530 User-Agent: KMail/1.4.3 References: <3DD25A07.25377.488A27F@localhost> <200211142055.42466.shridhar_daithankar@persistent.co.in> <007501c28bf2$e70f95e0$7100a8c0@STEINKAMP> In-Reply-To: <007501c28bf2$e70f95e0$7100a8c0@STEINKAMP> MIME-Version: 1.0 Message-Id: <200211142105.28396.shridhar_daithankar@persistent.co.in> Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by www.pspl.co.in id gAEFYrv10263 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/52 X-Sequence-Number: 210 On Thursday 14 November 2002 09:01 pm, you wrote: > this is what it look like right now... looks like 69 MB of shared memory... > ------ Shared Memory Segments -------- > key shmid owner perms Bytes nattch Status > 0x0052e2c1 131072 postgres 600 69074944 19 Well, if you sample this figure for min/max/avg usage say for a day, you will have sufficient idea as in what are your exact requirements are in terms of shared buffers. I would say 5% more that would prove to be much more optimal setting. IMO it's worth of experiement.. Just start out with pretty high to leave some room.. Shridhar From pgsql-performance-owner@postgresql.org Thu Nov 14 09:53:30 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 11153475EB9 for ; Thu, 14 Nov 2002 09:53:29 -0500 (EST) Received: from mta4.snet.net (mta4.snet.net [204.60.203.76]) by postgresql.org (Postfix) with ESMTP id AB79C475D93 for ; Thu, 14 Nov 2002 09:53:27 -0500 (EST) Received: from pop.snet.net ([204.60.203.73]) by mta4.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gAEEr48M007449 for ; Thu, 14 Nov 2002 09:53:04 -0500 (EST) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gAEErLwj005264 for ; Thu, 14 Nov 2002 09:53:21 -0500 (EST) Subject: Re: swapping? From: Wei Weng To: pgsql-performance@postgresql.org In-Reply-To: <3DD4027C.4503.18465B@localhost> References: <3DD4027C.4503.18465B@localhost> Content-Type: text/plain Organization: Message-Id: <1037289210.1348.4.camel@Monet> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 14 Nov 2002 10:53:30 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/46 X-Sequence-Number: 204 How do you notice that if a system started swapping or not? Thanks On Thu, 2002-11-14 at 09:37, Shridhar Daithankar wrote: > On 14 Nov 2002 at 10:30, Wei Weng wrote: > > > The term had been mentioned often enough on this mailing list. Can > > someone enlighten me with some description or a URL where I can read on? > > And why is it important to postgresql database performace? > > When programs request more memory than available, OS 'swaps' some memory to > special area on disk and make the memory available. To programs, it gives > appearance that nearly infinite memory is available. > > Unfortunately disk are hell slower than RAM and hence swapping slows things > down as it takes much to swap in to disk and swap out of disk. Since OS does > not care which programs get swapped, it is possible that postgresql instance > can get swapped. That slows down effective memory access to knees.. > > That's why for good performance, a serve should never swap.. > > Bye > Shridhar > > -- > Peterson's Admonition: When you think you're going down for the third time -- > just remember that you may have counted wrong. > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) -- Wei Weng Network Software Engineer KenCast Inc. From pgsql-performance-owner@postgresql.org Thu Nov 14 10:07:04 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 02F2E47604E for ; Thu, 14 Nov 2002 10:07:03 -0500 (EST) Received: from mta4.snet.net (mta4.snet.net [204.60.203.76]) by postgresql.org (Postfix) with ESMTP id 3B0B2475EB9 for ; Thu, 14 Nov 2002 10:07:02 -0500 (EST) Received: from pop.snet.net ([204.60.203.73]) by mta4.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gAEF6d8M013138 for ; Thu, 14 Nov 2002 10:06:39 -0500 (EST) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gAEF6twj028261 for ; Thu, 14 Nov 2002 10:06:56 -0500 (EST) Subject: Re: swapping? From: Wei Weng To: pgsql-performance@postgresql.org In-Reply-To: <200211141456.gAEEuNL27864@candle.pha.pa.us> References: <200211141456.gAEEuNL27864@candle.pha.pa.us> Content-Type: text/plain Organization: Message-Id: <1037290020.1348.10.camel@Monet> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 14 Nov 2002 11:07:00 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/48 X-Sequence-Number: 206 I hope this doesn't sound too stupid. :) 1: I see sort_mem setting in my postgresql.conf, what is the "buffer size" people often talk about? 2: What is the unit of sort_mem in postgresql.conf? In my basic(default) installation, I have sort_mem=512. Is that 512MBs or 512KBs? Thanks On Thu, 2002-11-14 at 09:56, Bruce Momjian wrote: > Usually vmstat shows page ins. I also write a paper on this: > > http://techdocs.postgresql.org/redir.php?link=http://www.ca.postgresql.org/docs/momjian/hw_performance/ > > The techdocs site has other stuff, see "Optimzation" section: > > http://techdocs.postgresql.org/ > > --------------------------------------------------------------------------- > > Wei Weng wrote: > > How do you notice that if a system started swapping or not? > > > > Thanks > > > > On Thu, 2002-11-14 at 09:37, Shridhar Daithankar wrote: > > > On 14 Nov 2002 at 10:30, Wei Weng wrote: > > > > > > > The term had been mentioned often enough on this mailing list. Can > > > > someone enlighten me with some description or a URL where I can read on? > > > > And why is it important to postgresql database performace? > > > > > > When programs request more memory than available, OS 'swaps' some memory to > > > special area on disk and make the memory available. To programs, it gives > > > appearance that nearly infinite memory is available. > > > > > > Unfortunately disk are hell slower than RAM and hence swapping slows things > > > down as it takes much to swap in to disk and swap out of disk. Since OS does > > > not care which programs get swapped, it is possible that postgresql instance > > > can get swapped. That slows down effective memory access to knees.. > > > > > > That's why for good performance, a serve should never swap.. > > > > > > Bye > > > Shridhar > > > > > > -- > > > Peterson's Admonition: When you think you're going down for the third time -- > > > just remember that you may have counted wrong. > > > > > > > > > ---------------------------(end of broadcast)--------------------------- > > > TIP 2: you can get off all lists at once with the unregister command > > > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > -- > > Wei Weng > > Network Software Engineer > > KenCast Inc. > > > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > -- Wei Weng Network Software Engineer KenCast Inc. From pgsql-performance-owner@postgresql.org Thu Nov 14 12:39:17 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B8B23475B84 for ; Thu, 14 Nov 2002 12:39:15 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id 53B864758E1 for ; Thu, 14 Nov 2002 12:39:13 -0500 (EST) Received: (qmail 17823 invoked from network); 14 Nov 2002 19:21:33 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 14 Nov 2002 19:21:33 -0000 Message-ID: <3DD3D2AE.70413B6D@t1.unisoftbg.com> Date: Thu, 14 Nov 2002 17:43:26 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: "pgsql-performance@postgresql.org" Subject: Sort time Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/54 X-Sequence-Number: 212 Hi, Why is the sort part of my query getting so much time? I run a relative complex query and it gets about 50 sec. For sorting I need another 50 sec! Can I increase the sort memory for better performance? How meny memory is needet for the sort in pg. The same data readet in java and sorted cost 10 sec ! Any idea about the pg tining? Regards, Ivan. From pgsql-general-owner@postgresql.org Thu Nov 14 12:13:48 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C3421476B81 for ; Thu, 14 Nov 2002 12:13:47 -0500 (EST) Received: from email03.aon.at (WARSL402PIP6.highway.telekom.at [195.3.96.93]) by postgresql.org (Postfix) with SMTP id D0D1D476B7F for ; Thu, 14 Nov 2002 12:13:46 -0500 (EST) Received: (qmail 549074 invoked from network); 14 Nov 2002 17:13:50 -0000 Received: from m160p012.dipool.highway.telekom.at (HELO cantor) ([62.46.9.236]) (envelope-sender ) by qmail3rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 14 Nov 2002 17:13:50 -0000 From: Manfred Koizar To: "Henrik Steffen" Cc: , Subject: Re: Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 18:15:45 +0100 Message-ID: References: <00ec01c28bc5$241b9200$7100a8c0@STEINKAMP> In-Reply-To: <00ec01c28bc5$241b9200$7100a8c0@STEINKAMP> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/623 X-Sequence-Number: 33044 On Thu, 14 Nov 2002 11:03:54 +0100, "Henrik Steffen" wrote: >this is how it looks like, when my system is busy (right now!!!) >vmstat 1 5: > procs memory swap io system cpu > r b w swpd free buff cache si so bi bo in cs us sy id > 1 8 1 60 4964 5888 309684 0 0 176 74 16 32 25 9 66 > 0 6 3 60 4964 5932 308772 0 0 6264 256 347 347 13 9 78 > 0 5 1 60 4964 5900 309364 0 0 9312 224 380 309 11 6 83 > 1 4 1 60 5272 5940 309152 0 0 10320 116 397 429 17 6 77 > 1 4 1 60 4964 5896 309512 0 0 11020 152 451 456 14 10 76 More than 10000 disk blocks coming in per second looks quite impressive, IMHO. (I wonder if this is due to seq scans?) But the cpu idle column tells us that you are not CPU bound any more. >free: > total used free shared buffers cached >Mem: 1020808 1015860 4948 531424 5972 309548 >-/+ buffers/cache: 700340 320468 >Swap: 1028112 60 1028052 There are two camps when it comes to PG shared buffers: (a) set shared_buffers as high as possible to minimize PG buffer misses vs. (b) assume that transfers between OS and PG buffers are cheap and choose a moderate value for shared_buffers ("in the low thousands") to let the operating system's disk caching do its work. Both camps agree that reserving half of your available memory for shared buffers is a Bad Thing, because whenever a page cannot be found in PG's buffers it is almost certainly not in the OS cache and has to be fetched from disk. So half of your memory (the OS cache) is wasted for nothing. FYI, I belong to the latter camp and I strongly feel you should set shared_buffers to something near 4000. Servus Manfred From pgsql-performance-owner@postgresql.org Thu Nov 14 12:20:51 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7E503475B84 for ; Thu, 14 Nov 2002 12:20:50 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 01E154758E1 for ; Thu, 14 Nov 2002 12:20:50 -0500 (EST) Received: from tokyo.samurai.com (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id 35A581E18; Thu, 14 Nov 2002 12:20:54 -0500 (EST) To: Andrew Sullivan Cc: pgsql-performance@postgresql.org Subject: Re: Docs about buffers and sortmem setting References: <20021114094344.GA28964@siaco.id.pl> <20021114065614.B2982@mail.libertyrms.com> <00d701c28bd8$28ecce80$0564a8c0@toolteam.net> <20021114083514.A9625@mail.libertyrms.com> From: Neil Conway In-Reply-To: <20021114083514.A9625@mail.libertyrms.com> Date: 14 Nov 2002 12:20:49 -0500 Message-ID: <87ptt8rrta.fsf@mailbox.samurai.com> Lines: 23 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/53 X-Sequence-Number: 211 Andrew Sullivan writes: > On our 16 G Solaris (Ultra SPARC) boxes, we found that using a gig > for shared buffers was actually worse than a slightly lower amount, > under Sol 7. The filesystem buffering is too good, so even though > the system call to the "filesystem" (which turns out to be just to > memory, because of the buffer) has a measurable cost, the > implementation of the shared-buffer handling is bad enough that it > costs _more_ to manage large buffers. Smaller buffers seem not to > face the difficulty. I haven't a clue why. Well, part of the reason is that a lot of the data in shared_buffers has to be effectively duplicated in the kernel's I/O caches, because it's frequently accessed. So while I'd think the cost of fetching a page from the buffer pool is lower than from the OS' cache, increasing the size of the Postgres buffer pool effectively decreases the total amount of RAM available for caching. Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-performance-owner@postgresql.org Thu Nov 14 13:01:22 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8A3A1475E1F for ; Thu, 14 Nov 2002 13:01:21 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id D1D17475D3F for ; Thu, 14 Nov 2002 13:01:19 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18COIp-0007za-00 for ; Thu, 14 Nov 2002 13:01:19 -0500 Date: Thu, 14 Nov 2002 13:01:19 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Docs about buffers and sortmem setting Message-ID: <20021114130119.G9625@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20021114094344.GA28964@siaco.id.pl> <20021114065614.B2982@mail.libertyrms.com> <00d701c28bd8$28ecce80$0564a8c0@toolteam.net> <20021114083514.A9625@mail.libertyrms.com> <87ptt8rrta.fsf@mailbox.samurai.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <87ptt8rrta.fsf@mailbox.samurai.com>; from neilc@samurai.com on Thu, Nov 14, 2002 at 12:20:49PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/55 X-Sequence-Number: 213 On Thu, Nov 14, 2002 at 12:20:49PM -0500, Neil Conway wrote: > Well, part of the reason is that a lot of the data in shared_buffers > has to be effectively duplicated in the kernel's I/O caches, because > it's frequently accessed. So while I'd think the cost of fetching a > page from the buffer pool is lower than from the OS' cache, increasing > the size of the Postgres buffer pool effectively decreases the total > amount of RAM available for caching. Well, yes, but on a machine with 16 G and a data set < 16 G, that's not the issue. A 1G shared buffer is too big anyway, according to our experience: it's fast at the beginning, but performance degrades. I don't know why. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-general-owner@postgresql.org Thu Nov 14 13:42:55 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BBDA4475E13 for ; Thu, 14 Nov 2002 13:42:53 -0500 (EST) Received: from local.iboats.com (local.iboats.com [204.246.129.200]) by postgresql.org (Postfix) with SMTP id 0ABB4475D00 for ; Thu, 14 Nov 2002 13:42:53 -0500 (EST) Received: (qmail 25293 invoked by uid 82); 14 Nov 2002 11:43:03 -0700 Received: from nw@codon.com by local.iboats.com by uid 81 with qmail-scanner-1.14 ( Clear:. Processed in 0.094949 secs); 14 Nov 2002 18:43:03 -0000 Received: from unknown (HELO WEASEL) (204.246.129.210) by 0 with SMTP; 14 Nov 2002 11:43:02 -0700 Message-ID: <01f701c28c0e$1e3a6750$d281f6cc@WEASEL> From: "Steve Wolfe" To: References: <004801c28a81$8da1ca40$7100a8c0@STEINKAMP> Subject: Re: Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 11:46:15 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/625 X-Sequence-Number: 33046 > The cache-field is saying 873548K cached at the moment > Is this a "whole bunch of cache" in your opinion? Is it too much? Too much cache? It ain't possible. ; ) For what it's worth, my DB machine generally uses about 1.25 gigs for disk cache, in addition to the 64 megs that are on the RAID card, and that's just fine with me. I allocate 256 megs of shared memory (32768 buffers), and the machine hums along very nicely. vmstat shows that actual reads to the disk are *extremely* rare, and the writes that come from inserts/etc. are nicely buffered. Here's how I chose 256 megs for shared buffers: First, I increased the shared buffer amount until I didn't see any more performance benefits. Then I doubled it just for fun. ; ) Again, in your message it seemed like you were doing quite a bit of writes - have you disabled fsync, and what sort of disk system do you have? steve From pgsql-general-owner@postgresql.org Thu Nov 14 14:26:43 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1BB5476258 for ; Thu, 14 Nov 2002 14:26:42 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 93ABE476110 for ; Thu, 14 Nov 2002 14:26:41 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.194) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 20:26:40 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 20:20:35 +0100 Message-ID: <01a101c28c13$b0c28300$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Steve Wolfe" Cc: , References: <004801c28a81$8da1ca40$7100a8c0@STEINKAMP> <01f701c28c0e$1e3a6750$d281f6cc@WEASEL> Subject: Re: Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 20:26:11 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/626 X-Sequence-Number: 33047 hi steve, why fsync? - what's fsync? never heard of it... google tells me something about syncing of remote hosts ... so why should I activate it ?? ... I conclude, it's probably disabled because I don't know what it is .... it's a raid-1 ide system -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Steve Wolfe" To: Sent: Thursday, November 14, 2002 7:46 PM Subject: Re: [GENERAL] Upgrade to dual processor machine? > > The cache-field is saying 873548K cached at the moment > > Is this a "whole bunch of cache" in your opinion? Is it too much? > > Too much cache? It ain't possible. ; ) > > For what it's worth, my DB machine generally uses about 1.25 gigs for > disk cache, in addition to the 64 megs that are on the RAID card, and > that's just fine with me. I allocate 256 megs of shared memory (32768 > buffers), and the machine hums along very nicely. vmstat shows that > actual reads to the disk are *extremely* rare, and the writes that come > from inserts/etc. are nicely buffered. > > Here's how I chose 256 megs for shared buffers: First, I increased the > shared buffer amount until I didn't see any more performance benefits. > Then I doubled it just for fun. ; ) > > Again, in your message it seemed like you were doing quite a bit of > writes - have you disabled fsync, and what sort of disk system do you > have? > > steve > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) From pgsql-performance-owner@postgresql.org Thu Nov 14 14:27:03 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CC74E476BFE for ; Thu, 14 Nov 2002 14:27:02 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 154A4476BF8 for ; Thu, 14 Nov 2002 14:27:02 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAEJQDKX011487; Thu, 14 Nov 2002 12:26:13 -0700 (MST) Date: Thu, 14 Nov 2002 12:27:42 -0700 (MST) From: "scott.marlowe" To: Bjoern Metzdorf Cc: Subject: Re: Docs about buffers and sortmem setting In-Reply-To: <00d701c28bd8$28ecce80$0564a8c0@toolteam.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/57 X-Sequence-Number: 215 On Thu, 14 Nov 2002, Bjoern Metzdorf wrote: > > The general rule of thumb is to try about 25% of physical memory for > > your buffer size. Some people like to increase from there, until > > swapping starts, and then back off; but there are arguments against > > doing this, given the efficiency of modern filesystem buffering. > > How about 32-bit Linux machines with more than 1 GB RAM? We have a 2 GB RAM > machine running, and I gave 800 MB to postgres shared buffers. AFAIK Linux > user space can handle only 1 GB and the rest is for kernel buffer and > cache.. Actually, I think the limit is 2 or 3 gig depending on how your kernel was compiled, but testing by folks on the list seems to show a maximum of under 2 gig. I'm a little fuzzy on it, you might wanna search the archives. I'm not sure if that was a linux or a postgresql problem, and it was reported several months back. Memory slowly fading.... :-) From pgsql-general-owner@postgresql.org Thu Nov 14 14:35:59 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BE120476B7F; Thu, 14 Nov 2002 14:35:56 -0500 (EST) Received: from varsoon.wireboard.com (www.wireboard.com [216.151.155.101]) by postgresql.org (Postfix) with ESMTP id D4B7D476B57; Thu, 14 Nov 2002 14:35:55 -0500 (EST) Received: from doug by varsoon.wireboard.com with local (Exim 3.35 #1) id 18CPmK-0001T1-00; Thu, 14 Nov 2002 14:35:52 -0500 To: "Henrik Steffen" Cc: "Steve Wolfe" , , Subject: Re: Upgrade to dual processor machine? References: <004801c28a81$8da1ca40$7100a8c0@STEINKAMP> <01f701c28c0e$1e3a6750$d281f6cc@WEASEL> <01a101c28c13$b0c28300$7100a8c0@STEINKAMP> From: Doug McNaught Date: 14 Nov 2002 14:35:52 -0500 In-Reply-To: "Henrik Steffen"'s message of "Thu, 14 Nov 2002 20:26:11 +0100" Message-ID: Lines: 16 User-Agent: Gnus/5.0806 (Gnus v5.8.6) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/628 X-Sequence-Number: 33049 "Henrik Steffen" writes: > hi steve, > > why fsync? - what's fsync? never heard of it... google tells > me something about syncing of remote hosts ... so why should I > activate it ?? ... I conclude, it's probably disabled because > I don't know what it is .... fsync() is a system call that flushes a file's contents from the buffer cache to disk. PG uses it to ensure consistency in the WAL files. It is enabled by default. Do NOT disable it unless you know exactly what you are doing and are prepared to sacrifice some data integrity for performance. -Doug From pgsql-general-owner@postgresql.org Thu Nov 14 14:37:08 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2B328476C1E for ; Thu, 14 Nov 2002 14:37:08 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 7077C476C02 for ; Thu, 14 Nov 2002 14:37:06 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.194) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 20:36:58 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 20:30:52 +0100 Message-ID: <01b101c28c15$20b48ae0$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Manfred Koizar" Cc: , References: <00ec01c28bc5$241b9200$7100a8c0@STEINKAMP> Subject: Re: Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 20:36:28 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/629 X-Sequence-Number: 33050 of course, there are some seq scans... one of the most difficult queries is for example a kind of full text search, that searches through 8 different tables with each between 300.000 and 500.000 rows and 5-50 columns, but that's a different issue (need a full-text-search-engine...) I will do some experiments with both camps you described Thanks to all of you who wrote answers to this thread It has helped me a huge lot ! -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Manfred Koizar" To: "Henrik Steffen" Cc: ; Sent: Thursday, November 14, 2002 6:15 PM Subject: Re: [GENERAL] Upgrade to dual processor machine? > On Thu, 14 Nov 2002 11:03:54 +0100, "Henrik Steffen" > wrote: > >this is how it looks like, when my system is busy (right now!!!) > >vmstat 1 5: > > procs memory swap io system cpu > > r b w swpd free buff cache si so bi bo in cs us sy id > > 1 8 1 60 4964 5888 309684 0 0 176 74 16 32 25 9 66 > > 0 6 3 60 4964 5932 308772 0 0 6264 256 347 347 13 9 78 > > 0 5 1 60 4964 5900 309364 0 0 9312 224 380 309 11 6 83 > > 1 4 1 60 5272 5940 309152 0 0 10320 116 397 429 17 6 77 > > 1 4 1 60 4964 5896 309512 0 0 11020 152 451 456 14 10 76 > > More than 10000 disk blocks coming in per second looks quite > impressive, IMHO. (I wonder if this is due to seq scans?) But the > cpu idle column tells us that you are not CPU bound any more. > > > >free: > > total used free shared buffers cached > >Mem: 1020808 1015860 4948 531424 5972 309548 > >-/+ buffers/cache: 700340 320468 > >Swap: 1028112 60 1028052 > > There are two camps when it comes to PG shared buffers: (a) set > shared_buffers as high as possible to minimize PG buffer misses vs. > (b) assume that transfers between OS and PG buffers are cheap and > choose a moderate value for shared_buffers ("in the low thousands") to > let the operating system's disk caching do its work. > > Both camps agree that reserving half of your available memory for > shared buffers is a Bad Thing, because whenever a page cannot be found > in PG's buffers it is almost certainly not in the OS cache and has to > be fetched from disk. So half of your memory (the OS cache) is wasted > for nothing. > > FYI, I belong to the latter camp and I strongly feel you should set > shared_buffers to something near 4000. > > Servus > Manfred > From pgsql-general-owner@postgresql.org Thu Nov 14 14:54:26 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 79D2D475E13; Thu, 14 Nov 2002 14:54:25 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id DB106475CEE; Thu, 14 Nov 2002 14:54:24 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAEJr9KX028085; Thu, 14 Nov 2002 12:53:09 -0700 (MST) Date: Thu, 14 Nov 2002 12:54:38 -0700 (MST) From: "scott.marlowe" To: Henrik Steffen Cc: Steve Wolfe , , Subject: Re: Upgrade to dual processor machine? In-Reply-To: <01a101c28c13$b0c28300$7100a8c0@STEINKAMP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/630 X-Sequence-Number: 33051 On Thu, 14 Nov 2002, Henrik Steffen wrote: > > hi steve, > > why fsync? - what's fsync? never heard of it... google tells > me something about syncing of remote hosts ... so why should I > activate it ?? ... I conclude, it's probably disabled because > I don't know what it is .... > > it's a raid-1 ide system fsync is enabled by default. fsync flushes disk buffers after every write. Turning it off lets the OS flush buffers at its leisure. setting fsync=false will often double the write performance and since writes are running faster, there's more bandwidth for the reads as well, so everything goes faster. Definitely look at putting your data onto a Ultra160 SCSI 15krpm RAID1 set. My dual 80 Gig Ultra100 IDEs can get about 30 Megs a second in a RAID1 for raw reads under bonnie++, while my pair of Ultra80 10krpm 18 gig scsis can get about 48 Megs a second raw read. Plus SCSI is usually MUCH faster for writes than IDE. From pgsql-general-owner@postgresql.org Thu Nov 14 15:00:13 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CA5E4476B83; Thu, 14 Nov 2002 15:00:10 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id EF581476B7F; Thu, 14 Nov 2002 15:00:09 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAEJvCKX000976; Thu, 14 Nov 2002 12:57:13 -0700 (MST) Date: Thu, 14 Nov 2002 12:58:41 -0700 (MST) From: "scott.marlowe" To: Doug McNaught Cc: Henrik Steffen , Steve Wolfe , , Subject: Re: Upgrade to dual processor machine? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/631 X-Sequence-Number: 33052 On 14 Nov 2002, Doug McNaught wrote: > "Henrik Steffen" writes: > > > hi steve, > > > > why fsync? - what's fsync? never heard of it... google tells > > me something about syncing of remote hosts ... so why should I > > activate it ?? ... I conclude, it's probably disabled because > > I don't know what it is .... > > fsync() is a system call that flushes a file's contents from the > buffer cache to disk. PG uses it to ensure consistency in the WAL > files. It is enabled by default. Do NOT disable it unless you know > exactly what you are doing and are prepared to sacrifice some data > integrity for performance. I thought the danger with WAL was minimized to the point of not being an issue anymore. Tom? From pgsql-performance-owner@postgresql.org Thu Nov 14 15:00:19 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AC174476B91 for ; Thu, 14 Nov 2002 15:00:16 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 7EE52476B85 for ; Thu, 14 Nov 2002 15:00:13 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAEJwWKX001964; Thu, 14 Nov 2002 12:58:33 -0700 (MST) Date: Thu, 14 Nov 2002 13:00:01 -0700 (MST) From: "scott.marlowe" To: pginfo Cc: "pgsql-performance@postgresql.org" Subject: Re: Sort time In-Reply-To: <3DD3D2AE.70413B6D@t1.unisoftbg.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/62 X-Sequence-Number: 220 On Thu, 14 Nov 2002, pginfo wrote: > Hi, > > Why is the sort part of my query getting so much time? > > I run a relative complex query and it gets about 50 sec. > For sorting I need another 50 sec! > > Can I increase the sort memory for better performance? > How meny memory is needet for the sort in pg. > The same data readet in java and sorted cost 10 sec ! Increasing sort_mem can help, but often the problem is that your query isn't optimal. If you'd like to post the explain analyze output of your query, someone might have a hint on how to increase the efficiency of the query. From pgsql-general-owner@postgresql.org Thu Nov 14 15:20:30 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AEDA6476BB6; Thu, 14 Nov 2002 15:20:25 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6E087476B57; Thu, 14 Nov 2002 15:20:23 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAEKJqhR021067; Thu, 14 Nov 2002 15:19:52 -0500 (EST) To: "scott.marlowe" Cc: Doug McNaught , Henrik Steffen , Steve Wolfe , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] Upgrade to dual processor machine? In-reply-to: References: Comments: In-reply-to "scott.marlowe" message dated "Thu, 14 Nov 2002 12:58:41 -0700" Date: Thu, 14 Nov 2002 15:19:52 -0500 Message-ID: <21066.1037305192@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/633 X-Sequence-Number: 33054 "scott.marlowe" writes: > On 14 Nov 2002, Doug McNaught wrote: >> fsync() is a system call that flushes a file's contents from the >> buffer cache to disk. PG uses it to ensure consistency in the WAL >> files. It is enabled by default. Do NOT disable it unless you know >> exactly what you are doing and are prepared to sacrifice some data >> integrity for performance. > I thought the danger with WAL was minimized to the point of not being an > issue anymore. Tom? Actually, more the other way 'round: WAL minimizes the cost of using fsync, since we now only need to fsync the WAL file and not anything else. The risk of not using it is still data corruption --- mainly because without fsync, we can't be certain that WAL writes hit disk in advance of the corresponding data-page changes. If you have a crash, the system will replay the log as far as it can; but if there are additional unlogged changes in the data files, you might have inconsistencies. I'd definitely recommend keeping fsync on in any production installation. For development maybe you don't care about data loss... regards, tom lane From pgsql-general-owner@postgresql.org Thu Nov 14 15:37:08 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A18E9476CE0 for ; Thu, 14 Nov 2002 15:37:04 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 1A756476CD9 for ; Thu, 14 Nov 2002 15:37:03 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.194) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 21:37:02 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 14 Nov 2002 21:30:57 +0100 Message-ID: <021d01c28c1d$85248ae0$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Cc: , References: <3DD3C819.3038.3E3812E@localhost> Subject: Re: [PERFORM] Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 21:36:33 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/635 X-Sequence-Number: 33056 Hi Shridhar, do you seriously think that I should vacuum frequently updated/inserted tables every 120 seconds ? This is what it says in the manual and what I have been doing until today: "You should run VACUUM periodically to clean out expired rows. For tables that are heavily modified, it is useful to run VACUUM every night in an automated manner. For tables with few modifications, VACUUM should be run less frequently. The command exclusively locks the table while processing. " And: "You should run VACUUM ANALYZE when a table is initially loaded and when a table's data changes dramatically. " I have many UPDATEs and INSERTs on my log-statistics. For each http-request there will be an INSERT into the logfile. And if certain customer pages are downloaded there will even be an UPDATE in a customer-statistics table causing a hits column to be set to hits+1... I didn't think this was a dramatical change so far. Still sure to run VACUUM ANALYZE on these tables so often? VACUUM ANALYZE takes about 30 seconds on one of these tables and will be done once every night automatically. > Besides almost transactions are insert/update.. And if you have 11K blocks per > second to write.. I suggest you vacuum analyse most used table one in a minute > or so. Decide the best frequency by trial and error. A good start is double the > time it takes for vacuum. i.e. if vacuum analyse takes 60 sec to finish, leave > a gap of 120 sec. between two runs of vacuum. -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Shridhar Daithankar" To: Sent: Thursday, November 14, 2002 11:28 AM Subject: Re: [PERFORM] [GENERAL] Upgrade to dual processor machine? > On 14 Nov 2002 at 11:03, Henrik Steffen wrote: > > vmstat 1 5: > > procs memory swap io system cpu > > r b w swpd free buff cache si so bi bo in cs us sy id > > 1 8 1 60 4964 5888 309684 0 0 176 74 16 32 25 9 66 > > 0 6 3 60 4964 5932 308772 0 0 6264 256 347 347 13 9 78 > > 0 5 1 60 4964 5900 309364 0 0 9312 224 380 309 11 6 83 > > 1 4 1 60 5272 5940 309152 0 0 10320 116 397 429 17 6 77 > > 1 4 1 60 4964 5896 309512 0 0 11020 152 451 456 14 10 76 > > w: > > 12:04pm up 2 days, 17:44, 1 user, load average: 10.28, 7.22, 3.88 > > USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT > > root pts/0 condor.city-map. 11:46am 0.00s 0.09s 0.01s w > > this is when things begin to go more slowly.... > > Two things immediately noticable.. Load average and block ins.. > > Either your disk write BW is saturated or CPU is too full, which I believe is > the case. HAve you ever got faster write performance than 12K blocks say? Disk > BW may be a bottleneck here.. Are they IDE disks? > > Besides almost transactions are insert/update.. And if you have 11K blocks per > second to write.. I suggest you vacuum analyse most used table one in a minute > or so. Decide the best frequency by trial and error. A good start is double the > > time it takes for vacuum. i.e. if vacuum analyse takes 60 sec to finish, leave > a gap of 120 sec. between two runs of vacuum. > > You need to vacuum only those tables which are heavily updated. This will make > vacuum faster. > > HTH > Bye > Shridhar > > -- > Nouvelle cuisine, n.: French for "not enough food".Continental breakfast, n.: > English for "not enough food".Tapas, n.: Spanish for "not enough food".Dim Sum, > > n.: Chinese for more food than you've ever seen in your entire life. > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-general-owner@postgresql.org Thu Nov 14 15:51:19 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9198D476C1A; Thu, 14 Nov 2002 15:51:17 -0500 (EST) Received: from varsoon.wireboard.com (www.wireboard.com [216.151.155.101]) by postgresql.org (Postfix) with ESMTP id B1A66476B03; Thu, 14 Nov 2002 15:51:16 -0500 (EST) Received: from doug by varsoon.wireboard.com with local (Exim 3.35 #1) id 18CQx0-0001bk-00; Thu, 14 Nov 2002 15:50:58 -0500 To: "Henrik Steffen" Cc: , , Subject: Re: [PERFORM] Upgrade to dual processor machine? References: <3DD3C819.3038.3E3812E@localhost> <021d01c28c1d$85248ae0$7100a8c0@STEINKAMP> From: Doug McNaught Date: 14 Nov 2002 15:50:58 -0500 In-Reply-To: "Henrik Steffen"'s message of "Thu, 14 Nov 2002 21:36:33 +0100" Message-ID: Lines: 12 User-Agent: Gnus/5.0806 (Gnus v5.8.6) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/636 X-Sequence-Number: 33057 "Henrik Steffen" writes: > This is what it says in the manual and what I have been doing until today: > > "You should run VACUUM periodically to clean out expired rows. For tables that are heavily modified, it is useful to run VACUUM > every night in an automated manner. For tables with few modifications, VACUUM should be run less frequently. The command exclusively > locks the table while processing. " The "exclusive lock" part is no longer true as of 7.2.X--it is now much cheaper to run VACUUM. What version were you running again? -Doug From pgsql-general-owner@postgresql.org Thu Nov 14 15:54:12 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5C9E7476BAB; Thu, 14 Nov 2002 15:54:11 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id ABA5E476BA2; Thu, 14 Nov 2002 15:54:10 -0500 (EST) Received: from [216.135.165.74] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1826284; Thu, 14 Nov 2002 12:57:42 -0800 From: "Josh Berkus" Subject: Re: [PERFORM] Upgrade to dual processor machine? To: "Henrik Steffen" , Cc: , X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 14 Nov 2002 12:57:42 -0800 Message-ID: In-Reply-To: <021d01c28c1d$85248ae0$7100a8c0@STEINKAMP> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/637 X-Sequence-Number: 33058 Henrik, > do you seriously think that I should vacuum frequently > updated/inserted > tables every 120 seconds ? > > This is what it says in the manual and what I have been doing until > today: > > "You should run VACUUM periodically to clean out expired rows. For > tables that are heavily modified, it is useful to run VACUUM > every night in an automated manner. For tables with few > modifications, VACUUM should be run less frequently. The command > exclusively > locks the table while processing. " > > And: > > "You should run VACUUM ANALYZE when a table is initially loaded and > when a table's data changes dramatically. " That's the postgres *7.1* manual you're reading. You need to read the 7.2 online manual; VACUUM has changed substantially. -Josh Berkus From pgsql-general-owner@postgresql.org Thu Nov 14 15:55:54 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 23F9F476A38; Thu, 14 Nov 2002 15:55:54 -0500 (EST) Received: from medi.engr.intransa.com (unknown [12.146.157.2]) by postgresql.org (Postfix) with ESMTP id A196F475F25; Thu, 14 Nov 2002 15:55:50 -0500 (EST) Received: from intransa.com (localhost.localdomain [127.0.0.1]) by medi.engr.intransa.com (8.12.5/8.12.5) with ESMTP id gAEL5QNB008828; Thu, 14 Nov 2002 13:05:27 -0800 Message-ID: <3DD41016.5050501@intransa.com> Date: Thu, 14 Nov 2002 13:05:26 -0800 From: Medi Montaseri User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020830 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Henrik Steffen Cc: shridhar_daithankar@persistent.co.in, pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] Upgrade to dual processor machine? References: <3DD3C819.3038.3E3812E@localhost> <021d01c28c1d$85248ae0$7100a8c0@STEINKAMP> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/638 X-Sequence-Number: 33059 I use the Async Query technique of PG to do such tasks as Vacuum-ing. Henrik Steffen wrote: >Hi Shridhar, > >do you seriously think that I should vacuum frequently updated/inserted >tables every 120 seconds ? > >This is what it says in the manual and what I have been doing until today: > >"You should run VACUUM periodically to clean out expired rows. For tables that are heavily modified, it is useful to run VACUUM >every night in an automated manner. For tables with few modifications, VACUUM should be run less frequently. The command exclusively >locks the table while processing. " > >And: > >"You should run VACUUM ANALYZE when a table is initially loaded and when a table's data changes dramatically. " > > >I have many UPDATEs and INSERTs on my log-statistics. For each http-request >there will be an INSERT into the logfile. And if certain customer pages >are downloaded there will even be an UPDATE in a customer-statistics table >causing a hits column to be set to hits+1... I didn't think this was a >dramatical change so far. > >Still sure to run VACUUM ANALYZE on these tables so often? > >VACUUM ANALYZE takes about 30 seconds on one of these tables and will be done once >every night automatically. > > > > >>Besides almost transactions are insert/update.. And if you have 11K blocks per >>second to write.. I suggest you vacuum analyse most used table one in a minute >>or so. Decide the best frequency by trial and error. A good start is double the >>time it takes for vacuum. i.e. if vacuum analyse takes 60 sec to finish, leave >>a gap of 120 sec. between two runs of vacuum. >> >> > >-- > >Mit freundlichem Gru� > >Henrik Steffen >Gesch�ftsf�hrer > >top concepts Internetmarketing GmbH >Am Steinkamp 7 - D-21684 Stade - Germany >-------------------------------------------------------- >http://www.topconcepts.com Tel. +49 4141 991230 >mail: steffen@topconcepts.com Fax. +49 4141 991233 >-------------------------------------------------------- >24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) >-------------------------------------------------------- >Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de >System-Partner gesucht: http://www.franchise.city-map.de >-------------------------------------------------------- >Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 >-------------------------------------------------------- > >----- Original Message ----- >From: "Shridhar Daithankar" >To: >Sent: Thursday, November 14, 2002 11:28 AM >Subject: Re: [PERFORM] [GENERAL] Upgrade to dual processor machine? > > > > >>On 14 Nov 2002 at 11:03, Henrik Steffen wrote: >> >> >>>vmstat 1 5: >>> procs memory swap io system cpu >>> r b w swpd free buff cache si so bi bo in cs us sy id >>> 1 8 1 60 4964 5888 309684 0 0 176 74 16 32 25 9 66 >>> 0 6 3 60 4964 5932 308772 0 0 6264 256 347 347 13 9 78 >>> 0 5 1 60 4964 5900 309364 0 0 9312 224 380 309 11 6 83 >>> 1 4 1 60 5272 5940 309152 0 0 10320 116 397 429 17 6 77 >>> 1 4 1 60 4964 5896 309512 0 0 11020 152 451 456 14 10 76 >>>w: >>>12:04pm up 2 days, 17:44, 1 user, load average: 10.28, 7.22, 3.88 >>>USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT >>>root pts/0 condor.city-map. 11:46am 0.00s 0.09s 0.01s w >>>this is when things begin to go more slowly.... >>> >>> >>Two things immediately noticable.. Load average and block ins.. >> >>Either your disk write BW is saturated or CPU is too full, which I believe is >>the case. HAve you ever got faster write performance than 12K blocks say? Disk >>BW may be a bottleneck here.. Are they IDE disks? >> >>Besides almost transactions are insert/update.. And if you have 11K blocks per >>second to write.. I suggest you vacuum analyse most used table one in a minute >>or so. Decide the best frequency by trial and error. A good start is double the >> >>time it takes for vacuum. i.e. if vacuum analyse takes 60 sec to finish, leave >>a gap of 120 sec. between two runs of vacuum. >> >>You need to vacuum only those tables which are heavily updated. This will make >>vacuum faster. >> >>HTH >>Bye >> Shridhar >> >>-- >>Nouvelle cuisine, n.: French for "not enough food".Continental breakfast, n.: >>English for "not enough food".Tapas, n.: Spanish for "not enough food".Dim Sum, >> >>n.: Chinese for more food than you've ever seen in your entire life. >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 6: Have you searched our list archives? >> >>http://archives.postgresql.org >> >> > > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > From pgsql-general-owner@postgresql.org Fri Nov 15 11:44:56 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 327D6476C99 for ; Thu, 14 Nov 2002 16:32:41 -0500 (EST) Received: from mail.performics.com (mail.performics.com [12.40.135.195]) by postgresql.org (Postfix) with SMTP id 60390476B0C for ; Thu, 14 Nov 2002 16:31:46 -0500 (EST) Received: (qmail 32025 invoked from network); 14 Nov 2002 21:31:39 -0000 Received: from unknown (HELO performics.com) (10.10.31.209) by 10.10.90.88 with SMTP; 14 Nov 2002 21:31:39 -0000 Date: Thu, 14 Nov 2002 15:26:05 -0600 (CST) From: jmelesky@performics.com Reply-To: jmelesky@performics.com Subject: Re: [PERFORM] Upgrade to dual processor machine? To: steffen@city-map.de Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <01b101c28c15$20b48ae0$7100a8c0@STEINKAMP> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=iso-8859-1 Message-Id: <20021114213146.60390476B0C@postgresql.org> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/679 X-Sequence-Number: 33100 On 14 Nov, Henrik Steffen wrote: > of course, there are some seq scans... one of the most > difficult queries is for example a kind of full text > search, that searches through 8 different tables with > each between 300.000 and 500.000 rows and 5-50 columns, > but that's a different issue (need a full-text-search-engine...) Ah, well, it may be worthwhile to check out fulltextindex or tsearch in contrib/. They both require some changes to the way you do queries, but they may be helpful in speeding up those queries. -johnnnnnnnnn From pgsql-performance-owner@postgresql.org Thu Nov 14 16:32:43 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CB1E9476CF4 for ; Thu, 14 Nov 2002 16:32:41 -0500 (EST) Received: from mail.performics.com (mail.performics.com [12.40.135.195]) by postgresql.org (Postfix) with SMTP id 60014476B03 for ; Thu, 14 Nov 2002 16:31:46 -0500 (EST) Received: (qmail 32025 invoked from network); 14 Nov 2002 21:31:39 -0000 Received: from unknown (HELO performics.com) (10.10.31.209) by 10.10.90.88 with SMTP; 14 Nov 2002 21:31:39 -0000 Date: Thu, 14 Nov 2002 15:26:05 -0600 (CST) From: jmelesky@performics.com Reply-To: jmelesky@performics.com Subject: Re: [GENERAL] Upgrade to dual processor machine? To: steffen@city-map.de Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <01b101c28c15$20b48ae0$7100a8c0@STEINKAMP> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=iso-8859-1 Message-Id: <20021114213146.60014476B03@postgresql.org> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/70 X-Sequence-Number: 228 On 14 Nov, Henrik Steffen wrote: > of course, there are some seq scans... one of the most > difficult queries is for example a kind of full text > search, that searches through 8 different tables with > each between 300.000 and 500.000 rows and 5-50 columns, > but that's a different issue (need a full-text-search-engine...) Ah, well, it may be worthwhile to check out fulltextindex or tsearch in contrib/. They both require some changes to the way you do queries, but they may be helpful in speeding up those queries. -johnnnnnnnnn From pgsql-general-owner@postgresql.org Thu Nov 14 16:28:52 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26FAD476083; Thu, 14 Nov 2002 16:28:52 -0500 (EST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by postgresql.org (Postfix) with ESMTP id 9ABB3475F25; Thu, 14 Nov 2002 16:28:51 -0500 (EST) Received: from tokyo.samurai.com (DU150.N224.ResNet.QueensU.CA [130.15.224.150]) by bob.samurai.com (Postfix) with ESMTP id EA7FF1E3E; Thu, 14 Nov 2002 16:28:50 -0500 (EST) To: "Henrik Steffen" Cc: , , Subject: Re: [PERFORM] Upgrade to dual processor machine? References: <3DD3C819.3038.3E3812E@localhost> <021d01c28c1d$85248ae0$7100a8c0@STEINKAMP> From: Neil Conway In-Reply-To: <021d01c28c1d$85248ae0$7100a8c0@STEINKAMP> Date: 14 Nov 2002 16:28:29 -0500 Message-ID: <8765uzsuwy.fsf@mailbox.samurai.com> Lines: 29 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/640 X-Sequence-Number: 33061 "Henrik Steffen" writes: > I have many UPDATEs and INSERTs on my log-statistics. For each > http-request there will be an INSERT into the logfile. And if > certain customer pages are downloaded there will even be an UPDATE > in a customer-statistics table causing a hits column to be set to > hits+1... I didn't think this was a dramatical change so far. Just to clarify, INSERT does not create dead rows -- tables that have lots of INSERTS don't need to be vacuumed particularly often. In contrast, an UPDATE is really a DELETE plus an INSERT, so it *will* create dead rows. To get an idea of how many dead tuples there are in a table, try contrib/pgstattuple (maybe it's only in 7.3's contrib/, not sure). > Still sure to run VACUUM ANALYZE on these tables so often? Well, the ANALYZE part is probably rarely needed, as I wouldn't think the statistical distribution of the data in the table changes very frequently -- so maybe run a database-wide ANALYZE once per day? But if a table is updated frequently, VACUUM frequently is definately a good idea. Cheers, Neil -- Neil Conway || PGP Key ID: DB3C29FC From pgsql-performance-owner@postgresql.org Thu Nov 14 16:29:20 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A9BF5476CE8 for ; Thu, 14 Nov 2002 16:29:19 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id 7793C476CA5 for ; Thu, 14 Nov 2002 16:29:18 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id gAELXN6P026256; Thu, 14 Nov 2002 16:33:23 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id gAELTDj32267; Thu, 14 Nov 2002 16:29:13 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id W7RLWLCS; Thu, 14 Nov 2002 16:29:12 -0500 Subject: Re: swapping? From: Robert Treat To: Wei Weng Cc: pgsql-performance@postgresql.org In-Reply-To: <1037289210.1348.4.camel@Monet> References: <3DD4027C.4503.18465B@localhost> <1037289210.1348.4.camel@Monet> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 14 Nov 2002 16:29:12 -0500 Message-Id: <1037309352.4724.81.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/69 X-Sequence-Number: 227 you can use vmstat to measure swap activity. check the man page for your system. Robert Treat On Thu, 2002-11-14 at 10:53, Wei Weng wrote: > How do you notice that if a system started swapping or not? > > Thanks > > On Thu, 2002-11-14 at 09:37, Shridhar Daithankar wrote: > > On 14 Nov 2002 at 10:30, Wei Weng wrote: > > > > > The term had been mentioned often enough on this mailing list. Can > > > someone enlighten me with some description or a URL where I can read on? > > > And why is it important to postgresql database performace? > > > > When programs request more memory than available, OS 'swaps' some memory to > > special area on disk and make the memory available. To programs, it gives > > appearance that nearly infinite memory is available. > > > > Unfortunately disk are hell slower than RAM and hence swapping slows things > > down as it takes much to swap in to disk and swap out of disk. Since OS does > > not care which programs get swapped, it is possible that postgresql instance > > can get swapped. That slows down effective memory access to knees.. > > > > That's why for good performance, a serve should never swap.. > > > > Bye > > Shridhar > > > > -- > > Peterson's Admonition: When you think you're going down for the third time -- > > just remember that you may have counted wrong. > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- > Wei Weng > Network Software Engineer > KenCast Inc. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Thu Nov 14 16:46:37 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BF530476D68 for ; Thu, 14 Nov 2002 16:46:36 -0500 (EST) Received: from office.nextbus.com (ns.nextbus.com [64.164.28.194]) by postgresql.org (Postfix) with ESMTP id 6A880476D02 for ; Thu, 14 Nov 2002 16:46:28 -0500 (EST) Received: from visor.corp.nextbus.com (visor.corp.nextbus.com [192.168.1.109]) by office.nextbus.com (Postfix) with ESMTP id 4D7534F87B for ; Thu, 14 Nov 2002 13:46:28 -0800 (PST) Received: from localhost (laurette@localhost) by visor.corp.nextbus.com (8.11.2/8.8.7) with ESMTP id gAELkTp17699 for ; Thu, 14 Nov 2002 13:46:29 -0800 X-Authentication-Warning: visor.corp.nextbus.com: laurette owned process doing -bs Date: Thu, 14 Nov 2002 13:46:29 -0800 (PST) From: Laurette Cisneros X-X-Sender: laurette@visor.corp.nextbus.com To: pgsql-performance@postgresql.org Subject: digest Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/71 X-Sequence-Number: 229 Is it possible to configure the digest form for this list? It's starting to get busy (which is relative I know, but I'm on a lot of lists and prefer digest...others too?). Thanks, -- Laurette Cisneros The Database Group (510) 420-3137 NextBus Information Systems, Inc. www.nextbus.com ---------------------------------- My other vehicle is my imagination. - bumper sticker From pgsql-general-owner@postgresql.org Thu Nov 14 18:33:51 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 75E5A476A8A; Thu, 14 Nov 2002 18:33:50 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id CE595476A8C; Thu, 14 Nov 2002 18:33:49 -0500 (EST) Received: from [216.135.165.74] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1826594; Thu, 14 Nov 2002 15:37:28 -0800 From: "Josh Berkus" Subject: Re: [PERFORM] Upgrade to dual processor machine? To: steffen@city-map.de Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 14 Nov 2002 15:37:28 -0800 Message-ID: In-Reply-To: <20021114213146.60014476B03@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/643 X-Sequence-Number: 33064 Henrik, > Ah, well, it may be worthwhile to check out fulltextindex or tsearch > in contrib/. They both require some changes to the way you do > queries, > but they may be helpful in speeding up those queries. Or OpenFTS: www.openfts.org -Josh From pgsql-performance-owner@postgresql.org Thu Nov 14 19:26:34 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A013D475B84 for ; Thu, 14 Nov 2002 19:26:33 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 13298475AA1 for ; Thu, 14 Nov 2002 19:26:33 -0500 (EST) Received: from [216.135.165.74] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1826692; Thu, 14 Nov 2002 16:30:12 -0800 From: "Josh Berkus" Subject: Re: digest To: Laurette Cisneros , pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 14 Nov 2002 16:30:12 -0800 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/73 X-Sequence-Number: 231 Laurette, > Is it possible to configure the digest form for this list? It's > starting > to get busy (which is relative I know, but I'm on a lot of lists and > prefer > digest...others too?). > > Thanks, At some point in the past, you should have received an e-mail from majordomo@postgresql.org with your user password and instructions on setting list options. There is both a web inteface, and you can set options by e-mail. There is way to get your password if you don't have it, but I don't have the commands in front of me, right now. If I'm being an idiot, and you're telling me that there is no digest mode set up for the list, then you should e-mail Marc (scrappy@hub.org) with a polite request to set daily digests for the list. -Josh Berkus From pgsql-performance-owner@postgresql.org Thu Nov 14 19:30:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 519DF475B84 for ; Thu, 14 Nov 2002 19:30:40 -0500 (EST) Received: from local.iboats.com (local.iboats.com [204.246.129.200]) by postgresql.org (Postfix) with SMTP id 63D48475AA1 for ; Thu, 14 Nov 2002 19:30:39 -0500 (EST) Received: (qmail 13874 invoked by uid 82); 14 Nov 2002 17:30:53 -0700 Received: from nw@codon.com by local.iboats.com by uid 81 with qmail-scanner-1.14 ( Clear:. Processed in 0.032148 secs); 15 Nov 2002 00:30:53 -0000 Received: from unknown (HELO WEASEL) (204.246.129.210) by 0 with SMTP; 14 Nov 2002 17:30:53 -0700 Message-ID: <005c01c28c3e$b6018890$d281f6cc@WEASEL> From: "Steve Wolfe" To: References: <004801c28a81$8da1ca40$7100a8c0@STEINKAMP><01f701c28c0e$1e3a6750$d281f6cc@WEASEL><01a101c28c13$b0c28300$7100a8c0@STEINKAMP> Subject: Re: [GENERAL] Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 17:33:35 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/74 X-Sequence-Number: 232 > fsync() is a system call that flushes a file's contents from the > buffer cache to disk. PG uses it to ensure consistency in the WAL > files. It is enabled by default. Do NOT disable it unless you know > exactly what you are doing and are prepared to sacrifice some data > integrity for performance. The only issue of data integrity is in the case of an unclean shutdown, like a power failure or a crash. PG and my OS are reliable enough that I trust them not to crash, and my hardware has proven itself as well. Of course, as you point out, if someone doesn't trust their server, they're taking chances. That being said, even on other machines with fsync turned off and unclean shutdowns (power cycles, etc.), I have yet to run into any problem with PG's consistency, although I certainly cannot guarantee that would be the case for anyone else! steve From pgsql-performance-owner@postgresql.org Thu Nov 14 19:34:52 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6310C475D99 for ; Thu, 14 Nov 2002 19:34:51 -0500 (EST) Received: from office.nextbus.com (ns.nextbus.com [64.164.28.194]) by postgresql.org (Postfix) with ESMTP id B9B21475CB4 for ; Thu, 14 Nov 2002 19:34:50 -0500 (EST) Received: from visor.corp.nextbus.com (visor.corp.nextbus.com [192.168.1.109]) by office.nextbus.com (Postfix) with ESMTP id 9580C4F87B; Thu, 14 Nov 2002 16:34:51 -0800 (PST) Received: from localhost (laurette@localhost) by visor.corp.nextbus.com (8.11.2/8.8.7) with ESMTP id gAF0Yrj20411; Thu, 14 Nov 2002 16:34:53 -0800 X-Authentication-Warning: visor.corp.nextbus.com: laurette owned process doing -bs Date: Thu, 14 Nov 2002 16:34:53 -0800 (PST) From: Laurette Cisneros X-X-Sender: laurette@visor.corp.nextbus.com To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: digest In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/75 X-Sequence-Number: 233 There is no digest set up for this list. I will send mail to Marc. Thanks, L. On Thu, 14 Nov 2002, Josh Berkus wrote: > Laurette, > > > Is it possible to configure the digest form for this list? It's > > starting > > to get busy (which is relative I know, but I'm on a lot of lists and > > prefer > > digest...others too?). > > > > Thanks, > > At some point in the past, you should have received an e-mail from > majordomo@postgresql.org with your user password and instructions on > setting list options. There is both a web inteface, and you can set > options by e-mail. > > There is way to get your password if you don't have it, but I don't > have the commands in front of me, right now. > > If I'm being an idiot, and you're telling me that there is no digest > mode set up for the list, then you should e-mail Marc (scrappy@hub.org) > with a polite request to set daily digests for the list. > > > -Josh Berkus > -- Laurette Cisneros The Database Group (510) 420-3137 NextBus Information Systems, Inc. www.nextbus.com ---------------------------------- My other vehicle is my imagination. - bumper sticker From pgsql-performance-owner@postgresql.org Thu Nov 14 19:35:43 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BEBF4475B84 for ; Thu, 14 Nov 2002 19:35:42 -0500 (EST) Received: from local.iboats.com (local.iboats.com [204.246.129.200]) by postgresql.org (Postfix) with SMTP id E61A3475AA1 for ; Thu, 14 Nov 2002 19:35:41 -0500 (EST) Received: (qmail 14088 invoked by uid 82); 14 Nov 2002 17:35:56 -0700 Received: from nw@codon.com by local.iboats.com by uid 81 with qmail-scanner-1.14 ( Clear:. Processed in 0.030377 secs); 15 Nov 2002 00:35:56 -0000 Received: from unknown (HELO WEASEL) (204.246.129.210) by 0 with SMTP; 14 Nov 2002 17:35:56 -0700 Message-ID: <006d01c28c3f$6a889740$d281f6cc@WEASEL> From: "Steve Wolfe" To: References: Subject: Re: [GENERAL] Upgrade to dual processor machine? Date: Thu, 14 Nov 2002 17:38:13 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/76 X-Sequence-Number: 234 > fsync is enabled by default. fsync flushes disk buffers after every > write. Turning it off lets the OS flush buffers at its leisure. setting > fsync=false will often double the write performance and since writes are > running faster, there's more bandwidth for the reads as well, so > everything goes faster. "doubling performance" is very conservative, I've seen it give more than a tenfold increase in performance on large insert/update batches. Of course, the exact figure depends on a lot of hardware and OS factors. > Definitely look at putting your data onto a Ultra160 SCSI 15krpm RAID1 > set. My dual 80 Gig Ultra100 IDEs can get about 30 Megs a second in a > RAID1 for raw reads under bonnie++, while my pair of Ultra80 10krpm 18 gig > scsis can get about 48 Megs a second raw read. If you trust the hardware, disabling fsync and using copious quantities of cache/buffer can almost eliminate actual disk access. My DB machine will quickly blip the lights on the RAID array once a minute or so, but that's about it. All of the actual work is happening from RAM. Of course, with obscenely large data sets, that becomes difficult to achieve. steve From pgsql-performance-owner@postgresql.org Fri Nov 15 02:04:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6CC0475ADD for ; Fri, 15 Nov 2002 02:04:40 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id A37C1474E42 for ; Fri, 15 Nov 2002 02:04:37 -0500 (EST) Received: (qmail 8814 invoked from network); 15 Nov 2002 08:46:50 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 15 Nov 2002 08:46:50 -0000 Message-ID: <3DD48F6A.D80604EC@t1.unisoftbg.com> Date: Fri, 15 Nov 2002 07:08:42 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: "scott.marlowe" Cc: "pgsql-performance@postgresql.org" Subject: Re: Sort time References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/77 X-Sequence-Number: 235 Hi, The sort mem is prety big at the moment. For this tuning I use 256 MB for sort mem ! The explain plan is: EXPLAIN gibi=# explain analyze select S.IDS_NUM,S.OP,S.KOL,S.OTN_MED,S.CENA,S.DDS,S.KURS,S.TOT,S.DTO,S.PTO,S.DTON,MED.MNAME AS MEDNAME,N.MNAME AS NOMENNAME,N.NUM AS NNUM,S.PART,S.IZV,D.DATE_OP from A_DOC D , A_SKLAD S, A_NOMEN N ,A_MED MED WHERE S.FID=0 AND N.OSN_MED=MED.ID S AND S.IDS_NUM=N.IDS AND S.IDS_DOC=D.IDS ORDER BY S.IDS_NUM,S.PART,S.OP ; NOTICE: QUERY PLAN: Sort (cost=100922.53..100922.53 rows=22330 width=215) (actual time=111241.88..111735.33 rows=679743 loops=1) -> Hash Join (cost=9153.28..99309.52 rows=22330 width=215) (actual time=3386.45..53065.59 rows=679743 loops=1) -> Hash Join (cost=2271.05..91995.05 rows=30620 width=198) (actual time=2395.76..36710.54 rows=679743 loops=1) -> Seq Scan on a_sklad s (cost=0.00..84181.91 rows=687913 width=111) (actual time=2111.30..22354.10 rows=679743 loops=1) -> Hash (cost=2256.59..2256.59 rows=5784 width=87) (actual time=282.95..282.95 rows=0 loops=1) -> Hash Join (cost=2.52..2256.59 rows=5784 width=87) (actual time=132.54..270.29 rows=5784 loops=1) -> Seq Scan on a_nomen n (cost=0.00..2152.84 rows=5784 width=74) (actual time=127.97..218.02 rows=5784 loops=1) -> Hash (cost=2.42..2.42 rows=42 width=13) (actual time=0.55..0.55 rows=0 loops=1) -> Seq Scan on a_med med (cost=0.00..2.42 rows=42 width=13) (actual time=0.22..0.43 rows=42 loops=1) -> Hash (cost=6605.19..6605.19 rows=110819 width=17) (actual time=987.26..987.26 rows=0 loops=1) -> Seq Scan on a_doc d (cost=0.00..6605.19 rows=110819 width=17) (actual time=67.96..771.54 rows=109788 loops=1) Total runtime: 112402.30 msec EXPLAIN All IDS_XXX fields are varchar(20),S.PART is also varchar(20). All tables are indexed. Can I change any parameters on my pg to increase the speed. It looks very slow. Only for test ( I do not need it) I executed: EXPLAIN gibi=# explain analyze select S.IDS_NUM,S.OP,S.KOL,S.OTN_MED,S.CENA,S.DDS,S.KURS,S.TOT,S.DTO,S.PTO,S.DTON,MED.MNAME AS MEDNAME,N.MNAME AS NOMENNAME,N.NUM AS NNUM,S.PART,S.IZV,D.DATE_OP from A_DOC D , A_SKLAD S, A_NOMEN N ,A_MED MED WHERE S.FID=0 AND N.OSN_MED=MED.ID S AND S.IDS_NUM=N.IDS AND S.IDS_DOC=D.IDS ORDER BY S.OP ; NOTICE: QUERY PLAN: Sort (cost=100922.53..100922.53 rows=22330 width=215) (actual time=62141.60..62598.05 rows=679743 loops=1) -> Hash Join (cost=9153.28..99309.52 rows=22330 width=215) (actual time=9032.59..54703.33 rows=679743 loops=1) -> Hash Join (cost=2271.05..91995.05 rows=30620 width=198) (actual time=8046.91..39132.91 rows=679743 loops=1) -> Seq Scan on a_sklad s (cost=0.00..84181.91 rows=687913 width=111) (actual time=7790.01..25565.74 rows=679743 loops=1) -> Hash (cost=2256.59..2256.59 rows=5784 width=87) (actual time=255.32..255.32 rows=0 loops=1) -> Hash Join (cost=2.52..2256.59 rows=5784 width=87) (actual time=123.40..243.02 rows=5784 loops=1) -> Seq Scan on a_nomen n (cost=0.00..2152.84 rows=5784 width=74) (actual time=118.75..204.41 rows=5784 loops=1) -> Hash (cost=2.42..2.42 rows=42 width=13) (actual time=0.59..0.59 rows=0 loops=1) -> Seq Scan on a_med med (cost=0.00..2.42 rows=42 width=13) (actual time=0.25..0.47 rows=42 loops=1) -> Hash (cost=6605.19..6605.19 rows=110819 width=17) (actual time=982.22..982.22 rows=0 loops=1) -> Seq Scan on a_doc d (cost=0.00..6605.19 rows=110819 width=17) (actual time=73.46..787.87 rows=109788 loops=1) Total runtime: 63194.60 msec The field S.OP is INT. It is huge improvement when I sort by INT field, but I need to sort varchar fileds ! Is this normal for pg to work so slow with varchar or I can change the setup. Also I think the query time ( without sorting is big). regards and thanks in advance. scott.marlowe wrote: > On Thu, 14 Nov 2002, pginfo wrote: > > > Hi, > > > > Why is the sort part of my query getting so much time? > > > > I run a relative complex query and it gets about 50 sec. > > For sorting I need another 50 sec! > > > > Can I increase the sort memory for better performance? > > How meny memory is needet for the sort in pg. > > The same data readet in java and sorted cost 10 sec ! > > Increasing sort_mem can help, but often the problem is that your query > isn't optimal. If you'd like to post the explain analyze output of your > query, someone might have a hint on how to increase the efficiency of the > query. > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html From pgsql-performance-owner@postgresql.org Fri Nov 15 02:25:20 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8656F474E61 for ; Fri, 15 Nov 2002 02:25:19 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id B8D41474E42 for ; Fri, 15 Nov 2002 02:25:15 -0500 (EST) Received: (qmail 9526 invoked from network); 15 Nov 2002 09:07:30 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 15 Nov 2002 09:07:30 -0000 Message-ID: <3DD49441.3D2E545E@t1.unisoftbg.com> Date: Fri, 15 Nov 2002 07:29:21 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: "scott.marlowe" Cc: "pgsql-performance@postgresql.org" Subject: Re: Sort time References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/79 X-Sequence-Number: 237 Sorry, I can post a little more info: I run the same query ( and receive the same result), but in this time I started vmstat 2, to see the system state. The results: gibi=# explain analyze select S.IDS_NUM,S.OP,S.KOL,S.OTN_MED,S.CENA,S.DDS,S.KURS,S.TOT,S.DTO,S.PTO,S.DTON,MED.MNAME AS MEDNAME,N.MNAME AS NOMENNAME,N.NUM AS NNUM,S.PART,S.IZV,D.DATE_OP from A_DOC D , A_SKLAD S, A_NOMEN N ,A_MED MED WHERE S.FID=0 AND N.OSN_MED=MED.ID S AND S.IDS_NUM=N.IDS AND S.IDS_DOC=D.IDS ORDER BY S.IDS_NUM,S.PART,S.OP ; NOTICE: QUERY PLAN: Sort (cost=100922.53..100922.53 rows=22330 width=215) (actual time=109786.23..110231.74 rows=679743 loops=1) -> Hash Join (cost=9153.28..99309.52 rows=22330 width=215) (actual time=12572.01..56330.28 rows=679743 loops=1) -> Hash Join (cost=2271.05..91995.05 rows=30620 width=198) (actual time=7082.66..36482.57 rows=679743 loops=1) -> Seq Scan on a_sklad s (cost=0.00..84181.91 rows=687913 width=111) (actual time=6812.81..23085.36 rows=679743 loops=1) -> Hash (cost=2256.59..2256.59 rows=5784 width=87) (actual time=268.05..268.05 rows=0 loops=1) -> Hash Join (cost=2.52..2256.59 rows=5784 width=87) (actual time=125.25..255.48 rows=5784 loops=1) -> Seq Scan on a_nomen n (cost=0.00..2152.84 rows=5784 width=74) (actual time=120.63..216.93 rows=5784 loops=1) -> Hash (cost=2.42..2.42 rows=42 width=13) (actual time=0.57..0.57 rows=0 loops=1) -> Seq Scan on a_med med (cost=0.00..2.42 rows=42 width=13) (actual time=0.24..0.46 rows=42 loops=1) -> Hash (cost=6605.19..6605.19 rows=110819 width=17) (actual time=5485.90..5485.90 rows=0 loops=1) -> Seq Scan on a_doc d (cost=0.00..6605.19 rows=110819 width=17) (actual time=61.18..5282.99 rows=109788 loops=1) Total runtime: 110856.36 msec EXPLAIN vmstat 2 procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 0 0 0 32104 196932 77404 948256 0 0 30 12 24 12 6 1 27 0 1 1 32104 181792 77404 952416 0 0 2080 36 328 917 7 9 84 0 1 0 32104 170392 77404 959584 0 0 3584 16 533 1271 5 4 91 1 0 0 32104 162612 77404 965216 0 0 2816 0 514 1332 2 6 92 1 0 0 32104 146832 77404 979956 0 0 7370 18 631 1741 5 16 79 1 0 0 32104 129452 77404 997364 0 0 8704 0 719 1988 7 7 86 0 2 1 32104 116016 77404 1010632 0 0 6634 8 563 1495 6 20 74 1 0 0 32104 109844 77404 1013360 0 0 1364 2 228 584 31 24 45 1 0 0 32104 101244 77404 1013364 0 0 2 0 103 219 43 11 46 1 0 0 32104 84652 77404 1021328 0 0 3982 16 402 455 44 8 49 3 0 0 32104 72916 77404 1024404 0 0 1538 0 294 215 44 5 51 2 0 0 32104 63844 77404 1024404 0 0 0 10 103 222 47 3 50 1 0 0 32104 54600 77404 1024404 0 0 0 0 102 222 55 6 39 1 0 0 32104 45472 77404 1024404 0 0 0 0 102 220 45 6 50 1 0 0 32104 36060 77404 1024404 0 0 0 10 103 215 45 5 50 2 0 0 32104 26640 77404 1024404 0 0 0 0 106 218 43 7 50 2 0 0 32104 17440 77404 1024404 0 0 0 10 148 253 46 6 48 1 0 0 32104 10600 77404 1022004 0 0 0 0 102 215 42 8 50 1 0 0 32104 10604 77404 1013900 0 0 0 0 103 212 41 9 50 1 0 0 32104 10600 77404 1006452 0 0 0 26 106 225 38 12 50 2 0 0 32104 10600 77404 997412 0 0 0 0 102 213 48 3 50 procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 1 0 0 32104 10572 77428 988936 0 0 340 118 214 455 62 8 29 1 0 0 32104 10532 77432 979872 0 0 642 124 307 448 70 12 18 1 0 0 32104 10516 77432 970316 0 0 0 0 102 238 49 6 45 1 0 0 32104 10508 77432 960880 0 0 0 46 105 224 50 5 45 1 0 0 32104 10500 77432 951740 0 0 3398 34 174 445 47 9 44 1 0 1 32104 10112 77432 943588 0 0 8192 94 289 544 50 12 39 1 0 0 32104 10484 77432 937204 0 0 16896 0 386 1698 37 20 43 2 0 0 32104 10484 77432 930004 0 0 14080 0 345 1415 39 17 45 3 0 0 32104 27976 77432 925592 0 0 1844 16 136 329 46 6 49 2 0 0 32104 27924 77432 925592 0 0 0 0 104 220 50 0 49 2 0 0 32104 27756 77436 925592 0 0 0 8 103 222 51 2 47 1 0 0 32104 27756 77436 925592 0 0 0 0 102 222 54 1 45 1 0 0 32104 27756 77436 925592 0 0 0 0 102 220 55 0 45 1 0 0 32104 27424 77436 925592 0 0 0 24 104 224 54 1 45 1 0 0 32104 27424 77436 925592 0 0 0 0 102 218 55 0 45 3 0 0 32104 27424 77436 925592 0 0 0 8 103 221 55 0 45 1 0 0 32104 27424 77436 925592 0 0 0 0 103 222 55 0 45 1 0 0 32104 27456 77436 925592 0 0 0 0 104 222 55 0 45 1 0 0 32104 27456 77436 925592 0 0 0 8 104 222 55 0 45 2 0 0 32104 26792 77436 925592 0 0 0 0 102 218 55 1 44 2 0 0 32104 26792 77436 925592 0 0 0 8 103 222 55 0 44 procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 2 0 0 32104 26792 77436 925592 0 0 0 0 102 221 66 0 33 1 0 0 32104 26792 77436 925592 0 0 0 0 103 221 55 0 44 1 0 0 32104 26792 77436 925592 0 0 0 8 103 219 55 0 44 1 0 0 32104 26792 77436 925592 0 0 0 0 104 221 56 0 44 2 0 0 32104 26792 77436 925592 0 0 0 8 105 223 56 0 44 1 0 0 32104 26792 77436 925592 0 0 0 0 102 222 56 0 44 1 0 0 32104 26792 77436 925592 0 0 0 8 106 223 55 1 44 1 0 0 32104 26792 77436 925592 0 0 0 0 102 216 56 0 44 2 0 0 32104 26792 77436 925592 0 0 0 0 102 221 56 0 43 2 0 0 32104 26628 77436 925592 0 0 0 26 106 230 57 0 43 1 0 0 32104 26768 77440 925592 0 0 0 12 104 228 57 0 43 1 0 0 32104 26760 77448 925592 0 0 0 30 106 226 56 1 43 2 0 0 32104 26168 77448 925592 0 0 0 0 102 221 57 0 43 1 0 0 32104 28088 77448 925592 0 0 0 0 103 220 46 12 42 Can I tune better my linux box or pq to get faster execution? regards. scott.marlowe wrote: > On Thu, 14 Nov 2002, pginfo wrote: > > > Hi, > > > > Why is the sort part of my query getting so much time? > > > > I run a relative complex query and it gets about 50 sec. > > For sorting I need another 50 sec! > > > > Can I increase the sort memory for better performance? > > How meny memory is needet for the sort in pg. > > The same data readet in java and sorted cost 10 sec ! > > Increasing sort_mem can help, but often the problem is that your query > isn't optimal. If you'd like to post the explain analyze output of your > query, someone might have a hint on how to increase the efficiency of the > query. > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html From pgsql-general-owner@postgresql.org Fri Nov 15 02:09:56 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 64E1D475ADD for ; Fri, 15 Nov 2002 02:09:54 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 82682476D06 for ; Fri, 15 Nov 2002 02:09:52 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id gAF79px12392 for ; Fri, 15 Nov 2002 12:39:51 +0530 Received: from daithan (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id gAF79pv12387; Fri, 15 Nov 2002 12:39:51 +0530 From: "Shridhar Daithankar" To: , Date: Fri, 15 Nov 2002 12:40:25 +0530 MIME-Version: 1.0 Subject: Re: [PERFORM] Upgrade to dual processor machine? Reply-To: shridhar_daithankar@persistent.co.in Message-ID: <3DD4EB39.2426.1F2004@localhost> In-reply-to: <021d01c28c1d$85248ae0$7100a8c0@STEINKAMP> X-mailer: Pegasus Mail for Windows (v4.02) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/650 X-Sequence-Number: 33071 On 14 Nov 2002 at 21:36, Henrik Steffen wrote: > do you seriously think that I should vacuum frequently updated/inserted > tables every 120 seconds ? Its not about 120 seconds. Its about how many new and dead tuples your server is generating. Here is a quick summary insert: New tuple:vacuum analyse updates that statistics. update: Causes a dead tuple: Vacuum analyse marks dead tuple for reuse saving buffer space. delete: Causes a dead unusable tuple: Vacuum full is required to reclaim the space on the disk. Vacuum analyse is nonblocking and vacuum full is blocking. If you are generating 10 dead pages i.e. 80K of data in matter of minutes. vacuum is warranted for optimal performance.. > I have many UPDATEs and INSERTs on my log-statistics. For each http-request > there will be an INSERT into the logfile. And if certain customer pages > are downloaded there will even be an UPDATE in a customer-statistics table > causing a hits column to be set to hits+1... I didn't think this was a > dramatical change so far. OK.. Schedule a cron job that would vacuum analyse every 5/10 minutes.. And see if that gives you overall increase in throughput > Still sure to run VACUUM ANALYZE on these tables so often? IMO you should.. Also have a look at http://gborg.postgresql.org/project/pgavd/projdisplay.php. I have written it but I don't know anybody using it. If you use it, I can help you with any bugfixes required. I haven't done too much testing on it. It vacuums things based on traffic rather than time. So your database performance should ideally be maintained automatically.. Let me know if you need anything on this.. And use the CVS version please.. Bye Shridhar -- love, n.: When, if asked to choose between your lover and happiness, you'd skip happiness in a heartbeat. From pgsql-performance-owner@postgresql.org Fri Nov 15 03:47:44 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 46AD2475925 for ; Fri, 15 Nov 2002 03:47:39 -0500 (EST) Received: from aristote1.infomaniak.ch (aristote1.infomaniak.ch [212.23.249.238]) by postgresql.org (Postfix) with ESMTP id 5DEC7474E61 for ; Fri, 15 Nov 2002 03:47:37 -0500 (EST) Received: from cedserver (unverified [213.221.138.60]) by aristote1.infomaniak.ch (Rockliffe SMTPRA 4.5.6) with ESMTP id for ; Fri, 15 Nov 2002 09:46:21 +0100 From: =?US-ASCII?Q?Cedric_Dufour_=28Cogito_Ergo_Soft=29?= To: Subject: Re: [GENERAL] Upgrade to dual processor machine? Date: Fri, 15 Nov 2002 09:47:23 +0100 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 V6.00.2600.0000 In-Reply-To: <3DD4EB39.2426.1F2004@localhost> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/80 X-Sequence-Number: 238 Concerning the VACUUM issue: In order to test my DB perfomance, I made a script that populates it with test data (about a million rows to start with). The INSERT insert in one of the table triggers an UPDATE in 3 related tables, which mean row size is about 50 bytes. I found out that it was *essential* to VACUUM the updated tables every 500 INSERT or so to keep the performance from *heavily* dropping. That's about every 73kB updated or so. Now, I guess this memory "limit" is depending of PG's configuration and the OS characteritics. Is there any setting in the conf file that is related to this VACUUM and dead tuples issue ? Could the "free-space map" settings be related (I never understood what were these settings) ? BTW, thanx to all of you participating to this thread. Nice to have such a complete overlook on PG's performance tuning and related OS issues. Cedric D. > -----Original Message----- > From: pgsql-general-owner@postgresql.org > [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Shridhar > Daithankar > Sent: Friday, November 15, 2002 08:10 > To: pgsql-general@postgresql.org; pgsql-performance@postgresql.org > Subject: Re: [PERFORM] [GENERAL] Upgrade to dual processor machine? > > > On 14 Nov 2002 at 21:36, Henrik Steffen wrote: > > > do you seriously think that I should vacuum frequently updated/inserted > > tables every 120 seconds ? > > Its not about 120 seconds. Its about how many new and dead tuples > your server > is generating. > > Here is a quick summary > > insert: New tuple:vacuum analyse updates that statistics. > update: Causes a dead tuple: Vacuum analyse marks dead tuple for > reuse saving > buffer space. > delete: Causes a dead unusable tuple: Vacuum full is required to > reclaim the > space on the disk. > > Vacuum analyse is nonblocking and vacuum full is blocking. > > If you are generating 10 dead pages i.e. 80K of data in matter of > minutes. > vacuum is warranted for optimal performance.. > > > I have many UPDATEs and INSERTs on my log-statistics. For each > http-request > > there will be an INSERT into the logfile. And if certain customer pages > > are downloaded there will even be an UPDATE in a > customer-statistics table > > causing a hits column to be set to hits+1... I didn't think this was a > > dramatical change so far. > > OK.. Schedule a cron job that would vacuum analyse every 5/10 > minutes.. And see > if that gives you overall increase in throughput > > > Still sure to run VACUUM ANALYZE on these tables so often? > > IMO you should.. > > Also have a look at http://gborg.postgresql.org/project/pgavd/projdisplay.php. I have written it but I don't know anybody using it. If you use it, I can help you with any bugfixes required. I haven't done too much testing on it. It vacuums things based on traffic rather than time. So your database performance should ideally be maintained automatically.. Let me know if you need anything on this.. And use the CVS version please.. Bye Shridhar -- love, n.: When, if asked to choose between your lover and happiness, you'd skip happiness in a heartbeat. ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster From pgsql-performance-owner@postgresql.org Fri Nov 15 04:43:00 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 611D0476D53 for ; Fri, 15 Nov 2002 04:42:56 -0500 (EST) Received: from mailhub1.sghms.ac.uk (firewall.sghms.ac.uk [194.82.50.2]) by postgresql.org (Postfix) with ESMTP id 97BE5476CFA for ; Fri, 15 Nov 2002 04:42:42 -0500 (EST) Received: from [194.82.51.24] (helo=imail) by mailhub1.sghms.ac.uk with esmtp (Exim 4.05) id 18CczJ-0006Jt-00; Fri, 15 Nov 2002 09:42:09 +0000 Received: from [172.16.20.3] (mrc1-003.sghms.ac.uk [172.16.20.3]) by imail.sghms.ac.uk (iPlanet Messaging Server 5.1 HotFix 0.7 (built May 7 2002)) with ESMTPA id <0H5M00ABD2Z59W@imail.sghms.ac.uk>; Fri, 15 Nov 2002 09:42:41 +0000 (GMT) Date: Fri, 15 Nov 2002 09:42:51 +0000 From: Adam Witney In-reply-to: <1037309352.4724.81.camel@camel> To: Robert Treat Cc: pgsql-performance Message-id: MIME-version: 1.0 User-Agent: Microsoft-Entourage/10.1.0.2006 Subject: Re: swapping? Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT X-Spam-Status: No, hits=-100.8 required=5.7 tests=IN_REP_TO,QUOTED_EMAIL_TEXT,SPAM_PHRASE_05_08,USER_AGENT, USER_AGENT_ENTOURAGE,USER_IN_WHITELIST version=2.43 X-Spam-Level: X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/81 X-Sequence-Number: 239 Sorry, a little OT, but anybody know the equivalent command for Mac OSX? There doesn't seem to be a vmstat on my system Thanks adam > you can use vmstat to measure swap activity. check the man page for your > system. > > Robert Treat > > On Thu, 2002-11-14 at 10:53, Wei Weng wrote: >> How do you notice that if a system started swapping or not? >> >> Thanks >> >> On Thu, 2002-11-14 at 09:37, Shridhar Daithankar wrote: >>> On 14 Nov 2002 at 10:30, Wei Weng wrote: >>> >>>> The term had been mentioned often enough on this mailing list. Can >>>> someone enlighten me with some description or a URL where I can read on? >>>> And why is it important to postgresql database performace? >>> >>> When programs request more memory than available, OS 'swaps' some memory to >>> special area on disk and make the memory available. To programs, it gives >>> appearance that nearly infinite memory is available. >>> >>> Unfortunately disk are hell slower than RAM and hence swapping slows things >>> down as it takes much to swap in to disk and swap out of disk. Since OS does >>> not care which programs get swapped, it is possible that postgresql instance >>> can get swapped. That slows down effective memory access to knees.. >>> >>> That's why for good performance, a serve should never swap.. >>> >>> Bye >>> Shridhar >>> >>> -- >>> Peterson's Admonition: When you think you're going down for the third time >>> -- >>> just remember that you may have counted wrong. >>> >>> >>> ---------------------------(end of broadcast)--------------------------- >>> TIP 2: you can get off all lists at once with the unregister command >>> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >> -- >> Wei Weng >> Network Software Engineer >> KenCast Inc. >> >> >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From pgsql-general-owner@postgresql.org Fri Nov 15 05:11:55 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DAB6E475ADD for ; Fri, 15 Nov 2002 05:11:50 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 4487B474E61 for ; Fri, 15 Nov 2002 05:11:49 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.194) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Fri, 15 Nov 2002 11:11:33 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Fri, 15 Nov 2002 11:05:33 +0100 Message-ID: <01cd01c28c8f$4fbe9fe0$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "Doug McNaught" Cc: , References: <3DD3C819.3038.3E3812E@localhost><021d01c28c1d$85248ae0$7100a8c0@STEINKAMP> Subject: Re: [PERFORM] Upgrade to dual processor machine? Date: Fri, 15 Nov 2002 11:11:06 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/652 X-Sequence-Number: 33073 running 7.2.1 here -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "Doug McNaught" To: "Henrik Steffen" Cc: ; ; Sent: Thursday, November 14, 2002 9:50 PM Subject: Re: [PERFORM] [GENERAL] Upgrade to dual processor machine? > "Henrik Steffen" writes: > > > This is what it says in the manual and what I have been doing until today: > > > > "You should run VACUUM periodically to clean out expired rows. For tables that are heavily modified, it is useful to run VACUUM > > every night in an automated manner. For tables with few modifications, VACUUM should be run less frequently. The command exclusively > > locks the table while processing. " > > The "exclusive lock" part is no longer true as of 7.2.X--it is now > much cheaper to run VACUUM. What version were you running again? > > -Doug > From pgsql-performance-owner@postgresql.org Fri Nov 15 07:38:28 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8584C476258 for ; Fri, 15 Nov 2002 07:38:26 -0500 (EST) Received: from relay.sirio.it (relay.sirio.it [212.66.230.4]) by postgresql.org (Postfix) with ESMTP id 49B4B475D00 for ; Fri, 15 Nov 2002 07:38:25 -0500 (EST) Received: from protciv14.cmirl.arpal.it ([212.66.228.234]) by relay.sirio.it (8.12.2/8.12.2) with ESMTP id gAFCcMvd020141 for ; Fri, 15 Nov 2002 13:38:27 +0100 Received: by protciv14.cmirl.arpal.it (Postfix, from userid 1000) id DFDBF16D2A5; Fri, 15 Nov 2002 13:31:56 +0100 (CET) Date: Fri, 15 Nov 2002 13:31:56 +0100 From: Federico To: pgsql-performance@postgresql.org Subject: for/loop performance in plpgsql ? Message-ID: <20021115123156.GB785@protciv14.cmirl.arpal.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/83 X-Sequence-Number: 241 Hi all, i've a doubt about how FOR/LOOP works in plpgsql. It seems to me that the SELECT query executed in that way is much slower that the same being executed interactively in psql. In particular it seems that it doesn't make use of indexes. Does it have any sense or am i wrong/missing something ? Thanks all. Ciao From pgsql-performance-owner@postgresql.org Fri Nov 15 07:59:15 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 145C347592C for ; Fri, 15 Nov 2002 07:59:15 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 72367475925 for ; Fri, 15 Nov 2002 07:59:14 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18Cg45-0003aH-00 for ; Fri, 15 Nov 2002 07:59:17 -0500 Date: Fri, 15 Nov 2002 07:59:17 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: [GENERAL] Upgrade to dual processor machine? Message-ID: <20021115075917.A13519@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <3DD4EB39.2426.1F2004@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from cedric.dufour@cogito-ergo-soft.com on Fri, Nov 15, 2002 at 09:47:23AM +0100 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/84 X-Sequence-Number: 242 On Fri, Nov 15, 2002 at 09:47:23AM +0100, Cedric Dufour (Cogito Ergo Soft) wrote: > Is there any setting in the conf file that is related to this VACUUM and > dead tuples issue ? Could the "free-space map" settings be related (I never > understood what were these settings) ? Yes. That's what those settings are. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Nov 15 08:37:18 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6A9947592C for ; Fri, 15 Nov 2002 08:37:16 -0500 (EST) Received: from aristote1.infomaniak.ch (aristote1.infomaniak.ch [212.23.249.238]) by postgresql.org (Postfix) with ESMTP id BB1A8475925 for ; Fri, 15 Nov 2002 08:37:13 -0500 (EST) Received: from cedserver (unverified [213.221.138.60]) by aristote1.infomaniak.ch (Rockliffe SMTPRA 4.5.6) with ESMTP id for ; Fri, 15 Nov 2002 14:36:02 +0100 From: =?US-ASCII?Q?Cedric_Dufour_=28Cogito_Ergo_Soft=29?= To: Subject: Re: [GENERAL] Upgrade to dual processor machine? Date: Fri, 15 Nov 2002 14:37:01 +0100 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 V6.00.2600.0000 In-Reply-To: <20021115075917.A13519@mail.libertyrms.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/85 X-Sequence-Number: 243 > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Andrew > Sullivan > Sent: Friday, November 15, 2002 13:59 > To: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] [GENERAL] Upgrade to dual processor machine? > > > On Fri, Nov 15, 2002 at 09:47:23AM +0100, Cedric Dufour (Cogito > Ergo Soft) wrote: > > Is there any setting in the conf file that is related to this VACUUM and > > dead tuples issue ? Could the "free-space map" settings be > related (I never > > understood what were these settings) ? > > Yes. That's what those settings are. > The 'Runtime configuration / General operation' part of the doc is quite short on the subject. Is there any other places to look for more details on this FSM ? What policy should drive changes to the FSM settings ? I guess allowing larger FSM values might improve UPDATE performance (require VACUUM less often) but consume RAM that may be more useful elsewhere. Am I right ? Has any one made experience on that matter and what conclusion were drawn ? In other words, shall we try to alter this FSM settings for better perfomance or is it better to stick to a regular (shortly timed) VACUUM scenario ? Cedric From pgsql-performance-owner@postgresql.org Fri Nov 15 08:45:10 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 81F29475E41 for ; Fri, 15 Nov 2002 08:45:08 -0500 (EST) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by postgresql.org (Postfix) with ESMTP id C093D475AD4 for ; Fri, 15 Nov 2002 08:45:07 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 18CgmO-0005fI-0W; Fri, 15 Nov 2002 13:45:05 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 26FDB17B4B; Fri, 15 Nov 2002 13:37:29 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 86A1316F59; Fri, 15 Nov 2002 13:37:28 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton To: Federico , pgsql-performance@postgresql.org Subject: Re: for/loop performance in plpgsql ? Date: Fri, 15 Nov 2002 13:37:25 +0000 User-Agent: KMail/1.4.3 References: <20021115123156.GB785@protciv14.cmirl.arpal.it> In-Reply-To: <20021115123156.GB785@protciv14.cmirl.arpal.it> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211151337.25980.richardh@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/86 X-Sequence-Number: 244 On Friday 15 Nov 2002 12:31 pm, Federico wrote: > Hi all, > > i've a doubt about how FOR/LOOP works in plpgsql. > > It seems to me that the SELECT query executed in that way is much slower > that the same being executed interactively in psql. > > In particular it seems that it doesn't make use of indexes. > > Does it have any sense or am i wrong/missing something ? Well - the query might well be pre-parsed which means it wouldn't notice an= y=20 updated stats. Can you provide an example of your code? --=20 Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Fri Nov 15 09:34:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7307C474E5C for ; Fri, 15 Nov 2002 09:34:56 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id F17C2474E53 for ; Fri, 15 Nov 2002 09:34:55 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18ChYh-0005Cq-00 for ; Fri, 15 Nov 2002 09:34:59 -0500 Date: Fri, 15 Nov 2002 09:34:59 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: [GENERAL] Upgrade to dual processor machine? Message-ID: <20021115093459.C19503@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20021115075917.A13519@mail.libertyrms.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from cedric.dufour@cogito-ergo-soft.com on Fri, Nov 15, 2002 at 02:37:01PM +0100 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/87 X-Sequence-Number: 245 On Fri, Nov 15, 2002 at 02:37:01PM +0100, Cedric Dufour (Cogito Ergo Soft) wrote: > The 'Runtime configuration / General operation' part of the doc is quite > short on the subject. I'm afriad the setting was new in 7.2, and people don't have a great deal of experience with it. So it's difficult to ake recommendations. > Is there any other places to look for more details on this FSM ? What policy > should drive changes to the FSM settings ? If your tables change a lot between VACUUM, the FSM may fill up. the problem is that the system is only to keep "in mind" so much information about how many pages can be freed. This affects the re-use of disk space. > I guess allowing larger FSM values might improve UPDATE performance (require > VACUUM less often) but consume RAM that may be more useful elsewhere. Am I > right ? Not really. Your better bet is to perform VACUUM often; but if you don't do that, then VACUUM will be able to re-claim more space in the table if your FSM is larger. Is that clear-ish? You can estimate the correct value, apparently, by doing some calculations about disk space and turnover. I think it requires some cycles where you do VACUUM FULL. There was a discussion on the -general list about it some months ago, IIRC. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Nov 15 11:08:59 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D07D74770E1 for ; Fri, 15 Nov 2002 11:08:46 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id 3E2CB476E7A for ; Fri, 15 Nov 2002 10:41:52 -0500 (EST) Received: (qmail 24426 invoked from network); 15 Nov 2002 17:24:01 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 15 Nov 2002 17:24:01 -0000 Message-ID: <3DD508A1.8DA09511@t1.unisoftbg.com> Date: Fri, 15 Nov 2002 15:45:53 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Tom Lane Cc: "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <3DD48F6A.D80604EC@t1.unisoftbg.com> <27564.1037374273@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/89 X-Sequence-Number: 247 Hi Tom, I use unicode for my db, but the locale is US! The unicode is only for non english varchar and I do not make any comparation or sorts or joins based on non english fields ( all this is made in the client part of the system). What locale will be fast? Have you any info about the speed in the faster locale and in INT? regards. Tom Lane wrote: > pginfo writes: > > It is huge improvement when I sort by INT field, but I need to sort varchar > > fileds ! > > What locale are you using? strcoll() comparisons can be awfully slow in > some locales. > > regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 15 11:46:33 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CA988477092 for ; Fri, 15 Nov 2002 11:33:03 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id D9E484770C8 for ; Fri, 15 Nov 2002 11:06:29 -0500 (EST) Received: (qmail 25184 invoked from network); 15 Nov 2002 17:48:39 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 15 Nov 2002 17:48:39 -0000 Message-ID: <3DD50E67.AC3A4DC8@t1.unisoftbg.com> Date: Fri, 15 Nov 2002 16:10:31 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Tom Lane Cc: "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <3DD48F6A.D80604EC@t1.unisoftbg.com> <27564.1037374273@sss.pgh.pa.us> <3DD508A1.8DA09511@t1.unisoftbg.com> <27817.1037375957@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/92 X-Sequence-Number: 250 Ok, Thanks! Have any one anoder idea? regards. Tom Lane wrote: > pginfo writes: > > What locale will be fast? > > C locale (a/k/a POSIX locale) should be quick. Not sure about anything > else. > > regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 15 10:43:37 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9986F476D40 for ; Fri, 15 Nov 2002 10:39:21 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id E185B476D74 for ; Fri, 15 Nov 2002 10:31:18 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAFFVEhR027565; Fri, 15 Nov 2002 10:31:15 -0500 (EST) To: pginfo Cc: "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-reply-to: <3DD48F6A.D80604EC@t1.unisoftbg.com> References: <3DD48F6A.D80604EC@t1.unisoftbg.com> Comments: In-reply-to pginfo message dated "Fri, 15 Nov 2002 07:08:42 +0100" Date: Fri, 15 Nov 2002 10:31:13 -0500 Message-ID: <27564.1037374273@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/88 X-Sequence-Number: 246 pginfo writes: > It is huge improvement when I sort by INT field, but I need to sort varchar > fileds ! What locale are you using? strcoll() comparisons can be awfully slow in some locales. regards, tom lane From pgsql-general-owner@postgresql.org Fri Nov 15 11:36:38 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E1F4E476CDB; Fri, 15 Nov 2002 11:25:04 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id B1838476D4B; Fri, 15 Nov 2002 10:46:52 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 4B963D68B; Fri, 15 Nov 2002 07:46:47 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 410425C0B; Fri, 15 Nov 2002 07:46:47 -0800 (PST) Date: Fri, 15 Nov 2002 07:46:47 -0800 (PST) From: Stephan Szabo To: Shridhar Daithankar Cc: , Subject: Re: [PERFORM] Upgrade to dual processor machine? In-Reply-To: <3DD4EB39.2426.1F2004@localhost> Message-ID: <20021115074333.H9290-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/674 X-Sequence-Number: 33095 On Fri, 15 Nov 2002, Shridhar Daithankar wrote: > On 14 Nov 2002 at 21:36, Henrik Steffen wrote: > > > do you seriously think that I should vacuum frequently updated/inserted > > tables every 120 seconds ? > > Its not about 120 seconds. Its about how many new and dead tuples your server > is generating. > > Here is a quick summary > > insert: New tuple:vacuum analyse updates that statistics. > update: Causes a dead tuple: Vacuum analyse marks dead tuple for reuse saving > buffer space. > delete: Causes a dead unusable tuple: Vacuum full is required to reclaim the > space on the disk. AFAIK, the delete line above is wrong. Deleted heap space should be able to be reclaimed with normal vacuums within the limitations of the free space map, etc... From pgsql-performance-owner@postgresql.org Fri Nov 15 11:46:16 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 27A61476B77 for ; Fri, 15 Nov 2002 11:29:54 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id DFE38476395 for ; Fri, 15 Nov 2002 10:59:19 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAFFxIhR027818; Fri, 15 Nov 2002 10:59:18 -0500 (EST) To: pginfo Cc: "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-reply-to: <3DD508A1.8DA09511@t1.unisoftbg.com> References: <3DD48F6A.D80604EC@t1.unisoftbg.com> <27564.1037374273@sss.pgh.pa.us> <3DD508A1.8DA09511@t1.unisoftbg.com> Comments: In-reply-to pginfo message dated "Fri, 15 Nov 2002 15:45:53 +0100" Date: Fri, 15 Nov 2002 10:59:17 -0500 Message-ID: <27817.1037375957@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/91 X-Sequence-Number: 249 pginfo writes: > What locale will be fast? C locale (a/k/a POSIX locale) should be quick. Not sure about anything else. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 15 12:50:38 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 69C9E477398 for ; Fri, 15 Nov 2002 12:44:55 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id 3DEA147E946 for ; Fri, 15 Nov 2002 12:18:17 -0500 (EST) Received: (qmail 27496 invoked from network); 15 Nov 2002 19:00:37 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 15 Nov 2002 19:00:37 -0000 Message-ID: <3DD51F44.B4A68B50@t1.unisoftbg.com> Date: Fri, 15 Nov 2002 17:22:28 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Josh Berkus Cc: "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/93 X-Sequence-Number: 251 Hi, Yes I have indexes on all this fields. Also I vacuumed and that is the result after it. Actualy I do not see what bad in query execution. The problem is in sort time! regards. Josh Berkus wrote: > Pginfo, > > > Sort (cost=100922.53..100922.53 rows=22330 width=215) (actual > > time=109786.23..110231.74 rows=679743 loops=1) > > -> Hash Join (cost=9153.28..99309.52 rows=22330 width=215) > > (actual > > time=12572.01..56330.28 rows=679743 loops=1) > > -> Hash Join (cost=2271.05..91995.05 rows=30620 width=198) > > (actual > > time=7082.66..36482.57 rows=679743 loops=1) > > -> Seq Scan on a_sklad s (cost=0.00..84181.91 > > rows=687913 > > width=111) (actual time=6812.81..23085.36 rows=679743 loops=1) > > -> Hash (cost=2256.59..2256.59 rows=5784 width=87) > > (actual > > time=268.05..268.05 rows=0 loops=1) > > -> Hash Join (cost=2.52..2256.59 rows=5784 > > width=87) > > (actual time=125.25..255.48 rows=5784 loops=1) > > -> Seq Scan on a_nomen n > > (cost=0.00..2152.84 > > rows=5784 width=74) (actual time=120.63..216.93 rows=5784 loops=1) > > -> Hash (cost=2.42..2.42 rows=42 > > width=13) > > (actual time=0.57..0.57 rows=0 loops=1) > > -> Seq Scan on a_med med > > (cost=0.00..2.42 > > rows=42 width=13) (actual time=0.24..0.46 rows=42 loops=1) > > -> Hash (cost=6605.19..6605.19 rows=110819 width=17) > > (actual > > time=5485.90..5485.90 rows=0 loops=1) > > -> Seq Scan on a_doc d (cost=0.00..6605.19 > > rows=110819 > > width=17) (actual time=61.18..5282.99 rows=109788 loops=1) > > Total runtime: 110856.36 msec > > Pardon me if we've been over this ground, but that's a *lot* of seq > scans for this query. It seems odd that there's not *one* index scan. > > Have you tried indexing *all* of the following fields? > S.FID > N.OSN_MED > S.IDS_NUM > N.IDS > S.IDS_DOC > D.IDS > (check to avoid duplicate indexes. don't forget to VACUUM ANALYZE > after you index) > > -Josh Berkus From pgsql-performance-owner@postgresql.org Fri Nov 15 12:55:08 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3215E4774C0 for ; Fri, 15 Nov 2002 12:52:25 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 93CD24766A1 for ; Fri, 15 Nov 2002 12:09:09 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1827471; Fri, 15 Nov 2002 09:12:55 -0800 From: "Josh Berkus" Subject: Re: Sort time To: pginfo , "scott.marlowe" Cc: "pgsql-performance@postgresql.org" X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Fri, 15 Nov 2002 09:12:55 -0800 Message-ID: In-Reply-To: <3DD49441.3D2E545E@t1.unisoftbg.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/95 X-Sequence-Number: 253 Pginfo, > Sort (cost=100922.53..100922.53 rows=22330 width=215) (actual > time=109786.23..110231.74 rows=679743 loops=1) > -> Hash Join (cost=9153.28..99309.52 rows=22330 width=215) > (actual > time=12572.01..56330.28 rows=679743 loops=1) > -> Hash Join (cost=2271.05..91995.05 rows=30620 width=198) > (actual > time=7082.66..36482.57 rows=679743 loops=1) > -> Seq Scan on a_sklad s (cost=0.00..84181.91 > rows=687913 > width=111) (actual time=6812.81..23085.36 rows=679743 loops=1) > -> Hash (cost=2256.59..2256.59 rows=5784 width=87) > (actual > time=268.05..268.05 rows=0 loops=1) > -> Hash Join (cost=2.52..2256.59 rows=5784 > width=87) > (actual time=125.25..255.48 rows=5784 loops=1) > -> Seq Scan on a_nomen n > (cost=0.00..2152.84 > rows=5784 width=74) (actual time=120.63..216.93 rows=5784 loops=1) > -> Hash (cost=2.42..2.42 rows=42 > width=13) > (actual time=0.57..0.57 rows=0 loops=1) > -> Seq Scan on a_med med > (cost=0.00..2.42 > rows=42 width=13) (actual time=0.24..0.46 rows=42 loops=1) > -> Hash (cost=6605.19..6605.19 rows=110819 width=17) > (actual > time=5485.90..5485.90 rows=0 loops=1) > -> Seq Scan on a_doc d (cost=0.00..6605.19 > rows=110819 > width=17) (actual time=61.18..5282.99 rows=109788 loops=1) > Total runtime: 110856.36 msec Pardon me if we've been over this ground, but that's a *lot* of seq scans for this query. It seems odd that there's not *one* index scan. Have you tried indexing *all* of the following fields? S.FID N.OSN_MED S.IDS_NUM N.IDS S.IDS_DOC D.IDS (check to avoid duplicate indexes. don't forget to VACUUM ANALYZE after you index) -Josh Berkus From pgsql-performance-owner@postgresql.org Fri Nov 15 12:52:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B0811477803 for ; Fri, 15 Nov 2002 12:30:54 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id B8ED647E97A for ; Fri, 15 Nov 2002 12:18:48 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1827493; Fri, 15 Nov 2002 09:22:32 -0800 From: "Josh Berkus" Subject: Re: Upgrade to dual processor machine? To: "Henrik Steffen" Cc: pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Fri, 15 Nov 2002 09:22:32 -0800 Message-ID: In-Reply-To: <002701c28ca4$c48d1260$7100a8c0@STEINKAMP> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/94 X-Sequence-Number: 252 Henrik, > I tested it, and it doesn't seem to change significantly > > Now I am trying the more regular vacuuming, too ... every 5 minutes > the most important tables are vacuumed... this, too, gives a bit > more performance. Disregard that last message. I just caught up with the list. If you're VACUUMing constantly, then another setting you may want to tweak is vacuum_mem. Like the other memory settings, you're looking for the "sweet spot" where vacuum_mem is high enough that your vacuums are over quickly, but low enough that it doesn't take away memory from other processes and slow them down. It may be that you don't need to change the value at all. I would, however, try increasing and decreasing my vacuum_mem to find the level at which the frequent vacuums have the greatest benefit. -Josh Berkus From pgsql-performance-owner@postgresql.org Fri Nov 15 12:57:43 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D573A477679 for ; Fri, 15 Nov 2002 12:56:47 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 70C1D479E27; Fri, 15 Nov 2002 12:30:03 -0500 (EST) Received: by davinci.ethosmedia.com (CommuniGate Pro PIPE 3.5.9) with PIPE id 1827509; Fri, 15 Nov 2002 09:33:50 -0800 X-Spam-Status: Scanner Called Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1827511; Fri, 15 Nov 2002 09:33:47 -0800 From: "Josh Berkus" Subject: Re: Sort time To: pginfo , Josh Berkus Cc: "scott.marlowe" , "pgsql-performance@postgresql.org" X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Fri, 15 Nov 2002 09:33:47 -0800 Message-ID: In-Reply-To: <3DD51F44.B4A68B50@t1.unisoftbg.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Spam-Status: No, hits=-3.8 required=6.0 tests=IN_REP_TO, TO_LOCALPART_EQ_REAL, AWL version=2.20 X-Spam-Level: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/96 X-Sequence-Number: 254 Pginfo, > Yes I have indexes on all this fields. > Also I vacuumed and that is the result after it. > Actualy I do not see what bad in query execution. The problem is in > sort > time! Hmmm... I don't understand. The way I read the EXPLAIN, the sort is only taking a few seconds. Am I missing something, here? And that's "VACUUM FULL ANALYZE", not just "VACUUM", yes? If all of the above has been tried, what happens to the query when you set enable_seqscan=off? -Josh Berkus From pgsql-performance-owner@postgresql.org Fri Nov 15 14:24:21 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8715B475EF0 for ; Fri, 15 Nov 2002 14:24:19 -0500 (EST) Received: from jester.senspire.com (nat.inquent.com [216.6.14.45]) by postgresql.org (Postfix) with ESMTP id 3BA68475DF2 for ; Fri, 15 Nov 2002 14:24:18 -0500 (EST) Received: from jester.senspire.com (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAFJOx5i031904 for ; Fri, 15 Nov 2002 14:25:00 -0500 (EST) (envelope-from rbt@rbt.ca) Received: (from rbt@localhost) by jester.senspire.com (8.12.6/8.12.6/Submit) id gAFImN3L019055; Fri, 15 Nov 2002 13:48:23 -0500 (EST) X-Authentication-Warning: jester.senspire.com: rbt set sender to rbt@rbt.ca using -f Subject: Re: Sort time From: Rod Taylor To: Josh Berkus Cc: pginfo , "scott.marlowe" , "pgsql-performance@postgresql.org" In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1037386103.14810.82.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 15 Nov 2002 13:48:23 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/98 X-Sequence-Number: 256 On Fri, 2002-11-15 at 12:33, Josh Berkus wrote: > Pginfo, > > > Yes I have indexes on all this fields. > > Also I vacuumed and that is the result after it. > > Actualy I do not see what bad in query execution. The problem is in > > sort > > time! > > Hmmm... I don't understand. The way I read the EXPLAIN, the sort is > only taking a few seconds. Am I missing something, here? The estimated cost had the sort at a few seconds, but the actual times show it is taking 50% of the total query time. The big problem is he's sorting by a varchar() which isn't overly quick no matter what locale. Integers are nice and quick (s.OP is an int, which shows this). If IDS_NUM is a number, he could try casting it to an int8, but without data examples I couldn't say. -- Rod Taylor From pgsql-performance-owner@postgresql.org Fri Nov 15 13:53:37 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 80EE0475925 for ; Fri, 15 Nov 2002 13:53:35 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 38C6D476281 for ; Fri, 15 Nov 2002 13:53:34 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1827704; Fri, 15 Nov 2002 10:57:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Henrik Steffen" Subject: Re: [GENERAL] Upgrade to dual processor machine? Date: Fri, 15 Nov 2002 10:55:11 -0800 X-Mailer: KMail [version 1.4] Cc: References: <001501c28bc0$2a339340$7100a8c0@STEINKAMP> In-Reply-To: <001501c28bc0$2a339340$7100a8c0@STEINKAMP> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211151055.11245.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/97 X-Sequence-Number: 255 Henrik, > > Well, now it gets more complicated. You need to determine: > > A) The median processing time of each of those requests. > > B) The amount of Sort_mem actually required for each request. >=20 > as I am dealing with postgres for a webserver the median processing > time of each request has got to be <1 sec. how can i measure > the amount of sort_mem needed? Through experimentation, mostly. SInce you are in a high-volume, small-que= ry=20 environment, I would try *lowering* your sort mem to see if that has an=20 adverse impact on queries. A good quick test would be to cut your sort_me= m=20 in half, and then run an EXPLAIN on the query from which you expect the=20 largest result set, and see if the SORT time on the query has been increase= d. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 15 14:25:52 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 176C1476000 for ; Fri, 15 Nov 2002 14:25:52 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 71655475F37 for ; Fri, 15 Nov 2002 14:25:51 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1827783; Fri, 15 Nov 2002 11:29:33 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Rod Taylor Subject: Re: Sort time Date: Fri, 15 Nov 2002 11:27:29 -0800 X-Mailer: KMail [version 1.4] Cc: pginfo , "scott.marlowe" , "pgsql-performance@postgresql.org" References: <1037386103.14810.82.camel@jester> In-Reply-To: <1037386103.14810.82.camel@jester> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211151127.29405.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/99 X-Sequence-Number: 257 Rod, > The estimated cost had the sort at a few seconds, but the actual times > show it is taking 50% of the total query time. D'oh! I was, of course, subtracting the estimated from the actual time.= =20=20 Oops. >=20 > The big problem is he's sorting by a varchar() which isn't overly quick > no matter what locale. Integers are nice and quick (s.OP is an int, > which shows this). >=20 > If IDS_NUM is a number, he could try casting it to an int8, but without > data examples I couldn't say. Hmmm ... how big *is* that varchar field? 8 characters gives us about 6mb = for=20 the column. Of course, if it's a 128-char global unque id, that;s a bit=20 larger. --=20 -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 15 15:54:20 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 36387475C60 for ; Fri, 15 Nov 2002 15:54:19 -0500 (EST) Received: from jester.senspire.com (nat.inquent.com [216.6.14.45]) by postgresql.org (Postfix) with ESMTP id 505E0475AE5 for ; Fri, 15 Nov 2002 15:54:18 -0500 (EST) Received: from jester.senspire.com (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAFKsx5c062613 for ; Fri, 15 Nov 2002 15:54:59 -0500 (EST) (envelope-from rbt@rbt.ca) Received: (from rbt@localhost) by jester.senspire.com (8.12.6/8.12.6/Submit) id gAFJSdk6038321; Fri, 15 Nov 2002 14:28:39 -0500 (EST) X-Authentication-Warning: jester.senspire.com: rbt set sender to rbt@rbt.ca using -f Subject: Re: Sort time From: Rod Taylor To: josh@agliodbs.com Cc: pginfo , "scott.marlowe" , "pgsql-performance@postgresql.org" In-Reply-To: <200211151127.29405.josh@agliodbs.com> References: <1037386103.14810.82.camel@jester> <200211151127.29405.josh@agliodbs.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1037388518.14810.118.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 15 Nov 2002 14:28:39 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/102 X-Sequence-Number: 260 On Fri, 2002-11-15 at 14:27, Josh Berkus wrote: > > The big problem is he's sorting by a varchar() which isn't overly quick > > no matter what locale. Integers are nice and quick (s.OP is an int, > > which shows this). > > > > If IDS_NUM is a number, he could try casting it to an int8, but without > > data examples I couldn't say. > > Hmmm ... how big *is* that varchar field? 8 characters gives us about 6mb for > the column. Of course, if it's a 128-char global unque id, that;s a bit > larger. 20 characters long in the Unicode locale -- which is 40 bytes? -- Rod Taylor From pgsql-performance-owner@postgresql.org Fri Nov 15 15:08:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 64F3F475AE5 for ; Fri, 15 Nov 2002 15:08:55 -0500 (EST) Received: from jester.senspire.com (nat.inquent.com [216.6.14.45]) by postgresql.org (Postfix) with ESMTP id 8C309475B84 for ; Fri, 15 Nov 2002 15:08:53 -0500 (EST) Received: from jester.senspire.com (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAFK9Y5c055850; Fri, 15 Nov 2002 15:09:35 -0500 (EST) (envelope-from rbt@rbt.ca) Received: (from rbt@localhost) by jester.senspire.com (8.12.6/8.12.6/Submit) id gAFK9WPX055849; Fri, 15 Nov 2002 15:09:32 -0500 (EST) X-Authentication-Warning: jester.senspire.com: rbt set sender to rbt@rbt.ca using -f Subject: Re: can this query be made to run faster? From: Rod Taylor To: "Peter T. Brown" Cc: pgsql-performance@postgresql.org In-Reply-To: <1037393480.2473.44.camel@localhost.localdomain> References: <1037393480.2473.44.camel@localhost.localdomain> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1037390971.14810.122.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 15 Nov 2002 15:09:31 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/101 X-Sequence-Number: 259 Please send us an 'EXPLAIN ANALYZE' of the query. Thanks On Fri, 2002-11-15 at 15:51, Peter T. Brown wrote: > Hi-- > > I have this rather long complex query that takes really long to complete > (please see below). It seems like I ought to improve the speed somehow. > I don't understand, for example, what the query planner is doing when it > says "Hash" and why this appears to take so long. And since I have a key > for Visitor.ID, I don't understand why its doing a sequential scan on > that table... > > Any advice would be greatly appreciated! > > > Thanks > > Peter > > > > > EXPLAIN SELECT > "Visitor"."Created", > "Visitor"."Updated", > "Tidbit"."ID", > "ProgramEvent"."ID", > "Visitor"."Email", > "Interest"."ID", > "VisitorInternetDeviceAssoc"."ID", > "Referral"."ID" > > FROM "VisitorExtra" > > LEFT OUTER JOIN Tidbit" ON > "VisitorExtra"."ID"="Tidbit"."VisitorID" > > LEFT OUTER JOIN "ProgramEvent" ON > "VisitorExtra"."ID"="ProgramEvent"."VisitorID" > > LEFT OUTER JOIN "Interest" ON > "VisitorExtra"."ID"="Interest"."VisitorID" > > LEFT OUTER JOIN "VisitorInternetDeviceAssoc" ON > "VisitorExtra"."ID"="VisitorInternetDeviceAssoc"."VisitorID" > > LEFT OUTER JOIN "Referral" ON > "VisitorExtra"."ID"="Referral"."FromVisitorID","Visitor" > > WHERE "VisitorExtra"."ID"="Visitor"."ID" AND > "VisitorExtra"."ID"= 325903; > > > > > QUERY PLAN: > > Hash Join (cost=14584.37..59037.79 rows=57747 width=76) > -> Merge Join (cost=0.00..36732.65 rows=57747 width=44) > -> Merge Join (cost=0.00..29178.16 rows=10681 width=36) > -> Nested Loop (cost=0.00..10505.74 rows=6674 width=28) > -> Nested Loop (cost=0.00..435.29 rows=177 > width=20) > -> Nested Loop (cost=0.00..15.70 rows=55 > width=12) > -> Index Scan using VisitorExtra_pkey > on VisitorExtra (cost=0.00..3.01 rows=1 width=4) > -> Index Scan using > Tidbit_VisitorID_key on Tidbit (cost=0.00..12.67 rows=2 > width=8) > -> Index Scan using > ProgramEvent_VisitorID_key on ProgramEvent (cost=0.00..7.57 > rows=2 width=8) > -> Index Scan using Interest_VisitorID_key on > Interest (cost=0.00..56.66 rows=19 width=8) > -> Index Scan using VisitorInternetDeviceAssoc_Visi on > VisitorInternetDeviceAssoc (cost=0.00..16402.90 rows=174887 > width=8) > -> Index Scan using Referral_FromVisitorID_key on Referral > (cost=0.00..6323.41 rows=87806 width=8) > -> Hash (cost=6061.79..6061.79 rows=317379 width=32) > -> Seq Scan on Visitor (cost=0.00..6061.79 rows=317379 > width=32) -- Rod Taylor From pgsql-performance-owner@postgresql.org Fri Nov 15 14:53:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5A85E475AE5 for ; Fri, 15 Nov 2002 14:53:56 -0500 (EST) Received: from mail.memeticsystems.com (flywheel.memeticsystems.com [64.85.80.85]) by postgresql.org (Postfix) with SMTP id 9A6FC4759BD for ; Fri, 15 Nov 2002 14:53:55 -0500 (EST) Received: (qmail 6827 invoked from network); 15 Nov 2002 19:53:56 -0000 Received: from unknown (HELO ?10.0.0.102?) (63.249.24.21) by 0 with SMTP; 15 Nov 2002 19:53:56 -0000 Subject: can this query be made to run faster? From: "Peter T. Brown" To: pgsql-performance@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 15 Nov 2002 12:51:18 -0800 Message-Id: <1037393480.2473.44.camel@localhost.localdomain> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/100 X-Sequence-Number: 258 Hi-- I have this rather long complex query that takes really long to complete (please see below). It seems like I ought to improve the speed somehow. I don't understand, for example, what the query planner is doing when it says "Hash" and why this appears to take so long. And since I have a key for Visitor.ID, I don't understand why its doing a sequential scan on that table... Any advice would be greatly appreciated! Thanks Peter EXPLAIN SELECT "Visitor"."Created", "Visitor"."Updated", "Tidbit"."ID", "ProgramEvent"."ID", "Visitor"."Email", "Interest"."ID", "VisitorInternetDeviceAssoc"."ID", "Referral"."ID" FROM "VisitorExtra" LEFT OUTER JOIN Tidbit" ON "VisitorExtra"."ID"="Tidbit"."VisitorID" LEFT OUTER JOIN "ProgramEvent" ON "VisitorExtra"."ID"="ProgramEvent"."VisitorID" LEFT OUTER JOIN "Interest" ON "VisitorExtra"."ID"="Interest"."VisitorID" LEFT OUTER JOIN "VisitorInternetDeviceAssoc" ON "VisitorExtra"."ID"="VisitorInternetDeviceAssoc"."VisitorID" LEFT OUTER JOIN "Referral" ON "VisitorExtra"."ID"="Referral"."FromVisitorID","Visitor" WHERE "VisitorExtra"."ID"="Visitor"."ID" AND "VisitorExtra"."ID"= 325903; QUERY PLAN: Hash Join (cost=14584.37..59037.79 rows=57747 width=76) -> Merge Join (cost=0.00..36732.65 rows=57747 width=44) -> Merge Join (cost=0.00..29178.16 rows=10681 width=36) -> Nested Loop (cost=0.00..10505.74 rows=6674 width=28) -> Nested Loop (cost=0.00..435.29 rows=177 width=20) -> Nested Loop (cost=0.00..15.70 rows=55 width=12) -> Index Scan using VisitorExtra_pkey on VisitorExtra (cost=0.00..3.01 rows=1 width=4) -> Index Scan using Tidbit_VisitorID_key on Tidbit (cost=0.00..12.67 rows=2 width=8) -> Index Scan using ProgramEvent_VisitorID_key on ProgramEvent (cost=0.00..7.57 rows=2 width=8) -> Index Scan using Interest_VisitorID_key on Interest (cost=0.00..56.66 rows=19 width=8) -> Index Scan using VisitorInternetDeviceAssoc_Visi on VisitorInternetDeviceAssoc (cost=0.00..16402.90 rows=174887 width=8) -> Index Scan using Referral_FromVisitorID_key on Referral (cost=0.00..6323.41 rows=87806 width=8) -> Hash (cost=6061.79..6061.79 rows=317379 width=32) -> Seq Scan on Visitor (cost=0.00..6061.79 rows=317379 width=32) -- Peter T. Brown Director Of Technology Memetic Systems, Inc. "Translating Customer Data Into Marketing Action." 206.335.2927 http://www.memeticsystems.com/ From pgsql-performance-owner@postgresql.org Fri Nov 15 16:16:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9AA61475AE5 for ; Fri, 15 Nov 2002 16:16:56 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 5E6A0475458 for ; Fri, 15 Nov 2002 16:16:54 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1828001; Fri, 15 Nov 2002 13:20:37 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Rod Taylor Subject: Re: Sort time Date: Fri, 15 Nov 2002 13:18:33 -0800 X-Mailer: KMail [version 1.4] Cc: pginfo , "scott.marlowe" , "pgsql-performance@postgresql.org" References: <200211151127.29405.josh@agliodbs.com> <1037388518.14810.118.camel@jester> In-Reply-To: <1037388518.14810.118.camel@jester> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211151318.33245.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/103 X-Sequence-Number: 261 Rod, > > Hmmm ... how big *is* that varchar field? 8 characters gives us about = 6mb=20 for=20 > > the column. Of course, if it's a 128-char global unque id, that;s a bi= t=20 > > larger. >=20 > 20 characters long in the Unicode locale -- which is 40 bytes? Well, 40+, probably about 43. Should be about 29mb, yes? Here's a question: is the total size of the column a good indicator of the= =20 sort_mem required? Or does the rowsize affect it somehow? --=20 -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 15 17:39:46 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C18C34759BD for ; Fri, 15 Nov 2002 17:39:44 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 9DC364758C9 for ; Fri, 15 Nov 2002 17:39:43 -0500 (EST) Received: from jester.senspire.com (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAFMeLKE062871; Fri, 15 Nov 2002 17:40:21 -0500 (EST) (envelope-from rbt@rbt.ca) Received: (from rbt@localhost) by jester.senspire.com (8.12.6/8.12.6/Submit) id gAFMeJYC062870; Fri, 15 Nov 2002 17:40:19 -0500 (EST) X-Authentication-Warning: jester.senspire.com: rbt set sender to rbt@rbt.ca using -f Subject: Re: Sort time From: Rod Taylor To: josh@agliodbs.com Cc: pginfo , "scott.marlowe" , "pgsql-performance@postgresql.org" In-Reply-To: <200211151318.33245.josh@agliodbs.com> References: <200211151127.29405.josh@agliodbs.com> <1037388518.14810.118.camel@jester> <200211151318.33245.josh@agliodbs.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1037400019.62804.0.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 15 Nov 2002 17:40:19 -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/104 X-Sequence-Number: 262 On Fri, 2002-11-15 at 16:18, Josh Berkus wrote: > Rod, > > > > Hmmm ... how big *is* that varchar field? 8 characters gives us about 6mb > for > > > the column. Of course, if it's a 128-char global unque id, that;s a bit > > > larger. > > > > 20 characters long in the Unicode locale -- which is 40 bytes? > > Well, 40+, probably about 43. Should be about 29mb, yes? > Here's a question: is the total size of the column a good indicator of the > sort_mem required? Or does the rowsize affect it somehow? I'd suspect the total row is sorted, especially in this case where he's sorting more than one attribute. -- Rod Taylor From pgsql-performance-owner@postgresql.org Fri Nov 15 18:02:28 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4F7B04758C9 for ; Fri, 15 Nov 2002 18:02:28 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A4818474E44 for ; Fri, 15 Nov 2002 18:02:27 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAFN2GhR002524; Fri, 15 Nov 2002 18:02:16 -0500 (EST) To: "Josh Berkus" Cc: pginfo , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: ANALYZE and indexes (was Re: Sort time) In-reply-to: References: Comments: In-reply-to "Josh Berkus" message dated "Fri, 15 Nov 2002 09:12:55 -0800" Date: Fri, 15 Nov 2002 18:02:15 -0500 Message-ID: <2523.1037401335@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/105 X-Sequence-Number: 263 "Josh Berkus" writes: > ... don't forget to VACUUM ANALYZE after you index ... People keep saying that, but it's a myth. ANALYZE doesn't care what indexes are present; adding or deleting an index doesn't invalidate previous ANALYZE results. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 15 18:32:55 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3D087475C26 for ; Fri, 15 Nov 2002 18:32:54 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8DB04475BD7 for ; Fri, 15 Nov 2002 18:32:53 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAFNWrhR002764; Fri, 15 Nov 2002 18:32:53 -0500 (EST) To: josh@agliodbs.com Cc: Rod Taylor , pginfo , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-reply-to: <200211151318.33245.josh@agliodbs.com> References: <200211151127.29405.josh@agliodbs.com> <1037388518.14810.118.camel@jester> <200211151318.33245.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Fri, 15 Nov 2002 13:18:33 -0800" Date: Fri, 15 Nov 2002 18:32:53 -0500 Message-ID: <2763.1037403173@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/106 X-Sequence-Number: 264 Josh Berkus writes: > Here's a question: is the total size of the column a good indicator of the > sort_mem required? Or does the rowsize affect it somehow? It will include all the data that's supposed to be output by the sort... both the key column(s) and the others. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 16 02:16:37 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C6AFA475D99 for ; Sat, 16 Nov 2002 02:16:34 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id 93B2B475CB1 for ; Sat, 16 Nov 2002 02:16:31 -0500 (EST) Received: (qmail 19364 invoked from network); 16 Nov 2002 08:58:44 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 16 Nov 2002 08:58:44 -0000 Message-ID: <3DD5E3B3.542C8F03@t1.unisoftbg.com> Date: Sat, 16 Nov 2002 07:20:35 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Rod Taylor Cc: josh@agliodbs.com, "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <200211151127.29405.josh@agliodbs.com> <1037388518.14810.118.camel@jester> <200211151318.33245.josh@agliodbs.com> <1037400019.62804.0.camel@jester> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/107 X-Sequence-Number: 265 Hi, Rod Taylor wrote: > On Fri, 2002-11-15 at 16:18, Josh Berkus wrote: > > Rod, > > > > > > Hmmm ... how big *is* that varchar field? 8 characters gives us about 6mb > > for > > > > the column. Of course, if it's a 128-char global unque id, that;s a bit > > > > larger. > > > > > > 20 characters long in the Unicode locale -- which is 40 bytes? > > > > Well, 40+, probably about 43. Should be about 29mb, yes? > > Here's a question: is the total size of the column a good indicator of the > > sort_mem required? Or does the rowsize affect it somehow? > > I'd suspect the total row is sorted, especially in this case where he's > sorting more than one attribute. > I think that total the row is sorted.I do not know hoe is sorting in pg working and why so slow, but I tested all this in java ( in C is much quicker) and the make this: 1. Read all data in memory defined as ArrayList from structure of data. 2. make comparator with unicode string compare. 3. Execute sort (all in memory) The sort take 2-4 sek for all this rows!!! It is good as performance. The question is : Why is it in ps so slow? Sorting is normal think for db! Also I have 256 MB for sort mem and this was the only executing query at the moment. I know that if the fields are INT all will work better, but we migrate this application from oracle and the fields in oracle was varchar. We do not have any performance problems with oracle and this data. Also one part from users will continue to work with oracle and exchange ( import and export) data to the pg systems. > -- > Rod Taylor > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) From pgsql-performance-owner@postgresql.org Sat Nov 16 02:32:51 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DD7F1475CCE for ; Sat, 16 Nov 2002 02:32:50 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id AADFD475CB1 for ; Sat, 16 Nov 2002 02:32:47 -0500 (EST) Received: (qmail 20028 invoked from network); 16 Nov 2002 09:15:01 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 16 Nov 2002 09:15:01 -0000 Message-ID: <3DD5E784.BA4FF2D7@t1.unisoftbg.com> Date: Sat, 16 Nov 2002 07:36:52 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Tom Lane Cc: josh@agliodbs.com, Rod Taylor , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <200211151127.29405.josh@agliodbs.com> <1037388518.14810.118.camel@jester> <200211151318.33245.josh@agliodbs.com> <2763.1037403173@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/108 X-Sequence-Number: 266 Hi, Tom Lane wrote: > Josh Berkus writes: > > Here's a question: is the total size of the column a good indicator of the > > sort_mem required? Or does the rowsize affect it somehow? > > It will include all the data that's supposed to be output by the sort... > both the key column(s) and the others. > Hmm it is not clear for me.Let we have all data. If I make sort by S.OP ( it is INT) it take < 6 sek for sort. I think we move all this data anly the number of comparation is by INT. I think the number of comparation is ~ n * ln(n). If we sort by S.IDS_xxx we have also n*ln(n) comparations but in varchar(string). I don't think that it can take 50 sek. Is it not so? regards, ivan. > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Sat Nov 16 12:15:14 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5FBF347623B for ; Sat, 16 Nov 2002 12:15:12 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id B8D64476233 for ; Sat, 16 Nov 2002 12:15:11 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id E20AED60C; Sat, 16 Nov 2002 09:15:11 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id D7C625C03; Sat, 16 Nov 2002 09:15:11 -0800 (PST) Date: Sat, 16 Nov 2002 09:15:11 -0800 (PST) From: Stephan Szabo To: pginfo Cc: Tom Lane , , Rod Taylor , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-Reply-To: <3DD5E784.BA4FF2D7@t1.unisoftbg.com> Message-ID: <20021116091337.U26137-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/109 X-Sequence-Number: 267 On Sat, 16 Nov 2002, pginfo wrote: > Hi, > > Tom Lane wrote: > > > Josh Berkus writes: > > > Here's a question: is the total size of the column a good indicator of the > > > sort_mem required? Or does the rowsize affect it somehow? > > > > It will include all the data that's supposed to be output by the sort... > > both the key column(s) and the others. > > > > Hmm it is not clear for me.Let we have all data. > If I make sort by S.OP ( it is INT) it take < 6 sek for sort. > I think we move all this data anly the number of comparation is by INT. I think > the number of comparation > is ~ n * ln(n). > If we sort by S.IDS_xxx we have also n*ln(n) comparations but in > varchar(string). > I don't think that it can take 50 sek. > > Is it not so? Have you tried setting up another database in "C" locale and compared the timings there? I'd wonder if maybe there's some extra copying going on given the comments in varstr_cmp. From pgsql-performance-owner@postgresql.org Sun Nov 17 02:27:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F1457475F66 for ; Sun, 17 Nov 2002 02:27:00 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id F189F476300 for ; Sun, 17 Nov 2002 02:26:33 -0500 (EST) Received: (qmail 29203 invoked from network); 17 Nov 2002 09:08:37 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 17 Nov 2002 09:08:37 -0000 Message-ID: <3DD73784.11ED2512@t1.unisoftbg.com> Date: Sun, 17 Nov 2002 07:30:28 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Stephan Szabo Cc: Tom Lane , josh@agliodbs.com, Rod Taylor , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <20021116091337.U26137-100000@megazone23.bigpanda.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/110 X-Sequence-Number: 268 Hi, Stephan Szabo wrote: > On Sat, 16 Nov 2002, pginfo wrote: > > > Hi, > > > > Tom Lane wrote: > > > > > Josh Berkus writes: > > > > Here's a question: is the total size of the column a good indicator of the > > > > sort_mem required? Or does the rowsize affect it somehow? > > > > > > It will include all the data that's supposed to be output by the sort... > > > both the key column(s) and the others. > > > > > > > Hmm it is not clear for me.Let we have all data. > > If I make sort by S.OP ( it is INT) it take < 6 sek for sort. > > I think we move all this data anly the number of comparation is by INT. I think > > the number of comparation > > is ~ n * ln(n). > > If we sort by S.IDS_xxx we have also n*ln(n) comparations but in > > varchar(string). > > I don't think that it can take 50 sek. > > > > Is it not so? > > Have you tried setting up another database in "C" locale and compared the > timings there? I'd wonder if maybe there's some extra copying going on > given the comments in varstr_cmp. No, I do not have any info about it.I will see if it is possible ( the data are not so simple). If it is possible I will make the tests. Have no one that have 700K row in thow tables? It is simple to test: 1. Run query that returns ~700K rows from this tables. 2. Make sort. It is interest only the sort time! regards, Ivan. From pgsql-performance-owner@postgresql.org Sun Nov 17 03:25:25 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6A9A14758C9 for ; Sun, 17 Nov 2002 03:25:23 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id 573A04758BD for ; Sun, 17 Nov 2002 03:25:18 -0500 (EST) Received: (qmail 4491 invoked from network); 17 Nov 2002 10:07:29 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 17 Nov 2002 10:07:29 -0000 Message-ID: <3DD74551.2AF7827B@t1.unisoftbg.com> Date: Sun, 17 Nov 2002 08:29:21 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Stephan Szabo Cc: Tom Lane , josh@agliodbs.com, Rod Taylor , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <20021116233532.J33150-100000@megazone23.bigpanda.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/113 X-Sequence-Number: 271 Hi, Stephan Szabo wrote: > On Sun, 17 Nov 2002, pginfo wrote: > > > Hi, > > > > Stephan Szabo wrote: > > > > > On Sat, 16 Nov 2002, pginfo wrote: > > > > > > > Hi, > > > > > > > > Tom Lane wrote: > > > > > > > > > Josh Berkus writes: > > > > > > Here's a question: is the total size of the column a good indicator of the > > > > > > sort_mem required? Or does the rowsize affect it somehow? > > > > > > > > > > It will include all the data that's supposed to be output by the sort... > > > > > both the key column(s) and the others. > > > > > > > > > > > > > Hmm it is not clear for me.Let we have all data. > > > > If I make sort by S.OP ( it is INT) it take < 6 sek for sort. > > > > I think we move all this data anly the number of comparation is by INT. I think > > > > the number of comparation > > > > is ~ n * ln(n). > > > > If we sort by S.IDS_xxx we have also n*ln(n) comparations but in > > > > varchar(string). > > > > I don't think that it can take 50 sek. > > > > > > > > Is it not so? > > > > > > Have you tried setting up another database in "C" locale and compared the > > > timings there? I'd wonder if maybe there's some extra copying going on > > > given the comments in varstr_cmp. > > > > No, I do not have any info about it.I will see if it is possible ( the data are not > > so simple). > > If it is possible I will make the tests. > > Have no one that have 700K row in thow tables? > > It is simple to test: > > 1. Run query that returns ~700K rows from this tables. > > 2. Make sort. > > > > It is interest only the sort time! > > I can make a table of 700k rows and test it (and am generating 700k of > random varchar rows), but I wouldn't hold great hope that this is > necessarily a valid test since possibly any of OS, configuration settings > and actual data (width and values) might have an effect on the results. > It is so.But the info will help. If the sort time is 5-6 sek.(by me it is 50 sek) I will work on config and OS settings. I am uning RH 7.3 at the moment. If anoder OS will have better performance I will make the change. But if the sort time is ~50 sek in any OS and config the problem will be in pg and I will start to think about to rewrite the sort part of src or migrate to anoder db(mysql or SAPdb. On oracle we have super performance in sorting at the moment, but the idea is to move the project to pg). I think the sort is very important for any db. Also it will be possible for me (in 1-2 days ) to install anoder box for tests and give access to some one that can see the problem. But as beginning it will be great to have more info about sort test results. If any one have better idea I am ready to discuse it. regards, Ivan. > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) From pgsql-performance-owner@postgresql.org Sun Nov 17 02:44:56 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5BB964758C9 for ; Sun, 17 Nov 2002 02:44:54 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 501394758BD for ; Sun, 17 Nov 2002 02:44:52 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 97504D606; Sat, 16 Nov 2002 23:44:40 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 3E48C5C02; Sat, 16 Nov 2002 23:44:40 -0800 (PST) Date: Sat, 16 Nov 2002 23:44:38 -0800 (PST) From: Stephan Szabo To: pginfo Cc: Tom Lane , , Rod Taylor , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-Reply-To: <3DD73784.11ED2512@t1.unisoftbg.com> Message-ID: <20021116233532.J33150-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/111 X-Sequence-Number: 269 On Sun, 17 Nov 2002, pginfo wrote: > Hi, > > Stephan Szabo wrote: > > > On Sat, 16 Nov 2002, pginfo wrote: > > > > > Hi, > > > > > > Tom Lane wrote: > > > > > > > Josh Berkus writes: > > > > > Here's a question: is the total size of the column a good indicator of the > > > > > sort_mem required? Or does the rowsize affect it somehow? > > > > > > > > It will include all the data that's supposed to be output by the sort... > > > > both the key column(s) and the others. > > > > > > > > > > Hmm it is not clear for me.Let we have all data. > > > If I make sort by S.OP ( it is INT) it take < 6 sek for sort. > > > I think we move all this data anly the number of comparation is by INT. I think > > > the number of comparation > > > is ~ n * ln(n). > > > If we sort by S.IDS_xxx we have also n*ln(n) comparations but in > > > varchar(string). > > > I don't think that it can take 50 sek. > > > > > > Is it not so? > > > > Have you tried setting up another database in "C" locale and compared the > > timings there? I'd wonder if maybe there's some extra copying going on > > given the comments in varstr_cmp. > > No, I do not have any info about it.I will see if it is possible ( the data are not > so simple). > If it is possible I will make the tests. > Have no one that have 700K row in thow tables? > It is simple to test: > 1. Run query that returns ~700K rows from this tables. > 2. Make sort. > > It is interest only the sort time! I can make a table of 700k rows and test it (and am generating 700k of random varchar rows), but I wouldn't hold great hope that this is necessarily a valid test since possibly any of OS, configuration settings and actual data (width and values) might have an effect on the results. From pgsql-performance-owner@postgresql.org Sun Nov 17 04:12:06 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D139E475B07 for ; Sun, 17 Nov 2002 04:11:59 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id 64EEB4758BD for ; Sun, 17 Nov 2002 04:11:56 -0500 (EST) Received: (qmail 5950 invoked from network); 17 Nov 2002 10:54:09 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 17 Nov 2002 10:54:09 -0000 Message-ID: <3DD75041.64B20817@t1.unisoftbg.com> Date: Sun, 17 Nov 2002 09:16:01 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Stephan Szabo Cc: "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <20021117001240.A33556-100000@megazone23.bigpanda.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/114 X-Sequence-Number: 272 Hi, Stephan Szabo wrote: > On Sat, 16 Nov 2002, Stephan Szabo wrote: > > > On Sun, 17 Nov 2002, pginfo wrote: > > > > > Hi, > > > > > > Stephan Szabo wrote: > > > > > > > On Sat, 16 Nov 2002, pginfo wrote: > > > > > > > > > Hi, > > > > > > > > > > Tom Lane wrote: > > > > > > > > > > > Josh Berkus writes: > > > > > > > Here's a question: is the total size of the column a good indicator of the > > > > > > > sort_mem required? Or does the rowsize affect it somehow? > > > > > > > > > > > > It will include all the data that's supposed to be output by the sort... > > > > > > both the key column(s) and the others. > > > > > > > > > > > > > > > > Hmm it is not clear for me.Let we have all data. > > > > > If I make sort by S.OP ( it is INT) it take < 6 sek for sort. > > > > > I think we move all this data anly the number of comparation is by INT. I think > > > > > the number of comparation > > > > > is ~ n * ln(n). > > > > > If we sort by S.IDS_xxx we have also n*ln(n) comparations but in > > > > > varchar(string). > > > > > I don't think that it can take 50 sek. > > > > > > > > > > Is it not so? > > > > > > > > Have you tried setting up another database in "C" locale and compared the > > > > timings there? I'd wonder if maybe there's some extra copying going on > > > > given the comments in varstr_cmp. > > > > > > No, I do not have any info about it.I will see if it is possible ( the data are not > > > so simple). > > > If it is possible I will make the tests. > > > Have no one that have 700K row in thow tables? > > > It is simple to test: > > > 1. Run query that returns ~700K rows from this tables. > > > 2. Make sort. > > > > > > It is interest only the sort time! > > > > I can make a table of 700k rows and test it (and am generating 700k of > > random varchar rows), but I wouldn't hold great hope that this is > > necessarily a valid test since possibly any of OS, configuration settings > > and actual data (width and values) might have an effect on the results. > > On my not terribly powerful or memory filled box, I got a time of about > 16s after going through a couple iterations of raising sort_mem and > watching if it made temp files (which is probably a good idea to check as > well). The data size ended up being in the vicinity of 100 meg in my > case. The time is very good! It is very good idea to watch the temp files. I started the sort_mem to 32 mb (it is 256 on the production system) and I see 3 temp files. The first is ~ 1.8 mb. The second is ~55 mb and the last is ~150 mb. Also I removed the bigest as size fileds from my query but got only litle improvemen. regards, ivan. From pgsql-performance-owner@postgresql.org Sun Nov 17 03:18:29 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BE4454758C9 for ; Sun, 17 Nov 2002 03:18:25 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 265954758BD for ; Sun, 17 Nov 2002 03:18:25 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 1636DD606; Sun, 17 Nov 2002 00:18:24 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 446015C02; Sun, 17 Nov 2002 00:18:24 -0800 (PST) Date: Sun, 17 Nov 2002 00:18:22 -0800 (PST) From: Stephan Szabo To: pginfo Cc: "pgsql-performance@postgresql.org" Subject: Re: Sort time In-Reply-To: <20021116233532.J33150-100000@megazone23.bigpanda.com> Message-ID: <20021117001240.A33556-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/112 X-Sequence-Number: 270 On Sat, 16 Nov 2002, Stephan Szabo wrote: > On Sun, 17 Nov 2002, pginfo wrote: > > > Hi, > > > > Stephan Szabo wrote: > > > > > On Sat, 16 Nov 2002, pginfo wrote: > > > > > > > Hi, > > > > > > > > Tom Lane wrote: > > > > > > > > > Josh Berkus writes: > > > > > > Here's a question: is the total size of the column a good indicator of the > > > > > > sort_mem required? Or does the rowsize affect it somehow? > > > > > > > > > > It will include all the data that's supposed to be output by the sort... > > > > > both the key column(s) and the others. > > > > > > > > > > > > > Hmm it is not clear for me.Let we have all data. > > > > If I make sort by S.OP ( it is INT) it take < 6 sek for sort. > > > > I think we move all this data anly the number of comparation is by INT. I think > > > > the number of comparation > > > > is ~ n * ln(n). > > > > If we sort by S.IDS_xxx we have also n*ln(n) comparations but in > > > > varchar(string). > > > > I don't think that it can take 50 sek. > > > > > > > > Is it not so? > > > > > > Have you tried setting up another database in "C" locale and compared the > > > timings there? I'd wonder if maybe there's some extra copying going on > > > given the comments in varstr_cmp. > > > > No, I do not have any info about it.I will see if it is possible ( the data are not > > so simple). > > If it is possible I will make the tests. > > Have no one that have 700K row in thow tables? > > It is simple to test: > > 1. Run query that returns ~700K rows from this tables. > > 2. Make sort. > > > > It is interest only the sort time! > > I can make a table of 700k rows and test it (and am generating 700k of > random varchar rows), but I wouldn't hold great hope that this is > necessarily a valid test since possibly any of OS, configuration settings > and actual data (width and values) might have an effect on the results. On my not terribly powerful or memory filled box, I got a time of about 16s after going through a couple iterations of raising sort_mem and watching if it made temp files (which is probably a good idea to check as well). The data size ended up being in the vicinity of 100 meg in my case. From pgsql-performance-owner@postgresql.org Sun Nov 17 12:29:49 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 392CF47590C for ; Sun, 17 Nov 2002 12:29:49 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id C0B614758E6 for ; Sun, 17 Nov 2002 12:29:48 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id B8AEFD60F; Sun, 17 Nov 2002 09:29:50 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id AA60B5C02; Sun, 17 Nov 2002 09:29:50 -0800 (PST) Date: Sun, 17 Nov 2002 09:29:50 -0800 (PST) From: Stephan Szabo To: pginfo Cc: "pgsql-performance@postgresql.org" Subject: Re: Sort time In-Reply-To: <3DD75041.64B20817@t1.unisoftbg.com> Message-ID: <20021117092657.L38418-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/115 X-Sequence-Number: 273 On Sun, 17 Nov 2002, pginfo wrote: > > On my not terribly powerful or memory filled box, I got a time of about > > 16s after going through a couple iterations of raising sort_mem and > > watching if it made temp files (which is probably a good idea to check as > > well). The data size ended up being in the vicinity of 100 meg in my > > case. > > The time is very good! > It is very good idea to watch the temp files. > I started the sort_mem to 32 mb (it is 256 on the production system) > and I see 3 temp files. The first is ~ 1.8 mb. The second is ~55 mb and the last is ~150 > mb. As a note, the same data loaded into a non-"C" locale database took about 42 seconds on the same machine, approximately 2.5x as long. From pgsql-performance-owner@postgresql.org Sun Nov 17 15:56:21 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C7A13475C45 for ; Sun, 17 Nov 2002 15:56:19 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0B779475AD7 for ; Sun, 17 Nov 2002 15:56:19 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAHKuDhR006814; Sun, 17 Nov 2002 15:56:13 -0500 (EST) To: Stephan Szabo Cc: pginfo , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-reply-to: <20021117092657.L38418-100000@megazone23.bigpanda.com> References: <20021117092657.L38418-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Sun, 17 Nov 2002 09:29:50 -0800" Date: Sun, 17 Nov 2002 15:56:13 -0500 Message-ID: <6813.1037566573@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/116 X-Sequence-Number: 274 Stephan Szabo writes: > As a note, the same data loaded into a non-"C" locale database took about > 42 seconds on the same machine, approximately 2.5x as long. The non-C locale is undoubtedly the problem. I made a test dataset of 700000 all-alphabetic 20-character random strings: $ head rand.data duofoesrlycdnilvlcrg crealjdrjpyczfbnlouo lxaiyicslwjnxgpehtzp ykizuovkvpkvvqsaocys rkkvrqfiiybczwqdvvfu stonxhbbvgwtjszodguv prqxhwcfibiopjpiddud ubgexbfdodhnauytebcf urfoqifgbrladpssrwzw ydcrsnxjpxospfqqoilw I performed the following experiment in 7.3 using a database in en_US locale, SQL_ASCII encoding: enus=# create table vc20 (f1 varchar(20)); CREATE TABLE enus=# \copy vc20 from rand.data \. enus=# vacuum analyze vc20; VACUUM enus=# set sort_mem to 50000; SET enus=# explain analyze select count(*) from enus-# (select * from vc20 order by f1) ss; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=83607.48..83607.48 rows=1 width=24) (actual time=1058167.66..1058167.67 rows=1 loops=1) -> Subquery Scan ss (cost=80107.48..81857.48 rows=700000 width=24) (actual time=1022972.86..1049559.50 rows=700000 loops=1) -> Sort (cost=80107.48..81857.48 rows=700000 width=24) (actual time=1022972.80..1034036.58 rows=700000 loops=1) Sort Key: f1 -> Seq Scan on vc20 (cost=0.00..12148.00 rows=700000 width=24) (actual time=0.20..24651.65 rows=700000 loops=1) Total runtime: 1058220.10 msec (6 rows) (The point of the select count(*) was to avoid shipping the result rows to the client, but in hindsight "explain analyze" would suppress that anyway. But the main datapoint here is the time for the Sort step.) I tried the test using datatype NAME as well, since it sorts using plain strcmp() instead of strcoll(): enus=# create table nm (f1 name); CREATE TABLE enus=# insert into nm select f1 from vc20; INSERT 0 700000 enus=# vacuum analyze nm; VACUUM enus=# set sort_mem to 50000; SET enus=# explain analyze select count(*) from enus-# (select * from nm order by f1) ss; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=122701.48..122701.48 rows=1 width=64) (actual time=157877.84..157877.85 rows=1 loops=1) -> Subquery Scan ss (cost=119201.48..120951.48 rows=700000 width=64) (actual time=121286.65..149376.93 rows=700000 loops=1) -> Sort (cost=119201.48..120951.48 rows=700000 width=64) (actual time=121286.60..134075.61 rows=700000 loops=1) Sort Key: f1 -> Seq Scan on nm (cost=0.00..15642.00 rows=700000 width=64) (actual time=0.21..24150.57 rows=700000 loops=1) Total runtime: 157962.79 msec (6 rows) In C locale, the identical test sequence gives QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=83607.48..83607.48 rows=1 width=24) (actual time=187480.70..187480.71 rows=1 loops=1) -> Subquery Scan ss (cost=80107.48..81857.48 rows=700000 width=24) (actual time=141100.03..178625.97 rows=700000 loops=1) -> Sort (cost=80107.48..81857.48 rows=700000 width=24) (actual time=141099.98..162288.95 rows=700000 loops=1) Sort Key: f1 -> Seq Scan on vc20 (cost=0.00..12148.00 rows=700000 width=24) (actual time=0.20..23954.71 rows=700000 loops=1) Total runtime: 187565.79 msec (6 rows) and of course about the same runtime as before for datatype NAME. So on this platform (HPUX 10.20), en_US locale incurs about a 6x penalty over C locale for sorting varchars. Note that NAME beats VARCHAR by a noticeable margin even in C locale, despite the handicap of requiring much more I/O (being 64 bytes per row not 24). This surprises me; it looks like varstr_cmp() is reasonably well optimized in the C-locale case. But the real loser is VARCHAR in non-C locales. I suspect the primary time sink is strcoll() not the palloc/copy overhead in varstr_cmp(), but don't have time right now to do profiling to prove it. Anyway, use of NAME instead of VARCHAR might be a workable workaround if you cannot change your database locale to C. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Nov 17 16:10:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F075C475C45 for ; Sun, 17 Nov 2002 16:10:39 -0500 (EST) Received: from rh72.home.ee (adsl1030.estpak.ee [213.168.29.11]) by postgresql.org (Postfix) with ESMTP id 8069D475AD7 for ; Sun, 17 Nov 2002 16:10:37 -0500 (EST) Received: from rh72.home.ee (localhost.localdomain [127.0.0.1]) by rh72.home.ee (8.12.5/8.12.5) with ESMTP id gAHLAGk3002554; Mon, 18 Nov 2002 02:10:16 +0500 Received: (from hannu@localhost) by rh72.home.ee (8.12.5/8.12.5/Submit) id gAHLADar002552; Mon, 18 Nov 2002 02:10:13 +0500 X-Authentication-Warning: rh72.home.ee: hannu set sender to hannu@tm.ee using -f Subject: Re: Sort time From: Hannu Krosing To: Stephan Szabo Cc: pginfo , "pgsql-performance@postgresql.org" In-Reply-To: <20021117092657.L38418-100000@megazone23.bigpanda.com> References: <20021117092657.L38418-100000@megazone23.bigpanda.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1037567411.2422.33.camel@rh72.home.ee> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 18 Nov 2002 02:10:12 +0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/117 X-Sequence-Number: 275 Stephan Szabo kirjutas P, 17.11.2002 kell 22:29: > On Sun, 17 Nov 2002, pginfo wrote: > > > > On my not terribly powerful or memory filled box, I got a time of about > > > 16s after going through a couple iterations of raising sort_mem and > > > watching if it made temp files (which is probably a good idea to check as > > > well). The data size ended up being in the vicinity of 100 meg in my > > > case. > > > > The time is very good! > > It is very good idea to watch the temp files. > > I started the sort_mem to 32 mb (it is 256 on the production system) > > and I see 3 temp files. The first is ~ 1.8 mb. The second is ~55 mb and the last is ~150 > > mb. > > As a note, the same data loaded into a non-"C" locale database took about > 42 seconds on the same machine, approximately 2.5x as long. I have investigated IBM's ICU (International Code for Unicode or smth like that) in order to use it for implementing native UNICODE text types. The sorting portion seems to work in two stages - 1. convert UTF_16 to "sorting string" and 2. compare said "sorting strings" - with the stages being also available separately. if the same is true for "native" locale support, then there is a good explanation why the text sort is orders of magnitude slower than int sort: as the full conversion to "sorting string" has to be done at each comparison (plus probably malloc/free) for locale-aware compare, but on most cases in C locale one does not need these, plus the comparison can usually stop at first or second char. Getting good performance on locale-aware text sorts seems to require storing these "sorting strings", either additionally or only these and find a way for reverse conversion ("sorting string" --> original) Some speed could be gained by doing the original --> "sorting string" conversion only once for each line, but that will probably require a major rewrite of sorting code - in essence select loctxt,a,b,c,d,e,f,g from mytab sort by localestring; should become select loctxt,a,b,c,d,e,f,g from ( select localestring,a,b,c,d,e,f,g from mytab sort by sorting_string(loctxt) ) t; or even select loctxt,a,b,c,d,e,f,g from ( select localestring,a,b,c,d,e,f,g, ss from ( select localestring,a,b,c,d,e,f,g, sorting_string(loctxt) as ss from from mytab ) sort by ss ) t; depending on how the second form is implemented (i.e. if sorting_string(loctxt) is evaluated once per row or one per compare) ------------- Hannu From pgsql-performance-owner@postgresql.org Sun Nov 17 18:05:23 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7BD37475AD7 for ; Sun, 17 Nov 2002 18:05:20 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B7C9A475A1E for ; Sun, 17 Nov 2002 18:05:19 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAHN5KhR008038; Sun, 17 Nov 2002 18:05:20 -0500 (EST) To: Stephan Szabo Cc: pginfo , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-reply-to: <6813.1037566573@sss.pgh.pa.us> References: <20021117092657.L38418-100000@megazone23.bigpanda.com> <6813.1037566573@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 17 Nov 2002 15:56:13 -0500" Date: Sun, 17 Nov 2002 18:05:20 -0500 Message-ID: <8037.1037574320@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/118 X-Sequence-Number: 276 I've applied the attached patch to current sources (7.4devel). It eliminates palloc/pfree overhead in varstr_cmp() for short strings (up to 1K as committed). I find that this reduces the sort time for 700,000 rows by about 10% on my HPUX box; might be better on machines with better-optimized strcoll(). regards, tom lane *** src/backend/utils/adt/varlena.c.orig Wed Sep 4 17:30:48 2002 --- src/backend/utils/adt/varlena.c Sun Nov 17 17:21:43 2002 *************** *** 736,771 **** varstr_cmp(char *arg1, int len1, char *arg2, int len2) { int result; - char *a1p, - *a2p; /* * Unfortunately, there is no strncoll(), so in the non-C locale case * we have to do some memory copying. This turns out to be * significantly slower, so we optimize the case where LC_COLLATE is ! * C. */ if (!lc_collate_is_c()) { ! a1p = (char *) palloc(len1 + 1); ! a2p = (char *) palloc(len2 + 1); memcpy(a1p, arg1, len1); ! *(a1p + len1) = '\0'; memcpy(a2p, arg2, len2); ! *(a2p + len2) = '\0'; result = strcoll(a1p, a2p); ! pfree(a1p); ! pfree(a2p); } else { ! a1p = arg1; ! a2p = arg2; ! ! result = strncmp(a1p, a2p, Min(len1, len2)); if ((result == 0) && (len1 != len2)) result = (len1 < len2) ? -1 : 1; } --- 736,782 ---- varstr_cmp(char *arg1, int len1, char *arg2, int len2) { int result; /* * Unfortunately, there is no strncoll(), so in the non-C locale case * we have to do some memory copying. This turns out to be * significantly slower, so we optimize the case where LC_COLLATE is ! * C. We also try to optimize relatively-short strings by avoiding ! * palloc/pfree overhead. */ + #define STACKBUFLEN 1024 + if (!lc_collate_is_c()) { ! char a1buf[STACKBUFLEN]; ! char a2buf[STACKBUFLEN]; ! char *a1p, ! *a2p; ! ! if (len1 >= STACKBUFLEN) ! a1p = (char *) palloc(len1 + 1); ! else ! a1p = a1buf; ! if (len2 >= STACKBUFLEN) ! a2p = (char *) palloc(len2 + 1); ! else ! a2p = a2buf; memcpy(a1p, arg1, len1); ! a1p[len1] = '\0'; memcpy(a2p, arg2, len2); ! a2p[len2] = '\0'; result = strcoll(a1p, a2p); ! if (len1 >= STACKBUFLEN) ! pfree(a1p); ! if (len2 >= STACKBUFLEN) ! pfree(a2p); } else { ! result = strncmp(arg1, arg2, Min(len1, len2)); if ((result == 0) && (len1 != len2)) result = (len1 < len2) ? -1 : 1; } From pgsql-performance-owner@postgresql.org Sun Nov 17 18:54:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 92F59475AD7 for ; Sun, 17 Nov 2002 18:54:41 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id F324E475A1E for ; Sun, 17 Nov 2002 18:54:40 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAHNshhR010092; Sun, 17 Nov 2002 18:54:43 -0500 (EST) To: Hannu Krosing Cc: Stephan Szabo , pginfo , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-reply-to: <1037567411.2422.33.camel@rh72.home.ee> References: <20021117092657.L38418-100000@megazone23.bigpanda.com> <1037567411.2422.33.camel@rh72.home.ee> Comments: In-reply-to Hannu Krosing message dated "18 Nov 2002 02:10:12 +0500" Date: Sun, 17 Nov 2002 18:54:42 -0500 Message-ID: <10091.1037577282@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/119 X-Sequence-Number: 277 Hannu Krosing writes: > Some speed could be gained by doing the original --> "sorting string" > conversion only once for each line, but that will probably require a > major rewrite of sorting code - in essence > select loctxt,a,b,c,d,e,f,g from mytab sort by localestring; > should become > select loctxt,a,b,c,d,e,f,g from ( > select localestring,a,b,c,d,e,f,g > from mytab > sort by sorting_string(loctxt) > ) t; > or even > select loctxt,a,b,c,d,e,f,g from ( > select localestring,a,b,c,d,e,f,g, ss from ( > select localestring,a,b,c,d,e,f,g, sorting_string(loctxt) as ss from > from mytab > ) > sort by ss > ) t; > depending on how the second form is implemented (i.e. if > sorting_string(loctxt) is evaluated once per row or one per compare) Indeed the function call will be evaluated only once per row, so it wouldn't be too hard to kluge up a prototype implementation to test what the real speed difference turns out to be. You'd basically need (a) a non-locale-aware set of comparison operators for type text --- you might as well build a whole index opclass, so that non-locale-aware indexes could be made (this'd be a huge win for LIKE optimization too); (b) a strxfrm() function to produce the sortable strings. If it turns out to be a big win, which is looking probable from the comparisons Stephan and I just reported, then the next question is how to make the transformation occur automatically. I think it'd be relatively simple to put a hack in the planner to do this when it's emitting a SORT operation that uses the locale-aware sort operators. It'd be kind of an ugly special case, but surely no worse than the ones that are in there already for LIKE and some other operators. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 18 02:06:21 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AD56E475AD7 for ; Mon, 18 Nov 2002 02:06:20 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id 89C4E4758F1 for ; Mon, 18 Nov 2002 02:06:17 -0500 (EST) Received: (qmail 11672 invoked from network); 18 Nov 2002 08:48:24 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 18 Nov 2002 08:48:24 -0000 Message-ID: <3DD88445.F617D9B@t1.unisoftbg.com> Date: Mon, 18 Nov 2002 07:10:13 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Tom Lane Cc: Stephan Szabo , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <20021117092657.L38418-100000@megazone23.bigpanda.com> <6813.1037566573@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/120 X-Sequence-Number: 278 Hi Tom, The idea is very good. I recreated the tables and for all IDS_xxx I used name (not varchar(20)). The the is also in unicode. I ran the query and got huge improvement! The work time is 166 sek. ( before it was ~320 - 340 sek.). I will continue to make new tests and play around the setups. I think all this can be more quicker. I expect to get ~ 45-60 sek. ( this is the time in oracle), but laso 166 sek is good. I think that we need to work around the non us sorting and compare. It is not possible to be so slow (all the functions are executed in memory and in java and by oracle and by ms all this is working very fast). regards, ivan. Tom Lane wrote: > Stephan Szabo writes: > > As a note, the same data loaded into a non-"C" locale database took about > > 42 seconds on the same machine, approximately 2.5x as long. > > The non-C locale is undoubtedly the problem. I made a test dataset of > 700000 all-alphabetic 20-character random strings: > > $ head rand.data > duofoesrlycdnilvlcrg > crealjdrjpyczfbnlouo > lxaiyicslwjnxgpehtzp > ykizuovkvpkvvqsaocys > rkkvrqfiiybczwqdvvfu > stonxhbbvgwtjszodguv > prqxhwcfibiopjpiddud > ubgexbfdodhnauytebcf > urfoqifgbrladpssrwzw > ydcrsnxjpxospfqqoilw > > I performed the following experiment in 7.3 using a database in > en_US locale, SQL_ASCII encoding: > > enus=# create table vc20 (f1 varchar(20)); > CREATE TABLE > enus=# \copy vc20 from rand.data > \. > enus=# vacuum analyze vc20; > VACUUM > enus=# set sort_mem to 50000; > SET > enus=# explain analyze select count(*) from > enus-# (select * from vc20 order by f1) ss; > QUERY PLAN > > --------------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=83607.48..83607.48 rows=1 width=24) (actual time=1058167.66..1058167.67 rows=1 loops=1) > -> Subquery Scan ss (cost=80107.48..81857.48 rows=700000 width=24) (actual time=1022972.86..1049559.50 rows=700000 loops=1) > -> Sort (cost=80107.48..81857.48 rows=700000 width=24) (actual time=1022972.80..1034036.58 rows=700000 loops=1) > Sort Key: f1 > -> Seq Scan on vc20 (cost=0.00..12148.00 rows=700000 width=24) (actual time=0.20..24651.65 rows=700000 loops=1) > Total runtime: 1058220.10 msec > (6 rows) > > (The point of the select count(*) was to avoid shipping the result rows > to the client, but in hindsight "explain analyze" would suppress that > anyway. But the main datapoint here is the time for the Sort step.) > > I tried the test using datatype NAME as well, since it sorts using > plain strcmp() instead of strcoll(): > > enus=# create table nm (f1 name); > CREATE TABLE > enus=# insert into nm select f1 from vc20; > INSERT 0 700000 > enus=# vacuum analyze nm; > VACUUM > enus=# set sort_mem to 50000; > SET > enus=# explain analyze select count(*) from > enus-# (select * from nm order by f1) ss; > QUERY PLAN > > --------------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=122701.48..122701.48 rows=1 width=64) (actual time=157877.84..157877.85 rows=1 loops=1) > -> Subquery Scan ss (cost=119201.48..120951.48 rows=700000 width=64) (actual time=121286.65..149376.93 rows=700000 loops=1) > -> Sort (cost=119201.48..120951.48 rows=700000 width=64) (actual time=121286.60..134075.61 rows=700000 loops=1) > Sort Key: f1 > -> Seq Scan on nm (cost=0.00..15642.00 rows=700000 width=64) (actual time=0.21..24150.57 rows=700000 loops=1) > Total runtime: 157962.79 msec > (6 rows) > > In C locale, the identical test sequence gives > > QUERY PLAN > > --------------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=83607.48..83607.48 rows=1 width=24) (actual time=187480.70..187480.71 rows=1 loops=1) > -> Subquery Scan ss (cost=80107.48..81857.48 rows=700000 width=24) (actual time=141100.03..178625.97 rows=700000 loops=1) > -> Sort (cost=80107.48..81857.48 rows=700000 width=24) (actual time=141099.98..162288.95 rows=700000 loops=1) > Sort Key: f1 > -> Seq Scan on vc20 (cost=0.00..12148.00 rows=700000 width=24) (actual time=0.20..23954.71 rows=700000 loops=1) > Total runtime: 187565.79 msec > (6 rows) > > and of course about the same runtime as before for datatype NAME. So on > this platform (HPUX 10.20), en_US locale incurs about a 6x penalty over > C locale for sorting varchars. > > Note that NAME beats VARCHAR by a noticeable margin even in C locale, > despite the handicap of requiring much more I/O (being 64 bytes per row > not 24). This surprises me; it looks like varstr_cmp() is reasonably > well optimized in the C-locale case. But the real loser is VARCHAR in > non-C locales. I suspect the primary time sink is strcoll() not the > palloc/copy overhead in varstr_cmp(), but don't have time right now to > do profiling to prove it. > > Anyway, use of NAME instead of VARCHAR might be a workable workaround > if you cannot change your database locale to C. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Mon Nov 18 06:12:22 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26A44476485 for ; Mon, 18 Nov 2002 06:12:18 -0500 (EST) Received: from jobs1.unisoftbg.com (unknown [194.12.229.208]) by postgresql.org (Postfix) with SMTP id A92B74761BF for ; Mon, 18 Nov 2002 06:12:13 -0500 (EST) Received: (qmail 18979 invoked from network); 18 Nov 2002 12:54:25 -0000 Received: from unisoft.unisoftbg.com (HELO t1.unisoftbg.com) (194.12.229.193) by 0 with SMTP; 18 Nov 2002 12:54:25 -0000 Message-ID: <3DD8BDEE.84E35746@t1.unisoftbg.com> Date: Mon, 18 Nov 2002 11:16:14 +0100 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Tom Lane , "pgsql-performance@postgresql.org" Subject: Re: Sort time References: <20021117092657.L38418-100000@megazone23.bigpanda.com> <6813.1037566573@sss.pgh.pa.us> <3DD88445.F617D9B@t1.unisoftbg.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/121 X-Sequence-Number: 279 Hi, anoder important point of view forme: As I know the size of sort_mem is given at the pg start and is not shared. Also I can use set sort_mem to xxx; Can I dot set sort_mem to myvalue ; execute my query , set sort_mem to old_value; only for querys that needet more sort memory? If I can so will the new seted sort_mem be only for the opened connection or for connections? Also will this dynamic sort_mem setting cause problems in pg? regards, iavn. From pgsql-performance-owner@postgresql.org Mon Nov 18 06:56:52 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E3FB2475AAC for ; Mon, 18 Nov 2002 06:56:48 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 6D38D47595A for ; Mon, 18 Nov 2002 06:56:48 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 03A0FD612; Mon, 18 Nov 2002 03:56:50 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id ED49C5C02; Mon, 18 Nov 2002 03:56:50 -0800 (PST) Date: Mon, 18 Nov 2002 03:56:50 -0800 (PST) From: Stephan Szabo To: pginfo Cc: Tom Lane , "pgsql-performance@postgresql.org" Subject: Re: Sort time In-Reply-To: <3DD88445.F617D9B@t1.unisoftbg.com> Message-ID: <20021118034829.P48668-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/122 X-Sequence-Number: 280 On Mon, 18 Nov 2002, pginfo wrote: > I think that we need to work around the non us sorting and compare. > It is not possible to be so slow (all the functions are executed in memory > and in java and by oracle and by ms all this is working very fast). I get similar results from the unix sort command, (8 sec elapsed for C locale, 25 sec for en_US) on my redhat 8 machine (and I forced the buffer size high enough to not get any temp files afaict). I'm not sure what platform Tom was using for his test, but maybe someone could try this on a non x86/linux machine and see what they get (I don't have access to one). From pgsql-performance-owner@postgresql.org Mon Nov 18 07:33:10 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B3C4A4758E6 for ; Mon, 18 Nov 2002 07:33:00 -0500 (EST) Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id EC1DA474E53 for ; Mon, 18 Nov 2002 07:32:50 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Mon, 18 Nov 2002 12:32:45 -0000 Message-ID: From: Nikk Anderson To: pgsql-performance@postgresql.org Subject: selects from large tables Date: Mon, 18 Nov 2002 12:32:45 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C28EFE.9871AFE0" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/123 X-Sequence-Number: 281 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C28EFE.9871AFE0 Content-Type: text/plain; charset="iso-8859-1" Hi All, We are using Postgres 7.1, on Solaris 8 - hardware is a 400mhz Netra X1, 512Mb ram, with the database on a separate partition. Our main result tables are getting really big, and we don't want to delete any data yet. Currently, our largest table has around 10 million rows and is going up at a rate of around 1 million per month. The table has 13 integer, one boolean and one timestamp column. We index the table on an ID number and the timestamp. We vacuum analyse the table every night. The performance has steadily degraded, and the more data we try and select, the longer the select queries take. The queries are not complex, and do not involve any unions etc, eg: SELECT * FROM table_name WHERE column1 = 454 AND time BETWEEN '2002-10-13 13:44:00.0' AND '2002-11-14' SELECT count(DISTINCT id) FROM table_name WHERE column1 = 454 AND time BETWEEN '2002-10-13 13:44:00.0' AND '2002-11-14 See various queries and explains at the end this email for more info on the type of queries we are doing. Most of the queries use a sequence scan - disabling this and forcing index scan decreases performance further for those queries. These queries are sometimes taking over 2 minutes to perform!!!! If we reduce the table size significantly (i.e. around 1 million rows)is is obviously faster - down to a few seconds. We then tried the DB on a clean installation of Solaris 9, on a dual 400mhz processor SunE250 with 2Gb ram, and 2 scsi 17gb disks. We put the database onto the second disk. Surprisingly the performance is only 5-10% greater. I expected far more, due to the increased power of the machine. Looking at the os info on this machine, the IO wait is negligible as is the cpu usage. So this machine is not working as hard as the Netra X1, though the time taken to perform queries is not too much different. We have tried tweaking the shared buffers and sort mem (also tweaking kernel shared mem size), which make little difference, and in fact if we increase it to around 25% of total memory performance degrades slightly. We have changed from the default amount of shared buffers, to 64000 to give us access to 25% of the total system memory. Any ideas on how we can select data more quickly from large tables? Other ideas we had was to split the data over multiple table by id (resulting in several thousand tables), however this would make management of the database in terms of keys, triggers and integrity very difficult and messy. I hope someone can offer some advice. Cheers Nikk - Queries and explain plans select count(*) from table_name; NOTICE: QUERY PLAN: Aggregate (cost=488700.65..488700.65 rows=1 width=0) -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=0) hawkdb=# explain select count(job_id) from table_name; NOTICE: QUERY PLAN: Aggregate (cost=488700.65..488700.65 rows=1 width=4) -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=4) hawkdb=# explain select * from table_name; NOTICE: QUERY PLAN: Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=57) hawkdb=# explain select count(*) from table_name where job_id = 13; NOTICE: QUERY PLAN: Aggregate (cost=537874.18..537874.18 rows=1 width=0) -> Seq Scan on table_name (cost=0.00..488700.65 rows=19669412 width=0) hawkdb=# explain select * from table_name where job_id = 13; NOTICE: QUERY PLAN: Seq Scan on http_result (cost=0.00..488700.65 rows=19669412 width=57) hawkdb=# explain select * from table_name where job_id = 1; NOTICE: QUERY PLAN: Index Scan using http_result_pk on table_name (cost=0.00..5.01 rows=1 width=57) hawkdb=#explain select * from table_name where time > '2002-10-10'; NOTICE: QUERY PLAN: Seq Scan on table_name (cost=0.00..488700.65 rows=19649743 width=57) hawkdb=# explain select * from http_result where time < '2002-10-10'; NOTICE: QUERY PLAN: Index Scan using table_name_time on table_name (cost=0.00..75879.17 rows=19669 width=57) Nikk Anderson Parallel ltd. Cranfield Innovation Centre University Way Cranfield Bedfordshire MK43 0BT http://www.nexuswatch.com http://www.parallel.ltd.uk Tel: +44 (0)8700 PARALLEL (727255) Fax: +44 (0)8700 PARAFAX (727232) ****************************************************************** Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Parallel shall be understood as neither given nor endorsed by it. Unless agreed otherwise by way of a signed agreement, any business conducted by Parallel shall be subject to its Standard Terms and Conditions which are available upon request. ****************************************************************** ------_=_NextPart_001_01C28EFE.9871AFE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable selects from large tables

Hi All,

We are using Postgres 7.1, on Solaris 8 - hardware is a 4= 00mhz Netra X1, 512Mb ram, with the database on a separate partition.

Our main result tables are getting really big, and we don= 't want to delete any data yet.  Currently, our largest table has arou= nd 10 million rows and is going up at a rate of around 1 million per month.=   The table has 13 integer, one boolean and one timestamp column. = ; We index the table on an ID number and the timestamp.  We vacuum ana= lyse the table every night.  The performance has steadily degraded, an= d the more data we try and select, the longer the select queries take.

The queries are not complex, and do not involve any union= s etc, eg:

SELECT * FROM table_name WHERE column1 =3D 454 AND time B= ETWEEN '2002-10-13 13:44:00.0' AND '2002-11-14'

SELECT count(DISTINCT id) FROM table_name WHERE column1 = =3D 454 AND time BETWEEN '2002-10-13 13:44:00.0' AND '2002-11-14

See various queries and explains at the end this email fo= r more info on the type of queries we are doing.
Most of the queries use a sequence scan - disabling this= and forcing index scan decreases performance further for those queries.

These queries are sometimes taking over 2 minutes to perf= orm!!!! If we reduce the table size significantly (i.e. around 1 million ro= ws)is is obviously faster - down to a few seconds.

We then tried the DB on a clean installation of Solaris 9= , on a dual 400mhz processor SunE250 with 2Gb ram, and 2 scsi 17gb disks.&n= bsp; We put the database onto the second disk.  Surprisingly the perfo= rmance is only 5-10% greater.  I expected far more, due to the increas= ed power of the machine.  Looking at the os info on this machine, the = IO wait is negligible as is the cpu usage.  So this machine is not wor= king as hard as the Netra X1, though the time taken to perform queries is n= ot too much different.

We have tried tweaking the shared buffers and sort mem (a= lso tweaking kernel shared mem size), which make little difference, and in = fact if we increase it to around 25% of total memory performance degrades s= lightly.  We have changed from the default amount of shared buffers, t= o 64000 to give us access to 25% of the total system memory.

Any ideas on how we can select data more quickly from lar= ge tables?

Other ideas we had was to split the data over multiple ta= ble by id (resulting in several thousand tables), however this would make m= anagement of the database in terms of keys, triggers and integrity very dif= ficult and messy.


I hope someone can offer some advice.

Cheers

Nikk

- Queries and explain plans

select count(*) from table_name;
NOTICE:  QUERY PLAN:
Aggregate  (cost=3D488700.65..488700.65 rows=3D1 wi= dth=3D0)
  ->  Seq Scan on table_name  (cost=3D= 0.00..439527.12 rows=3D19669412 width=3D0)

hawkdb=3D# explain select count(job_id) from table_name;<= /FONT>
NOTICE:  QUERY PLAN:
Aggregate  (cost=3D488700.65..488700.65 rows=3D1 wi= dth=3D4)
  ->  Seq Scan on table_name  (cost=3D= 0.00..439527.12 rows=3D19669412 width=3D4)

hawkdb=3D# explain select * from table_name;
NOTICE:  QUERY PLAN:
Seq Scan on table_name  (cost=3D0.00..439527.12 row= s=3D19669412 width=3D57)

hawkdb=3D# explain select count(*) from table_name where = job_id =3D 13;
NOTICE:  QUERY PLAN:
Aggregate  (cost=3D537874.18..537874.18 rows=3D1 wi= dth=3D0)
  ->  Seq Scan on table_name  (cost=3D= 0.00..488700.65 rows=3D19669412 width=3D0)

hawkdb=3D# explain select * from table_name where job_id = =3D 13;
NOTICE:  QUERY PLAN:
Seq Scan on http_result  (cost=3D0.00..488700.65 ro= ws=3D19669412 width=3D57)

hawkdb=3D# explain select * from table_name where job_id = =3D 1;
NOTICE:  QUERY PLAN:
Index Scan using http_result_pk on table_name  (cos= t=3D0.00..5.01 rows=3D1 width=3D57)

hawkdb=3D#explain select * from table_name where time >= ; '2002-10-10';
NOTICE:  QUERY PLAN:
Seq Scan on table_name  (cost=3D0.00..488700.65 row= s=3D19649743 width=3D57)

hawkdb=3D# explain select * from http_result where time &= lt; '2002-10-10';
NOTICE:  QUERY PLAN:
Index Scan using table_name_time on table_name  (co= st=3D0.00..75879.17 rows=3D19669 width=3D57)



Nikk Anderson

Parallel ltd.
Cranfield Innovation Centre
University Way
Cranfield
Bedfordshire
MK43 0BT

h= ttp://www.nexuswatch.com
http://www.parallel.ltd.uk

Tel: +44 (0)8700 PARALLEL (727255)
Fax: +44 (0)8700 PARAFAX  (727232)


*********************************************************= *********
Privileged/Confidential Information may be contained in = this
message.  If you are not the addressee indicated in= this message
(or responsible for delivery of the message to such pers= on), you
may not copy or deliver this message to anyone. In such = case, you
should destroy this message and kindly notify the sender= by reply
email. Please advise immediately if you or your employer= do not
consent to Internet email for messages of this kind.&nbs= p; Opinions,
conclusions and other information in this message that d= o not
relate to the official business of Parallel shall be und= erstood
as neither given nor endorsed by it.

Unless agreed otherwise by way of a signed agreement, any= business
conducted by Parallel shall be subject to its Standard T= erms
and Conditions which are available upon request.
********************************************************= **********

------_=_NextPart_001_01C28EFE.9871AFE0-- From pgsql-performance-owner@postgresql.org Mon Nov 18 08:02:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 17A2C47595A for ; Mon, 18 Nov 2002 08:02:01 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 704E74758F1 for ; Mon, 18 Nov 2002 08:02:00 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 5B42BD610; Mon, 18 Nov 2002 05:02:03 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 50FCB5C02; Mon, 18 Nov 2002 05:02:03 -0800 (PST) Date: Mon, 18 Nov 2002 05:02:03 -0800 (PST) From: Stephan Szabo To: Nikk Anderson Cc: Subject: Re: selects from large tables In-Reply-To: Message-ID: <20021118045236.A49278-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/124 X-Sequence-Number: 282 On Mon, 18 Nov 2002, Nikk Anderson wrote: > Any ideas on how we can select data more quickly from large tables? Are these row estimates realistic? It's estimating nearly 20 million rows to be returned by some of the queries (unless I'm misreading the number - possible since it's 5am here). At that point you almost certainly want to be using a cursor rather than plain queries since even a small width result (say 50 bytes) gives a very large (1 gig) result set. > - Queries and explain plans > > select count(*) from table_name; > NOTICE: QUERY PLAN: > Aggregate (cost=488700.65..488700.65 rows=1 width=0) > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=0) > > hawkdb=# explain select count(job_id) from table_name; > NOTICE: QUERY PLAN: > Aggregate (cost=488700.65..488700.65 rows=1 width=4) > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=4) > > hawkdb=# explain select * from table_name; > NOTICE: QUERY PLAN: > Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=57) > > hawkdb=# explain select count(*) from table_name where job_id = 13; > NOTICE: QUERY PLAN: > Aggregate (cost=537874.18..537874.18 rows=1 width=0) > -> Seq Scan on table_name (cost=0.00..488700.65 rows=19669412 width=0) > > hawkdb=# explain select * from table_name where job_id = 13; > NOTICE: QUERY PLAN: > Seq Scan on http_result (cost=0.00..488700.65 rows=19669412 width=57) > > hawkdb=# explain select * from table_name where job_id = 1; > NOTICE: QUERY PLAN: > Index Scan using http_result_pk on table_name (cost=0.00..5.01 rows=1 > width=57) > > hawkdb=#explain select * from table_name where time > '2002-10-10'; > NOTICE: QUERY PLAN: > Seq Scan on table_name (cost=0.00..488700.65 rows=19649743 width=57) > > hawkdb=# explain select * from http_result where time < '2002-10-10'; > NOTICE: QUERY PLAN: > Index Scan using table_name_time on table_name (cost=0.00..75879.17 > rows=19669 width=57) From pgsql-performance-owner@postgresql.org Mon Nov 18 10:04:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AFA574758F1 for ; Mon, 18 Nov 2002 10:04:07 -0500 (EST) Received: from relay.sirio.it (relay.sirio.it [212.66.230.4]) by postgresql.org (Postfix) with ESMTP id 750B34758E6 for ; Mon, 18 Nov 2002 10:04:06 -0500 (EST) Received: from stealth.fepede.org ([212.66.228.234]) by relay.sirio.it (8.12.2/8.12.2) with ESMTP id gAIF46vd018125 for ; Mon, 18 Nov 2002 16:04:09 +0100 Received: by stealth.fepede.org (Postfix, from userid 1000) id 3BF26191C1; Mon, 18 Nov 2002 16:02:17 +0100 (CET) Date: Mon, 18 Nov 2002 16:02:17 +0100 From: Federico To: pgsql-performance@postgresql.org Subject: Re: for/loop performance in plpgsql ? Message-ID: <20021118150217.GC1138@stealth.cmirl.arpal.it> References: <20021115123156.GB785@protciv14.cmirl.arpal.it> <200211151337.25980.richardh@archonet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200211151337.25980.richardh@archonet.com> User-Agent: Mutt/1.3.28i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/125 X-Sequence-Number: 283 On Fri, Nov 15, 2002 at 01:37:25PM +0000, Richard Huxton wrote: > On Friday 15 Nov 2002 12:31 pm, Federico wrote: > > Hi all, > > > > i've a doubt about how FOR/LOOP works in plpgsql. > > > > It seems to me that the SELECT query executed in that way is much slower > > that the same being executed interactively in psql. > > > > In particular it seems that it doesn't make use of indexes. > > > > Does it have any sense or am i wrong/missing something ? > > Well - the query might well be pre-parsed which means it wouldn't notice any > updated stats. Can you provide an example of your code? It's nothing particular strange. It's something like : result record; for result in select rai, tem from data where (codice LIKE cod_staz and ora > orain and ora <= orafin) loop -- do some calculation end loop; If i do the same select with pgsql it runs much faster. Is to be noticed that the calculations it does in the loop are just "light", nothing that should matter. I'll just investigate about this strange behaviour. Thanks ! Ciao ! From pgsql-performance-owner@postgresql.org Mon Nov 18 10:08:36 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3869F47580B for ; Mon, 18 Nov 2002 10:08:36 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A43E1476376 for ; Mon, 18 Nov 2002 10:08:30 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAIF3YhR029170; Mon, 18 Nov 2002 10:03:34 -0500 (EST) To: Stephan Szabo Cc: Nikk Anderson , pgsql-performance@postgresql.org Subject: Re: selects from large tables In-reply-to: <20021118045236.A49278-100000@megazone23.bigpanda.com> References: <20021118045236.A49278-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Mon, 18 Nov 2002 05:02:03 -0800" Date: Mon, 18 Nov 2002 10:03:33 -0500 Message-ID: <29169.1037631813@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/126 X-Sequence-Number: 284 Stephan Szabo writes: > On Mon, 18 Nov 2002, Nikk Anderson wrote: >> Any ideas on how we can select data more quickly from large tables? > Are these row estimates realistic? Showing EXPLAIN ANALYZE results would be much more useful than just EXPLAIN. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 18 10:31:35 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3F5184758F1 for ; Mon, 18 Nov 2002 10:31:34 -0500 (EST) Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id 7CE5A474E53 for ; Mon, 18 Nov 2002 10:31:31 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Mon, 18 Nov 2002 15:31:35 -0000 Message-ID: From: Nikk Anderson To: 'Stephan Szabo' Cc: pgsql-performance@postgresql.org Subject: Re: selects from large tables Date: Mon, 18 Nov 2002 15:31:34 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C28F17.93BAFC40" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/127 X-Sequence-Number: 285 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C28F17.93BAFC40 Content-Type: text/plain; charset="iso-8859-1" Hi, Thanks for the reply Stephen, the data is 'somewhat' realistic..... The data in the table is actually synthetic, but the structure is the same as our live system, and the queries are similar to those we actually carry out. As the data was synthetic there was a bit of repetition (19 million rows of repetition!! ) of the item used in the where clause, meaning that most of the table was returned by the queries - oops! So, I have done is some more realistic queries from our live system, and put the time it takes, and the explain results. Just to note that the explain's estimated number of rows is way out - its guesses are way too low. Typically a normal query on our live system returns between 200 and 30000 rows depending on the reports a user wants to generate. In prior testing, we noted that using SELECT COUNT( .. was slower than other queries, which is why we though we would test counts first. Here are some more realistic results, which still take a fair whack of time........ Starting query 0 Query 0: SELECT * FROM xx WHERE time BETWEEN '2002-11-17 14:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id = 335 Time taken = 697 ms Index Scan using http_timejobid on xx (cost=0.00..17.01 rows=4 width=57) This query returns 500 rows of data Starting query 1 Query 1: SELECT * FROM xx WHERE time BETWEEN '2002-11-11 14:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id = 335 Time taken = 15 seconds Index Scan using http_timejobid on xx (cost=0.00..705.57 rows=175 width=57) This query return 3582 rows Starting query 2 Query 2: SELECT * FROM xx WHERE time BETWEEN '2002-10-19 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id = 335; Time taken = 65 seconds Index Scan using http_timejobid on xx (cost=0.00..3327.55 rows=832 width=57) This query returns 15692 rows Starting query 3 Query 3: SELECT * FROM xx_result WHERE time BETWEEN '2002-08-20 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id = 335; Time taken = 241 seconds Index Scan using http_timejobid on xx (cost=0.00..10111.36 rows=2547 width=57) This query returns 48768 rows Cheers Nikk -----Original Message----- From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com] Sent: 18 November 2002 13:02 To: Nikk Anderson Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] selects from large tables On Mon, 18 Nov 2002, Nikk Anderson wrote: > Any ideas on how we can select data more quickly from large tables? Are these row estimates realistic? It's estimating nearly 20 million rows to be returned by some of the queries (unless I'm misreading the number - possible since it's 5am here). At that point you almost certainly want to be using a cursor rather than plain queries since even a small width result (say 50 bytes) gives a very large (1 gig) result set. > - Queries and explain plans > > select count(*) from table_name; > NOTICE: QUERY PLAN: > Aggregate (cost=488700.65..488700.65 rows=1 width=0) > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=0) > > hawkdb=# explain select count(job_id) from table_name; > NOTICE: QUERY PLAN: > Aggregate (cost=488700.65..488700.65 rows=1 width=4) > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=4) > > hawkdb=# explain select * from table_name; > NOTICE: QUERY PLAN: > Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=57) > > hawkdb=# explain select count(*) from table_name where job_id = 13; > NOTICE: QUERY PLAN: > Aggregate (cost=537874.18..537874.18 rows=1 width=0) > -> Seq Scan on table_name (cost=0.00..488700.65 rows=19669412 width=0) > > hawkdb=# explain select * from table_name where job_id = 13; > NOTICE: QUERY PLAN: > Seq Scan on http_result (cost=0.00..488700.65 rows=19669412 width=57) > > hawkdb=# explain select * from table_name where job_id = 1; > NOTICE: QUERY PLAN: > Index Scan using http_result_pk on table_name (cost=0.00..5.01 rows=1 > width=57) > > hawkdb=#explain select * from table_name where time > '2002-10-10'; > NOTICE: QUERY PLAN: > Seq Scan on table_name (cost=0.00..488700.65 rows=19649743 width=57) > > hawkdb=# explain select * from http_result where time < '2002-10-10'; > NOTICE: QUERY PLAN: > Index Scan using table_name_time on table_name (cost=0.00..75879.17 > rows=19669 width=57) ------_=_NextPart_001_01C28F17.93BAFC40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] selects from large tables

Hi,
Thanks for the reply Stephen, the data is 'somewhat' rea= listic.....

The data in the table is actually synthetic, but the stru= cture is the same as our live system, and the queries are similar to those = we actually carry out. 

As the data was synthetic there was a bit of repetition (= 19 million rows of repetition!! ) of the item used in the where clause, mea= ning that most of the table was returned by the queries - oops!  So, I= have done is some more realistic queries from our live system, and put the= time it takes, and the explain results.  Just to note that the explai= n's estimated number of rows is way out - its guesses are way too low.

Typically a normal query on our live system returns betwe= en 200 and 30000 rows depending on the reports a user wants to generate.&nb= sp; In prior testing, we noted that using SELECT COUNT( ..   was = slower than other queries, which is why we though we would test counts firs= t.


Here are some more realistic results, which still take a = fair whack of time........


Starting query 0
Query 0: SELECT * FROM xx WHERE time BETWEEN '2002-11-17= 14:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id =3D 335
Time taken =3D 697 ms
Index Scan using http_timejobid on xx  (cost=3D0.00= ..17.01 rows=3D4 width=3D57)
This query returns 500 rows of data


Starting query 1
Query 1: SELECT * FROM xx WHERE time BETWEEN '2002-11-11= 14:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id =3D 335
Time taken =3D 15 seconds
Index Scan using http_timejobid on xx  (cost=3D0.00= ..705.57 rows=3D175 width=3D57)
This query return 3582 rows

Starting query 2
Query 2: SELECT * FROM xx WHERE time BETWEEN '2002-10-19= 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id =3D 335;
Time taken =3D 65 seconds
Index Scan using http_timejobid on xx  (cost=3D0.00= ..3327.55 rows=3D832 width=3D57)
This query returns 15692 rows

Starting query 3
Query 3: SELECT * FROM xx_result WHERE time BETWEEN '200= 2-08-20 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id =3D 335;

Time taken =3D 241 seconds
Index Scan using http_timejobid on xx  (cost=3D0.00= ..10111.36 rows=3D2547 width=3D57)
This query returns 48768 rows


Cheers

Nikk




-----Original Message-----
From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com]
Sent: 18 November 2002 13:02
To: Nikk Anderson
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] selects from large tables



On Mon, 18 Nov 2002, Nikk Anderson wrote:

> Any ideas on how we can select data more quickly fro= m large tables?

Are these row estimates realistic? It's estimating nearly= 20 million rows
to be returned by some of the queries (unless I'm misrea= ding the
number - possible since it's 5am here).  At that po= int you almost
certainly want to be using a cursor rather than plain qu= eries since even a
small width result (say 50 bytes) gives a very large (1 = gig) result set.

> - Queries and explain plans
>
> select count(*) from table_name;
> NOTICE:  QUERY PLAN:
> Aggregate  (cost=3D488700.65..488700.65 rows= =3D1 width=3D0)
>   ->  Seq Scan on table_name = ; (cost=3D0.00..439527.12 rows=3D19669412 width=3D0)
>
> hawkdb=3D# explain select count(job_id) from table_= name;
> NOTICE:  QUERY PLAN:
> Aggregate  (cost=3D488700.65..488700.65 rows= =3D1 width=3D4)
>   ->  Seq Scan on table_name = ; (cost=3D0.00..439527.12 rows=3D19669412 width=3D4)
>
> hawkdb=3D# explain select * from table_name;
> NOTICE:  QUERY PLAN:
> Seq Scan on table_name  (cost=3D0.00..439527.1= 2 rows=3D19669412 width=3D57)
>
> hawkdb=3D# explain select count(*) from table_name = where job_id =3D 13;
> NOTICE:  QUERY PLAN:
> Aggregate  (cost=3D537874.18..537874.18 rows= =3D1 width=3D0)
>   ->  Seq Scan on table_name = ; (cost=3D0.00..488700.65 rows=3D19669412 width=3D0)
>
> hawkdb=3D# explain select * from table_name where j= ob_id =3D 13;
> NOTICE:  QUERY PLAN:
> Seq Scan on http_result  (cost=3D0.00..488700.= 65 rows=3D19669412 width=3D57)
>
> hawkdb=3D# explain select * from table_name where j= ob_id =3D 1;
> NOTICE:  QUERY PLAN:
> Index Scan using http_result_pk on table_name = (cost=3D0.00..5.01 rows=3D1
> width=3D57)
>
> hawkdb=3D#explain select * from table_name where ti= me > '2002-10-10';
> NOTICE:  QUERY PLAN:
> Seq Scan on table_name  (cost=3D0.00..488700.6= 5 rows=3D19649743 width=3D57)
>
> hawkdb=3D# explain select * from http_result where = time < '2002-10-10';
> NOTICE:  QUERY PLAN:
> Index Scan using table_name_time on table_name = ; (cost=3D0.00..75879.17
> rows=3D19669 width=3D57)

------_=_NextPart_001_01C28F17.93BAFC40-- From pgsql-performance-owner@postgresql.org Mon Nov 18 10:36:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0B29A47580B for ; Mon, 18 Nov 2002 10:36:08 -0500 (EST) Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id 04734474E53 for ; Mon, 18 Nov 2002 10:36:06 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Mon, 18 Nov 2002 15:36:10 -0000 Message-ID: From: Nikk Anderson To: 'Tom Lane' Cc: pgsql-performance@postgresql.org Subject: Re: selects from large tables Date: Mon, 18 Nov 2002 15:36:08 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C28F18.37494150" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/128 X-Sequence-Number: 286 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C28F18.37494150 Content-Type: text/plain; charset="iso-8859-1" Hi, Unfortunately explain analyze does not work on our postgres version (7.1) ? I think I will download and compile 7.2, and try to compile in 64bit mode to see if that helps improve performance. Cheers Nikk -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: 18 November 2002 15:04 To: Stephan Szabo Cc: Nikk Anderson; pgsql-performance@postgresql.org Subject: Re: [PERFORM] selects from large tables Stephan Szabo writes: > On Mon, 18 Nov 2002, Nikk Anderson wrote: >> Any ideas on how we can select data more quickly from large tables? > Are these row estimates realistic? Showing EXPLAIN ANALYZE results would be much more useful than just EXPLAIN. regards, tom lane ------_=_NextPart_001_01C28F18.37494150 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] selects from large tables

Hi,

Unfortunately explain analyze does not work on our postgr= es version (7.1) ?

I think I will download and compile 7.2, and try to compi= le in 64bit mode to see if that helps improve performance.

Cheers

Nikk


-----Original Message-----
From: Tom Lane [mai= lto:tgl@sss.pgh.pa.us]
Sent: 18 November 2002 15:04
To: Stephan Szabo
Cc: Nikk Anderson; pgsql-performance@postgresql.org
Subject: Re: [PERFORM] selects from large tables


Stephan Szabo <sszabo@megazone23.bigpanda.com> writ= es:
> On Mon, 18 Nov 2002, Nikk Anderson wrote:

>> Any ideas on how we can select data more quickly= from large tables?

> Are these row estimates realistic?

Showing EXPLAIN ANALYZE results would be much more useful= than just
EXPLAIN.

             = ;           reg= ards, tom lane

------_=_NextPart_001_01C28F18.37494150-- From pgsql-performance-owner@postgresql.org Mon Nov 18 10:43:01 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7FF48475DB4 for ; Mon, 18 Nov 2002 10:43:00 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id E34A3476029 for ; Mon, 18 Nov 2002 10:42:57 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18Do3C-00013y-00 for ; Mon, 18 Nov 2002 10:43:02 -0500 Date: Mon, 18 Nov 2002 10:43:02 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: selects from large tables Message-ID: <20021118104302.F30738@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from Nikk.Anderson@parallel.ltd.uk on Mon, Nov 18, 2002 at 03:36:08PM -0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/129 X-Sequence-Number: 287 On Mon, Nov 18, 2002 at 03:36:08PM -0000, Nikk Anderson wrote: > Hi, > > Unfortunately explain analyze does not work on our postgres version (7.1) ? No, it doesn't. > I think I will download and compile 7.2, and try to compile in 64bit mode to > see if that helps improve performance. I have seen something like a 40% improvement in performance from 7.1 to 7.2 on Solaris 7 in my tests. There are some problems with the 64 bit compilation, by the way, so make sure that you check out the FAQ and test carefully. You need to make some modifications of the source files in order to avoid some buggly libraries on Solaris. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Mon Nov 18 10:58:47 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5F9284761D2 for ; Mon, 18 Nov 2002 10:58:46 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id 7BC8D4761D7 for ; Mon, 18 Nov 2002 10:58:45 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id gAIFkC112590; Mon, 18 Nov 2002 10:46:12 -0500 Message-ID: <3DD90B43.306@clearmetrix.com> Date: Mon, 18 Nov 2002 10:46:11 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Nikk Anderson Cc: "'Stephan Szabo'" , pgsql-performance@postgresql.org Subject: Re: selects from large tables References: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/130 X-Sequence-Number: 288 Nikk: Are you doing vaccums on these tables? I was under the understanding that the estimated row count should be close to the real row count returned, and when it is not (as it looks in your case), the primary reason for the disconnect is that the stats for the tables are out-of-date. Since it used the indexes, I am not sure if the old stats are causing any issues, but I suspect they are not helping. Also, do you do any clustering of the data (since the queries are mostly time limited)? I am wondering if the system is doing lots of seeks to get the data (implying that the data is all over the disk and not clustered). Charlie Nikk Anderson wrote: > Hi, > Thanks for the reply Stephen, the data is 'somewhat' realistic..... > > The data in the table is actually synthetic, but the structure is the > same as our live system, and the queries are similar to those we > actually carry out. > > As the data was synthetic there was a bit of repetition (19 million > rows of repetition!! ) of the item used in the where clause, meaning > that most of the table was returned by the queries - oops! So, I have > done is some more realistic queries from our live system, and put the > time it takes, and the explain results. Just to note that the > explain's estimated number of rows is way out - its guesses are way > too low. > > Typically a normal query on our live system returns between 200 and > 30000 rows depending on the reports a user wants to generate. In > prior testing, we noted that using SELECT COUNT( .. was slower than > other queries, which is why we though we would test counts first. > > > Here are some more realistic results, which still take a fair whack of > time........ > > > Starting query 0 > Query 0: SELECT * FROM xx WHERE time BETWEEN '2002-11-17 14:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335 > Time taken = 697 ms > Index Scan using http_timejobid on xx (cost=0.00..17.01 rows=4 width=57) > This query returns 500 rows of data > > > Starting query 1 > Query 1: SELECT * FROM xx WHERE time BETWEEN '2002-11-11 14:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335 > Time taken = 15 seconds > Index Scan using http_timejobid on xx (cost=0.00..705.57 rows=175 > width=57) > This query return 3582 rows > > Starting query 2 > Query 2: SELECT * FROM xx WHERE time BETWEEN '2002-10-19 15:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335; > Time taken = 65 seconds > Index Scan using http_timejobid on xx (cost=0.00..3327.55 rows=832 > width=57) > This query returns 15692 rows > > Starting query 3 > Query 3: SELECT * FROM xx_result WHERE time BETWEEN '2002-08-20 > 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id = 335; > > Time taken = 241 seconds > Index Scan using http_timejobid on xx (cost=0.00..10111.36 rows=2547 > width=57) > This query returns 48768 rows > > > Cheers > > Nikk > > > > > -----Original Message----- > From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com] > Sent: 18 November 2002 13:02 > To: Nikk Anderson > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] selects from large tables > > > > On Mon, 18 Nov 2002, Nikk Anderson wrote: > > > Any ideas on how we can select data more quickly from large tables? > > Are these row estimates realistic? It's estimating nearly 20 million rows > to be returned by some of the queries (unless I'm misreading the > number - possible since it's 5am here). At that point you almost > certainly want to be using a cursor rather than plain queries since even a > small width result (say 50 bytes) gives a very large (1 gig) result set. > > > - Queries and explain plans > > > > select count(*) from table_name; > > NOTICE: QUERY PLAN: > > Aggregate (cost=488700.65..488700.65 rows=1 width=0) > > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 > width=0) > > > > hawkdb=# explain select count(job_id) from table_name; > > NOTICE: QUERY PLAN: > > Aggregate (cost=488700.65..488700.65 rows=1 width=4) > > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 > width=4) > > > > hawkdb=# explain select * from table_name; > > NOTICE: QUERY PLAN: > > Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=57) > > > > hawkdb=# explain select count(*) from table_name where job_id = 13; > > NOTICE: QUERY PLAN: > > Aggregate (cost=537874.18..537874.18 rows=1 width=0) > > -> Seq Scan on table_name (cost=0.00..488700.65 rows=19669412 > width=0) > > > > hawkdb=# explain select * from table_name where job_id = 13; > > NOTICE: QUERY PLAN: > > Seq Scan on http_result (cost=0.00..488700.65 rows=19669412 width=57) > > > > hawkdb=# explain select * from table_name where job_id = 1; > > NOTICE: QUERY PLAN: > > Index Scan using http_result_pk on table_name (cost=0.00..5.01 rows=1 > > width=57) > > > > hawkdb=#explain select * from table_name where time > '2002-10-10'; > > NOTICE: QUERY PLAN: > > Seq Scan on table_name (cost=0.00..488700.65 rows=19649743 width=57) > > > > hawkdb=# explain select * from http_result where time < '2002-10-10'; > > NOTICE: QUERY PLAN: > > Index Scan using table_name_time on table_name (cost=0.00..75879.17 > > rows=19669 width=57) > -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com From pgsql-performance-owner@postgresql.org Mon Nov 18 11:27:05 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6B992475FD4 for ; Mon, 18 Nov 2002 11:27:01 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0A85E475F64 for ; Mon, 18 Nov 2002 11:27:00 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAIGPRhR029736; Mon, 18 Nov 2002 11:25:27 -0500 (EST) To: "Charles H. Woloszynski" Cc: Nikk Anderson , "'Stephan Szabo'" , pgsql-performance@postgresql.org Subject: Re: selects from large tables In-reply-to: <3DD90B43.306@clearmetrix.com> References: <3DD90B43.306@clearmetrix.com> Comments: In-reply-to "Charles H. Woloszynski" message dated "Mon, 18 Nov 2002 10:46:11 -0500" Date: Mon, 18 Nov 2002 11:25:27 -0500 Message-ID: <29735.1037636727@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/131 X-Sequence-Number: 289 "Charles H. Woloszynski" writes: > Are you doing vaccums on these tables? I was under the understanding > that the estimated row count should be close to the real row count > returned, and when it is not (as it looks in your case), the primary > reason for the disconnect is that the stats for the tables are > out-of-date. The fact that he's using 7.1 doesn't help any; the statistics mechanisms in 7.1 are pretty weak compared to 7.2. > Also, do you do any clustering of the data (since the queries are mostly > time limited)? I am wondering if the system is doing lots of seeks to > get the data (implying that the data is all over the disk and not > clustered). It would also be interesting to try a two-column index ordered the other way (timestamp as the major sort key instead of ID). Can't tell if that will be a win without more info about the data properties, but it's worth looking at. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 18 11:32:53 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D686047611B for ; Mon, 18 Nov 2002 11:32:46 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 1734B476033 for ; Mon, 18 Nov 2002 11:32:42 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D5862D60D; Mon, 18 Nov 2002 08:32:46 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id CB3405C02; Mon, 18 Nov 2002 08:32:46 -0800 (PST) Date: Mon, 18 Nov 2002 08:32:46 -0800 (PST) From: Stephan Szabo To: Nikk Anderson Cc: Subject: Re: selects from large tables In-Reply-To: Message-ID: <20021118083059.P51208-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/132 X-Sequence-Number: 290 On Mon, 18 Nov 2002, Nikk Anderson wrote: > Hi, > Thanks for the reply Stephen, the data is 'somewhat' realistic..... Tom's said most of what I would have, except that if you've got a wide variation based on job_id you may want to change the statistics gathering defaults for that column with ALTER TABLE ALTER COLUMN SET STATISTICS when you get to 7.2. From pgsql-performance-owner@postgresql.org Mon Nov 18 11:33:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8F9364762ED for ; Mon, 18 Nov 2002 11:32:56 -0500 (EST) Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id 5B0C64760B0 for ; Mon, 18 Nov 2002 11:32:46 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Mon, 18 Nov 2002 16:32:50 -0000 Message-ID: From: Nikk Anderson To: "'Charles H. Woloszynski'" Cc: pgsql-performance@postgresql.org Subject: Re: selects from large tables Date: Mon, 18 Nov 2002 16:32:49 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C28F20.224B2270" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/133 X-Sequence-Number: 291 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C28F20.224B2270 Content-Type: text/plain; charset="iso-8859-1" Hi Charlie, We do a vacuum analyze every night at midnight. I thought that perhaps the analyzing was not being done correctly, so I manually did a vacuum analyze and the estimated row counts were way still out. I will look into clustering the data and see what effect that may have. Thanks Nikk -----Original Message----- From: Charles H. Woloszynski [mailto:chw@clearmetrix.com] Sent: 18 November 2002 15:46 To: Nikk Anderson Cc: 'Stephan Szabo'; pgsql-performance@postgresql.org Subject: Re: [PERFORM] selects from large tables Nikk: Are you doing vaccums on these tables? I was under the understanding that the estimated row count should be close to the real row count returned, and when it is not (as it looks in your case), the primary reason for the disconnect is that the stats for the tables are out-of-date. Since it used the indexes, I am not sure if the old stats are causing any issues, but I suspect they are not helping. Also, do you do any clustering of the data (since the queries are mostly time limited)? I am wondering if the system is doing lots of seeks to get the data (implying that the data is all over the disk and not clustered). Charlie Nikk Anderson wrote: > Hi, > Thanks for the reply Stephen, the data is 'somewhat' realistic..... > > The data in the table is actually synthetic, but the structure is the > same as our live system, and the queries are similar to those we > actually carry out. > > As the data was synthetic there was a bit of repetition (19 million > rows of repetition!! ) of the item used in the where clause, meaning > that most of the table was returned by the queries - oops! So, I have > done is some more realistic queries from our live system, and put the > time it takes, and the explain results. Just to note that the > explain's estimated number of rows is way out - its guesses are way > too low. > > Typically a normal query on our live system returns between 200 and > 30000 rows depending on the reports a user wants to generate. In > prior testing, we noted that using SELECT COUNT( .. was slower than > other queries, which is why we though we would test counts first. > > > Here are some more realistic results, which still take a fair whack of > time........ > > > Starting query 0 > Query 0: SELECT * FROM xx WHERE time BETWEEN '2002-11-17 14:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335 > Time taken = 697 ms > Index Scan using http_timejobid on xx (cost=0.00..17.01 rows=4 width=57) > This query returns 500 rows of data > > > Starting query 1 > Query 1: SELECT * FROM xx WHERE time BETWEEN '2002-11-11 14:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335 > Time taken = 15 seconds > Index Scan using http_timejobid on xx (cost=0.00..705.57 rows=175 > width=57) > This query return 3582 rows > > Starting query 2 > Query 2: SELECT * FROM xx WHERE time BETWEEN '2002-10-19 15:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335; > Time taken = 65 seconds > Index Scan using http_timejobid on xx (cost=0.00..3327.55 rows=832 > width=57) > This query returns 15692 rows > > Starting query 3 > Query 3: SELECT * FROM xx_result WHERE time BETWEEN '2002-08-20 > 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id = 335; > > Time taken = 241 seconds > Index Scan using http_timejobid on xx (cost=0.00..10111.36 rows=2547 > width=57) > This query returns 48768 rows > > > Cheers > > Nikk > > > > > -----Original Message----- > From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com] > Sent: 18 November 2002 13:02 > To: Nikk Anderson > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] selects from large tables > > > > On Mon, 18 Nov 2002, Nikk Anderson wrote: > > > Any ideas on how we can select data more quickly from large tables? > > Are these row estimates realistic? It's estimating nearly 20 million rows > to be returned by some of the queries (unless I'm misreading the > number - possible since it's 5am here). At that point you almost > certainly want to be using a cursor rather than plain queries since even a > small width result (say 50 bytes) gives a very large (1 gig) result set. > > > - Queries and explain plans > > > > select count(*) from table_name; > > NOTICE: QUERY PLAN: > > Aggregate (cost=488700.65..488700.65 rows=1 width=0) > > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 > width=0) > > > > hawkdb=# explain select count(job_id) from table_name; > > NOTICE: QUERY PLAN: > > Aggregate (cost=488700.65..488700.65 rows=1 width=4) > > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 > width=4) > > > > hawkdb=# explain select * from table_name; > > NOTICE: QUERY PLAN: > > Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=57) > > > > hawkdb=# explain select count(*) from table_name where job_id = 13; > > NOTICE: QUERY PLAN: > > Aggregate (cost=537874.18..537874.18 rows=1 width=0) > > -> Seq Scan on table_name (cost=0.00..488700.65 rows=19669412 > width=0) > > > > hawkdb=# explain select * from table_name where job_id = 13; > > NOTICE: QUERY PLAN: > > Seq Scan on http_result (cost=0.00..488700.65 rows=19669412 width=57) > > > > hawkdb=# explain select * from table_name where job_id = 1; > > NOTICE: QUERY PLAN: > > Index Scan using http_result_pk on table_name (cost=0.00..5.01 rows=1 > > width=57) > > > > hawkdb=#explain select * from table_name where time > '2002-10-10'; > > NOTICE: QUERY PLAN: > > Seq Scan on table_name (cost=0.00..488700.65 rows=19649743 width=57) > > > > hawkdb=# explain select * from http_result where time < '2002-10-10'; > > NOTICE: QUERY PLAN: > > Index Scan using table_name_time on table_name (cost=0.00..75879.17 > > rows=19669 width=57) > -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org ------_=_NextPart_001_01C28F20.224B2270 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] selects from large tables

Hi Charlie,
We do a vacuum analyze every night at midnight.  I = thought that perhaps the analyzing was not being done correctly, so I manua= lly did a vacuum analyze and the estimated row counts were way still out.&n= bsp;

I will look into clustering the data and see what effect = that may have.

Thanks

Nikk


-----Original Message-----
From: Charles H. Woloszynski [mailto:chw@clearmetrix.com]
Sent: 18 November 2002 15:46
To: Nikk Anderson
Cc: 'Stephan Szabo'; pgsql-performance@postgresql.org
Subject: Re: [PERFORM] selects from large tables


Nikk:

Are you doing vaccums on these tables?  I was under = the understanding
that the estimated row count should be close to the real= row count
returned, and when it is not (as it looks in your case),= the primary
reason for the disconnect is that the stats for the tabl= es are
out-of-date. 

Since it used the indexes, I am not sure if the old stats= are causing
any issues, but I suspect they are not helping. 

Also, do you do any clustering of the data (since the que= ries are mostly
time limited)?  I am wondering if the system is doi= ng lots of seeks to
get the data (implying that the data is all over the dis= k and not
clustered). 

Charlie

Nikk Anderson wrote:

> Hi,
> Thanks for the reply Stephen, the data is 'somewhat= ' realistic.....
>
> The data in the table is actually synthetic, but th= e structure is the
> same as our live system, and the queries are simila= r to those we
> actually carry out.
>
> As the data was synthetic there was a bit of repeti= tion (19 million
> rows of repetition!! ) of the item used in the wher= e clause, meaning
> that most of the table was returned by the queries = - oops!  So, I have
> done is some more realistic queries from our live s= ystem, and put the
> time it takes, and the explain results.  Just = to note that the
> explain's estimated number of rows is way out - its= guesses are way
> too low.
>
> Typically a normal query on our live system returns= between 200 and
> 30000 rows depending on the reports a user wants to= generate.  In
> prior testing, we noted that using SELECT COUNT( ..=    was slower than
> other queries, which is why we though we would test= counts first.
>
>
> Here are some more realistic results, which still t= ake a fair whack of
> time........
>
>
> Starting query 0
> Query 0: SELECT * FROM xx WHERE time BETWEEN '2002-= 11-17 14:08:58.021'
> AND '2002-11-18 14:08:58.021' AND job_id =3D 335
> Time taken =3D 697 ms
> Index Scan using http_timejobid on xx  (cost= =3D0.00..17.01 rows=3D4 width=3D57)
> This query returns 500 rows of data
>
>
> Starting query 1
> Query 1: SELECT * FROM xx WHERE time BETWEEN '2002-= 11-11 14:08:58.021'
> AND '2002-11-18 14:08:58.021' AND job_id =3D 335
> Time taken =3D 15 seconds
> Index Scan using http_timejobid on xx  (cost= =3D0.00..705.57 rows=3D175
> width=3D57)
> This query return 3582 rows
>
> Starting query 2
> Query 2: SELECT * FROM xx WHERE time BETWEEN '2002-= 10-19 15:08:58.021'
> AND '2002-11-18 14:08:58.021' AND job_id =3D 335;
> Time taken =3D 65 seconds
> Index Scan using http_timejobid on xx  (cost= =3D0.00..3327.55 rows=3D832
> width=3D57)
> This query returns 15692 rows
>
> Starting query 3
> Query 3: SELECT * FROM xx_result WHERE time BETWEEN= '2002-08-20
> 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job= _id =3D 335;
>
> Time taken =3D 241 seconds
> Index Scan using http_timejobid on xx  (cost= =3D0.00..10111.36 rows=3D2547
> width=3D57)
> This query returns 48768 rows
>
>
> Cheers
>
> Nikk
>
>
>
>
> -----Original Message-----
> From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com]
> Sent: 18 November 2002 13:02
> To: Nikk Anderson
> Cc: pgsql-performance@postgresql.org
> Subject: Re: [PERFORM] selects from large tables
>
>
>
> On Mon, 18 Nov 2002, Nikk Anderson wrote:
>
> > Any ideas on how we can select data more quick= ly from large tables?
>
> Are these row estimates realistic? It's estimating = nearly 20 million rows
> to be returned by some of the queries (unless I'm m= isreading the
> number - possible since it's 5am here).  At th= at point you almost
> certainly want to be using a cursor rather than pla= in queries since even a
> small width result (say 50 bytes) gives a very larg= e (1 gig) result set.
>
> > - Queries and explain plans
> >
> > select count(*) from table_name;
> > NOTICE:  QUERY PLAN:
> > Aggregate  (cost=3D488700.65..488700.65 r= ows=3D1 width=3D0)
> >   ->  Seq Scan on table_name=   (cost=3D0.00..439527.12 rows=3D19669412
> width=3D0)
> >
> > hawkdb=3D# explain select count(job_id) from t= able_name;
> > NOTICE:  QUERY PLAN:
> > Aggregate  (cost=3D488700.65..488700.65 r= ows=3D1 width=3D4)
> >   ->  Seq Scan on table_name=   (cost=3D0.00..439527.12 rows=3D19669412
> width=3D4)
> >
> > hawkdb=3D# explain select * from table_name;
> > NOTICE:  QUERY PLAN:
> > Seq Scan on table_name  (cost=3D0.00..439= 527.12 rows=3D19669412 width=3D57)
> >
> > hawkdb=3D# explain select count(*) from table_= name where job_id =3D 13;
> > NOTICE:  QUERY PLAN:
> > Aggregate  (cost=3D537874.18..537874.18 r= ows=3D1 width=3D0)
> >   ->  Seq Scan on table_name=   (cost=3D0.00..488700.65 rows=3D19669412
> width=3D0)
> >
> > hawkdb=3D# explain select * from table_name wh= ere job_id =3D 13;
> > NOTICE:  QUERY PLAN:
> > Seq Scan on http_result  (cost=3D0.00..48= 8700.65 rows=3D19669412 width=3D57)
> >
> > hawkdb=3D# explain select * from table_name wh= ere job_id =3D 1;
> > NOTICE:  QUERY PLAN:
> > Index Scan using http_result_pk on table_name&= nbsp; (cost=3D0.00..5.01 rows=3D1
> > width=3D57)
> >
> > hawkdb=3D#explain select * from table_name whe= re time > '2002-10-10';
> > NOTICE:  QUERY PLAN:
> > Seq Scan on table_name  (cost=3D0.00..488= 700.65 rows=3D19649743 width=3D57)
> >
> > hawkdb=3D# explain select * from http_result w= here time < '2002-10-10';
> > NOTICE:  QUERY PLAN:
> > Index Scan using table_name_time on table_name=   (cost=3D0.00..75879.17
> > rows=3D19669 width=3D57)
>

--


Charles H. Woloszynski

ClearMetrix, Inc.
115 Research Drive
Bethlehem, PA 18015

tel: 610-419-2210 x400
fax: 240-371-3256
web: www.clearmetrix.com





---------------------------(end of broadcast)------------= ---------------
TIP 1: subscribe and unsubscribe commands go to majordom= o@postgresql.org

------_=_NextPart_001_01C28F20.224B2270-- From pgsql-performance-owner@postgresql.org Mon Nov 18 11:36:48 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5070147634D for ; Mon, 18 Nov 2002 11:36:47 -0500 (EST) Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id 8F164476009 for ; Mon, 18 Nov 2002 11:36:40 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Mon, 18 Nov 2002 16:36:45 -0000 Message-ID: From: Nikk Anderson To: 'Tom Lane' Cc: pgsql-performance@postgresql.org Subject: Re: selects from large tables Date: Mon, 18 Nov 2002 16:36:44 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C28F20.AE237540" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/134 X-Sequence-Number: 292 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C28F20.AE237540 Content-Type: text/plain; charset="iso-8859-1" Hi Tom, Yes, we should upgrade to 7.2 soon, its just that as it is a live system running 24x7 we are careful about upgrading core components so we do not disrupt our data collection agents too much. Here is some table info, we currently index by time then ID. Generally, data will be selected by ID, then time range. Clustering may help on this. Attribute | Type | Modifier -----------------+--------------------------+---------- job_id | integer | not null server_id | integer | not null time | timestamp with time zone | not null availability | boolean | connection_time | integer | dns_setup | integer | server_response | integer | frontpage_size | integer | frontpage_time | integer | transfer_size | integer | transfer_time | integer | error_id | integer | redirect_time | integer | polling_id | integer | not null Indices: http_result_pk, http_timejobid Thanks Nikk -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: 18 November 2002 16:25 To: Charles H. Woloszynski Cc: Nikk Anderson; 'Stephan Szabo'; pgsql-performance@postgresql.org Subject: Re: [PERFORM] selects from large tables "Charles H. Woloszynski" writes: > Are you doing vaccums on these tables? I was under the understanding > that the estimated row count should be close to the real row count > returned, and when it is not (as it looks in your case), the primary > reason for the disconnect is that the stats for the tables are > out-of-date. The fact that he's using 7.1 doesn't help any; the statistics mechanisms in 7.1 are pretty weak compared to 7.2. > Also, do you do any clustering of the data (since the queries are mostly > time limited)? I am wondering if the system is doing lots of seeks to > get the data (implying that the data is all over the disk and not > clustered). It would also be interesting to try a two-column index ordered the other way (timestamp as the major sort key instead of ID). Can't tell if that will be a win without more info about the data properties, but it's worth looking at. regards, tom lane ------_=_NextPart_001_01C28F20.AE237540 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] selects from large tables

Hi Tom,

Yes, we should upgrade to 7.2 soon, its just that as it i= s a live system running 24x7 we are careful about upgrading core components= so we do not disrupt our data collection agents too much.

Here is some table info, we currently index by time then = ID.  Generally, data will be selected by ID, then time range.  Cl= ustering may help on this. 


    Attribute    | &nb= sp;         Type   &= nbsp;       | Modifier
-----------------+--------------------------+----------<= /FONT>
 job_id       &n= bsp;  | integer         &= nbsp;        | not null
 server_id       | in= teger           &nbs= p;      | not null
 time       &nbs= p;    | timestamp with time zone | not null
 availability    | boolean &nbs= p;            &= nbsp;   |
 connection_time | integer    &= nbsp;           &nbs= p; |
 dns_setup       | in= teger           &nbs= p;      |
 server_response | integer    &= nbsp;           &nbs= p; |
 frontpage_size  | integer   &n= bsp;            = ;  |
 frontpage_time  | integer   &n= bsp;            = ;  |
 transfer_size   | integer  &nb= sp;            =    |
 transfer_time   | integer  &nb= sp;            =    |
 error_id       = | integer           = ;       |
 redirect_time   | integer  &nb= sp;            =    |
 polling_id      | integer=             &nb= sp;     | not null
Indices: http_result_pk,
         http_ti= mejobid

Thanks

Nikk


-----Original Message-----
From: Tom Lane [mai= lto:tgl@sss.pgh.pa.us]
Sent: 18 November 2002 16:25
To: Charles H. Woloszynski
Cc: Nikk Anderson; 'Stephan Szabo'; pgsql-performance@po= stgresql.org
Subject: Re: [PERFORM] selects from large tables


"Charles H. Woloszynski" <chw@clearmetrix.co= m> writes:
> Are you doing vaccums on these tables?  I was = under the understanding
> that the estimated row count should be close to the= real row count
> returned, and when it is not (as it looks in your c= ase), the primary
> reason for the disconnect is that the stats for the= tables are
> out-of-date. 

The fact that he's using 7.1 doesn't help any; the statis= tics mechanisms
in 7.1 are pretty weak compared to 7.2.

> Also, do you do any clustering of the data (since th= e queries are mostly
> time limited)?  I am wondering if the system i= s doing lots of seeks to
> get the data (implying that the data is all over th= e disk and not
> clustered).

It would also be interesting to try a two-column index or= dered the other
way (timestamp as the major sort key instead of ID).&nbs= p; Can't tell if that
will be a win without more info about the data propertie= s, but it's
worth looking at.

             = ;           reg= ards, tom lane

------_=_NextPart_001_01C28F20.AE237540-- From pgsql-performance-owner@postgresql.org Mon Nov 18 13:48:46 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 47F95475BC3 for ; Mon, 18 Nov 2002 13:48:44 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id 9EC9E475461 for ; Mon, 18 Nov 2002 13:48:43 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id gAIIrc6P018121; Mon, 18 Nov 2002 13:53:38 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id gAIImWj29347; Mon, 18 Nov 2002 13:48:33 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id W7RLWZSM; Mon, 18 Nov 2002 13:48:32 -0500 Subject: Re: selects from large tables From: Robert Treat To: Nikk Anderson Cc: "'Tom Lane'" , pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 18 Nov 2002 13:48:32 -0500 Message-Id: <1037645312.21501.11.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/135 X-Sequence-Number: 293 You might want to check out 7.3 while your at it. It's currently planned to be released around Dec 1st, which might fit in nicely with your upgrade schedule. Robert Treat On Mon, 2002-11-18 at 11:36, Nikk Anderson wrote: > Hi Tom, > > Yes, we should upgrade to 7.2 soon, its just that as it is a live system > running 24x7 we are careful about upgrading core components so we do not > disrupt our data collection agents too much. > > Here is some table info, we currently index by time then ID. Generally, > data will be selected by ID, then time range. Clustering may help on > this. > > > Attribute | Type | Modifier > -----------------+--------------------------+---------- > job_id | integer | not null > server_id | integer | not null > time | timestamp with time zone | not null > availability | boolean | > connection_time | integer | > dns_setup | integer | > server_response | integer | > frontpage_size | integer | > frontpage_time | integer | > transfer_size | integer | > transfer_time | integer | > error_id | integer | > redirect_time | integer | > polling_id | integer | not null > Indices: http_result_pk, > http_timejobid > > Thanks > > Nikk > > > -----Original Message----- > From: Tom Lane [ mailto:tgl@sss.pgh.pa.us ] > Sent: 18 November 2002 16:25 > To: Charles H. Woloszynski > Cc: Nikk Anderson; 'Stephan Szabo'; pgsql-performance@postgresql.org > Subject: Re: [PERFORM] selects from large tables > > > "Charles H. Woloszynski" writes: > > Are you doing vaccums on these tables? I was under the understanding > > that the estimated row count should be close to the real row count > > returned, and when it is not (as it looks in your case), the primary > > reason for the disconnect is that the stats for the tables are > > out-of-date. > > The fact that he's using 7.1 doesn't help any; the statistics mechanisms > > in 7.1 are pretty weak compared to 7.2. > > > Also, do you do any clustering of the data (since the queries are > mostly > > time limited)? I am wondering if the system is doing lots of seeks to > > > get the data (implying that the data is all over the disk and not > > clustered). > > It would also be interesting to try a two-column index ordered the other > > way (timestamp as the major sort key instead of ID). Can't tell if that > > will be a win without more info about the data properties, but it's > worth looking at. > > regards, tom lane > From pgsql-hackers-owner@postgresql.org Tue Nov 19 08:22:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 49A7F475D22 for ; Mon, 18 Nov 2002 22:02:37 -0500 (EST) Received: from web13008.mail.yahoo.com (web13008.mail.yahoo.com [216.136.174.18]) by postgresql.org (Postfix) with SMTP id A9F57475D1C for ; Mon, 18 Nov 2002 22:02:36 -0500 (EST) Message-ID: <20021119030240.23442.qmail@web13008.mail.yahoo.com> Received: from [24.170.104.139] by web13008.mail.yahoo.com via HTTP; Mon, 18 Nov 2002 19:02:40 PST Date: Mon, 18 Nov 2002 19:02:40 -0800 (PST) From: Adrian Calvin Subject: Question regarding effects of Vacuum, Vacuum Analyze, and Reindex To: pgsql-hackers@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-390881357-1037674960=:22944" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/797 X-Sequence-Number: 32013 --0-390881357-1037674960=:22944 Content-Type: text/plain; charset=us-ascii To whom it may concern, I am a java developer using postgres as a DB server. Me and my development team have a product comprised of about 50 tables, with about 10,000 records in the largest table. We have looked for concrete answers in books and the web for solutions to several problems that are plaguing us. Now we look to the source. Issue #1 Massive deletion of records. Q - If many (eg hundreds) records are deleted (purposely), those records get flagged for later removal. What is the best sequence of operations to optimize the database afterwards? Is it Vacuum, Re-index, then do a Vacuum Analyze. Some of what I have read suggests that doing a vacuum without a re-index, can cause a given index to be invalid (ie entries pointing to records that do not match the index criteria). This would then suggest that doing a Vacuum Analyze would create an incorrect statistics table. Any help regarding the best maintenance policy, ramifications of mass deletions, vacuuming, and re-indexing would be most appreciated. Thanks --------------------------------- Do you Yahoo!? Yahoo! Web Hosting - Let the expert host your site --0-390881357-1037674960=:22944 Content-Type: text/html; charset=us-ascii

To whom it may concern,

I am a java developer using postgres as a DB server.  Me and my development team have a product comprised of about 50 tables, with about 10,000 records in the largest table.  We have looked for concrete answers in books and the web for solutions to several problems that are plaguing us.  Now we look to the source.

Issue #1 Massive deletion of records.

Q - If many (eg hundreds) records are deleted (purposely), those records get flagged for later removal.  What is the best sequence of operations to optimize the database afterwards?  Is it Vacuum, Re-index, then do a Vacuum Analyze.

Some of what I have read suggests that doing a vacuum without a re-index, can cause a given index to be invalid (ie entries pointing to records that do not match the index criteria).

This would then suggest that doing a Vacuum Analyze would create an incorrect statistics table.

Any help regarding the best maintenance policy, ramifications of mass deletions, vacuuming, and re-indexing would be most appreciated.  Thanks



Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site --0-390881357-1037674960=:22944-- From pgsql-performance-owner@postgresql.org Tue Nov 19 00:23:59 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F30C947592C for ; Tue, 19 Nov 2002 00:23:54 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id BFE844753A1 for ; Tue, 19 Nov 2002 00:23:53 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAJ5NvhR017929; Tue, 19 Nov 2002 00:23:57 -0500 (EST) To: Federico Cc: pgsql-performance@postgresql.org Subject: Re: for/loop performance in plpgsql ? In-reply-to: <20021118150217.GC1138@stealth.cmirl.arpal.it> References: <20021115123156.GB785@protciv14.cmirl.arpal.it> <200211151337.25980.richardh@archonet.com> <20021118150217.GC1138@stealth.cmirl.arpal.it> Comments: In-reply-to Federico message dated "Mon, 18 Nov 2002 16:02:17 +0100" Date: Tue, 19 Nov 2002 00:23:56 -0500 Message-ID: <17928.1037683436@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/136 X-Sequence-Number: 294 Federico writes: >> Well - the query might well be pre-parsed which means it wouldn't notice any >> updated stats. Can you provide an example of your code? > It's nothing particular strange. It's something like : > result record; > for result in select rai, tem > from data > where (codice LIKE cod_staz and > ora > orain and > ora <= orafin) loop Which of these names are columns of the selected tables, and which ones are plpgsql variables? The planner has to fall back to default selectivity estimates when it's looking at queries involving plpgsql variables (since it can't know their actual values in advance). I suspect your problem is related to an inaccurate default estimate. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Nov 19 04:53:20 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7ABD5475B84 for ; Tue, 19 Nov 2002 04:53:17 -0500 (EST) Received: from smtp3.libero.it (smtp3.libero.it [193.70.192.127]) by postgresql.org (Postfix) with ESMTP id 0616C475A71 for ; Tue, 19 Nov 2002 04:53:15 -0500 (EST) Received: from stealth.fepede.org (62.98.72.83) by smtp3.libero.it (6.5.028) id 3DDA093F00000C1D for pgsql-performance@postgresql.org; Tue, 19 Nov 2002 10:53:16 +0100 Received: by stealth.fepede.org (Postfix, from userid 1000) id BABCBECE1; Tue, 19 Nov 2002 10:49:26 +0100 (CET) Date: Tue, 19 Nov 2002 10:49:26 +0100 From: Federico /* juri */ Pedemonte To: pgsql-performance@postgresql.org Subject: Re: for/loop performance in plpgsql ? Message-ID: <20021119094926.GA786@stealth.fepede.org> References: <20021115123156.GB785@protciv14.cmirl.arpal.it> <200211151337.25980.richardh@archonet.com> <20021118150217.GC1138@stealth.cmirl.arpal.it> <17928.1037683436@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17928.1037683436@sss.pgh.pa.us> User-Agent: Mutt/1.3.28i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/137 X-Sequence-Number: 295 On Tue, Nov 19, 2002 at 12:23:56AM -0500, Tom Lane wrote: > > result record; > > > for result in select rai, tem > > from data > > where (codice LIKE cod_staz and > > ora > orain and > > ora <= orafin) loop > > Which of these names are columns of the selected tables, and which ones > are plpgsql variables? rai, tem, codice, ora are columns name cod_staz, orain, orafin are plpgsql variables > The planner has to fall back to default selectivity estimates when it's > looking at queries involving plpgsql variables (since it can't know > their actual values in advance). I suspect your problem is related to > an inaccurate default estimate. mmm... does it mean that i can't do anything about that ? From pgsql-performance-owner@postgresql.org Tue Nov 19 08:46:06 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E9539476622 for ; Tue, 19 Nov 2002 08:46:03 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 19203476888 for ; Tue, 19 Nov 2002 08:45:49 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAJDkdb7084698; Tue, 19 Nov 2002 08:46:40 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: [HACKERS] Question regarding effects of Vacuum, Vacuum From: Rod Taylor To: Adrian Calvin Cc: pgsql-performance@postgresql.org In-Reply-To: <20021119030240.23442.qmail@web13008.mail.yahoo.com> References: <20021119030240.23442.qmail@web13008.mail.yahoo.com> Content-Type: text/plain Organization: Message-Id: <1037713599.83738.34.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 19 Nov 2002 08:46:39 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/138 X-Sequence-Number: 296 Moving thread to pgsql-performance. On Mon, 2002-11-18 at 22:02, Adrian Calvin wrote: > Q - If many (eg hundreds) records are deleted (purposely), those > records get flagged for later removal. What is the best sequence of > operations to optimize the database afterwards? Is it Vacuum, > Re-index, then do a Vacuum Analyze. Just run a regular vacuum once for the above. If you modify 10%+ of the table (via single or multiple updates, deletes or inserts) then a vacuum analyze will be useful. Re-index when you change the tables contents a few times over. (Have deleted or updated 30k entries in a table with 10k entries at any given time). General maintenance for a dataset of that size will probably simply be a nightly vacuum, weekly vacuum analyze, and annual reindex or dump / restore (upgrades). -- Rod Taylor From pgsql-performance-owner@postgresql.org Tue Nov 19 09:08:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D599647671F for ; Tue, 19 Nov 2002 09:08:55 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 69D524766A7 for ; Tue, 19 Nov 2002 09:04:01 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAJE43hR020275; Tue, 19 Nov 2002 09:04:03 -0500 (EST) To: Federico /* juri */ Pedemonte Cc: pgsql-performance@postgresql.org Subject: Re: for/loop performance in plpgsql ? In-reply-to: <20021119094926.GA786@stealth.fepede.org> References: <20021115123156.GB785@protciv14.cmirl.arpal.it> <200211151337.25980.richardh@archonet.com> <20021118150217.GC1138@stealth.cmirl.arpal.it> <17928.1037683436@sss.pgh.pa.us> <20021119094926.GA786@stealth.fepede.org> Comments: In-reply-to Federico /* juri */ Pedemonte message dated "Tue, 19 Nov 2002 10:49:26 +0100" Date: Tue, 19 Nov 2002 09:04:02 -0500 Message-ID: <20274.1037714642@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/139 X-Sequence-Number: 297 Federico /* juri */ Pedemonte writes: > On Tue, Nov 19, 2002 at 12:23:56AM -0500, Tom Lane wrote: >> The planner has to fall back to default selectivity estimates when it's >> looking at queries involving plpgsql variables (since it can't know >> their actual values in advance). I suspect your problem is related to >> an inaccurate default estimate. > mmm... does it mean that i can't do anything about that ? A brute-force solution is to use EXECUTE so that the query is re-planned each time, with the planner seeing constants instead of variables compared to the column values. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Nov 19 09:26:08 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5B5574762FE for ; Tue, 19 Nov 2002 09:26:07 -0500 (EST) Received: from head.netsystem.cz (head.netsystem.cz [194.212.169.67]) by postgresql.org (Postfix) with ESMTP id 4DAFE475ED1 for ; Tue, 19 Nov 2002 09:26:06 -0500 (EST) Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1]) by head.netsystem.cz (Postfix) with SMTP id DA05089DF for ; Tue, 19 Nov 2002 15:26:09 +0100 (CET) Received: from netsystem.cz (novakji.netsystem.cz [192.168.200.24]) by head.netsystem.cz (Postfix) with ESMTP id C02728770 for ; Tue, 19 Nov 2002 15:26:09 +0100 (CET) Message-ID: <3DDA4A01.5040403@netsystem.cz> Date: Tue, 19 Nov 2002 15:26:09 +0100 From: Jirka Novak Organization: Net-System Liberec User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020826 X-Accept-Language: cs, en-us MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Slow DELETE with IN clausule Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/140 X-Sequence-Number: 298 Hello, does have IN operator in WHERE clausule any "undocumented" slowdown? I have tables: CREATE TABLE A ( pkA int NOT NULL num int ... ); CREATE TABLE B ( fkA int NOT NULL, ... ); ALTER TABLE B ADD CONSTRAINT FK_B_fkB_A_pkA FOREIGN KEY (fkB) REFERENCES A(pkA); I have 3000 records in A and same number in B. For each record A I have one record in B. When I do: DELETE FROM B WHERE fkB IN (SELECT pkA FROM A WHERE num=1) postgresql start working for 2-3 minutes. But select (from IN clausule) SELECT pkA FROM A WHERE num=1 end in few seconds. The slowest is this DELETE when IN SELECT returns no records. Does any have some idea whats wrong? Jirka Novak From pgsql-performance-owner@postgresql.org Tue Nov 19 09:45:08 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5037A47616E for ; Tue, 19 Nov 2002 09:45:08 -0500 (EST) Received: from anchor-post-39.mail.demon.net (anchor-post-39.mail.demon.net [194.217.242.80]) by postgresql.org (Postfix) with ESMTP id E107D475F84 for ; Tue, 19 Nov 2002 09:45:04 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-39.mail.demon.net with esmtp (Exim 3.36 #2) id 18E9ci-0001Ut-0U; Tue, 19 Nov 2002 14:45:08 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 25E6317C4A; Tue, 19 Nov 2002 14:36:33 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 8ADE017C48; Tue, 19 Nov 2002 14:36:32 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-2" From: Richard Huxton To: Jirka Novak , pgsql-performance@postgresql.org Subject: Re: Slow DELETE with IN clausule Date: Tue, 19 Nov 2002 14:36:19 +0000 User-Agent: KMail/1.4.3 References: <3DDA4A01.5040403@netsystem.cz> In-Reply-To: <3DDA4A01.5040403@netsystem.cz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211191436.19287.richardh@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/142 X-Sequence-Number: 300 On Tuesday 19 Nov 2002 2:26 pm, Jirka Novak wrote: > Hello, > > does have IN operator in WHERE clausule any "undocumented" slowdown? Yes, but I thought it was documented somewhere. It's certainly been discuss= ed=20 on the lists. Search the archives for IN/EXISTS. If you can rewrite your=20 query with an EXISTS clause you should see a big improvement. http://archives.postgresql.org --=20 Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Tue Nov 19 09:39:36 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E3932476434 for ; Tue, 19 Nov 2002 09:39:35 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 3B6B4476407 for ; Tue, 19 Nov 2002 09:39:35 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18E9XP-0004nb-00 for ; Tue, 19 Nov 2002 09:39:39 -0500 Date: Tue, 19 Nov 2002 09:39:39 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Slow DELETE with IN clausule Message-ID: <20021119093939.B17883@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <3DDA4A01.5040403@netsystem.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3DDA4A01.5040403@netsystem.cz>; from j.novak@netsystem.cz on Tue, Nov 19, 2002 at 03:26:09PM +0100 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/141 X-Sequence-Number: 299 On Tue, Nov 19, 2002 at 03:26:09PM +0100, Jirka Novak wrote: > Hello, > > does have IN operator in WHERE clausule any "undocumented" slowdown? > I have tables: It's not undocumented: http://www.ca.postgresql.org/docs/faq-english.html#4.22 A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Wed Nov 20 10:08:22 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 23101475D17 for ; Wed, 20 Nov 2002 10:08:21 -0500 (EST) Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id 539C4475D01 for ; Wed, 20 Nov 2002 10:08:17 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Wed, 20 Nov 2002 15:08:20 -0000 Message-ID: From: Nikk Anderson To: "'Charles H. Woloszynski'" Cc: pgsql-performance@postgresql.org Subject: Re: selects from large tables Date: Wed, 20 Nov 2002 15:08:11 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C290A6.A410A3C0" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/143 X-Sequence-Number: 301 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C290A6.A410A3C0 Content-Type: text/plain; charset="iso-8859-1" Hi, I tried a test cluster on a copy of our real data - all 10 million rows or so. WOW! The normal select performance improved drastically. Selecting 3 months worth of data was taking 146 seconds to retrieve. After clustering it took 7.7 seconds! We are now looking into ways we can automate clustering to keep the table up to date. The cluster itself took around 2.5 hours. As our backend systems are writing hundreds of rows of data in per minute into the table that needs clustering - will cluster handle locking the tables when dropping the old, and renaming the clustered data? What happens to the data being added to the table while cluster is running? Our backend systems may have some problems if the table does not exist when it tries to insert, and we don't want to lose any data. Thanks Nikk -----Original Message----- From: Charles H. Woloszynski [mailto:chw@clearmetrix.com] Sent: 18 November 2002 15:46 To: Nikk Anderson Cc: 'Stephan Szabo'; pgsql-performance@postgresql.org Subject: Re: [PERFORM] selects from large tables Nikk: Are you doing vaccums on these tables? I was under the understanding that the estimated row count should be close to the real row count returned, and when it is not (as it looks in your case), the primary reason for the disconnect is that the stats for the tables are out-of-date. Since it used the indexes, I am not sure if the old stats are causing any issues, but I suspect they are not helping. Also, do you do any clustering of the data (since the queries are mostly time limited)? I am wondering if the system is doing lots of seeks to get the data (implying that the data is all over the disk and not clustered). Charlie Nikk Anderson wrote: > Hi, > Thanks for the reply Stephen, the data is 'somewhat' realistic..... > > The data in the table is actually synthetic, but the structure is the > same as our live system, and the queries are similar to those we > actually carry out. > > As the data was synthetic there was a bit of repetition (19 million > rows of repetition!! ) of the item used in the where clause, meaning > that most of the table was returned by the queries - oops! So, I have > done is some more realistic queries from our live system, and put the > time it takes, and the explain results. Just to note that the > explain's estimated number of rows is way out - its guesses are way > too low. > > Typically a normal query on our live system returns between 200 and > 30000 rows depending on the reports a user wants to generate. In > prior testing, we noted that using SELECT COUNT( .. was slower than > other queries, which is why we though we would test counts first. > > > Here are some more realistic results, which still take a fair whack of > time........ > > > Starting query 0 > Query 0: SELECT * FROM xx WHERE time BETWEEN '2002-11-17 14:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335 > Time taken = 697 ms > Index Scan using http_timejobid on xx (cost=0.00..17.01 rows=4 width=57) > This query returns 500 rows of data > > > Starting query 1 > Query 1: SELECT * FROM xx WHERE time BETWEEN '2002-11-11 14:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335 > Time taken = 15 seconds > Index Scan using http_timejobid on xx (cost=0.00..705.57 rows=175 > width=57) > This query return 3582 rows > > Starting query 2 > Query 2: SELECT * FROM xx WHERE time BETWEEN '2002-10-19 15:08:58.021' > AND '2002-11-18 14:08:58.021' AND job_id = 335; > Time taken = 65 seconds > Index Scan using http_timejobid on xx (cost=0.00..3327.55 rows=832 > width=57) > This query returns 15692 rows > > Starting query 3 > Query 3: SELECT * FROM xx_result WHERE time BETWEEN '2002-08-20 > 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job_id = 335; > > Time taken = 241 seconds > Index Scan using http_timejobid on xx (cost=0.00..10111.36 rows=2547 > width=57) > This query returns 48768 rows > > > Cheers > > Nikk > > > > > -----Original Message----- > From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com] > Sent: 18 November 2002 13:02 > To: Nikk Anderson > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] selects from large tables > > > > On Mon, 18 Nov 2002, Nikk Anderson wrote: > > > Any ideas on how we can select data more quickly from large tables? > > Are these row estimates realistic? It's estimating nearly 20 million rows > to be returned by some of the queries (unless I'm misreading the > number - possible since it's 5am here). At that point you almost > certainly want to be using a cursor rather than plain queries since even a > small width result (say 50 bytes) gives a very large (1 gig) result set. > > > - Queries and explain plans > > > > select count(*) from table_name; > > NOTICE: QUERY PLAN: > > Aggregate (cost=488700.65..488700.65 rows=1 width=0) > > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 > width=0) > > > > hawkdb=# explain select count(job_id) from table_name; > > NOTICE: QUERY PLAN: > > Aggregate (cost=488700.65..488700.65 rows=1 width=4) > > -> Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 > width=4) > > > > hawkdb=# explain select * from table_name; > > NOTICE: QUERY PLAN: > > Seq Scan on table_name (cost=0.00..439527.12 rows=19669412 width=57) > > > > hawkdb=# explain select count(*) from table_name where job_id = 13; > > NOTICE: QUERY PLAN: > > Aggregate (cost=537874.18..537874.18 rows=1 width=0) > > -> Seq Scan on table_name (cost=0.00..488700.65 rows=19669412 > width=0) > > > > hawkdb=# explain select * from table_name where job_id = 13; > > NOTICE: QUERY PLAN: > > Seq Scan on http_result (cost=0.00..488700.65 rows=19669412 width=57) > > > > hawkdb=# explain select * from table_name where job_id = 1; > > NOTICE: QUERY PLAN: > > Index Scan using http_result_pk on table_name (cost=0.00..5.01 rows=1 > > width=57) > > > > hawkdb=#explain select * from table_name where time > '2002-10-10'; > > NOTICE: QUERY PLAN: > > Seq Scan on table_name (cost=0.00..488700.65 rows=19649743 width=57) > > > > hawkdb=# explain select * from http_result where time < '2002-10-10'; > > NOTICE: QUERY PLAN: > > Index Scan using table_name_time on table_name (cost=0.00..75879.17 > > rows=19669 width=57) > -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org ------_=_NextPart_001_01C290A6.A410A3C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [PERFORM] selects from large tables

Hi,

I tried a test cluster on a copy of our real data - all 1= 0 million rows or so.  WOW!   The normal select performance = improved drastically. 

Selecting 3 months worth of data was taking 146 seconds t= o retrieve.  After clustering it took 7.7 seconds!  We are now lo= oking into ways we can automate clustering to keep the table up to date.&nb= sp; The cluster itself took around 2.5 hours.

As our backend systems are writing hundreds of rows of da= ta in per minute into the table that needs clustering - will cluster handle= locking the tables when dropping the old, and renaming the clustered data?=   What happens to the data being added to the table while cluster is r= unning? Our backend systems may have some problems if the table does not ex= ist when it tries to insert, and we don't want to lose any data.

Thanks

Nikk


-----Original Message-----
From: Charles H. Woloszynski [mailto:chw@clearmetrix.com]
Sent: 18 November 2002 15:46
To: Nikk Anderson
Cc: 'Stephan Szabo'; pgsql-performance@postgresql.org
Subject: Re: [PERFORM] selects from large tables


Nikk:

Are you doing vaccums on these tables?  I was under = the understanding
that the estimated row count should be close to the real= row count
returned, and when it is not (as it looks in your case),= the primary
reason for the disconnect is that the stats for the tabl= es are
out-of-date. 

Since it used the indexes, I am not sure if the old stats= are causing
any issues, but I suspect they are not helping. 

Also, do you do any clustering of the data (since the que= ries are mostly
time limited)?  I am wondering if the system is doi= ng lots of seeks to
get the data (implying that the data is all over the dis= k and not
clustered). 

Charlie

Nikk Anderson wrote:

> Hi,
> Thanks for the reply Stephen, the data is 'somewhat= ' realistic.....
>
> The data in the table is actually synthetic, but th= e structure is the
> same as our live system, and the queries are simila= r to those we
> actually carry out.
>
> As the data was synthetic there was a bit of repeti= tion (19 million
> rows of repetition!! ) of the item used in the wher= e clause, meaning
> that most of the table was returned by the queries = - oops!  So, I have
> done is some more realistic queries from our live s= ystem, and put the
> time it takes, and the explain results.  Just = to note that the
> explain's estimated number of rows is way out - its= guesses are way
> too low.
>
> Typically a normal query on our live system returns= between 200 and
> 30000 rows depending on the reports a user wants to= generate.  In
> prior testing, we noted that using SELECT COUNT( ..=    was slower than
> other queries, which is why we though we would test= counts first.
>
>
> Here are some more realistic results, which still t= ake a fair whack of
> time........
>
>
> Starting query 0
> Query 0: SELECT * FROM xx WHERE time BETWEEN '2002-= 11-17 14:08:58.021'
> AND '2002-11-18 14:08:58.021' AND job_id =3D 335
> Time taken =3D 697 ms
> Index Scan using http_timejobid on xx  (cost= =3D0.00..17.01 rows=3D4 width=3D57)
> This query returns 500 rows of data
>
>
> Starting query 1
> Query 1: SELECT * FROM xx WHERE time BETWEEN '2002-= 11-11 14:08:58.021'
> AND '2002-11-18 14:08:58.021' AND job_id =3D 335
> Time taken =3D 15 seconds
> Index Scan using http_timejobid on xx  (cost= =3D0.00..705.57 rows=3D175
> width=3D57)
> This query return 3582 rows
>
> Starting query 2
> Query 2: SELECT * FROM xx WHERE time BETWEEN '2002-= 10-19 15:08:58.021'
> AND '2002-11-18 14:08:58.021' AND job_id =3D 335;
> Time taken =3D 65 seconds
> Index Scan using http_timejobid on xx  (cost= =3D0.00..3327.55 rows=3D832
> width=3D57)
> This query returns 15692 rows
>
> Starting query 3
> Query 3: SELECT * FROM xx_result WHERE time BETWEEN= '2002-08-20
> 15:08:58.021' AND '2002-11-18 14:08:58.021' AND job= _id =3D 335;
>
> Time taken =3D 241 seconds
> Index Scan using http_timejobid on xx  (cost= =3D0.00..10111.36 rows=3D2547
> width=3D57)
> This query returns 48768 rows
>
>
> Cheers
>
> Nikk
>
>
>
>
> -----Original Message-----
> From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com]
> Sent: 18 November 2002 13:02
> To: Nikk Anderson
> Cc: pgsql-performance@postgresql.org
> Subject: Re: [PERFORM] selects from large tables
>
>
>
> On Mon, 18 Nov 2002, Nikk Anderson wrote:
>
> > Any ideas on how we can select data more quick= ly from large tables?
>
> Are these row estimates realistic? It's estimating = nearly 20 million rows
> to be returned by some of the queries (unless I'm m= isreading the
> number - possible since it's 5am here).  At th= at point you almost
> certainly want to be using a cursor rather than pla= in queries since even a
> small width result (say 50 bytes) gives a very larg= e (1 gig) result set.
>
> > - Queries and explain plans
> >
> > select count(*) from table_name;
> > NOTICE:  QUERY PLAN:
> > Aggregate  (cost=3D488700.65..488700.65 r= ows=3D1 width=3D0)
> >   ->  Seq Scan on table_name=   (cost=3D0.00..439527.12 rows=3D19669412
> width=3D0)
> >
> > hawkdb=3D# explain select count(job_id) from t= able_name;
> > NOTICE:  QUERY PLAN:
> > Aggregate  (cost=3D488700.65..488700.65 r= ows=3D1 width=3D4)
> >   ->  Seq Scan on table_name=   (cost=3D0.00..439527.12 rows=3D19669412
> width=3D4)
> >
> > hawkdb=3D# explain select * from table_name;
> > NOTICE:  QUERY PLAN:
> > Seq Scan on table_name  (cost=3D0.00..439= 527.12 rows=3D19669412 width=3D57)
> >
> > hawkdb=3D# explain select count(*) from table_= name where job_id =3D 13;
> > NOTICE:  QUERY PLAN:
> > Aggregate  (cost=3D537874.18..537874.18 r= ows=3D1 width=3D0)
> >   ->  Seq Scan on table_name=   (cost=3D0.00..488700.65 rows=3D19669412
> width=3D0)
> >
> > hawkdb=3D# explain select * from table_name wh= ere job_id =3D 13;
> > NOTICE:  QUERY PLAN:
> > Seq Scan on http_result  (cost=3D0.00..48= 8700.65 rows=3D19669412 width=3D57)
> >
> > hawkdb=3D# explain select * from table_name wh= ere job_id =3D 1;
> > NOTICE:  QUERY PLAN:
> > Index Scan using http_result_pk on table_name&= nbsp; (cost=3D0.00..5.01 rows=3D1
> > width=3D57)
> >
> > hawkdb=3D#explain select * from table_name whe= re time > '2002-10-10';
> > NOTICE:  QUERY PLAN:
> > Seq Scan on table_name  (cost=3D0.00..488= 700.65 rows=3D19649743 width=3D57)
> >
> > hawkdb=3D# explain select * from http_result w= here time < '2002-10-10';
> > NOTICE:  QUERY PLAN:
> > Index Scan using table_name_time on table_name=   (cost=3D0.00..75879.17
> > rows=3D19669 width=3D57)
>

--


Charles H. Woloszynski

ClearMetrix, Inc.
115 Research Drive
Bethlehem, PA 18015

tel: 610-419-2210 x400
fax: 240-371-3256
web: www.clearmetrix.com





---------------------------(end of broadcast)------------= ---------------
TIP 1: subscribe and unsubscribe commands go to majordom= o@postgresql.org

------_=_NextPart_001_01C290A6.A410A3C0-- From pgsql-performance-owner@postgresql.org Wed Nov 20 10:19:41 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A5B12475C8B for ; Wed, 20 Nov 2002 10:19:39 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D5CA9475ADE for ; Wed, 20 Nov 2002 10:19:32 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gAKFGghR001454; Wed, 20 Nov 2002 10:16:42 -0500 (EST) To: Nikk Anderson Cc: "'Charles H. Woloszynski'" , pgsql-performance@postgresql.org Subject: Re: selects from large tables In-reply-to: References: Comments: In-reply-to Nikk Anderson message dated "Wed, 20 Nov 2002 15:08:11 +0000" Date: Wed, 20 Nov 2002 10:16:42 -0500 Message-ID: <1453.1037805402@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/145 X-Sequence-Number: 303 Nikk Anderson writes: > As our backend systems are writing hundreds of rows of data in per minute > into the table that needs clustering - will cluster handle locking the > tables when dropping the old, and renaming the clustered data? What happens > to the data being added to the table while cluster is running? Nothing, because there won't be any: cluster acquires exclusive lock on the table while it runs. Any would-be inserter will block till it's done. If you are clustering by timestamp of insertion, and you never update or delete rows, then I think it's a one-time-and-you're-done kind of task anyway --- newly inserted rows will always get added at the end, and so will be in timestamp order anyway. But if you need to update the table then things aren't so nice :-( regards, tom lane PS: it's not really necessary to quote the entire thread in every message, and it's definitely not nice to do so twice in both plain text and HTML :-(. Please have some consideration for the size of your emails that Marc is archiving for posterity ... From pgsql-performance-owner@postgresql.org Wed Nov 20 10:18:41 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B6267475C8B for ; Wed, 20 Nov 2002 10:18:40 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 5A77F475C5F for ; Wed, 20 Nov 2002 10:18:39 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id gAKFIGD01247; Wed, 20 Nov 2002 10:18:16 -0500 (EST) From: Bruce Momjian Message-Id: <200211201518.gAKFIGD01247@candle.pha.pa.us> Subject: Re: selects from large tables In-Reply-To: To: Nikk Anderson Date: Wed, 20 Nov 2002 10:18:16 -0500 (EST) Cc: "'Charles H. Woloszynski'" , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/144 X-Sequence-Number: 302 Nikk Anderson wrote: > Hi, > > I tried a test cluster on a copy of our real data - all 10 million rows or > so. WOW! The normal select performance improved drastically. > Selecting 3 months worth of data was taking 146 seconds to retrieve. After > clustering it took 7.7 seconds! We are now looking into ways we can > automate clustering to keep the table up to date. The cluster itself took > around 2.5 hours. > > As our backend systems are writing hundreds of rows of data in per minute > into the table that needs clustering - will cluster handle locking the > tables when dropping the old, and renaming the clustered data? What happens > to the data being added to the table while cluster is running? Our backend > systems may have some problems if the table does not exist when it tries to > insert, and we don't want to lose any data. CLUSTER will exclusively lock the table from read/write during the CLUSTER. Sorry. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Wed Nov 20 10:30:46 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C4046475B47 for ; Wed, 20 Nov 2002 10:30:44 -0500 (EST) Received: from jester.senspire.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id 1783F475ADE for ; Wed, 20 Nov 2002 10:30:44 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAKFV5Ho015899; Wed, 20 Nov 2002 10:31:06 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: selects from large tables From: Rod Taylor To: Nikk Anderson Cc: "\"'Charles H. \"Woloszynski'" , pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Organization: Message-Id: <1037806265.87360.18.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 20 Nov 2002 10:31:05 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/146 X-Sequence-Number: 304 On Wed, 2002-11-20 at 10:08, Nikk Anderson wrote: > Hi, > > I tried a test cluster on a copy of our real data - all 10 million > rows or so. WOW! The normal select performance improved > drastically. > > Selecting 3 months worth of data was taking 146 seconds to retrieve. > After clustering it took 7.7 seconds! We are now looking into ways we > can automate clustering to keep the table up to date. The cluster > itself took around 2.5 hours. > > As our backend systems are writing hundreds of rows of data in per > minute into the table that needs clustering - will cluster handle > locking the tables when dropping the old, and renaming the clustered > data? What happens to the data being added to the table while cluster > is running? Our backend systems may have some problems if the table > does not exist when it tries to insert, and we don't want to lose any > data. The table will be locked while cluster is running. Meaning, any new data will have to sit and wait. Cluster won't buy much on a mostly clustered table. But it's probably worth it for you to do it when 20% of the tuples turnover (deleted, updated, inserts, etc). I'm a little curious to know when the last time you had run a VACUUM FULL on that table was. -- Rod Taylor From pgsql-performance-owner@postgresql.org Wed Nov 20 10:49:30 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 97B9B475D01 for ; Wed, 20 Nov 2002 10:49:29 -0500 (EST) Received: from nic-nts1.nic.parallel.ltd.uk (parallel1.demon.co.uk [194.222.145.131]) by postgresql.org (Postfix) with ESMTP id 66A21475C8B for ; Wed, 20 Nov 2002 10:49:27 -0500 (EST) Received: by nic-nts1.nic.parallel.ltd.uk with Internet Mail Service (5.5.2656.59) id ; Wed, 20 Nov 2002 15:49:31 -0000 Message-ID: From: Nikk Anderson To: 'Rod Taylor' Cc: pgsql-performance@postgresql.org Subject: Re: selects from large tables Date: Wed, 20 Nov 2002 15:49:26 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C290AC.673BC460" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/147 X-Sequence-Number: 305 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C290AC.673BC460 Content-Type: text/plain; charset="iso-8859-1" Hi, > I'm a little curious to know when the last time you had run a VACUUM > FULL on that table was. > >-- >Rod Taylor We do a VACUUM ANALYZE every night, there is no option for FULL on our version (7.1) Nikk ------_=_NextPart_001_01C290AC.673BC460 Content-Type: text/html; charset="iso-8859-1" RE: [PERFORM] selects from large tables

Hi,
> I'm a little curious to know when the last time you had run a VACUUM
> FULL on that table was.
>
>--
>Rod Taylor <rbt@rbt.ca>

We do a VACUUM ANALYZE every night, there is no option for FULL on our version (7.1)

Nikk

------_=_NextPart_001_01C290AC.673BC460-- From pgsql-performance-owner@postgresql.org Wed Nov 20 10:56:44 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 76D1F4758FE for ; Wed, 20 Nov 2002 10:56:42 -0500 (EST) Received: from jester.senspire.com (unknown [216.208.117.7]) by postgresql.org (Postfix) with ESMTP id AD97C474E5C for ; Wed, 20 Nov 2002 10:56:41 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAKFuJHo076713; Wed, 20 Nov 2002 10:56:20 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: selects from large tables From: Rod Taylor To: Nikk Anderson Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Organization: Message-Id: <1037807779.87360.20.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 20 Nov 2002 10:56:19 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/148 X-Sequence-Number: 306 > We do a VACUUM ANALYZE every night, there is no option for FULL on our > version (7.1) Oh, I see. Old stuff :) -- Rod Taylor From pgsql-performance-owner@postgresql.org Wed Nov 20 13:53:07 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B14354764F9 for ; Wed, 20 Nov 2002 13:53:06 -0500 (EST) Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) by postgresql.org (Postfix) with ESMTP id 140394764E4 for ; Wed, 20 Nov 2002 13:53:06 -0500 (EST) Received: from p65-147.acedsl.com (p65-147.acedsl.com [66.114.65.147]) by mail1.acecape.com (8.12.2/8.12.2) with ESMTP id gAKIr6XT004929 for ; Wed, 20 Nov 2002 13:53:06 -0500 Date: Wed, 20 Nov 2002 13:58:49 -0500 (EST) From: Francisco Reyes X-X-Sender: fran@zoraida.natserv.net To: pgsql-performance@postgresql.org Message-ID: <20021120135841.J30106-100000@zoraida.natserv.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/149 X-Sequence-Number: 307 subscribe From pgsql-performance-owner@postgresql.org Wed Nov 20 15:26:45 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9B8554758DC for ; Wed, 20 Nov 2002 15:26:43 -0500 (EST) Received: from rh72.home.ee (adsl1030.estpak.ee [213.168.29.11]) by postgresql.org (Postfix) with ESMTP id A283A474E61 for ; Wed, 20 Nov 2002 15:26:42 -0500 (EST) Received: from rh72.home.ee (localhost.localdomain [127.0.0.1]) by rh72.home.ee (8.12.5/8.12.5) with ESMTP id gAKKQOTO002389; Thu, 21 Nov 2002 01:26:24 +0500 Received: (from hannu@localhost) by rh72.home.ee (8.12.5/8.12.5/Submit) id gAKKQNMm002387; Thu, 21 Nov 2002 01:26:23 +0500 X-Authentication-Warning: rh72.home.ee: hannu set sender to hannu@tm.ee using -f Subject: Re: selects from large tables From: Hannu Krosing To: Nikk Anderson Cc: "\"'Charles H. \"Woloszynski'" , pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1037823981.1930.5.camel@rh72.home.ee> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 21 Nov 2002 01:26:22 +0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/150 X-Sequence-Number: 308 Nikk Anderson kirjutas K, 20.11.2002 kell 20:08: > Hi, > > I tried a test cluster on a copy of our real data - all 10 million > rows or so. WOW! The normal select performance improved > drastically. > > Selecting 3 months worth of data was taking 146 seconds to retrieve. > After clustering it took 7.7 seconds! We are now looking into ways we > can automate clustering to keep the table up to date. The cluster > itself took around 2.5 hours. > > As our backend systems are writing hundreds of rows of data in per > minute into the table that needs clustering - will cluster handle > locking the tables when dropping the old, and renaming the clustered > data? What happens to the data being added to the table while cluster > is running? Our backend systems may have some problems if the table > does not exist when it tries to insert, and we don't want to lose any > data. You could use a staging table that takes all the inserts and the contents of which are moved (begin;insert into big select from small;delete from small;commit;vacuum full small;) to the main table once a day (or week or month) just before clustering the big one. Then do all your selects from a UNION view on both - thus you have a big fast clustered table and non-clustered "live" table which stays small. That should make your selects fast(er). ----------------- Hannu From pgsql-performance-owner@postgresql.org Wed Nov 20 18:40:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3D534475843 for ; Wed, 20 Nov 2002 18:40:41 -0500 (EST) Received: from o2.hostbaby.com (o2.hostbaby.com [208.187.29.121]) by postgresql.org (Postfix) with SMTP id 8B3CF474E61 for ; Wed, 20 Nov 2002 18:40:40 -0500 (EST) Received: (qmail 16786 invoked from network); 20 Nov 2002 23:40:46 -0000 Received: from unknown (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 20 Nov 2002 23:40:46 -0000 Received: from 216.80.95.13 (Hostbaby Webmail authenticated user typea@l-i-e.com) by www.l-i-e.com with HTTP; Wed, 20 Nov 2002 15:40:46 -0800 (PST) Message-ID: <51042.216.80.95.13.1037835646.squirrel@www.l-i-e.com> Date: Wed, 20 Nov 2002 15:40:46 -0800 (PST) Subject: Query Analysis From: To: X-Priority: 3 Importance: Normal X-Mailer: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/151 X-Sequence-Number: 309 Direct Cc: would be MUCH appreciated! I'm using PostgreSQL 7.1.3 My FIRST question is: How come I can't seem to get any of that nifty profiling output to /var/log/messages? [aside] Not in /var/log/pgsql nor in /var/lib/pgsql/data/pg.log either. Don't care where it goes, so long as I can find it... While I realize that this is very configurable, some "clues" to newbies about the usual places would have been most welcome in the docs. [/aside] I have: Altered postgresql.conf to turn "on" the show_query_stats (et al) as well as syslog = 2 Altered /etc/rc.d/init/postgresql to be: su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -o '-i -s ' -p /usr/bin/postmaster start > /dev/null 2>&1" < /dev/null Altered /var/lib/pgsql/postmaster.opts to be: /usr/bin/postmaster '-D' '/var/lib/pgsql/data' '-i' '-s' Once I'm in psql, I use SET to turn them on as well. This resulted in all my ERROR and NOTICE messages going into /var/log/messages, but *NOT* any sort of nifty query analysis type stuff. So what did I miss? Is there another client/server spot where I need to get that '-s' in there? Is there another switch to actually kick-start it? The docs are probably real clear to y'all, but I'm obviously missing something simple here... Of course, the root problem is a monster query that suddenly takes far far too long... I realize that I'm trying to do a full-text search, *BUT* a similar query "works fine"... Why does this take minutes: SELECT DISTINCT *, 0 + (0 + 10 * (lower(title) like '%einstein%') ::int + 10 * (lower(author_flattened) like '%einstein%') ::int + 30 * (lower(subject_flattened) like '%einstein%') ::int + 30 * (lower(text) LIKE '%einstein%') ::int + 9 * (substring(lower(title), 1, 20) like '%einstein%') ::int + 25 * (substring(lower(text), 1, 20) LIKE '%einstein%') ::int ) AS points FROM article WHERE TRUE AND (FALSE OR (lower(title) like '%einstein%') OR (lower(author_flattened) like '%einstein%') OR (lower(subject_flattened) like '%einstein%') OR (lower(text) LIKE '%einstein%') ) ORDER BY points desc, volume, number, article.article LIMIT 10, 0 while this takes seconds: SELECT *, 0 + 3 * ( title like '%Einstein%' )::int + 3 * ( author like '%Einstein%' )::int + ( ( 1 + 1 * ( lower(text) like '%einstein%' )::int ) + ( 0 + ( subject like '%Einstein%' )::int ) ) AS points FROM article WHERE TRUE AND title like '%Einstein%' AND author like '%Einstein%' AND ( ( TRUE AND lower(text) like '%einstein%' ) OR ( FALSE OR subject like '%Einstein%' ) ) ORDER BY points desc, volume, number, article.article LIMIT 10, 0 Is it the function calls to lower() which I have yet to implement on the second query? Is it the sheer number of rows being returned? Do a lot of "OR" sub-parts to the WHERE drag it down? Article has ~17000 records in it. The 'text' field is the actual contents of a magazine article. I would ask if it was the ~* (REGEXP) but that hasn't even kicked in for this single-term ('Einstein') input! :-^ We're talking about minutes instead of seconds here. All fields are of type 'text' VACUUM VERBOSE ANALYZE is running nightly /proc/cpuinfo sez: processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 11 model name : Intel(R) Pentium(R) III CPU family 1400MHz stepping : 1 cpu MHz : 1406.005 cache size : 512 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse bogomips : 2804.94 Finally, any "rules of thumb" about that one 512 RAM size thingie in postmaster.conf would be especially appreciated... If you're willing to actually poke at the search engine with other inputs, I'd be happy to provide a URL off-list. From pgsql-performance-owner@postgresql.org Wed Nov 20 18:50:40 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9D508475843 for ; Wed, 20 Nov 2002 18:50:38 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 04375474E61 for ; Wed, 20 Nov 2002 18:50:38 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1834841; Wed, 20 Nov 2002 15:54:51 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: , Subject: Re: Query Analysis Date: Wed, 20 Nov 2002 15:52:40 -0800 X-Mailer: KMail [version 1.4] References: <51042.216.80.95.13.1037835646.squirrel@www.l-i-e.com> In-Reply-To: <51042.216.80.95.13.1037835646.squirrel@www.l-i-e.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211201552.40452.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/152 X-Sequence-Number: 310 "typea": > Why does this take minutes: >=20 > SELECT DISTINCT *, 0 + (0 + 10 * (lower(title) like '%einstein%') ::int + > 10 * (lower(author_flattened) like '%einstein%') ::int + 30 * > (lower(subject_flattened) like '%einstein%') ::int + 30 * (lower(text) > LIKE '%einstein%') ::int + 9 * (substring(lower(title), 1, 20) like > '%einstein%') ::int + 25 * (substring(lower(text), 1, 20) LIKE > '%einstein%') ::int ) AS points FROM article WHERE TRUE AND (FALSE OR > (lower(title) like '%einstein%') OR (lower(author_flattened) like > '%einstein%') OR (lower(subject_flattened) like '%einstein%') OR > (lower(text) LIKE '%einstein%') ) ORDER BY points desc, volume, number, > article.article LIMIT 10, 0 >=20 > while this takes seconds: >=20 > SELECT *, 0 + 3 * ( title like '%Einstein%' )::int + 3 * ( author like > '%Einstein%' )::int + ( ( 1 + 1 * ( lower(text) like '%einstein%' )::int ) > + ( 0 + ( subject like '%Einstein%' )::int ) ) AS points FROM article > WHERE TRUE AND title like '%Einstein%' AND author like '%Einstein%' AND ( > ( TRUE AND lower(text) like '%einstein%' ) OR ( FALSE OR subject like > '%Einstein%' ) ) ORDER BY points desc, volume, number, article.article > LIMIT 10, 0 It's probably mostly the SELECT DISTINCT, which aggregates records and is= =20 therefore slow. Try running EXPLAIN ANALYZE to see what steps are actual= ly=20 taking the time. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Nov 21 04:29:21 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 80FB3475925 for ; Thu, 21 Nov 2002 04:29:18 -0500 (EST) Received: from zenon.apartia.com (ATuileries-117-2-2-171.abo.wanadoo.fr [193.251.42.171]) by postgresql.org (Postfix) with ESMTP id 854EC4758DC for ; Thu, 21 Nov 2002 04:29:17 -0500 (EST) Received: from argos (argos.apartia.int [10.0.2.105]) by zenon.apartia.com (Postfix) with ESMTP id 118B81B63AD for ; Thu, 21 Nov 2002 10:29:16 +0100 (CET) Received: by argos (Postfix, from userid 1018) id C96122ED1; Thu, 21 Nov 2002 10:28:38 +0100 (CET) Date: Thu, 21 Nov 2002 10:28:38 +0100 From: David Pradier To: pgsql-performance@postgresql.org Subject: Is there a system of cache in pgsql 7.3rc1 ? Message-ID: <20021121092838.GA26455@apartia.fr> Mail-Followup-To: pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/153 X-Sequence-Number: 311 Hi! This is my first post to the list. I'm currently searching to improve the performances of some requests, and recently switched to postgresql 7.3rc1. I thought there would be in this release a kind of cache for the results of requests (i.e. the second time a request is asked, if the concerned tables haven't changed, the result of the request isn't calculated another time, but taken from a cache.) ? Am i wrong ? Does such a mechanism exist ? Is it planned to create one ? Thanks for your help. Best regards, David -- dpradier@apartia.fr From pgsql-performance-owner@postgresql.org Thu Nov 21 11:16:11 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ED3FC476292 for ; Thu, 21 Nov 2002 11:16:09 -0500 (EST) Received: from o2.hostbaby.com (o2.hostbaby.com [208.187.29.121]) by postgresql.org (Postfix) with SMTP id F0D45476257 for ; Thu, 21 Nov 2002 11:16:08 -0500 (EST) Received: (qmail 8010 invoked from network); 21 Nov 2002 16:16:14 -0000 Received: from unknown (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 21 Nov 2002 16:16:14 -0000 Received: from 216.80.95.13 (Hostbaby Webmail authenticated user typea@l-i-e.com) by www.l-i-e.com with HTTP; Thu, 21 Nov 2002 08:16:14 -0800 (PST) Message-ID: <49187.216.80.95.13.1037895374.squirrel@www.l-i-e.com> Date: Thu, 21 Nov 2002 08:16:14 -0800 (PST) Subject: Re: Query Analysis From: To: In-Reply-To: <200211201552.40452.josh@agliodbs.com> References: <51042.216.80.95.13.1037835646.squirrel@www.l-i-e.com> <200211201552.40452.josh@agliodbs.com> X-Priority: 3 Importance: Normal X-Mailer: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/154 X-Sequence-Number: 312 Since it's 7.1.3 I don't have the "ANALYZE" bit in EXPLAIN, but: archive_beta=> explain SELECT DISTINCT *, 0 + (0 + 10 * (lower(title) like '%einstein%') ::int + 10 * (lower(author_flattened) like '%einstein%') ::int + 30 * (lower(subject_flattened) like '%einstein%') ::int + 30 * (lower(text) LIKE '%einstein%') ::int + 9 * (substring(lower(title), 1, 20) like '%einstein%') ::int + 25 * (substring(lower(text), 1, 20) LIKE '%einstein%') ::int ) AS points FROM article WHERE TRUE AND (FALSE OR (lower(title) like '%einstein%') OR (lower(author_flattened) like '%einstein%') OR (lower(subject_flattened) like '%einstein%') OR (lower(text) LIKE '%einstein%') ) ORDER BY points desc, volume, number, article.article LIMIT 10, 0 ; NOTICE: QUERY PLAN: Limit (cost=1374.97..1375.02 rows=1 width=212) -> Unique (cost=1374.97..1375.02 rows=1 width=212) -> Sort (cost=1374.97..1374.97 rows=1 width=212) -> Seq Scan on article (cost=0.00..1374.96 rows=1 width=212) EXPLAIN archive_beta=> explain SELECT *, 0 + 3 * ( title like '%Einstein%' )::int + 3 * ( author like '%Einstein%' )::int + ( ( 1 + 1 * ( lower(text) like '%einstein%' )::int ) + ( 0 + ( subject like '%Einstein%' )::int ) ) AS points FROM article WHERE TRUE AND title like '%Einstein%' AND author like '%Einstein%' AND ( ( TRUE AND lower(text) like '%einstein%' ) OR ( FALSE OR subject like '%Einstein%' ) ) ORDER BY points desc, volume, number, article.article LIMIT 10, 0; NOTICE: QUERY PLAN: Limit (cost=1243.48..1243.48 rows=1 width=212) -> Sort (cost=1243.48..1243.48 rows=1 width=212) -> Seq Scan on article (cost=0.00..1243.47 rows=1 width=212) While the first one is higher, these two do not seem drastically different to me -- Those numbers are accumulative, right? So the top row is my "final answer" The extra Unique row doesn't seem to be adding significantly to the numbers as far as EXPLAIN can tell... And yet the queries are orders of magnitude apart in actual performance. 'Course, I don't claim to completely understand the output of EXPLAIN yet either. I also took out the DISTINCT in the first one, just to test. It was certainly "faster" but not nearly so much that it "caught up" to the other query. Thanks in advance for any help! From pgsql-admin-owner@postgresql.org Thu Nov 21 11:40:52 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7DD19475D01 for ; Thu, 21 Nov 2002 11:40:50 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 21F48475AE5 for ; Thu, 21 Nov 2002 11:40:47 -0500 (EST) Received: (qmail 11555 invoked from network); 21 Nov 2002 16:30:07 -0000 Received: from unknown (HELO system67.trade-india-local.com) (192.168.0.67) by infocom-236-129-del.trade-india.com with SMTP; 21 Nov 2002 16:30:07 -0000 Content-Type: text/plain; charset="us-ascii" From: "Rajesh Kumar Mallah." Organization: Infocom Network Limited. To: pgsql-performance@postgresql.org, pgsql-admin@postgresql.org Subject: H/W RAID 5 on slower disks versus no raid on faster HDDs Date: Thu, 21 Nov 2002 22:15:02 +0530 User-Agent: KMail/1.4.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211212215.02699.mallah@trade-india.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/191 X-Sequence-Number: 6379 Hi folks, I have two options: 3*18 GB 10,000 RPM Ultra160 Dual Channel SCSI controller + H/W Raid 5 and=20 2*36 GB 15,000 RPM Ultra320 Dual Channel SCSI and no RAID Does anyone opinions *performance wise* the pros and cons of above=20 two options. please take in consideration in latter case its higher RPM and better SCSI interface.=20 Regds Mallah. --=20 Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Thu Nov 21 11:52:28 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A9661476488 for ; Thu, 21 Nov 2002 11:52:26 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 1E334476417 for ; Thu, 21 Nov 2002 11:52:23 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.229) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 21 Nov 2002 17:52:27 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 21 Nov 2002 17:45:36 +0100 Message-ID: <019301c2917e$52be3860$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: Subject: vacuum full Date: Thu, 21 Nov 2002 17:52:05 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/156 X-Sequence-Number: 314 hello all, how often should "vacuum full" usually be run ? thanks, -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Nov 21 12:05:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DD695476569 for ; Thu, 21 Nov 2002 12:05:55 -0500 (EST) Received: from clearmetrix.com (unknown [209.92.142.67]) by postgresql.org (Postfix) with ESMTP id ECEC2476568 for ; Thu, 21 Nov 2002 12:05:54 -0500 (EST) Received: from clearmetrix.com (chw.muvpn.clearmetrix.com [172.16.1.3]) by clearmetrix.com (8.11.6/linuxconf) with ESMTP id gALH5x100917; Thu, 21 Nov 2002 12:05:59 -0500 Message-ID: <3DDD127B.3030003@clearmetrix.com> Date: Thu, 21 Nov 2002 12:06:03 -0500 From: "Charles H. Woloszynski" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Rajesh Kumar Mallah." , pgsql-performance Subject: Re: H/W RAID 5 on slower disks versus no raid on faster References: <200211212215.02699.mallah@trade-india.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/157 X-Sequence-Number: 315 How are you going to make use of the three faster drives under postgresql? Were you intending to put the WAL, system/swap, and the actual data files on separate drives/partitions? Unless you do something like that (or s/w RAID to distribute the processing across the disks), you really have ONE SCSI 15K Ultra320 drive against 3 slower drives with the RAID overhead (and spreading of performance because of the multiple heads). I don't have specifics here, but I'd expect that the RAID5 on slower drives would work better for apps with lots of selects or lots of concurrent users. I suspect that the Ultra320 would be better for batch jobs and mostly transactions with less selects. Charlie Rajesh Kumar Mallah. wrote: >Hi folks, > >I have two options: >3*18 GB 10,000 RPM Ultra160 Dual Channel SCSI controller + H/W Raid 5 >and >2*36 GB 15,000 RPM Ultra320 Dual Channel SCSI and no RAID > >Does anyone opinions *performance wise* the pros and cons of above >two options. > >please take in consideration in latter case its higher RPM and better >SCSI interface. > > > >Regds >Mallah. > > > > > > -- Charles H. Woloszynski ClearMetrix, Inc. 115 Research Drive Bethlehem, PA 18015 tel: 610-419-2210 x400 fax: 240-371-3256 web: www.clearmetrix.com From pgsql-admin-owner@postgresql.org Sat Nov 23 00:35:06 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B12004762E7 for ; Thu, 21 Nov 2002 12:15:23 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id 3E8C447628C for ; Thu, 21 Nov 2002 12:15:21 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id gALHLC6P002077; Thu, 21 Nov 2002 12:21:12 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id gALHFQj17822; Thu, 21 Nov 2002 12:15:26 -0500 Received: from intergylinux (intergylinux.mmrd.com [172.25.4.92]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id W7RLX2RP; Thu, 21 Nov 2002 12:15:25 -0500 Content-Type: text/plain; charset="iso-8859-1" From: Chris Ruprecht To: "Rajesh Kumar Mallah." Subject: Re: H/W RAID 5 on slower disks versus no raid on faster HDDs Date: Thu, 21 Nov 2002 12:19:35 -0500 User-Agent: KMail/1.4.1 References: <200211212215.02699.mallah@trade-india.com> <200211211157.58260.chris@ruprecht.org> <200211212232.40491.mallah@trade-india.com> In-Reply-To: <200211212232.40491.mallah@trade-india.com> Cc: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211211219.35550.chris@ruprecht.org> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/213 X-Sequence-Number: 6401 raid 0 (striping) spreads the load over multiple spindels, the same way rai= d 5=20 does. but raid 5 always needs to calculate parity and write that to it's=20 parity drive. RPM isn't that critical, a lot depends on the machine, the processor and th= e=20 memory (and the spped with which the processor can get to the memory). I ha= ve=20 recently tested a lot of systems with some database benchmarks we wrote her= e=20 at work. We're not running Postgres here at work, sorry, these benchmarks a= re=20 of no use to Postgres ... We we found is that a lot depends on motherboard design, not so much on dri= ve=20 speed. We got to stages where we allocated 1.8 GB of RAM to shared memory f= or=20 the database server process, resulting in the entire database being sucked= =20 into memory. When doing reads, 100% of the data is coming out the that=20 menory, and drive speed becomes irrelevant. From tests I did with Postgres on my boxes at home, I can say: The more sha= red=20 memory you can throw at the server process, the better. Under MacOS X I=20 wasn't able to allocate more than 3 MB, Under Linux, I can allocate anythin= g=20 I want to, so I usually start up the server with 256 MB. The difference? A= =20 process which takes 4 minutes under Linux, takes 6 hours under MacOS - same= =20 hardware, same drives, different memory settings. Best regards, Chris On Thursday 21 November 2002 12:02, you wrote: > Thanks Chris, > > does raid0 enhances both read/write both? > > does rpms not matter that much? > > regds > mallah. > > On Thursday 21 November 2002 22:27, you wrote: > > RAID 5 gives you pretty bad performance, a slowdown of about 50%. For > > pure performance, I'd use the 3 18 GB drives with RAID 0. > > > > If you need fault tolerance, you could use RAID 0+1 or 1+0 but you'd ne= ed > > an even number of drives for that, of which half would become 'usable > > space'. > > > > Best regards, > > Chris > > > > On Thursday 21 November 2002 11:45, you wrote: > > > Hi folks, > > > > > > I have two options: > > > 3*18 GB 10,000 RPM Ultra160 Dual Channel SCSI controller + H/W Raid 5 > > > and > > > 2*36 GB 15,000 RPM Ultra320 Dual Channel SCSI and no RAID > > > > > > Does anyone opinions *performance wise* the pros and cons of above > > > two options. > > > > > > please take in consideration in latter case its higher RPM and better > > > SCSI interface. > > > > > > > > > > > > Regds > > > Mallah. --=20 Network Grunt and Bit Pusher extraordinaire From pgsql-performance-owner@postgresql.org Thu Nov 21 12:32:41 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D8FA1475AA1 for ; Thu, 21 Nov 2002 12:32:40 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 42D37475921 for ; Thu, 21 Nov 2002 12:32:40 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALHW1Gx005925; Thu, 21 Nov 2002 10:32:01 -0700 (MST) Date: Thu, 21 Nov 2002 10:32:05 -0700 (MST) From: "scott.marlowe" To: "Rajesh Kumar Mallah." Cc: Subject: Re: H/W RAID 5 on slower disks versus no raid on faster In-Reply-To: <200211212215.02699.mallah@trade-india.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/159 X-Sequence-Number: 317 On Thu, 21 Nov 2002, Rajesh Kumar Mallah. wrote: > > Hi folks, > > I have two options: > 3*18 GB 10,000 RPM Ultra160 Dual Channel SCSI controller + H/W Raid 5 > and > 2*36 GB 15,000 RPM Ultra320 Dual Channel SCSI and no RAID > > Does anyone opinions *performance wise* the pros and cons of above > two options. > > please take in consideration in latter case its higher RPM and better > SCSI interface. Does the OS you're running on support software RAID? If so the dual 36 gigs in a RAID0 software would be fastest, and in a RAID1 would still be pretty fast plus they would be redundant. Depending on your queries, there may not be a lot of difference between running the 3*18 hw RAID or the 2*36 setup, especially if most of your data can fit into memory on the server. Generally, the 2*36 should be faster for writing, and the 3*18 should be about even for reads, maybe a little faster. From pgsql-performance-owner@postgresql.org Thu Nov 21 12:34:41 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0CA5C475C8B for ; Thu, 21 Nov 2002 12:34:41 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 216C8475B85 for ; Thu, 21 Nov 2002 12:34:40 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALHWeGx006356; Thu, 21 Nov 2002 10:32:40 -0700 (MST) Date: Thu, 21 Nov 2002 10:32:44 -0700 (MST) From: "scott.marlowe" To: Henrik Steffen Cc: Subject: Re: vacuum full In-Reply-To: <019301c2917e$52be3860$7100a8c0@STEINKAMP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/160 X-Sequence-Number: 318 On Thu, 21 Nov 2002, Henrik Steffen wrote: > > hello all, > > how often should "vacuum full" usually be run ? I recommend nightly. Also, check index size. If they are growing, you may want to reindex each night or week as well. From pgsql-performance-owner@postgresql.org Thu Nov 21 12:42:41 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AE88D4760B9 for ; Thu, 21 Nov 2002 12:42:40 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 0390C47605C for ; Thu, 21 Nov 2002 12:42:40 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALHcFGx011850; Thu, 21 Nov 2002 10:38:15 -0700 (MST) Date: Thu, 21 Nov 2002 10:38:20 -0700 (MST) From: "scott.marlowe" To: David Pradier Cc: Subject: Re: Is there a system of cache in pgsql 7.3rc1 ? In-Reply-To: <20021121092838.GA26455@apartia.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/161 X-Sequence-Number: 319 On Thu, 21 Nov 2002, David Pradier wrote: > Hi! > This is my first post to the list. > > I'm currently searching to improve the performances of some requests, > and recently switched to postgresql 7.3rc1. > > I thought there would be in this release a kind of cache for the results > of requests (i.e. the second time a request is asked, if the concerned > tables haven't changed, the result of the request isn't calculated another time, but > taken from a cache.) ? > Am i wrong ? > Does such a mechanism exist ? > Is it planned to create one ? This issue has been discussed. The performance gains from a results cache are not all that great, and postgresql's mvcc "locking" mechanism isn't a good candidate to be served by results caching / updating. Generally speaking, if you've got enough memory in your box, then the results are "cached" in memory, requiring only sorting before being output. This is a niche problem that is not likely to be implemented any time soon. From pgsql-performance-owner@postgresql.org Thu Nov 21 12:42:44 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26A8347609B for ; Thu, 21 Nov 2002 12:42:42 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id AE82947605A for ; Thu, 21 Nov 2002 12:42:38 -0500 (EST) Received: (qmail 12586 invoked from network); 21 Nov 2002 17:32:00 -0000 Received: from unknown (HELO system67.trade-india-local.com) (192.168.0.67) by infocom-236-129-del.trade-india.com with SMTP; 21 Nov 2002 17:32:00 -0000 Content-Type: text/plain; charset="iso-8859-1" From: "Rajesh Kumar Mallah." Organization: Infocom Network Limited. To: "scott.marlowe" Subject: Re: H/W RAID 5 on slower disks versus no raid on faster HDDs Date: Thu, 21 Nov 2002 23:16:55 +0530 User-Agent: KMail/1.4.1 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211212316.55081.mallah@trade-india.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/162 X-Sequence-Number: 320 Oh i did not mention, its linux, it does. RAM: 2.0 GB CPU: Dual 2.0 Ghz Intel Xeon DP Processors. On Thursday 21 November 2002 23:02, scott.marlowe wrote: > On Thu, 21 Nov 2002, Rajesh Kumar Mallah. wrote: > > Hi folks, > > > > I have two options: > > 3*18 GB 10,000 RPM Ultra160 Dual Channel SCSI controller + H/W Raid 5 > > and > > 2*36 GB 15,000 RPM Ultra320 Dual Channel SCSI and no RAID > > > > Does anyone opinions *performance wise* the pros and cons of above > > two options. > > > > please take in consideration in latter case its higher RPM and better > > SCSI interface. > > Does the OS you're running on support software RAID? If so the dual 36 > gigs in a RAID0 software would be fastest, and in a RAID1 would still be > pretty fast plus they would be redundant. > > Depending on your queries, there may not be a lot of difference between > running the 3*18 hw RAID or the 2*36 setup, especially if most of your > data can fit into memory on the server. > Generally, the 2*36 should be faster for writing, and the 3*18 should be > about even for reads, maybe a little faster. Since i got lots of RAM and my Data Size (on disk ) is 2 GB i feel frequen= t reads can happen from the memory. I have heard putting pg_xlog in a drive of its own helps in boosting update= s to=20 DB server. in that case shud i forget abt the h/w and use one disk exclusively for the= WAL? Regds mallah. --=20 Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Thu Nov 21 12:54:29 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 34424475461 for ; Thu, 21 Nov 2002 12:54:29 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id B1A35475F25 for ; Thu, 21 Nov 2002 12:54:25 -0500 (EST) Received: (qmail 12726 invoked from network); 21 Nov 2002 17:43:48 -0000 Received: from unknown (HELO system67.trade-india-local.com) (192.168.0.67) by infocom-236-129-del.trade-india.com with SMTP; 21 Nov 2002 17:43:48 -0000 Content-Type: text/plain; charset="iso-8859-1" From: "Rajesh Kumar Mallah." Organization: Infocom Network Limited. To: "scott.marlowe" Subject: Re: H/W RAID 5 on slower disks versus no raid on faster HDDs Date: Thu, 21 Nov 2002 23:28:43 +0530 User-Agent: KMail/1.4.1 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211212328.43204.mallah@trade-india.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/163 X-Sequence-Number: 321 OK now i am reading Momjian's "PostgreSQL Hardware Performance Tuning"=20 once again ;-) mallah. On Thursday 21 November 2002 23:02, scott.marlowe wrote: > On Thu, 21 Nov 2002, Rajesh Kumar Mallah. wrote: > > Hi folks, > > > > I have two options: > > 3*18 GB 10,000 RPM Ultra160 Dual Channel SCSI controller + H/W Raid 5 > > and > > 2*36 GB 15,000 RPM Ultra320 Dual Channel SCSI and no RAID > > > > Does anyone opinions *performance wise* the pros and cons of above > > two options. > > > > please take in consideration in latter case its higher RPM and better > > SCSI interface. > > Does the OS you're running on support software RAID? If so the dual 36 > gigs in a RAID0 software would be fastest, and in a RAID1 would still be > pretty fast plus they would be redundant. > > Depending on your queries, there may not be a lot of difference between > running the 3*18 hw RAID or the 2*36 setup, especially if most of your > data can fit into memory on the server. > > Generally, the 2*36 should be faster for writing, and the 3*18 should be > about even for reads, maybe a little faster. --=20 Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Thu Nov 21 13:18:13 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 307FF4760F6 for ; Thu, 21 Nov 2002 13:18:13 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 2AC0D476086 for ; Thu, 21 Nov 2002 13:18:12 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.229) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 21 Nov 2002 19:18:10 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 21 Nov 2002 19:11:20 +0100 Message-ID: <01fa01c2918a$4afffd00$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "scott.marlowe" Cc: References: Subject: Re: vacuum full Date: Thu, 21 Nov 2002 19:17:46 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/164 X-Sequence-Number: 322 ok, but how can I measure index sizes? -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "scott.marlowe" To: "Henrik Steffen" Cc: Sent: Thursday, November 21, 2002 6:32 PM Subject: Re: [PERFORM] vacuum full > On Thu, 21 Nov 2002, Henrik Steffen wrote: > > > > > hello all, > > > > how often should "vacuum full" usually be run ? > > I recommend nightly. Also, check index size. If they are growing, you > may want to reindex each night or week as well. > From pgsql-performance-owner@postgresql.org Thu Nov 21 12:21:29 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C3C744758FE for ; Thu, 21 Nov 2002 12:21:26 -0500 (EST) Received: from mail.memeticsystems.com (flywheel.memeticsystems.com [64.85.80.85]) by postgresql.org (Postfix) with SMTP id C3241475461 for ; Thu, 21 Nov 2002 12:21:24 -0500 (EST) Received: (qmail 30317 invoked from network); 21 Nov 2002 17:21:29 -0000 Received: from unknown (HELO ?10.0.0.102?) (63.249.24.21) by 0 with SMTP; 21 Nov 2002 17:21:29 -0000 Subject: stange optimizer results From: "Peter T. Brown" To: pgsql-performance@postgresql.org In-Reply-To: <019301c2917e$52be3860$7100a8c0@STEINKAMP> References: <019301c2917e$52be3860$7100a8c0@STEINKAMP> Content-Type: multipart/mixed; boundary="=-r0/2OXXj2terRxlzwiAG" X-Mailer: Ximian Evolution 1.0.8 Date: 21 Nov 2002 10:18:53 -0800 Message-Id: <1037902735.1784.22.camel@localhost.localdomain> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/158 X-Sequence-Number: 316 --=-r0/2OXXj2terRxlzwiAG Content-Type: text/plain Content-Transfer-Encoding: 7bit Hello-- Attached is a file containing two SQL queries. The first take prohibitively long to complete because, according to EXPLAIN, it ignore two very important indexes. The second SQL query seems almost identical to the first but runs very fast because, according to EXPLAIN, it does uses all the indexes appropriately. Can someone please explain to me what the difference is here? Or if there is something I can do with my indexes to make the first query run like the second? Thanks Much Peter --=-r0/2OXXj2terRxlzwiAG Content-Disposition: attachment; filename=sqlquestion.sql Content-Transfer-Encoding: quoted-printable Content-Type: text/x-sql; name=sqlquestion.sql; charset=ISO-8859-15 ######## QUERY 1 ##########################################################= ########## EXPLAIN SELECT "VisitorExtra"."ID",=20 "Visitor"."Created", "Visitor"."Updated", "Tidbit"."ID", "ProgramEvent"."ID", "Visitor"."Email", "Interest"."ID", "VisitorInternetDeviceAssoc"."ID", "Referral"."ID"=20 FROM "VisitorExtra"=20 LEFT OUTER JOIN "Tidbit" ON "VisitorExtra"."ID"=3D"Tidbit"."VisitorID"=20 LEFT OUTER JOIN "ProgramEvent" ON "VisitorExtra"."ID"=3D"ProgramEvent"."Vis= itorID"=20 LEFT OUTER JOIN "Interest" ON "VisitorExtra"."ID"=3D"Interest"."VisitorID"= =20 LEFT OUTER JOIN "VisitorInternetDeviceAssoc" ON "VisitorExtra"."ID"=3D"Visi= torInternetDeviceAssoc"."VisitorID"=20 LEFT OUTER JOIN "Referral" ON "VisitorExtra"."ID"=3D"Referral"."FromVisitor= ID","Visitor"=20 WHERE "VisitorExtra"."ID"=3D"Visitor"."ID" AND ("Visitor"."ID" =3D 2); Nested Loop (cost=3D380512.64..605796.12 rows=3D9 width=3D76) -> Index Scan using Visitor_pkey on Visitor (cost=3D0.00..4.29 rows=3D1= width=3D32) -> Materialize (cost=3D574946.55..574946.55 rows=3D2467623 width=3D44) -> Merge Join (cost=3D380512.64..574946.55 rows=3D2467623 width= =3D44) -> Merge Join (cost=3D380512.64..542978.20 rows=3D2467623 w= idth=3D36) -> Merge Join (cost=3D380512.64..507911.61 rows=3D246= 7623 width=3D28) -> Merge Join (cost=3D380512.64..470620.82 rows= =3D2467623 width=3D20) -> Merge Join (cost=3D349342.02..405798.5= 0 rows=3D2403643 width=3D12) -> Index Scan using VisitorExtra_pke= y on VisitorExtra (cost=3D0.00..22898.28 rows=3D281013 width=3D4) -> Sort (cost=3D349342.02..349342.0= 2 rows=3D2403643 width=3D8) -> Seq Scan on Tidbit (cost= =3D0.00..49644.43 rows=3D2403643 width=3D8) -> Sort (cost=3D31170.62..31170.62 rows= =3D288493 width=3D8) -> Seq Scan on ProgramEvent (cost= =3D0.00..5006.93 rows=3D288493 width=3D8) -> Index Scan using Interest_VisitorID_key on In= terest (cost=3D0.00..5340.01 rows=3D88439 width=3D8) -> Index Scan using VisitorInternetDeviceAssoc_Visi on= VisitorInternetDeviceAssoc (cost=3D0.00..3447.06 rows=3D61939 width=3D8) -> Index Scan using Referral_FromVisitorID_key on Referral = (cost=3D0.00..914.08 rows=3D16719 width=3D8) ###### QUERY 2 ############################################################= #### EXPLAIN SELECT "VisitorExtra"."ID",=20 "Visitor"."Created", "Visitor"."Updated", "Tidbit"."ID", "ProgramEvent"."ID", "Visitor"."Email", "Interest"."ID", "VisitorInternetDeviceAssoc"."ID", "Referral"."ID"=20 FROM "VisitorExtra"=20 LEFT OUTER JOIN "Tidbit" ON "VisitorExtra"."ID"=3D"Tidbit"."VisitorID"=20 LEFT OUTER JOIN "ProgramEvent" ON "VisitorExtra"."ID"=3D"ProgramEvent"."Vis= itorID"=20 LEFT OUTER JOIN "Interest" ON "VisitorExtra"."ID"=3D"Interest"."VisitorID"= =20 LEFT OUTER JOIN "VisitorInternetDeviceAssoc" ON "VisitorExtra"."ID"=3D"Visi= torInternetDeviceAssoc"."VisitorID"=20 LEFT OUTER JOIN "Referral" ON "VisitorExtra"."ID"=3D"Referral"."FromVisitor= ID","Visitor"=20 WHERE "VisitorExtra"."ID" =3D 2; Nested Loop (cost=3D0.00..73719.08 rows=3D2467623 width=3D72) -> Nested Loop (cost=3D0.00..235.97 rows=3D9 width=3D44) -> Nested Loop (cost=3D0.00..163.21 rows=3D9 width=3D36) -> Nested Loop (cost=3D0.00..143.81 rows=3D9 width=3D28) -> Nested Loop (cost=3D0.00..73.66 rows=3D9 width=3D2= 0) -> Nested Loop (cost=3D0.00..12.45 rows=3D9 wid= th=3D12) -> Index Scan using VisitorExtra_pkey on V= isitorExtra (cost=3D0.00..3.56 rows=3D1 width=3D4) -> Index Scan using Tidbit_VisitorID_key o= n Tidbit (cost=3D0.00..8.87 rows=3D2 width=3D8) -> Index Scan using ProgramEvent_VisitorID_key o= n ProgramEvent (cost=3D0.00..7.14 rows=3D2 width=3D8) -> Index Scan using Interest_VisitorID_key on Interest= (cost=3D0.00..7.93 rows=3D5 width=3D8) -> Index Scan using VisitorInternetDeviceAssoc_Visi on Visit= orInternetDeviceAssoc (cost=3D0.00..2.20 rows=3D1 width=3D8) -> Index Scan using Referral_FromVisitorID_key on Referral (cost= =3D0.00..8.21 rows=3D6 width=3D8) -> Seq Scan on Visitor (cost=3D0.00..5558.13 rows=3D281013 width=3D28) --=-r0/2OXXj2terRxlzwiAG-- From pgsql-performance-owner@postgresql.org Thu Nov 21 13:20:44 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B6D45475921 for ; Thu, 21 Nov 2002 13:20:42 -0500 (EST) Received: from ibis.city-map.de (proxy.firewall-by-call.de [62.116.172.146]) by postgresql.org (Postfix) with ESMTP id 8CB674758FE for ; Thu, 21 Nov 2002 13:20:41 -0500 (EST) Received: from mail.topconcepts.net (62.155.189.229) by mail.city-map.de with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 21 Nov 2002 19:20:40 +0100 Received: from HENRIK (192.168.0.113) by blah.topconcepts.net with [XMail 1.11 (Linux/Ix86) ESMTP Server] id for from ; Thu, 21 Nov 2002 19:13:50 +0100 Message-ID: <021e01c2918a$a435d160$7100a8c0@STEINKAMP> From: "Henrik Steffen" To: "scott.marlowe" Cc: References: Subject: Re: vacuum full Date: Thu, 21 Nov 2002 19:20:16 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/165 X-Sequence-Number: 323 sorry, didn't notice your message posted to pgsql-general... but is there any method to see the size in bytes a particular index for a particular table takes? -- Mit freundlichem Gru� Henrik Steffen Gesch�ftsf�hrer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -------------------------------------------------------- http://www.topconcepts.com Tel. +49 4141 991230 mail: steffen@topconcepts.com Fax. +49 4141 991233 -------------------------------------------------------- 24h-Support Hotline: +49 1908 34697 (EUR 1.86/Min,topc) -------------------------------------------------------- Ihr SMS-Gateway: JETZT NEU unter: http://sms.city-map.de System-Partner gesucht: http://www.franchise.city-map.de -------------------------------------------------------- Handelsregister: AG Stade HRB 5811 - UstId: DE 213645563 -------------------------------------------------------- ----- Original Message ----- From: "scott.marlowe" To: "Henrik Steffen" Cc: Sent: Thursday, November 21, 2002 6:32 PM Subject: Re: [PERFORM] vacuum full > On Thu, 21 Nov 2002, Henrik Steffen wrote: > > > > > hello all, > > > > how often should "vacuum full" usually be run ? > > I recommend nightly. Also, check index size. If they are growing, you > may want to reindex each night or week as well. > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > From pgsql-performance-owner@postgresql.org Thu Nov 21 13:34:17 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 974FF4758FE for ; Thu, 21 Nov 2002 13:34:15 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 1C9F1475461 for ; Thu, 21 Nov 2002 13:34:15 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 6272FD619; Thu, 21 Nov 2002 10:34:14 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 542395C03; Thu, 21 Nov 2002 10:34:14 -0800 (PST) Date: Thu, 21 Nov 2002 10:34:14 -0800 (PST) From: Stephan Szabo To: "Peter T. Brown" Cc: Subject: Re: stange optimizer results In-Reply-To: <1037902735.1784.22.camel@localhost.localdomain> Message-ID: <20021121101430.J96861-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/166 X-Sequence-Number: 324 On 21 Nov 2002, Peter T. Brown wrote: > Hello-- > > Attached is a file containing two SQL queries. The first take > prohibitively long to complete because, according to EXPLAIN, it ignore > two very important indexes. The second SQL query seems almost identical > to the first but runs very fast because, according to EXPLAIN, it does > uses all the indexes appropriately. > > Can someone please explain to me what the difference is here? Or if > there is something I can do with my indexes to make the first query run > like the second? It doesn't take into account that in general a=b, b=constant implies a=constant. Perhaps if you used explicit join syntax for visitor joining visitorextra it might help. Like doing: FROM visitor inner join visitorextra on (...) left outer join ... From pgsql-performance-owner@postgresql.org Thu Nov 21 13:35:39 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B5B144758E1 for ; Thu, 21 Nov 2002 13:35:38 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 35E21475461 for ; Thu, 21 Nov 2002 13:35:38 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 19EF4D60C; Thu, 21 Nov 2002 10:35:38 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 0F6935C03; Thu, 21 Nov 2002 10:35:38 -0800 (PST) Date: Thu, 21 Nov 2002 10:35:37 -0800 (PST) From: Stephan Szabo To: "Peter T. Brown" Cc: Subject: Re: stange optimizer results In-Reply-To: <20021121101430.J96861-100000@megazone23.bigpanda.com> Message-ID: <20021121103424.X96861-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/167 X-Sequence-Number: 325 On Thu, 21 Nov 2002, Stephan Szabo wrote: > On 21 Nov 2002, Peter T. Brown wrote: > > > Hello-- > > > > Attached is a file containing two SQL queries. The first take > > prohibitively long to complete because, according to EXPLAIN, it ignore > > two very important indexes. The second SQL query seems almost identical > > to the first but runs very fast because, according to EXPLAIN, it does > > uses all the indexes appropriately. > > > > Can someone please explain to me what the difference is here? Or if > > there is something I can do with my indexes to make the first query run > > like the second? > > It doesn't take into account that in general a=b, b=constant implies > a=constant. > > Perhaps if you used explicit join syntax for visitor joining > visitorextra it might help. Like doing: > FROM visitor inner join visitorextra on (...) > left outer join ... Sent this too quickly. It probably won't make it use an index on vistorextra, but it may lower the number of expected rows that it's going to be left outer joining so that a nested loop and index scan makes sense. From pgsql-performance-owner@postgresql.org Thu Nov 21 13:50:54 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CD4D44758FE for ; Thu, 21 Nov 2002 13:50:52 -0500 (EST) Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by postgresql.org (Postfix) with ESMTP id 308CE475461 for ; Thu, 21 Nov 2002 13:50:52 -0500 (EST) Received: (from smtp@localhost) by ll.mit.edu (8.11.3/8.8.8) id gALIohC17962; Thu, 21 Nov 2002 13:50:43 -0500 (EST) Received: from sty.llan.ll.mit.edu( ), claiming to be "sty.llan" via SMTP by llpost, id smtpdAAALRa4aI; Thu Nov 21 13:50:36 2002 Date: Thu, 21 Nov 2002 13:50:36 -0500 From: george young To: "Henrik Steffen" Cc: pgsql-performance@postgresql.org Subject: Re: vacuum full Message-Id: <20021121135036.788d3fcb.gry@ll.mit.edu> In-Reply-To: <021e01c2918a$a435d160$7100a8c0@STEINKAMP> References: <021e01c2918a$a435d160$7100a8c0@STEINKAMP> Reply-To: gry@ll.mit.edu Organization: MIT Lincoln Laboratory X-Mailer: Sylpheed version 0.8.5 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/168 X-Sequence-Number: 326 On Thu, 21 Nov 2002 19:20:16 +0100 "Henrik Steffen" wrote: > sorry, didn't notice your message posted to pgsql-general... > > but is there any method to see the size in bytes a particular index > for a particular table takes? For a table foo, do: psql mydatabase -- first find the index name: mydatabase=> \d foo ... Indexes: foo_pkey unique btree (mykey) -- now find the unix file name of the index: mydatabase=> select relfilenode from pg_class where relname='foo_pkey'; relfilenode ------------- 18122 -- Thus the file name of the index is "18122". \q # now go and look for the file: unixprompt> su postgres Password: postgres> cd /var/lib/pgsql/data/base/???? postgres> ls -l 18122 -rw------- 1 postgres daemon 7471104 Nov 21 12:52 18122 Thus the index for table foo is 7.4 MBytes in size. What I left out is the ???? directory name above. I find it by educated guess. Does someone know the right way to map from database name to data directory name? -- George > From: "scott.marlowe" > To: "Henrik Steffen" > Cc: > Sent: Thursday, November 21, 2002 6:32 PM > Subject: Re: [PERFORM] vacuum full > > > > On Thu, 21 Nov 2002, Henrik Steffen wrote: > > > > > > how often should "vacuum full" usually be run ? > > > > I recommend nightly. Also, check index size. If they are growing, you > > may want to reindex each night or week as well. -- I cannot think why the whole bed of the ocean is not one solid mass of oysters, so prolific they seem. Ah, I am wandering! Strange how the brain controls the brain! -- Sherlock Holmes in "The Dying Detective" From pgsql-performance-owner@postgresql.org Thu Nov 21 13:56:31 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6E8B3475ECE for ; Thu, 21 Nov 2002 13:56:30 -0500 (EST) Received: from polaris.pinpointresearch.com (66-7-238-176.cust.telepacific.net [66.7.238.176]) by postgresql.org (Postfix) with ESMTP id E1D05475E75 for ; Thu, 21 Nov 2002 13:56:29 -0500 (EST) Received: from there (66-7-238-179.cust.telepacific.net [66.7.238.179]) by polaris.pinpointresearch.com (Postfix) with SMTP id C6A11103C2; Thu, 21 Nov 2002 10:56:29 -0800 (PST) Content-Type: text/plain; charset="iso-8859-1" From: Steve Crawford Organization: Pinpoint Research To: "Rajesh Kumar Mallah." , pgsql-performance@postgresql.org Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on faster HDDs Date: Thu, 21 Nov 2002 10:56:29 -0800 X-Mailer: KMail [version 1.3.1] References: <200211212215.02699.mallah@trade-india.com> In-Reply-To: <200211212215.02699.mallah@trade-india.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <20021121185629.C6A11103C2@polaris.pinpointresearch.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/169 X-Sequence-Number: 327 I had long labored under the impression that RAID 5 should give me better performance but I have since encountered many reports that this is not the case. Do some searching on Google and you will probably find numerous articles. Note 3x18 w/RAID5 will give 36GB usable while 2x36 w/o RAID is 72GB. You could use mirroring on the 2x36 and have the same usable space. A mirrored 2x36 setup will probably yield a marginal hit on writes (vs a single disk) and an improvement on reads due to having two drives to read from and will (based on the Scientific Wild Ass Guess method and knowing nothing about your overall system) probably be faster than the RAID5 configuration while giving you identical usable space and data safety. You also may see improvements due to the 15,000RPM drives (of course RPM is sort of an arbitrary measure - you really want to know about track access times, latency, transfer rate, etc. and RPM is just one influencing factor for the above). The quality of your RAID cards will also be important (how fast do they perform their calculations, how much buffer do they have) as will the overall specs of you system. If you have a bottleneck somewhere other than your raw disk I/O then you can throw all the money you want at faster drives and see no improvement. Cheers, Steve On Thursday 21 November 2002 8:45 am, you wrote: > Hi folks, > > I have two options: > 3*18 GB 10,000 RPM Ultra160 Dual Channel SCSI controller + H/W Raid 5 > and > 2*36 GB 15,000 RPM Ultra320 Dual Channel SCSI and no RAID > > Does anyone opinions *performance wise* the pros and cons of above > two options. > > please take in consideration in latter case its higher RPM and better > SCSI interface. > > > > Regds > Mallah. From pgsql-performance-owner@postgresql.org Thu Nov 21 14:04:36 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C2F35475E60 for ; Thu, 21 Nov 2002 14:04:35 -0500 (EST) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 5CBB6475BF9 for ; Thu, 21 Nov 2002 14:04:32 -0500 (EST) Received: (qmail 13396 invoked from network); 21 Nov 2002 18:53:49 -0000 Received: from unknown (HELO system67.trade-india-local.com) (192.168.0.67) by infocom-236-129-del.trade-india.com with SMTP; 21 Nov 2002 18:53:49 -0000 Content-Type: text/plain; charset="iso-8859-1" From: "Rajesh Kumar Mallah." Organization: Infocom Network Limited. To: Steve Crawford , pgsql-performance@postgresql.org Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on faster HDDs Date: Fri, 22 Nov 2002 00:38:43 +0530 User-Agent: KMail/1.4.1 References: <200211212215.02699.mallah@trade-india.com> <20021121185629.C6A11103C2@polaris.pinpointresearch.com> In-Reply-To: <20021121185629.C6A11103C2@polaris.pinpointresearch.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211220038.43950.mallah@trade-india.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/170 X-Sequence-Number: 328 Thanks Steve, recently i have come to know that i can only get 3*18 GB ultra160 10K hraddrives, my OS is lunux , other parameters are RAM:2GB , CPU:2*2Ghz Xeon, i feel i will do away with raid use one disk for the OS=20 and pg_dumps , one for tables and last one for WAL , does this sound good? regds mallah. On Friday 22 November 2002 00:26, Steve Crawford wrote: > I had long labored under the impression that RAID 5 should give me better > performance but I have since encountered many reports that this is not the > case. Do some searching on Google and you will probably find numerous > articles. > > Note 3x18 w/RAID5 will give 36GB usable while 2x36 w/o RAID is 72GB. > You could use mirroring on the 2x36 and have the same usable space. > > A mirrored 2x36 setup will probably yield a marginal hit on writes (vs a > single disk) and an improvement on reads due to having two drives to read > from and will (based on the Scientific Wild Ass Guess method and knowing > nothing about your overall system) probably be faster than the RAID5 > configuration while giving you identical usable space and data safety. > > You also may see improvements due to the 15,000RPM drives (of course RPM = is > sort of an arbitrary measure - you really want to know about track access > times, latency, transfer rate, etc. and RPM is just one influencing factor > for the above). > > The quality of your RAID cards will also be important (how fast do they > perform their calculations, how much buffer do they have) as will the > overall specs of you system. If you have a bottleneck somewhere other than > your raw disk I/O then you can throw all the money you want at faster > drives and see no improvement. > > Cheers, > Steve > > On Thursday 21 November 2002 8:45 am, you wrote: > > Hi folks, > > > > I have two options: > > 3*18 GB 10,000 RPM Ultra160 Dual Channel SCSI controller + H/W Raid 5 > > and > > 2*36 GB 15,000 RPM Ultra320 Dual Channel SCSI and no RAID > > > > Does anyone opinions *performance wise* the pros and cons of above > > two options. > > > > please take in consideration in latter case its higher RPM and better > > SCSI interface. > > > > > > > > Regds > > Mallah. > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) --=20 Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Thu Nov 21 14:14:00 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 42F854758FE for ; Thu, 21 Nov 2002 14:13:59 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 8EDD147618E for ; Thu, 21 Nov 2002 14:13:57 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALJCWGx024965; Thu, 21 Nov 2002 12:12:32 -0700 (MST) Date: Thu, 21 Nov 2002 12:12:35 -0700 (MST) From: "scott.marlowe" To: Henrik Steffen Cc: Subject: Re: vacuum full In-Reply-To: <021e01c2918a$a435d160$7100a8c0@STEINKAMP> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/171 X-Sequence-Number: 329 On Thu, 21 Nov 2002, Henrik Steffen wrote: > sorry, didn't notice your message posted to pgsql-general... > > but is there any method to see the size in bytes a particular index > for a particular table takes? There are some sql queries that can tell you the number of blocks used and all, but I generally do it with oid2name (you can get it installed by going into your source tree/contrib/oid2name and doing a make/make install there.) oid2name by itself will tell you the oids of your databases. On my fairly fresh system it looks like this: All databases: --------------------------------- 16976 = postgres 1 = template1 16975 = template0 Then, 'oid2name -d postgres' outputs this: 16999 = g 17025 = g_name_dx 16977 = gaff 16988 = test 16986 = test_id_seq 17019 = tester So, I can do this 'ls -l $PGDATA/base/16976/17025' to see how big the index g_name_dx is. From pgsql-performance-owner@postgresql.org Thu Nov 21 14:22:03 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 821B04763BA for ; Thu, 21 Nov 2002 14:22:02 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B1F6B4758FE for ; Thu, 21 Nov 2002 14:21:52 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gALJLOsX013678; Thu, 21 Nov 2002 14:21:24 -0500 (EST) To: gry@ll.mit.edu Cc: "Henrik Steffen" , pgsql-performance@postgresql.org Subject: Re: vacuum full In-reply-to: <20021121135036.788d3fcb.gry@ll.mit.edu> References: <021e01c2918a$a435d160$7100a8c0@STEINKAMP> <20021121135036.788d3fcb.gry@ll.mit.edu> Comments: In-reply-to george young message dated "Thu, 21 Nov 2002 13:50:36 -0500" Date: Thu, 21 Nov 2002 14:21:24 -0500 Message-ID: <13677.1037906484@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/173 X-Sequence-Number: 331 george young writes: > Does someone know the right way to map from database name to > data directory name? pg_database.oid column. However, that's definitely the hard way. I'd just look at the relpages column of pg_class, which should be reasonably accurate if you've done a VACUUM or ANALYZE recently. For example: regression=# select relname, relkind, relpages from pg_class where regression-# relname like 'tenk1%'; relname | relkind | relpages ---------------+---------+---------- tenk1 | r | 358 tenk1_hundred | i | 30 tenk1_unique1 | i | 30 tenk1_unique2 | i | 30 (4 rows) Here we have a table and its three indexes, and the index sizes look reasonable. If the index sizes approach or exceed the table size, you are probably suffering from index bloat --- try a reindex. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 21 14:21:29 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4EA2C476592 for ; Thu, 21 Nov 2002 14:21:28 -0500 (EST) Received: from o2.hostbaby.com (o2.hostbaby.com [208.187.29.121]) by postgresql.org (Postfix) with SMTP id 95A7E47655A for ; Thu, 21 Nov 2002 14:21:23 -0500 (EST) Received: (qmail 73592 invoked from network); 21 Nov 2002 19:21:26 -0000 Received: from unknown (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 21 Nov 2002 19:21:26 -0000 Received: from 216.80.95.13 (Hostbaby Webmail authenticated user typea@l-i-e.com) by www.l-i-e.com with HTTP; Thu, 21 Nov 2002 11:21:26 -0800 (PST) Message-ID: <49566.216.80.95.13.1037906486.squirrel@www.l-i-e.com> Date: Thu, 21 Nov 2002 11:21:26 -0800 (PST) Subject: Re: Query Analysis From: To: In-Reply-To: <200211201552.40452.josh@agliodbs.com> References: <51042.216.80.95.13.1037835646.squirrel@www.l-i-e.com> <200211201552.40452.josh@agliodbs.com> X-Priority: 3 Importance: Normal X-Mailer: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/172 X-Sequence-Number: 330 I think I've narrowed down my problem space a bit. Playing with various "fast" versus "slow" queries leads me to ask: GIVEN: 15,000 reocrds with a 'text' field named 'text' Average 'text' length about 10 K. Full text search using lower() and LIKE and even ~* sometimes on that field with a keyword. What can be done to maximize performance on such large chunks of text? More RAM? Tweak that 512 number in postmaster.conf? Faster CPU? Is my only option to resort to a concordance? From pgsql-performance-owner@postgresql.org Thu Nov 21 14:24:28 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 88DC447610B for ; Thu, 21 Nov 2002 14:24:27 -0500 (EST) Received: from ns1.gnw.de (ns1.turtle-entertainment.de [193.41.200.20]) by postgresql.org (Postfix) with ESMTP id 920D04760AF for ; Thu, 21 Nov 2002 14:24:26 -0500 (EST) Received: from [213.148.158.226] (helo=mail.office.turtle-entertainment.de) by ns1.gnw.de with esmtp (Exim 3.16 #1 (Debian)) id 18EwwB-0005zb-00 for ; Thu, 21 Nov 2002 20:24:31 +0100 Received: from pd9520be9.dip.t-dialin.net ([217.82.11.233] helo=shock) by mail.office.turtle-entertainment.de with asmtp (Exim 3.22 #7 (Debian)) id 18Eww1-000660-00 for ; Thu, 21 Nov 2002 20:24:21 +0100 Message-ID: <008e01c29193$9795eb80$0564a8c0@toolteam.net> From: "Bjoern Metzdorf" To: References: <200211212215.02699.mallah@trade-india.com> <20021121185629.C6A11103C2@polaris.pinpointresearch.com> Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on faster HDDs Date: Thu, 21 Nov 2002 20:24:19 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Scanner: exiscan *18Eww1-000660-00*7dwjvqgfkqE* http://duncanthrax.net/exiscan/ X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/174 X-Sequence-Number: 332 > A mirrored 2x36 setup will probably yield a marginal hit on writes (vs a > single disk) and an improvement on reads due to having two drives to read > from and will (based on the Scientific Wild Ass Guess method and knowing slightly offtopic: Does anyone one if linux software raid 1 supports this method (reading from both disks, thus doubling performance)? Regards, Bjoern From pgsql-performance-owner@postgresql.org Thu Nov 21 14:31:35 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A6D6647618E for ; Thu, 21 Nov 2002 14:31:34 -0500 (EST) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id E1DC24766ED for ; Thu, 21 Nov 2002 14:30:47 -0500 (EST) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id 60B6124646F for ; Thu, 21 Nov 2002 11:30:47 -0800 (PST) X-Mailer: UserLand Frontier 8.0.5 (Macintosh OS) (mailServer v1.1..142) Mime-Version: 1.0 Message-Id: <109501694.1174244252@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <008e01c29193$9795eb80$0564a8c0@toolteam.net> Date: Thu, 21 Nov 2002 11:30:44 -0800 To: From: eric soroos Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on faster HDDs Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/175 X-Sequence-Number: 333 > Does anyone one if linux software raid 1 supports this method (reading from > both disks, thus doubling performance)? > From memory of reading slightly old (1999) howtos, I believe that the answer is yes, at least for the md system. Not sure about LVM, or even if mirroring is supported under LVM. I would guess that it shouldn't be too hard to test: 1) set up dataset on mirred system. 2) run pg_bench or one of the tpc benches. 3) fail one of the drives in the mirror. 4) run the test again. If the read latency goes down, it should be reflected in the benchmark. eric From pgsql-performance-owner@postgresql.org Thu Nov 21 14:39:52 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7C01147605A for ; Thu, 21 Nov 2002 14:39:51 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id BDA5547603C for ; Thu, 21 Nov 2002 14:39:50 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALJd6Gx015108; Thu, 21 Nov 2002 12:39:06 -0700 (MST) Date: Thu, 21 Nov 2002 12:39:09 -0700 (MST) From: "scott.marlowe" To: "Rajesh Kumar Mallah." Cc: Steve Crawford , Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on In-Reply-To: <200211220038.43950.mallah@trade-india.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/176 X-Sequence-Number: 334 On Fri, 22 Nov 2002, Rajesh Kumar Mallah. wrote: > > > Thanks Steve, > > recently i have come to know that i can only get 3*18 GB ultra160 10K > hraddrives, > > my OS is lunux , other parameters are > RAM:2GB , CPU:2*2Ghz Xeon, > > i feel i will do away with raid use one disk for the OS > and pg_dumps > > , one for tables and last one for WAL , does this sound good? That depends. Are you going to be mostly reading, mostly updating, or an even mix of both? If you are going to be 95% reading, then don't bother moving WAL to another drive, install the OS on the first 2 or 3 gigs of each drive, then make a RAID5 out of what's left over and put everything on that. If you're going to be mostly updating, then yes, your setup is a pretty good choice. If it will be mostly mixed, look at using a software RAID1. More important will be tuning your database once it's up, i.e. increasing shared buffers, setting random page costs to reflect what percentage of your dataset is likely to be cached (the closer you come to caching your whole dataset, the closer random page cost approaches 1) From pgsql-performance-owner@postgresql.org Thu Nov 21 14:41:46 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 824634762D9 for ; Thu, 21 Nov 2002 14:41:45 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 535B1476246 for ; Thu, 21 Nov 2002 14:41:40 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gALJfesX013901; Thu, 21 Nov 2002 14:41:40 -0500 (EST) To: typea@l-i-e.com Cc: pgsql-performance@postgresql.org Subject: Re: Query Analysis In-reply-to: <49566.216.80.95.13.1037906486.squirrel@www.l-i-e.com> References: <51042.216.80.95.13.1037835646.squirrel@www.l-i-e.com> <200211201552.40452.josh@agliodbs.com> <49566.216.80.95.13.1037906486.squirrel@www.l-i-e.com> Comments: In-reply-to message dated "Thu, 21 Nov 2002 11:21:26 -0800" Date: Thu, 21 Nov 2002 14:41:39 -0500 Message-ID: <13900.1037907699@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/177 X-Sequence-Number: 335 writes: > 15,000 reocrds with a 'text' field named 'text' > Average 'text' length about 10 K. > Full text search using lower() and LIKE and even ~* sometimes on that > field with a keyword. Consider using a full-text-indexing method (there are a couple in contrib, and OpenFTS has a website that was mentioned recently in the mail lists). regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 21 15:04:00 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7450A475E60 for ; Thu, 21 Nov 2002 15:03:59 -0500 (EST) Received: from mta02bw.bigpond.com (unknown [144.135.24.138]) by postgresql.org (Postfix) with ESMTP id CF46E475E31 for ; Thu, 21 Nov 2002 15:03:57 -0500 (EST) Received: from CPE-144-132-182-167.nsw.bigpond.net.au ([144.135.24.75]) by mta02bw.bigpond.com (Netscape Messaging Server 4.15 mta02bw Jul 16 2002 22:47:55) with SMTP id H5XZQJ00.73X; Fri, 22 Nov 2002 06:03:55 +1000 Received: from CPE-144-132-182-167.nsw.bigpond.net.au ([144.132.182.167]) by bwmam03.mailsvc.email.bigpond.com(MailRouter V3.2 26/479773); 22 Nov 2002 06:03:55 Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on From: Mike Nielsen To: Bjoern Metzdorf Cc: Postgresql performance In-Reply-To: <008e01c29193$9795eb80$0564a8c0@toolteam.net> References: <200211212215.02699.mallah@trade-india.com> <20021121185629.C6A11103C2@polaris.pinpointresearch.com> <008e01c29193$9795eb80$0564a8c0@toolteam.net> Content-Type: multipart/alternative; boundary="=-ru+RY5KnzI1TkKbR8DkI" Organization: Message-Id: <1037909025.21282.510.camel@CPE-144-132-182-167.nsw.bigpond.net.au> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 22 Nov 2002 07:03:46 +1100 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/178 X-Sequence-Number: 336 --=-ru+RY5KnzI1TkKbR8DkI Content-Type: text/plain Content-Transfer-Encoding: 7bit Bjoern, You may find that hoping for a doubling of performance by using RAID 1 is a little on the optimistic side. Except on very long sequential reads, media transfer rates are unlikely to be the limiting factor in disk throughput. Seek and rotational latencies are the cost factor in random I/O, and with RAID 1, the performance gain comes from reducing the mean latency -- on a single request, one disk will be closer to the data than the other. If the software that's handling the RAID 1 will schedule concurrent requests, you lose the advantage of reducing mean latency in this fashion, but you can get some improvement in throughput by overlapping some latency periods. While not wanting to argue against intelligent I/O design, memory is cheap these days, and usually gives big bang-for-buck in improving response times. As to the specifics of how one level or another of Linux implements RAID 1, I'm afraid I can't shed much light at the moment. Regards, Mike On Fri, 2002-11-22 at 06:24, Bjoern Metzdorf wrote: > > A mirrored 2x36 setup will probably yield a marginal hit on writes (vs a > > single disk) and an improvement on reads due to having two drives to read > > from and will (based on the Scientific Wild Ass Guess method and knowing > > slightly offtopic: > > Does anyone one if linux software raid 1 supports this method (reading from > both disks, thus doubling performance)? > > Regards, > Bjoern > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster Michael Nielsen ph: 0411-097-023 email: miken@bigpond.net.au Mike Nielsen ________________________________________________________________________ --=-ru+RY5KnzI1TkKbR8DkI Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Bjoern,

You may find that hoping for a doubling of performance by using RAID 1 is a little on the optimistic side.


Except on very long sequential reads, media transfer rates are unlikely to be the limiting factor in disk throughput.  Seek and rotational latencies are the cost factor in random I/O, and with RAID 1, the performance gain comes from reducing the mean latency --  on a single request, one disk will be closer to the data than the other.  If the software that's handling the RAID 1 will schedule concurrent requests, you lose the advantage of reducing mean latency in this fashion, but you can get some improvement in throughput by overlapping some latency periods.

While not wanting to argue against intelligent I/O design, memory is cheap these days, and usually gives big bang-for-buck in improving response times.

As to the specifics of how one level or another of Linux implements RAID 1, I'm afraid I can't shed much light at the moment.

Regards,

Mike
On Fri, 2002-11-22 at 06:24, Bjoern Metzdorf wrote:
> A mirrored 2x36 setup will probably yield a marginal hit on writes (vs a
> single disk) and an improvement on reads due to having two drives to read
> from and will (based on the Scientific Wild Ass Guess method and knowing

slightly offtopic:

Does anyone one if linux software raid 1 supports this method (reading from
both disks, thus doubling performance)?

Regards,
Bjoern


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Michael Nielsen

ph: 0411-097-023 email: miken@bigpond.net.au


Mike Nielsen

--=-ru+RY5KnzI1TkKbR8DkI-- From pgsql-performance-owner@postgresql.org Thu Nov 21 15:17:49 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1F208475BF9 for ; Thu, 21 Nov 2002 15:17:48 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 63B9A475B33 for ; Thu, 21 Nov 2002 15:17:47 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALKH1Gx012100; Thu, 21 Nov 2002 13:17:02 -0700 (MST) Date: Thu, 21 Nov 2002 13:17:05 -0700 (MST) From: "scott.marlowe" To: Bjoern Metzdorf Cc: Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on In-Reply-To: <008e01c29193$9795eb80$0564a8c0@toolteam.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/180 X-Sequence-Number: 338 On Thu, 21 Nov 2002, Bjoern Metzdorf wrote: > > A mirrored 2x36 setup will probably yield a marginal hit on writes (vs a > > single disk) and an improvement on reads due to having two drives to read > > from and will (based on the Scientific Wild Ass Guess method and knowing > > slightly offtopic: > > Does anyone one if linux software raid 1 supports this method (reading from > both disks, thus doubling performance)? Yes, it does. Generally speaking, it increases raw throughput by a factor of 2 if you're grabbing enough data to justify reading it from both drives. But for most database apps, you don't read enough at a time to get a gain from this. I.e. if your stripe size is 8k and you're reading 1k at a time, no gain. However, under parallel load, the extra drives really help. In fact, the linux kernel supports >2 drives in a mirror. Useful for a mostly read database that needs to handle lots of concurrent users. From pgsql-performance-owner@postgresql.org Thu Nov 21 15:42:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B8F86475B33 for ; Thu, 21 Nov 2002 15:42:00 -0500 (EST) Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) by postgresql.org (Postfix) with ESMTP id 0EC61475AFA for ; Thu, 21 Nov 2002 15:42:00 -0500 (EST) Received: from p65-147.acedsl.com (p65-147.acedsl.com [66.114.65.147]) by mail1.acecape.com (8.12.2/8.12.2) with ESMTP id gALKfwXT016077; Thu, 21 Nov 2002 15:41:59 -0500 Date: Thu, 21 Nov 2002 15:47:51 -0500 (EST) From: Francisco J Reyes To: Francisco Reyes Cc: pgsql-performance@postgresql.org In-Reply-To: <20021120135841.J30106-100000@zoraida.natserv.net> Message-ID: <20021121154730.K36066-100000@zoraida.natserv.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/182 X-Sequence-Number: 340 subscribe lists@natserv.com From pgsql-performance-owner@postgresql.org Thu Nov 21 15:53:10 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4515F475B33 for ; Thu, 21 Nov 2002 15:53:09 -0500 (EST) Received: from ns1.gnw.de (ns1.turtle-entertainment.de [193.41.200.20]) by postgresql.org (Postfix) with ESMTP id 57A01475AFA for ; Thu, 21 Nov 2002 15:53:08 -0500 (EST) Received: from [213.148.158.226] (helo=mail.office.turtle-entertainment.de) by ns1.gnw.de with esmtp (Exim 3.16 #1 (Debian)) id 18EyJz-0000ef-00; Thu, 21 Nov 2002 21:53:11 +0100 Received: from pd9520be9.dip.t-dialin.net ([217.82.11.233] helo=shock) by mail.office.turtle-entertainment.de with asmtp (Exim 3.22 #7 (Debian)) id 18EyJr-00076e-00; Thu, 21 Nov 2002 21:53:04 +0100 Message-ID: <012201c2919f$fc4e1b40$0564a8c0@toolteam.net> From: "Bjoern Metzdorf" To: "scott.marlowe" Cc: References: Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on Date: Thu, 21 Nov 2002 21:53:02 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Scanner: exiscan *18EyJr-00076e-00*PW7v67I47Do* http://duncanthrax.net/exiscan/ X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/183 X-Sequence-Number: 341 > In fact, the linux kernel supports >2 drives in a mirror. Useful for a > mostly read database that needs to handle lots of concurrent users. Good to know. What do you think is faster: 3 drives in raid 1 or 3 drives in raid 5? Regards, Bjoern From pgsql-performance-owner@postgresql.org Thu Nov 21 15:14:51 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BA8B5476130 for ; Thu, 21 Nov 2002 15:14:49 -0500 (EST) Received: from mta5.snet.net (mta5.snet.net [204.60.203.77]) by postgresql.org (Postfix) with ESMTP id 0067247610B for ; Thu, 21 Nov 2002 15:14:49 -0500 (EST) X-Originating-IP: [204.60.203.72] Received: from pop.snet.net (pop.snet.net [204.60.203.72]) by mta5.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gALK9pBe017794 for ; Thu, 21 Nov 2002 15:11:33 -0500 (EST) X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gALJs0UC017796 for ; Thu, 21 Nov 2002 14:54:05 -0500 (EST) Subject: performance of insert/delete/update From: Wei Weng To: pgsql-performance@postgresql.org Content-Type: text/plain Organization: Message-Id: <1037912043.5931.5.camel@Monet> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 21 Nov 2002 15:54:03 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/179 X-Sequence-Number: 337 There had been a great deal of discussion of how to improve the performance of select/sorting on this list, what about insert/delete/update? Is there any rules of thumb we need to follow? What are the parameters we should tweak to whip the horse to go faster? Thanks -- Wei Weng Network Software Engineer KenCast Inc. From pgsql-performance-owner@postgresql.org Thu Nov 21 16:16:41 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 818B947611C for ; Thu, 21 Nov 2002 16:16:38 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id BAE2F475FEC for ; Thu, 21 Nov 2002 16:16:36 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1836145; Thu, 21 Nov 2002 13:20:56 -0800 From: "Josh Berkus" Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no To: "Bjoern Metzdorf" , "scott.marlowe" Cc: X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 21 Nov 2002 13:20:56 -0800 Message-ID: In-Reply-To: <012201c2919f$fc4e1b40$0564a8c0@toolteam.net> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/184 X-Sequence-Number: 342 Bjoern, > Good to know. > > What do you think is faster: 3 drives in raid 1 or 3 drives in raid > 5? My experience? Raid 1. But that depends on other factors as well; your controller (software controllers use system RAM and thus lower performance), what kind of reads you're getting and how often. IMHO, RAID 5 is faster for sequential reads (lareg numbers of records on clustered tables), RAID 1 for random reads. And keep in mind: RAID 5 is *bad* for data writes. In my experience, database data-write performance on RAID 5 UW SCSI is as slow as IDE drives, particulary for updating large numbers of records, *unless* the updated records are sequentially updated and clustered. But in a multi-user write-often setup, RAID 5 will slow you down and RAID 1 is better. Did that help? -Josh Berkus From pgsql-performance-owner@postgresql.org Thu Nov 21 16:17:15 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AB720476547 for ; Thu, 21 Nov 2002 16:17:14 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 4816347648C for ; Thu, 21 Nov 2002 16:16:57 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1836149; Thu, 21 Nov 2002 13:21:16 -0800 From: "Josh Berkus" Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no To: "Bjoern Metzdorf" , "scott.marlowe" Cc: X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 21 Nov 2002 13:21:16 -0800 Message-ID: In-Reply-To: <012201c2919f$fc4e1b40$0564a8c0@toolteam.net> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/185 X-Sequence-Number: 343 Bjoern, > Good to know. > > What do you think is faster: 3 drives in raid 1 or 3 drives in raid > 5? My experience? Raid 1. But that depends on other factors as well; your controller (software controllers use system RAM and thus lower performance), what kind of reads you're getting and how often. IMHO, RAID 5 is faster for sequential reads (lareg numbers of records on clustered indexes), RAID 1 for random reads. And keep in mind: RAID 5 is *bad* for data writes. In my experience, database data-write performance on RAID 5 UW SCSI is as slow as IDE drives, particulary for updating large numbers of records, *unless* the updated records are sequentially updated and clustered. But in a multi-user write-often setup, RAID 5 will slow you down and RAID 1 is better. Did that help? -Josh Berkus From pgsql-performance-owner@postgresql.org Thu Nov 21 16:19:43 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 832044758FE for ; Thu, 21 Nov 2002 16:19:42 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id E188847639B for ; Thu, 21 Nov 2002 16:19:38 -0500 (EST) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1836154; Thu, 21 Nov 2002 13:23:57 -0800 From: "Josh Berkus" Subject: Re: performance of insert/delete/update To: Wei Weng , pgsql-performance@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 21 Nov 2002 13:23:57 -0800 Message-ID: In-Reply-To: <1037912043.5931.5.camel@Monet> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/186 X-Sequence-Number: 344 Wei, > There had been a great deal of discussion of how to improve the > performance of select/sorting on this list, what about > insert/delete/update? > > Is there any rules of thumb we need to follow? What are the > parameters > we should tweak to whip the horse to go faster? yes, lots of rules. Wanna be more specific? You wondering about query structure, hardware, memory config, what? -Josh Berkus From pgsql-performance-owner@postgresql.org Thu Nov 21 16:25:04 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6594D4765E6 for ; Thu, 21 Nov 2002 16:25:03 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id F06174764B2 for ; Thu, 21 Nov 2002 16:24:50 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALLNvGx004566; Thu, 21 Nov 2002 14:23:57 -0700 (MST) Date: Thu, 21 Nov 2002 14:24:00 -0700 (MST) From: "scott.marlowe" To: Bjoern Metzdorf Cc: Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on In-Reply-To: <012201c2919f$fc4e1b40$0564a8c0@toolteam.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/188 X-Sequence-Number: 346 On Thu, 21 Nov 2002, Bjoern Metzdorf wrote: > > In fact, the linux kernel supports >2 drives in a mirror. Useful for a > > mostly read database that needs to handle lots of concurrent users. > > Good to know. > > What do you think is faster: 3 drives in raid 1 or 3 drives in raid 5? Generally RAID 5. RAID 1 is only faster if you are doing a lot of parellel reads. I.e. you have something like 10 agents reading at the same time. RAID 5 also works better under parallel load than a single drive. The fastest of course, is multidrive RAID0. But there's no redundancy. Oddly, my testing doesn't show any appreciable performance increase in linux by layering RAID5 or 1 over RAID0 or vice versa, something that is usually faster under most setups. From pgsql-performance-owner@postgresql.org Thu Nov 21 16:26:49 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CD105476246 for ; Thu, 21 Nov 2002 16:26:48 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 5B9FF476253 for ; Thu, 21 Nov 2002 16:26:47 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id EE361D60B; Thu, 21 Nov 2002 13:26:44 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id E3F0A5C02; Thu, 21 Nov 2002 13:26:44 -0800 (PST) Date: Thu, 21 Nov 2002 13:26:44 -0800 (PST) From: Stephan Szabo To: "Peter T. Brown" Cc: Subject: Re: stange optimizer results In-Reply-To: <1037914453.1784.45.camel@localhost.localdomain> Message-ID: <20021121132423.X99265-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/189 X-Sequence-Number: 347 On 21 Nov 2002, Peter T. Brown wrote: > trouble is that this SQL is being automatically created by my > object-relational mapping software and I can't easily customize it. Is > there any other way I can force Postgres to do the most efficient thing? Given no changes to the query, probably only by using blunt hammers like seeing if set enable_seqscan=off or set enable_mergejoin=off helps, but you'd want to wrap the statement with them (setting them globally is bad) and you might not be able to do that as well if your software won't let you. From pgsql-performance-owner@postgresql.org Thu Nov 21 15:36:48 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E17BB475BF9 for ; Thu, 21 Nov 2002 15:36:47 -0500 (EST) Received: from mail.memeticsystems.com (flywheel.memeticsystems.com [64.85.80.85]) by postgresql.org (Postfix) with SMTP id 2C010475B33 for ; Thu, 21 Nov 2002 15:36:47 -0500 (EST) Received: (qmail 13794 invoked from network); 21 Nov 2002 20:36:47 -0000 Received: from unknown (HELO ?10.0.0.102?) (63.249.24.21) by 0 with SMTP; 21 Nov 2002 20:36:47 -0000 Subject: Re: stange optimizer results From: "Peter T. Brown" To: Stephan Szabo Cc: pgsql-performance@postgresql.org In-Reply-To: <20021121103424.X96861-100000@megazone23.bigpanda.com> References: <20021121103424.X96861-100000@megazone23.bigpanda.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 21 Nov 2002 13:34:12 -0800 Message-Id: <1037914453.1784.45.camel@localhost.localdomain> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/181 X-Sequence-Number: 339 trouble is that this SQL is being automatically created by my object-relational mapping software and I can't easily customize it. Is there any other way I can force Postgres to do the most efficient thing? On Thu, 2002-11-21 at 10:35, Stephan Szabo wrote: > > On Thu, 21 Nov 2002, Stephan Szabo wrote: > > > On 21 Nov 2002, Peter T. Brown wrote: > > > > > Hello-- > > > > > > Attached is a file containing two SQL queries. The first take > > > prohibitively long to complete because, according to EXPLAIN, it ignore > > > two very important indexes. The second SQL query seems almost identical > > > to the first but runs very fast because, according to EXPLAIN, it does > > > uses all the indexes appropriately. > > > > > > Can someone please explain to me what the difference is here? Or if > > > there is something I can do with my indexes to make the first query run > > > like the second? > > > > It doesn't take into account that in general a=b, b=constant implies > > a=constant. > > > > Perhaps if you used explicit join syntax for visitor joining > > visitorextra it might help. Like doing: > > FROM visitor inner join visitorextra on (...) > > left outer join ... > > Sent this too quickly. It probably won't make it use an index on > vistorextra, but it may lower the number of expected rows that it's going > to be left outer joining so that a nested loop and index scan makes sense. > > -- Peter T. Brown Director Of Technology Memetic Systems, Inc. "Translating Customer Data Into Marketing Action." 206.335.2927 http://www.memeticsystems.com/ From pgsql-performance-owner@postgresql.org Thu Nov 21 16:50:03 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DAC43475AE4 for ; Thu, 21 Nov 2002 16:50:00 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 352FC4759AF for ; Thu, 21 Nov 2002 16:50:00 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALLnFGx023376; Thu, 21 Nov 2002 14:49:15 -0700 (MST) Date: Thu, 21 Nov 2002 14:49:18 -0700 (MST) From: "scott.marlowe" To: Wei Weng Cc: Josh Berkus , Subject: Re: performance of insert/delete/update In-Reply-To: <1037917437.5930.7.camel@Monet> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/190 X-Sequence-Number: 348 On 21 Nov 2002, Wei Weng wrote: > On Thu, 2002-11-21 at 16:23, Josh Berkus wrote: > > Wei, > > > > > There had been a great deal of discussion of how to improve the > > > performance of select/sorting on this list, what about > > > insert/delete/update? > > > > > > Is there any rules of thumb we need to follow? What are the > > > parameters > > > we should tweak to whip the horse to go faster? > > > > yes, lots of rules. Wanna be more specific? You wondering about > > query structure, hardware, memory config, what? > I am most concerned about the software side, that is query structures > and postgresql config. The absolutely most important thing to do to speed up inserts and updates is to squeeze as many as you can into one transaction. Within reason, of course. There's no great gain in putting more than a few thousand together at a time. If your application is only doing one or two updates in a transaction, it's going to be slower in terms of records written per second than an application that is updating 100 rows in a transaction. Reducing triggers and foreign keys on the inserted tables to a minimum helps. Inserting into temporary holding tables and then having a regular process that migrates the data into the main tables is sometimes necessary if you're putting a lot of smaller inserts into a very large dataset. Then using a unioned view to show the two tables as one. Putting WAL (e.g. $PGDATA/pg_xlog directory) on it's own drive(s). Putting indexes that have to be updated during inserts onto their own drive(s). Performing regular vacuums on heavily updated tables. Also, if your hardware is reliable, you can turn off fsync in postgresql.conf. That can increase performance by anywhere from 2 to 10 times, depending on your application. From pgsql-performance-owner@postgresql.org Thu Nov 21 16:58:14 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 36B7047662B for ; Thu, 21 Nov 2002 16:58:14 -0500 (EST) Received: from ns1.gnw.de (ns1.turtle-entertainment.de [193.41.200.20]) by postgresql.org (Postfix) with ESMTP id 24701476551 for ; Thu, 21 Nov 2002 16:58:05 -0500 (EST) Received: from [213.148.158.226] (helo=mail.office.turtle-entertainment.de) by ns1.gnw.de with esmtp (Exim 3.16 #1 (Debian)) id 18EzKs-00035v-00; Thu, 21 Nov 2002 22:58:10 +0100 Received: from pd9520be9.dip.t-dialin.net ([217.82.11.233] helo=shock) by mail.office.turtle-entertainment.de with asmtp (Exim 3.22 #7 (Debian)) id 18EzKj-0007pc-00; Thu, 21 Nov 2002 22:58:02 +0100 Message-ID: <016901c291a9$0f23cc20$0564a8c0@toolteam.net> From: "Bjoern Metzdorf" To: "scott.marlowe" Cc: References: Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on Date: Thu, 21 Nov 2002 22:57:59 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Scanner: exiscan *18EzKj-0007pc-00*BeH8PP91.UQ* http://duncanthrax.net/exiscan/ X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/191 X-Sequence-Number: 349 > Generally RAID 5. RAID 1 is only faster if you are doing a lot of > parellel reads. I.e. you have something like 10 agents reading at the > same time. RAID 5 also works better under parallel load than a single > drive. yep, but write performance sucks. > The fastest of course, is multidrive RAID0. But there's no redundancy. With 4 drives I'd always go for raid 10, fast and secure > Oddly, my testing doesn't show any appreciable performance increase in > linux by layering RAID5 or 1 over RAID0 or vice versa, something that > is usually faster under most setups. Is this with linux software raid? raid10 is not significantly faster? cant believe that... Regards, Bjoern From pgsql-performance-owner@postgresql.org Thu Nov 21 16:24:45 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D6DBB4762C1 for ; Thu, 21 Nov 2002 16:24:43 -0500 (EST) Received: from mta5.snet.net (mta5.snet.net [204.60.203.77]) by postgresql.org (Postfix) with ESMTP id E203C47655F for ; Thu, 21 Nov 2002 16:24:36 -0500 (EST) Received: from pop.snet.net (pop.snet.net [204.60.203.72]) by mta5.snet.net (8.12.3/8.12.3/SNET-mx-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gALLLD9m021483; Thu, 21 Nov 2002 16:21:13 -0500 (EST) X-Originating-IP: [64.252.95.167] X-SBCIS-MTA: [pop.snet.net] Received: from [192.168.1.83] (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.3/8.12.3/SNET-pop-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id gALLOC5b011636; Thu, 21 Nov 2002 16:24:25 -0500 (EST) Subject: Re: performance of insert/delete/update From: Wei Weng To: Josh Berkus Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Organization: Message-Id: <1037917437.5930.7.camel@Monet> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 21 Nov 2002 17:23:57 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/187 X-Sequence-Number: 345 On Thu, 2002-11-21 at 16:23, Josh Berkus wrote: > Wei, > > > There had been a great deal of discussion of how to improve the > > performance of select/sorting on this list, what about > > insert/delete/update? > > > > Is there any rules of thumb we need to follow? What are the > > parameters > > we should tweak to whip the horse to go faster? > > yes, lots of rules. Wanna be more specific? You wondering about > query structure, hardware, memory config, what? I am most concerned about the software side, that is query structures and postgresql config. Thanks -- Wei Weng Network Software Engineer KenCast Inc. From pgsql-performance-owner@postgresql.org Thu Nov 21 17:22:26 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 960A447607A for ; Thu, 21 Nov 2002 17:22:25 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id E6E51476052; Thu, 21 Nov 2002 17:22:24 -0500 (EST) Received: by davinci.ethosmedia.com (CommuniGate Pro PIPE 3.5.9) with PIPE id 1836283; Thu, 21 Nov 2002 14:26:45 -0800 X-Spam-Status: Scanner Called Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1836282; Thu, 21 Nov 2002 14:26:40 -0800 From: "Josh Berkus" Subject: Re: performance of insert/delete/update To: "scott.marlowe" , Wei Weng Cc: Josh Berkus , X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 21 Nov 2002 14:26:40 -0800 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Spam-Status: No, hits=-3.8 required=6.0 tests=IN_REP_TO, TO_LOCALPART_EQ_REAL, AWL version=2.20 X-Spam-Level: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/192 X-Sequence-Number: 350 Scott, > The absolutely most important thing to do to speed up inserts and > updates > is to squeeze as many as you can into one transaction. Within > reason, of > course. There's no great gain in putting more than a few thousand > together at a time. If your application is only doing one or two > updates > in a transaction, it's going to be slower in terms of records written > per > second than an application that is updating 100 rows in a > transaction. This only works up to the limit of the memory you have available for Postgres. If the updates in one transaction exceed your available memory, you'll see a lot of swaps to disk log that will slow things down by a factor of 10-50 times. > Reducing triggers and foreign keys on the inserted tables to a > minimum > helps. ... provided that this will not jeapordize your data integrity. If you have indispensable triggers in PL/pgSQL, re-qriting them in C will make them, and thus updates on their tables, faster. Also, for foriegn keys, it speeds up inserts and updates on parent tables with many child records if the foriegn key column in the child table is indexed. > Putting WAL (e.g. $PGDATA/pg_xlog directory) on it's own drive(s). > > Putting indexes that have to be updated during inserts onto their own > > drive(s). > > Performing regular vacuums on heavily updated tables. > > Also, if your hardware is reliable, you can turn off fsync in > postgresql.conf. That can increase performance by anywhere from 2 to > 10 > times, depending on your application. It can be dangerous though ... in the event of a power outage, for example, your database could be corrupted and difficult to recover. So ... "at your own risk". I've found that switching from fsync to fdatasync on Linux yields marginal performance gain ... about 10-20%. Also, if you are doing large updates (many records at once) you may want to increase WAL_FILES and CHECKPOINT_BUFFER in postgresql.conf to allow for large transactions. Finally, you want to structure your queries so that you do the minimum number of update writes possible, or insert writes. For example, a procedure that inserts a row, does some calculations, and then modifies several fields in that row is going to slow stuff down significantly compared to doing the calculations as variables and only a single insert. Certainly don't hit a table with 8 updates, each updating one field instead of a single update statement. -Josh Berkus From pgsql-performance-owner@postgresql.org Thu Nov 21 17:38:56 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9D78047626B for ; Thu, 21 Nov 2002 17:38:55 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id F240D476023 for ; Thu, 21 Nov 2002 17:38:53 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALMbiGx003890; Thu, 21 Nov 2002 15:37:45 -0700 (MST) Date: Thu, 21 Nov 2002 15:37:47 -0700 (MST) From: "scott.marlowe" To: Bjoern Metzdorf Cc: Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on In-Reply-To: <016901c291a9$0f23cc20$0564a8c0@toolteam.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/193 X-Sequence-Number: 351 On Thu, 21 Nov 2002, Bjoern Metzdorf wrote: > > Generally RAID 5. RAID 1 is only faster if you are doing a lot of > > parellel reads. I.e. you have something like 10 agents reading at the > > same time. RAID 5 also works better under parallel load than a single > > drive. > > yep, but write performance sucks. Well, it's not all that bad. After all, you only have to read the parity stripe and data stripe (two reads) update the data stripe, xor the new data stripe against the old parity stripe, and write both. In RAID 1 you have to read the old data stripe, update it, and then write it to two drives. So, generally speaking, it's not that much more work on RAID 5 than 1. My experience has been that RAID5 is only about 10 to 20% percent slower than RAID1 in writing, if that. > > The fastest of course, is multidrive RAID0. But there's no redundancy. > > With 4 drives I'd always go for raid 10, fast and secure > > > Oddly, my testing doesn't show any appreciable performance increase in > > linux by layering RAID5 or 1 over RAID0 or vice versa, something that > > is usually faster under most setups. > > Is this with linux software raid? raid10 is not significantly faster? cant > believe that... Yep, Linux software raid. It seems like it doesn't parallelize well. That's with several different setups. I've tested it on a machine a dual Ultra 40/80 controller and 6 Ultra wide 10krpm SCSI drives, and no matter how I arrange the drives, 50, 10, 01, 05, the old 1 or 5 setups are just about as fast. From pgsql-performance-owner@postgresql.org Thu Nov 21 17:55:03 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 771B9475B33 for ; Thu, 21 Nov 2002 17:55:02 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id CBF654759AF for ; Thu, 21 Nov 2002 17:55:01 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gALMsBGx014779; Thu, 21 Nov 2002 15:54:11 -0700 (MST) Date: Thu, 21 Nov 2002 15:54:14 -0700 (MST) From: "scott.marlowe" To: Josh Berkus Cc: Wei Weng , Subject: Re: performance of insert/delete/update In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/194 X-Sequence-Number: 352 On Thu, 21 Nov 2002, Josh Berkus wrote: > Scott, > > > The absolutely most important thing to do to speed up inserts and > > updates > > is to squeeze as many as you can into one transaction. Within > > reason, of > > course. There's no great gain in putting more than a few thousand > > together at a time. If your application is only doing one or two > > updates > > in a transaction, it's going to be slower in terms of records written > > per > > second than an application that is updating 100 rows in a > > transaction. > > This only works up to the limit of the memory you have available for > Postgres. If the updates in one transaction exceed your available > memory, you'll see a lot of swaps to disk log that will slow things > down by a factor of 10-50 times. Sorry, but that isn't true. MVCC means we don't have to hold all the data in memory, we can have multiple versions of the same tuples on disk, and use memory for what it's meant for, buffering. The performance gain comes from the fact that postgresql doesn't have to perform the data consistency checks needed during an insert until after all the rows are inserted, and it can "gang check" them/ > > Reducing triggers and foreign keys on the inserted tables to a > > minimum > > helps. > > ... provided that this will not jeapordize your data integrity. If you > have indispensable triggers in PL/pgSQL, re-qriting them in C will make > them, and thus updates on their tables, faster. Agreed. But you've probably seen the occasional "I wasn't sure if we needed that check or not, so I threw it in just in case" kind of database design. :-) I definitely don't advocate just tossing all your FKs to make it run faster. Also note that many folks have replaced foreign keys with triggers and gained in performance, as fks in pgsql still have some deadlock issues to be worked out. > Also, for foriegn keys, it speeds up inserts and updates on parent > tables with many child records if the foriegn key column in the child > table is indexed. Absolutely. > > Putting WAL (e.g. $PGDATA/pg_xlog directory) on it's own drive(s). > > > > Putting indexes that have to be updated during inserts onto their own > > > > drive(s). > > > > Performing regular vacuums on heavily updated tables. > > > > Also, if your hardware is reliable, you can turn off fsync in > > postgresql.conf. That can increase performance by anywhere from 2 to > > 10 > > times, depending on your application. > > It can be dangerous though ... in the event of a power outage, for > example, your database could be corrupted and difficult to recover. So > ... "at your own risk". No, the database will not be corrupted, at least not in my experience. however, you MAY lose data from transactions that you thought were committed. I think Tom posted something about this a few days back. > I've found that switching from fsync to fdatasync on Linux yields > marginal performance gain ... about 10-20%. I'll have to try that. > Also, if you are doing large updates (many records at once) you may > want to increase WAL_FILES and CHECKPOINT_BUFFER in postgresql.conf to > allow for large transactions. Actually, postgresql will create more WAL files if it needs to to handle the size of a transaction. BUT, it won't create extra ones for heavier parallel load without being told to. I've inserted 100,000 rows at a time with no problem on a machine with only 1 WAL file specified, and it didn't burp. It does run faster having multiple wal files when under parallel load. > Finally, you want to structure your queries so that you do the minimum > number of update writes possible, or insert writes. For example, a > procedure that inserts a row, does some calculations, and then modifies > several fields in that row is going to slow stuff down significantly > compared to doing the calculations as variables and only a single > insert. Certainly don't hit a table with 8 updates, each updating one > field instead of a single update statement. This is critical, and bites many people coming from a row level locking database to an MVCC database. In MVCC every update creates a new on disk tuple. I think someone on the list a while back was updating their database something like this: update table set field1='abc' where id=1; update table set field2='def' where id=1; update table set field3='ghi' where id=1; update table set field4='jkl' where id=1; update table set field5='mno' where id=1; update table set field6='pqr' where id=1; and they had to vacuum something like every 5 minutes. Also, things like: update table set field1=field1+1 are killers in an MVCC database as well. From pgsql-performance-owner@postgresql.org Thu Nov 21 18:32:51 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4EB25475F27 for ; Thu, 21 Nov 2002 18:32:50 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id EBFA5476747 for ; Thu, 21 Nov 2002 18:32:46 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1836398; Thu, 21 Nov 2002 15:37:06 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "scott.marlowe" Subject: Re: performance of insert/delete/update Date: Thu, 21 Nov 2002 15:34:53 -0800 X-Mailer: KMail [version 1.4] Cc: Wei Weng , References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211211534.53358.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/195 X-Sequence-Number: 353 Scott, > > This only works up to the limit of the memory you have available for > > Postgres. If the updates in one transaction exceed your available > > memory, you'll see a lot of swaps to disk log that will slow things > > down by a factor of 10-50 times. >=20 > Sorry, but that isn't true. MVCC means we don't have to hold all the dat= a=20 > in memory, we can have multiple versions of the same tuples on disk, and= =20 > use memory for what it's meant for, buffering. Sorry, you're absolutely correct. I don't know what I was thinking of; 's = the=20 problem with an off-the-cuff response. Please disregard the previous quote. Instead: Doing several large updates in a single transaction can lower performance i= f=20 the number of updates is sufficient to affect index usability and a VACUUM = is=20 really needed between them. For example, a series of large data=20 transformation statements on a single table or set of related tables should= =20 have VACCUUM statements between them, thus preventing you from putting them= =20 in a single transaction.=20=20=20 Example, the series: 1. INSERT 10,000 ROWS INTO table_a; 2. UPDATE 100,000 ROWS IN table_a WHERE table_b; 3. UPDATE 100,000 ROWS IN table_c WHERE table_a; WIll almost certainly need a VACUUM or even VACUUM FULL table_a after 2),= =20 requiring you to split the update series into 2 transactions. Otherwise, t= he=20 "where table_a" condition in step 3) will be extremely slow. > Also note that many folks have replaced foreign keys with triggers and=20 > gained in performance, as fks in pgsql still have some deadlock issues to= =20 > be worked out. Yeah. I think Neil Conway is overhauling FKs, which everyone considers a = bit=20 of a hack in the current implementation, including Jan who wrote it. > > It can be dangerous though ... in the event of a power outage, for > > example, your database could be corrupted and difficult to recover. So > > ... "at your own risk". >=20 > No, the database will not be corrupted, at least not in my experience.=20= =20 > however, you MAY lose data from transactions that you thought were=20 > committed. I think Tom posted something about this a few days back. Hmmm ... have you done this? I'd like the performance gain, but I don't wa= nt=20 to risk my data integrity. I've seen some awful things in databases (such = as=20 duplicate primary keys) from yanking a power cord repeatedly. > update table set field1=3Dfield1+1 >=20 > are killers in an MVCC database as well. Yeah -- don't I know it. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 22 02:31:29 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 59E4B4759AF for ; Fri, 22 Nov 2002 02:31:27 -0500 (EST) Received: from relay.icomedias.com (relay.icomedias.com [62.99.232.66]) by postgresql.org (Postfix) with ESMTP id 554F64758FE for ; Fri, 22 Nov 2002 02:31:26 -0500 (EST) Received: from 10.192.17.128 ([10.192.17.128]) by relay.icomedias.com (8.12.5/8.12.5) with ESMTP id gAM7VCvO024362; Fri, 22 Nov 2002 08:31:12 +0100 From: Mario Weilguni To: "Bjoern Metzdorf" , "scott.marlowe" Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on Date: Fri, 22 Nov 2002 08:31:11 +0100 User-Agent: KMail/1.5 Cc: References: <012201c2919f$fc4e1b40$0564a8c0@toolteam.net> In-Reply-To: <012201c2919f$fc4e1b40$0564a8c0@toolteam.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200211220831.11599.mweilguni@sime.com> avpresult: 0, ok, ok X-Scanned-By: MIMEDefang 2.16 (www . roaringpenguin . com / mimedefang) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/196 X-Sequence-Number: 354 Am Donnerstag, 21. November 2002 21:53 schrieb Bjoern Metzdorf: > > In fact, the linux kernel supports >2 drives in a mirror. Useful for a > > mostly read database that needs to handle lots of concurrent users. > > Good to know. > > What do you think is faster: 3 drives in raid 1 or 3 drives in raid 5? > > Regards, > Bjoern > If 4 drives are an option, I suggest 2 x RAID1, one for data, and one for WAL and temporary DB space (pg_temp). Regards, Mario Weilguni From pgsql-performance-owner@postgresql.org Fri Nov 22 08:52:49 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7384E475E20 for ; Fri, 22 Nov 2002 08:52:48 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id C5B36475AE6 for ; Fri, 22 Nov 2002 08:52:47 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gAMDqmsX023483; Fri, 22 Nov 2002 08:52:50 -0500 (EST) To: Mario Weilguni Cc: "Bjoern Metzdorf" , "scott.marlowe" , pgsql-performance@postgresql.org Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on In-reply-to: <200211220831.11599.mweilguni@sime.com> References: <012201c2919f$fc4e1b40$0564a8c0@toolteam.net> <200211220831.11599.mweilguni@sime.com> Comments: In-reply-to Mario Weilguni message dated "Fri, 22 Nov 2002 08:31:11 +0100" Date: Fri, 22 Nov 2002 08:52:48 -0500 Message-ID: <23482.1037973168@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/197 X-Sequence-Number: 355 Mario Weilguni writes: > If 4 drives are an option, I suggest 2 x RAID1, one for data, and one for WAL and temporary DB space (pg_temp). Ideally there should be *nothing* on the WAL drive except WAL; you don't ever want that disk head seeking away from the WAL. Put the temp files on the data disk. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 22 09:16:13 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 20AD8475F00 for ; Fri, 22 Nov 2002 09:16:10 -0500 (EST) Received: from ds9.quadratec-software.com (ds9.quadratec-software.com [62.23.102.82]) by postgresql.org (Postfix) with ESMTP id DBE89475EBD for ; Fri, 22 Nov 2002 09:16:07 -0500 (EST) Received: from spade.orsay.quadratec.fr (deltaq.quadratec-software.com [62.23.102.66]) by ds9.quadratec-software.com (8.11.3/8.11.3) with ESMTP id gAMEG0I31716; Fri, 22 Nov 2002 15:16:01 +0100 Received: from hotshine (hotshine.orsay.quadratec.fr [172.16.200.100]) by spade.orsay.quadratec.fr (Switch-2.1.0/Switch-2.1.0) with SMTP id gAMEFxT12173; Fri, 22 Nov 2002 15:15:59 +0100 (CET) From: "philip johnson" To: "Tom Lane" Cc: Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on Date: Fri, 22 Nov 2002 15:17:26 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 1 (Highest) X-MSMail-Priority: High X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <23482.1037973168@sss.pgh.pa.us> Importance: High X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/198 X-Sequence-Number: 356 pgsql-performance-owner@postgresql.org wrote: > Objet : Re: [PERFORM] [ADMIN] H/W RAID 5 on slower disks versus no > raid on > > > Mario Weilguni writes: >> If 4 drives are an option, I suggest 2 x RAID1, one for data, and >> one for WAL and temporary DB space (pg_temp). > > Ideally there should be *nothing* on the WAL drive except WAL; you > don't ever want that disk head seeking away from the WAL. Put the > temp files on the data disk. > > regards, tom lane > > ---------------------------(end of > broadcast)--------------------------- TIP 4: Don't 'kill -9' the > postmaster which temp files ? From pgsql-performance-owner@postgresql.org Fri Nov 22 10:01:54 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A2DA2475AE4 for ; Fri, 22 Nov 2002 10:01:48 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id A8CD84758FE for ; Fri, 22 Nov 2002 10:01:47 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18FFJY-0003Hs-00 for ; Fri, 22 Nov 2002 10:01:52 -0500 Date: Fri, 22 Nov 2002 10:01:52 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: [ADMIN] H/W RAID 5 on slower disks versus no raid on Message-ID: <20021122100152.I27984@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <012201c2919f$fc4e1b40$0564a8c0@toolteam.net> <200211220831.11599.mweilguni@sime.com> <23482.1037973168@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <23482.1037973168@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Fri, Nov 22, 2002 at 08:52:48AM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/199 X-Sequence-Number: 357 On Fri, Nov 22, 2002 at 08:52:48AM -0500, Tom Lane wrote: > Mario Weilguni writes: > > If 4 drives are an option, I suggest 2 x RAID1, one for data, and one for WAL and temporary DB space (pg_temp). > > Ideally there should be *nothing* on the WAL drive except WAL; you don't > ever want that disk head seeking away from the WAL. Put the temp files > on the data disk. Unless the interface and disks are so fast that it makes no difference. Try as I might, I can't make WAL go any faster on its own controller and disks than if I leave it on the same filesystem as everything else, on our production arrays. We use Sun A5200s, and I have tried it set up with the WAL on separate disks on the box, and on separate disks in the array, and even on separate disks on a separate controller in the array (I've never tried it with two arrays, but I don't have infinite money, either). I have never managed to demonstrate a throughput difference outside the margin of error of my tests. One arrangement -- putting the WAL on a separate pair of UFS disks using RAID 1, but not on the fibre channel -- was demonstrably slower than leaving the WAL in the data area. Nothing is proved by this, of course, except that if you're going to use high-performance hardware, you have to tune and test over and over again. I was truly surprised that a separate pair of VxFS RAID-1 disks in the array were no faster, but I guess it makes sense: the array is just as busy in either case, and the disks are really fast. I still don't really believe it, though. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Fri Nov 22 10:57:10 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7B7EC4758FE for ; Fri, 22 Nov 2002 10:56:56 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 137C3475461 for ; Fri, 22 Nov 2002 10:56:55 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAMFuHGx007227; Fri, 22 Nov 2002 08:56:17 -0700 (MST) Date: Fri, 22 Nov 2002 08:56:14 -0700 (MST) From: "scott.marlowe" To: Josh Berkus Cc: Wei Weng , Subject: Re: performance of insert/delete/update In-Reply-To: <200211211534.53358.josh@agliodbs.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/200 X-Sequence-Number: 358 On Thu, 21 Nov 2002, Josh Berkus wrote: > Doing several large updates in a single transaction can lower performance if > the number of updates is sufficient to affect index usability and a VACUUM is > really needed between them. For example, a series of large data > transformation statements on a single table or set of related tables should > have VACCUUM statements between them, thus preventing you from putting them > in a single transaction. > > Example, the series: > 1. INSERT 10,000 ROWS INTO table_a; > 2. UPDATE 100,000 ROWS IN table_a WHERE table_b; > 3. UPDATE 100,000 ROWS IN table_c WHERE table_a; > > WIll almost certainly need a VACUUM or even VACUUM FULL table_a after 2), > requiring you to split the update series into 2 transactions. Otherwise, the > "where table_a" condition in step 3) will be extremely slow. Very good point. One that points out the different mind set one needs when dealing with pgsql. > > > It can be dangerous though ... in the event of a power outage, for > > > example, your database could be corrupted and difficult to recover. So > > > ... "at your own risk". > > > > No, the database will not be corrupted, at least not in my experience. > > however, you MAY lose data from transactions that you thought were > > committed. I think Tom posted something about this a few days back. > > Hmmm ... have you done this? I'd like the performance gain, but I don't want > to risk my data integrity. I've seen some awful things in databases (such as > duplicate primary keys) from yanking a power cord repeatedly. I have, with killall -9 postmaster, on several occasions during testing under heavy parallel load. I've never had 7.2.x fail because of this. From pgsql-performance-owner@postgresql.org Fri Nov 22 23:14:01 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EF13D475EC7 for ; Fri, 22 Nov 2002 23:13:58 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 3F9FF475E30; Fri, 22 Nov 2002 23:13:58 -0500 (EST) Received: by davinci.ethosmedia.com (CommuniGate Pro PIPE 3.5.9) with PIPE id 1838335; Fri, 22 Nov 2002 20:18:28 -0800 X-Spam-Status: Scanner Called Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1838339; Fri, 22 Nov 2002 20:18:22 -0800 From: "Josh Berkus" Subject: Re: performance of insert/delete/update To: "scott.marlowe" , Josh Berkus Cc: Wei Weng , X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Fri, 22 Nov 2002 20:18:22 -0800 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Spam-Status: No, hits=-3.8 required=6.0 tests=IN_REP_TO, TO_LOCALPART_EQ_REAL, AWL version=2.20 X-Spam-Level: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/201 X-Sequence-Number: 359 Scott, > > > The absolutely most important thing to do to speed up inserts and > > > updates > > > is to squeeze as many as you can into one transaction. I was discussing this on IRC, and nobody could verify this assertion. Do you have an example of bunlding multiple writes into a transaction giving a performance gain? -Josh From pgsql-performance-owner@postgresql.org Sat Nov 23 10:06:01 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DFA56476414 for ; Sat, 23 Nov 2002 10:05:57 -0500 (EST) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by postgresql.org (Postfix) with ESMTP id 5A17A476413 for ; Sat, 23 Nov 2002 10:05:56 -0500 (EST) Received: from localhost.localdomain ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20021123150600.DRDF2203.lakemtao02.cox.net@localhost.localdomain> for ; Sat, 23 Nov 2002 10:06:00 -0500 Subject: Re: performance of insert/delete/update From: Ron Johnson To: PgSQL Performance ML In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 23 Nov 2002 09:06:00 -0600 Message-Id: <1038063960.16125.22.camel@haggis> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/202 X-Sequence-Number: 360 On Fri, 2002-11-22 at 22:18, Josh Berkus wrote: > Scott, > > > > > The absolutely most important thing to do to speed up inserts and > > > > updates > > > > is to squeeze as many as you can into one transaction. > > I was discussing this on IRC, and nobody could verify this assertion. > Do you have an example of bunlding multiple writes into a transaction > giving a performance gain? Unfortunately, I missed the beginning of this thread, but I do know that eliminating as many indexes as possible is the answer. If I'm going to insert "lots" of rows in an off-line situation, then I'll drop *all* of the indexes, load the data, then re-index. If deleting "lots", then I'll drop all but the 1 relevant index, then re-index afterwards. As for bundling multiple statements into a transaction to increase performance, I think the questions are: - how much disk IO does one BEGIN TRANSACTION do? If it *does* do disk IO, then "bundling" *will* be more efficient, since less disk IO will be performed. - are, for example, 500 COMMITs of small amounts of data more or less efficient than 1 COMMIT of a large chunk of data? On the proprietary database that I use at work, efficiency goes up, then levels off at ~100 inserts per transaction. Ron -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "they love our milk and honey, but preach about another | | way of living" | | Merle Haggard, "The Fighting Side Of Me" | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sat Nov 23 14:23:56 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8E2CD476069 for ; Sat, 23 Nov 2002 14:23:54 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 6BF73476445 for ; Sat, 23 Nov 2002 14:23:32 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1839137; Sat, 23 Nov 2002 11:28:01 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Ron Johnson , PgSQL Performance ML Subject: Re: performance of insert/delete/update Date: Sat, 23 Nov 2002 11:25:45 -0800 X-Mailer: KMail [version 1.4] References: <1038063960.16125.22.camel@haggis> In-Reply-To: <1038063960.16125.22.camel@haggis> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211231125.45663.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/203 X-Sequence-Number: 361 Ron, > As for bundling multiple statements into a transaction to increase > performance, I think the questions are: > - how much disk IO does one BEGIN TRANSACTION do? If it *does* > do disk IO, then "bundling" *will* be more efficient, since > less disk IO will be performed. > - are, for example, 500 COMMITs of small amounts of data more or=20 > less efficient than 1 COMMIT of a large chunk of data? On the > proprietary database that I use at work, efficiency goes up, > then levels off at ~100 inserts per transaction. That's because some commercial databases (MS SQL, Sybase) use an "unwinding= =20 transaction log" method of updating. That is, during a transaction, change= s=20 are written only to the transaction log, and those changes are "played" to= =20 the database only on a COMMIT. It's an approach that is more efficient for= =20 large transactions, but has the unfortuate side effect of *requiring* read= =20 and write row locks for the duration of the transaction. In Postgres, with MVCC, changes are written to the database immediately wit= h a=20 new transaction ID and the new rows are "activated" on COMMIT. So the=20 changes are written to the database as the statements are executed,=20 regardless. This is less efficient for large transactions than the=20 "unwinding log" method, but has the advantage of eliminating read locks=20 entirely and most deadlock situations. Under MVCC, then, I am not convinced that bundling a bunch of writes into o= ne=20 transaction is faster until I see it demonstrated. I certainly see no=20 performance gain on my system. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Nov 23 15:20:18 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4D6904758C9 for ; Sat, 23 Nov 2002 15:20:16 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A67FF4758BD for ; Sat, 23 Nov 2002 15:20:15 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gANKKAsX019251; Sat, 23 Nov 2002 15:20:10 -0500 (EST) To: josh@agliodbs.com Cc: Ron Johnson , PgSQL Performance ML Subject: Re: performance of insert/delete/update In-reply-to: <200211231125.45663.josh@agliodbs.com> References: <1038063960.16125.22.camel@haggis> <200211231125.45663.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Sat, 23 Nov 2002 11:25:45 -0800" Date: Sat, 23 Nov 2002 15:20:10 -0500 Message-ID: <19250.1038082810@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/204 X-Sequence-Number: 362 Josh Berkus writes: > Under MVCC, then, I am not convinced that bundling a bunch of writes into one > transaction is faster until I see it demonstrated. I certainly see no > performance gain on my system. Are you running with fsync off? The main reason for bundling updates into larger transactions is that each transaction commit requires an fsync on the WAL log. If you have fsync enabled, it is physically impossible to commit transactions faster than one per revolution of the WAL disk, no matter how small the transactions. (*) So it pays to make the transactions larger, not smaller. On my machine I see a sizable difference (more than 2x) in the rate at which simple INSERT statements are processed as separate transactions and as large batches --- if I have fsync on. With fsync off, nearly no difference. regards, tom lane (*) See recent proposals from Curtis Faith in pgsql-hackers about how we might circumvent that limit ... but it's there today. From pgsql-performance-owner@postgresql.org Sat Nov 23 15:29:37 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6AAC1475FF9 for ; Sat, 23 Nov 2002 15:29:35 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id C977D475FC6 for ; Sat, 23 Nov 2002 15:29:34 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1839202; Sat, 23 Nov 2002 12:34:05 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane Subject: Re: performance of insert/delete/update Date: Sat, 23 Nov 2002 12:31:50 -0800 X-Mailer: KMail [version 1.4] Cc: Ron Johnson , PgSQL Performance ML References: <200211231125.45663.josh@agliodbs.com> <19250.1038082810@sss.pgh.pa.us> In-Reply-To: <19250.1038082810@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211231231.50102.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/205 X-Sequence-Number: 363 Tom, > On my machine I see a sizable difference (more than 2x) in the rate at > which simple INSERT statements are processed as separate transactions > and as large batches --- if I have fsync on. With fsync off, nearly no > difference. I'm using fdatasych, which *does* perform faster than fsych on my system.= =20=20=20 Could this make the difference? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Nov 23 15:42:01 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C7E194758C9 for ; Sat, 23 Nov 2002 15:41:59 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 197114758BD for ; Sat, 23 Nov 2002 15:41:59 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gANKfvsX019420; Sat, 23 Nov 2002 15:41:57 -0500 (EST) To: josh@agliodbs.com Cc: Ron Johnson , PgSQL Performance ML Subject: Re: performance of insert/delete/update In-reply-to: <200211231231.50102.josh@agliodbs.com> References: <200211231125.45663.josh@agliodbs.com> <19250.1038082810@sss.pgh.pa.us> <200211231231.50102.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Sat, 23 Nov 2002 12:31:50 -0800" Date: Sat, 23 Nov 2002 15:41:57 -0500 Message-ID: <19419.1038084117@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/206 X-Sequence-Number: 364 Josh Berkus writes: >> On my machine I see a sizable difference (more than 2x) in the rate at >> which simple INSERT statements are processed as separate transactions >> and as large batches --- if I have fsync on. With fsync off, nearly no >> difference. > I'm using fdatasych, which *does* perform faster than fsych on my system. > Could this make the difference? No; you still have to write the data and wait for the disk to spin. (FWIW, PG defaults to wal_sync_method = open_datasync on my system, and that's what I used in checking the speed just now. So I wasn't actually executing any fsync() calls either.) On lots of PC hardware, the disks are configured to lie and report write complete as soon as they've accepted the data into their internal buffers. If you see very little difference between fsync on and fsync off, or if you are able to benchmark transaction rates in excess of your disk's RPM, you should suspect that your disk drive is lying to you. As an example: in testing INSERT speed on my old HP box just now, I got measured rates of about 16000 inserts/minute with fsync off, and 5700/min with fsync on (for 1 INSERT per transaction). Knowing that my disk drive is 6000 RPM, the latter number is credible. On my PC I get numbers way higher than the disk rotation rate :-( regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 23 15:46:07 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BAAC447641B for ; Sat, 23 Nov 2002 15:46:04 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id C9F47476406 for ; Sat, 23 Nov 2002 15:46:00 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1839218; Sat, 23 Nov 2002 12:50:30 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane Subject: Re: performance of insert/delete/update Date: Sat, 23 Nov 2002 12:48:14 -0800 X-Mailer: KMail [version 1.4] Cc: Ron Johnson , PgSQL Performance ML References: <200211231231.50102.josh@agliodbs.com> <19419.1038084117@sss.pgh.pa.us> In-Reply-To: <19419.1038084117@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211231248.14863.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/207 X-Sequence-Number: 365 Tom, > As an example: in testing INSERT speed on my old HP box just now, > I got measured rates of about 16000 inserts/minute with fsync off, and > 5700/min with fsync on (for 1 INSERT per transaction). Knowing that my > disk drive is 6000 RPM, the latter number is credible. On my PC I get > numbers way higher than the disk rotation rate :-( Thanks for the info. As long as I have your ear, what's your opinion on th= e=20 risk level of running with fsynch off on a production system? I've seen a= =20 lot of posts on this list opining the lack of danger, but I'm a bit paranoi= d. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Nov 23 16:20:45 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 052EC4758C9 for ; Sat, 23 Nov 2002 16:20:45 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 603674758BD for ; Sat, 23 Nov 2002 16:20:44 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gANLKdsX019605; Sat, 23 Nov 2002 16:20:39 -0500 (EST) To: josh@agliodbs.com Cc: Ron Johnson , PgSQL Performance ML Subject: Re: performance of insert/delete/update In-reply-to: <200211231248.14863.josh@agliodbs.com> References: <200211231231.50102.josh@agliodbs.com> <19419.1038084117@sss.pgh.pa.us> <200211231248.14863.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Sat, 23 Nov 2002 12:48:14 -0800" Date: Sat, 23 Nov 2002 16:20:39 -0500 Message-ID: <19604.1038086439@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/208 X-Sequence-Number: 366 Josh Berkus writes: > Thanks for the info. As long as I have your ear, what's your opinion on the > risk level of running with fsynch off on a production system? Depends on how much you trust your hardware, kernel, and power source. Fsync off does not introduce any danger from Postgres crashes --- we always write data out of userspace to the kernel before committing. The question is whether writes can be relied on to get to disk once the kernel has 'em. There is a definite risk of data corruption (not just lost transactions, but actively inconsistent database contents) if you suffer a system-level crash while running with fsync off. The theory of WAL (which remember means write *ahead* log) is that it protects you from data corruption as long as WAL records always hit disk before the associated changes in database data files do. Then after a crash you can replay the WAL to make sure you have actually done all the changes described by each readable WAL record, and presto you're consistent up to the end of the readable WAL. But if data file writes can get to disk in advance of their WAL record, you could have a situation where some but not all changes described by a WAL record are in the database after a system crash and recovery. This could mean incompletely applied transactions, broken indexes, or who knows what. When you get right down to it, what we use fsync for is to force write ordering --- Unix kernels do not guarantee write ordering any other way. We use it to ensure WAL records hit disk before data file changes do. Bottom line: I wouldn't run with fsync off in a mission-critical database. If you're prepared to accept a risk of having to restore from your last backup after a system crash, maybe it's okay. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 23 16:27:08 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 903D64758C9 for ; Sat, 23 Nov 2002 16:27:06 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id E33E64758BD for ; Sat, 23 Nov 2002 16:27:05 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.5.9) with ESMTP id 1839252; Sat, 23 Nov 2002 13:31:36 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane Subject: Re: performance of insert/delete/update Date: Sat, 23 Nov 2002 13:29:20 -0800 X-Mailer: KMail [version 1.4] Cc: Ron Johnson , PgSQL Performance ML References: <200211231248.14863.josh@agliodbs.com> <19604.1038086439@sss.pgh.pa.us> In-Reply-To: <19604.1038086439@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211231329.20384.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/209 X-Sequence-Number: 367 Tom, > When you get right down to it, what we use fsync for is to force write > ordering --- Unix kernels do not guarantee write ordering any other way. > We use it to ensure WAL records hit disk before data file changes do. >=20 > Bottom line: I wouldn't run with fsync off in a mission-critical > database. If you're prepared to accept a risk of having to restore from > your last backup after a system crash, maybe it's okay. Thanks for that overview. Sadly, even with fsynch on, I was forced to rest= ore=20 from backup because the data needs to be 100% reliable and the crash was du= e=20 to a disk lockup on a checkpoint ... beyond the ability of WAL to deal with= ,=20 I think. One last, last question: I was just asked a question on IRC, and I can't f= ind=20 docs defining fsynch, fdatasynch, opensynch, and opendatasynch beyond secti= on=20 11.3 which just says that they are all synch methods. Are there docs? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Nov 23 16:41:46 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1676D4758C9 for ; Sat, 23 Nov 2002 16:41:39 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 5E4124758BD for ; Sat, 23 Nov 2002 16:41:38 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gANLfbsX019737; Sat, 23 Nov 2002 16:41:37 -0500 (EST) To: josh@agliodbs.com Cc: Ron Johnson , PgSQL Performance ML Subject: Re: performance of insert/delete/update In-reply-to: <200211231329.20384.josh@agliodbs.com> References: <200211231248.14863.josh@agliodbs.com> <19604.1038086439@sss.pgh.pa.us> <200211231329.20384.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Sat, 23 Nov 2002 13:29:20 -0800" Date: Sat, 23 Nov 2002 16:41:37 -0500 Message-ID: <19736.1038087697@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/210 X-Sequence-Number: 368 Josh Berkus writes: > One last, last question: I was just asked a question on IRC, and I > can't find docs defining fsynch, fdatasynch, opensynch, and > opendatasynch beyond section 11.3 which just says that they are all > synch methods. Are there docs? Section 11.3 of what? The only mention of open_datasync that I see in the docs is in the Admin Guide chapter 3: http://developer.postgresql.org/docs/postgres/runtime-config.html#RUNTIME-CONFIG-WAL which saith WAL_SYNC_METHOD (string) Method used for forcing WAL updates out to disk. Possible values are FSYNC (call fsync() at each commit), FDATASYNC (call fdatasync() at each commit), OPEN_SYNC (write WAL files with open() option O_SYNC), or OPEN_DATASYNC (write WAL files with open() option O_DSYNC). Not all of these choices are available on all platforms. This option can only be set at server start or in the postgresql.conf file. This may not help you much to decide which to use :-(, but it does tell you what they are. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 25 11:34:33 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 36C58475D22 for ; Mon, 25 Nov 2002 11:34:32 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 7D604475D39 for ; Mon, 25 Nov 2002 11:34:31 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAPGVimn025073; Mon, 25 Nov 2002 09:31:53 -0700 (MST) Date: Mon, 25 Nov 2002 09:31:20 -0700 (MST) From: "scott.marlowe" To: Josh Berkus Cc: Wei Weng , Subject: Re: performance of insert/delete/update In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/211 X-Sequence-Number: 369 On Fri, 22 Nov 2002, Josh Berkus wrote: > Scott, > > > > > The absolutely most important thing to do to speed up inserts and > > > > updates > > > > is to squeeze as many as you can into one transaction. > > I was discussing this on IRC, and nobody could verify this assertion. > Do you have an example of bunlding multiple writes into a transaction > giving a performance gain? Yes, my own experience. It's quite easy to test if you have a database with a large table to play with, use pg_dump to dump a table with the -d switch (makes the dump use insert statements.) Then, make two versions of the dump, one which has a begin;end; pair around all the inserts and one that doesn't, then use psql -e to restore both dumps. The difference is HUGE. Around 10 to 20 times faster with the begin end pairs. I'd think that anyone who's used postgresql for more than a few months could corroborate my experience. From pgsql-performance-owner@postgresql.org Mon Nov 25 17:30:45 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 410E8475C85 for ; Mon, 25 Nov 2002 17:30:43 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id EB9A8474E42 for ; Mon, 25 Nov 2002 17:30:41 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.1) with ESMTP id 1961668; Mon, 25 Nov 2002 14:31:13 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "scott.marlowe" Subject: Re: performance of insert/delete/update Date: Mon, 25 Nov 2002 14:33:07 -0800 X-Mailer: KMail [version 1.4] Cc: Wei Weng , References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211251433.07049.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/212 X-Sequence-Number: 370 Scott, > It's quite easy to test if you have a database with a large table to play= =20 > with, use pg_dump to dump a table with the -d switch (makes the dump use= =20 > insert statements.) Then, make two versions of the dump, one which has a= =20 > begin;end; pair around all the inserts and one that doesn't, then use psq= l=20 > -e to restore both dumps. The difference is HUGE. Around 10 to 20 times= =20 > faster with the begin end pairs.=20=20 >=20 > I'd think that anyone who's used postgresql for more than a few months=20 > could corroborate my experience. Ouch!=20=20 No need to get testy about it.=20=20=20 Your test works as you said; the way I tried testing it before was differen= t.=20=20=20 Good to know. However, this approach is only useful if you are doing=20 rapidfire updates or inserts coming off a single connection. But then it i= s=20 *very* useful. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 25 18:01:32 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7941D475EE1 for ; Mon, 25 Nov 2002 18:01:31 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id A7001475E24 for ; Mon, 25 Nov 2002 18:01:30 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAPMxhCm015281; Mon, 25 Nov 2002 15:59:43 -0700 (MST) Date: Mon, 25 Nov 2002 15:59:16 -0700 (MST) From: "scott.marlowe" To: Josh Berkus Cc: Wei Weng , Subject: Re: performance of insert/delete/update In-Reply-To: <200211251433.07049.josh@agliodbs.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/213 X-Sequence-Number: 371 On Mon, 25 Nov 2002, Josh Berkus wrote: > Scott, > > > It's quite easy to test if you have a database with a large table to play > > with, use pg_dump to dump a table with the -d switch (makes the dump use > > insert statements.) Then, make two versions of the dump, one which has a > > begin;end; pair around all the inserts and one that doesn't, then use psql > > -e to restore both dumps. The difference is HUGE. Around 10 to 20 times > > faster with the begin end pairs. > > > > I'd think that anyone who's used postgresql for more than a few months > > could corroborate my experience. > > Ouch! > > No need to get testy about it. > > Your test works as you said; the way I tried testing it before was different. > Good to know. However, this approach is only useful if you are doing > rapidfire updates or inserts coming off a single connection. But then it is > *very* useful. I didn't mean that in a testy way, it's just that after you've sat through a fifteen minute wait while a 1000 records are inserted, you pretty quickly switch to the method of inserting them all in one big transaction. That's all. Note that the opposite is what really gets people in trouble. I've seen folks inserting rather large amounts of data, say into ten or 15 tables, and their web servers were crawling under parallel load. Then, they put them into a single transaction and they just flew. The funny thing it, they've often avoided transactions because they figured they'd be slower than just inserting the rows, and you kinda have to make them sit down first before you show them the performance increase from putting all those inserts into a single transaction. No offense meant, really. It's just that you seemed to really doubt that putting things into one transaction helped, and putting things into one big transaction if like the very first postgresql lesson a lot of newcomers learn. :-) From pgsql-performance-owner@postgresql.org Mon Nov 25 18:44:41 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 126AC475EF7 for ; Mon, 25 Nov 2002 18:44:41 -0500 (EST) Received: from mta4.srv.hcvlny.cv.net (mta4.srv.hcvlny.cv.net [167.206.5.10]) by postgresql.org (Postfix) with ESMTP id 84B0D475EF0 for ; Mon, 25 Nov 2002 18:44:40 -0500 (EST) Received: from [192.168.1.4] (ool-18bd861d.dyn.optonline.net [24.189.134.29]) by mta4.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.05 (built Nov 6 2002)) with ESMTP id <0H6500LV7OHY6Q@mta4.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Mon, 25 Nov 2002 18:41:58 -0500 (EST) Date: Mon, 25 Nov 2002 18:41:53 -0500 From: Tim Gardner Subject: Re: performance of insert/delete/update In-reply-to: X-Sender: codeh1@cmail1.panix.com To: pgsql-performance@postgresql.org Cc: "scott.marlowe" Message-id: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/214 X-Sequence-Number: 372 >The funny thing it, they've often avoided transactions because they >figured they'd be slower than just inserting the rows, and you kinda have >to make them sit down first before you show them the performance increase >from putting all those inserts into a single transaction. > >No offense meant, really. It's just that you seemed to really doubt that >putting things into one transaction helped, and putting things into one >big transaction if like the very first postgresql lesson a lot of >newcomers learn. :-) Scott, I'm new to postgresql, and as you suggested, this is counter-intuitive to me. I would have thought that having to store all the inserts to be able to roll them back would take longer. Is my thinking wrong or not relevant? Why is this not the case? Thanks, Tim From pgsql-performance-owner@postgresql.org Mon Nov 25 19:19:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 72A63475C85 for ; Mon, 25 Nov 2002 19:19:36 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id A8BFF475C2B for ; Mon, 25 Nov 2002 19:19:35 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAQ0K3wv089279; Mon, 25 Nov 2002 19:20:04 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: performance of insert/delete/update From: Rod Taylor To: Tim Gardner Cc: Pgsql Performance , "scott.marlowe" In-Reply-To: References: Content-Type: text/plain Organization: Message-Id: <1038270003.89124.8.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 25 Nov 2002 19:20:03 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/215 X-Sequence-Number: 373 > I'm new to postgresql, and as you suggested, this is > counter-intuitive to me. I would have thought that having to store > all the inserts to be able to roll them back would take longer. Is > my thinking wrong or not relevant? Why is this not the case? Typically that is the case. But Postgresql switches it around a little bit. Different trade-offs. No rollback log, but other processes are forced to go through you're left over garbage (hence 'vacuum'). It's still kinda slow with hundreds of connections (as compared to Oracle) -- but close enough that a license fee -> hardware purchase funds transfer more than makes up for it. Get yourself a 1GB battery backed ramdisk on it's own scsi chain for WAL and it'll fly no matter what size of transaction you use ;) -- Rod Taylor From pgsql-performance-owner@postgresql.org Mon Nov 25 19:25:31 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6134E475CB1 for ; Mon, 25 Nov 2002 19:25:30 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 8ABCC475C9E for ; Mon, 25 Nov 2002 19:25:29 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAQ0OPCm000012; Mon, 25 Nov 2002 17:24:25 -0700 (MST) Date: Mon, 25 Nov 2002 17:23:57 -0700 (MST) From: "scott.marlowe" To: Tim Gardner Cc: Subject: Re: performance of insert/delete/update In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/216 X-Sequence-Number: 374 On Mon, 25 Nov 2002, Tim Gardner wrote: > >The funny thing it, they've often avoided transactions because they > >figured they'd be slower than just inserting the rows, and you kinda have > >to make them sit down first before you show them the performance increase > >from putting all those inserts into a single transaction. > > > >No offense meant, really. It's just that you seemed to really doubt that > >putting things into one transaction helped, and putting things into one > >big transaction if like the very first postgresql lesson a lot of > >newcomers learn. :-) > > Scott, > > I'm new to postgresql, and as you suggested, this is > counter-intuitive to me. I would have thought that having to store > all the inserts to be able to roll them back would take longer. Is > my thinking wrong or not relevant? Why is this not the case? Your thinking on this is wrong, and it is counter-intuitive to think that a transaction would speed things up. Postgresql is very different from other databases. Postgresql was designed from day one as a transactional database. Which is why it was so bothersome that an Oracle marketroid recently was telling the .org folks why they shouldn't use Postgresql because it didn't have transactions. Postgresql may have a few warts here and there, but not supporting transactions has NEVER been a problem for it. There are two factors that make Postgresql so weird in regards to transactions. One it that everything happens in a transaction (we won't mention truncate for a while, it's the only exception I know of.) The next factor that makes for fast inserts of large amounts of data in a transaction is MVCC. With Oracle and many other databases, transactions are written into a seperate log file, and when you commit, they are inserted into the database as one big group. This means you write your data twice, once into the transaction log, and once into the database. With Postgresql's implementation of MVCC, all your data are inserted in real time, with a transaction date that makes the other clients ignore them (mostly, other read committed transactions may or may not see them.) If there are indexes to update, they are updated in the same "invisible until committed" way. All this means that your inserts don't block anyone else's reads as well. This means that when you commit, all postgresql does is make them visible. In the event you roll back a transaction, the tuples are all just marked as dead and they get ignored. It's interesting when you work with folks who came from other databases. My coworker, who's been using Postgresql for about 2 years now, had an interesting experience when he first started here. He was inserting something like 10,000 rows. He comes over and tells me there must be something wrong with the database, as his inserts have been running for 10 minutes, and he's not even halfway through. So I had him stop the inserts, clean out the rows (it was a new table for a new project) and wrap all 10,000 inserts into a transaction. What had been running for 10 minutes now ran in about 30 seconds. He was floored. Well, good luck on using postgresql, and definitely keep in touch with the performance and general mailing lists. They're a wealth of useful info. From pgsql-performance-owner@postgresql.org Mon Nov 25 19:33:05 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D1E78475CB1 for ; Mon, 25 Nov 2002 19:33:04 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 2B6BF475C9E for ; Mon, 25 Nov 2002 19:33:04 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAQ0URCm002397; Mon, 25 Nov 2002 17:30:27 -0700 (MST) Date: Mon, 25 Nov 2002 17:30:00 -0700 (MST) From: "scott.marlowe" To: Rod Taylor Cc: Tim Gardner , Pgsql Performance Subject: Re: performance of insert/delete/update In-Reply-To: <1038270003.89124.8.camel@jester> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/217 X-Sequence-Number: 375 On 25 Nov 2002, Rod Taylor wrote: > > I'm new to postgresql, and as you suggested, this is > > counter-intuitive to me. I would have thought that having to store > > all the inserts to be able to roll them back would take longer. Is > > my thinking wrong or not relevant? Why is this not the case? > > Typically that is the case. But Postgresql switches it around a little > bit. Different trade-offs. No rollback log, but other processes are > forced to go through you're left over garbage (hence 'vacuum'). Yeah, which means you always need to do a vacuum on a table after a lot of updates/deletes. And analyze after a lot of inserts/updates/deletes. > It's still kinda slow with hundreds of connections (as compared to > Oracle) -- but close enough that a license fee -> hardware purchase > funds transfer more than makes up for it. Ain't it amazing how much hardware a typical Oracle license can buy? ;^) Heck, even the license cost MS-SQL server is enough to buy a nice quad Xeon with all the trimmings nowadays. Then you can probably still have enough left over for one of the pgsql developers to fly out and train your folks on it. From pgsql-performance-owner@postgresql.org Mon Nov 25 19:41:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A794847650C for ; Mon, 25 Nov 2002 19:41:08 -0500 (EST) Received: from mta10.srv.hcvlny.cv.net (mta10.srv.hcvlny.cv.net [167.206.5.45]) by postgresql.org (Postfix) with ESMTP id 1FA97476458 for ; Mon, 25 Nov 2002 19:41:01 -0500 (EST) Received: from [192.168.1.4] (ool-18bd861d.dyn.optonline.net [24.189.134.29]) by mta10.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 0.9 (built Jul 29 2002)) with ESMTP id <0H6500J7PR7ZSV@mta10.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Mon, 25 Nov 2002 19:40:48 -0500 (EST) Date: Mon, 25 Nov 2002 19:40:43 -0500 From: Tim Gardner Subject: Re: performance of insert/delete/update In-reply-to: X-Sender: codeh1@cmail1.panix.com To: pgsql-performance@postgresql.org Cc: "scott.marlowe" Message-id: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/218 X-Sequence-Number: 376 >With Postgresql's implementation of MVCC, all your data are inserted in >real time, with a transaction date that makes the other clients ignore >them (mostly, other read committed transactions may or may not see them.) > >If there are indexes to update, they are updated in the same "invisible >until committed" way. > >All this means that your inserts don't block anyone else's reads as well. > >This means that when you commit, all postgresql does is make them visible. scott, Exactly the kind of explanation/understanding I was hoping for! Thank you! Tim From pgsql-performance-owner@postgresql.org Mon Nov 25 19:43:04 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3313A475C45 for ; Mon, 25 Nov 2002 19:43:04 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id CD964475C2B for ; Mon, 25 Nov 2002 19:43:02 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAQ0fbCm007366; Mon, 25 Nov 2002 17:41:37 -0700 (MST) Date: Mon, 25 Nov 2002 17:41:09 -0700 (MST) From: "scott.marlowe" To: Tim Gardner Cc: Subject: Re: performance of insert/delete/update In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/219 X-Sequence-Number: 377 On Mon, 25 Nov 2002, scott.marlowe wrote: > On Mon, 25 Nov 2002, Tim Gardner wrote: > > > I'm new to postgresql, and as you suggested, this is > > counter-intuitive to me. I would have thought that having to store > > all the inserts to be able to roll them back would take longer. Is > > my thinking wrong or not relevant? Why is this not the case? > > Your thinking on this is wrong, and it is counter-intuitive to think that > a transaction would speed things up. Postgresql is very different from > other databases. Sorry that came out like that, I meant to write: I meant to add in there that I thought the same way at first, and only after a little trial and much error did I realize that I was thinking in terms of how other databases did things. I.e. most people make the same mistake when starting out with pgsql. From pgsql-performance-owner@postgresql.org Mon Nov 25 19:43:50 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B192747631F for ; Mon, 25 Nov 2002 19:43:49 -0500 (EST) Received: from www.fastmail.fm (fastmail.fm [209.61.183.86]) by postgresql.org (Postfix) with ESMTP id 4AC224762FC for ; Mon, 25 Nov 2002 19:43:49 -0500 (EST) Received: from server3.fastmail.fm (server3.internal [10.202.2.134]) by localhost.localdomain (Postfix) with ESMTP id CB3986DBE7; Mon, 25 Nov 2002 18:43:39 -0600 (CST) Received: from 127.0.0.1 ([127.0.0.1] helo=server3.fastmail.fm) by fastmail.fm with SMTP; Mon, 25 Nov 2002 18:43:39 -0600 Received: by server3.fastmail.fm (Postfix, from userid 99) id 46BB12FD1F; Mon, 25 Nov 2002 18:43:39 -0600 (CST) Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1" MIME-Version: 1.0 X-Mailer: MIME::Lite 1.2 (F2.6; T1.001; A1.51; B2.12; Q2.03) From: "Rich Scott" To: "scott.marlowe" , "Josh Berkus" Date: Mon, 25 Nov 2002 17:43:39 -0700 X-Epoch: 1038271419 X-Sasl-enc: +bG/5EnW23U8q/AL9Ur4cw Cc: "Wei Weng" , pgsql-performance@postgresql.org Subject: Re: performance of insert/delete/update Message-Id: <20021126004339.46BB12FD1F@server3.fastmail.fm> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/220 X-Sequence-Number: 378 I have seen a number of real-world situations where bundling inserts into transactions made a considerable difference - sometimes as much as a 100x speed-up, and not just in Postgresql databases, but also commercial systems (my experience is in Oracle & Sybase). I've often used an idiom of building up rows until I hit some high-water mark, and then insert those rows in one fell swoop - it's almost always measurably faster than one-at-a-time. Sidebar: a number of years ago, while contracting at a regional telephone company, I became peripherally enmired in a gigantic billing-system-makeover fiasco. Upon initial deployment, the system was so slow at processing that it was taking about 30 hours for each day of billing data. After a week or so, when it became apparent that fundamental Cash Flow was threatened, there were multi-hour conference calls, in which various VPs called for massive h/w upgrades and/or lawsuits against Oracle. An astute cohort of mine asked to see some of the code, and found out that the original developers (at the telco) had created a bloated and slow control system in C++, using semaphores or somesuch, to *serialize* inserts/updates/deletes, and so they had gigantic home-built queues of insert jobs. Not only were they not bundling updates in transactions, they were only ever doing one transaction at a time. (Apparently, they never learned RDBMS fundamentals.) He told them to rip out all that code, and let Oracle (like any other decent RDBMS) handle the update ordering. The resultant speed-up factor was several hundred times. -R On Mon, 25 Nov 2002 15:59:16 -0700 (MST), "scott.marlowe" said: > On Mon, 25 Nov 2002, Josh Berkus wrote: > > > Scott, > > > > > It's quite easy to test if you have a database with a large table to play > > > with, use pg_dump to dump a table with the -d switch (makes the dump use > > > insert statements.) Then, make two versions of the dump, one which has a > > > begin;end; pair around all the inserts and one that doesn't, then use psql > > > -e to restore both dumps. The difference is HUGE. Around 10 to 20 times > > > faster with the begin end pairs. > > > > > > I'd think that anyone who's used postgresql for more than a few months > > > could corroborate my experience. > > > > Ouch! > > > > No need to get testy about it. > > > > Your test works as you said; the way I tried testing it before was different. > > Good to know. However, this approach is only useful if you are doing > > rapidfire updates or inserts coming off a single connection. But then it is > > *very* useful. > > I didn't mean that in a testy way, it's just that after you've sat > through > a fifteen minute wait while a 1000 records are inserted, you pretty > quickly switch to the method of inserting them all in one big > transaction. That's all. > > Note that the opposite is what really gets people in trouble. I've seen > folks inserting rather large amounts of data, say into ten or 15 tables, > and their web servers were crawling under parallel load. Then, they put > them into a single transaction and they just flew. > > The funny thing it, they've often avoided transactions because they > figured they'd be slower than just inserting the rows, and you kinda have > to make them sit down first before you show them the performance increase > from putting all those inserts into a single transaction. > > No offense meant, really. It's just that you seemed to really doubt that > putting things into one transaction helped, and putting things into one > big transaction if like the very first postgresql lesson a lot of > newcomers learn. :-) > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > From pgsql-performance-owner@postgresql.org Mon Nov 25 20:41:04 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 78C6947602A for ; Mon, 25 Nov 2002 20:41:03 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id B6625475F3D for ; Mon, 25 Nov 2002 20:41:02 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20021126014105.WVZE2204.lakemtao03.cox.net@[192.168.1.1]> for ; Mon, 25 Nov 2002 20:41:05 -0500 Subject: Re: performance of insert/delete/update From: Ron Johnson To: PgSQL Performance ML In-Reply-To: References: Content-Type: text/plain Organization: Message-Id: <1038274863.26988.10.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 25 Nov 2002 19:41:03 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/222 X-Sequence-Number: 380 On Mon, 2002-11-25 at 18:23, scott.marlowe wrote: > On Mon, 25 Nov 2002, Tim Gardner wrote: > [snip] > > There are two factors that make Postgresql so weird in regards to > transactions. One it that everything happens in a transaction (we won't > mention truncate for a while, it's the only exception I know of.) Why is this so weird? Do I use the /other/ weird RDBMS? (Rdb/VMS) > The next factor that makes for fast inserts of large amounts of data in a > transaction is MVCC. With Oracle and many other databases, transactions > are written into a seperate log file, and when you commit, they are > inserted into the database as one big group. This means you write your > data twice, once into the transaction log, and once into the database. You are just deferring the pain. Whereas others must flush from log to "database files", they do not have to VACUUM or VACUUM ANALYZE. > With Postgresql's implementation of MVCC, all your data are inserted in > real time, with a transaction date that makes the other clients ignore > them (mostly, other read committed transactions may or may not see them.) Is this unusual? (Except that Rdb/VMS uses a 64-bit integer (a Transaction Sequence Number) instead of a timestamp, because Rdb, cominging from VAX/VMS is natively cluster-aware, and it's not guaranteed that all nodes have the exact same timestamp. [snip] > In the event you roll back a transaction, the tuples are all just marked > as dead and they get ignored. What if you are in a 24x365 environment? Doing a VACUUM ANALYZE would really slow down the nightly operations. > It's interesting when you work with folks who came from other databases. > My coworker, who's been using Postgresql for about 2 years now, had an > interesting experience when he first started here. He was inserting > something like 10,000 rows. He comes over and tells me there must be > something wrong with the database, as his inserts have been running for 10 > minutes, and he's not even halfway through. So I had him stop the > inserts, clean out the rows (it was a new table for a new project) and > wrap all 10,000 inserts into a transaction. What had been running for 10 > minutes now ran in about 30 seconds. Again, why is this so unusual????? -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "they love our milk and honey, but preach about another | | way of living" | | Merle Haggard, "The Fighting Side Of Me" | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Nov 25 20:39:17 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0546B475C2B for ; Mon, 25 Nov 2002 20:39:16 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 7C518474E44 for ; Mon, 25 Nov 2002 20:39:14 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.1) with ESMTP id 1962006; Mon, 25 Nov 2002 17:39:49 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "scott.marlowe" Subject: Re: performance of insert/delete/update Date: Mon, 25 Nov 2002 17:41:42 -0800 X-Mailer: KMail [version 1.4] Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211251741.42394.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/221 X-Sequence-Number: 379 Scott, > No offense meant, really. It's just that you seemed to really doubt that= =20 > putting things into one transaction helped, and putting things into one= =20 > big transaction if like the very first postgresql lesson a lot of=20 > newcomers learn. :-) Not so odd, if you think about it. After all, this approach is only useful= =20 for a series of small update/insert statements on a single connection.=20= =20=20 Thinking about it, I frankly never do this except as part of a stored=20 procedure ... which, in Postgres, is automatically a transaction. I'm lucky enough that my data loads have all been adaptable to COPY=20 statements, which bypasses this issue completely. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 25 20:52:34 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EA257475C2B for ; Mon, 25 Nov 2002 20:52:32 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 312C8474E44 for ; Mon, 25 Nov 2002 20:52:32 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20021126015235.WYZB2204.lakemtao03.cox.net@[192.168.1.1]> for ; Mon, 25 Nov 2002 20:52:35 -0500 Subject: Re: performance of insert/delete/update From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <20021126004339.46BB12FD1F@server3.fastmail.fm> References: <20021126004339.46BB12FD1F@server3.fastmail.fm> Content-Type: text/plain Organization: Message-Id: <1038275553.26988.21.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 25 Nov 2002 19:52:33 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/223 X-Sequence-Number: 381 On Mon, 2002-11-25 at 18:43, Rich Scott wrote: [snip] > upgrades and/or lawsuits against Oracle. An astute cohort of mine asked > to > see some of the code, and found out that the original developers (at the > telco) > had created a bloated and slow control system in C++, using semaphores or > somesuch, > to *serialize* inserts/updates/deletes, and so they had gigantic > home-built > queues of insert jobs. Not only were they not bundling updates in > transactions, > they were only ever doing one transaction at a time. (Apparently, they > never > learned RDBMS fundamentals.) He told them to rip out all that code, and > let > Oracle (like any other decent RDBMS) handle the update ordering. The > resultant > speed-up factor was several hundred times. Just goes to show the difference between RDBMSs. Even with the biggest Alphas possible at the time, our Customer Service Center app was crawling because of lock conflicts (each transaction affected ~10-12 tables). Rdb/VMS works best with a TP monitor (specifically ACMS). We were'nt using one, and weren't handling lock conflicts in the best way. Thus, the slowdowns. The developers finally wrote a home-grown dedicated TP-like server, using DEC Message Queue and /serialized/ data flow. Without all of the lock conflicts, performance warped forward. The reason for this, I think, is that Oracle serializes things itself, whereas Rdb/VMS expects ACMS to do the serialization. (Since both Rdb & ACMS were both written by DEC, that's understandable I think.) -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "they love our milk and honey, but preach about another | | way of living" | | Merle Haggard, "The Fighting Side Of Me" | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Nov 25 22:30:27 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CE6F7475F82 for ; Mon, 25 Nov 2002 22:30:21 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id F2AE0475F00 for ; Mon, 25 Nov 2002 22:30:20 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gAQ3UOsX005164; Mon, 25 Nov 2002 22:30:24 -0500 (EST) To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: performance of insert/delete/update In-reply-to: <1038274863.26988.10.camel@haggis> References: <1038274863.26988.10.camel@haggis> Comments: In-reply-to Ron Johnson message dated "25 Nov 2002 19:41:03 -0600" Date: Mon, 25 Nov 2002 22:30:23 -0500 Message-ID: <5163.1038281423@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/224 X-Sequence-Number: 382 Ron Johnson writes: > On Mon, 2002-11-25 at 18:23, scott.marlowe wrote: >> The next factor that makes for fast inserts of large amounts of data in a >> transaction is MVCC. With Oracle and many other databases, transactions >> are written into a seperate log file, and when you commit, they are >> inserted into the database as one big group. This means you write your >> data twice, once into the transaction log, and once into the database. > You are just deferring the pain. Whereas others must flush from log > to "database files", they do not have to VACUUM or VACUUM ANALYZE. Sure, it's just shuffling the housekeeping work from one place to another. The thing that I like about Postgres' approach is that we put the housekeeping in a background task (VACUUM) rather than in the critical path of foreground transaction commit. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 25 22:45:45 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EB69D475956 for ; Mon, 25 Nov 2002 22:45:41 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 1DE6E475D17 for ; Mon, 25 Nov 2002 22:44:31 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gAQ3iTsX005254; Mon, 25 Nov 2002 22:44:30 -0500 (EST) To: Tim Gardner Cc: pgsql-performance@postgresql.org, "scott.marlowe" Subject: Re: performance of insert/delete/update In-reply-to: References: Comments: In-reply-to Tim Gardner message dated "Mon, 25 Nov 2002 19:40:43 -0500" Date: Mon, 25 Nov 2002 22:44:29 -0500 Message-ID: <5253.1038282269@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/225 X-Sequence-Number: 383 Tim Gardner writes: >> All this means that your inserts don't block anyone else's reads as well. >> This means that when you commit, all postgresql does is make them visible. > Exactly the kind of explanation/understanding I was hoping for! There's another point worth making. What Scott was pointing out is that whether you commit or roll back a transaction costs about the same, in Postgres, as far as tuple update processing is concerned. At the end of a transaction, we have both new (inserted/updated) and old (deleted/replaced) tuples laying about in the database. Commit marks the transaction committed in pg_clog; abort marks it aborted instead; neither one lifts a finger to touch the tuples. (Subsequent visitors to the tuples will mark them "good" or "dead" based on consulting pg_clog, but we don't try to do that during transaction commit.) But having said all that, transaction commit is more expensive than transaction abort, because we have to flush the transaction commit WAL record to disk before we can report "transaction successfully committed". That means waiting for the disk to spin. Transaction abort doesn't have to wait --- that's because if there's a crash and the abort record never makes it to disk, the default assumption on restart will be that the transaction aborted, anyway. So the basic reason that it's worth batching multiple updates into one transaction is that you only wait for the commit record flush once, not once per update. This makes no difference worth mentioning if your updates are big, but on modern hardware you can update quite a few individual rows in the time it takes the disk to spin once. (BTW, if you set fsync = off, then the performance difference goes away, because we don't wait for the commit record to flush to disk ... but then you become vulnerable to problems after a system crash.) regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 25 22:52:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 123F2475956 for ; Mon, 25 Nov 2002 22:52:01 -0500 (EST) Received: from jester.senspire.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.51.175]) by postgresql.org (Postfix) with ESMTP id 036AF4758F1 for ; Mon, 25 Nov 2002 22:51:59 -0500 (EST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by jester.senspire.com (8.12.6/8.12.6) with ESMTP id gAQ3qpwv089791; Mon, 25 Nov 2002 22:52:52 -0500 (EST) (envelope-from rbt@rbt.ca) Subject: Re: performance of insert/delete/update From: Rod Taylor To: "scott.marlowe" Cc: Tim Gardner , Pgsql Performance In-Reply-To: References: Content-Type: text/plain Organization: Message-Id: <1038282771.89124.11.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 25 Nov 2002 22:52:51 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/226 X-Sequence-Number: 384 On Mon, 2002-11-25 at 19:30, scott.marlowe wrote: > On 25 Nov 2002, Rod Taylor wrote: > > > > I'm new to postgresql, and as you suggested, this is > > > counter-intuitive to me. I would have thought that having to store > > > all the inserts to be able to roll them back would take longer. Is > > > my thinking wrong or not relevant? Why is this not the case? > > > > Typically that is the case. But Postgresql switches it around a little > > bit. Different trade-offs. No rollback log, but other processes are > > forced to go through you're left over garbage (hence 'vacuum'). > > Yeah, which means you always need to do a vacuum on a table after a lot of > updates/deletes. And analyze after a lot of inserts/updates/deletes. A good auto-vacuum daemon will help that out :) Not really any different than an OO dbs garbage collection process -- except PGs vacuum is several orders of magnitude faster. -- Rod Taylor From pgsql-performance-owner@postgresql.org Mon Nov 25 23:27:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1CCD3475956 for ; Mon, 25 Nov 2002 23:27:40 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 2E6AC4758F1 for ; Mon, 25 Nov 2002 23:27:39 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20021126042743.YLDF2204.lakemtao03.cox.net@[192.168.1.1]>; Mon, 25 Nov 2002 23:27:43 -0500 Subject: Re: performance of insert/delete/update From: Ron Johnson To: Tom Lane Cc: PgSQL Performance ML In-Reply-To: <5163.1038281423@sss.pgh.pa.us> References: <1038274863.26988.10.camel@haggis> <5163.1038281423@sss.pgh.pa.us> Content-Type: text/plain Organization: Message-Id: <1038284861.26985.59.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 25 Nov 2002 22:27:41 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/227 X-Sequence-Number: 385 On Mon, 2002-11-25 at 21:30, Tom Lane wrote: > Ron Johnson writes: > > On Mon, 2002-11-25 at 18:23, scott.marlowe wrote: > >> The next factor that makes for fast inserts of large amounts of data in a > >> transaction is MVCC. With Oracle and many other databases, transactions > >> are written into a seperate log file, and when you commit, they are > >> inserted into the database as one big group. This means you write your > >> data twice, once into the transaction log, and once into the database. > > > You are just deferring the pain. Whereas others must flush from log > > to "database files", they do not have to VACUUM or VACUUM ANALYZE. > > Sure, it's just shuffling the housekeeping work from one place to > another. The thing that I like about Postgres' approach is that we > put the housekeeping in a background task (VACUUM) rather than in the > critical path of foreground transaction commit. If you have a quiescent point somewhere in the middle of the night... It's all about differing philosophies, though, and there's no way that Oracle will re-write Rdb/VMS (they bought it from DEC in 1997 for it's high-volume OLTP technolgies) and you all won't re-write Postgres... -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "they love our milk and honey, but preach about another | | way of living" | | Merle Haggard, "The Fighting Side Of Me" | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Tue Nov 26 04:37:07 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6D630475AD4 for ; Tue, 26 Nov 2002 04:36:53 -0500 (EST) Received: from o2.hostbaby.com (o2.hostbaby.com [208.187.29.121]) by postgresql.org (Postfix) with SMTP id A1CFE475AAC for ; Tue, 26 Nov 2002 04:36:50 -0500 (EST) Received: (qmail 14013 invoked from network); 26 Nov 2002 09:36:59 -0000 Received: from unknown (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 26 Nov 2002 09:36:59 -0000 Received: from 12.249.229.112 (Hostbaby Webmail authenticated user typea@l-i-e.com) by www.l-i-e.com with HTTP; Tue, 26 Nov 2002 01:36:59 -0800 (PST) Message-ID: <61258.12.249.229.112.1038303419.squirrel@www.l-i-e.com> Date: Tue, 26 Nov 2002 01:36:59 -0800 (PST) Subject: Full Text Index disk space requirements From: To: X-Priority: 3 Importance: Normal X-Mailer: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/228 X-Sequence-Number: 386 So, I'm trying to create a full text index as described here: http://techdocs.postgresql.org/techdocs/fulltextindexing.php Everything was going mostly okay... I had to hack a quick PHP script instead of using the Perl once since I didn't have a working Pg.pm, but that was a minor speed bump. Then I hit a real road-block... \copy article_fti from fulltext.sorted \. ERROR: copy: line 34635390, cannot extend article_fti: No space left on device. Check free disk space. PQendcopy: resetting connection archive=> \q [root@rm-004-24 utilities]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 15G 15G 0 100% / /dev/sda1 48M 6.1M 39M 14% /boot none 439M 0 439M 0% /dev/shm Oh. Yeah. I guess that *IS* going to be kind of big... Any SWAGs how much disk space is required for a 500 M fulltext.sorted file? IE, the ASCII file of string/OID pairs, in tab-delimited form, is 500 M -- How much PostgreSQL space does that turn into with the tables/indices as described the URL above? When I deleted all the fti rows, and did a VACUUM, there was almost 2G available... ALSO: Wouldn't using f1.string = 'perth' be faster than f1.string ~ '^perth' and equally useful? Or is ~ with ^ somehow actually faster than the seemingly simple = comparison? AND: Would using OR for the individual word comparisons be a big drag on speed? I'd kind of like to give ranked results based on how many of the terms were present rather than a complete filter. I'd be happy to try the EXPLAIN queries, but I don't think they're going to be accurate without the data in the FTI table... I got some weird results when I did a test run with a very small dataset in the FTI table -- But I also think I was doing it in the middle of a train-wreck between daily VACUUM and pg_dump, which were thrashing each other with all the FTI data I had imported just for the small test... I've altered the cron jobs to have more time in between. THANKS IN ADVANCE! From pgsql-performance-owner@postgresql.org Tue Nov 26 07:49:26 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E9A7F475AE5 for ; Tue, 26 Nov 2002 07:49:25 -0500 (EST) Received: from eufig1.rit.reuters.com (unknown [194.205.123.3]) by postgresql.org (Postfix) with SMTP id 0EF76475AD4 for ; Tue, 26 Nov 2002 07:49:25 -0500 (EST) Received: from no.name.available by eufig1.rit.reuters.com via smtpd (for postgresql.org [64.49.215.8]) with SMTP; 26 Nov 2002 12:49:28 UT Received: from eupig1 (unverified) by reuters.com (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Tue, 26 Nov 2002 12:52:15 +0000 Message-ID: Received: from eungw2.ime.reuters.com ([10.1.4.30]) by eupig1.dtc.lon.ime.reuters.com (PMDF V6.1-1 #40186) with ESMTP id <0H66002SWOXJN3@eupig1.dtc.lon.ime.reuters.com>; Tue, 26 Nov 2002 12:48:55 +0000 (GMT) Date: Tue, 26 Nov 2002 16:48:42 +0400 From: Maarten Boekhold Subject: Re: Full Text Index disk space requirements To: typea@l-i-e.com Cc: pgsql-performance@postgresql.org MIME-version: 1.0 X-Mailer: Lotus Notes Release 5.0.2b (Intl) 16 December 1999 Content-type: text/plain; charset="us-ascii" X-MIMETrack: Serialize by Router on EUNGW2/LON/GB/Reuters(Release 5.0.6a |January 17, 2001) at 26/11/2002 12:39:18, Serialize complete at 26/11/2002 12:39:18 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/229 X-Sequence-Number: 387 Hi, if memory serves me right, the space requirements for this would be something like: 42 (per tuple overhead) 4 (size of OID?) 16 (substitute with the maximum length of any 'string' in your fulltext.sorted) + ------------- 62 20,000,000 (substitute with number of lines in fulltext.sorted, i.e. 'wc -l fulltext.sorted') *--------------------------- 1,240,000,000 or about 1.2G? or On 11/26/2002 01:36:59 PM typea wrote: > Wouldn't using f1.string = 'perth' be faster than f1.string ~ '^perth' and > equally useful? Or is ~ with ^ somehow actually faster than the seemingly > simple = comparison? f1.string = 'perth' would only match 'perth', while f1.string ~ '^perth' would also match 'perthinent' (yes, I know this word does not exist). Maarten ps. are you trying to use the stuf from the 'fulltextindex' directory in contrib/? I originally wrote this as an experiment, and it actually turned out not to be fast enough for my purpose. I've never done anything with full text indexing again, but I believe that currently there are better solutions based on PostgreSQL (i.e. OpenFTI?) -------------------------------------------------------------- -- Visit our Internet site at http://www.reuters.com Get closer to the financial markets with Reuters Messaging - for more information and to register, visit http://www.reuters.com/messaging Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Reuters Ltd. From pgsql-performance-owner@postgresql.org Tue Nov 26 10:32:55 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 59E6247694C; Tue, 26 Nov 2002 10:32:51 -0500 (EST) Received: from acorn.he.net (acorn.he.net [64.71.137.130]) by postgresql.org (Postfix) with ESMTP id EB79F4763C4; Tue, 26 Nov 2002 10:32:27 -0500 (EST) Received: from CurtisVaio ([63.164.0.44] (may be forged)) by acorn.he.net (8.8.6/8.8.2) with SMTP id HAA12555; Tue, 26 Nov 2002 07:32:27 -0800 From: "Curtis Faith" To: "Tom Lane" , "Ron Johnson" Cc: "PgSQL Performance ML" , Subject: [HACKERS] Realtime VACUUM, was: performance of insert/delete/update Date: Tue, 26 Nov 2002 11:32:28 -0400 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) In-Reply-To: <5163.1038281423@sss.pgh.pa.us> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/230 X-Sequence-Number: 388 tom lane wrote: > Sure, it's just shuffling the housekeeping work from one place to > another. The thing that I like about Postgres' approach is that we > put the housekeeping in a background task (VACUUM) rather than in the > critical path of foreground transaction commit. Thinking with my marketing hat on, MVCC would be a much bigger win if VACUUM was not required (or was done automagically). The need for periodic VACUUM just gives ammunition to the PostgreSQL opponents who can claim we are deferring work but that it amounts to the same thing. A fully automatic background VACUUM will significantly reduce but will not eliminate this perceived weakness. However, it always seemed to me there should be some way to reuse the space more dynamically and quickly than a background VACUUM thereby reducing the percentage of tuples that are expired in heavy update cases. If only a very tiny number of tuples on the disk are expired this will reduce the aggregate performance/space penalty of MVCC into insignificance for the majority of uses. Couldn't we reuse tuple and index space as soon as there are no transactions that depend on the old tuple or index values. I have imagined that this was always part of the long-term master plan. Couldn't we keep a list of dead tuples in shared memory and look in the list first when deciding where to place new values for inserts or updates so we don't have to rely on VACUUM (even a background one)? If there are expired tuple slots in the list these would be used before allocating a new slot from the tuple heap. The only issue is determining the lowest transaction ID for in-process transactions which seems relatively easy to do (if it's not already done somewhere). In the normal shutdown and startup case, a tuple VACUUM could be performed automatically. This would normally be very fast since there would not be many tuples in the list. Index slots would be handled differently since these cannot be substituted one for another. However, these could be recovered as part of every index page update. Pages would be scanned before being written and any expired slots that had transaction ID's lower than the lowest active slot would be removed. This could be done for non-leaf pages as well and would result in only reorganizing a page that is already going to be written thereby not adding much to the overall work. I don't think that internal pages that contain pointers to values in nodes further down the tree that are no longer in the leaf nodes because of this partial expired entry elimination will cause a problem since searches and scans will still work fine. Does VACUUM do something that could not be handled in this realtime manner? - Curtis From pgsql-performance-owner@postgresql.org Tue Nov 26 11:51:12 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 083A64763EF for ; Tue, 26 Nov 2002 11:50:46 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 03D7E476459 for ; Tue, 26 Nov 2002 11:49:13 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18Giti-0007EI-00 for ; Tue, 26 Nov 2002 11:49:18 -0500 Date: Tue, 26 Nov 2002 11:49:18 -0500 From: Andrew Sullivan To: Pgsql Performance Subject: Re: performance of insert/delete/update Message-ID: <20021126114918.G12832@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , Pgsql Performance References: <1038270003.89124.8.camel@jester> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from scott.marlowe@ihs.com on Mon, Nov 25, 2002 at 05:30:00PM -0700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/231 X-Sequence-Number: 389 On Mon, Nov 25, 2002 at 05:30:00PM -0700, scott.marlowe wrote: > > Ain't it amazing how much hardware a typical Oracle license can buy? ;^) Not to mention the hardware budget for a typical Oracle installation. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Nov 26 11:54:21 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4CD034760F8 for ; Tue, 26 Nov 2002 11:54:20 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 867AA475B8D for ; Tue, 26 Nov 2002 11:54:12 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18GiyX-0007Lm-00 for ; Tue, 26 Nov 2002 11:54:17 -0500 Date: Tue, 26 Nov 2002 11:54:17 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: performance of insert/delete/update Message-ID: <20021126115417.H12832@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <1038274863.26988.10.camel@haggis> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1038274863.26988.10.camel@haggis>; from ron.l.johnson@cox.net on Mon, Nov 25, 2002 at 07:41:03PM -0600 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/232 X-Sequence-Number: 390 On Mon, Nov 25, 2002 at 07:41:03PM -0600, Ron Johnson wrote: > > What if you are in a 24x365 environment? Doing a VACUUM ANALYZE would > really slow down the nightly operations. Why? After upgrading to 7.2, we find it a good idea to do frequent vacuum analyse on frequently-changed tables. It doesn't block, and if you vacuum frequently enough, it goes real fast. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Nov 26 13:09:00 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1D8FD4764FC for ; Tue, 26 Nov 2002 13:08:59 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 58C5D4764E4 for ; Tue, 26 Nov 2002 13:08:56 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAQI7KCm002105; Tue, 26 Nov 2002 11:07:20 -0700 (MST) Date: Tue, 26 Nov 2002 11:06:47 -0700 (MST) From: "scott.marlowe" To: Andrew Sullivan Cc: PgSQL Performance ML Subject: Re: performance of insert/delete/update In-Reply-To: <20021126115417.H12832@mail.libertyrms.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/233 X-Sequence-Number: 391 On Tue, 26 Nov 2002, Andrew Sullivan wrote: > On Mon, Nov 25, 2002 at 07:41:03PM -0600, Ron Johnson wrote: > > > > What if you are in a 24x365 environment? Doing a VACUUM ANALYZE would > > really slow down the nightly operations. > > Why? After upgrading to 7.2, we find it a good idea to do frequent > vacuum analyse on frequently-changed tables. It doesn't block, and > if you vacuum frequently enough, it goes real fast. For example, I just ran pgbench -c 20 -t 200 (20 concurrent's) with a script in the background that looked like this: #!/bin/bash for ((a=0;a=1;a=0)) do { vacuumdb -z postgres } done (i.e. run vacuumdb in analyze against the database continuously.) Output of top: 71 processes: 63 sleeping, 8 running, 0 zombie, 0 stopped CPU0 states: 66.2% user, 25.1% system, 0.0% nice, 8.1% idle CPU1 states: 79.4% user, 18.3% system, 0.0% nice, 1.2% idle Mem: 254660K av, 249304K used, 5356K free, 26736K shrd, 21720K buff Swap: 3084272K av, 1300K used, 3082972K free 142396K cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 21381 postgres 11 0 1304 1304 868 S 10.8 0.5 0:00 pgbench 21393 postgres 14 0 4832 4832 4116 R 8.4 1.8 0:00 postmaster 21390 postgres 9 0 4880 4880 4164 S 7.8 1.9 0:00 postmaster 21385 postgres 14 0 4884 4884 4168 R 6.7 1.9 0:00 postmaster 21399 postgres 9 0 4768 4768 4076 S 6.3 1.8 0:00 postmaster 21402 postgres 9 0 4776 4776 4076 S 6.1 1.8 0:00 postmaster 21383 postgres 14 0 4828 4828 4112 R 5.9 1.8 0:00 postmaster 21386 postgres 14 0 4872 4872 4156 R 5.9 1.9 0:00 postmaster 21392 postgres 9 0 4820 4820 4104 S 5.9 1.8 0:00 postmaster 21409 postgres 11 0 4600 4600 3544 R 5.8 1.8 0:00 postmaster 21387 postgres 9 0 4824 4824 4108 S 5.4 1.8 0:00 postmaster 21394 postgres 9 0 4808 4808 4092 S 5.4 1.8 0:00 postmaster 21391 postgres 9 0 4816 4816 4100 S 5.0 1.8 0:00 postmaster 21398 postgres 9 0 4796 4796 4088 S 5.0 1.8 0:00 postmaster 21384 postgres 9 0 4756 4756 4040 R 4.8 1.8 0:00 postmaster 21389 postgres 9 0 4788 4788 4072 S 4.8 1.8 0:00 postmaster 21397 postgres 9 0 4772 4772 4056 S 4.6 1.8 0:00 postmaster 21388 postgres 9 0 4780 4780 4064 S 4.4 1.8 0:00 postmaster 21396 postgres 9 0 4756 4756 4040 S 4.3 1.8 0:00 postmaster 21395 postgres 14 0 4760 4760 4044 S 4.1 1.8 0:00 postmaster 21401 postgres 14 0 4736 4736 4036 R 4.1 1.8 0:00 postmaster 21400 postgres 9 0 4732 4732 4028 S 2.9 1.8 0:00 postmaster 21403 postgres 9 0 1000 1000 820 S 2.4 0.3 0:00 vacuumdb 21036 postgres 9 0 1056 1056 828 R 2.0 0.4 0:27 top 18615 postgres 9 0 1912 1912 1820 S 1.1 0.7 0:01 postmaster 21408 postgres 9 0 988 988 804 S 0.7 0.3 0:00 psql So, pgbench is the big eater of CPU at 10%, each postmaster using about 5%, and vacuumdb using 2.4%. Note that after a second, the vacuumdb use drops off to 0% until it finishes and runs again. The output of the pgbench without vacuumdb running, but with top, to be fair was: number of clients: 20 number of transactions per client: 200 number of transactions actually processed: 4000/4000 tps = 54.428632 (including connections establishing) tps = 54.847276 (excluding connections establishing) While the output with the vacuumdb running continuously was: number of clients: 20 number of transactions per client: 200 number of transactions actually processed: 4000/4000 tps = 52.114343 (including connections establishing) tps = 52.873435 (excluding connections establishing) So, the difference in performance was around 4% slower. I'd hardly consider that a big hit against the database. Note that in every test I've made up and run, the difference is at most 5% with vacuumdb -z running continuously in the background. Big text fields, lots of math, lots of fks, etc... Yes, vacuum WAS a problem long ago, but since 7.2 came out it's only a "problem" in terms of remember to run it. From pgsql-performance-owner@postgresql.org Tue Nov 26 13:24:43 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 536AB475AEC for ; Tue, 26 Nov 2002 13:24:40 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 4BF22475AAC for ; Tue, 26 Nov 2002 13:24:39 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18GkNz-0000yG-00 for ; Tue, 26 Nov 2002 13:24:39 -0500 Date: Tue, 26 Nov 2002 13:24:39 -0500 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: performance of insert/delete/update Message-ID: <20021126132439.K12832@mail.libertyrms.com> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <20021126115417.H12832@mail.libertyrms.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from scott.marlowe@ihs.com on Tue, Nov 26, 2002 at 11:06:47AM -0700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/234 X-Sequence-Number: 392 On Tue, Nov 26, 2002 at 11:06:47AM -0700, scott.marlowe wrote: > So, the difference in performance was around 4% slower. > > I'd hardly consider that a big hit against the database. > > Note that in every test I've made up and run, the difference is at most 5% > with vacuumdb -z running continuously in the background. Big text fields, > lots of math, lots of fks, etc... Also, it's important to remember that you may see a considerable improvement in efficiency of some queries if you vacuum often, (it's partly dependent on the turnover in your database -- if it never changes, you don't need to vacuum often). So a 5% hit in regular performance may be worth it over the long haul, if certain queries are way cheaper to run. (That is, while you may get 4% slower performance overall, if the really slow queries are much faster, the fast queries running slower may well be worth it. In my case, certainly, I think it is.) A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Nov 26 13:47:50 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 320C747642D for ; Tue, 26 Nov 2002 13:47:49 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 6F92547612B for ; Tue, 26 Nov 2002 13:47:31 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gAQIl0Cm002038; Tue, 26 Nov 2002 11:47:01 -0700 (MST) Date: Tue, 26 Nov 2002 11:46:27 -0700 (MST) From: "scott.marlowe" To: Andrew Sullivan Cc: PgSQL Performance ML Subject: Re: performance of insert/delete/update In-Reply-To: <20021126132439.K12832@mail.libertyrms.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/235 X-Sequence-Number: 393 On Tue, 26 Nov 2002, Andrew Sullivan wrote: > On Tue, Nov 26, 2002 at 11:06:47AM -0700, scott.marlowe wrote: > > So, the difference in performance was around 4% slower. > > > > I'd hardly consider that a big hit against the database. > > > > Note that in every test I've made up and run, the difference is at most 5% > > with vacuumdb -z running continuously in the background. Big text fields, > > lots of math, lots of fks, etc... > > Also, it's important to remember that you may see a considerable > improvement in efficiency of some queries if you vacuum often, (it's > partly dependent on the turnover in your database -- if it never > changes, you don't need to vacuum often). So a 5% hit in regular > performance may be worth it over the long haul, if certain queries > are way cheaper to run. (That is, while you may get 4% slower > performance overall, if the really slow queries are much faster, the > fast queries running slower may well be worth it. In my case, > certainly, I think it is.) Agreed. We used to run vacuumdb at night only when we were running 7.1, and we had a script top detect if it had hung or anything. I.e. vacuuming was still a semi-dangerous activity. I now have it set to run every hour (-z -a switches to vacuumdb). I'd run it more often but we just don't have enough load to warrant it. From pgsql-performance-owner@postgresql.org Tue Nov 26 14:16:48 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 98A21476626; Tue, 26 Nov 2002 14:16:44 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id BCE13476B23; Tue, 26 Nov 2002 14:09:57 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id gAQJ9ce02496; Tue, 26 Nov 2002 14:09:38 -0500 (EST) From: Bruce Momjian Message-Id: <200211261909.gAQJ9ce02496@candle.pha.pa.us> Subject: Re: [HACKERS] Realtime VACUUM, was: performance of insert/delete/update In-Reply-To: To: Curtis Faith Date: Tue, 26 Nov 2002 14:09:38 -0500 (EST) Cc: Tom Lane , Ron Johnson , PgSQL Performance ML , pgsql-hackers@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/236 X-Sequence-Number: 394 Good ideas. I think the master solution is to hook the statistics daemon information into an automatic vacuum that could _know_ which tables need attention. --------------------------------------------------------------------------- Curtis Faith wrote: > tom lane wrote: > > Sure, it's just shuffling the housekeeping work from one place to > > another. The thing that I like about Postgres' approach is that we > > put the housekeeping in a background task (VACUUM) rather than in the > > critical path of foreground transaction commit. > > Thinking with my marketing hat on, MVCC would be a much bigger win if VACUUM > was not required (or was done automagically). The need for periodic VACUUM > just gives ammunition to the PostgreSQL opponents who can claim we are > deferring work but that it amounts to the same thing. > > A fully automatic background VACUUM will significantly reduce but will not > eliminate this perceived weakness. > > However, it always seemed to me there should be some way to reuse the space > more dynamically and quickly than a background VACUUM thereby reducing the > percentage of tuples that are expired in heavy update cases. If only a very > tiny number of tuples on the disk are expired this will reduce the aggregate > performance/space penalty of MVCC into insignificance for the majority of > uses. > > Couldn't we reuse tuple and index space as soon as there are no transactions > that depend on the old tuple or index values. I have imagined that this was > always part of the long-term master plan. > > Couldn't we keep a list of dead tuples in shared memory and look in the list > first when deciding where to place new values for inserts or updates so we > don't have to rely on VACUUM (even a background one)? If there are expired > tuple slots in the list these would be used before allocating a new slot from > the tuple heap. > > The only issue is determining the lowest transaction ID for in-process > transactions which seems relatively easy to do (if it's not already done > somewhere). > > In the normal shutdown and startup case, a tuple VACUUM could be performed > automatically. This would normally be very fast since there would not be many > tuples in the list. > > Index slots would be handled differently since these cannot be substituted > one for another. However, these could be recovered as part of every index > page update. Pages would be scanned before being written and any expired > slots that had transaction ID's lower than the lowest active slot would be > removed. This could be done for non-leaf pages as well and would result in > only reorganizing a page that is already going to be written thereby not > adding much to the overall work. > > I don't think that internal pages that contain pointers to values in nodes > further down the tree that are no longer in the leaf nodes because of this > partial expired entry elimination will cause a problem since searches and > scans will still work fine. > > Does VACUUM do something that could not be handled in this realtime manner? > > - Curtis > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Tue Nov 26 14:40:40 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2E2424769BA for ; Tue, 26 Nov 2002 14:40:39 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id A68FB476B13 for ; Tue, 26 Nov 2002 14:25:47 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id gAQJWi6P021246; Tue, 26 Nov 2002 14:32:45 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id gAQJPkj03804; Tue, 26 Nov 2002 14:25:46 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id W7RLXV56; Tue, 26 Nov 2002 14:25:45 -0500 Subject: Re: performance of insert/delete/update From: Robert Treat To: Ron Johnson Cc: Tom Lane , PgSQL Performance ML In-Reply-To: <1038284861.26985.59.camel@haggis> References: <1038274863.26988.10.camel@haggis> <5163.1038281423@sss.pgh.pa.us> <1038284861.26985.59.camel@haggis> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 26 Nov 2002 14:25:46 -0500 Message-Id: <1038338746.17245.51.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/237 X-Sequence-Number: 395 On Mon, 2002-11-25 at 23:27, Ron Johnson wrote: > On Mon, 2002-11-25 at 21:30, Tom Lane wrote: > > Ron Johnson writes: > > > On Mon, 2002-11-25 at 18:23, scott.marlowe wrote: > > >> The next factor that makes for fast inserts of large amounts of data in a > > >> transaction is MVCC. With Oracle and many other databases, transactions > > >> are written into a seperate log file, and when you commit, they are > > >> inserted into the database as one big group. This means you write your > > >> data twice, once into the transaction log, and once into the database. > > > > > You are just deferring the pain. Whereas others must flush from log > > > to "database files", they do not have to VACUUM or VACUUM ANALYZE. > > > > Sure, it's just shuffling the housekeeping work from one place to > > another. The thing that I like about Postgres' approach is that we > > put the housekeeping in a background task (VACUUM) rather than in the > > critical path of foreground transaction commit. > > If you have a quiescent point somewhere in the middle of the night... > You seem to be implying that running vacuum analyze causes some large performance issues, but it's just not the case. I run a 24x7 operation, and I have a few tables that "turn over" within 15 minutes. On these tables I run vacuum analyze every 5 - 10 minutes and really there is little/no performance penalty. Robert Treat From pgsql-performance-owner@postgresql.org Tue Nov 26 15:18:10 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4534E476657 for ; Tue, 26 Nov 2002 15:18:02 -0500 (EST) Received: from o2.hostbaby.com (o2.hostbaby.com [208.187.29.121]) by postgresql.org (Postfix) with SMTP id B5D15476916 for ; Tue, 26 Nov 2002 15:13:49 -0500 (EST) Received: (qmail 83901 invoked from network); 26 Nov 2002 20:13:53 -0000 Received: from unknown (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 26 Nov 2002 20:13:53 -0000 Received: from 12.249.229.112 (Hostbaby Webmail authenticated user typea@l-i-e.com) by www.l-i-e.com with HTTP; Tue, 26 Nov 2002 12:13:53 -0800 (PST) Message-ID: <61777.12.249.229.112.1038341633.squirrel@www.l-i-e.com> Date: Tue, 26 Nov 2002 12:13:53 -0800 (PST) Subject: Re: Full Text Index disk space requirements From: To: In-Reply-To: References: X-Priority: 3 Importance: Normal X-Mailer: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/238 X-Sequence-Number: 396 > ps. are you trying to use the stuf from the 'fulltextindex' directory in > contrib/? Yes. > I originally wrote this as an experiment, and it actually > turned out not to be fast enough for my purpose. I've never done > anything with full text indexing again, but I believe that currently > there are better solutions based on PostgreSQL (i.e. OpenFTI?) Oh. ... In case anybody finds these archived, it's OpenFTS: http://sourceforge.net/projects/openfts/ Perhaps my question should be "What's the best full-text-index solution?" Too open-ended? PostgreSQL 7.1.3 (upgrading is not out of the question, but...) ~20,000 text articles scanned with OCR from _The Bulletin of the Atomic Scientists_ (the Doomsday Clock folks) Average text length: 9635 characters Max text length: 278227 Only 2000 of the texts are null or '', and those are probably "buglets" Any other pertinent facts needed? From pgsql-performance-owner@postgresql.org Tue Nov 26 16:33:39 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9C41F475C9E for ; Tue, 26 Nov 2002 16:33:17 -0500 (EST) Received: from rh72.home.ee (adsl1030.estpak.ee [213.168.29.11]) by postgresql.org (Postfix) with ESMTP id 4CD7F475B07 for ; Tue, 26 Nov 2002 16:33:16 -0500 (EST) Received: from rh72.home.ee (localhost.localdomain [127.0.0.1]) by rh72.home.ee (8.12.5/8.12.5) with ESMTP id gAQLXFxK003308; Wed, 27 Nov 2002 02:33:15 +0500 Received: (from hannu@localhost) by rh72.home.ee (8.12.5/8.12.5/Submit) id gAQLXEai003306; Wed, 27 Nov 2002 02:33:14 +0500 X-Authentication-Warning: rh72.home.ee: hannu set sender to hannu@tm.ee using -f Subject: Re: Full Text Index disk space requirements From: Hannu Krosing To: typea@l-i-e.com Cc: pgsql-performance@postgresql.org In-Reply-To: <61777.12.249.229.112.1038341633.squirrel@www.l-i-e.com> References: <61777.12.249.229.112.1038341633.squirrel@www.l-i-e.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1038346393.1958.34.camel@rh72.home.ee> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 27 Nov 2002 02:33:14 +0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/239 X-Sequence-Number: 397 typea@l-i-e.com kirjutas K, 27.11.2002 kell 01:13: > > ps. are you trying to use the stuf from the 'fulltextindex' directory in > > contrib/? > > Yes. > > > I originally wrote this as an experiment, and it actually > > turned out not to be fast enough for my purpose. I've never done > > anything with full text indexing again, but I believe that currently > > there are better solutions based on PostgreSQL (i.e. OpenFTI?) > > Oh. ... > > In case anybody finds these archived, it's OpenFTS: > http://sourceforge.net/projects/openfts/ > > Perhaps my question should be "What's the best full-text-index solution?" > You should at least check possibilities of using contrib/tsearch and contrib/intarray If you find out some good answers, report back to this list :) -------------- Hannu From pgsql-performance-owner@postgresql.org Tue Nov 26 21:40:35 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 120F9475FEE for ; Tue, 26 Nov 2002 21:40:30 -0500 (EST) Received: from o2.hostbaby.com (o2.hostbaby.com [208.187.29.121]) by postgresql.org (Postfix) with SMTP id 02242475FB9 for ; Tue, 26 Nov 2002 21:40:29 -0500 (EST) Received: (qmail 55984 invoked from network); 27 Nov 2002 02:40:38 -0000 Received: from unknown (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 27 Nov 2002 02:40:38 -0000 Received: from 12.249.229.112 (Hostbaby Webmail authenticated user typea@l-i-e.com) by www.l-i-e.com with HTTP; Tue, 26 Nov 2002 18:40:38 -0800 (PST) Message-ID: <62972.12.249.229.112.1038364838.squirrel@www.l-i-e.com> Date: Tue, 26 Nov 2002 18:40:38 -0800 (PST) Subject: Re: Full Text Index disk space requirements From: To: In-Reply-To: References: X-Priority: 3 Importance: Normal X-Mailer: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/240 X-Sequence-Number: 398 >> Wouldn't using f1.string = 'perth' be faster than f1.string ~ '^perth' >> > and >> equally useful? Or is ~ with ^ somehow actually faster than the > seemingly >> simple = comparison? > > f1.string = 'perth' would only match 'perth', while f1.string ~ '^perth' > would also match 'perthinent' (yes, I know this word does not exist). D'oh! I figured that one out in the shower this morning. Sleep deprivation, I guess... But something is very wrong with what I've done... archive=> explain SELECT article.* FROM article , article_fti as f1, article_fti as f2 WHERE TRUE AND (TRUE AND (f1.string ~ '^nuclear' AND f1.id = article.oid ) AND (f2.string ~ '^winter' AND f2.id = article.oid ) ) ; NOTICE: QUERY PLAN: Merge Join (cost=1476541.78..1492435.98 rows=77581 width=228) -> Merge Join (cost=740017.07..744846.55 rows=368824 width=224) -> Sort (cost=3492.36..3492.36 rows=17534 width=220) -> Seq Scan on article (cost=0.00..1067.34 rows=17534 width=220) -> Sort (cost=736524.71..736524.71 rows=368824 width=4) -> Seq Scan on article_fti f2 (cost=0.00..693812.18 rows=368824 width=4) -> Sort (cost=736524.71..736524.71 rows=368824 width=4) -> Seq Scan on article_fti f1 (cost=0.00..693812.18 rows=368824 width=4) EXPLAIN archive=> explain select * from article where text like '%nuclear%' and text like '%winter%'; NOTICE: QUERY PLAN: Seq Scan on article (cost=0.00..1155.01 rows=1 width=216) EXPLAIN archive=> \d article_fti Table "article_fti" Attribute | Type | Modifier -----------+------+---------- string | text | id | oid | Indices: article_fti_id_index, article_fti_string_index archive=> \d article Table "article" Attribute | Type | Modifier -------------------+---------+---------------------------------------------- id | integer | not null default nextval('article_ID'::text) ... text | text | Indices: article_id_index, article_oid_index, article_type_index archive=> I'm befuddled. From pgsql-performance-owner@postgresql.org Tue Nov 26 22:13:55 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CEEC9475D00; Tue, 26 Nov 2002 22:13:50 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 9CB35475CE5; Tue, 26 Nov 2002 22:13:49 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gAR3DpsX013414; Tue, 26 Nov 2002 22:13:51 -0500 (EST) To: "Curtis Faith" Cc: "Ron Johnson" , "PgSQL Performance ML" , pgsql-hackers@postgresql.org Subject: Re: [HACKERS] Realtime VACUUM, was: performance of insert/delete/update In-reply-to: References: Comments: In-reply-to "Curtis Faith" message dated "Tue, 26 Nov 2002 11:32:28 -0400" Date: Tue, 26 Nov 2002 22:13:51 -0500 Message-ID: <13413.1038366831@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/241 X-Sequence-Number: 399 "Curtis Faith" writes: > tom lane wrote: >> Sure, it's just shuffling the housekeeping work from one place to >> another. The thing that I like about Postgres' approach is that we >> put the housekeeping in a background task (VACUUM) rather than in the >> critical path of foreground transaction commit. > Couldn't we reuse tuple and index space as soon as there are no transactions > that depend on the old tuple or index values. I have imagined that this was > always part of the long-term master plan. > Couldn't we keep a list of dead tuples in shared memory and look in the list > first when deciding where to place new values for inserts or updates so we > don't have to rely on VACUUM (even a background one)? ISTM that either of these ideas would lead to pushing VACUUM overhead into the foreground transactions, which is exactly what we don't want to do. Keep in mind also that shared memory is finite ... *very* finite. It's bad enough trying to keep per-page status in there (cf FSM) --- per-tuple status is right out. I agree that automatic background VACUUMing would go a long way towards reducing operational problems. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 27 09:39:54 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1E4BC476E3D; Wed, 27 Nov 2002 09:25:59 -0500 (EST) Received: from prana.apb.com.tr (unknown [212.45.91.2]) by postgresql.org (Postfix) with ESMTP id 1693D476B64; Wed, 27 Nov 2002 09:01:22 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by prana.apb.com.tr (Postfix) with ESMTP id 177C111344; Wed, 27 Nov 2002 15:57:23 +0200 (EET) Received: from nicolailnx (unknown [192.168.1.164]) by prana.apb.com.tr (Postfix) with SMTP id AD13B11334; Wed, 27 Nov 2002 15:57:19 +0200 (EET) Message-ID: <043701c2961d$9bbd7d20$8016a8c0@apb.com.tr> From: "Nicolai Tufar" To: , "PgSQL Performance ML" References: <200211261909.gAQJ9ce02496@candle.pha.pa.us> Subject: Re: [HACKERS] Realtime VACUUM, was: performance of insert/delete/update Date: Wed, 27 Nov 2002 16:02:22 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Virus-Scanned: by AMaViS perl-11 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/242 X-Sequence-Number: 400 I always wandered if VACUUM is the right name for the porcess. Now, when PostgreSQL is actively challenging in Enterprise space, it might be a good idea to give it a more enterprise-like name. Try to think how it is looking for an outside person to see us, database professionals hold lenghty discussions about the ways we vacuum a database. Why should you need to vacuum a database? Is it dirty? In my personal opinion, something like "space reclaiming daemon", "free-list organizer", "tuple recyle job" or "segment coalesce process" would sound more business-like . Regards, Nick ----- Original Message ----- From: "Bruce Momjian" To: "Curtis Faith" Cc: "Tom Lane" ; "Ron Johnson" ; "PgSQL Performance ML" ; Sent: Tuesday, November 26, 2002 9:09 PM Subject: Re: [PERFORM] [HACKERS] Realtime VACUUM, was: performance of insert/delete/update > > Good ideas. I think the master solution is to hook the statistics > daemon information into an automatic vacuum that could _know_ which > tables need attention. > > -------------------------------------------------------------------------- - > > Curtis Faith wrote: > > tom lane wrote: > > > Sure, it's just shuffling the housekeeping work from one place to > > > another. The thing that I like about Postgres' approach is that we > > > put the housekeeping in a background task (VACUUM) rather than in the > > > critical path of foreground transaction commit. > > > > Thinking with my marketing hat on, MVCC would be a much bigger win if VACUUM > > was not required (or was done automagically). The need for periodic VACUUM > > just gives ammunition to the PostgreSQL opponents who can claim we are > > deferring work but that it amounts to the same thing. > > > > A fully automatic background VACUUM will significantly reduce but will not > > eliminate this perceived weakness. > > > > However, it always seemed to me there should be some way to reuse the space > > more dynamically and quickly than a background VACUUM thereby reducing the > > percentage of tuples that are expired in heavy update cases. If only a very > > tiny number of tuples on the disk are expired this will reduce the aggregate > > performance/space penalty of MVCC into insignificance for the majority of > > uses. > > > > Couldn't we reuse tuple and index space as soon as there are no transactions > > that depend on the old tuple or index values. I have imagined that this was > > always part of the long-term master plan. > > > > Couldn't we keep a list of dead tuples in shared memory and look in the list > > first when deciding where to place new values for inserts or updates so we > > don't have to rely on VACUUM (even a background one)? If there are expired > > tuple slots in the list these would be used before allocating a new slot from > > the tuple heap. > > > > The only issue is determining the lowest transaction ID for in-process > > transactions which seems relatively easy to do (if it's not already done > > somewhere). > > > > In the normal shutdown and startup case, a tuple VACUUM could be performed > > automatically. This would normally be very fast since there would not be many > > tuples in the list. > > > > Index slots would be handled differently since these cannot be substituted > > one for another. However, these could be recovered as part of every index > > page update. Pages would be scanned before being written and any expired > > slots that had transaction ID's lower than the lowest active slot would be > > removed. This could be done for non-leaf pages as well and would result in > > only reorganizing a page that is already going to be written thereby not > > adding much to the overall work. > > > > I don't think that internal pages that contain pointers to values in nodes > > further down the tree that are no longer in the leaf nodes because of this > > partial expired entry elimination will cause a problem since searches and > > scans will still work fine. > > > > Does VACUUM do something that could not be handled in this realtime manner? > > > > - Curtis > > > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > > -- > Bruce Momjian | http://candle.pha.pa.us > pgman@candle.pha.pa.us | (610) 359-1001 > + If your life is a hard drive, | 13 Roberts Road > + Christ can be your backup. | Newtown Square, Pennsylvania 19073 > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > From pgsql-performance-owner@postgresql.org Wed Nov 27 10:07:23 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 579A2476937 for ; Wed, 27 Nov 2002 10:07:18 -0500 (EST) Received: from smtp803.mail.sc5.yahoo.com (smtp803.mail.sc5.yahoo.com [66.163.168.182]) by postgresql.org (Postfix) with SMTP id 161A347641D for ; Wed, 27 Nov 2002 09:44:11 -0500 (EST) Received: from adsl-66-73-179-227.dsl.sfldmi.ameritech.net (HELO sbcglobal.net) (jrbeckstrom@sbcglobal.net@66.73.179.227 with plain) by smtp-sbc-v1.mail.vip.sc5.yahoo.com with SMTP; 27 Nov 2002 14:44:14 -0000 Message-ID: <3DE4D9F5.2070203@sbcglobal.net> Date: Wed, 27 Nov 2002 09:43:01 -0500 From: Jim Beckstrom User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Nicolai Tufar Cc: pgsql-hackers@postgresql.org, PgSQL Performance ML Subject: Re: [HACKERS] Realtime VACUUM, was: performance of insert/delete/update References: <200211261909.gAQJ9ce02496@candle.pha.pa.us> <043701c2961d$9bbd7d20$8016a8c0@apb.com.tr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/243 X-Sequence-Number: 401 Just for the humor of it, as well as to confirm Nick's perspective, years ago on our inhouse developed Burroughs mainframe dbms, we had a process called "garbage collect". Nicolai Tufar wrote: >I always wandered if VACUUM is the right name for the porcess. Now, when >PostgreSQL >is actively challenging in Enterprise space, it might be a good idea to give >it a more >enterprise-like name. Try to think how it is looking for an outside person >to see >us, database professionals hold lenghty discussions about the ways we >vacuum a database. Why should you need to vacuum a database? Is it >dirty? In my personal opinion, something like "space reclaiming daemon", >"free-list organizer", "tuple recyle job" or "segment coalesce process" >would >sound more business-like . > >Regards, >Nick > > >----- Original Message ----- >From: "Bruce Momjian" >To: "Curtis Faith" >Cc: "Tom Lane" ; "Ron Johnson" ; >"PgSQL Performance ML" ; > >Sent: Tuesday, November 26, 2002 9:09 PM >Subject: Re: [PERFORM] [HACKERS] Realtime VACUUM, was: performance of >insert/delete/update > > > > >>Good ideas. I think the master solution is to hook the statistics >>daemon information into an automatic vacuum that could _know_ which >>tables need attention. >> >>-------------------------------------------------------------------------- >> >> >- > > >>Curtis Faith wrote: >> >> >>>tom lane wrote: >>> >>> >>>>Sure, it's just shuffling the housekeeping work from one place to >>>>another. The thing that I like about Postgres' approach is that we >>>>put the housekeeping in a background task (VACUUM) rather than in the >>>>critical path of foreground transaction commit. >>>> >>>> >>>Thinking with my marketing hat on, MVCC would be a much bigger win if >>> >>> >VACUUM > > >>>was not required (or was done automagically). The need for periodic >>> >>> >VACUUM > > >>>just gives ammunition to the PostgreSQL opponents who can claim we are >>>deferring work but that it amounts to the same thing. >>> >>>A fully automatic background VACUUM will significantly reduce but will >>> >>> >not > > >>>eliminate this perceived weakness. >>> >>>However, it always seemed to me there should be some way to reuse the >>> >>> >space > > >>>more dynamically and quickly than a background VACUUM thereby reducing >>> >>> >the > > >>>percentage of tuples that are expired in heavy update cases. If only a >>> >>> >very > > >>>tiny number of tuples on the disk are expired this will reduce the >>> >>> >aggregate > > >>>performance/space penalty of MVCC into insignificance for the majority >>> >>> >of > > >>>uses. >>> >>>Couldn't we reuse tuple and index space as soon as there are no >>> >>> >transactions > > >>>that depend on the old tuple or index values. I have imagined that this >>> >>> >was > > >>>always part of the long-term master plan. >>> >>>Couldn't we keep a list of dead tuples in shared memory and look in the >>> >>> >list > > >>>first when deciding where to place new values for inserts or updates so >>> >>> >we > > >>>don't have to rely on VACUUM (even a background one)? If there are >>> >>> >expired > > >>>tuple slots in the list these would be used before allocating a new slot >>> >>> >from > > >>>the tuple heap. >>> >>>The only issue is determining the lowest transaction ID for in-process >>>transactions which seems relatively easy to do (if it's not already done >>>somewhere). >>> >>>In the normal shutdown and startup case, a tuple VACUUM could be >>> >>> >performed > > >>>automatically. This would normally be very fast since there would not be >>> >>> >many > > >>>tuples in the list. >>> >>>Index slots would be handled differently since these cannot be >>> >>> >substituted > > >>>one for another. However, these could be recovered as part of every >>> >>> >index > > >>>page update. Pages would be scanned before being written and any expired >>>slots that had transaction ID's lower than the lowest active slot would >>> >>> >be > > >>>removed. This could be done for non-leaf pages as well and would result >>> >>> >in > > >>>only reorganizing a page that is already going to be written thereby not >>>adding much to the overall work. >>> >>>I don't think that internal pages that contain pointers to values in >>> >>> >nodes > > >>>further down the tree that are no longer in the leaf nodes because of >>> >>> >this > > >>>partial expired entry elimination will cause a problem since searches >>> >>> >and > > >>>scans will still work fine. >>> >>>Does VACUUM do something that could not be handled in this realtime >>> >>> >manner? > > >>>- Curtis >>> >>> >>> >>>---------------------------(end of broadcast)--------------------------- >>>TIP 4: Don't 'kill -9' the postmaster >>> >>> >>> >>-- >> Bruce Momjian | http://candle.pha.pa.us >> pgman@candle.pha.pa.us | (610) 359-1001 >> + If your life is a hard drive, | 13 Roberts Road >> + Christ can be your backup. | Newtown Square, Pennsylvania >> >> >19073 > > >>---------------------------(end of broadcast)--------------------------- >>TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >> >> >> > > >---------------------------(end of broadcast)--------------------------- >TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > > From pgsql-performance-owner@postgresql.org Wed Nov 27 10:11:03 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6AC82476280 for ; Wed, 27 Nov 2002 10:11:02 -0500 (EST) Received: from egwn.net (ns2.egwn.net [193.172.5.4]) by postgresql.org (Postfix) with ESMTP id AC2B74768A8 for ; Wed, 27 Nov 2002 09:52:27 -0500 (EST) Received: from fibers.upc.es (gw01.es3.egwn.net [212.9.66.13]) (authenticated) by egwn.net (8.11.6/8.11.6/EGWN) with ESMTP id gAREqJV19980 for ; Wed, 27 Nov 2002 15:52:20 +0100 Message-ID: <3DE4DC24.3020108@fibers.upc.es> Date: Wed, 27 Nov 2002 15:52:20 +0100 From: Thrasher User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.1b) Gecko/20020721 X-Accept-Language: es, es-es, en-us MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Child process procedures Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/244 X-Sequence-Number: 402 Hi all, I have developed a system that is composed of 10 separate running processes. Each of the processes opens a connection to postgres with the C interface. Whenever any process has to process any query, it should fork and create a new independent process (not thread). How does the database connection is kept? In other words, if I fork a process that have an opened postgres connection, does its children inherit that connection, and can I use them as is, closing them at the end, or do I have to open a new connection foreach children process ? Thanks in advance, Thrasher From pgsql-performance-owner@postgresql.org Wed Nov 27 10:23:25 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 69814476735; Wed, 27 Nov 2002 10:23:22 -0500 (EST) Received: from salem.vale-housing.co.uk (mailgate.vale-housing.co.uk [193.195.77.162]) by postgresql.org (Postfix) with ESMTP id 02A784763A9; Wed, 27 Nov 2002 10:09:56 -0500 (EST) Subject: Re: [HACKERS] Realtime VACUUM, was: performance of insert/delete/update Date: Wed, 27 Nov 2002 15:09:59 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Message-ID: <03AF4E498C591348A42FC93DEA9661B8128C8C@mail.vale-housing.co.uk> Content-Class: urn:content-classes:message X-MS-Has-Attach: X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] [HACKERS] Realtime VACUUM, was: performance of insert/delete/update thread-index: AcKWJoaqExEHf3cYTamLTLiWWodMuwAAEJ2Q From: "Dave Page" To: "Nicolai Tufar" , , "PgSQL Performance ML" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/245 X-Sequence-Number: 403 > -----Original Message----- > From: Nicolai Tufar [mailto:ntufar@apb.com.tr]=20 > Sent: 27 November 2002 14:02 > To: pgsql-hackers@postgresql.org; PgSQL Performance ML > Subject: Re: [PERFORM] [HACKERS] Realtime VACUUM, was:=20 > performance of insert/delete/update >=20 >=20 > I always wandered if VACUUM is the right name for the=20 > porcess. Now, when PostgreSQL is actively challenging in=20 > Enterprise space, it might be a good idea to give it a more=20 > enterprise-like name. Try to think how it is looking for an=20 > outside person to see us, database professionals hold lenghty=20 > discussions about the ways we vacuum a database. Why should=20 > you need to vacuum a database? Is it dirty? In my personal=20 > opinion, something like "space reclaiming daemon", "free-list=20 > organizer", "tuple recyle job" or "segment coalesce process"=20 > would sound more business-like . As inspired by the SQL Server Enterprise Manager I've just been swearing at: "Database Optimizer" Regards, Dave. From pgsql-hackers-owner@postgresql.org Wed Nov 27 10:41:39 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8F938476694 for ; Wed, 27 Nov 2002 10:41:34 -0500 (EST) Received: from mail.eckpart.de (unknown [62.206.85.106]) by postgresql.org (Postfix) with SMTP id 9DAF24760F9 for ; Wed, 27 Nov 2002 10:34:00 -0500 (EST) Received: (qmail 26103 invoked from network); 27 Nov 2002 15:34:04 -0000 Received: from db2.eckpart.de (HELO db2) (tommi@192.168.41.72) by cserv.eckpart.de with SMTP; 27 Nov 2002 15:34:04 -0000 Content-Type: text/plain; charset="iso-8859-1" From: Tommi Maekitalo Organization: Dr. Eckhardt + Partner GmbH To: Subject: Re: [PERFORM] Realtime VACUUM, was: performance of insert/delete/update Date: Wed, 27 Nov 2002 16:34:04 +0100 User-Agent: KMail/1.4.3 References: <200211261909.gAQJ9ce02496@candle.pha.pa.us> <043701c2961d$9bbd7d20$8016a8c0@apb.com.tr> In-Reply-To: <043701c2961d$9bbd7d20$8016a8c0@apb.com.tr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211271634.04404.t.maekitalo@epgmbh.de> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/1032 X-Sequence-Number: 32248 Or just reorg. Am Mittwoch, 27. November 2002 15:02 schrieb Nicolai Tufar: > I always wandered if VACUUM is the right name for the porcess. Now, when > PostgreSQL > is actively challenging in Enterprise space, it might be a good idea to > give it a more > enterprise-like name. Try to think how it is looking for an outside person > to see > us, database professionals hold lenghty discussions about the ways we > vacuum a database. Why should you need to vacuum a database? Is it > dirty? In my personal opinion, something like "space reclaiming daemon", > "free-list organizer", "tuple recyle job" or "segment coalesce process" > would > sound more business-like . > > Regards, > Nick > > > ----- Original Message ----- > From: "Bruce Momjian" > To: "Curtis Faith" > Cc: "Tom Lane" ; "Ron Johnson" ; > "PgSQL Performance ML" ; > > Sent: Tuesday, November 26, 2002 9:09 PM > Subject: Re: [PERFORM] [HACKERS] Realtime VACUUM, was: performance of > insert/delete/update > > > Good ideas. I think the master solution is to hook the statistics > > daemon information into an automatic vacuum that could _know_ which > > tables need attention. > > > > -----------------------------------------------------------------------= -- > >- > > - > > > Curtis Faith wrote: > > > tom lane wrote: > > > > Sure, it's just shuffling the housekeeping work from one place to > > > > another. The thing that I like about Postgres' approach is that we > > > > put the housekeeping in a background task (VACUUM) rather than in t= he > > > > critical path of foreground transaction commit. > > > > > > Thinking with my marketing hat on, MVCC would be a much bigger win if > > VACUUM > > > > was not required (or was done automagically). The need for periodic > > VACUUM > > > > just gives ammunition to the PostgreSQL opponents who can claim we are > > > deferring work but that it amounts to the same thing. > > > > > > A fully automatic background VACUUM will significantly reduce but will > > not > > > > eliminate this perceived weakness. > > > > > > However, it always seemed to me there should be some way to reuse the > > space > > > > more dynamically and quickly than a background VACUUM thereby reducing > > the > > > > percentage of tuples that are expired in heavy update cases. If only a > > very > > > > tiny number of tuples on the disk are expired this will reduce the > > aggregate > > > > performance/space penalty of MVCC into insignificance for the majority > > of > > > > uses. > > > > > > Couldn't we reuse tuple and index space as soon as there are no > > transactions > > > > that depend on the old tuple or index values. I have imagined that th= is > > was > > > > always part of the long-term master plan. > > > > > > Couldn't we keep a list of dead tuples in shared memory and look in t= he > > list > > > > first when deciding where to place new values for inserts or updates = so > > we > > > > don't have to rely on VACUUM (even a background one)? If there are > > expired > > > > tuple slots in the list these would be used before allocating a new > > > slot > > from > > > > the tuple heap. > > > > > > The only issue is determining the lowest transaction ID for in-process > > > transactions which seems relatively easy to do (if it's not already > > > done somewhere). > > > > > > In the normal shutdown and startup case, a tuple VACUUM could be > > performed > > > > automatically. This would normally be very fast since there would not > > > be > > many > > > > tuples in the list. > > > > > > Index slots would be handled differently since these cannot be > > substituted > > > > one for another. However, these could be recovered as part of every > > index > > > > page update. Pages would be scanned before being written and any > > > expired slots that had transaction ID's lower than the lowest active > > > slot would > > be > > > > removed. This could be done for non-leaf pages as well and would resu= lt > > in > > > > only reorganizing a page that is already going to be written thereby > > > not adding much to the overall work. > > > > > > I don't think that internal pages that contain pointers to values in > > nodes > > > > further down the tree that are no longer in the leaf nodes because of > > this > > > > partial expired entry elimination will cause a problem since searches > > and > > > > scans will still work fine. > > > > > > Does VACUUM do something that could not be handled in this realtime > > manner? > > > > - Curtis > > > > > > > > > > > > ---------------------------(end of > > > broadcast)--------------------------- TIP 4: Don't 'kill -9' the > > > postmaster > > > > -- > > Bruce Momjian | http://candle.pha.pa.us > > pgman@candle.pha.pa.us | (610) 359-1001 > > + If your life is a hard drive, | 13 Roberts Road > > + Christ can be your backup. | Newtown Square, Pennsylvania > > 19073 > > > ---------------------------(end of broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster --=20 Dr. Eckhardt + Partner GmbH http://www.epgmbh.de From pgsql-hackers-owner@postgresql.org Thu Nov 28 12:43:05 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4A29B4764A2 for ; Wed, 27 Nov 2002 11:23:55 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 909BD47638D for ; Wed, 27 Nov 2002 11:23:13 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 15B1D43A822; Wed, 27 Nov 2002 11:23:12 -0500 (EST) From: "Merlin Moncure" X-Newsgroups: comp.databases.postgresql.hackers Subject: Re: [PERFORM] Realtime VACUUM, was: performance of insert/delete/update Date: Wed, 27 Nov 2002 11:26:30 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 88 Message-ID: References: X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-hackers@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/1078 X-Sequence-Number: 32293 How about OPTIMIZE? eg. optimize customers instead of analyze, could be paired with agressive so, OPTIMIZE AGREESSIVE very much a glass half empty, half full type thing. vacuum is not a problem, its a solution. Merlin ""Curtis Faith"" wrote in message news:DMEEJMCDOJAKPPFACMPMIEIDCFAA.curtis@galtair.com... > tom lane wrote: > > Sure, it's just shuffling the housekeeping work from one place to > > another. The thing that I like about Postgres' approach is that we > > put the housekeeping in a background task (VACUUM) rather than in the > > critical path of foreground transaction commit. > > Thinking with my marketing hat on, MVCC would be a much bigger win if VACUUM > was not required (or was done automagically). The need for periodic VACUUM > just gives ammunition to the PostgreSQL opponents who can claim we are > deferring work but that it amounts to the same thing. > > A fully automatic background VACUUM will significantly reduce but will not > eliminate this perceived weakness. > > However, it always seemed to me there should be some way to reuse the space > more dynamically and quickly than a background VACUUM thereby reducing the > percentage of tuples that are expired in heavy update cases. If only a very > tiny number of tuples on the disk are expired this will reduce the aggregate > performance/space penalty of MVCC into insignificance for the majority of > uses. > > Couldn't we reuse tuple and index space as soon as there are no transactions > that depend on the old tuple or index values. I have imagined that this was > always part of the long-term master plan. > > Couldn't we keep a list of dead tuples in shared memory and look in the list > first when deciding where to place new values for inserts or updates so we > don't have to rely on VACUUM (even a background one)? If there are expired > tuple slots in the list these would be used before allocating a new slot from > the tuple heap. > > The only issue is determining the lowest transaction ID for in-process > transactions which seems relatively easy to do (if it's not already done > somewhere). > > In the normal shutdown and startup case, a tuple VACUUM could be performed > automatically. This would normally be very fast since there would not be many > tuples in the list. > > Index slots would be handled differently since these cannot be substituted > one for another. However, these could be recovered as part of every index > page update. Pages would be scanned before being written and any expired > slots that had transaction ID's lower than the lowest active slot would be > removed. This could be done for non-leaf pages as well and would result in > only reorganizing a page that is already going to be written thereby not > adding much to the overall work. > > I don't think that internal pages that contain pointers to values in nodes > further down the tree that are no longer in the leaf nodes because of this > partial expired entry elimination will cause a problem since searches and > scans will still work fine. > > Does VACUUM do something that could not be handled in this realtime manner? > > - Curtis > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Wed Nov 27 12:20:27 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EC2EA47657C; Wed, 27 Nov 2002 12:20:16 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 4A8DD475FBE; Wed, 27 Nov 2002 12:19:50 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id gARHJCCm008482; Wed, 27 Nov 2002 10:19:12 -0700 (MST) Date: Wed, 27 Nov 2002 10:18:32 -0700 (MST) From: "scott.marlowe" To: Jim Beckstrom Cc: Nicolai Tufar , , PgSQL Performance ML Subject: Re: [HACKERS] Realtime VACUUM, was: performance of In-Reply-To: <3DE4D9F5.2070203@sbcglobal.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailBodyFilter: Message body has not been filtered X-MailScanner: Found to be clean X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/246 X-Sequence-Number: 404 In a similar vein, setting the way back machine to the mid 80s when I was in the USAF and teaching the computer subsystem of the A-10 INS test station, we had old reclaimed Sperry 1650 computers (the precursor to the 1750) that had come out of the 1960 era fire control systems on battleships like the Missouri and what not. When the OS went south, it would put up a message that said "System Crash at address XXXXXXX" or something very similar. A colonol saw that and insisted that the folks who wrote the OS change the word crash, since in the Air Force crash (as in plane crash) had such bad connotations. So, it got changed to "System Fault at address xxxxxxxxx" For the first month or two that happened, folks would ask what a system fault was and what to do with it. They new that a crash would need the machine to be power cycled but didn't know what to do with a system fault. Shortly after that, the manual for the test station had a little section added to it that basically said a system fault was a crash. :-) On Wed, 27 Nov 2002, Jim Beckstrom wrote: > Just for the humor of it, as well as to confirm Nick's perspective, > years ago on our inhouse developed Burroughs mainframe dbms, we had a > process called "garbage collect". > > Nicolai Tufar wrote: > > >I always wandered if VACUUM is the right name for the porcess. Now, when > >PostgreSQL > >is actively challenging in Enterprise space, it might be a good idea to give > >it a more > >enterprise-like name. Try to think how it is looking for an outside person > >to see > >us, database professionals hold lenghty discussions about the ways we > >vacuum a database. Why should you need to vacuum a database? Is it > >dirty? In my personal opinion, something like "space reclaiming daemon", > >"free-list organizer", "tuple recyle job" or "segment coalesce process" > >would > >sound more business-like . > > From pgsql-admin-owner@postgresql.org Thu Nov 28 12:31:53 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 73422475E20 for ; Wed, 27 Nov 2002 13:13:23 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 79D1B475AE6 for ; Wed, 27 Nov 2002 13:13:22 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 373AE43A847; Wed, 27 Nov 2002 13:13:22 -0500 (EST) From: "Merlin Moncure" X-Newsgroups: comp.databases.postgresql.admin Subject: Re: H/W RAID 5 on slower disks versus no raid on faster HDDs Date: Wed, 27 Nov 2002 13:16:35 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 42 Message-ID: References: <200211212215.02699.mallah@trade-india.com> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-admin@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/296 X-Sequence-Number: 6484 On Mon, 2002-11-25 at 23:03, David Gilbert wrote: > > I'm on a bit of a mission to stamp out this misconception. In my > testing, all but the most expensive hardware raid controllers are > actually slower than FreeBSD's software RAID. I've done my tests with > a variety of controllers with the same data load and the same disks. > I agree 100%: hardware raid sucks. We had a raid 5 Postgres server on midgrade hardware with 5 60gig 7200rpm IDE disks (240 gig total) and the thouroughput was just as high (maybe 10% less) than a single disk. Same for the seek times. CPU around 1Ghz never hit more than 10% for the raid service. Since very few databases are CPU limited, this is a small price to pay. We confirmed the performance results with heavy testing. There is virtually no disadvatage to software raid, just spend 10$ and get a 10% faster cpu. The linux software raid drivers (and others I assume) are very optimized. Not to sure about m$ but win2k comes with raid services, its pretty reasonalbe to believe they work ok. You can double the performance of a raid system by going 0+x or x+0 (eg 05 or 50). just by adding drives. This really doubles it, and an optmized software driver improves the seek times too by placing the idle heads it different places on the disks. p.s. scsi is a huge waste of money and is no faster than IDE. IMHO, scsi's only advantage is longer cables. Both interfaces will soon be obsolete with the coming serial ATA. High rpm disks are very expensive and add latent heat to your system. Western digitial's IDE disks outperform even top end scsi disks at a fraction of a cost. You can install a 4 drive 10 raid setup for the cost of a single 15k rpm scsi disk that will absolutely blow it away in terms of performance (reliability too). Just remember, don't add more than one IDE disk on a raid system to a single IDE channel! Also, do not attempt to buy IDE cables longer than 18"..they will not be reliable. Merlin From pgsql-performance-owner@postgresql.org Wed Nov 27 13:51:28 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5E3C94765F5 for ; Wed, 27 Nov 2002 13:51:27 -0500 (EST) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id 9C81E47634E for ; Wed, 27 Nov 2002 13:51:07 -0500 (EST) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id E928E2653D4 for ; Wed, 27 Nov 2002 10:51:06 -0800 (PST) X-Mailer: UserLand Frontier 8.0.5 (Macintosh OS) (mailServer v1.1..142) Mime-Version: 1.0 Message-Id: <25877025.1173728234@[4.42.179.151]> X-authenticated-sender: erics X-GSgroup: private Date: Wed, 27 Nov 2002 10:51:02 -0800 To: pgsql-performance@postgresql.org From: eric soroos Subject: Low Budget Performance, Part 2 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/247 X-Sequence-Number: 405 In our first installment a couple of weeks ago, I was asking about low end hardware optimizations, it got into ide/scsi, memory, and drive layout issues. I've been wondering more about the IDE/SCSI difference for low end hardware, and since my dev worksatation needed more hard drive space, I have a good opportunity to aquire hardware and run some benchmarks. The machine: Sawtooth g4/400, X 10.1.5, PG 7.2.1 from entropy.ch's packages. IDE: udma66 controller, ibm 7200rpm 15 gig deskstar. On it's own controller on the motherboard. This is the system drive. SCSI: Ultra160 ATTO Apple OEM PCI controller, Ultra320 cable, IBM 10k rpm 18 gig Ultrastar drive. Total scsi chain price = $140. pgbench was run from a machine (debian woody) on the local net segment that could actually compile pgbench. The IDE drive is about 2 years old, but was one of the fastest at the time. The SCSI drive is new but of inexpensive provenance. Essentially, roughly what I can afford if I'm doing a raid setup. My gut feeling is that this is stacked against the IDE drive. It's older lower rpm technology, and it has the system and pg binaries on it. The ide system in OSX probably has more development time behind it than scsi. However, the results say something a little different. Running pgbench with: scaling factor=1, # transactions = 100, and #clients =1,2,3,5,10,15 The only difference that was more than the scatter between runs was at 15 clients, and the SCSI system was marginally better. (diff of 1-2 tps at ~ 60 sustained) Roughly, I'm seeing the following performance clients SCSI IDE (tps) 1 83 84 2 83 83 3 79 79 5 77 76 10 73 73 15 66 64 I'm enclined to think that the bottleneck is elsewhere for this system and this benchmark, but I'm not sure where. Probably processor or bandwidth to memory. My questions from this excercise are: 1) do these seem like reasonable values, or would you have expected a bigger difference. 2) Is pgbench the proper test? It's not my workload, but it's also easily replicated at other sites. 3) Does running remotely make a difference? eric From pgsql-performance-owner@postgresql.org Wed Nov 27 14:19:29 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9549C475F25 for ; Wed, 27 Nov 2002 14:19:23 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B2C26474E44 for ; Wed, 27 Nov 2002 14:19:22 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id gARJJMsX021019; Wed, 27 Nov 2002 14:19:22 -0500 (EST) To: eric soroos Cc: pgsql-performance@postgresql.org Subject: Re: Low Budget Performance, Part 2 In-reply-to: <25877025.1173728234@[4.42.179.151]> References: <25877025.1173728234@[4.42.179.151]> Comments: In-reply-to eric soroos message dated "Wed, 27 Nov 2002 10:51:02 -0800" Date: Wed, 27 Nov 2002 14:19:22 -0500 Message-ID: <21018.1038424762@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/248 X-Sequence-Number: 406 eric soroos writes: > Running pgbench with: scaling factor=1, # transactions = 100, and > #clients =1,2,3,5,10,15 The scaling factor has to at least equal the max # of clients you intend to test, else pgbench will spend most of its time fighting update contention (parallel transactions wanting to update the same row). regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 27 15:45:43 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7E2984765DD for ; Wed, 27 Nov 2002 15:45:42 -0500 (EST) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id 392474765D4 for ; Wed, 27 Nov 2002 15:45:41 -0500 (EST) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id DA83E265AA4 for ; Wed, 27 Nov 2002 12:45:41 -0800 (PST) X-Mailer: UserLand Frontier 8.0.5 (Macintosh OS) (mailServer v1.1..142) Mime-Version: 1.0 Message-Id: <26289626.1173721357@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <21018.1038424762@sss.pgh.pa.us> Date: Wed, 27 Nov 2002 12:45:39 -0800 To: pgsql-performance@postgresql.org From: eric soroos Subject: Re: Low Budget Performance, Part 2 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/249 X-Sequence-Number: 407 On Wed, 27 Nov 2002 14:19:22 -0500 in message <21018.1038424762@sss.pgh.pa.us>, Tom Lane wrote: > eric soroos writes: > > Running pgbench with: scaling factor=1, # transactions = 100, and > > #clients =1,2,3,5,10,15 > > The scaling factor has to at least equal the max # of clients you intend > to test, else pgbench will spend most of its time fighting update > contention (parallel transactions wanting to update the same row). > Ok, with the scaling factor set at 20, the new results are more in line with expectations: For 1-10 clients, IDE gets 25-30 tps, SCSI 40-50 (more with more clients, roughly linear). The CPU was hardly working in these runs (~50% on scsi, ~20% on ide), vs nearly 100% on the previous run. I'm suspect that the previous runs were colored by having the entire dataset in memory as well as the update contention. eric From pgsql-performance-owner@postgresql.org Thu Nov 28 04:45:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 06BE3476631 for ; Thu, 28 Nov 2002 04:45:37 -0500 (EST) Received: from anchor-post-39.mail.demon.net (anchor-post-39.mail.demon.net [194.217.242.80]) by postgresql.org (Postfix) with ESMTP id A02944765D0 for ; Thu, 28 Nov 2002 04:45:09 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-39.mail.demon.net with esmtp (Exim 3.36 #2) id 18HLEM-0001Ph-0U; Thu, 28 Nov 2002 09:45:10 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id BA39316D5F; Thu, 28 Nov 2002 09:31:33 +0000 (GMT) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 2664A16D5E; Thu, 28 Nov 2002 09:31:33 +0000 (GMT) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton To: eric soroos , pgsql-performance@postgresql.org Subject: Re: Low Budget Performance, Part 2 Date: Thu, 28 Nov 2002 09:31:39 +0000 User-Agent: KMail/1.4.3 References: <26289626.1173721357@[4.42.179.151]> In-Reply-To: <26289626.1173721357@[4.42.179.151]> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200211280931.39873.richardh@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/250 X-Sequence-Number: 408 On Wednesday 27 Nov 2002 8:45 pm, eric soroos wrote: > Ok, with the scaling factor set at 20, the new results are more in line > with expectations: > > For 1-10 clients, IDE gets 25-30 tps, SCSI 40-50 (more with more clients, > roughly linear). > > The CPU was hardly working in these runs (~50% on scsi, ~20% on ide), vs > nearly 100% on the previous run. > > I'm suspect that the previous runs were colored by having the entire > dataset in memory as well as the update contention. A run of vmstat while the test is in progress might well show what's affect= ing=20 performance here. --=20 Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Thu Nov 28 07:05:31 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B741F475A9E for ; Thu, 28 Nov 2002 07:05:20 -0500 (EST) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 199CD4759AF for ; Thu, 28 Nov 2002 07:05:19 -0500 (EST) Received: from [192.168.1.1] ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20021128120522.ZLDM2204.lakemtao03.cox.net@[192.168.1.1]> for ; Thu, 28 Nov 2002 07:05:22 -0500 Subject: Re: Low Budget Performance, Part 2 From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <26289626.1173721357@[4.42.179.151]> References: <26289626.1173721357@[4.42.179.151]> Content-Type: text/plain Organization: Message-Id: <1038485117.24355.44.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 28 Nov 2002 06:05:17 -0600 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/251 X-Sequence-Number: 409 On Wed, 2002-11-27 at 14:45, eric soroos wrote: > On Wed, 27 Nov 2002 14:19:22 -0500 in message <21018.1038424762@sss.pgh.pa.us>, Tom Lane wrote: > > eric soroos writes: > > > Running pgbench with: scaling factor=1, # transactions = 100, and > > > #clients =1,2,3,5,10,15 > > > > The scaling factor has to at least equal the max # of clients you intend > > to test, else pgbench will spend most of its time fighting update > > contention (parallel transactions wanting to update the same row). > > > > Ok, with the scaling factor set at 20, the new results are more in line with > expectations: > > For 1-10 clients, IDE gets 25-30 tps, SCSI 40-50 (more with more clients, > roughly linear). > > The CPU was hardly working in these runs (~50% on scsi, ~20% on ide), vs nearly > 100% on the previous run. Going back to the OP, you think the CPU load is so high when using SCSI because of underperforming APPLE drivers? -- +------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "they love our milk and honey, but preach about another | | way of living" | | Merle Haggard, "The Fighting Side Of Me" | +------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Nov 28 07:57:06 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26DC7475A9E for ; Thu, 28 Nov 2002 07:57:03 -0500 (EST) Received: from new-smtp1.ihug.com.au (new-smtp1.ihug.com.au [203.109.250.27]) by postgresql.org (Postfix) with ESMTP id 2609A4759AF for ; Thu, 28 Nov 2002 07:57:02 -0500 (EST) Received: from p738-tnt2.mel.ihug.com.au (postgresql.org) [203.173.166.230] by new-smtp1.ihug.com.au with esmtp (Exim 3.22 #1 (Debian)) id 18HOE1-0005E7-00; Thu, 28 Nov 2002 23:57:02 +1100 Message-ID: <3DE6128D.1E681C08@postgresql.org> Date: Thu, 28 Nov 2002 23:56:45 +1100 From: Justin Clift X-Mailer: Mozilla 4.8 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: Low Budget Performance, Part 2 References: <26289626.1173721357@[4.42.179.151]> <1038485117.24355.44.camel@haggis> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/252 X-Sequence-Number: 410 Ron Johnson wrote: > > On Wed, 2002-11-27 at 14:45, eric soroos wrote: > > The CPU was hardly working in these runs (~50% on scsi, ~20% on ide), vs nearly > > 100% on the previous run. > > Going back to the OP, you think the CPU load is so high when using SCSI > because of underperforming APPLE drivers? Hmmm..... Eric, have you tuned PostgreSQL's memory buffers at all? :-) Regards and best wishes, Justin Clift -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi From pgsql-performance-owner@postgresql.org Thu Nov 28 13:14:19 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4CE0D476851 for ; Thu, 28 Nov 2002 13:14:18 -0500 (EST) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id 56383476301 for ; Thu, 28 Nov 2002 13:11:26 -0500 (EST) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id A0AF4267891 for ; Thu, 28 Nov 2002 10:11:25 -0800 (PST) X-Mailer: UserLand Frontier 8.0.5 (Macintosh OS) (mailServer v1.1..142) Mime-Version: 1.0 Message-Id: <30918002.1173644217@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <200211280931.39873.richardh@archonet.com> Date: Thu, 28 Nov 2002 10:11:19 -0800 To: pgsql-performance@postgresql.org From: eric soroos Subject: Re: Low Budget Performance, Part 2 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/253 X-Sequence-Number: 411 > > I'm suspect that the previous runs were colored by having the entire > > dataset in memory as well as the update contention. > > A run of vmstat while the test is in progress might well show what's affecting > performance here. Unfortunately, vmstat on OSX is not what it is on Linux. vm_stat on osx gives virtual memory stats, but not disk io or cpu load. iostat looks promising, but is a noop. Top takes 10 % of processor. eric From pgsql-performance-owner@postgresql.org Thu Nov 28 13:32:51 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 820DF475ECE for ; Thu, 28 Nov 2002 13:32:50 -0500 (EST) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id 0BCFC475EAE for ; Thu, 28 Nov 2002 13:32:50 -0500 (EST) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id 71A172678C3 for ; Thu, 28 Nov 2002 10:32:49 -0800 (PST) X-Mailer: UserLand Frontier 8.0.5 (Macintosh OS) (mailServer v1.1..142) Mime-Version: 1.0 Message-Id: <30995191.1173642930@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <1038485117.24355.44.camel@haggis> Date: Thu, 28 Nov 2002 10:32:46 -0800 To: From: eric soroos Subject: Re: Low Budget Performance, Part 2 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/254 X-Sequence-Number: 412 > > > > For 1-10 clients, IDE gets 25-30 tps, SCSI 40-50 (more with more clients, > > roughly linear). > > > > The CPU was hardly working in these runs (~50% on scsi, ~20% on ide), vs nearly > > 100% on the previous run. > > Going back to the OP, you think the CPU load is so high when using SCSI > because of underperforming APPLE drivers? I think it's a combination of one significant digit for cpu load and more transactions on the scsi system. I'm concluding that since the processor wasn't redlined, the bottleneck is somewhere else. Given the heavily transactional nature of these tests, it's reasonable to assume that the bottleneck is the disk. 10 tps= 600 transactions per minute, so for the scsi drive, I'm seeing 3k transactions / 10k revolutions, for a 30% 'saturation'. For the ide, I'm seeing 1800/7200 = 25% 'saturation'. The rotational speed difference is 40% (10k/7.2k), and the TPS difference is about 60% (50/30 or 40/25) So, my analysis here is that 2/3 of the difference in transaction speed can be attributed to rotational speed. It appears that the scsi architecture is also somewhat more efficient as well, allowing for a further 20% increase (over baseline) in tps. A test with a 7.2k rpm scsi drive would be instructive, as it would remove the rotational difference from the equation. As the budget for this is $0, donations will be accepted. eric From pgsql-performance-owner@postgresql.org Thu Nov 28 13:39:19 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2A90A475AFF for ; Thu, 28 Nov 2002 13:39:18 -0500 (EST) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id 9AB77475A1E for ; Thu, 28 Nov 2002 13:39:17 -0500 (EST) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id 107632678C4 for ; Thu, 28 Nov 2002 10:39:17 -0800 (PST) X-Mailer: UserLand Frontier 8.0.5 (Macintosh OS) (mailServer v1.1..142) Mime-Version: 1.0 Message-Id: <31018458.1173642543@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <3DE6128D.1E681C08@postgresql.org> Date: Thu, 28 Nov 2002 10:39:13 -0800 To: From: eric soroos Subject: Re: Low Budget Performance, Part 2 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/255 X-Sequence-Number: 413 > > Going back to the OP, you think the CPU load is so high when using SCSI > > because of underperforming APPLE drivers? > > Hmmm..... Eric, have you tuned PostgreSQL's memory buffers at all? > Shared memory, buffers, and sort memory have been boosted as well as the number of clients. The tuning that I've done is for my app, not for pgbench. eric From pgsql-admin-owner@postgresql.org Mon Dec 2 12:56:57 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 76CD14767D6 for ; Thu, 28 Nov 2002 21:58:47 -0500 (EST) Received: from mxin-1.poc.bytecomm.com.au (mx-1.poc.bytecomm.com.au [203.143.236.106]) by postgresql.org (Postfix) with ESMTP id 827DE476761 for ; Thu, 28 Nov 2002 21:58:31 -0500 (EST) ENTIREScan-Kaspersky: Yes ENTIREScan-Sophos: Yes Envelope-to: pgsql-admin@postgresql.org Delivery-date: Fri, 29 Nov 2002 13:04:46 +1000 Received: from alpha.bytecomm.com.au ([203.143.236.114] helo=herbie.local) by mxin-1.poc.bytecomm.com.au with esmtp (Exim 4.10) id 18HbSQ-0003iJ-1d for pgsql-admin@postgresql.org; Fri, 29 Nov 2002 13:04:46 +1000 Received: from slinky.bytecomm.com.au (slinky.local [192.168.0.13]) by herbie.local with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.1960.3) id WW9Z3R2X; Fri, 29 Nov 2002 13:01:12 +1000 Received: from davidj by slinky.bytecomm.com.au with local (Exim 4.10) id 18HbMN-0003O3-00 for pgsql-admin@postgresql.org; Fri, 29 Nov 2002 12:58:31 +1000 Date: Fri, 29 Nov 2002 12:58:31 +1000 From: David Jericho To: pgsql-admin@postgresql.org Subject: Re: H/W RAID 5 on slower disks versus no raid on faster HDDs Message-ID: <20021129025831.GA12300@bytecomm.com.au> References: <200211212215.02699.mallah@trade-india.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.27i Organisation: Bytecomm Pty Ltd X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/7 X-Sequence-Number: 6502 On Wed, Nov 27, 2002 at 01:16:35PM -0500, Merlin Moncure wrote: > I agree 100%: hardware raid sucks. I've been mostly ignoring this thread, but I'm going to jump in at this point. > We confirmed the performance results with heavy testing. There is virtually > no disadvatage to software raid, just spend 10$ and get a 10% faster cpu. Define heavy testing. I can do sequential selects on a low end PC with one client and have it perform as well as an E10K. I could also fire up 600 clients doing seemingly random queries and updates and reduce the same low end PC to a smoldering pile of rubble. It'd be easy to fudge the results of the "heavy testing" to match what I wanted to believe. > The linux software raid drivers (and others I assume) are very optimized. As are the Solaris drivers, and many others. But there is more to a RAID array than drivers. There's the stability of the controller chipsets and the latency involved in getting data to and from the devices. Would you feel comfortable if you knew the state data for the aircraft you're travelling on was stored on IDE software RAID? Part of the point of hardware raid is that it does do a small set of operations, and therefore far easier to specify and validate the correct operation of the software and hardware. > p.s. scsi is a huge waste of money and is no faster than IDE. IMHO, scsi's > only advantage is longer cables. Both interfaces will soon be obsolete with > the coming serial ATA. Don't get me wrong, I'm a huge fan of IDE RAID in the right locations, but comments like this reflect a total lack of understanding what makes SCSI a better protocol over IDE. Disconnected operation is one _HUGE_ benefit of SCSI, simply being the ability for the CPU and controller to send a command, and then both head off to do another task while waiting for data to be returned from the device. Most (that is most, not all) IDE controllers are incapable of this. Another is command reordering (which I believe SATA does have), being the reordering of requests to better utilise each head sweep. This feature comes into play far more obviously when you have many clients performing operations across a large dataset where the elements have no immediate relationship to each other. It is amplified when your database of such a size, and used in a way that you have multiple controllers with multiple spools. SCSI is not about speed to and from the device, although this does end up being a side effect of the design. It's about latency, and removal of contention from the shared bus. Ultra/320 devices in reality are no faster than Ultra/160 devices. What is faster, is that you can now have 4 devices instead of 2 on the same bus, with lower request latency and no reduction in throughput performance. SCSI also allows some more advanced features too. Remote storage over fibre, iSCSI, shared spools just to name a few. > High rpm disks are very expensive and add latent heat to your system. If you have a real justification for SCSI in your database server, you probably do have both the cooling and the budget to accomodate it. > Western digitial's IDE disks outperform even top end scsi disks at a > fraction of a cost. Complete and utter rubbish. That's like saying your 1.1 litre small city commuter hatch can outperform a 600hp Mack truck. Yes, in the general case it's quite probable. Once you start shuffling real loads IDE will grind the machine to a halt. Real database iron does not use normal IDE. > You can install a 4 drive 10 raid setup for the cost of a single 15k > rpm scsi disk that will absolutely blow it away in terms of performance See above. Raw disk speed does not equal performance. Database spool performance is a combination of a large number of factors, one being seek time, and another being bus contention. > (reliability too). Now you're smoking crack. Having run some rather large server farms for some very large companies, I can tell you with both anecdotal, and recorded historical evidence that the failure rate for IDE was at least double, if not four times that of the SCSI hardware. And the IDE hardware was under much lower loads than the SCSI hardware. > Just remember, don't add more than one IDE disk on a raid system to a single > IDE channel! Also, do not attempt to buy IDE cables longer than 18"..they > will not be reliable. So now you're pointing out that you share PCI bus interrupts over a large number of devices, introducing another layer of contention and that you'll have to cable your 20 spool machine with 20 cables each no longer than 45cm. Throw in some very high transaction rates, and a large data set that won't fit in your many GB of ram. I believe the game show sound effect would be similar to "Bzzzt". IDE for the general case is acceptable. SCSI is for everything else. -- David Jericho Senior Systems Administrator, Bytecomm Pty Ltd -- Scanned and found clear of viruses by ENTIREScan. http://www.entirescan.com/ From pgsql-performance-owner@postgresql.org Fri Nov 29 13:24:15 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 01BB447603D for ; Fri, 29 Nov 2002 13:24:15 -0500 (EST) Received: from email04.aon.at (WARSL402PIP5.highway.telekom.at [195.3.96.79]) by postgresql.org (Postfix) with SMTP id 2421A475ECE for ; Fri, 29 Nov 2002 13:24:14 -0500 (EST) Received: (qmail 250562 invoked from network); 29 Nov 2002 18:24:12 -0000 Received: from m149p023.dipool.highway.telekom.at (HELO cantor) ([62.46.8.151]) (envelope-sender ) by qmail5rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 29 Nov 2002 18:24:12 -0000 From: Manfred Koizar To: miken@bigpond.net.au (Mike Nielsen) Cc: pgsql-performance@postgresql.org Subject: Re: Query performance discontinuity Date: Fri, 29 Nov 2002 19:24:44 +0100 Message-ID: References: <1037074231.29703.234.camel@CPE-144-132-182-167> In-Reply-To: <1037074231.29703.234.camel@CPE-144-132-182-167> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/256 X-Sequence-Number: 414 On Fri, 15 Nov 2002 03:26:32 +0000 (UTC), in comp.databases.postgresql.performance you wrote: > -> Seq Scan on ps2 (cost=0.00..13783.40 rows=327895 width=179) ^^^^^ >(actual time=0.15..15211.49 rows=327960 loops=1) > > -> Index Scan using ps2_idx on ps2 (cost=0.00..881616.45 rows=327895 ^^^^^^ >width=179) (actual time=40.38..2151.38 rows=59629 loops=1) ^^^^ > >The ps2 table is in time_stamp order, but the tstarts aren't quite as >good -- they're mostly there, but they're computed by subtracting a >(stochastic) value from time_stamp. Mike, this is the well known "divide correlation by number of index columns" effect. This effect can be masked to a certain degree by reducing random_page_cost, as has already been suggested. The estimated index scan cost is also influenced by effective_cache_size; its default value is 1000. Try SET effective_cache_size = 50000; This should help a bit, but please don't expect a big effect. I'm running Postgres 7.2 with a modified index cost estimator here. The patch is at http://www.pivot.at/pg/16-correlation.diff This patch gives you two new GUC variables. index_cost_algorithm: allows you to select between different methods of interpolating between best case and worst case. 0 is the standard behavior (before the patch), 1 to 4 tend more and more towards lower index scan costs. See the switch statement in costsize.c for details. Default = 3. secondary_correlation: is a factor that is used to reduce the correlation of the first index column a little bit once for each additional index column. Default = 0.95. With default settings you should get an index cost estimate between 20000 and 30000. Which allows you to increase random_page_cost to a more reasonable value of something like 10 or even higher. If you try it, please let me know how it works for you. Servus Manfred From pgsql-performance-owner@postgresql.org Sat Nov 30 11:40:02 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5F865475DD7; Sat, 30 Nov 2002 11:40:00 -0500 (EST) Received: from office.nextbus.com (ns.nextbus.com [64.164.28.194]) by postgresql.org (Postfix) with ESMTP id B9DC247592C; Sat, 30 Nov 2002 11:39:59 -0500 (EST) Received: from visor.corp.nextbus.com (visor.corp.nextbus.com [192.168.1.109]) by office.nextbus.com (Postfix) with ESMTP id 82BBB4F87D; Sat, 30 Nov 2002 08:40:03 -0800 (PST) Received: from localhost (laurette@localhost) by visor.corp.nextbus.com (8.11.2/8.8.7) with ESMTP id gAUGe4T04752; Sat, 30 Nov 2002 08:40:04 -0800 X-Authentication-Warning: visor.corp.nextbus.com: laurette owned process doing -bs Date: Sat, 30 Nov 2002 08:40:04 -0800 (PST) From: Laurette Cisneros X-X-Sender: laurette@visor.corp.nextbus.com To: Justin Clift Cc: Ron Johnson , PgSQL Performance ML Subject: Re: Low Budget Performance, Part 2 In-Reply-To: <3DE6128D.1E681C08@postgresql.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/257 X-Sequence-Number: 415 Hi, Speaking of which, what is the recommended optimum setting for memory buffers? Thanks, L. On Thu, 28 Nov 2002, Justin Clift wrote: > > Hmmm..... Eric, have you tuned PostgreSQL's memory buffers at all? > > :-) > > Regards and best wishes, > > Justin Clift > > > > > -- Laurette Cisneros The Database Group (510) 420-3137 NextBus Information Systems, Inc. www.nextbus.com ---------------------------------- My other vehicle is my imagination. - bumper sticker From pgsql-performance-owner@postgresql.org Sat Nov 30 14:47:53 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 306C4475D64 for ; Sat, 30 Nov 2002 14:47:50 -0500 (EST) Received: from smtp3.ihug.com.au (smtp3.ihug.com.au [203.109.250.76]) by postgresql.org (Postfix) with ESMTP id 21D15475CED for ; Sat, 30 Nov 2002 14:47:49 -0500 (EST) Received: from p454-tnt1.mel.ihug.com.au (postgresql.org) [203.173.161.200] by smtp3.ihug.com.au with esmtp (Exim 3.22 #1 (Debian)) id 18IDad-0006n9-00; Sun, 01 Dec 2002 06:47:47 +1100 Message-ID: <3DE915E1.70689A1B@postgresql.org> Date: Sun, 01 Dec 2002 06:47:45 +1100 From: Justin Clift X-Mailer: Mozilla 4.8 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Laurette Cisneros Cc: Ron Johnson , PgSQL Performance ML Subject: Re: Low Budget Performance, Part 2 References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/258 X-Sequence-Number: 416 Laurette Cisneros wrote: > > Hi, > > Speaking of which, what is the recommended optimum setting for > memory buffers? Hi Laurette, It depends on how much memory you have, how big your database is, the types of queries, expected number of clients, etc. It's just that the default settings commonly cause non-optimal performance and massive CPU utilisation, so I was wondering. :-) Regards and best wishes, Justin Clift > Thanks, > > L. > On Thu, 28 Nov 2002, Justin Clift wrote: > > > > Hmmm..... Eric, have you tuned PostgreSQL's memory buffers at all? > > > > :-) > > > > Regards and best wishes, > > > > Justin Clift > > > > > > > > > > > > -- > Laurette Cisneros > The Database Group > (510) 420-3137 > NextBus Information Systems, Inc. > www.nextbus.com > ---------------------------------- > My other vehicle is my imagination. > - bumper sticker -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi