Multiple queries OR one and big

Поиск
Список
Период
Сортировка
От Alex Dovlecel
Тема Multiple queries OR one and big
Дата
Msg-id E18ItiF-0002aB-00@ford.kbs.twi.tudelft.nl
обсуждение исходный текст
Список pgsql-jdbc
Hello all,

This is a little bit out of topic but is related to jdbc.

I have a database containing three tables : Route, RouteItem and
RouteItemStop (Route : 1 -- n RouteItems 1 -- n RouteItemStops ). Hope you
see the picture. :o)

I want to obtain a route with a specific ID. I have two ways of implementing
it:
1) one big sql join statement that links all those 3 tables. The problem will
be the huge ammount of data (like all the Route data will be repeated for n^2
times , the same data). The advantage: only one query.

2) join by route and routeitem and then get all the routeItemStops for each
route item. This means n+1 queries. Advantage : don't have all that ammount
of inutile data sent from sql server. Disadvantage: n+1 sql statements to be
executed, instead of only one.

Is there any 'better' solution. If not, what should I choose? (don't have the
experience and I don't know how psql sends a join query: optimised, not
optimised)...

For now join is just Where route.id = route_item.route_id.

If I am going to use the JOIN sql command, will that be faster and better?
Why ?

Tx
dovle

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Rasputin
Дата:
Сообщение: Re: md5 passwords in 7.2.3 ?
Следующее
От: "David Hooker"
Дата:
Сообщение: Updatable result sets