MOCKSTACKS
EN
Questions And Answers

More Tutorials









SQLServer EXPLAIN and DESCRIBE

EXPLAIN Select query


An Explain infront of a select query shows you how the query will be executed. This way you to see if the query uses an index or if you could optimize your query by adding an index.

Example query:

explain select * from user join data on user.test = data.fk_user;

Example result:

id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE user index test test 5 (null) 1 Using where; Using
index
1 SIMPLE data ref fk_user fk_user 5 user.test 1 (null)

on type you see if an index was used. In the column possible_keys you see if the execution plan can choose from different indexes of if none exists. key tells you the acutal used index. key_len shows you the size in bytes for one index item. The lower this value is the more index items fit into the same memory size an they can be faster processed. rows shows you the expected number of rows the query needs to scan, the lower the better.

Conclusion

In this page (written and validated by ) you learned about SQLServer EXPLAIN and DESCRIBE . What's Next? If you are interested in completing SQLServer tutorial, your next topic will be learning about: SQLServer EXISTS CLAUSE.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.