1 Pertemuan 01 Pengantar tentang database Matakuliah: >/ > Tahun: > Versi: >
Optimizing SQL Pertemuan 13 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
-
date post
21-Dec-2015 -
Category
Documents
-
view
221 -
download
3
Transcript of Optimizing SQL Pertemuan 13 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Optimizing SQLPertemuan 13
Matakuliah : T0413/Current Popular IT IITahun : 2007
Bina Nusantara
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu mendemonstrasikan proses optimasi di dalam SQL
Bina Nusantara
Outline Materi
• Using indexes• Types of indexes• Reprashing queries
Bina Nusantara
USING INDEX
One of important ways to improve systemPerformance
Bina Nusantara
SEVERAL WAYS TO CATEGORIZE INDEXES
• UNIQUE• NON UNIQUE
Bina Nusantara
CREATE INDEX• SINTAX :
CREATE [UNIQUE] INDEX index-Name ON table-Name ( Simple-column-Name [ ASC | DESC ] [ , Simple-column-Name [ ASC | DESC ]] * )
Bina Nusantara
TYPE OF INDEXS • B+ trees• Join indexes & clusters• Bitmap indexes• R-trees
Bina Nusantara
REPHRASING QUERIES• Optimizer in the DBMS is supposed to convert
queries to the most efficient formulation and execution
• Two general flavors of optimizer– Rule based– Cost based
Bina Nusantara
REPHRASING QUERIES• Here are some rules of thumb to make queries
run faster :1. Be careful about using value expressions or datatype
conversions on indexed values used in predicates2. The same applies to <> (does not equal)
Bina Nusantara
REPHRASING QUERIES (Cont.)3. ANY and EXISTS
4. Place the predicates that are likely to eliminate the most rows from the output first in where clause
Bina Nusantara
REPHRASING QUERIES (Cont.)5. LEFT and RIGHT OUTER joins are interconvertible.
LEFT joins may be faster6. In a join, place the table with fewer rows first in the
FROM clause.7. With an indexes column referenced in a predicate,
you may do a bit better by combining equalities and inequalities
(x>=8 lebih cepat daripada x>7)8. NULLs value
Bina Nusantara
REPHRASING QUERIES (Cont.)9. If we want more than 20 percent rows of table
better off without using an index10. If we refferencing a multi column index, you
need not reference the query every column11. Avoid using like12. Often a UNION of two queries will do better than
a single query (using OR)