开发者

how to know whether a sql query is optimal or not

开发者 https://www.devze.com 2023-01-13 04:35 出处:网络
i have four queries, all of which are valid and they do the same work. how to find out which one is the most optimal?

i have four queries, all of which are valid and they do the same work. how to find out which one is the most optimal? i'm using oracle 10g. is there a开发者_如何学Cny method like finding time complexity of a program?


One of the parameters to measure is the performance of the query. For oracle you can use Explain Plan. Check out the details below -

http://www.adp-gmbh.ch/ora/explainplan.html

http://download.oracle.com/docs/cd/B10500_01/server.920/a96533/ex_plan.htm


If you use MySQL, i think that most practical method to compare queries efficiency is BENCHMARK() query.


If you're using Microsoft SQL Server you could use SQL Management Studio to look at the queries' Execution Plans, or even run a SQL Profiler trace.


Generate the execution plan (e.g. using EXPLAIN PLAN) and compare the costs of the different statements.

0

精彩评论

暂无评论...
验证码 换一张
取 消