Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#294326 - 27/02/2007 08:57 MS SQL Server 2005 Help
Taym
carpal tunnel

Registered: 18/06/2001
Posts: 2504
Loc: Roma, Italy
This is what happened to me.

A database in MS SQL Server 2005 is being used for a forum software. It's been running flawlessly for years.

In the DB tables, all entries are correct and all messages are there. I can see them.

BUT, for example, when searching for a specific post with a simple query like

SELECT * from pgd_messages where threadId = 10990 (=return all posts belonging to thread 10990)

I only get one record as a result, even though I know and I found other messages being in the threadId 10990 . In other threads I may get more than one results, but not all, and in others I will get all results.
Also, those same messages/entries that are not returned by the query, are not shown in the forum, which is in fact suffering from some "missing message" problem.

What is wrong? I am not an expert in SQL Server, but the problem must not be in the forum software, and more likely be somwhere "between" the table containing all data and some index which is corrupted, and which is used by the SELECT function.

Has this happened to anyone? Any help is greatly appreciated!
_________________________
= Taym =
MK2a #040103216 * 100Gb *All/Colors* Radio * 3.0a11 * Hijack = taympeg

Top
#294327 - 27/02/2007 10:23 Re: MS SQL Server 2005 Help [Re: Taym]
andy
carpal tunnel

Registered: 10/06/1999
Posts: 5915
Loc: Wivenhoe, Essex, UK
When you say "found other messages being in the threadId 10990" how did you "find" them, if it wasn't though a query very similar to the one you say doesn't work ?
_________________________
Remind me to change my signature to something more interesting someday

Top
#294328 - 27/02/2007 14:00 Re: MS SQL Server 2005 Help [Re: andy]
Taym
carpal tunnel

Registered: 18/06/2001
Posts: 2504
Loc: Roma, Italy
Oops, Sorry for not being clear.
I found them by opening the message table itself. It's not a huge forum and with 10 minutes research scrolling the table on the screen I could find them. The records are there, with correct author, message number, thread number, etc.


Edited by taym (27/02/2007 14:02)
_________________________
= Taym =
MK2a #040103216 * 100Gb *All/Colors* Radio * 3.0a11 * Hijack = taympeg

Top
#294329 - 27/02/2007 14:18 Re: MS SQL Server 2005 Help [Re: Taym]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
You need to be more precise. How did you "open the message table"? Did you do a "SELECT * from pgd_messages"? Did you open the raw database file with a binary editor? Is there some sort of direct access utility in MSSQL?
_________________________
Bitt Faulk

Top
#294330 - 27/02/2007 14:55 Re: MS SQL Server 2005 Help [Re: wfaulk]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Quote:
Is there some sort of direct access utility in MSSQL?


If you right-click on a table in SQL Management Studio, you can choose the "Show Table" item, which displays the rows.

I suspect that you've got a corrupted index (which shouldn't happen). I suspect this because a table scan works, but a query (using the index) doesn't. Drop the index and recreate it.
_________________________
-- roger

Top
#294331 - 27/02/2007 14:55 Re: MS SQL Server 2005 Help [Re: wfaulk]
andy
carpal tunnel

Registered: 10/06/1999
Posts: 5915
Loc: Wivenhoe, Essex, UK
I imagine he did "Open table -> return all rows" in SQL Server Enterprise Manager, which basically does a "select * from..." and displays it in grid.
_________________________
Remind me to change my signature to something more interesting someday

Top
#294332 - 27/02/2007 15:18 Re: MS SQL Server 2005 Help [Re: Roger]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Quote:
Drop the index and recreate it.


An extremely similar question just came up here, only with default/non-default collation orders.

Apparently there's a DBCC command that'll cause it to rebuild existing indexes.
_________________________
-- roger

Top
#294333 - 27/02/2007 18:37 Re: MS SQL Server 2005 Help [Re: Roger]
g_attrill
old hand

Registered: 14/04/2002
Posts: 1172
Loc: Hants, UK
It's even a GUI option:

How to: Rebuild an Index (SQL Server Management Studio)
http://msdn2.microsoft.com/en-us/library/ms187874.aspx

Top
#294334 - 27/02/2007 21:35 Re: MS SQL Server 2005 Help [Re: wfaulk]
Taym
carpal tunnel

Registered: 18/06/2001
Posts: 2504
Loc: Roma, Italy
That was it, Roger. The index was corrupted. I dropped it and recreated it, and now everything seems to be working.
Thanks you all for your help.

Quote:
You need to be more precise. How did you "open the message table"?

It's a MSSQLServer feature. You can "show" a table, as Roger described, by simply using a specific GUI option.
Not being a SQL Server expert at all, I too believed that "showing" a table simply meant doing a "select..." .
It seemss that's not the case, instead. While a "select" uses the index (which was corrupted), "showing" a table reads the table directly.

And, thanks a_attrill for pointing to the GUI option to rebuild the index.
_________________________
= Taym =
MK2a #040103216 * 100Gb *All/Colors* Radio * 3.0a11 * Hijack = taympeg

Top
#294335 - 28/02/2007 04:57 Re: MS SQL Server 2005 Help [Re: Taym]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Quote:
I too believed that "showing" a table simply meant doing a "select..." .


It does. It's just that different queries will be optimised differently.

If you do a "SELECT ... WHERE ...", then the query optimiser will attempt to use any relevant indexes that it can find.

If you do a "SELECT * FROM T", then there's no point in using an index (since you're asking for all of the rows, there won't be any speedup). The query optimiser will do a simple table scan, which doesn't use any of the indexes.

This means that, depending on the exact query, and on the volume (and distribution) of data, the query optimiser can do entirely different things in order to find your data.
_________________________
-- roger

Top
#294336 - 28/02/2007 07:01 Re: MS SQL Server 2005 Help [Re: Roger]
andy
carpal tunnel

Registered: 10/06/1999
Posts: 5915
Loc: Wivenhoe, Essex, UK
I very, very nearly suggested that it could be a corrupted index as well. The reason I decided not to mention it is that although I know a corrupted index is theoretically possible I had never actually seen it happen in 10 years of SQL Server usage.

Many of the larger databases I have worked with have regular jobs to rebuild indexes, I guess that is why I have never seen a corruption.


Edited by andy (28/02/2007 07:02)
_________________________
Remind me to change my signature to something more interesting someday

Top
#294337 - 05/03/2007 01:54 Re: MS SQL Server 2005 Help [Re: Roger]
Taym
carpal tunnel

Registered: 18/06/2001
Posts: 2504
Loc: Roma, Italy
Thanks Roger for the explanation.

I just wanted to confirm it was really it. After days of full usage, and several searches of very old and new messages, all seems to be there.

And, for the record, what caused the index to break, I believe, is a bad power failure coupled bwith misconfigured UPS.
_________________________
= Taym =
MK2a #040103216 * 100Gb *All/Colors* Radio * 3.0a11 * Hijack = taympeg

Top