From: | Richard Broersma Jr <rabroersma(at)yahoo(dot)com> |
---|---|
To: | "Reuven M(dot) Lerner" <reuven(at)lerner(dot)co(dot)il>, Webb Sprague <webb(dot)sprague(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Database slowness -- my design, hardware, or both? |
Date: | 2007-03-08 18:25:56 |
Message-ID: | 767092.60664.qm@web31802.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> LOG: statement: UPDATE Transactions
> SET previous_value = previous_value(id)
> WHERE new_value IS NOT NULL
> AND new_value <> ''
> AND node_id IN (SELECT node_id FROM NodeSegments)
> LOG: duration: 16687993.067 ms
I hope that I can presume some suggestions that I gleened after finishing my celko book. I don't
know if the suggestions presented will help in your case.
From the reading WHERE conditions such as <> '' or IS NOT NULL can be preformance killers as these
may discourge the optimizer from using an index scan. The suggest was to replace this with:
new_value > '<some minimum value possible in this field i.e. A>'
this WHERE conditions should only find non-NULL and non-empty strings.
Also, the IN is also know as a killer so the suggestion was to reform the query like so:
UPDATE Transactions
SET previous_value = previous_value(id)
FROM NodeSegments
WHERE Transactions.Node_id = NodeSegments.Node_id
AND Transactions.new_value > 'A'; --assuming A is a minimum value
I hope this can help.
Regards,
Richard Broersma Jr.
From | Date | Subject | |
---|---|---|---|
Next Message | Rhys Stewart | 2007-03-08 18:33:40 | group by and aggregate functions on regular expressions |
Previous Message | Martijn van Oosterhout | 2007-03-08 18:25:11 | Re: vacuum error |