X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F34D2D1B55D for ; Mon, 27 Oct 2003 19:23:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 15548-01 for ; Mon, 27 Oct 2003 15:23:02 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id CE493D1B533 for ; Mon, 27 Oct 2003 15:23:00 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id A102036932; Mon, 27 Oct 2003 14:23:01 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 1AECxB-0005b1-00; Mon, 27 Oct 2003 14:23:01 -0500 To: Dror Matalon Cc: Postgresql Performance Subject: Re: Various performance questions References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> In-Reply-To: <20031027045431.GE2979@rlx11.zapatec.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Oct 2003 14:23:01 -0500 Message-ID: <87he1uwkmi.fsf@stark.dyndns.tv> Lines: 82 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/692 X-Sequence-Number: 4440 In fact the number of records seems to be almost irrelevant. A sequential scan takes almost exactly the same amount of time up until a critical region (for me around 100000 records) at which point it starts going up very quickly. It's almost as if it's doing some disk i/o, but I'm watching vmstat and don't see anything. And in any case it would have to read all the same blocks to do the sequential scan regardless of how many records match, no? I don't hear the disk seeking either -- though oddly there is some sound coming from the computer when this computer running. It sounds like a high pitched sound, almost like a floppy drive reading without seeking. Perhaps there is some i/o happening and linux is lying about it? Perhaps I'm not hearing seeking because it's reading everything from one track and not seeking? Very strange. slo=> explain analyze select 1::int4 from test where a < 1 ; QUERY PLAN ------------------------------------------------------------------------------------------------------ Seq Scan on test (cost=0.00..1693.00 rows=11 width=0) (actual time=417.468..417.468 rows=0 loops=1) Filter: (a < 1) Total runtime: 417.503 ms (3 rows) Time: 418.181 ms slo=> explain analyze select 1::int4 from test where a < 100 ; QUERY PLAN ----------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..1693.00 rows=53 width=0) (actual time=0.987..416.224 rows=50 loops=1) Filter: (a < 100) Total runtime: 416.301 ms (3 rows) Time: 417.008 ms slo=> explain analyze select 1::int4 from test where a < 10000 ; QUERY PLAN --------------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..1693.00 rows=5283 width=0) (actual time=0.812..434.967 rows=5000 loops=1) Filter: (a < 10000) Total runtime: 439.620 ms (3 rows) Time: 440.665 ms slo=> explain analyze select 1::int4 from test where a < 100000 ; QUERY PLAN ----------------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..1693.00 rows=50076 width=0) (actual time=0.889..458.623 rows=50000 loops=1) Filter: (a < 100000) Total runtime: 491.281 ms (3 rows) Time: 491.998 ms slo=> explain analyze select 1::int4 from test where a < 1000000 ; QUERY PLAN ------------------------------------------------------------------------------------------------------------ Seq Scan on test (cost=0.00..1693.00 rows=99991 width=0) (actual time=0.018..997.421 rows=715071 loops=1) Filter: (a < 1000000) Total runtime: 1461.851 ms (3 rows) Time: 1462.898 ms slo=> explain analyze select 1::int4 from test where a < 10000000 ; QUERY PLAN ------------------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..1693.00 rows=99991 width=0) (actual time=0.015..1065.456 rows=800000 loops=1) Filter: (a < 10000000) Total runtime: 1587.481 ms (3 rows) -- greg