Help with indexes

Поиск
Список
Период
Сортировка
От James Orr
Тема Help with indexes
Дата
Msg-id Pine.LNX.4.10.10205091422240.3264-100000@database.lrg.office
обсуждение исходный текст
Ответы Re: Help with indexes  (James Orr <james@lrgmail.com>)
Список pgsql-sql
Hi,

I need some help with this query, which is currently taking minutes to run
(it needs to be seconds!).

SELECTUPPER(teams.team_name),players.first_name,players.last_name,NULL,teams.id,brackets.court,teams.team_number
FROMteams JOINplayers ON (teams.id = players.team) JOINbrackets ON (teams.id = brackets.team)
WHEREplayers.player_number = 1 ANDteams.complete ANDbrackets.court = 580
ORDER BYbrackets.game_order,teams.team_name
;

When I run it with EXPLAIN I get ...


Sort  (cost=3.15..3.15 rows=1 width=60) ->  Nested Loop  (cost=0.00..3.14 rows=1 width=60)       ->  Nested Loop
(cost=0.00..2.12rows=1 width=48)             ->  Seq Scan on players  (cost=0.00..1.05 rows=1 width=28)             ->
SeqScan on teams  (cost=0.00..1.04 rows=2 width=20)       ->  Seq Scan on brackets  (cost=0.00..1.01 rows=1 width=12)
 

Now the indexes I have are:
On table players  - unique btree on id                 - unique btree on team, player_number
On table teams    - unique btree on id
On table brackets - btree on court                 - btree on team                 - unique btree on court, team

This is on version 7.1.3.  Would upgrading to 7.2 make it faster?

- James



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

Предыдущее
От: Tod McQuillin
Дата:
Сообщение: Re: escaping arrays in perl dbi
Следующее
От: James Orr
Дата:
Сообщение: Re: Help with indexes