日期:2014-05-16 浏览次数:20542 次
今天有个兄弟跟我说sql跑得太慢了,让我看看。sql如下:
SELECT rownum row_num, pv.vendor_name, pha.segment1 po_num, prh.preparer_id, pha.Org_Id, pha.po_header_id, wo.department_code, wo.description oper_seq_desc, to_char(pha.creation_date, 'RRRR-MM-DD HH24:MI:SS') enter_date, to_char(pha.approved_date, 'RRRR-MM-DD HH24:MI:SS') approved_date, --cux_public_pkg.get_item_no(wdj.primary_item_id) item_no, we.wip_entity_name FROM PO.po_headers_all pha, APPS.po_vendors pv, PO.po_lines_all pla, PO.po_line_locations_all pll, PO.po_distributions_all pld, PO.po_requisition_headers_all prh, PO.po_requisition_lines_all prl, PO.po_req_distributions_all prd, WIP.wip_discrete_jobs wdj, APPS.BOM_STANDARD_OPERATIONS_V bso, APPS.wip_operations_v wo, WIP.wip_entities we WHERE 1 = 1 AND prl.wip_entity_id = we.wip_entity_id AND pha.po_header_id = pla.po_header_id AND pha.vendor_id = pv.vendor_id AND pll.po_line_id = pla.po_line_id AND pll.po_header_id = pha.po_header_id AND pll.line_location_id = pld.line_location_id AND prd.requisition_line_id = prl.requisition_line_id AND pld.req_distribution_id = prd.distribution_id AND prl.requisition_header_id = prh.requisition_header_id AND prl.wip_entity_id = wdj.wip_entity_id AND prl.wip_entity_id = wo.wip_entity_id AND prl.wip_operation_seq_num = wo.operation_seq_num AND wo.standard_operation_id = bso.STANDARD_OPERATION_ID AND wdj.Organization_Id = /*p_organization_id*/83 AND pha.segment1 >= /*nvl(p_po_num_f, pha.segment1)*/'621337540' AND pha.segment1 <= /*nvl(p_po_num_t, pha.segment1)*/ '621337540' AND nvl(pha.approved_date, SYSDATE + 9999) >= nvl(pha.approved_date, SYSDATE + 9999) AND nvl(pha.approved_date, SYSDATE + 9999) <=nvl(pha.approved_date, SYSDATE + 9999) ORDER BY pha.segment1, pla.line_num;
快速的运用sql三段分拆方法(分享过的) 扫描一下,发现没问题 (如果不知道的哥们,请自己百度 落落 sql 三段分拆方法)
SQL里面有个视图wo 视图代码如下:
/*CREATE OR REPLACE VIEW WIP_OPERATIONS_V (row_id, wip_entity_id, operation_seq_num, organization_id, repetitive_schedule_id, last_update_date, last_updated_by, creation_date, created_by, last_update_login, request_id, program_application_id, program_id, program_update_date, operation_sequence_id, standard_operation_id, operation_code, department_id, department_code, location_id, description, scheduled_quantity, quantity_in_queue, quantity_running, quantity_waiting_to_move, quantity_rejected, quantity_scrapped, quantity_completed, first_unit_start_date, first_unit_completion_date, last_unit_start_date, last_unit_completion_date, previous_operation_seq_num, next_operation_seq_num, count_point_type, count_point_flag, autocharge_flag, backflush_flag, minimum_transfer_quantity, date_last_moved, attribute_category, attribute1, attribute2, attribute3, attribute4, attribute5, attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15, operation_yield, cumulative_scrap_quantity, operation_yield_enabled, operation_completed, shutdown_type, shutdown_type_disp, x_pos, y_pos, long_description, disable_date, recommended, progress_percentage, wsm_bonus_quantity, actual_start_date, actual_completion_date, employee_id, employee_name, lowest_accep