Re: help understanding analyze

From: "Shoaib Mir" <shoaibmir(at)gmail(dot)com>
To: "Luca Ferrari" <fluca1978(at)infinito(dot)it>
Cc: "pgsql general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: help understanding analyze
Date: 2006-12-09 08:22:46
Message-ID: bf54be870612090022y78c13747qc98a43b98e7bbfec@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You will need to first ANALYZE the table so that the stats are updated, and
then it depends on the number of records in the table as well because if the
number is low then a Sequence will be much better cost wise then choosing an
index scan...

Thanks,
---------
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)

On 12/8/06, Luca Ferrari <fluca1978(at)infinito(dot)it> wrote:
>
> Hi all,
> excuse me for this trivial question, but here's my doubt:
> create table person(varchar id, varchar surname, varchar name)
> with id primary key. Now, the query:
> select * from person order by surname,name
> provide me an explaination that is sequential scan + sort, as I expected.
> After that I build an index on surname,name (clustered) and run vacuum to
> update statistics. Then I ran again the query and got the same results
> (scan
> + sort) with the same time.
> Now my trivial question is: why another sort? The index is clustered so
> the
> database should not need to sort the output, or am I using wrong the
> tools?
> Someone can explain me that?
>
> Thanks,
> Luca
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org/
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shoaib Mir 2006-12-09 08:25:21 Re: loading data, creating indexes, clustering, vacuum...
Previous Message Shoaib Mir 2006-12-09 08:19:33 Re: TOAD-like query builder for PostgreSQL?