Is there any (preferably open source) software than can analyze a PostgreSQL EXPLAIN, and recommend the necessary indices that would speed up the query?
Is there any (preferably open source) software than can analyze a PostgreSQL EXPLAIN, and recommend the necessary indices that would speed up the query?
I literally just found this a couple of minutes ago: http://explain.depesz.com/. You paste in the results of your EXPLAIN ANALYZE and it shows you where there may be problems (it's even color coded).
From the help section...
I'm not aware of any tool for Postgres that does this algorithmically, and in my opinion the human brain (and often a bit of experimentation in a dev environment) is really the only appropriate tool here. There are a lot of factors involved, including whether or not the query planner will even think your index is worth using -- something which is determined by the way your installation has tuned the query planner settings and the size/statistics on the involved table(s).
The best recommendation I can make is to do an
EXPLAIN ANALYZE
(theANALYZE
is important -- it will give you query & subplan run times), look at the results yourself & attack the biggest number you see first. You could probably write a parser to break up the EXPLAIN output (especially in 9.0 with JSON output), but I don't know of anyone who has tackled this yet (this is basically what optimizers for MS-SQL do...)Nothing production grade, but for the curious, there is/was a research project to implement something like that. Search for "PostgreSQL index advisor".