I have a rapidly growing database with a very complex schema, and I'm looking
to improve performance. It's typical to have 2-4 foreign keys in each table,
and there are currently 113 tables, and queries with 5-10 tables with
combined inner/outer joins are pretty typical. (I avoid subqueries anywhere I
can)
So far, my guiding philosophy has been "constrain everything" with primary
keys, unique, foreign keys and the like, relying on the implicit indexes and
the query scheduler to handle things, and so far, it's worked very well.
The database has grown in total size (calculated by the size of a pg_dump) 25%
in the past month, and the growth rate seems to be accellerating. (yikes!) We
are buying new equipment now, but I'd still like to optimize as best as
possible.
A few questions:
1) Any problem with running "Analyze" hourly via cron?
2) Does "Vacuum analyze" also do the actions performed by "Analyze"?
3) What's the best way to handle indexes when only 1 index is used per table
in a query, but there are several due to the various constraints on it? Is
there a way to benefit from all of these other indexes somehow? Is there a
definitive, detailed book for optimizing PG queries?
-Ben
--
"The best way to predict the future is to invent it."
- XEROX PARC slogan, circa 1978