Showing posts with label community. Show all posts
Showing posts with label community. Show all posts

Wednesday, March 21, 2012

Database Engine Tuning Advisor gives non existent errors in SQL 2005

Hello,

I am sure you have heard of Community server - if not you are just using it ;)

I decided to try to optimise the performance of my site, run a trace and then DETA.

And I am getting errors like these:


E000 exec dbo.cs_user_Get @.UserName=N'jded',@.UserID=0,@.IsOnline=0,@.LastAction=N'',@.SettingsID=1000 122 [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.cs_user_Get'.
exec dbo.cs_thread_IsTracked @.ThreadID=5969,@.UserID=28236,@.SettingsID=1000,@.IsTracked=@.p4 output
select @.p4 1 [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.cs_thread_IsTracked'.
E000 declare @.p4 bit
set @.p4=0
exec dbo.cs_thread_IsTracked @.ThreadID=414,@.UserID=1001,@.SettingsID=1000,@.IsTracked=@.p4 output
select @.p4 1 [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.cs_thread_IsTracked'.
E000 exec dbo.cs_Section_GetSectionIDByPostID @.SettingsID=1000,@.PostID=44641 1 [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.cs_Section_GetSectionIDByPostID'.


The "trouble" is that those sprocs do exist and that the site apparently is working fine. But not for DETA. As far as DETA is concerned... 54% of my processing power is used to serve syntax errors!

A couple of hints.
The database was an upgrade from 2000.:
- I changed the compatibility level to 2005 but no luck there. I tried with a brand new database, and the errors keep cropping up.
B. The errors were observed in a kit that comprises of a 32bit IIS and 64bit SQL2005 and thought that it had to do with the connectivity of those two.
- I run the traces in one (32bit) server that hosts both IIS and SQL and I am getting the same errors.

Any help will be greatly appreciated.

Thank you.

Which catelog are these stored proc resides? What is the catalog that you are using?|||

Hi!

The database name is CommunityServer - the sprocs reside in it.

It is referenced like this in the web.config:
<add key="SiteSqlServer" value="uid=userXXX;server=SUXXX;pwd=XXXXX;database=CommunityServer;Min Pool Size=5;Max Pool Size=5000;Connect Timeout=20;" />

Does this help you to help me?

Thank you,

Dimitris

|||

The issue has to do with the fact that we use ADO.NET to access the data whereas the tuning advisor uses SQL Native Client and thus it compares the actions to SQLNCLI's syntax.

The team of the tuning advisor should something about it.

|||

Can you please use the -d option (dta.exe) or "Database for Workload Analysis" option in UI to set the database context to the database that contains the stored procedures.

Thanks

Sanjay

|||What if the "Database for Workload Analysis" dropdown is way way way too small to see the entire database name? If I have 50 databases there and they all begin with the same first 20 characters, that's all I can see. How could I possible choose the correct database name in the dropdown?

Database Engine Tuning Advisor gives non existent errors in SQL 2005

Hello,

I am sure you have heard of Community server - if not you are just using it ;)

I decided to try to optimise the performance of my site, run a trace and then DETA.

And I am getting errors like these:


E000 exec dbo.cs_user_Get @.UserName=N'jded',@.UserID=0,@.IsOnline=0,@.LastAction=N'',@.SettingsID=1000 122 [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.cs_user_Get'.
exec dbo.cs_thread_IsTracked @.ThreadID=5969,@.UserID=28236,@.SettingsID=1000,@.IsTracked=@.p4 output
select @.p4 1 [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.cs_thread_IsTracked'.
E000 declare @.p4 bit
set @.p4=0
exec dbo.cs_thread_IsTracked @.ThreadID=414,@.UserID=1001,@.SettingsID=1000,@.IsTracked=@.p4 output
select @.p4 1 [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.cs_thread_IsTracked'.
E000 exec dbo.cs_Section_GetSectionIDByPostID @.SettingsID=1000,@.PostID=44641 1 [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'dbo.cs_Section_GetSectionIDByPostID'.


The "trouble" is that those sprocs do exist and that the site apparently is working fine. But not for DETA. As far as DETA is concerned... 54% of my processing power is used to serve syntax errors!

A couple of hints.
The database was an upgrade from 2000.:
- I changed the compatibility level to 2005 but no luck there. I tried with a brand new database, and the errors keep cropping up.
B. The errors were observed in a kit that comprises of a 32bit IIS and 64bit SQL2005 and thought that it had to do with the connectivity of those two.
- I run the traces in one (32bit) server that hosts both IIS and SQL and I am getting the same errors.

Any help will be greatly appreciated.

Thank you.

Which catelog are these stored proc resides? What is the catalog that you are using?|||

Hi!

The database name is CommunityServer - the sprocs reside in it.

It is referenced like this in the web.config:
<add key="SiteSqlServer" value="uid=userXXX;server=SUXXX;pwd=XXXXX;database=CommunityServer;Min Pool Size=5;Max Pool Size=5000;Connect Timeout=20;" />

Does this help you to help me?

Thank you,

Dimitris

|||

The issue has to do with the fact that we use ADO.NET to access the data whereas the tuning advisor uses SQL Native Client and thus it compares the actions to SQLNCLI's syntax.

The team of the tuning advisor should something about it.

|||

Can you please use the -d option (dta.exe) or "Database for Workload Analysis" option in UI to set the database context to the database that contains the stored procedures.

Thanks

Sanjay

|||What if the "Database for Workload Analysis" dropdown is way way way too small to see the entire database name? If I have 50 databases there and they all begin with the same first 20 characters, that's all I can see. How could I possible choose the correct database name in the dropdown?

Monday, March 19, 2012

Database driven images not showing in non-english systems

I'd like to share with the community the results of 3 days of testings and
headaches. I finally found the reason for the problem and a way to solve it:
As stated in
http://www.microsoft.com/technet/prodtechnol/sql/2000/deploy/migratereports.mspx
dealing with 'How to Migrate Access Reports to Reporting Services', when
talking about database-stored images, the writer (Adam Cogan) says:
[...]
3. Replace the default value in the image Value field with the following
expression as shown in Figure 16:
=System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields!Picture.Value),105))
[...]
However this piece of code does not work under certain conditions. I have
seen several forum pages of people posting they are having the same problem
(see
http://forums.devarticles.com/archive/t-11844/displaying-image-fields-in-reporting-services )
. The former code takes the assumption that the images stored in the
database were saved by a English/American localised application. If you are
using an English version of MS Access, do copy a bitmap file and paste it
into an image field of SQL table (using ADP Access project), MS Access adds
an OLE header and trailer to the image you are storing. In the English case,
the header is 78 bytes and trailer 38 bytes. However, this header is not of
that size if you are using another language. In my case, we use spanish
applications and the OLE header for bitmap files is 88 bytes instead of 78
(the trailer is also 38 bytes but you can forget about it).
If you use the former piece of code in your reports and you are not using an
English OS and applications you will see red crosses on your reports (this
is an assumption of my own because at least in the Spanish case the header
size differs from English; I suppose the same might happen in German,
French, etc.).
The reason of this behaviour is because when converting those 78 bytes of
english header into a Base64 string, it turns to be exactly 104 Base64
chars:
78 bytes * 8 bits each = 624 bits
If you convert that stream of 624 bits using Base64 (6 bits each char):
624 bits / 6 bits = 104 Base64 chars
So the next Base64 char (105) belongs completely to the bitmap file data and
you don't experience any problem if you use the Mid function to cut the
string by 105th char and then FromBase64String to convert the Base64 string
back to a byte() (byte array).
However if you use Spanish applications, the OLE header is 88 bytes (704
bits). If you try to convert that stream of bits into a Base64 string:
740 bits / 6 bits each Base64 char = 123,333... chars
What does it mean? It means that it will use 123 chars and 2 bits of the
next char. The other 4 bits of the 124th Base64 char will have data
belonging to the bitmap file. And here is the tricky part: You CANNOT remove
the OLE header without turning the whole string into rubbish because of
this. Thats why you always see red crosses on your reports no matter the
number you use to remove the OLE header from the Base64 string. No matter if
you use 105, 104, 103, or 123, 124, etc. It will always break the Base64
string and when you convert it back to get the image you will get just
rubish.
THE SOLUTION:
Instead of using Base64 strings to cut the OLE header and try to rebuild the
image, you should use this piece of code in your Image RS components:
=System.Text.Encoding.Default.GetBytes(Mid(System.Text.Encoding.Default.GetString(Fields!Picture.Value),XXX))
Where XXX is the size of the localised OLE header + 1.
For Spanish use XXX = 89
For English use XXX = 79
For other languages you will have to guess (you can do some trial/error
until you find out).
Why is there this difference of sizes in the OLE header? The header contains
the type description of the file (the type column when you see the file
using explorer) using your local language. In Spanish, the default value for
a bitmap file is 'Imagen de mapa de bits' (22 bytes). However in English the
type description for that kind of files (I suppose) is 'Bitmap image' (12
bytes). Hence:
22 - 12 = 10
The OLE header is 10 bytes larger for spanish applications (in the case of
.bmp files). For other type of files the size probably differs (I have not
tested it).
Instead of trial/error to find the XXX value for your local languae you can
try to do this little calculation:
78 + ( length(bitmap type description for your language) - 12) + 1
That's all. Just use:
=System.Text.Encoding.Default.GetBytes(Mid(System.Text.Encoding.Default.GetString(Fields!Picture.Value),XXX))
being XXX the value you have just calculated and forget about the original
Adam's code.
I hope this could help to people experiencing this problem and save their
valuable time. I also hope that Adam Cogan revises his article to replace
his version of the code and explains the restrictions of this alternative
also. People tend to consider documentation under microsoft.com domain to be
fully trustable, but in this case the information was totally wrong for
users that are not using English localised applications.
Regards.Thanks for sharing your findings!
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"David Lightman Robles" <dlightman@.NOSPAMiname.com> wrote in message
news:uyB2AeiVFHA.228@.TK2MSFTNGP12.phx.gbl...
> I'd like to share with the community the results of 3 days of testings and
> headaches. I finally found the reason for the problem and a way to solve
> it:
> As stated in
> http://www.microsoft.com/technet/prodtechnol/sql/2000/deploy/migratereports.mspx
> dealing with 'How to Migrate Access Reports to Reporting Services', when
> talking about database-stored images, the writer (Adam Cogan) says:
> [...]
> 3. Replace the default value in the image Value field with the following
> expression as shown in Figure 16:
> =System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields!Picture.Value),105))
> [...]
> However this piece of code does not work under certain conditions. I have
> seen several forum pages of people posting they are having the same
> problem (see
> http://forums.devarticles.com/archive/t-11844/displaying-image-fields-in-reporting-services )
> . The former code takes the assumption that the images stored in the
> database were saved by a English/American localised application. If you
> are using an English version of MS Access, do copy a bitmap file and paste
> it into an image field of SQL table (using ADP Access project), MS Access
> adds an OLE header and trailer to the image you are storing. In the
> English case, the header is 78 bytes and trailer 38 bytes. However, this
> header is not of that size if you are using another language. In my case,
> we use spanish applications and the OLE header for bitmap files is 88
> bytes instead of 78 (the trailer is also 38 bytes but you can forget about
> it).
> If you use the former piece of code in your reports and you are not using
> an English OS and applications you will see red crosses on your reports
> (this is an assumption of my own because at least in the Spanish case the
> header size differs from English; I suppose the same might happen in
> German, French, etc.).
> The reason of this behaviour is because when converting those 78 bytes of
> english header into a Base64 string, it turns to be exactly 104 Base64
> chars:
> 78 bytes * 8 bits each = 624 bits
> If you convert that stream of 624 bits using Base64 (6 bits each char):
> 624 bits / 6 bits = 104 Base64 chars
> So the next Base64 char (105) belongs completely to the bitmap file data
> and you don't experience any problem if you use the Mid function to cut
> the string by 105th char and then FromBase64String to convert the Base64
> string back to a byte() (byte array).
> However if you use Spanish applications, the OLE header is 88 bytes (704
> bits). If you try to convert that stream of bits into a Base64 string:
> 740 bits / 6 bits each Base64 char = 123,333... chars
> What does it mean? It means that it will use 123 chars and 2 bits of the
> next char. The other 4 bits of the 124th Base64 char will have data
> belonging to the bitmap file. And here is the tricky part: You CANNOT
> remove the OLE header without turning the whole string into rubbish
> because of this. Thats why you always see red crosses on your reports no
> matter the number you use to remove the OLE header from the Base64 string.
> No matter if you use 105, 104, 103, or 123, 124, etc. It will always break
> the Base64 string and when you convert it back to get the image you will
> get just rubish.
>
> THE SOLUTION:
> Instead of using Base64 strings to cut the OLE header and try to rebuild
> the image, you should use this piece of code in your Image RS components:
> =System.Text.Encoding.Default.GetBytes(Mid(System.Text.Encoding.Default.GetString(Fields!Picture.Value),XXX))
> Where XXX is the size of the localised OLE header + 1.
> For Spanish use XXX = 89
> For English use XXX = 79
> For other languages you will have to guess (you can do some trial/error
> until you find out).
> Why is there this difference of sizes in the OLE header? The header
> contains the type description of the file (the type column when you see
> the file using explorer) using your local language. In Spanish, the
> default value for a bitmap file is 'Imagen de mapa de bits' (22 bytes).
> However in English the type description for that kind of files (I suppose)
> is 'Bitmap image' (12 bytes). Hence:
> 22 - 12 = 10
> The OLE header is 10 bytes larger for spanish applications (in the case of
> .bmp files). For other type of files the size probably differs (I have not
> tested it).
> Instead of trial/error to find the XXX value for your local languae you
> can try to do this little calculation:
> 78 + ( length(bitmap type description for your language) - 12) + 1
> That's all. Just use:
> =System.Text.Encoding.Default.GetBytes(Mid(System.Text.Encoding.Default.GetString(Fields!Picture.Value),XXX))
> being XXX the value you have just calculated and forget about the original
> Adam's code.
> I hope this could help to people experiencing this problem and save their
> valuable time. I also hope that Adam Cogan revises his article to replace
> his version of the code and explains the restrictions of this alternative
> also. People tend to consider documentation under microsoft.com domain to
> be fully trustable, but in this case the information was totally wrong for
> users that are not using English localised applications.
> Regards.
>

Friday, February 24, 2012

Database Design Help Required

Hi

I am working on a community site that pretty much works like anyother community site like orkut or myspace..I have few doubts for which i badly need your help.. if you can point me to some usefully links, articles, pdf or your suggestions..i will surely be obiliged.

THE application i am talking about willl be invite only.. and will let the users grow there network of friends... there will be other data associated with each userid like the profile,bookmarks etc etc.. , also there will be aurthorisation based on who are the members friends are who are not...

My problem.. database design

though i am planning ot user MS SQLSERVER 2005 ,, i have not finalised yet.. I want to make up my mind on how to structure the database..also,,if you have seen Orkut.com when you visit a cirten persons profile it shows (trhu a breadcrum like view) how you are connected.. ie.. thru what friend of yours you are connected...

I want to know ,,what kind of mapping is used here... how can i achive that without sacrifising performance,, coz surely thease kind of applications are to be build for VERY LARGE USER BASE...

Please suggest ...I am fighting my war alone..but i am determind.. you can help though. :)

If you go with Sql 2005, you can retreive breadcrumbs in a single query very easy and efficiently.

Say I have a Catalog with the following Categories:

CategoryIDNameParentID0Home-11Aquatic Supplies019Filters120Canister Filters19

If I use the following query against my Categories Table:

WITH Navigation (CategoryID, ParentID, Name, Sequence) AS ( SELECT CategoryID, ParentID, Name, 0 AS Sequence FROM Categories WHERE CategoryID = @.CategoryID AND Disabled = 0 UNION ALL SELECT c.CategoryID, c.ParentID, c.Name, n.Sequence + 1 AS Sequence FROM Categories c INNER JOIN Navigation n ON c.CategoryID = n.ParentID) SELECT CategoryID, Name, ParentID FROM Navigation

WHERE @.CategoryID = 20 and Navigation is a derived table, the results come back like this

CategoryIDNameParentID20Canister Filters1919Filters11Aquatic Supplies00Home-1


This makes it very easy to build breadcrumbs (you can tack on an ORDER BY CategoryID to flip the results).

So if you have a table of related data, replacing the above data:

UserIDNameFriendID0Bob-11Tom019Jerry120John19


And you are looking at John's profile, you can run the above query and trace this back to you "Bob." It's probably a little more in depth than that because not everyone in the table will end up back to a single "Home" friend, but you can probably modify the query statement to know exactly where to stop. I hope this gives you a start.|||

thanks, surely thats a great start.. will get back to this post, once I get my coding done, to post what i did .

thanks again.