Re: Help speeding up this query - maybe need another index?

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Pat Maddox <pergesu(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Help speeding up this query - maybe need another index?
Date: 2006-06-13 12:27:25
Message-ID: 448EAF2D.400@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pat Maddox wrote:
> Here's my SQL query. I don't think it's too gigantic, but it is kind
> of beastly:
>
> SELECT COUNT(r) FROM trainer_hand_results r, trainer_scenarios s,
> trainer_scenario_stats stats WHERE r.user_id=1 AND
> r.trainer_scenario_id=s.id AND s.id=stats.trainer_scenario_id AND
> r.action=stats.correct_action;

The only indices that can help here are
trainer_hand_results: (user_id), (trainer_scenario_id)
trainer_scenarios: (id)
trainer_scenario_stats: (trainer_scenario_id), (correct_action)

Which of those help depends on the size of your tables.

greetings, Florian Pflug

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Sidney-Woollett 2006-06-13 12:28:18 Re: Searching BLOB
Previous Message Florian G. Pflug 2006-06-13 12:22:39 Re: pg_dump: missing pg_database entry