Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Which is faster within the SQL forums, part of the Databases category; Which is faster and why among below; select count(*) from T1 select count(1) from T1 select count(PK) from T1 Question asked by visitor sant...
|
|||||||
|
|||
|
Re: Which is faster
All the three will give you same performance. But there will be difference if you are using oracle version 8 or before.
In that case 2nd wil be faster than 1st. and 3rd will be the fastest. Find the details here. |
|
|||
|
Re: Which is faster
it actually depends upon whether your table is having any primary key ? if there is any primary key ,then an associated index would be there . if there is an primary key in a table oracle only counts nodes in the index
my answer is if the first column is primary key then all the three queries performance would be the same. if the first column is not a primary key then query 1 and query 3 will result in same performance (using index). But query 2 will lag. |
|
|||
|
Re: Which is faster
I dont think so I would like to explain with example
suppose that I have written following qyuery for the emp table select count(*) from emp; this will always take more time.....just because it will have to retrive all the fields of the emp table......... But Instead you have written the query as select count(1) from emp; it will only retirve the data about the first column so it woould surely be faste compared to the prevoius one......... as far as primary key is concerned it will always be faster cause by deafult the oracle assign the index to the primary key...... so it will again be faster than previous one........ but for this particular query there is no condition specified so again it will have the same performance as the first query but I think second one will be faster |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Which frog is faster? | jamesravid | Aptitude Skills | 13 | 01-29-2009 02:37 AM |
| Running 3 JCL is much more faster than one JCL with three steps | altehexe74 | MainFrame | 1 | 06-11-2007 03:49 PM |
| How many minutes was his clock faster? | jainbrijesh | Brainteasers | 5 | 05-10-2007 06:15 AM |
| Faster technique for Manual Software testing | JobHelper | Testing Issues | 2 | 02-12-2007 06:53 AM |