From: | John McCawley <nospam(at)hardgeus(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Performance of a view |
Date: | 2005-11-17 16:08:14 |
Message-ID: | 437CAAEE.2010808@hardgeus.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> I'd be curious to see what would happen if you added claimnum as a
> field in your view. I don't have a complete understanding of the
> postgres internals in terms of how it is able to push outer clauses
> down in to its views, but I think it might be able to optimize in
> that fashion if it is able to add a WHERE clause internally to the
> view, which it can't do in the case of claimnum since it doesn't
> exist in the view.
I added the claimnum and this actually slowed it down a bit because of
the additional group by, however I then changed my where clause to
filter on the view's claimnum rather than tbl_claim's claimnum, and I
got the results I wanted.
It seems to me that in the future I should always construct my views
such that my WHERE clauses end up on the view and not on any tables that
they join with. The only problem with this is that very often I don't
know in advance what fields the client will want to search by, and now
I'll end up with two steps instead of one (modify my code AND modify the
view), however the speed increase is an order of magnatude and well
worth it.
Thanks!
John
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2005-11-17 16:13:06 | Re: Numeric 508 datatype |
Previous Message | codeWarrior | 2005-11-17 16:03:57 | Re: Very slow queries on 8.1 |