{"action":"created","issue":{"url":"https://api.github.com/repos/pg-strom/devel/issues/203","labels_url":"https://api.github.com/repos/pg-strom/devel/issues/203/labels{/name}","comments_url":"https://api.github.com/repos/pg-strom/devel/issues/203/comments","events_url":"https://api.github.com/repos/pg-strom/devel/issues/203/events","html_url":"https://github.com/pg-strom/devel/issues/203","id":108646553,"number":203,"title":"(JP)GpuJoinではBulkLoadをoffにしても片方のテーブルはBulkScanになってしまう","user":{"login":"onlyindreams","id":7244786,"avatar_url":"https://avatars.githubusercontent.com/u/7244786?v=3","gravatar_id":"","url":"https://api.github.com/users/onlyindreams","html_url":"https://github.com/onlyindreams","followers_url":"https://api.github.com/users/onlyindreams/followers","following_url":"https://api.github.com/users/onlyindreams/following{/other_user}","gists_url":"https://api.github.com/users/onlyindreams/gists{/gist_id}","starred_url":"https://api.github.com/users/onlyindreams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onlyindreams/subscriptions","organizations_url":"https://api.github.com/users/onlyindreams/orgs","repos_url":"https://api.github.com/users/onlyindreams/repos","events_url":"https://api.github.com/users/onlyindreams/events{/privacy}","received_events_url":"https://api.github.com/users/onlyindreams/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pg-strom/devel/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-28T12:19:39Z","updated_at":"2015-09-28T12:36:02Z","closed_at":null,"body":"これは故意でしょうか？\r\n意図があるのであれば、NOTICEメッセージなどを出しておいたほうがいいのかなぁと思いました。\r\n\r\nクエリ\r\n```\r\ndrop table if exists x;\r\ncreate table x(key integer,data numeric);\r\ninsert into x select 1, generate_series(1,100);\r\ninsert into x select 2, generate_series(-50,50);\r\nanalyze x;\r\nset pg_strom.gpu_setup_cost = 0;\r\nset pg_strom.bulkload_enabled = off;\r\nexplain select * from x x1 inner join x x2 on x1.key=1 and x2.key=2 and x1.data < x2.data;\r\n```\r\n\r\n実行結果\r\n```\r\nnanzai=# explain select * from x x1 inner join x x2 on x1.key=1 and x2.key=2 and x1.data < x2.data;\r\n                                 QUERY PLAN                                 \r\n----------------------------------------------------------------------------\r\n Custom Scan (GpuJoin)  (cost=6.84..40.51 rows=3367 width=16)\r\n   Bulkload: Off\r\n   OuterQual: (key = 2) (50.25%)\r\n   Depth 1: GpuNestLoop, JoinQual: (data < data)\r\n            Nrows (in/out: 3333.66%), KDS-Heap (size: 11.33KB, nbatches: 1)\r\n   ->  Custom Scan (BulkScan) on x x2  (cost=2.02..3.03 rows=201 width=8)\r\n   ->  Custom Scan (GpuScan) on x x1  (cost=2.02..3.02 rows=100 width=8)\r\n         Device Filter: (key = 1)\r\n(8 rows)\r\n```\r\n\r\n以下の修正をしたらBulkLoadがされないようになりましたが...\r\n\r\n```\r\ndiff --git a/src/gpujoin.c b/src/gpujoin.c\r\nindex 38abc9d..3d9762c 100644\r\n--- a/src/gpujoin.c\r\n+++ b/src/gpujoin.c\r\n@@ -1696,7 +1696,7 @@ create_gpujoin_plan(PlannerInfo *root,\r\n        }\r\n \r\n        /* check bulkload availability */\r\n-       if (IsA(outer_plan, CustomScan))\r\n+       if (pgstrom_bulkload_enabled && IsA(outer_plan, CustomScan))\r\n        {\r\n                int             custom_flags = ((CustomScan *) outer_plan)->flags;\r\n                double  outer_density = pgstrom_get_bulkload_density(outer_plan);\r\ndiff --git a/src/gpuscan.c b/src/gpuscan.c\r\nindex a7eab49..f0f3614 100644\r\n--- a/src/gpuscan.c\r\n+++ b/src/gpuscan.c\r\n@@ -412,6 +412,9 @@ gpuscan_pullup_devquals(Plan *plannode,\r\n        RangeTblEntry  *rte = rt_fetch(cscan_old->scan.scanrelid, range_tables);\r\n        List               *outer_quals;\r\n \r\n+       if (!pgstrom_bulkload_enabled)\r\n+         return NULL;\r\n+\r\n        Assert(pgstrom_plan_is_gpuscan(plannode));\r\n        gs_info = deform_gpuscan_info(&cscan_old->scan.plan);\r\n```\r\n\r\n実行結果\r\n```\r\nnanzai=# explain select * from x x1 inner join x x2 on x1.key=1 and x2.key=2 and x1.data < x2.data;\r\n                                 QUERY PLAN                                 \r\n----------------------------------------------------------------------------\r\n Custom Scan (GpuJoin)  (cost=6.84..40.51 rows=3367 width=16)\r\n   Bulkload: Off\r\n   Depth 1: GpuNestLoop, JoinQual: (data < data)\r\n            Nrows (in/out: 3333.66%), KDS-Heap (size: 11.33KB, nbatches: 1)\r\n   ->  Custom Scan (GpuScan) on x x2  (cost=2.02..3.03 rows=101 width=8)\r\n         Device Filter: (key = 2)\r\n   ->  Custom Scan (GpuScan) on x x1  (cost=2.02..3.02 rows=100 width=8)\r\n         Device Filter: (key = 1)\r\n(8 rows)\r\n```"},"comment":{"url":"https://api.github.com/repos/pg-strom/devel/issues/comments/143730683","html_url":"https://github.com/pg-strom/devel/issues/203#issuecomment-143730683","issue_url":"https://api.github.com/repos/pg-strom/devel/issues/203","id":143730683,"user":{"login":"kaigai","id":216210,"avatar_url":"https://avatars.githubusercontent.com/u/216210?v=3","gravatar_id":"","url":"https://api.github.com/users/kaigai","html_url":"https://github.com/kaigai","followers_url":"https://api.github.com/users/kaigai/followers","following_url":"https://api.github.com/users/kaigai/following{/other_user}","gists_url":"https://api.github.com/users/kaigai/gists{/gist_id}","starred_url":"https://api.github.com/users/kaigai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaigai/subscriptions","organizations_url":"https://api.github.com/users/kaigai/orgs","repos_url":"https://api.github.com/users/kaigai/repos","events_url":"https://api.github.com/users/kaigai/events{/privacy}","received_events_url":"https://api.github.com/users/kaigai/received_events","type":"User","site_admin":false},"created_at":"2015-09-28T12:36:02Z","updated_at":"2015-09-28T12:36:02Z","body":"ま、若干の設計意図としては、PLAN時とEXEC時にモードが変わってしまい・・・というのはあるんだけども、\r\nそれ以外の enable_xxxx 系のパラメータと挙動を合わせるなら、PLAN時に設定してたパラメータが正義で、\r\nEXEC前に値を変えたりしても \"知らん！\" が正解なんでしょうね。\r\n\r\nなお、gpuscan.c のコードを見てもらえば分かりますが、GpuScanとBulkLoadの実体は全く同じです。"}}