This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Searching technique used by SQL server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Searching technique used by SQL server" Watch "Searching technique used by SQL server" New topic

Searching technique used by SQL server

sunita shaw
Ranch Hand

Joined: Apr 06, 2003
Posts: 45
When we use " Where " clause with a condition , then what is the searching technique used by SQL server to retrieve the particular data from the database.
Please help , I need it urgent.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

SQL doesn't specify anything about how the database works; it only specifies how to talk to it. Every database will be implemented differently, and closed-source database vendors of course don't share their code or algorithms, so for many databases, the precise answer is not known nor knowable.
But in general, for a WHERE clause that mentions a single column of a single table, the answer depends on whether there's an index on the column or not. If there is, then (depending on the operation used in your WHERE clause, of course) the database will probably be able to do a fast lookup like a binary search to find the matching records. If there's no index, then there isn't much it can do but a linear search through the whole table.
For WHERE x.y == y.z queries (join queries) things are more complicated, of course. There are many whole books written on the topic.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Searching technique used by SQL server
Similar Threads
Struts 2 In Action : Redirect After Post
How to Port Data in a Database to a System where there is no DB Software like SQL Server,oracle
Million record upload and diplay with pagination
Word by word string matching
textfield event handling