Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
464 views
in Q2A Core by

I have realized that if I let this be true, then page/questions.php allows sorting the questions per category as hot, more votes... As I understand, this happens here:

https://github.com/q2a/question2answer/blob/master/qa-include/pages/questions.php#L35

1) What does exactly this line mean?

2) Why is this set (by default) to false? Is there any impact in terms of performance?

3) Does the impact in performance only happen in the specific category pages or somewhere else?

Q2A version: 1.7

1 Answer

+1 vote
by
selected by
 
Best answer

1) It doesn't have so much meaning itself. It just determines whether the user requested to sort in a particular way and, if you allow the user to sort in that particular way, then the variable takes the sorting value. Otherwise, it becomes null. Then, based on that value, the sorting is assigned when generating the query. This actually happens here.

2) Yes. There is an index on the created field but there is no index in any of the other fields (flagcount, netvotes, views, hotness). So when the database tries to sort the values it has to sort the actual values rather than the values in the index so it takes more time. Note the ORDER BY there is just the only difference between the indexed and unindexed queries

3) Somewhere else too. But only when you are in a questions/XYZ URL and when you request the HOT page or the HOT feeds, because it has to sort a calculated field so it can never be indexed.

...