Tuesday, April 26, 2005

Day 2, Microsoft Zirvesi 2005

Day 2 of the event. We have a meeting tonight at 6 pm for INETA MEA. But first, we attend a few sessions. Goksin picks us up in his Ford Explorer. We go to the conference meeting. First up is Stephen Forte. Stephen is wild, he's crazy, he's the kind of guy you'd like to hear.
He's doing Data driven caching with data controls using Visual Studio .NET 2003 and 2005
He can be found at this page. He is with the NYC .NET Developer Group.
He has a company called Corzen Inc.
Data caching can really improve the prerformance of a web application and is a very sensible way of scaling a web application without really investing huge amounts in expensive server infrastrcture.
There are two parts to this, one, SQL Server does in-memory data caching for us, two, ASP.NET can be used to cache pages in-memory very very easily and it is highly customizable as well. So here goes.
Using a DataList, which is like a light weight DataGrid. Another thing that will be used is a DataRepeater which is something that repeats a version of HTML format on all records in your data. This is done inside a <HeaderTemplate> tag. Steve's website has several downloadable Repeater controls.

Performance tuning is a very difficult job. How do you trace what you can improve to increase performance? As already mentioned, caching can get you a lot closer a lot easier. It is the least expensive way of increasing performance. How do you use it? Very simple, use the <%@OutputCache%> directive on your page, with which you can specify the caching duration in number of seconds. There are also optional API calls that you can make. No change in code-behind files is needed. With this you could even turn off your SQL Server and the users would be able to use your web application through the cached versions.
But you'd say if it is a dynamic application in which a page is generated based on user input, it wouldnt work? Think again, there is the VaryByParam attribute that you can use to specify that different cached versions would be used based on a certain parameter, for example, which is used in certain SQL queries to fetch data and spit out HTML to the user screen. Also, VaryByHeader and another attribute can be used as well.
How about discarding the cached version when a certain resource changes? Sure you can do that. Even on filesystem objects. That is done with something called file dependency. You specify which file your application depends upon and as long as that file doesnt change, your cached page will be used. As soon as that file changes, your cached pages will be discarded. Marvelous!
This is done with a call to Response.AddFileDependency(Server.MapPath("data.xml")) as an example to watch for changes to a file called data.xml.
You can also add triggers to your database so that a certain extended stored procedure would be called when data in a table changes.
Can you cache only a portion of a page, such as when in an application only a certain portion is fixed while the rest is dynamically generated? Yes, you can, by using a user control. This is called fragmented caching.
SqlDataSource is new with Yukon and Whidbey. GridView can also be used.
can be used in web.config for this.
Scavenging is when your web server goes hunting for memory space and takes up space used for caching.

SQL Server 2005, bridging the gap between the DBA and the developer by Kimberly Tripp

I had viewed a few of her MSDN Webcasts, which is why her name sounded a bell.

ETL (Extract, Transform, Load)

SQL Computer Manager has been replaced with Configuration Manager in Yukon.

One can deploy a database project into SQL Server by using Whidbey, or compile a project to a DLL and ship it to be deployed on the server. The advantage of the former is that everything is backed up and restored during SQL Server backups and restores.
Be careful about SQL CLR, you can build user functions using SQL CLR which is running as managed code. It is a limited version of the .NET CLR, of course. However, it is not advised to develop your full applications this way. It is still better to keep the logic loosely coupled and TSQL still used. There are certain SQL data types which are different from the native .NET data types, for example String vs SqlString. SqlString keeps in mind the NULL value in concatenation. If you concatenate anything with a NULL into a SqlString, the result is NULL, which is the SQL Server behavior, whereas it woudlnt be that way if you used type String.

T-SQL Enhancements in SQL Server 2005 by Stephen Forte

SQL Server versions are codenamed after National Parks in the USA and Yukon is a National Park in Alaska.

XML is a native data type in SQL Server, which means that you can index data inside an XML column, search through it and use it as a reference into other columns or tables. There are two ways to pull XML data from a table:

select * from EmployeeTree for XML raw or select * from EmployeeTree for XML auto

auto is going to keep joins in mind.

select top 5 can be used to pull out the top 5 records froma table. Now it can use a calculated value or a value pulled from another SQL query. The same can be done with inserts, updates and deletes.

Common Table Expressions are like non-persistent views meaning they wouldnt be available to later statements. For example:

with CoolEmployees as (select * from EmployeeTree)

Where clauses can also be used here. One of the main reasons for using CTE is recursive queries.

Ranking and windowing functions. SQL Junkies website has Steve's articles on ranking functions such as this.

Part I of New features in Performance, Manageability and Recovery in SQL Server 2005 by Kimberly Tripps

Check out SqlSkills. Kimberly is back. SqlSkills has a lot of resources, do check it out.
SQL Server can be very stable and with 2005, in the event of damage to the server, you can restore it in most cases, without taking it offline, taking a single database or portions of a database offline. Of course, you can take the entire server offline if you wish, but you dont have to.

Unless your primary data file or log file gets damaged, you dont have to shutdown your server. But if either of these gets damaged, that is serious trouble that can not be restored while online. Damage to secondary data files can be sustained with online recovery.
How we use this facility is by creating separate file groups and placing different objects onto separate file groups. If you wish to put a single object over multiple file groups, you can use schemes.

Part II, not much to write down, it is about scalability in terms of having a primary and a mirror and optionally a witness, which can even be a machine running SQL Server 2005 Express (no licensing required), so that whenever the primary shuts down, the mirror takes over transparently without user interruption. Both primary and mirror can be kept in sync upto the second.

That's the end of the second day's sessions. Now we go upstairs to the INETA MEA meeting. Minutes of that meeting are available elsewhere. Then we go to Hotel Hilton, which is very close to the conference hall. All speakers are staying there.
I had a chat with one of the speakers in the hall. I forgot his name. I'll blog it later. From there we went to a certain historical tower from which the first person flew with wings. We had a multiple course dinner, I missed the count. I took photos from the top of the tower. They started by serving wine. Of course, I refused. Yikes, I started feeling uncomfortable and out of place. Everyone, even people with muslim names were dirnking. Everyone except me. Then there was some show about the Sultan coming to the stage and clapping to call two girls (properly dressed) sit on his sides and he feeds them some fruit or something from a tooth pick. Then he claps and they start dancing. I go, uh oh, let's get out of here. Then it gets worse. The ladies come down and drag a couple of ladies from the audience to the stage and those new ladies sit to the Sultan's side while the professionals dance. May I mention that the dancing girls looked very bored, obviously since they do the same stupid drill every night. So did the Sultan. Then the dancing girls ask the two guests and teach them how to dance.
After that, when I'm thinking it cant get any worse, an almost naked dancer comes on stage and does a dance. I'm like, holy shit, let's get out of here. They bring the main part of the meal, I take it, ask Edgar if he wants to come, he agrees, we tell Goksin, our host and we leave. Kimberly Tripp ceases the opportunity and escapes with us. We take a cab, drop her at the Hilton. She thanks us like a hundred times on the way for saving us from the party that was to go on further in the night for very long and the others were planning to go to a strip club, too. Puke!
What's really gross is that that almost naked dancer went to every table, every chair one after another, stood behind everyone one by one (a bit too close) and a photographer photographed. Yea, yea, I got trapped, too. I didnt even dare to move or look around. I hope they dont mail the photos to my place. I have no news of that photo and hope it gets destroyed or something.
She tries to pay the fare or split, but we refuse to accept that, we get to the hotel at 11 pm and then go to sleep. Escaped!

No comments: