I have 3 tables (A,B,C) and I need quite often to query the result of
A inner join B
union
A inner join C
I’m just thinking which way is going to be faster:
-
to write in each query the whole thing from scratch
-
to create a view and use it in queries
If the view contains no aggregations, then using the view will be exactly the same as using the raw SQL. No aggregations means that a where clause can be applied ‘internally’ to a view where the optimiser deems optimal (based on statistics). (I think this is often referred to as ‘pushing’ the where clause inside a view)