On Mon, 19 Nov 2001, Brian Avis wrote:
> | server_id | date | time | data_type_id | data |
> |___________|________|________|______________|______|
> | | | | | |
> | 26 | a date | a time | 8 | 98 |
> | | | | | |
> -----------------------------------------------------
>
>
> This table is indexed on server_id and data_type_id.
>
> It currently has about 674,456 rows and is growing on a daily
> basis.
>
> The problem is that selects from this table are really slow.
>
> For instance if I do this.
>
> SELECT AVG(data) FROM system_data
> WHERE date BETWEEN CAST('2001-02-01' AS DATE)
> AND CAST ('2001-02-28' AS DATE)
> AND
> server_id = 26
> AND
> data_type_id = 8;
>
> It will take several seconds to complete this select.
Let's go through the usual. Have you used vacuum analyze
recently and what does explain show for the query?