Re: 3-Way Join Running Sloowww with the Query/Schema
Posted in 1996
From your description of your database's structure, I see two likely problems.
First nearly all of your indexes have strings in them, this slows down queries
because the server must match the search string character by character with the
rows in your table. One of your indexes has three char(25) strings. Do not use
long char columns in your indexes, those indexes will bog down your queries.
Second, joining three tables by string indexes will always seem slow. The
more tables you join, the slower your queries.
I would recomend you unload your tables, and then run dbschema. Modify the
schema sql file to eliminate those char fields from your indexes. Add a serial
column to each of your tables and use that in your indexes. Then reload your
tables.
If you insist on indexing on strings your queries will run slow. You may
optimize them a tad by running UPDATE STATISTICS HIGH.