Re: Help speeding up this query - maybe need another index? - Mailing list pgsql-general

From Florian G. Pflug
Subject Re: Help speeding up this query - maybe need another index?
Date
Msg-id 448EAF2D.400@phlo.org
Whole thread Raw
In response to Help speeding up this query - maybe need another index?  ("Pat Maddox" <pergesu@gmail.com>)
List 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

pgsql-general by date:

Previous
From: "Florian G. Pflug"
Date:
Subject: Re: pg_dump: missing pg_database entry
Next
From: "John Sidney-Woollett"
Date:
Subject: Re: Searching BLOB