Re: Can this be indexed?

From: "Jerry III" <jerryiii(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Can this be indexed?
Date: 2004-11-07 09:29:30
Message-ID: _Vljd.7851$O11.4984@newsread3.news.pas.earthlink.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

But if you do build an index over "id" then pgsql would only have to do a
sequential scan on that index, which might be a lot faster if your table
contains a lot of other data, won't it?

Jerry

""Ed L."" <pgsql(at)bluepolka(dot)net> wrote in message
news:200411060930(dot)30859(dot)pgsql(at)bluepolka(dot)net(dot)(dot)(dot)
> On Saturday November 6 2004 7:34, Net Virtual Mailing Lists wrote:
>> Is there a way to create an index that would make this query be efficient
>> and not perform a sequential scan?
>>
>> SELECT count(*) AS count,id FROM sometable GROUP BY id;
>>
>> .. I've considered creating a rule on this table which would put the
>> results of this into another table anytime it is updated, but I thought
>> there might be an easier way.
>
> Since you have no "WHERE" clause and you want to group by id, I believe
> pgsql has to scan all id values. Those id values are only fully stored in
> the table, so I don't think so.
>
> Ed
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gary L. Burnore 2004-11-07 17:19:14 Re: RFD: comp.databases.postgresql.general
Previous Message Arjen van der Meijden 2004-11-07 09:19:33 Re: Sorting based on maximum value over several columns