Subject | Re: [firebird-support] Strange performance on a VIEW |
---|---|
Author | Arno Brinkman |
Post date | 2005-07-29T07:02:12Z |
Hi Ben,
for this is that you could filter on an aggregate function (in your case SUM(t2.ID)). The only
workaround is running the statement direct or use an SP. The same problem is there for UNIONs in
VIEWs.
Firebird 2.0 will become much smarter for these VIEWs and will try to "distribute" the condition
from the HAVING clause to the WHERE clause when possible.
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database developer support:
http://www.databasedevelopmentforum.com
Firebird open source database (based on IB-OE) with many SQL-99 features:
http://www.firebirdsql.org
http://www.firebirdsql.info
Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info
> I have a view (lets call it V_VIEW).Your condition on the VIEW is placed in the HAVING clause instead of in the WHERE clause. The reason
> select ID, A, B, t2.C, sum(t2.D)
> from table1 t1
> left join table2 t2 on t1.ID = t2.ID
> group by ID, A, B, C
> When I run a query like this:
> select * from V_VIEW where ID = X
> it is SLOW
> But if I don't use the view, and just take the SQL that makes up
> V_VIEW and put the "where ID = X" into that SQL, it is FAST
for this is that you could filter on an aggregate function (in your case SUM(t2.ID)). The only
workaround is running the statement direct or use an SP. The same problem is there for UNIONs in
VIEWs.
Firebird 2.0 will become much smarter for these VIEWs and will try to "distribute" the condition
from the HAVING clause to the WHERE clause when possible.
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database developer support:
http://www.databasedevelopmentforum.com
Firebird open source database (based on IB-OE) with many SQL-99 features:
http://www.firebirdsql.org
http://www.firebirdsql.info
Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info