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

Re: readlocals SQL query



On Thu, 25 Jan 2007, Catalin Constantin wrote:

> I noticed in the postgresql log that a CPU consuming query is ran
> quite often.
>
> SELECT DISTINCT virtual_host FROM passwd WHERE enabled='1' AND (startdate IS
> NULL OR startdate<=CURRENT_TIMESTAMP) AND (stopdate IS NULL OR
> stopdate>=CURRENT_TIMESTAMP);
>
> We host around 5000 domains and running this query that often slows
> the server quite a lot.
>
> Can somebody explain why this query is needed ?

This gathers the list of domains that you are hosting, i.e., the domains that
your server accepts mail for.

> How can it be optimized ?

How many user records in the table?

Can you post the EXPLAIN output for your database?

-- 
Alex Howansky
Wankwood Associates
http://wankwood.com/