pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Dror Matalon <dror@zapatec.com>
Cc: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: Various performance questions
Date: 27 Oct 2003 14:23:01 -0500
Message-ID: <87he1uwkmi.fsf@stark.dyndns.tv> (raw)
In-Reply-To: <20031027045431.GE2979@rlx11.zapatec.com>
References: <20031026194449.GD2979@rlx11.zapatec.com>
	<87u15vxrue.fsf@stark.dyndns.tv>
	<20031027045431.GE2979@rlx11.zapatec.com>


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




view thread (23+ messages)  latest in thread

Message-ID: <87he1uwkmi.fsf@stark.dyndns.tv>
Permalink:  ../87he1uwkmi.fsf@stark.dyndns.tv/
Also on:    postgresql.org/message-id/87he1uwkmi.fsf@stark.dyndns.tv

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: gsstark@mit.edu, dror@zapatec.com
  Subject: Re: Various performance questions
  In-Reply-To: <87he1uwkmi.fsf@stark.dyndns.tv>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox