Search Postgresql Archives

Re: max time in a table query takes ages

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

 



"=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?=" <gryzman@xxxxxxxxx> writes:
> I have a simple query over a fairly simple query here, that scans for max
> date in a table that's fairly hudge (300M rows). there's index on that field
> that's being used, but for whatever reason, it takes ages. Ideas ?

>  select date_trunc('day', max(data)) into dt from staticstats where
> processed = false

I suppose the problem is that rows with processed = false are very few
in the upper range of data.  If so, and if you really need this to go
fast, a partial index might be worth its overhead:
	create index foo on staticstats(data) where processed = false;

			regards, tom lane

-- 
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