|
|
|
|
|
by ewalk153
1919 days ago
|
|
If this is a database for reporting, using a temporary table is probably fine and a union all wouldn’t concern me. On Mysql, using a union all creates a temp table which can perform catastrophically under database load.
I’ve seen a union all query with zero rows in the second half render a database server unresponsive when the database was under high load, causing a service disruption. We ended rewriting the union all query as two database fetches and have not seen a single problem in that area since. I was shocked by this union all behavior, but it is apparently a well known thing on MySQL. I can’t speak to Postgres behavior for this kind of query. |
|