Reputation: 6320
Given a database, a query returns correct output 99% of the time, however 1% of the time, it returns wrong output. What could be the possible reasons?
Upvotes: 3
Views: 1197
Reputation: 8269
There are several reasons why the query return "wrong" or "not expected" result set:
For example, assume that you have a table with 500,000 pages. UserA executes a Transact-SQL statement that requires a scan (and retrieve some records) of the table. When that scan has processed 100,000 pages, UserB executes another Transact-SQL statement that scans the same table. The Database Engine schedules one set of read requests for pages after 100,001, and passes the rows from each page back to both scans. When the scan reaches the 200,000th page, UserC executes another Transact-SQL statement that scans the same table. Starting with page 200,001, the Database Engine passes the rows from each page it reads back to all three scans. After it reads the 500,000th row, the scan for UserA is complete, and the scans for UserB and UserC wrap back and start to read the pages starting with page 1. When the Database Engine gets to page 100,000, the scan for UserB is completed. The scan for UserC then keeps going alone until it reads page 200,000. At this point, all the scans have been completed. More about this optimization here: merry-go-round scanning
If some other ideas comes up - I'll update my post.
Upvotes: 2
Reputation: 295
i think maybe they did not put check for special charactor and 1 % of time user may insert special character.
Upvotes: 1