473,700 Members | 2,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very puzzling count

fn
Does anyone have possible explanations for the following results?

select count(*) from tablename
2,500,000
select count(*) from tablename where fieldname is null 2,400,000
select count(*) from tablename where fieldname is not null 900,000


Just my luck, I was showing something to the CFO when I got these
results...

I'd appreciate any hints. Thanks.

fn

Jul 20 '05 #1
5 1362
Hi

You could try DBCC CHECKDB to find any possible corruption.

John

"fn" <f_************ **************@ hotmail.com> wrote in message
news:Lq******** ************@br itsys.net...
Does anyone have possible explanations for the following results?

select count(*) from tablename
>>> 2,500,000
select count(*) from tablename where fieldname is null >>> 2,400,000
select count(*) from tablename where fieldname is not null >>> 900,000


Just my luck, I was showing something to the CFO when I got these
results...

I'd appreciate any hints. Thanks.

fn

Jul 20 '05 #2
Check out MSKB 814509 to see if applies:
http://support.microsoft.com/default...09&Product=sql

As a workaround, you can set 'max degree of parallelism' to 1 or specify a
MAXDOP 1 hint.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"fn" <f_************ **************@ hotmail.com> wrote in message
news:Lq******** ************@br itsys.net...
Does anyone have possible explanations for the following results?

select count(*) from tablename
>>> 2,500,000
select count(*) from tablename where fieldname is null >>> 2,400,000
select count(*) from tablename where fieldname is not null >>> 900,000


Just my luck, I was showing something to the CFO when I got these
results...

I'd appreciate any hints. Thanks.

fn

Jul 20 '05 #3
fn
Thanks for the replies.

The problem was definetely related to indexes and nulls rather than to
data curruption. I tried rebuilding the index but still got erroneous
results. On a hunch, I dropped all indexes and the query returned what
looked like correct results.

Dan, the MS article implies that the bug may not affect every
installation but doesn't provide any hints on how to test for it. Any
thoughts.

Thanks again.

FN

Dan Guzman wrote:
Check out MSKB 814509 to see if applies:
http://support.microsoft.com/default...09&Product=sql

As a workaround, you can set 'max degree of parallelism' to 1 or specify a
MAXDOP 1 hint.


Jul 20 '05 #4
> Dan, the MS article implies that the bug may not affect every
installation but doesn't provide any hints on how to test for it. Any
thoughts.
Try recreating the index in question to see if the problem reoccurs. If you
get incorrect results with the nonclustered index in place, take a look at
the query plan and then repeat with the MAXDOP 1 hint.

I suspect the bug is the culprit if you get wrong results with a parallel
query and the expected results with parallelism off. You can either use one
of the workarounds I suggested or contact PSS for the hotfix.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"fn" <f_************ **************@ hotmail.com> wrote in message
news:65******** ************@br itsys.net... Thanks for the replies.

The problem was definetely related to indexes and nulls rather than to
data curruption. I tried rebuilding the index but still got erroneous
results. On a hunch, I dropped all indexes and the query returned what
looked like correct results.

Dan, the MS article implies that the bug may not affect every
installation but doesn't provide any hints on how to test for it. Any
thoughts.

Thanks again.

FN

Dan Guzman wrote:
Check out MSKB 814509 to see if applies:
http://support.microsoft.com/default...09&Product=sql
As a workaround, you can set 'max degree of parallelism' to 1 or specify a MAXDOP 1 hint.

Jul 20 '05 #5
Hi

You may want to look at the query execution plans to see which/if it is
using an index. You may also way to try

SELECT fieldname, count(*) FROM tablename GROUP BY fieldname

John

"fn" <f_************ **************@ hotmail.com> wrote in message
news:65******** ************@br itsys.net...
Thanks for the replies.

The problem was definetely related to indexes and nulls rather than to
data curruption. I tried rebuilding the index but still got erroneous
results. On a hunch, I dropped all indexes and the query returned what
looked like correct results.

Dan, the MS article implies that the bug may not affect every
installation but doesn't provide any hints on how to test for it. Any
thoughts.

Thanks again.

FN

Dan Guzman wrote:
Check out MSKB 814509 to see if applies:
http://support.microsoft.com/default...09&Product=sql
As a workaround, you can set 'max degree of parallelism' to 1 or specify a MAXDOP 1 hint.

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1440
by: andrea | last post by:
I was thinking to code the huffman algorithm and trying to compress something with it, but I've got a problem. How can I represent for example a char with only 3 bits?? I had a look to the compression modules but I can't understand them much... Thank you very much Any good link would be appreciated of course :)
0
2271
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly delicately balanced and finding my way through it has descended into one of those awful situations which I refer to as guess & test. From the point at which DoDragDrop() function is called until some later
1
2127
by: John Wharmby | last post by:
Hi there, I have been stumped by a where statement! (Thought it would never happen!) I have a database that stores parts of postcodes for a survey to see where our customers have traveled from, and I want to query it to produce count totals in a report. I have already built the report and it works good querying the data as I want it, producing totals per code. However, i don't want the whole lot all the time. When I use a WHERE in...
10
1747
by: Bernard Liang | last post by:
Consider the following excerpt below, with the included relevant declarations. Firstly, the lines marked with **, ***, **** at the beginning are not supposed to have those stars at the beginning; they are only used to direct attention. Suppose, first of all, that the lines with the **** are not present. p_num is somehow getting changed from its previous value to 0 by the sscanf command (***) that doesn't even involve p_num. I cannot
12
20684
by: John | last post by:
I can't get my head around this! I have the following code: <% .... Code for connection to the database ... .... Code for retrieving recordset ... If Not rs.EOF Then ... Do something...
73
2793
by: Rajeet Dalawal | last post by:
Good day group. I was asked in an interview to explain the behavior of this program. void main() { char *s = "abc"; int *i = (int *) s; printf("%x", *i); }
1
2118
by: Chris Dunaway | last post by:
When working with GDI+, calling the CreateGraphics method to draw on a control has normally been frowned upon and it is always emphasized to dispose of pens and brushes and other GDI objects lest you run out. But consider the following code (in a timer elapsed event on a Windows Form): private void TimerFunc(object sender, System.Timers.ElapsedEventArgs e) { Graphics gdi = this.CreateGraphics();
6
7473
by: Terry Carroll | last post by:
I am trying to do something with a very large tarfile from within Python, and am running into memory constraints. The tarfile in question is a 4-gigabyte datafile from freedb.org, http://ftp.freedb.org/pub/freedb/ , and has about 2.5 million members in it. Here's a simple toy program that just goes through and counts the number of members in the tarfile, printing a status message every N records (N=10,000 for the smaller file;...
4
1480
by: jlhsgcib | last post by:
Hello, I have the following snippet of code: sub getPasswordStatus { my ($login, $password) = @_; my$quotedLogin = quotemeta($login);
0
8709
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8638
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9058
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8952
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8909
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4649
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3081
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.