{"action":"opened","issue":{"url":"https://api.github.com/repos/uwescience/raco/issues/424","labels_url":"https://api.github.com/repos/uwescience/raco/issues/424/labels{/name}","comments_url":"https://api.github.com/repos/uwescience/raco/issues/424/comments","events_url":"https://api.github.com/repos/uwescience/raco/issues/424/events","html_url":"https://github.com/uwescience/raco/issues/424","id":75820537,"number":424,"title":"cross joins depending on table order in the from clause","user":{"login":"jortiz16","id":3239603,"avatar_url":"https://avatars.githubusercontent.com/u/3239603?v=3","gravatar_id":"","url":"https://api.github.com/users/jortiz16","html_url":"https://github.com/jortiz16","followers_url":"https://api.github.com/users/jortiz16/followers","following_url":"https://api.github.com/users/jortiz16/following{/other_user}","gists_url":"https://api.github.com/users/jortiz16/gists{/gist_id}","starred_url":"https://api.github.com/users/jortiz16/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jortiz16/subscriptions","organizations_url":"https://api.github.com/users/jortiz16/orgs","repos_url":"https://api.github.com/users/jortiz16/repos","events_url":"https://api.github.com/users/jortiz16/events{/privacy}","received_events_url":"https://api.github.com/users/jortiz16/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-13T02:53:55Z","updated_at":"2015-05-13T02:53:55Z","closed_at":null,"body":"Posting this per request from @bmyerz \r\n\r\nI'm parsing this query from myria production since the data is there. You can't run these myrial queries though since the relations are only placed on a specific number of workers. I'm just using this as an example because it can be parsed. Let me know if you need a query that actually runs though.\r\n\r\nI'm working with a star schema dataset and want to run a join across 3 relations (lineitem, supplier and customer). \r\n\r\nHere is an example with a \"bad order\":\r\n\r\n```\r\nR1 = scan(public:adhoc10GB:supplier);\r\nR2 = scan(public:adhoc10GB:customer);\r\nR3 = scan(public:adhoc10GB:lineitem);\r\n\r\nQ = [from R1, R2, R3\r\n\t where R1.s_suppkey = R3.l_suppkey \r\n     \t   and R2.c_custkey = R3.l_custkey\r\n     emit R3.l_linenumber];\r\n\r\nstore(Q, result);\r\n```\r\n\r\nThis example produces this plan, where the supplier is broadcast and cross joined with the customer relation. This is likely because in my query, I am not directly joining between supplier and customer. This can be bad in cases where the supplier and customer are large.\r\n\r\n![broadcastcrossjoin](https://cloud.githubusercontent.com/assets/3239603/7602910/a958bb06-f8df-11e4-9174-6d557bb9fccd.png)\r\n\r\n\r\nIf I rearrange the order of the join where lineitem is first, then I get a better plan without crossjoins:\r\n\r\n```\r\nR1 = scan(public:adhoc10GB:supplier);\r\nR2 = scan(public:adhoc10GB:customer);\r\nR3 = scan(public:adhoc10GB:lineitem);\r\n\r\nQ = [from R3, R2, R1\r\n\t where R1.s_suppkey = R3.l_suppkey \r\n     \t   and R2.c_custkey = R3.l_custkey\r\n     emit R3.l_linenumber];\r\n\r\n\r\nstore(Q, result);\r\n```\r\n\r\n![shufflecorrect](https://cloud.githubusercontent.com/assets/3239603/7602945/24b1c3ce-f8e0-11e4-842a-2cee1a88f6e3.png)\r\n\r\n\r\nLet me know if there are any other questions/comments. Thanks!\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}