Guest User

Untitled

a guest
Feb 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. SELECT ord.id AS ord_id,
  2. oli.id AS oli_id,
  3. ord.dealer_code__c AS ord_dealer_code__c,
  4. ord.recordtypeid AS ord_recordtypeid,
  5. ord.order_number__c AS ord_order_number__c,
  6. ord.status AS ord_status,
  7. ord.opportunityid AS ord_opportunityid,
  8. ord.sfid AS ord_sfid,
  9. ord.pricebook2id AS ord_pricebook2id,
  10. cont.opportunity__c AS cont_opportunity__c,
  11. cont.sfid AS cont_sfid,
  12. opp.sfid AS opp_sfid,
  13. opp.recordtypeid AS opp_recordtypeid,
  14. opp.pricebook2id AS opp_pricebook2id,
  15. accban.sfid AS accban_sfid,
  16. accban.ban__c AS accban_ban__c,
  17. usr.sfid AS usr_sfid
  18. FROM fullsbxsalesforce.order ord
  19. LEFT JOIN fullsbxsalesforce.contract cont
  20. ON ord.contractid = cont.sfid
  21. LEFT JOIN fullsbxsalesforce.opportunity opp
  22. ON cont.opportunity__c = opp.sfid
  23. LEFT JOIN fullsbxsalesforce.user usr
  24. ON ( ord.dealer_code__c = usr.dealer_code_bd__c
  25. OR ord.dealer_code__c = usr.dealer_code_co_sell__c
  26. OR ord.dealer_code__c = usr.rep_dealer_code__c
  27. OR ord.dealer_code__c = usr.dealer_code_secondary__c )
  28. LEFT JOIN fullsbxsalesforce.account_ban_tax_id__c accban
  29. ON ord.ban_number__c = accban.ban__c
  30. LEFT JOIN fullsbxsalesforce.orderitem oli
  31. ON oli.sfid = (SELECT sfid
  32. FROM fullsbxsalesforce.orderitem oli
  33. WHERE ord.sfid = oli.orderid
  34. LIMIT 1)
  35. WHERE ord.recordtypeid = 'specificid'
  36. AND ( ord.status IN ( 'Submitted', 'Pending EIP eSignature',
  37. 'Partially Shipped',
  38. 'In-Fulfilment Queue',
  39. 'Locked', 'Pending Approval', 'Resubmitted',
  40. 'Pending Order',
  41. 'Pending Customer Completion', 'Backorder', 'Draft'
  42. ,
  43. 'Credit Card Declined',
  44. 'External System', 'Shipped/Pending Activation',
  45. 'Shipped/Partially Activated'
  46. , 'SAP Order Does not exist',
  47. 'Approved', 'Submit Failed for an Easy Order',
  48. 'Pending e-Signature',
  49. 'e-Signature Complete',
  50. 'Credit Card Decline (Hold)', 'Pre-Order',
  51. 'In Shipping Queue'
  52. )
  53. OR ( ord.status = 'Shipped'
  54. AND ord.hasmsisdn__c = false
  55. AND ord.last_status_change__c >= CURRENT_DATE -
  56. INTERVAL '7' day ) );
  57.  
  58. Nested Loop Left Join (cost=4283.25..5032.80 rows=2 width=256)
  59. Join Filter: (((ord.dealer_code__c)::text = (usr.dealer_code_bd__c)::text) OR ((ord.dealer_code__c)::text = (usr.dealer_code_co_sell__c)::text) OR ((ord.dealer_code__c)::text = (usr.rep_dealer_code__c)::text) OR ((ord.dealer_code__c)::text = (usr.dealer_code_secondary__c)::text))
  60. -> Nested Loop Left Join (cost=4283.25..4298.93 rows=1 width=237)
  61. -> Nested Loop Left Join (cost=0.34..12.01 rows=1 width=233)
  62. -> Nested Loop Left Join (cost=0.25..7.92 rows=1 width=215)
  63. -> Nested Loop Left Join (cost=0.17..6.99 rows=1 width=158)
  64. -> Index Scan using hc_idx_order_recordtypeid on "order" ord (cost=0.08..2.90 rows=1 width=139)
  65. Index Cond: ((recordtypeid)::text = 'specificid'::text)
  66. Filter: (((status)::text = ANY ('{Submitted,"Pending EIP eSignature","Partially Shipped","In-Fulfilment Queue",Locked,"Pending Approval",Resubmitted,"Pending Order","Pending Customer Completion",Backorder,Draft,"Credit Card Declined","External System","Shipped/Pending Activation","Shipped/Partially Activated","SAP Order Does not exist",Approved,"Submit Failed for an Easy Order","Pending e-Signature","e-Signature Complete","Credit Card Decline (Hold)",Pre-Order,"In Shipping Queue"}'::text[])) OR (((status)::text = 'Shipped'::text) AND (NOT hasmsisdn__c) AND (last_status_change__c >= (('now'::cstring)::date - '7 days'::interval day))))
  67. -> Index Scan using hcu_idx_contract_sfid on contract cont (cost=0.08..4.09 rows=1 width=38)
  68. Index Cond: ((ord.contractid)::text = (sfid)::text)
  69. -> Index Scan using hcu_idx_opportunity_sfid on opportunity opp (cost=0.08..0.93 rows=1 width=57)
  70. Index Cond: ((cont.opportunity__c)::text = (sfid)::text)
  71. -> Index Scan using hcu_idx_account_ban_tax_id__c_ban__c on account_ban_tax_id__c accban (cost=0.08..4.09 rows=1 width=28)
  72. Index Cond: ((ord.ban_number__c)::text = (ban__c)::text)
  73. -> Index Scan using hcu_idx_orderitem_sfid on orderitem oli (cost=4282.91..4286.92 rows=1 width=23)
  74. Index Cond: ((sfid)::text = ((SubPlan 1))::text)
  75. SubPlan 1
  76. -> Limit (cost=0.00..4282.83 rows=1 width=19)
  77. -> Seq Scan on orderitem oli_1 (cost=0.00..25696.96 rows=6 width=19)
  78. Filter: ((ord.sfid)::text = (orderid)::text)
  79. -> Seq Scan on "user" usr (cost=0.00..555.20 rows=35733 width=74)
  80. (22 rows)
Add Comment
Please, Sign In to add comment