Обсуждение: Benchmark two separate SELECTs versus one LEFT JOIN

Поиск
Список
Период
Сортировка

Benchmark two separate SELECTs versus one LEFT JOIN

От
Miles Keaton
Дата:
Has anyone seen a benchmark on the speed difference between:

SELECT * FROM item WHERE id=123;
and
SELECT * FROM vendor WHERE id=515;

versus:

SELECT * FROM item LEFT JOIN vendor ON item.vendor_id=vendor.id WHERE
item.id=123;



I only have a laptop here so I can't really benchmark properly.
I'm hoping maybe someone else has, or just knows which would be faster
under high traffic/quantity.

Thanks!

Re: Benchmark two separate SELECTs versus one LEFT JOIN

От
Josh Berkus
Дата:
Miles,

> I only have a laptop here so I can't really benchmark properly.
> I'm hoping maybe someone else has, or just knows which would be faster
> under high traffic/quantity.

Well, it's really a difference between round-trip time vs. the time required
to compute the join.   If your database is setup correctly, the 2nd should be
faster.

However, it should be very easy to test ....

--
Josh Berkus
Aglio Database Solutions
San Francisco