473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Tuning The Sql Query

Hi,

This is Bhargav and I am trying to tune this query that is being used in a discoverer report and the columns in the select statement are the ones that are to be displayed in the discoverer output.

Can somebody help me as top how to tune this query. Any sort of help is greatly appreciated , as this is of high priority.

Regards,

Bhargav.

Expand|Select|Wrap|Line Numbers
  1. select
  2.   cost_orgs.organization_code || ' - ' || cost_orgs.organization_name cost_org,
  3.   on_hand_orgs.organization_code || ' - ' || on_hand_orgs.organization_name on_hand_org,
  4.   msi.segment1 item_name,
  5.   msi.description item_desc,
  6.   mcb.segment1 cost_cat_1,
  7.   mcb.segment2 cost_cat_2,
  8.   mcb.segment3 cost_cat_3,
  9.   mcb.segment1 || '.' || mcb.segment2 || '.' || mcb.segment3 cost_category,
  10.   upper(ctf1.cost_type) cost_type_1,
  11.   cicf1.item_cost item_cost_1,
  12.   cicf1.material_cost mtl_cost_1,
  13.   upper(ctf2.cost_type) cost_type_2,
  14.   cicf2.item_cost item_cost_2,
  15.   cicf2.material_cost mtl_cost_2,
  16.   sum(moh.transaction_quantity) on_hand_qty,
  17.   decode(msi.planning_make_buy_code,1,'M','B') make_buy_flag
  18. from
  19. --  mtl_parameters mp,
  20.   cst_item_costs cicf1,
  21.   cst_cost_types ctf1,
  22.   cst_item_costs cicf2,
  23.   cst_cost_types ctf2,
  24.   mtl_onhand_quantities moh,
  25.   inv.mtl_categories_b mcb,
  26.   inv.mtl_item_categories mic,
  27. --  inv.mtl_category_sets_tl mcst,
  28.   org_organization_definitions cost_orgs,
  29.   org_organization_definitions on_hand_orgs,
  30.   inv.mtl_system_items_b msi
  31. where 1=1
  32. and cost_orgs.organization_id = msi.organization_id
  33. and cicf1.organization_id = msi.organization_id
  34. and cicf1.inventory_item_id = msi.inventory_item_id
  35. and ctf1.cost_type_id = cicf1.cost_type_id --this should be set to frozen
  36. and cicf2.organization_id = msi.organization_id  --cross-product between sets will be resolved by Discoverer parameters
  37. and cicf2.inventory_item_id = msi.inventory_item_id
  38. and ctf2.cost_type_id = cicf2.cost_type_id
  39. and moh.organization_id = on_hand_orgs.ORGANIZATION_ID
  40. and moh.inventory_item_id = msi.inventory_item_id
  41. and mic.organization_id (+) = msi.organization_id
  42. and mic.inventory_item_id (+) = msi.inventory_item_id
  43. and mic.category_set_id (+) = 1100000006 --inventory cost category
  44. and mcb.category_id (+)= mic.category_id -- the inventory cost category consisists of mcb. segment1,2 and 3
  45. --and mcst.CATEGORY_SET_ID = mic.CATEGORY_SET_ID
  46. --and mcst.CATEGORY_SET_NAME = 'QC INVENTORY CATEGORY'
  47. --and msi.inventory_item_id = 512
  48. --and cicf1.COST_TYPE_ID = 1
  49. --and cicf2.COST_TYPE_ID = 1101
  50. --and msi.ORGANIZATION_ID = 89
  51. group by
  52.   cost_orgs.organization_code || ' - ' || cost_orgs.organization_name,
  53.   on_hand_orgs.organization_code || ' - ' || on_hand_orgs.organization_name,
  54.   msi.segment1,
  55.   msi.description,
  56.   mcb.segment1,
  57.   mcb.segment2,
  58.   mcb.segment3,
  59.   mcb.segment1 || '.' || mcb.segment2 || '.' || mcb.segment3,
  60.   upper(ctf1.cost_type),
  61.   cicf1.item_cost,
  62.   cicf1.material_cost,
  63.   upper(ctf2.cost_type),
  64.   cicf2.item_cost,
  65.   cicf2.material_cost,
  66.   decode(msi.planning_make_buy_code,1,'M','B')
  67.  --order by msi.SEGMENT1
/
Sep 20 '07 #1
3 4035
amitpatel66
2,367 Expert 2GB
Make use of HINTS in the query (HINT - INDEX,PARALLEL will be helpful)
Sep 21 '07 #2
Hi Amit,

I am not so familiar with using Hints in the sql query.

Can you pls give a small example and tell me which hint to use in this scenario, where so many joins are there.

Will appreciate your response in the earliest possible time.

Thanks,

Bhargav.
Sep 21 '07 #3
amitpatel66
2,367 Expert 2GB
Hi Amit,

I am not so familiar with using Hints in the sql query.

Can you pls give a small example and tell me which hint to use in this scenario, where so many joins are there.

Will appreciate your response in the earliest possible time.

Thanks,

Bhargav.
Hi Bhargav,

You can make us of HINTS in your sql query to improve the performance of the Query.

There are many HINTS availabe with oracle that can be used but to make use of
the appropriate one will improve the performance.

See below example on making use of INDEX HINT in SQL Query:

Expand|Select|Wrap|Line Numbers
  1. SELECT /* INDEX(<table_alias>,<index_name>) */ FROM table_name table_alias
  2.  
Find more about INDEX HINT here

Another HINT PARALLEL can be used for parallel execution of your Query.
See more about usage of PARALLEL HINT here
Sep 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Arni Snorri Eggertsson | last post by:
Hi I am trying to design an IO subsystem for my SQL Server and for that I need to try and predict IO activity on each table in my MSSQL Database. My idea is to move the hottest tables into...
9
by: majsen | last post by:
Hi, I have problem running this query. It will time out for me... My database are small just about 200 members. I have a site for swaping appartments (rental). my query should look for match in...
3
by: crystal1 | last post by:
Just curious if anyone has a script to find and delete all indexes created by index tuning wizard, leaving the original indexes untouched. All of the original indexes in this particular database...
4
by: bala | last post by:
hi!!! the following is the sql which is veri slow cos of the 'Not In' clause, would appreciate if u anyone can suggest any other way to bring about the same result SELECT Id, LOC, AGENCY,...
2
by: Ed L. | last post by:
The planner is choosing a sequential scan for my query. I am trying to understand why since it is clearly not the fastest choice, and what the proper tuning dial is to adjust here. Here's the...
0
by: meytal.weiss | last post by:
Hi, I am using the dta utility successfully. I have problem to tune query without specifying the schema as prefix in case the tuning session is not with the login that own the schema, the dta...
3
by: mleal | last post by:
Does anyone have some more detailed information about how Oracle and MS implement / allow Tuning on Oracle 10g and SQL Server 2005 and the differences between them? Which of them, In a deep...
0
by: Medhatithi | last post by:
Hi, I have been in several ways benefiited from this site. I would like to share some sql tuning techniques(simple, but effective) with you all. SQL Tuning Tips Oracle Tips Session #6 ...
1
by: Vinod Sadanandan | last post by:
A Roadmap To Query Tuning ============================ For each SQL statement, there are different approaches that could be used to retrieve the required data. Optimization is the process of...
3
by: dunleav1 | last post by:
In 9.1 and 9.5 (Linux 64 bit) when a buffer pool is set to self- tuning, how are blocks configured in respect to blocked vs non-blocked when self-tuning is set to on? (ie) I have one bufferpool...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.