Search Postgresql Archives

Re: Why count(*) doest use index?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Glenn Maynard [mailto:glenn@xxxxxxxx] 
> Sent: Monday, March 07, 2011 5:27 PM
> To: pgsql-general@xxxxxxxxxxxxxx
> Subject: Re: Why count(*) doest use index?
> 
> 
> An index on "events(user, event_time::date)" could optimize 
> this, eg. effectively maintaining a count of matching rows 
> for each (user, day) tuple--which is ultimately what I'm 
> doing manually with triggers.  Of course, it would have a 
> significant cost, in some combination of complexity, index 
> size and write concurrency, and couldn't be the default 
> behavior for an index.
> 
> --
> Glenn Maynard
> 

Indexes don't "maintain counts", indexes maintain pointers to the table
records.

What you need is "materialized view" storing aggregates.
And it looks like you already have it with your triggers.

Regards,
Igor Neyman

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux