|
|
|
|
|
by ckuehne
3724 days ago
|
|
"What’s going on here? Why is Postgres wasting its time, continuing to search even though it’s already found the data we’re looking for?" Because Postgres has not already found what we are looking for. The query is select *
from users
where name = 'Capitain Nemo'
order by id asc
limit 1;
Only after Postgres has found all users with the name 'Capitain Nemo' it can sort them by their 'id' attribute and limit the result set to the first one in the sorted relation.Otherwise very nice post though. |
|
[0] https://news.ycombinator.com/item?id=8449329 [1] http://api.rubyonrails.org/classes/ActiveRecord/FinderMethod...