Some days ago I discovered the Stack Exchange Data Explorer (SEDE) which provides already lots of interesting queries out of the box (thanks to the contributors).
After a while I noticed that some of the queries are running very long. In fact, they ran so long that they were cancelled by the system, which showed the following message:
Something unexpected went wrong while running your query. Don't worry, blame is already being assigned.
One example is the Top Users by Country list. Well, I thought this isn't really a big issue, because I can (try to) enhance the query myself. So I opened the query composer, saw the SQL text field on the left and the database schema on the right. A quick search returned some additional descriptions of the tables the columns.
But what I missed was a description of indexes and foreign keys, because they have a big influence on how I build a query and they are quite essential for query optimization.
So my questions: can I find this information somewhere? Or even better: could this be added to the SEDE? I'd appreciate it as well, if I could evaluate an execution plan without running the query. Would that be possible?
p.s.: as per comment here is an execution plan from the SEDE for the simple statement below:
SELECT ROW_NUMBER() OVER(ORDER BY Reputation DESC) AS [#],
Id AS [User Link],
Reputation
FROM Users
WHERE id = 1
ORDER BY Reputation DESC;
This information is very helpful for query optimization - in particular for more complex and long running statements.
Explain Plan For <query>
command on the database - is not the same as executing the statement. Check for instance the Oracle documentation: docs.oracle.com/cd/B10500_01/server.920/a96533/ex_plan.htm. The query composer offers an option "Include execution plan" which works only in combination with execution. I'd prefer a feature for creating an execution plan without running the statement, because it's usually much faster and extremely helpful to database experts. I'll add a plan as example above ...ANALYZE table <table> compute statistics;
(oradev.com/create_statistics.jsp). This can usually be done in a batch. In the end the database takes its advantage of fresh statistics as well :)