What is the SQL query for Orchestration debugger information (tracking data) in BizTalk? - biztalk

By using the Orchestration debugger one can get useful time information on the left, regarding entering and leaving shapes. Unfortunately one cannot copy the information from that window. I would like to do some benchmarks and save statistics in Excel.
Does anyone know the sql query to get the same data from the DB? I have tried to find out with SQL Profiler, but did not hit anything that looks like the correct query or stored procedure.
I know I could use BAM, but I just need a quick one for temporary use.

If you are trying to watch with SQL trace be sure you have stopped BizTalk and you are looking at the BizTalkDTADb database otherwise it is guaranteed to be an exercise in futility as BizTalk constantly interacts with SQL Server.
The exact stored procedure it calls to display the orchestration info is dtasp_LocalCallGetActions. You will likely have to do some fancy joins to get some meaningful data out of it. A good place to start is the views in the BizTalkDTADb database which can show the same data you see in the HAT views and will allow you to run the same queries over in query analyzer.

Related

How to implement synchronized Memcached with database

AFAIK, Memcached does not support synchronization with database (at least SQL Server and Oracle). We are planning to use Memcached (it is free) with our OLTP database.
In some business processes we do some heavy validations which requires lot of data from database, we can not keep static copy of these data as we don't know whether the data has been modified so we fetch the data every time which slows the process down.
One possible solution could be
Write triggers on database to create/update prefixed-postfixed (table-PK1-PK2-PK3-column) files on change of records
Monitor this change of file using FileSystemWatcher and expire the key (table-PK1-PK2-PK3-column) to get updated data
Problem: There would be around 100,000 users using any combination of data for 10 hours. So we will end up having a lot of files e.g. categ1-subcateg5-subcateg-78-data100, categ1-subcateg5-subcateg-78-data250, categ2-subcateg5-subcateg-78-data100, categ1-subcateg5-subcateg-33-data100, etc.
I am expecting 5 million files at least. Now it looks a pathetic solution :(
Other possibilities are
call a web service asynchronously from the trigger passing the key
to be expired
call an exe from trigger without waiting it to finish and then this
exe would expire the key. (I have got some success with this approach on SQL Server using xp_cmdsell to call an exe, calling an exe from oracle's trigger looks a bit difficult)
Still sounds pathetic, isn't it?
Any intelligent suggestions please
It's not clear (to me) if the use of Memcached is mandatory or not. I would personally avoid it and use instead SqlDependency and OracleDependency. The two both allow to pass a db command and get notified when the data that the command would return changes.
If Memcached is mandatory you can still use this two classes to trigger the invalidation.
MS SQL Server has "Change Tracking" features that maybe be of use to you. You enable the database for change tracking and configure which tables you wish to track. SQL Server then creates change records on every update, insert, delete on a table and then lets you query for changes to records that have been made since the last time you checked. This is very useful for syncing changes and is more efficient than using triggers. It's also easier to manage than making your own tracking tables. This has been a feature since SQL Server 2005.
How to: Use SQL Server Change Tracking
Change tracking only captures the primary keys of the tables and let's you query which fields might have been modified. Then you can query the tables join on those keys to get the current data. If you want it to capture the data also you can use Change Capture, but it requires more overhead and at least SQL Server 2008 enterprise edition.
Change Data Capture
I have no experience with Oracle, but i believe it may also have some tracking functionality as well. This article might get you started:
20 Using Oracle Streams to Record Table Changes

Entity Framework listening to SQL Server changes

I'm working on the following scenario:
I have a console up that populates a SQL Server database with some data. I have one more web app that reads the same database and displays the data on a front-end. Both of the applications use Entity Framework to communicate with the database (they have the same connection string).
I wonder how can the web app be notified for any changes that have occurred to the database. Bear in mind that the two applications are not referenced, whatsoever.
Is there event provided by EF that fires when some has changes. In essence, I would like to know when a change has happened, as well as, the nature of that change
I had a similar requirement and I solved it using the EF function:
[context].Database.CompatibleWithModel(throwIfNoMetadata: true)
It will return if your model matches the underlying database structure using the metadata table.
Note that I was using a Code First approach.
The msdn definition is below:
http://msdn.microsoft.com/en-us/library/system.data.entity.database.compatiblewithmodel(v=vs.103).aspx
Edit:
Just found an amazing article with a demonstration:
http://blog.oneunicorn.com/2011/04/08/code-first-what-is-that-edmmetadata-table/
This is not something that is related to EF at all. EF is just a library that makes SQL calls and maps them to objects. It has no inside knowledge of the database. As such, when data changes in one application, another application doesn't know unless they query to see if that data changes (and you're not going to be constantly running queries to know that, it's too impractical).
There are, potentially some ways to do this, such as adding triggers to the database, which then call extended stored procs to send messages to the app, but this is a lot of work to go through, and it can possibly compromise the robustness of the database.
There used to be something called Notification Services, but that was deprecated. There's now something called SqlDependency objects, which may help you in some cases.. but it all depends on what you're trying to do exactly.
In any event, it's usually easier to find a different way to do what you want. This is complex topic, and really requires a lot of sql server knowledge.

How do I see the SQL commands issued against ASPNETDB and watch the dataflow?

Just about everything I've seen relating to ASP.Net's Login control treats it like a black box. I'm interested in seeing the SQL commands issued against ASPNETDB and watching the dataflow.
For example, the Login control uses ASPNETDB and stored procedure dbo.aspnet_Membership_FindUsersByName. I'm not clear on how to call the procedure because it expects #PageIndex and #PageSize parameters (#ApplicationName and #UserNameToMatch make sense to me). I would like to read about the procedure or trace it.
Would anyone know of good reading on the topic, or suggest a path to explore the control?
What you are looking for is called a SQL Server Trace. The Graphical User Interface for SQL Traces is SQL Server Profiler. This only ships with certain versions of SQL Server (for instance, if you have SQL Server Express Edition then you will not have SQL Server Profiler, but you will still be able to utilize the Trace stored procedures and database objects).
Using Profiler (or the Trace db objects), you'll be able to filter out certain events and data depending on what you are specifically looking to capture. This will give you all the information you'll need to find out the data being transmitted to and from the server -> client application (or in this case, the ASP.NET application).
The events and data that a Trace puts forth can be extremely daunting, especially if you are new to this (which it sounds like you are) and there are a lot of hits to the database. Learn about the Profiler Templates you can utilize, and the individual Events you can analyze.
If you have access to SQL Server, then fire up the profiler and you can see in real-time the sql statements executed against the db.
Just for good measure a brief step by step guide for starting up profiler.
Starting up SQL profiler
If your using SQL express you may not have profiler, however here's an open source alternative (note. I've never used it)
free profiler
If you set it up to use SQL Server (using aspnet_regsql.exe), you can see the stored procedures it uses.

Number of total select statement for particular web page?

I was wondering what is the easiest way to see total number of database queries from my ASP.Net (.NET 2.0) application.
My application heavily use sql 2005 database because all data are dynamic and everything goes through one connection string in web.config. Connection pooling is enabled there.
So, I am wondering how many select statements are executed for particular page I load in my browser.
I don't care if I can see that information from .net side or from db side as long as I can see only connections to MY database. Not all connections to that db server because I use shared db server and there is a lot of other databases.
The best way to do this is to set up a profiler on your database and then make a single request to your ASP.NET application. The profiler will aggregate any data you wish and you will be able to use that data to determine what queries were sent to SQL Server from your application.
The SQL Server Profiler will list all actions performed on your DB. If you use a different db login name for your project (probably a really good idea if you are not) you can filter so it only shows actions from your login (see Events Selection, Column Filters then Login Name).
Use SQL Profiler. You can configure it to filter by the database you want and to just show select statements.
If you have some sort of database layer in your code, you could modify it to write out a log message every time you run a select statement. Then just load the page once and count the number of log statements. This may or may not work, depending on how your code is structured, but it's an option.
Edit: I misread the question. I thought you had multiple clients connecting to the same database, not the same database server. In that case, a profiler probably is the best choice.
Do you have access to SQL Server Profiler? You can set up traces to monitor this sort of thing by loading a page and looking at the effects in the profiler.
JUst be aware that Profiler can affect performance, so it is best to do this on dev.

What utilities can provide database hits/duration per page?

SQL Server profiler is great for profiling SQL Server performance for web apps. However, when I'm testing my webapp I'd like a summary of database hits/duration per page.
Does anybody know of any utilities for giving you this kind of information?
If you want duration per page, I'd recommand Google Analytics.
If you want a summary of database hits (ie, you run three procedures during one page load so you want to show a count of three) then I would recommend adding auditing code to your sprocs.
Alternately (though more expensively in terms of processing) you could turn on either SQL Profiler or SQL Trace and then track the database hits that way to perform statistical analysis on them.
I would recommend setting a data access routine that will be used for all the site.
This routine/class/or whatever you like could log in the database or in a log all the "hits", their duration, error (is any), timeout, etc.
If you program it properly, you will be able to know how many DB hit / page load, avg(DBHit) + you will get as a free bonus the "longest SProc, shortest, more often called".
The positive side of this is that you don't need to modify any stored proc and you can have a nice little "wrapper" around your access to the DB.
For the "Duration per page", if you go with google analysis you will not be able to merge the information back with what you got on the database server. So I would recommend logging each access to a page in the DB.
Then you can infer that Page1.StartTime = getdate(), Page1.EndTime = (page2.Starttime-1 or session.log_off_time) for example. [This is a little basic but according to your environment you can improve it].

Resources