Shirleen, both sentences are grammatically incorrect
You sould say: "When I took astronomy class last semester, I went to the professor to ask what the essential to this subject is and how to learn it effectively"
You have to use past tense “went”, since the action happened in the past. Also, the use of the word “essential“ in this context is ambiguous. It is not clear what you were actually asking: Was it about the requirements for the class? About the main topics covered? About the basic principles of Astronomy? You should select words which more specifically described your question to the professor