Let's say that I have the following two queries, getting aggregate data from two separate tables:
SELECT count(*) as count_a
FROM table_a
WHERE some_column = "some_value"
SELECT count(*) as count_b
FROM table_b
WHERE another_column = "another_value"
The queries are executed by code that uses both count_a
and count_b
in some sort of computation
To get count_a
and count_b
, I have the option of either executing both queries in parallel or combining them into a single query (below) that can be executed by itself to get both results:
SELECT (
SELECT count(*)
FROM table_a
WHERE some_column = "some_value"
) as count_a,
(
SELECT count(*)
FROM table_b
WHERE another_column = "another_value"
) as count_b
Am I likely to see any noticeable (or even a small) difference in performance between the two approaches? If so, which approach is more efficient?