Re: select count(*) is slow

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

 



aditya desai <admad123@xxxxxxxxx> writes:
> Below query takes 12 seconds. We have an index on  postcode.

> select count(*) from table where postcode >= '00420' AND postcode <= '00500'

That query does not match this index:

> CREATE INDEX Table_i1
>     ON table  USING btree
>     ((postcode::numeric));

You could either change postcode to numeric, change all your queries
of this sort to include the cast explicitly, or make an index that
doesn't have a cast.

			regards, tom lane





[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux