Re: Seq Scan - Mailing list pgsql-general

From Tyler Durden
Subject Re: Seq Scan
Date
Msg-id ab07320e0706011024n4383117an1d69b96584536a71@mail.gmail.com
Whole thread Raw
In response to Re: Seq Scan  ("Joshua D. Drake" <jd@commandprompt.com>)
Responses Re: Seq Scan  (Michael Glaesemann <grzm@seespotcode.net>)
Re: Seq Scan  (Reece Hart <reece@harts.net>)
List pgsql-general
Ok, my bad.
But why this happens:
# explain ANALYZE select id from table_name where id>200000;
                                                                 QUERY PLAN

--------------------------------------------------------------------------------------------------------------------------------------------
 Index Scan using table_name_pkey on table_name  (cost=0.00..2618.96
rows=68960 width=4) (actual time=220.543..1479.495 rows=66730 loops=1)
   Index Cond: (id > 200000)
 Total runtime: 1504.839 ms
(3 rows)

dun=# explain ANALYZE select id from table_name where id>10;
                                                      QUERY PLAN
----------------------------------------------------------------------------------------------------------------------
 Seq Scan on table_name  (cost=0.00..9268.12 rows=266703 width=4)
(actual time=107.935..2733.592 rows=266720 loops=1)
   Filter: (id > 10)
 Total runtime: 2833.744 ms
(3 rows)


It uses Index Scan for id>200000 and Seq Scan for id>10?!

On 6/1/07, Joshua D. Drake <jd@commandprompt.com> wrote:

> Nothing. You have to scan the table because you aren't giving postgresql
> anything to use the index by.
>
> Joshua D. Drake
>

pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Looking for Graphical people for PostgreSQL tradeshow signage
Next
From: Dudás József
Date:
Subject: Re: invalid memory alloc after insert with c trigger function