add functionality to determine sql query cost.
don't display graphs-link if the cost is too high

- Currently this uses a cost of 500 as "too high"
  We do not know if this is actually a sane value.
fix resource chain for logics.
Use DISTINCT to optimize expensive sql-queries.
Merge branch 'git' into correcting271_use_explain_for_complex_sql

Conflicts:
	app/controllers/application_controller.rb
	lib/graph_data_fetcher.rb
Merge pull request #302 from ontohub/correcting271_use_explain_for_complex_sql

Correcting271 use explain for complex sql