sql - Query that can benefit from index, cluster or hash-cluster -


i'm trying find equi-join query shows decent performance bump when use index, cluster or hash-cluster structure on data. need run query on unstructured data first , execution time should significant can see performance boost of 3 structures. issues having if use query utilizes index column search narrow , few rows returned , baseline query's execution time fast can't measure time later.

it seems queries have major effect on baseline queries execution time cause full table scan of table rows, makes using index structure useless won't use index. clusters or hash-clusters benefit full table scans - in general don't know queries benefit clusters/hash-clusters.

my table has 500,000+ rows , of queries have tried:

select c.cust_name, s.total_price   sales s, customer c  s.cust_id = c.cust_id  order c.cust_name;   select count(*)   sales s, customer c   s.cust_id < 500    , s.cust_id = c.cust_id;   select c.cust_name, s.total_price  sales s, customer c s.cust_id = c.cust_id   , c.cust_name '%a'; 

meaningful database performance testing requires multiple runs, alternating between different methods, removing outliers, , averaging remaining values. necessary avoid differences caused caching , server load fluctuations.

something work in sql*plus. automated more in pl/sql take more code.

set timing on;  --run #1: declare     v_count number; begin     in 1 .. 100 loop         select count(*) v_count         sales s, customer c         s.cust_id < 500 , s.cust_id = c.cust_id;     end loop; end; /  --run #2: alter table ... (changesomething here)  declare     v_count number; begin     in 1 .. 100 loop         select count(*) v_count         sales s, customer c         s.cust_id < 500 , s.cust_id = c.cust_id;     end loop; end; /  --run #1: ... 

if need use single run of query demonstrate these differences, you'll need make data larger , make queries more selective. index range scans helpful when select small percentage of data table. magic number depends on lot of factors, how fast single-block versus multi-block i/o on hardware, how ordered index (the index clustering factor), etc.

my experience hash clusters has been disappointing. think feature around historical purposes; never see them discussed in oracle performance tuning resources. nobody has time figure out exactly how data fit blocks.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -