Re: Various performance questions

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Dror Matalon <dror(at)zapatec(dot)com>
Cc: Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Various performance questions
Date: 2003-10-27 19:23:01
Message-ID: 87he1uwkmi.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2003-10-27 19:26:07 Re: Various performance questions
Previous Message Greg Stark 2003-10-27 19:10:11 Re: Various performance questions