23.10.2012 Views

Structured Query Language (SQL) - Cultural View of Technology

Structured Query Language (SQL) - Cultural View of Technology

Structured Query Language (SQL) - Cultural View of Technology

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Query</strong> optimizer 84<br />

Cost estimation<br />

One <strong>of</strong> the hardest problems in query optimization is to accurately estimate the costs <strong>of</strong> alternative query plans.<br />

Optimizers cost query plans using a mathematical model <strong>of</strong> query execution costs that relies heavily on estimates <strong>of</strong><br />

the cardinality, or number <strong>of</strong> tuples, flowing through each edge in a query plan. Cardinality estimation in turn<br />

depends on estimates <strong>of</strong> the selection factor <strong>of</strong> predicates in the query. Traditionally, database systems estimate<br />

selectivities through fairly detailed statistics on the distribution <strong>of</strong> values in each column, such as histograms. This<br />

technique works well for estimation <strong>of</strong> selectivities <strong>of</strong> individual predicates. However many queries have<br />

conjunctions <strong>of</strong> predicates such as select count(*) from R where R.make='Honda' and R.model='Accord'. <strong>Query</strong><br />

predicates are <strong>of</strong>ten highly correlated (for example, model='Accord' implies make='Honda'), and it is very hard to<br />

estimate the selectivity <strong>of</strong> the conjunct in general. Poor cardinality estimates and uncaught correlation are one <strong>of</strong> the<br />

main reasons why query optimizers pick poor query plans. This is one reason why a DBA should regularly update<br />

the database statistics, especially after major data loads/unloads.<br />

References<br />

• Chaudhuri, Surajit (1998). "An Overview <strong>of</strong> <strong>Query</strong> Optimization in Relational Systems" [1] . Proceedings <strong>of</strong> the<br />

ACM Symposium on Principles <strong>of</strong> Database Systems [1] . pp. pages 34–43. doi:10.1145/275487.275492.<br />

• Ioannidis, Yannis (March 1996). "<strong>Query</strong> optimization" [2] . ACM Computing Surveys 28 (1): 121–123.<br />

doi:10.1145/234313.234367.<br />

• Selinger, P. G.; Astrahan, M. M.; Chamberlin, D. D.; Lorie, R. A.; Price, T. G. (1979). "Access Path Selection in<br />

a Relational Database Management System". Proceedings <strong>of</strong> the 1979 ACM SIGMOD International Conference<br />

on Management <strong>of</strong> Data. pp. 23–34. doi:10.1145/582095.582099<br />

See also<br />

• Join Selection Factor<br />

• <strong>Query</strong> optimization<br />

References<br />

[1] http://citeseer.ist.psu.edu/chaudhuri98overview.html<br />

[2] http://citeseer.ist.psu.edu/487912.html

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!