Wednesday, December 22, 2010

Fake Id's In Niagara Falls

Comparison of Methods and Types of joins in Oracle

To build the execution plan the optimizer should perform the following basic actions:

  1. determine the order of evaluation of the tables.
  2. determine the method join.
  3. determine the types of access (access path, eg full scan, rowid, index range, etc).
  4. determine the order of filtering.

The first 3 are the tree structure that supports the implementation plan. The 4th defines the data flow "Flows" through the tree. This time I'll just concentrate on point 2, leaving the other for future notes.

The joins are always made between two sets of data, if the sentences had more than two tables are determined by the first two tables both join and the result is joinea the table below, this result is joinea with the following table and so on .
join
The most common methods are:

  • NESTED LOOP JOIN MERGE JOIN SORT JOIN HASH
  • Cartesian join

Description NESTED LOOP JOIN

The two sets of data processed for nested loop (NL) are called outer loop and inner loop. The outer loop is executed once and the inner loop once for each record returned by the outer loop. The main features of NL are:

  • are the best choice when you need to get the front row as soon as possible, so you do not need to process all the data to start returning results. This is very performing, for example, front-end applications that use pagination. Leverages
  • filters and joins conditions using available indexes.
  • can be used with any type of joins.

Description HASH JOIN

The two sets of data processed for hash join (HJ) are build input and probe input. With the build input is built in memory (or temporary tablespace if there is insufficient physical memory available) a hash table. Once built the build input is used to start processing each record in the input probe the hash table so as to compare whether or not it meets the join condition. The main characteristics of HJ are

  • The hash table is usually built using the smaller dataset.
  • Not all types of joins can be used, such as theta joins and cross joins are not supported.
  • That is starting to return rows from the hash table must be created and processed.
  • HJ
  • can not implement joins using indexes conditions.

MERGE JOIN SORT Description

The two sets of data processed by the merge join (MJ) are read and sorted according to the columns referenced in the join condition. Once the two set are sorted are mixed (merge). The ordering is done in memory as long as physical memory is sufficient, but reaches the memory (pga) temporary space should be used as a support which, as expected, slow down operations. The main characteristics of MJ are

  • Both data set must be ordered before merge
  • The first row of the result set is returned recently when the merge starts.
  • All types of joins are supported.

Types of Joins

There are two possible syntaxes for use with joins: SQL-


ANSI-86 SQL-ANSI-92

The first is the general use, and is the most common, the second is newer and is standard for other database engines, is more common for new generations of developers and DBAs, or for those who come to use sql server. It is also clearer because it separates the filters of joins, which is easier to read and interpret. Now I will give a brief overview of the types of joins with examples in the two notations:


Join

Cross also called Cartesian product. It is generally used when the joins are not specified for some tables. I've also seen some private plans where is the best option, although very rare
 
select emp.ename, dept.dname
from emp, dept

select emp.ename, dept.dname
from emp CROSS JOIN dept


Theta Join

also called inner join, and returns only the rows that satisfy a join condition
 
select emp.enam, salgrade.grade
from emp, salgrade WHERE
emp.sal entre salgrade.hisal

salgrade.local and select emp.ename, salgrade.grade
from emp INNER JOIN on emp.sal entre salgrade salgrade.losal and salgrade.hisal



Equi Join

also called natural join is a special case of theta join where
operators are used only for equality join conditions
 
select emp.ename, dept.dname
from emp, dept WHERE
emp.deptno =
dept.deptno
select emp.ename, dept.dname
from emp NATURAL JOIN dept on emp.deptno = dept.deptno


Self
Join
are a special case of theta join where the joined table is the same.
 
select emp.ename, mgr.ename
from emp, emp WHERE mgr
emp.mgr = mgr.empno


select emp.ename, mgr.ename
JOIN emp mgr from emp on emp.mgr = mgr.
empno


Outer Join

The outer join extends the result set of theta joins. With this kind of join the ranks of all the tables involved are returned if no match with the columns join the other table, returning NULL in the columns of the records that matches a table. Oracle uses its own syntax, but it is advisable to use the ANSI-92 syntax as it is portable to other database engines.

For example, to see the number of employees by department, considering also the departments that have no employees:
 
dept.dname select count (emp.ename)
from emp, dept WHERE
emp.deptno dept.deptno = (+)
group by dept.dname

dept.dname select count (emp.ename)
dept from emp LEFT OUTER JOIN on (dept.deptno = emp.deptno) group by dept.dname


With the new syntax also you can use RIGHT OUTER JOIN and FULL OUTER JOIN.

From Oracle 10g you can use a new type of join (or subtype) called partitioned outer join. This type of join a priori would seem to be related to partitioned tables but not in this case, the concept of partitioning is that the data are divided into subset during the execution
 
dept.dname select count (emp.empno)
dept from emp LEFT JOIN PARTITION BY (emp.job) ON emp.deptno = dept.deptno
group by dept.dname


Semi Join

This type of join between two tables returns only rows of a column in the tables which exist in the other join table.

For example, to see that employees are bonus:
 
scott.emp select * from emp

WHERE exists (select null from bon
scott.bonus WHERE emp.EMPNO = bon.ename)

select * from scott
.
emp emp WHERE empno in (select empno from scott.bonus bon)



Join Anti

This type of join between two tables returns only rows of tables whose columns are NOT join in the other table

For example, to consult employees who do not have bonus:
 
scott.emp select * from emp

where not exists (select null from bon
scott.bonus WHERE emp.EMPNO = bon.ename)

select *

scott.emp from emp WHERE empno NOT IN (select empno from scott.bonus bon)


Once reviewed the types of methods joins joins we return and see some examples as plans are put together according to each method:

As always I will create the environment in order to try and if anyone wants to test it in their own environment can:
 
- I table t1 create table T1

as select rownum
c1,
trunc (dbms_random.value (1100)) c2,
dbms_random.string ('a', 100)
c3 from dual connect by rownum
<= 1000000 -- Creo tabla T2 create table t2 as select rownum c1, trunc(dbms_random.value(1,100000)) c2, dbms_random.string('a',100) c3 from dual connect by rownum <= 2000000 -- Creo un indice para la tabla T2 create index t2_idx on t2(c2) -- Recolecto estadisticas para los segmentos creados: begin dbms_stats.gather_table_stats(ownname => user, tabname => 'T1', cascade => true);
dbms_stats.gather_table_stats (ownname => user, tabname => 'T2', cascade => true);
end;


Now I will show each join method, obviously I'm going to tamper with hints to make it simple:

be forced to use NESTED LOOP JOIN:
 
select / * + Leading (t1) use_nl (t2) index (t2) * / count (1)
from t1, t2 WHERE t1
. c2 = t2.c2
and t1.c3> 'zzz'

Plan hash value: 3705558160

-------------------------- -------------------------------------------------- -
1 para que se use MERGE JOIN:



select /*+ ordered use_merge(t2) */ count(1)
from t1, t2
where t1.c2 = t2.c2 and t1.c3 > 'zzz'
Plan hash value: 1164406001

------------------------------------------------------------------------------------------
Information (identified by operation id):
---------------------------------------------------

4 - filter("T1"."C3">'zzz')
5 - access("T1"."C2"="T2"."C2")
filter("T1"."C2"="T2"."C2")


 Forzamos para que se use HASH JOIN: 



select /*+ leading(t1) use_hash(t2) */ t1.*
from t1, t2
where t1.c2 = t2.c2
and t1.c3 > 'zzz'


Plan hash value: 442409572

---------------------------------------------------------------------------------
(%CPU)
Predicate Information (IDENTIFIED BY operation id): ---------------------------------------


------------ 2 - access ("T1". "C2" = "T2". "C2")
3 - filter ("T1". "C3"> 'zzz' )

Comparing the 3 plans for each method is used only with NL index range rather than using a full scan of the index. NL times are best estimates the value of plan. Running each of the 3 queries can be seen that this estimate is in line with reality and that NL is the fastest. This is because both HJ and MJ can not use the index to find matches over the table T2 based on the values \u200b\u200breturned by the table T1. With NL is used to access that information more promptly, via the index. The lower the selectivity (or stronger) the NL method will have greater advantage over the other two.




Wednesday, December 15, 2010

Bejeweler Pro Example

When a query uses an index, but not the best possible rate


Many times I asked that a query does not respond in a timely manner when the execution plan shows that you are using an index. The answer in some cases is very simple and because the index is not as selective as possible, no filters that could filter everything. To say that a query uses an access plan for an index is not sufficient to ensure that you have found the most efficient way. To show a bit of that I'm talking about putting together a case, but somewhat trivial therefore less instructive, so that they understand the idea.
I will create a T-chart with 3 columns. COL1 column will have 1000 distinct values \u200b\u200band column COL2 will have 10 possible values. Also add filler column COL3


 

create table t as



select mod (rownum, 1000) col1,


mod (rownum, 100000) col2,
dbms_random.string ('a', 50)
col3 from dual connect by rownum





Once you create the table I create an index for COL1 and harvest statistics for table and index:

t_idx create index on t (col1) begin


dbms_stats.gather_table_stats (ownname => user, tabname => 'T', cascade => true);
end;



I run the following query and extract the plan using DBMS_XPLAN.DISPLAY_CURSOR so that the plan be more detailed (in a future I will use the same method to show how to see how "confused" the optimizer when there are no adequate statistics):
select / * + * gather_plan_statistics / * from t where col1 = 9

and

col2 = 9 select * from table (dbms_xplan.display_cursor (null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT

----------------------------------------------------------------------------------------------------
 SQL_ID  25p2md7bszhj6, child number 0 
------------------------------------- select /*+ gather_plan_statistics */ * from t where col1 = 9 and col2
= 9

Plan hash value: 1020776977
-----------------------------------------------------------------------------------------------
filtering 10, as shown in step 1 (A-Rows)

(Note: A-Rows is the number of actual rows and E-Rows is the number of rows estimated)
<= 1000000
Now I will delete the index and T_IDX I will create another with the same name but indexed by COL1 and COL2. Let the new plan:


drop index create index t_idx
t_idx on t (col1, col2)
 
select / * + gather_plan_statistics 2 * / * from t where col1 = 9

and col2 = 9 select

* from table (dbms_xplan.display_cursor (null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
--------------------------- -------------------------------------------------- -----------------------
SQL_ID 25p2md7bszhj6, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from t where col1 = 9 and col2
= 9
 Plan hash value: 1020776977 

-----------------------------------------------------------------------------------------------
10 fewer resources and therefore less processing time to obtain the same output.

The moral is that you should never settle for just verify that the decision reached by an index and in-depth analysis on the current checking indexing is the best index possible or if you can find some other combination more efficient.




Thursday, December 9, 2010

Chines Banges Long Hair

ADVERTISING HAPPY YEAR 2011 , IS THAT COMMUNICATION

Monday, December 6, 2010

Dungarees That Meryl Streep Wore In Mamma Mia

Recently Read Books


3 .-
  • Title :.................... .. Positioning: The concept that has revolutionized communication advertising and marketing.
  • Editorial :................. McGRAW-HILL BOOKS DE MEXICO, SA de CV.
  • Place :..................... Mexico.
  • Year :........................ June 1985.
  • :...... No. of Pages 263.
  • :.................. Authors Al Ries and Jack Trout.
Guatemala December 6, 2010 ______________________________________




2 .-
Title :......................
  • Marketing, Internet and Enterprise. Editorial
  • :................. sponsored by the Community of Madrid.
  • Place :..................... Madrid.
  • Year :........................ May 7, 2007.
  • :...... No. of Pages 148. Authors
  • :.................. Mobile Marketing Association, National Association of Internet, ISNA, Dune netwoks, Galinus, INFONA E-consultants, Interaktir Oline Media Netfilia Interactive, Comunidad de Madrid, Madrid Digital Community. _____________________________________




1 .-

  • Title :......................... Relations Public. Editorial
  • :.................... Prise Among Moderne D'Edition. Place
  • :........................ Paris.
  • :........................... Year 1969.
  • :......... No. of Pages 339


Friday, December 3, 2010

Should Men Wear One Peice Swimsuits



This idea was requested from Argentina, is ta is an innovative new company formed by four students, who study the cart's degree in marketing, I hope to see you helped. These are just sketches, not the final art



How Long Does It Take For Temezan To W

LOGO FOR CONSULTANT MAKING A GOOD NAME FOR MY COMPANY. CHRISTMAS TO SHARE

Good day / evenings for all, as you know a person without name is nothing, therefore it can name a company is very important.

Today and seen many acronyms (the first letter of one, two or more names) as name, I think from the beginning I started to analyze the issue of names, did not seem very reasonable / logical for a name, because what is being sought identified by someone else, but I recognize that there are good names that are very attractive since one thinks for first time.

This comment is because many, many names and seen are the same but with different meanings, for example, a group of football players, puts Name your team and CC just because the two founders of the team are called Carlos, the name sounds great but what would happen to a courier company is also called CC, C Charles and the other C by mail. Other examples: EPA (Pleasures and Art Space), EPA (Labour Force Survey) PPS (Purchasing Power Standard).

TEDAS account that you have to think / invest time / discussing among other things, is not just grab one or two letters of your name / service, many large companies have taken a couple of years to perfect his name.

I'll set an example, to start this blog, although I as two to three months looking for create and imagine the name, despite having the basic knowledge, I made the mistake of putting this name:

As you can tell, the great mistakes is as clear as water, "name" was so long, not is that I was thinking, maybe explain the content of the blog, that if bleating but is very long and I think that would go on mission / vision / description, etc.. here are many problems to mention this name, but leave as unique and important problem, a person not easily remember the name, being very extensive.

Following this setback, and then reasonably arrive the name of IMG ADVERTISING , and logo: IMG PUBLICIDAD
To me, this was the end, but as that been feeding me , Web and other books, I follow the road to explore new theories to improve the blog name, but said the name IMG ADVERTISING , what will the problem this?, from the search point in google, there are many similar names, this is a big problem, pretend you are in a large conference room of an advertising agency and call IMG ADVERTISING
and in that chair, raise your hand now 7 representatives of agencies called IMG ADVERTISING , you have ever happened in your school? "That big problem" for the person who wants to talk to the agency called IMG ADVERTISING. WHAT OF ALL IS IT?
This is an example of the main problem and seen.


And to create a name of a product / service or product / service, Let us be careful in creating a name, you can fall into the error of the line extension and this would cause the name uniquely positioned the company lost.

and analysis in this process if you can realize we have simplified, and this process simplification is very important that we bear in mind as the shorter but stays in the mind of the user / consumer.

The contents of this publication , also will can serve to create a good slogan.

This publication it is part of the experience and lived in the building of this blog, and as I said I eat other means against a good name for my blog.

have doubts to make a name for your business, check or leave a comment.


Gameshark Elixir Ruby