Have you vacuum'd and/or analyzed D2?
http://www.postgresql.org/docs/8.1/static/maintenance.html http://www.postgresql.org/docs/8.1/static/sql-analyze.html
----James RobinsonSocialserve.com