[#2034] sort and limit in subqueries before unions
[#2034] real subqueries required for limits inside unions
[#2034] distinct now required before offset+limit
Merge remote-tracking branch 'origin/master' into 2034-activity-query-performance-1
[#2034] apply distinct after union
[#2034] select_from now called select_entity_from in sqlalchemy 0.9
Merge branch '2034-activity-query-performance-1' of https://github.com/wardi/ckan into wardi-2034-activity-query-performance-1
Merge branch 'wardi-2034-activity-query-performance-1'