5 ms·
I got 4/5 on PostgreSQL. I selected "Not enough information" on question 5, which is supposed to be the wrong answer. But I think it's the correct answer. Depe
by felixge 9y ago
I got 4/5 on PostgreSQL. I selected "Not enough information" on question 5, which is supposed to be the wrong answer. But I think it's the correct answer.
Depending on the distribution of the data in the table (e.g. all rows have a = 38, but no rows have b = 1), PostgreSQL will chose a Sequential-Scan instead of an Index-Only scan for both queries. This of course leads to the 2nd query being faster due to not having to aggregate anything.
https://gist.github.com/felixge/af97c844cb1f24ac278e0357741c4ea9 https://gist.github.com/felixge/af97c844cb1f24ac278e0357741c...
- kasparsklavins 9y agoI don't agree. The same could be said for the other questions as well. In quizzes like these its usually assumed the worst possible scenario/dataset.
- felixge 9y agoGood point. But the other questions didn't have a "Not enough information" choice. So I think the question should be improved to avoid false negatives in the results.
- pilif 9y agoWhen I did the quiz (5/5), I assumed based on the query and the information given that the index was being helpful in the first example, so I assumed it was index scanning. In that case it does have to recheck the additional condition which would definitely be slower. However, following your assumption, I would say, both would be about the same speed because it still has to sequence scan the whole table (because more b=1 rows could exist) Anyways. Seeing that the result could be either of the two answers, I agree that the question is under-specified