{"action":"opened","issue":{"url":"https://api.github.com/repos/raw-db/ldb/issues/1","labels_url":"https://api.github.com/repos/raw-db/ldb/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/raw-db/ldb/issues/1/comments","events_url":"https://api.github.com/repos/raw-db/ldb/issues/1/events","html_url":"https://github.com/raw-db/ldb/issues/1","id":90133601,"number":1,"title":"predicate not pushed down","user":{"login":"bgaidioz","id":10529136,"avatar_url":"https://avatars.githubusercontent.com/u/10529136?v=3","gravatar_id":"","url":"https://api.github.com/users/bgaidioz","html_url":"https://github.com/bgaidioz","followers_url":"https://api.github.com/users/bgaidioz/followers","following_url":"https://api.github.com/users/bgaidioz/following{/other_user}","gists_url":"https://api.github.com/users/bgaidioz/gists{/gist_id}","starred_url":"https://api.github.com/users/bgaidioz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgaidioz/subscriptions","organizations_url":"https://api.github.com/users/bgaidioz/orgs","repos_url":"https://api.github.com/users/bgaidioz/repos","events_url":"https://api.github.com/users/bgaidioz/events{/privacy}","received_events_url":"https://api.github.com/users/bgaidioz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-22T15:33:27Z","updated_at":"2015-06-22T15:33:27Z","closed_at":null,"body":"This query (group authors by title only for authors born in 1978):\r\n\r\nselect title, count(partition) as c from authors a where a.year=1978 group by title:a.title\r\n\r\ncorrectly comes with a plan where the filtering on year happens at the bottom, near the \"get\".\r\n\r\nWhen running this query (see full code below): select T.title, T.c from <first query> T having T.c > 2, the filtering on year occurs at the level of the nest, with a totally suboptimal plan (the nest groups by <title, author> (instead of title) and filtering occurs above, while it could have pushed the filtering on year below near the get.\r\n\r\nreduce(bag,\r\n       nest(sum,\r\n            get(bag,authors,_X230,and()),\r\n            _X252,\r\n            1,\r\n            pair(project(_X230,title,string),_X230),\r\n            and(),\r\n            and(eq(project(_X230,year,long),1978),gt(_X252,2))), <--------\r\n       _X229,\r\n       struct(bind(title,project(_X230,title,string)),bind(c,_X252)),\r\n       and())\r\n\r\nHere is cut/paste friendly query:\r\n\r\nselect T.title, T.c from (select title, count(partition) as c from authors a where a.year=1978 group by title\r\n:a.title) T having T.c > 2"}}