Re: Large tables, ORDER BY and sequence/index scans

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Milan Zamazal <pdm(at)brailcom(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Large tables, ORDER BY and sequence/index scans
Date: 2010-01-05 15:43:18
Message-ID: 162867791001050743l2ca61825sb5b045c3d807806d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/1/5 Milan Zamazal <pdm(at)brailcom(dot)org>:
>>>>>> "PS" == Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>
>    PS> please EXPLAIN ANALYZE Pavel
>
> I see, I'm sorry.  Here are the results:

Have you original values random_page_cost and seq_page_cost in postgres.conf?

it is strange.

Pavel

>
>  set enable_seqscan = on;
>  explain analyze declare c cursor for select * from foo2 order by value;
>                                                         QUERY PLAN
>  -------------------------------------------------------------------------------------------------------------------------
>   Sort  (cost=1829429.20..1854429.20 rows=9999999 width=10) (actual time=43432.727..49303.902 rows=9999999 loops=1)
>     Sort Key: value
>     Sort Method:  external merge  Disk: 204208kB
>     ->  Seq Scan on foo2  (cost=0.00..154049.99 rows=9999999 width=10) (actual time=0.058..1775.928 rows=9999999 loops=1)
>   Total runtime: 53693.012 ms
>  (5 rows)
>
>  set enable_seqscan = off;
>  explain analyze declare c cursor for select * from foo2 order by value;
>
>                                                                   QUERY PLAN
>  ---------------------------------------------------------------------------------------------------------------------------------------------
>   Index Scan using foo2_value_idx on foo2  (cost=0.00..32220140.73 rows=9999999 width=10) (actual time=0.225..55055.583 rows=9999999 loops=1)
>   Total runtime: 56394.283 ms
>  (2 rows)
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Milan Zamazal 2010-01-05 15:53:00 Re: Large tables, ORDER BY and sequence/index scans
Previous Message Grzegorz Jaśkiewicz 2010-01-05 15:38:17 Re: Using table name in column for joining