Subject | Re: [firebird-support] simple sql join ? |
---|---|
Author | Martijn Tonies |
Post date | 2006-03-31T13:29:32Z |
> Well, in fact I need to perform "dummy" union with joins; but I cant useDunno exactly - but you should use a join when a join is needed
> union, because this
> select is incapsulated into view, and so, first of all it will union
> tables, ant only then will do outer filtering (and, I suppose, without
> indices)
> Maybe I am wrong ?
and you should use a union when a union is needed.
You might want to try UNION ALL instead of plain UNION and
see if that makes a difference.
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
> sample :
> TB1 (ID1,DATE1),TB2(ID2,DATE2). ID,DATE1/2 - indexed.
> this would be what I need :
>
> select tb1.id,tb1.date1 from tb1
> where date1 > '2000.01.01'
> union
> select tb2.id2,tb2.date2 from tb2
> where date2 > '2000.01.01'.
>
> date1/2 is indexed field, so results are instant.
>
> But, because of some reason, we have to incapsulate this selection into
> view :
> create view V_A1
> (
> ID,
> DATE0
> )
> AS
> select tb1.id,tb1.date1 from tb1
> union
> select tb2.id2,tb2.date2 from tb2.
>
> And now,
> select * V_A1 where date0 > '2000.01.01'
> is very, very slow....I looks, like FB decides first of all make union
> and then filter it. I definitely know this does not happen with joins :).
> That is why I need make "union" :) via joins :).