Showing posts with label followingquery. Show all posts
Showing posts with label followingquery. Show all posts

Friday, March 9, 2012

Inconsistant query results with Count(*)... bad index?

I have a table that seems to have a bad index. When I do the following
query I get inconsistant and needless to say incorrect results.

select count(*) from mytable where mycolumn = 1

If I remove the index from "mycolumn" the query works correctly. If I
add the index back (even with a new name etc...) it doesn't work
right.

Has anyone ran into this? or does anyone know how I can fix this
problem?

It seems that removing the index is not really removing everything
because when I add a new one I get this same problem... btw, this is
isolated to this column on this table. all other indexes within the
database are fine.

Any help would be appreciated.

Thanks,
dharperDharper:

Are you able to recreate this using a simple sample with DDL and data that
you can post?

"dharper" <dharper@.ablesoftonline.com> wrote in message
news:a1ffc0e2.0312180711.505ff5d9@.posting.google.c om...
> I have a table that seems to have a bad index. When I do the following
> query I get inconsistant and needless to say incorrect results.
> select count(*) from mytable where mycolumn = 1
> If I remove the index from "mycolumn" the query works correctly. If I
> add the index back (even with a new name etc...) it doesn't work
> right.
> Has anyone ran into this? or does anyone know how I can fix this
> problem?
> It seems that removing the index is not really removing everything
> because when I add a new one I get this same problem... btw, this is
> isolated to this column on this table. all other indexes within the
> database are fine.
> Any help would be appreciated.
> Thanks,
> dharper