| From: | "Gaetano Mendola" <mendola(at)bigfoot(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Performance inside and outside view ( WAS Re: Select the max on a field ) |
| Date: | 2002-09-12 15:53:38 |
| Message-ID: | alqd9s$mlb$1@news.hub.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote in message
news:7350(dot)1031842223(at)sss(dot)pgh(dot)pa(dot)us(dot)(dot)(dot)
> "Gaetano Mendola" <mendola(at)bigfoot(dot)com> writes:
> > Yes that's right it's help me,
> > but here the optimizer have some problems:
>
> What's the datatype of id_user, and why are you quoting the compared
> constant in some cases but not others? I don't think the difference
> has anything to do with the view here ...
id_user is an INTEGER type.
Well what about this two selects:
a) SELECT DISTINCT ON (id_user) *
FROM user_logs
WHERE id_user = 5430
ORDER BY id_user, id_user_log DESC;
b) CREATE VIEW last_user_logs AS
SELECT DISTINCT ON (id_user) *
FROM user_logs
ORDER BY id_user, id_user_log DESC;
SELECT *
FROM last_user_logs
WHERE id_user = 5430
I think that in the second case the filter is not pushed inside the view.
Ciao
Gaetano
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hanno Wiegard | 2002-09-12 15:57:44 | Table alias in DELETE statements |
| Previous Message | Stephan Szabo | 2002-09-12 15:22:54 | Re: Performance inside and outside view ( WAS Re: Select the |